# COMS W3261 Computer Science Theory Homework Assignment #5 November 28, 2012 Due in class 1:10pm, December 5, 2012

## Instructions

• This is the last homework assignment!
• Problems (1)-(5) are each worth 20 points.
• This assignment may be handed in December 10, 2012 for 50% credit.

## Problems

1. Here is an ambiguous grammar G for lambda calculus:
•    E → λ var . E | E E | ( E ) | var
1. Construct an unambiguous grammar equivalent to G. Have your unambiguous grammar enforce the standard disambiguating conventions for lambda expressions.
2. Show one parse tree in each grammar for the expression
(λx. λy. x y) λz. z

2. Consider the lambda-calculus expression (λx. (λy. x) x) ((λz. z) (λw. (λv.v) w) ).
1. Identify all redexes in this expression.
2. Evaluate this expression using normal order evaluation.
3. Evaluate this expression using applicative order evaluation.

3. Evaluate the lambda expression (λx.(λy.(x(λx.xy))))y. Describe all the steps in your evaluation.

4. Let G be the lambda abstraction
• G = (λf.λx.f (f x))
Evaluate the lambda expression G G.

5. Let add, one, and two be the following lambda expressions:
• add = λm. λn. λf. λx. m f (n f x)
one = λf.λx.f x
two = λf.λx.f (f x)