A lot of programming languages (PHP,C++0x,Java...) were just added lambda expression facilities recently.
However their lambda expression definitions usually does not allow direct recursion. But we can always do this:
Define a type
WRAP
that cana) Be constructed from a function closure receives a
WRAP
and returns an generic type. this is equivalent to the surjective condition.b) Be executed with another
WRAP
object and evaluate the function used to construct the object at this point. This is equivlent to a morphism $WRAP \to X^{WRAP}$Now apply the trick garanteed by Lawvere's fixed point theorem, which says every function
X -> X
have a fixed point (of typeX
). Since we don't even know whetherX
have an accessable constructor, the only way we can construct such anX
is by recursion. Implement a function that receive such a function and return the fixed point, now we obtained the Y combinator for the programming language.
See this code review postthis code review post for an instance of how the above trick applies to C++1x.