Skip to content

Commit 8e6f619

Browse files
authored
Merge pull request #29 from objectionary/refactor-church-rosser
Refactor ARS
2 parents 39f1bfb + da5b567 commit 8e6f619

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

Minimal/ARS.lean

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,37 @@ def DiamondProperty (r : α → α → Type u)
4242

4343
/-- Property that if diverged in any number of steps, the results can be joined in any number of steps -/
4444
@[simp]
45-
def ChurchRosser (r : α → α → Type u)
45+
def Confluence (r : α → α → Type u)
4646
:= ∀ a b c, ReflTransGen r a b → ReflTransGen r a c → Join (ReflTransGen r) b c
4747

48-
def confluence_step
49-
{ a b c : α }
50-
(h : ∀ a b c, r a b → r a c → Join r b c)
51-
(hab : r a b)
52-
(hac : ReflTransGen r a c)
53-
: Σ d : α, Prod (ReflTransGen r b d) (r c d) := match hac with
54-
| ReflTransGen.refl => ⟨ b, ReflTransGen.refl, hab ⟩
55-
| ReflTransGen.head hax hxc => by
56-
rename_i x
57-
have ⟨y, hby, hxy⟩ := (h a b x hab hax)
58-
have ⟨d, hyd, hcd⟩ := confluence_step h hxy hxc
59-
exact ⟨d, ReflTransGen.head hby hyd, hcd⟩
60-
6148
/-- Diamond property implies Church-Rosser (in the form in which Lean recognizes termination) -/
62-
def confluence
49+
def diamond_implies_confluence'
6350
(h : ∀ a b c, r a b → r a c → Join r b c)
6451
(a b c : α)
6552
(hab : ReflTransGen r a b)
6653
(hac : ReflTransGen r a c)
6754
: Join (ReflTransGen r) b c := match hab with
6855
| ReflTransGen.refl => ⟨ c, hac, ReflTransGen.refl⟩
6956
| ReflTransGen.head hax hxb => by
57+
let rec step
58+
{ a b c : α }
59+
(h : ∀ a b c, r a b → r a c → Join r b c)
60+
(hab : r a b)
61+
(hac : ReflTransGen r a c)
62+
: Σ d : α, Prod (ReflTransGen r b d) (r c d) := match hac with
63+
| ReflTransGen.refl => ⟨ b, ReflTransGen.refl, hab ⟩
64+
| ReflTransGen.head hax hxc => by
65+
rename_i x
66+
have ⟨y, hby, hxy⟩ := (h a b x hab hax)
67+
have ⟨d, hyd, hcd⟩ := step h hxy hxc
68+
exact ⟨d, ReflTransGen.head hby hyd, hcd⟩
7069
rename_i x
71-
have ⟨c', hxc', hcc'⟩ := confluence_step h hax hac
72-
have ⟨d, hbd, hc'd⟩ := confluence h x b c' hxb hxc'
70+
have ⟨c', hxc', hcc'⟩ := step h hax hac
71+
have ⟨d, hbd, hc'd⟩ := diamond_implies_confluence' h x b c' hxb hxc'
7372
exact ⟨d, hbd, ReflTransGen.head hcc' hc'd⟩
7473

7574
/-- Diamond property implies Church-Rosser -/
76-
def diamond_implies_church_rosser : DiamondProperty r → ChurchRosser r := by
75+
def diamond_implies_confluence : DiamondProperty r → Confluence r := by
7776
simp
7877
intros h a b c hab hac
79-
exact confluence h a b c hab hac
78+
exact diamond_implies_confluence' h a b c hab hac

Minimal/Calculus.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,11 +1806,11 @@ def diamond_preduce : DiamondProperty PReduce
18061806
18071807

18081808
/-- Confluence of `⇛` [KS22, Corollary 3.10], [Krivine93, Lemma 1.17] -/
1809-
def confluence_preduce : ChurchRosser PReduce
1810-
:= diamond_implies_church_rosser diamond_preduce
1809+
def confluence_preduce : Confluence PReduce
1810+
:= diamond_implies_confluence diamond_preduce
18111811

18121812
/-- Confluence of `⇝` [KS22, Theorem 3.11] -/
1813-
def confluence_reduce : ChurchRosser Reduce
1813+
def confluence_reduce : Confluence Reduce
18141814
:= λ t u v tu tv =>
18151815
let (tu', tv') := (redMany_to_parMany tu, redMany_to_parMany tv)
18161816
let ⟨w, uw', vw'⟩ := confluence_preduce t u v tu' tv'

lake-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
{"url": "https://github.com/leanprover/std4",
5050
"type": "git",
5151
"subDir": null,
52-
"rev": "d77f6535a34bc65bd00cf6b2e8e7c1edf5ad960b",
52+
"rev": "1fa3d92b9aff636c2b64e55c2baf06e3783530ae",
5353
"name": "std",
5454
"manifestFile": "lake-manifest.json",
5555
"inputRev": "main",

0 commit comments

Comments
 (0)