Fall 2001, CSE 520: Lecture 2

The Semantics of the Lambda Calculus (Cont'ed)

Some examples of lambda conversion

Example 1

Consider the lambda term
   M = (\x.x (\y.y))(\z.z)w
We get the following lambda conversions:
     (\x.x (\y.y))(\z.z)w
   = (\z.z)(\y.y)w    by beta conversion on (\x.x (\y.y))(\z.z) and by Congruence 1
   = (\y.y)w          by beta conversion on (\z.z)(\y.y) and by Congruence 1
   = w                by beta conversion
Note that there were other possibilities. For instance, at the second step, we could have applied beta conversion on \x.x (\y.y). It is easy to see, however, that the final result would have been the same (w). This is not a coincidence: in general, all ways of converting a term bring to the same reult. We will study in more detail this property, called "confluence", in some future lecture.

Note that we *cannot* apply beta conversion to the subterm (\z.z)w In fact, according to the prentheses convention, the structure of M is the following:

   ((\x.x (\y.y))(\z.z))w

Example 2

Consider the lambda term
   N = (\z.z)((\x.(\y.y)x)w)
We get the following lambda conversions:
   = (\z.z)((\x.x)w)  by beta conversion on (\y.y)x, the rule xi, Congruence 1 and Congruence 2
   = (\z.z)w          by beta conversion on (\x.x)w and by Congruence 2
   = w                by beta conversion
Again, this is only one of the possible conversion sequences.

By using transitivity and symmetry we can derive also that

   M = N

Expressiveness of the Lambda Calculus

We will focus now on the computational power of the Lambda Calculus. We will show that the Lambda Calculus is computationally complete, in the sense that it is able to express all computable functions.

As a definition of computable function, we will use the system of "Recursive Functions" defined by Gödel in 1931.

Recursive Functions

The recursive functions are defined by using a few basic functions (also called initial functions or elementary functions) and a few rules for defining new functions from the already defined ones.

Initial functions

Rules for defining new functions


Given f : Nk -> N and g1,...,gk : Nh -> N, the function f o (g1,...,gk) : Nh -> N (composition of f and g1,...,gk) is the function defined as
(f o (g1,...,gk)) (n1,...,nh) = f(g1(n1,...,nh),..., gk(n1,...,nh))
Example: the function f(n) = n + 2 can be defined as the composition of the successor function with itself, namely f = S o S.

Primitive recursion

Given g : Nk -> N and h : Nk+2 -> N, the function f : Nk+1 -> N is defined by primitive recursion from g and h if the following equalities hold:
f(0,n1,...,nk) = g(n1,...,nk)
f(n+1,n1,...,nk) = h(n, f(n,n1,...,nk), n1,...,nk)
  1. The function plus(n,m) = n + m can be defined by primitive recursion from g = U11 and h = S o U32.
  2. The function times(n,m) = n * m can be defined by primitive recursion from g = Z and h = plus o (U33, U32).


Given g : Nk+1 -> N, the function f : Nk -> N is defined by minimalization from g if the following holds:
f(n1,...,nk) = mu n. (g(n,n1,...,nk) = 0)
where mu is the minimalization operator: mu n. P(n) returns the least natural number n such that P(n) holds. If such n does not exists, then the result is undefined.

Note that f could be computed by general iteration, i.e. using a while loop of the form

n := 0; while (g(n,n1,...,nk) <> 0) do n := n+1;

Example: Consider the function log2 n = k, where k is the number, if it exists, such that 2k = n (the result is undefined otherwise). Then log2 can be defined by minimalization from the function g(k,n) = | 2k - n |, where | m | represents the absolute value of m.

Definition The set of Recursive Functions is the smallest set which contains the initial functions and is closed w.r.t. composition, primitive recursion, and minimalization.

If we exclude minimalization from this construction, we get the set of Primitive Recursive Fuctions, which are all total. Minimalization is the only operator which introduces non-termination, i.e. partiality.