Recall that we have already fixed the following definitions:
The function succ is the encoding for the initial function Successor. We can define encodings for the other initial functions Zero and Projection as follows:
Similarly, the composition of functions is easily defined in the lambda calculus. What remains is to encode primitive recursion and minimalization. We begin by defining encodings for constructing pairs and projecting out the components of a pair.
Observe that
. Similarly, we can
show that
.
We now show how to encode primitive recursion. For notational simplicity, we restrict ourselves to the case where the function being defined by primitive recursion has just one argument. Thus, the definition of primitive recursion becomes
Observe that is just a constant--that is, some fixed number . Inductively assume that is a function defined by the lambda expression --in other words, for all numbers and , . The aim is to come up with a lambda expression defining , such that for all , .
Consider the function . Then, can be defined by primitive recursion as follows:
This is a simpler form of primitive recursion called iteration--think of it as repeatedly iterating a step function starting with . (In programming language parlance, this is equivalent to translating a top-down recursive definition into an equivalent bottom-up iterative one).
The step function is lambda-definable by the following expression:
We can check that .
The encoding for is as follows:
We can check that for all , .
Since is , is the following expression:
It is immediate that for all , .
Collapsing all the steps we have seen above, we can write down an expression that constructs a primitive recursive definition from the functions and :
We could also have used recursive definitions of lambda experssions to encode primitive recursion. Recursive definitions can also be used to define minimalization. It turns out that every recursive definition in the lambda calculus can be ``solved'' by finding its fixed point.