Capture-Avoiding Substitution and Alpha-Renaming

Evaluate a substitution where a bound name would otherwise capture the inserted free variable.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Binding distinguishes two occurrences of the same name
  2. Rename before placing a free variable under a binder

Binding distinguishes two occurrences of the same name

A lambda binds occurrences of its parameter inside the body, except where another binder shadows it. Renaming a binder together with its bound occurrences to a fresh name preserves meaning. This is alpha-equivalence. A free variable is interpreted by an outer context and must retain that status when inserted into a new expression.

Rename before placing a free variable under a binder

Substitute the free variable \(y\) for \(x\) in \(\lambda y.x\). Direct replacement gives \(\lambda y.y\), in which the inserted variable has become bound. Rename the original bound \(y\) to fresh \(z\) first, obtaining \(\lambda z.x\), and then substitute to produce \(\lambda z.y\). The resulting function still refers to the outer \(y\). Small-step evaluation depends on this discipline for beta-reduction. Lexical closures implement the same binding behavior with environments and stored values.[1][2]

References

  1. Benjamin C. Pierce et al., Software Foundations ↩
  2. Shriram Krishnamurthi, Programming Languages: Application and Interpretation ↩