Proving Confluence
This skill provides guidance for proving confluence of rewriting systems in the Metatheory project.
Choose Your Approach
Option 1: Diamond Property (for systems like Lambda, CL)
Best when: The reduction relation has an obvious "parallel" version.
- •
Define parallel reduction that contracts multiple redexes simultaneously:
leaninductive ParRed : Term → Term → Prop where | var : ParRed (var n) (var n) | app : ParRed M M' → ParRed N N' → ParRed (app M N) (app M' N') | lam : ParRed M M' → ParRed (lam M) (lam M') | beta : ParRed M M' → ParRed N N' → ParRed (app (lam M) N) (M'[N'])
- •
Define complete development that contracts ALL redexes:
leandef complete : Term → Term
- •
Prove the key lemma: any parallel reduction reaches complete development:
leantheorem parRed_complete : M ⇒ N → N ⇒ complete M
- •
Diamond property follows from the triangle:
leantheorem parRed_diamond : Rewriting.Diamond ParRed
- •
Apply generic theorem:
leantheorem confluent : Confluent BetaRed := confluent_of_diamond parRed_diamond
Option 2: Newman's Lemma (for terminating systems like TRS)
Best when: You can prove termination via a well-founded measure.
- •
Prove termination via a decreasing measure:
leantheorem step_terminating : Rewriting.Terminating Step := by apply terminating_of_measure size intro a b h exact step_decreases_size h
- •
Prove local confluence by critical pair analysis:
leantheorem local_confluent : LocalConfluent Step := by intro a b c hab hac -- Analyze all critical pairs cases hab <;> cases hac <;> ...
- •
Apply Newman's lemma:
leantheorem confluent : Confluent Step := confluent_of_terminating_localConfluent step_terminating local_confluent
Option 3: Hindley-Rosen (for unions of relations)
Best when: You have two confluent relations that commute.
lean
theorem confluent_union : Confluent r → Confluent s → Commute r s → Confluent (Union r s)
Key Imports
lean
import Metatheory.Rewriting.Basic import Metatheory.Rewriting.Diamond import Metatheory.Rewriting.Newman import Metatheory.Rewriting.HindleyRosen
Examples in This Repo
- •
Lambda/Confluence.lean- Diamond property approach - •
CL/Confluence.lean- Diamond property approach - •
TRS/Confluence.lean- Newman's lemma approach - •
StringRewriting/Confluence.lean- Newman's lemma approach