Formal result
Confluence of the deterministic TLC evaluator
The claim
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.
Definitions
Let R ⊆ α × α be a reduction relation. Call R functional (deterministic, a partial function) if:
Call R confluent if:
The theorem
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 Lean proof
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)
Application to TLC
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 a partial function in the relational sense. This is betaRel_deterministic in ChurchRosser.lean, proved by rfl-style case analysis on betaStep.
What the lemma covers
Two successful bounded normalizations under this stepping strategy agree. A different relation that permits choosing any redex can branch and needs a separate proof of confluence. Square-zero residual operations in the source are independent of the deterministic argument.
Three consequences
| Consequence | Statement |
|---|---|
| Uniqueness of bounded WHNF | whnf_result_unique: the same argument on the weak-head relation |
| Monotone fuel | nf_mono: once bounded normalisation succeeds, every larger fuel returns the same term |
| Replay-purity of the Zig runtime | Determinism of the Lean function motivates a replay test. Correspondence with a native runtime and its input environment is a separate obligation. |
Formalisation
| Metric | Value |
|---|---|
| File | ChurchRosser.lean |
| Total lines | 571 (most is betaStep definition; confluence proof is ~30 lines) |
| Sorrys | 0 |
| Verification | lake build |
Cite this page
Richard Hoekstra. Confluence of the deterministic TLC evaluator. https://richardhoekstra.nl/papers/church-rosser.html