Manuscript reading edition
Confluence of the deterministic TLC evaluator
Confluence of the deterministic TLC evaluator
A deterministic step gives each initial term a single trajectory. Any two finite prefixes join at the endpoint of the longer prefix. The Lean result applies this argument to TLC’s chosen stepping strategy.
Abstract
The evaluator fixes one reduction choice at each step. Its reachable normal forms are unique when a run terminates. Full β-reduction permits multiple redex choices and requires a separate confluence argument.
1. The three lines
Let R ⊆ α × α be a reduction relation. Call R functional (equivalently: deterministic, or a partial function) if
R(a, b) ∧ R(a, c) ⇒ b = c.
Call R confluent if
R*(a, b) ∧ R*(a, c) ⇒ ∃d. R*(b, d) ∧ R*(c, d).
Theorem. If R is functional, then R* is confluent.
Proof. Follow the two finite paths from their common origin. Whenever both have another step, functionality makes those steps identical. When the shorter path ends, the longer path supplies a continuation to its own endpoint, which is the join.
The generic lemma confluent_of_partial_function takes the partial step function as an argument. Its TLC application in Proof/ChurchRosser.lean reads
theorem betaStar_confluent : Confluent BetaStar := by
simpa [BetaStar, BetaRel] using confluent_of_partial_function (step := betaStep)
2. TLC is a partial function
The ternary lambda calculus TLC uses a left-biased betaStep evaluator: at every beta-redex the leftmost outermost reduction fires. The evaluator is a total function betaStep : Term → Option Term. Its graph
betaRel(t, t′) : ⇔ betaStep(t) = some t′
is therefore a partial function in the relational sense. This is betaRel_deterministic in ChurchRosser.lean, proved by rfl-style case analysis on betaStep.
3. Corollary: Church-Rosser
The checked specialization above gives confluence of BetaStar, the closure of the graph of betaStep.
Normal forms are unique. Two successful bounded normaliser runs agree:
theorem nf_result_unique {fuel₁ fuel₂ : Nat} {t u v : TLC}
(hu : nf (fuel₁ + 1) t = some u)
(hv : nf (fuel₂ + 1) t = some v) : u = v := …
Again a direct corollary — functionality of nf follows from functionality of betaStep.
4. Why this is not cheating
The usual Church-Rosser proof handles non-deterministic relations: untyped lambda calculus with full beta reduction admits (λx. x x) ((λy. y) z) → (λx. x x) z → z z and (λx. x x) ((λy. y) z) → ((λy. y) z) ((λy. y) z) → z z. There the diamond is content.
TLC fixes a left-biased evaluator. The deterministic argument applies to that relation. A proof about all permitted redex choices would require a different relation.
The file also studies square-zero residual operations. The confluence proof uses only determinism.
5. Three consequences
Uniqueness of bounded WHNF. whnf_result_unique is the same argument on the weak-head relation.
Monotone fuel. The file proves that a successful normalization still succeeds with additional fuel, using the evaluator recursion.
Native replay. Determinism of the Lean function motivates a replay test. Relating the Zig runtime and its event inputs to this formal step requires an independent correspondence argument.
6. Reproducibility
- One file:
Proof/ChurchRosser.lean, 573 lines (most are the TLC term-levelbetaStepdefinition; the confluence proof itself is §1 and §3 above, ~30 lines). - Zero sorrys.
lake buildverifies everything.
7. Proof size
The specialization is short because the generic lemma already proves confluence. Its length does not measure the difficulty of confluence for unrestricted reduction.
Cite this page
Richard Hoekstra. Confluence of the deterministic TLC evaluator (HTML manuscript edition). https://richardhoekstra.nl/papers/church-rosser-paper.html