categories - Category Theory list
 help / color / mirror / Atom feed
From: Charles Wells <charles@abstractmath.org>
To: Andrew Stacey <andrew.stacey@math.ntnu.no>, catbb <categories@mta.ca>
Subject: Re:  Functions in programming
Date: Fri, 13 Mar 2009 21:21:43 -0500	[thread overview]
Message-ID: <E1LiUbV-0000rq-7o@mailserv.mta.ca> (raw)

In terms of common mathematical usage, the student was wrong to say
that a constant function is a function with no input.  A constant
function can be defined on any domain; its defining characteristic is
that it has the same value for every input.

In categorical terms, a constant function is a function that factors
through the terminal object.  The empty function to an object should
be defined as the unique function from the initial object to that
object, but I am not claiming that is common usage.

Some computer languages do indeed have functions with no inputs.
Their output can still vary since the definition may contain global
variables.   No doubt objects (in the sense of OOP) with global
variables can be modeled as objects in a slice category but now I am
out of my depth, so I will stop.

Charles Wells

On Fri, Mar 13, 2009 at 6:29 AM, Andrew Stacey
<andrew.stacey@math.ntnu.no> wrote:
> Here's a question for those who know about translating between category theory
> for mathematicians and category theory for computer programmers.
>
> In class today I was discussing functions with domain the empty set.  The
> students don't have much background in formal set theory (and none in category
> theory though I'm doing my best to sneak it in where I can) so they were
> trying to get to grips with the idea that the _are_ functions from the empty
> set, but just not very many of them.
>
> Afterwards, one student asked about how this related to functions as used in
> computer programming.  It seemed from what he said that he had some
> understanding of the formal relationship between functions in mathematics and
> functions in computer programs - beyond them having the same name.  He said
> that a function that takes no input is known as a "constant function" and so
> wasn't sure how to fit the two notions together.
>
> I, on the other hand, am at the level of "Ooo, look!  Mathematicians and
> computer programmers both use the word 'function'.  So do biologists and event
> organisers.  Maybe we should organise a function whose function would be to
> investigate all these different uses.' so I didn't know what answer to give.
>
> The best that I could think of was that program functions have a 'hidden'
> input: the fact that they have been called.  So a function defined on the
> empty set corresponds to a function that can never be called.
>
> Can anyone help me straighten this out?
>
> Extra kudos for answers that I can just pass on to the student!
>
> Thanks,
>
> Andrew Stacey
>
>
>



-- 
professional website: http://www.cwru.edu/artsci/math/wells/home.html
blog: http://sixwingedseraph.wordpress.com/
abstract math website: http://www.abstractmath.org/MM//MMIntro.htm
astounding math stories: http://www.abstractmath.org/MM//MMAstoundingMath.htm
personal website:  http://www.abstractmath.org/Personal/index.html




             reply	other threads:[~2009-03-14  2:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-14  2:21 Charles Wells [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-03-21 16:06 Bill Lawvere
2009-03-20 21:18 Robin Cockett
2009-03-19 15:37 Peter Selinger
2009-03-19 15:37 Peter Selinger
2009-03-19 14:18 Peter Selinger
2009-03-19 14:11 MigMit
2009-03-19  2:32 Robin Cockett
2009-03-18 15:34 Bill Lawvere
2009-03-17 23:06 Robin Cockett
2009-03-17  5:17 Nathan Bloomfield
2009-03-16 15:12 Andrew Stacey
2009-03-16 11:37 Miles Gould
2009-03-16  9:27 Tom Hirschowitz
2009-03-16  5:52 Vaughan Pratt
2009-03-16  4:25 Daniel Schüssler
2009-03-15 23:55 Thorsten Altenkirch
2009-03-15 22:18 Robin Cockett
2009-03-14 19:52 Ellis D. Cooper
2009-03-14 17:39 Thorsten Altenkirch
2009-03-14 14:58 Steve Stevenson
2009-03-14 14:51 Miguel Mitrofanov
2009-03-14  9:51 Luis Barbosa
2009-03-14  6:02 Vaughan Pratt
2009-03-14  3:38 Fred E.J. Linton
2009-03-14  3:22 Michael Shulman
2009-03-13 11:29 Andrew Stacey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1LiUbV-0000rq-7o@mailserv.mta.ca \
    --to=charles@abstractmath.org \
    --cc=andrew.stacey@math.ntnu.no \
    --cc=categories@mta.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).