Talk:Haskell/Graph reduction

Explain Confluence?
Should we note that reduction is confluent, or rather that it might be imaginable that it's not? Arguably, this is assumed intuitively and an explanataion only eats space but doesn't add additional insights. Unless there's either an informal proof or a good non-confluent example, I wouldn't mention confluence at all. --apfe&lambda;mus 10:34, 20 June 2007 (UTC)

''So far, we implicitely assumed that every sequence of reductions would yield the same normal form. After all, we're replacing equals by equals and the result should be the same. But "equal" only means that we can convert from one to the other by expanding function definitions or abstracting a given expression into a function application, there is no guarantee that always applying only one direction of the equivalence will lead to a unique normal form. Of course, intuition tells us that for expanding function applications, this should nevertheless be the case and we can in fact rely on the following''


 * Theorem: Every Haskell expression has at most one normal form, i.e. the order of reduction doesn't change the result.

''This follows more or less from the Church-Rosser theorem stating that the untyped lambda-calculus is confluent. We will not proof this here, but to appreciate the result, we'll show an example of a term rewriting system that does not enjoy unique normal forms.''

Show the example!


 * The confluence theorem is of interest when studying deeply lambda-calculus and reduction strategies of lambda-terms; however, it has a nontrivial part, mentioning that every 'terminating' sequence of reduction leads to the same normal form. But $$(\lambda x y. x) 1 \Omega $$ terminates only with a call-by-name strategy (like Haskell's one), not with a call-by-value one.
 * Reduction order is also important for infinite data structures.
 * So, what you say is correct as long as the reduction strategy is lazy.
 * --Blaisorblade (talk) 15:52, 6 January 2008 (UTC)

Solutions to Graph reduction exercises
There ought to be a tool that automatically generates solutions to these exercises, so that we don't have to do it ourselves. -- apfe&lambda;mus 13:58, 21 June 2007 (UTC)

Supercombinators means Combinatory logic?
The page mentions supercombinators about GHC implementation. Are you talking about the ones in: http://en.wikipedia.org/wiki/Combinatory_logic ?
 * Yes, pretty much. Apparently, this wikibook section is not written yet, the todo notes just track what I have in mind for it. The notes are based on SPJ's book chapter 13, in particular 13.2.1.

The question arises since I've read in http://www.cl.cam.ac.uk/teaching/Lectures/founds-fp/Founds-FP.ps.gz (lecture notes of a Cambridge course) about the work of David Turner (also mentioned in the above wikipedia article), who used them to implement graph reduction. The naive approach exposed in the article does not work well because the graph representing a function may be shared, so you must either copy the graph before starting reductions, or use combinators (I've not yet fully understood the solution).
 * It's actually fairly simple. For evaluating something like, there are several options:
 * Copy the body  and replace every occurrence of x with 5.
 * Evaluate the body  while keeping in mind that   (environment).
 * Defer the "keep in mind" part to the lambda expression, i.e. use (super-)combinators which looks like . In other words, instead of storing expressions as , store them as  . This is pretty neat and thus that's how ghc and others do it.
 * Btw, thanks for your lecture notes, I think they make a very good reference concerning lambda calculus for the wikibook.
 * -- apfe&lambda;mus 10:17, 6 January 2008 (UTC)