

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


This assignment is due on Tuesday, November 22, 2005.
In lecture I presented five schemas for defining primitive recursive functions. They are as follows:
Zk(x 1 ,... , xk) = 0
S(x) = x + 1
P (^) ik (x 1 ,... , xk) = xi where k > 0, i ≤ k
f ◦lk [g 1... gk](x 1 ,... , xl) = f (g 1 (x 1 ,... , xl),... , gk(x 1 ,... , xl))
PRk[g, h](0, x 2 ,... , xk) = g(x 2 ,... , xk) PRk[g, h](x + 1, x 2 ,... , xk) = h(x, PRk[g, h](x, x 2 ,... , xk), x 2 ,... , xk)
In lecture we showed how to define addition by primitive recursion:
PR^2 [P 11 , S ◦^31 [P 23 ]]
Using primitive recursion define:
(a) BEQ[P] = ∃x < y.P(x) (b) BUQ[P] = ∀x < y.P(x) Define these as functions of y. My solution uses primitive recursion on y, so the order of arguments is y first, x second. It helps to define if-then-else and “boolean” functions (I use 0 for false and 1 for true) first.
2 Lambda Calculus
Terms in the lambda calculus are either variables, lambda-abstractions, or ap- plications. Application associates to the left, that is mno is associated ((mn)o). The dot in lambda abstraction is a left parenthesis that extends as far to the right as possible. Hence, λx.λy.mno is (λx.(λy.((mn)o))). The first rule (α) states formally that variable names do not matter: λx.M = λy.M [y/x] provided y does not occur free in M. The second rule (β) embodies the basic mechanism for function application, in which the formal parameter is replaced by the actual parameter.
(λx.M )N = M [N/x] Both rules rely on substitution, which is defined as follows: z[M/x] = z if x 6 = z x[M/x] = M if x = z (λy.N )[M/x] = λz.(N [z/y][M/x]) where z is a new variable that is distinct from x and does not oc- cur in N and is not free in M. (N 1 N 2 )[M/x] = (N 1 [M/x])(N 2 [M/x])
The treatment of variable renaming prevents capture of bound variables. It is sometimes necessary to do all of the renaming suggested by the definition. Often in calculation it is useful to preserve names if they do not cause conflict.