Computer Science 591i
Recursion in the Lambda Calculus

The fixed-point combinator lets us recurse

A programming language has to allow us, in some sense, to perform an action repeatedly. In imperative languages you will have met constructs like while and {\bf for} loops. It is not immediately apparent that the -calculus has equivalent power, but it does!

Let us suppose we have an operator Y which acts upon expressions of the -calculus according to the rule

Doing the factorial function with Y

Consider the expression

For some variable n

using -reduction we obtain:

again using -reduction we obtain: that is to say, YF satisfies the equation usually given for the factorial function

YE is a fixed point of E

We say that YE is a fixed point of E, and we call Y a fixpoint combinator.[There is an interesting analogy in linear algebra - let \cal E be a function which returns the eigenvectors of a matrix. Then A(\cal E A) \equiv \cal E A, where vectors are equivalent if they have the same direction. Thus eigenvectors are a fixed point of the matrix. Indeed, if we take A to be a linear function over projective space, then \cal E is a fixpoint combinator in the same sense as Y]

Working out the factorial function

For an exercise, let us evaluate YF for a few natural numbers:

But we have freedom in where to reduce

Note that where chose to apply our reduction rules is significant in working out YF. For example, we could have chosen to expand using YF = F(YF), and gone on forever. In the next section we will consider reduction strategies.

We can define Y in -calculus!

Up to now we have supposed that Y is an operator that we have made available as an addition to the -calculus. But it is not! We can define it as an expression in the -calculus: It is left as an exercise to the reader to verify that, for any expression E of the -calculus, YE = E(YE), where Y is defined as above.