

The Derivation of Y Combinator - pkrumins
http://www.catonmat.net/blog/derivation-of-ycombinator/

======
fadmmatt
Nifty.

I wrote up an alternate derivation based on fixed points for my compilers
students:

[http://matt.might.net/articles/implementation-of-
recursive-f...](http://matt.might.net/articles/implementation-of-recursive-
fixed-point-y-combinator-in-javascript-for-memoization/)

It also shows how to exploit the Y combinator to get speed-ups from
memoization in JavaScript.

~~~
scott_s
You gave one of my two favorite talks at PLDI 2006. I have to admit I don't
remember most of the technical content now, but damn were you enthusiastic
about it. ("And now, _super_ beta!") I also remember the talk because you only
found out the day before that you were doing it - I think your adviser had
just gone to the ER.

HN has had some growing pains, but there's still something special here.

~~~
fadmmatt
Stay tuned: I'll be giving another crazy lambda talk at PLDI 2010 this summer.

------
btilly
For yet another alternate derivation, see [http://www.mail-archive.com/boston-
pm@mail.pm.org/msg02716.h...](http://www.mail-archive.com/boston-
pm@mail.pm.org/msg02716.html). I find that one the easiest to understand,
possibly in part because it is the one that I came up with. :-)

------
calcnerd256
I prefer to start with two definitions and an assumption:

Yf = f(Yf) for all [combinators] f, defines the desired behavior of Y

Mx = xx for all [combinators] x (note that M then equals SII in SKI combinator
calculus)

assume there exists a y such that My = Y

proceeding from there, I can derive Y without having to memorize it

~~~
pkrumins
Can you show the derivation steps you take?

~~~
calcnerd256
Sure.

    
    
      Myf = f(Myf)
      yyf = f(yyf)

Suppose yxf = f(xxf) for all x. Now y is simply

    
    
      (lambda x f . f(xxf))

Note that this doesn't get you the applicative-order version we want, but it
does satisfy the definition of Y

    
    
      My = (lambda x . x x) (lambda x f . f (x x f))
      = (lambda x f . f (x x f)) (lambda x f . f (x x f))
      = (lambda f . f ((lambda a g . g (a a g)) (lambda a g . g (a a g)) f))
    

etc.

------
Panoramix
That's kind of beautiful. Non-programmer here, so can somebody point me to an
application of these beasts? can I use this kind of thing to e.g., speed up
something? Not that it would have less merit otherwise. Stretching my brain is
already nice in itself.

~~~
mbrubeck
Fixed-point combinators are useful for memoizing or otherwise modifying
recursive functions: [http://matt.might.net/articles/implementation-of-
recursive-f...](http://matt.might.net/articles/implementation-of-recursive-
fixed-point-y-combinator-in-javascript-for-memoization/)

------
amix
A derivation of Y Combinator in JavaScript (using the fac function):
<http://amix.dk/blog/post/19239>

