Richard Hoekstra

Formal result

Confluence of the deterministic TLC evaluator

Research note
Richard Hoekstra · April 2026

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:

Functionality R(a, b) ∧ R(a, c) ⇒ b = c.

Call R confluent if:

Confluence R*(a, b) ∧ R*(a, c) ⇒ ∃d. R*(b, d) ∧ R*(c, d).

The theorem

Main result 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 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

ConsequenceStatement
Uniqueness of bounded WHNFwhnf_result_unique: the same argument on the weak-head relation
Monotone fuelnf_mono: once bounded normalisation succeeds, every larger fuel returns the same term
Replay-purity of the Zig runtimeDeterminism of the Lean function motivates a replay test. Correspondence with a native runtime and its input environment is a separate obligation.

Formalisation

MetricValue
FileChurchRosser.lean
Total lines571 (most is betaStep definition; confluence proof is ~30 lines)
Sorrys0
Verificationlake build
The result states confluence and uniqueness along the selected strategy. It makes no termination claim for arbitrary input terms.
Full paper (HTML) PDF
Cite this page

Richard Hoekstra. Confluence of the deterministic TLC evaluator. https://richardhoekstra.nl/papers/church-rosser.html