Lambda Calculus Continued Solutions
Question: Easy Beta
-
(λx.xyzx) w
Answer:
(λx.xyzx) w
→βwyzw
-
(λx.xxx) (yz)
Answer:
(λx.xxx) (yz)
→βyzyzyz
-
(λy.xyz)
Answer:
(λy.xyz)
cannot be beta reduced as there is no application. -
(λx.x) (λz.zw) y
Answer:
(λx.x) (λz.zw) y
→β(λz.zw) y
→βyw
-
(λx.x u) (λz.wzwz) yv
Answer:
(λx.x u) (λz.wzwz) yv
→β(λz.wzwz) u yv
→βwuwu yv
-
(λy.(λw.ywy)) x u
Answer:
(λy.(λw.ywy)) x u
→β(λw.xwx) u
→βxux
-
(λx.(λy.xyxy)) y z
Answer:
(λx.(λy.xyxy)) y
=α(λx.(λw.xwxw)) y z
→β(λw.ywyw) z
→βyzyz
Question: Converting
In each of the following, use alpha conversion to make all sets of bound variables have unique names.
Note: We have explicitly done the alpha conversion in two steps, to re-iterate the principle. See page 13 of the lambda slides to understand this explicit form.
-
(λx.zx) x
Answer:
(λx.zx) x
=α(λa.zx[x\a]) x
→β(λa.za) x
-
(λy.yxy) yy
Answer:
(λy.yxy) yy
=α(λa.yxy[y\a]) yy
→β(λa.axa) yy
-
((λx.xy) z) ((λy.xy) z)
Answer:
((λx.xy) z) ((λy.xy) z)
=α((λa.xy[x\a]) z) ((λb.xy[y\b]) z)
→β((λa.ay) z) ((λb.xb) z)
-
(λx.yx) (λx.xyx) z
Answer:
(λx.yx) (λx.xyx) z
=α(λa.yx[x\a]) (λb.xyx[x\b]) z
→β(λa.ya) (λb.byb) z
-
(λx.(λy.xx)) ((λy.uyw) v)
Answer:
(λx.(λy.xx)) ((λy.uyw) v)
=α(λx.(λz.xx[y\z])) ((λy.ayc) b)
→β(λx.(λw.xx)) ((λy.ayc) b)
Question: Alpha and Beta Together
Now that we can do alpha conversion and beta reduction, we can tackle many interesting and challenging lambda expressions. See if you can reduce the following:
-
(λx.xx) (λz.z) y
Answer:
(λx.xx) (λz.z) y
→β(λz.z) (λz.z) y
=α(λw.w) (λz.z) y
→β(λz.z) y
→βy
-
(λx.(λy.xy)) y z
Answer:
(λx.(λy.xy)) y z
=α(λx.(λw.xw)) y z
→β(λw.yw) z
→βyz
-
(λx.(λy.x y)) (λz.z y) v
Answer:
(λx.(λy.x y)) (λz.z y) v
=α(λx.(λw.x w)) (λz.z y) v
→β(λw.(λz.z y) w) v
→β(λz.z y) v
→βv w
-
(λy.x) (λy.((λy.z) y)) yx
Answer:
(λy.x) (λy.((λy.z) y)) yx
=α(λu.x)(λv.((λw.z) v)) yx
→βx yx
We converted allλy
in one batch, renaming them and the variables they have bound all. -
(λx.xx) (λx.xx)
Answer:
(λx.xx) (λx.xx)
=α(λy.yy) (λx.xx)
→β(λx.xx) (λx.xx)
And we’re back where we started! Continuously evaluating this would result in an infinite series of beta reductions. Not every expression can be finitely beta reduced!