prac5-soln-fall09

# Prac5-soln-fall09 - CMSC330 Fall 2009 Practice Problems 5 Solutions 1 Lambda calculus Make all parentheses explicit in the

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMSC330 Fall 2009 Practice Problems 5 Solutions 1. Lambda calculus Make all parentheses explicit in the following &-expressions a. & x.xz & y.xy & ( & x.((x z) ( & y.(x y)))) b. ( & x.xz) & y.w & w.wyzx & (( & x.(x z)) ( & y.(w ( & w.((((w y) z) x)))))) c. & x.xy & x.yx & ( & x.((x y) ( & x.(y x)))) Find all free (unbound) variables in the following &-expressions d. & x.x z & y.x y & ( & x.((x z ) ( & y.(x y)))) e. ( & x. x z) & y. w & w. w y z x & (( & x.(x z )) ( & y.( w ( & w.((((w y) z ) x )))))) f. & x. x y & x. y x & ( & x.((x y ) ( & x.( y x)))) Apply -reduction to the following &-expressions as much as possible g. ( & z.z) ( & y.y y) ( & x.x a) // ¡-reduction = body[sym/replacement] ( & z. z ) ( & y.y y ) ( & x.x a) & // z[z/( & y.y y)] replace z with & y.y y ( & y. y y ) ( & x.x a ) & // y y[y/( & x.x a)] replace y with & x.x a ( & x. x a) ( & x.x a ) & // x a[x/( & x.x a)] replace x with & x.x a ( & x. x a) a & a a // x a[x/a] replace x with a h. ( & z.z) ( & z.z z) ( & z.z y) ( & z. z ) ( & z.z z ) ( & z.z y) & // ¡-reduction: replace z with & z.z z ( & z. z z ) ( & z.z y ) & // ¡-reduction: replace z with & z.z y ( & z. z y) ( & z.z y ) & // ¡-reduction: replace z with & z.z y ( & z. z y) y & y y // ¡-reduction: replace z with y i. ( & x. & y.x y y) ( & a.a) b ( & x. & y. x y y) ( & a.a ) b & // ¡-reduction: replace x with & a.a ( & y.( & a.a) y y ) b & // ¡-reduction: replace y with b ( & a. a ) b b & b b // ¡-reduction: replace a with b j. ( & x. & y.x y y) ( & y.y) y ( & x. & y .x y y ) ( & y.y) y & // ¢-conversion: rename y to a ( & x. & a. x a a) ( & y.y ) y & // ¡-reduction: replacing x with & y.y ( & a.( & y.y) a a ) y & // ¡-reduction: replacing a with y ( & y. y ) y y & y y // ¡-reduction: replacing y with y k. ( & x.x x) ( & y.y x) z y....
View Full Document

## This note was uploaded on 01/13/2012 for the course CMSC 330 taught by Professor Staff during the Fall '08 term at Maryland.

### Page1 / 4

Prac5-soln-fall09 - CMSC330 Fall 2009 Practice Problems 5 Solutions 1 Lambda calculus Make all parentheses explicit in the

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online