[n] = \x y. xnywhere, for generic lambda terms M and N, MnN represents the term M(...(M(M N))...), i.e. the application of M to N repeated n times. These terms [n] are called Church's numerals.
A partial function f : Nk -> N is lambda-definable if there exists a lambda term [f] such that, whenever f(n1,...,nk) is defined, we have
[f][n1]...[nk] = [f(n1,...,nk)]The equality here is the "lambda-convertibility" (see previous lecture), i.e. the equality in the theory of Lambda Calculus. Note that [f] is curried, i.e. it takes its arguments one by one.
[S][n] = (\z.\x y. x(z x y))[n] = \x y. x([n] x y) = \x y. x(xn y) = [n+1]
[f o (g1,...,gk)] = \x1...xh. [f]([g1]x1...xh) ... ([gk]x1...xh)
f(0) = g (constant)In ML we could define this function as:
f(n+1) = h(n,f(n))
fun f(n) = if n = 0 then g else h(n-1,f(n-1))or equivalently (remember that the syntax for \n. M[n] in ML is fn n => M[n]) :
val rec f = fn n => if n = 0 then g else h(n-1,f(n-1))The meaning of this declaration is that f is a fixpoint of the following functional F:
F = fn f' => fn n => if n = 0 then g else h(n-1,f'(n-1))Namely, f satisfies the equation
f = F(f)We will see that in the lambda calculus it is always possible to define such f (for a given F), namely it is always possible to define the fixpoint of a given function F.