@@ -9,49 +9,30 @@ variable {α : Type*} {I : Independence α}
99theorem length_eq_of_eqv {u v : List α} (h : TraceEqv I u v) :
1010 u.length = v.length := by
1111 induction h with
12- | swap _ _ _ =>
13- rfl
14- | refl _ =>
15- rfl
16- | symm _ ih =>
17- exact ih.symm
18- | trans _ _ ih₁ ih₂ =>
19- exact ih₁.trans ih₂
20- | compat _ _ ih₁ ih₂ =>
21- simp [ih₁, ih₂]
12+ | swap _ _ _ => rfl
13+ | refl _ => rfl
14+ | symm _ ih => exact ih.symm
15+ | trans _ _ ih₁ ih₂ => exact ih₁.trans ih₂
16+ | compat _ _ ih₁ ih₂ => simp [ih₁, ih₂]
2217
2318theorem mem_iff_mem {u v : List α} (a : α) (h : TraceEqv I u v) :
2419 (a ∈ u ↔ a ∈ v) := by
2520 induction h with
26- | swap _ _ _ =>
27- simp
28- exact Or.comm
29- | refl _ =>
30- exact Eq.to_iff rfl
31- | symm _ ih =>
32- exact Iff.symm ih
33- | trans _ _ ih₁ ih₂ =>
34- exact ih₁.trans ih₂
35- | compat _ _ ih₁ ih₂ =>
36- simp
37- exact or_congr ih₁ ih₂
21+ | swap _ _ _ => simp [or_comm]
22+ | refl _ => rfl
23+ | symm _ ih => exact ih.symm
24+ | trans _ _ ih₁ ih₂ => exact ih₁.trans ih₂
25+ | compat _ _ ih₁ ih₂ => simp [ih₁, ih₂]
3826
3927/-- The mirror rule. -/
4028theorem reverse_eqv_of_eqv {u v : List α} (h : TraceEqv I u v) :
4129 TraceEqv I u.reverse v.reverse := by
4230 induction h with
43- | swap a b h =>
44- simp
45- exact TraceEqv.swap b a (I.symm a b h)
46- | refl u' =>
47- exact TraceEqv.refl u'.reverse
48- | symm _ ih =>
49- exact ih.symm
50- | trans _ _ ih₁ ih₂ =>
51- exact ih₁.trans ih₂
52- | compat _ _ ih₁ ih₂ =>
53- simp
54- exact ih₂.compat ih₁
31+ | swap a b h => simp [TraceEqv.swap b a (I.symm a b h)]
32+ | refl u' => apply TraceEqv.refl
33+ | symm _ ih => exact ih.symm
34+ | trans _ _ ih₁ ih₂ => exact ih₁.trans ih₂
35+ | compat _ _ ih₁ ih₂ => simp [ih₂.compat ih₁]
5536
5637/-- The projection rule. -/
5738theorem proj_eqv_of_eqv {u v : List α} {S : Finset α} [DecidableEq α] (h : TraceEqv I u v) :
@@ -64,15 +45,10 @@ theorem proj_eqv_of_eqv {u v : List α} {S : Finset α} [DecidableEq α] (h : Tr
6445 · apply TraceEqv.refl
6546 · apply TraceEqv.refl
6647 · apply TraceEqv.refl
67- | refl _ =>
68- apply TraceEqv.refl
69- | symm _ ih =>
70- exact ih.symm
71- | trans _ _ ih₁ ih₂ =>
72- exact ih₁.trans ih₂
73- | compat _ _ ih₁ ih₂ =>
74- simp
75- exact ih₁.compat ih₂
48+ | refl _ => apply TraceEqv.refl
49+ | symm _ ih => exact ih.symm
50+ | trans _ _ ih₁ ih₂ => exact ih₁.trans ih₂
51+ | compat _ _ ih₁ ih₂ => simp [ih₁.compat ih₂]
7652
7753theorem proj_eq_of_eqv {u v : List α} [DecidableEq α]
7854 (D : Dependence α) (h : TraceEqv (inducedIndependence D) u v)
@@ -94,15 +70,10 @@ theorem proj_eq_of_eqv {u v : List α} [DecidableEq α]
9470 · simp [filter, ha', hb']
9571 · simp [filter, ha', hb']
9672 · simp [filter, ha', hb']
97- | refl _ =>
98- rfl
99- | symm _ ih =>
100- exact ih.symm
101- | trans _ _ ih₁ ih₂ =>
102- exact ih₁.trans ih₂
103- | compat _ _ ih₁ ih₂ =>
104- simp [proj_append]
105- rw [ih₁, ih₂]
73+ | refl _ => rfl
74+ | symm _ ih => exact ih.symm
75+ | trans _ _ ih₁ ih₂ => exact ih₁.trans ih₂
76+ | compat _ _ ih₁ ih₂ => simp [ih₁, ih₂]
10677
10778theorem cancelRight_congr {u v : List α} [DecidableEq α] (a : α) (h : TraceEqv I u v) :
10879 TraceEqv I (u ÷ a) (v ÷ a) := by
@@ -118,19 +89,14 @@ theorem cancelRight_congr {u v : List α} [DecidableEq α] (a : α) (h : TraceEq
11889 · simp [cancelRight, hab, hac]
11990 apply TraceEqv.swap
12091 exact h_indep
121- | refl _ =>
122- apply TraceEqv.refl
123- | symm _ ih =>
124- exact ih.symm
125- | trans _ _ ih₁ ih₂ =>
126- exact ih₁.trans ih₂
92+ | refl _ => apply TraceEqv.refl
93+ | symm _ ih => exact ih.symm
94+ | trans _ _ ih₁ ih₂ => exact ih₁.trans ih₂
12795 | compat t₁ t₂ ih₁ ih₂ =>
12896 expose_names
12997 by_cases h_mem : a ∈ w₃
130- · simp [h_mem, (mem_iff_mem a t₂).mp h_mem]
131- exact t₁.compat ih₂
132- · simp [h_mem, (mem_iff_mem a t₂).mpr.mt h_mem]
133- exact ih₁.compat t₂
98+ · simp [h_mem, (mem_iff_mem a t₂).mp h_mem, t₁.compat ih₂]
99+ · simp [h_mem, (mem_iff_mem a t₂).mpr.mt h_mem, ih₁.compat t₂]
134100
135101theorem erase_congr {u v : List α} [DecidableEq α] (a : α) (h : TraceEqv I u v) :
136102 TraceEqv I (u.erase a) (v.erase a) := by
@@ -163,6 +129,22 @@ theorem append_cancel_middle {l r u v : List α} [DecidableEq α]
163129 TraceEqv I u v :=
164130 append_cancel_left (append_cancel_right h)
165131
132+ instance [DecidableEq α] : CancelMonoid (Trace I) where
133+ mul_left_cancel := by
134+ intro t₁ t₂ t₃
135+ refine Quotient.inductionOn₃ t₁ t₂ t₃ (fun w₁ w₂ w₃ => ?_)
136+ intro heq
137+ apply Quotient.sound
138+ simp only at heq
139+ exact append_cancel_left (Quotient.exact heq)
140+ mul_right_cancel := by
141+ intro t₁ t₂ t₃
142+ refine Quotient.inductionOn₃ t₁ t₂ t₃ (fun w₁ w₂ w₃ => ?_)
143+ intro heq
144+ apply Quotient.sound
145+ simp only at heq
146+ exact append_cancel_right (Quotient.exact heq)
147+
166148lemma eqv_length_eq_two {a b : α} {w : List α} (h : TraceEqv I [a, b] w) :
167149 w = [a, b] ∨ w = [b, a] := by
168150 rcases length_eq_two.mp (length_eq_of_eqv h).symm with ⟨c, d, rfl⟩
@@ -185,13 +167,11 @@ lemma eqv_singletons {a b : α} (h : TraceEqv I [a] [b]) : a = b := by
185167 generalize hu : ([a] : List α) = u at h
186168 generalize hv : ([b] : List α) = v at h
187169 induction h generalizing a b with
188- | swap _ _ _ =>
189- cases hu
170+ | swap _ _ _ => cases hu
190171 | refl _ =>
191172 subst hv
192173 injection hu
193- | symm _ ih =>
194- exact (ih hv hu).symm
174+ | symm _ ih => exact (ih hv hu).symm
195175 | trans t₁ t₂ _ _ =>
196176 have ht₁ := mem_iff_mem a t₁
197177 have ht₂ := mem_iff_mem a t₂
@@ -287,8 +267,7 @@ theorem indep_of_comm_singleton {u v w : List α} {a : α} [DecidableEq α]
287267 (h : TraceEqv I (u ++ [a] ++ v) (w ++ [a])) (h_mem : a ∉ v) :
288268 Independent I [a] v := by
289269 induction v using reverseRecOn generalizing w with
290- | nil =>
291- simp
270+ | nil => simp
292271 | append_singleton x b ih =>
293272 intro a' ha' b' hb'
294273 simp at ha' hb' h_mem
@@ -308,8 +287,7 @@ theorem indep_of_comm_singleton {u v w : List α} {a : α} [DecidableEq α]
308287theorem comm_singleton_of_indep {w : List α} {a : α} (h : Independent I [a] w) :
309288 TraceEqv I (w ++ [a]) ([a] ++ w) := by
310289 induction w using reverseRecOn with
311- | nil =>
312- apply TraceEqv.refl
290+ | nil => apply TraceEqv.refl
313291 | append_singleton w' b ih =>
314292 simp at h
315293 have haw' : Independent I [a] w' := by
0 commit comments