From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.science.mathematics.categories/157 Path: news.gmane.org!not-for-mail From: Thorsten Altenkirch Newsgroups: gmane.science.mathematics.categories Subject: Re: Functions in programming Date: Sat, 14 Mar 2009 17:39:47 +0000 Message-ID: Reply-To: Thorsten Altenkirch NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1237126993 12058 80.91.229.12 (15 Mar 2009 14:23:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Mar 2009 14:23:13 +0000 (UTC) To: Andrew Stacey , Original-X-From: categories@mta.ca Sun Mar 15 15:24:29 2009 Return-path: Envelope-to: gsmc-categories@m.gmane.org Original-Received: from mailserv.mta.ca ([138.73.1.1]) by lo.gmane.org with esmtp (Exim 4.50) id 1LirGO-00031z-A6 for gsmc-categories@m.gmane.org; Sun, 15 Mar 2009 15:24:28 +0100 Original-Received: from Majordom by mailserv.mta.ca with local (Exim 4.61) (envelope-from ) id 1LiqRJ-0006gp-6w for categories-list@mta.ca; Sun, 15 Mar 2009 10:31:41 -0300 Original-Sender: categories@mta.ca Precedence: bulk Xref: news.gmane.org gmane.science.mathematics.categories:157 Archived-At: There really shouldn't be a difference between the functions in Mathematics and in Computer Science, especially functional programming. However, there may be some historic differences. Many Mathematicians still use classical set theory, where the set of functions is a derived concept (i.e. a relation which has certain properties) while in constructive theories (such as Type Theory) as in functional programming, functions are a primitive concepts and they are always computable (I like to say that a function which isn't computable doesn't really function :-). Another potential confusion is that functional programming languages allow the definition of partial functions which may not be terminating. However, I think this is an unnecessary complication because non-termination is just a bug and we are really only interested in the total functions anyway. A constant function in functional programming as in set theory is a function which always returns the same value. And clearly there is only one function from the empty set into any set, because any two functions are equal if they agree on all inputs and hence this statement is vaccously true here. The problem in understanding this is the usual trouble in understanding "ex falso quod libet". Cheers, Thorsten On 13 Mar 2009, at 11:29, Andrew Stacey 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 > > This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.