You are on page 1of 2

CS 6371Advanced Programming Languages

Homework 2 Solutions

Problem 1
Given the definitions of the combinators S,K and I in class show that:
a. KKK = K
b. SKKK = K
a.
S xyz. xz (yz)
K xy. x
I x. x
KKK = (xy.x)( xy.x)( xy.x)
= (y. xy. x)( xy.x)
= (xy.x)
=K
b.
SKKK = (xyz. xz ( yz))( xy.x)( xy.x)( xy.x)
= (yz. (xy.x)z (yz))( xy.x)( xy.x)
= (yz. (y.z)(yz))( xy.x)( xy.x)
= (yz. z)( xy.x)( xy.x)
= (z. z)( xy.x)
= (xy.x)
=K
Problem 2
a. Simplify the following lambda expressions to their normal forms.
i.((x. (x y))( z. z))
(z. z)y
y
ii.((x. ((y. (x y))x))( z. w))
(y. (((z. w) y) (z. w)))

((y. w)( z. w))


w
iii. ((((f. (g. (x. ((f x)(g x)))))( m. (n. (n m))))( n. z))p)
(g. (x. (((m. (n. (n m))) x)(g x))( n. z))p)
(x.((( m. (n. (n m)))x)( n. z))p)
(x.(( n. n (n. z))x)p)
((x. (n. z) x)p)
zp
iv.((x.(x x))( x.(x x)))
This lambda expression does not have a normal form.
v.((f. ((g. ((f f) g))( h.(k h))))( x. (y. y)))
(g. ((((x. (y. y))( x. (y. y))) g) (h.(k h))))
(g. (((x. (y. y)) g) (h.(k h))))
(x. (y. y)) (h.(k h))
h.(k h)
vi. (g. ((f. ((x. (f (x x)))( x. (f (x x)))))g))
This lambda expression does not have a normal form.
b. Redo the simplifications using the -rule and the -rule.
The places where the -rule can be applied in problems i-vi have been underlined above.

You might also like