Solutions to in-class reductions (Feb 24, 2022)
These are the same reductions as shown in the video, but they’re a little more careful about writing every step.
Normal order reduction: outermost, leftmost
The normal order reduction chooses the outermost, leftmost reducible expression (aka, redex) to beta-reduce. If you are having trouble finding redexes, try drawing the expression’s abstract syntax tree, as shown in class. For the normal order redex, look for the uppermost, leftmost application that has an abstraction as its left child.
1. | (λf.λx.f(f x)) (λz.(+ x z)) 2 | given |
2. | (λf.λ |
alpha reduce |
3. | (λf.λ |
do |
4. | ( |
beta reduce |
5. | (λa. |
do |
6. | ( |
beta reduce |
7. | do |
|
8. | (λ |
alpha reduce |
9. | (λ |
do |
10. | ( |
beta reduce |
11. | do |
|
12. | (+ x (( |
beta reduce |
13. | (+ x |
do |
14. | (+ x (+ x 2)) | done |
Applicative order reduction: innermost, rightmost
The applicative order reduction chooses the innermost, rightmost redex to beta-reduce. If you draw the expression’s abstract syntax tree, the applicative order redex corresponds with the lowermost, rightmost application that has an abstraction as its left child.
Note that the normal order and applicative order reductions start out the same way because, in the beginning, there is only one reducible subexpression. Partway through the reduction (
1. | (λf.λx.f(f x)) (λz.(+ x z)) 2 | given |
2. | (λf.λ |
alpha reduce |
3. | (λf.λ |
do |
4. | ( |
beta reduce |
5. | (λa. |
do |
6. | (λa.(λz.(+ x z)) (( |
beta reduce |
7. | (λa.(λz.(+ x z)) |
do |
8. | (λa.( |
beta reduce |
9. | (λa. |
do |
10. | ( |
beta reduce |
11. | do |
|
12. | (+ x (+ x 2)) | done |