Docsity

Lambda Calculus Homework 2: Solving Lambda Expressions and Combinators - Prof. Jeffrey S. , Assignments of Programming Languages

Toggle sidebar
bg1
CMSC 330
Homework 2
Due: December 4, 2006
Lambda Calculus Problems
1. Apply β-reduction to each of the following λ-expressions until no more beta reductions can be
applied:
(a) (λ x.xx)( λ y.yx)z
(b) (λ x. (λ y. (x y)) y) z
(c) ((λ x.xx)(λ y.y))(λ y.y)
(d) (( (λx. λy. (x y)) (λ y.y)) w)
2. Consider the λ-expression (λ x.y)(( λ y. y y y)( λ x. x x x))
(a) Show that this expression has multiple reduction sequences, some infinite and some finite.
(b) What is the reduced value of a finite reduction sequence? (All finite reduction sequences
have the same result.)
3. Here are three important combinators, which are lambda terms with no free variables:
I = λx.x,
K = λx. λy. x
S = λx. λy. λz.(xz(yz)).
I is the identity function, and K is the function of two arguments that ignores its second argument
and returns its first. It can be shown that any combinator can be generated from S and K using
only function application. Verify that SKK reduces to I.
4. Using the definitions of true, false, and and given in class (see slides), show that and behaves
correctly as a logical “and” function.
5. We say that f and λx.fx are extensionally equivalent if x does not occur free in f. Which of the
following λ-expressions are extensionally equivalent, and why or why not?
(a) (λx.(square x)) and square
(b) λx.((λy. (f x y)) x) and λy.(f x y)

Partial preview of the text

Download Lambda Calculus Homework 2: Solving Lambda Expressions and Combinators - Prof. Jeffrey S. and more Assignments Programming Languages in PDF only on Docsity!

CMSC 330

Homework 2 Due: December 4, 2006 Lambda Calculus Problems

  1. Apply β-reduction to each of the following λ-expressions until no more beta reductions can be applied: (a) (λ x.xx)( λ y.yx)z (b) (λ x. (λ y. (x y)) y) z (c) ((λ x.xx)(λ y.y))(λ y.y) (d) (( (λx. λy. (x y)) (λ y.y)) w)
  2. Consider the λ-expression (λ x.y)(( λ y. y y y)( λ x. x x x)) (a) Show that this expression has multiple reduction sequences, some infinite and some finite. (b) What is the reduced value of a finite reduction sequence? (All finite reduction sequences have the same result.)
  3. Here are three important combinators , which are lambda terms with no free variables: I = λx.x, K = λx. λy. x S = λx. λy. λz.(xz(yz)). I is the identity function, and K is the function of two arguments that ignores its second argument and returns its first. It can be shown that any combinator can be generated from S and K using only function application. Verify that SKK reduces to I.
  4. Using the definitions of true , false , and and given in class (see slides), show that and behaves correctly as a logical “and” function.
  5. We say that f and λ x_._ fx are extensionally equivalent if x does not occur free in f. Which of the following λ-expressions are extensionally equivalent, and why or why not? (a) (λx.(square x)) and square (b) λx.((λy. (f x y)) x) and λy.(f x y)