Basics of Substitution and Alpha-Equivalence
1Introduction
This lecture defines the operation that replaces only the free occurrences of a variable by a term. Naive textual replacement may accidentally bind a free variable, so bound variables must sometimes be renamed to avoid variable capture. Alpha-equivalence formalizes these harmless renamings.
2Substitution and capture
denotes the result of replacing the free occurrences of in by the term . Bound occurrences are not targets of substitution. For example,
By contrast, mechanically turning into makes the inserted occurrence of bound by , although it was free before insertion. This change is variable capture. The correct result first renames the binder and is .
3Fresh variables
For a finite set of terms , a variable is fresh for if its name occurs in none of the terms in . Because is infinite and finitely many terms contain only finitely many variable names, a fresh variable can always be chosen. Below, is chosen not to occur in either or , avoiding ambiguity during renaming.
4Capture-avoiding substitution
Capture-avoiding substitution is defined recursively on syntax:
There are three abstraction cases:
where in the last clause is fresh for both and . More precisely, if , the result is itself and no renaming is needed; the last clause need only be applied when .
For example, choosing fresh and distinct from gives
The inserted occurrence of remains free in the result.
5Alpha-conversion and alpha-equivalence
Alpha-conversion simultaneously renames a binder and the occurrences that it binds to a fresh variable. If , then
where the substitution on the right is capture-avoiding. Alpha-equivalence is the least congruence relation that permits this elementary renaming in any subterm and is reflexive, symmetric, and transitive. Consequently,
but free variables cannot be renamed, so . Moreover, : alpha-equivalence preserves binding structure.
6Connection to beta-reduction
Beta-reduction is defined by
using capture-avoiding substitution on the right. For example,
not . Different choices of a fresh variable may produce different spellings, but all resulting terms are alpha-equivalent.