Docsity

CS 421 - Lambda Calculus Homework 3 - Prof. Elsa Gunter, Assignments of Computer Science

Toggle sidebar
bg1
HW 3 – Lambda Calculus
CS 421 – Spring 2007
Revision 1.0
Assigned Wednesday, April 4. 2007
Due Wednesday April 11, 2007, 9:00 AM - in class
Extension 48 hours (20% penalty)
1 Change Log
1.0 Initial Release.
2 Turn-In Procedure
Your answers to the following questions are to be hand-written neatly or printed on one or more sheets of paper, each
with your name in the upper right corner. The homework is to be turned in in class at the start of class. Alternately,
you may hand it to Prof. Elsa Gunter in person before the deadline.
3 Objectives and Background
The purpose of this HW is to test your understanding of:
•Alpha and beta conversion in the lambda calculus
•The consequences of different evaluation schemes
•How to represent datatypes in the lambda calculus
Another purpose of HW3 is to provide you with experience answering non-programming written questions of the
kind you may experience on the final.
4 Problems
1. (15 pts) Prove that λx.λy.λz.xy(xz )is α-equivalent λy.λz.λx.yz(yx)
2. (45 pts) Given the following term:
(λn.λm.λf.λx.n(mf )x)(λf.λx.x)((λn.λf .λx.f(nfx))(λf .λx.x))
reduce this term as much as possible using each of
a. eager evaluation
b. lazy evaluation
c. unrestricted αβ-reduction (i.e. by αβ conversion that can be applied anywhere)
Label each step of reduction with the rule justifying it. You do not need to label uses of congruence.
1
pf2

Partial preview of the text

Download CS 421 - Lambda Calculus Homework 3 - Prof. Elsa Gunter and more Assignments Computer Science in PDF only on Docsity!

HW 3 – Lambda Calculus

CS 421 – Spring 2007

Revision 1.

Assigned Wednesday, April 4. 2007

Due Wednesday April 11, 2007, 9:00 AM - in class

Extension 48 hours (20% penalty)

1 Change Log

1.0 Initial Release.

2 Turn-In Procedure

Your answers to the following questions are to be hand-written neatly or printed on one or more sheets of paper, each with your name in the upper right corner. The homework is to be turned in in class at the start of class. Alternately, you may hand it to Prof. Elsa Gunter in person before the deadline.

3 Objectives and Background

The purpose of this HW is to test your understanding of:

  • Alpha and beta conversion in the lambda calculus
  • The consequences of different evaluation schemes
  • How to represent datatypes in the lambda calculus

Another purpose of HW3 is to provide you with experience answering non-programming written questions of the kind you may experience on the final.

4 Problems

  1. (15 pts) Prove that λx.λy.λz.xy(xz) is α-equivalent λy.λz.λx.yz(yx)
  2. (45 pts) Given the following term:

(λn.λm.λf.λx.n(mf )x)(λf.λx.x)((λn.λf.λx.f (nf x))(λf.λx.x))

reduce this term as much as possible using each of

a. eager evaluation b. lazy evaluation c. unrestricted αβ-reduction (i.e. by αβ conversion that can be applied anywhere)

Label each step of reduction with the rule justifying it. You do not need to label uses of congruence.

  1. (Extra Credit) (10 pts) Using the methodology discussed in class, give the lambda terms that encode the construc- tors, and the function option map for the option datatype given as follows:

type ’a option = Some of ’a | None

let option_map f = fun x -> match x with Some y -> Some (f y) | None -> None