3.6. Beta-Reduction¶
3.6.1. Beta-Redexes¶
Now that we have rigorously defined substitution in the previous section, we can define a rule for evaluating a function application, which is the main operation for any λ calculus interpreter. This rule is called β-reduction. An expression to which the rule can be applied is called a β-redex (short for β-reduction expression). So, a β-redex is formally defined as a λ expression of a specific form, namely, an application in which the first term is a function abstraction.
For example, (λx.(xv)(z(vu))) is a β-redex because λx.(xv) is a function abstraction. On the other hand, ((λx.(xv)y)(z(vu))) is not because its first term is a function application and not a function abstraction. However, the application that comprises the first term of this expression is a β-redex. This illustrates that it is possible for expressions that may not themselves be β-redexes to contain sub-expressions that are.
A critical part of analyzing how any language evaluates function calls is to examine its semantics from the perspective of β-reduction.
3.6.2. Identifying Beta-Redexes¶
This randomized problem will help you identify β-redexes. To earn credit for it, you will have to solve it correctly three times in a row.
3.6.3. Beta-Reduction is a Substitution¶
If we have a β-redex of the form (λx.EE′), then to β-reduce this expression means that we substitute E′ for x in E using the substitution algorithm developed in the preceding section. For example, β-reducing (λx.(xv)(z(vu))) would yield the expression ((z(vu))v).
3.6.4. Some Beta-Reductions Require Alpha-Conversion¶
This randomized problem will help you identify β-redexes and prepare to reduce them by determining whether an α-conversion is needed. To earn credit for it, you will have to solve it correctly three times in a row.
3.6.5. Performing Beta-Reductions¶
This randomized problem will provide practice performing β-reductions. To earn credit for it, you will have to solve it correctly three times in a row. BeCareful: remember that, because β-reducing uses the substitution algorithm, it may be necessary to perform an α-conversion. For example, β-reducing (λx.λu.(ux)(vu)) yields λa.(a(vu)), where we must do an α-conversion to avoid capturing the free variable u.