You may work singly or in pairs on this assignment.
Note: It is OK to use any of the lambda-calculus evaluators to check your work for these problems.
But you'll have to do some of this on the next test, so please, please, please work them out by hand first.
Note: Typos in Exercises 1c, 1d, and 3a have been fixed.
… and in Exercise 1b.
(28 points) Do the following substitutions. Do not change any bound variables unless the substitution requires it.
(w y)[(x z)/w]
(lambda (y) (((x y) t) (x
w)))[(t
x)/x]
(t (z y))[(x
z)/w]
((lambda (y)((x y) t)) (w
x))[(t
x)/x]
(lambda (w) (w
y))[(lambda (w)
w)/y]
((w x) (lambda (u) (t
x)))[(u
t)/x]
((lambda (r) ((r x) (lambda (t) (y
t)))))[(r
t)/x]
(12 points) For each of the following expressions, alpha-convert the leftmost y to t.
(lambda (y) ((lambda (y) (x y)) (w y)))
(lambda (y) ((lambda (t) (y t)) (y t)))
(12 points) Use the normal-order reduction scheme to beta-reduce the following two expressions to normal-form. In each step do only one beta-reduction and underline the redex you are reducing.
((lambda (t) ((x z) (z x))) (((lambda (z) (lambda
(u) (u z))) t) z))
((lambda (t) (t t)) ((lambda (z) (t z)) x))
(12 points) Use the applicative-order reduction scheme to beta-reduce the following two expressions to normal-form. In each step do only one beta-reduction and underline the redex you are reducing.
(36 points) Write two Scheme procedures:
find-norm-redex exp (in abstract
syntax form) and returns the
redex
that would be reduced first under
normal-order reduction. If the expression does not
contain an redex, the procedure should return
#f; and
find-app-redexfind-norm-redex
except for
applicative-order reduction.
> (define exp1 '(lambda (x) ((lambda (y) (x y)) ((lambda (z) z) (t y)))))
> (define display-result
(lambda (exp)
(if exp (unparse exp) #f)))
> (display-result (find-norm-redex (parse exp1)))
((lambda (y) (x y)) ((lambda (z) z) (t y)))
> (display-result (find-app-redex (parse exp1)))
((lambda (z) z) (t y))
> (display-result (find-norm-redex (parse '(lambda (x) (x y)))))
#f
> (display-result (find-app-redex (parse '(lambda (x) (x y)))))
#f
As you no doubt figured out, this is the part you will need to build
on the code in
lambda-calc.scm.