@@ -20,7 +20,7 @@ structure Independence (α : Type) where
2020
2121/-- The Independence relation induced by a Dependence `D`. -/
2222def inducedIndependence {α : Type } (D : Dependence α) : Independence α where
23- rel := fun a b => ¬ D.rel a b
23+ rel := fun a b => ¬D.rel a b
2424 irrefl := by
2525 intro a h
2626 exact h (D.refl a)
@@ -197,7 +197,7 @@ lemma cancellation_rule {w₁ w₂ : List α} [DecidableEq α] (a : α) (h : Tra
197197 · simp [List.cancelRight, hab, hac, ne_comm]
198198 exact TraceEquiv.swap b c hbc
199199 | refl _ =>
200- exact TraceEquiv.refl _
200+ apply TraceEquiv.refl
201201 | symm _ ih =>
202202 exact ih.symm
203203 | trans _ _ ih₁ ih₂ =>
@@ -206,10 +206,10 @@ lemma cancellation_rule {w₁ w₂ : List α} [DecidableEq α] (a : α) (h : Tra
206206 rename_i l₃ _
207207 by_cases hal₃ : a ∈ l₃
208208 · have hal₄ := (mem_iff_mem a t₂).mp hal₃
209- simp [List.cancelRight_append , hal₃, hal₄]
209+ simp [List.append_cancelRight , hal₃, hal₄]
210210 exact t₁.compat ih₂
211211 · have hal₄ := (mem_iff_mem a t₂).mpr.mt hal₃
212- simp [List.cancelRight_append , hal₃, hal₄]
212+ simp [List.append_cancelRight , hal₃, hal₄]
213213 exact ih₁.compat t₂
214214
215215lemma cancellation_rule_left {w₁ w₂ : List α} [DecidableEq α] (a : α) (h : TraceEquiv I w₁ w₂) :
@@ -224,15 +224,15 @@ lemma projection_rule {w₁ w₂ : List α} [DecidableEq α]
224224 (S: Finset α) (h : TraceEquiv I w₁ w₂) :
225225 TraceEquiv I (w₁.proj S) (w₂.proj S) := by
226226 induction h with
227- | swap a b h =>
227+ | swap a b h_indep =>
228228 by_cases ha : a ∈ S <;> by_cases hb : b ∈ S
229229 all_goals (
230230 simp [List.proj, ha, hb]
231- try exact TraceEquiv.swap a b h
231+ try exact TraceEquiv.swap a b h_indep
232232 try exact TraceEquiv.refl _
233233 )
234234 | refl _ =>
235- exact TraceEquiv.refl _
235+ apply TraceEquiv.refl
236236 | symm _ ih =>
237237 exact ih.symm
238238 | trans _ _ ih₁ ih₂ =>
@@ -241,13 +241,6 @@ lemma projection_rule {w₁ w₂ : List α} [DecidableEq α]
241241 simp only [List.proj_append]
242242 exact ih₁.compat ih₂
243243
244- theorem projection_lemma {w₁ w₂ : List α} [DecidableEq α] (D : Dependence α) :
245- TraceEquiv I w₁ w₂ ↔ ∀ a b, D.rel a b → w₁.proj {a, b} = w₂.proj {a, b} := by
246- constructor
247- · intro h
248- sorry
249- · sorry
250-
251244lemma equiv_length_eq_two {a b : α} {w : List α} (h : TraceEquiv I [a, b] w) :
252245 w = [a, b] ∨ w = [b, a] := by
253246 have h_len := List.length_eq_two.mp (length_eq_of_equiv h).symm
@@ -391,9 +384,7 @@ lemma indep_and_decomp_of_equiv_of_tail_ne {u v : List α} {a b : α} [Decidable
391384 have h_cancel_b_concat_ab := h_cancel_b.compat (TraceEquiv.refl [b])
392385 have h_tail := by simpa using h_cancel_b_concat_ab.symm.trans (h.symm.trans h_cancel_b_concat_ba)
393386 have h_ab_ba := equiv_cancel_left h_tail
394- exact ⟨indep_of_equiv_of_ne h_ab_ba hne,
395- ⟨u ÷ b,
396- ⟨h_cancel_b_concat_b, h_cancel_b⟩⟩⟩
387+ exact ⟨indep_of_equiv_of_ne h_ab_ba hne, u ÷ b, h_cancel_b_concat_b, h_cancel_b⟩
397388
398389-- Fact (1.10)
399390lemma equiv_cancel_left_right {u v x y : List α} [DecidableEq α]
@@ -429,7 +420,7 @@ lemma indep_of_equiv_rightmost_symbol {u v w : List α} {a : α} [DecidableEq α
429420 · rw [← hb'b] at hr
430421 exact I.symm b' a hr
431422
432- lemma right_most_occurrence {w : List α} {a : α} (h : a ∈ w) :
423+ lemma rightmost_occurrence {w : List α} {a : α} (h : a ∈ w) :
433424 ∃ w' w'', w = w' ++ [a] ++ w'' ∧ a ∉ w'' := by
434425 induction w using List.reverseRecOn with
435426 | nil =>
@@ -501,12 +492,12 @@ theorem levi_lemma {u v x y : List α} [DecidableEq α] (h : TraceEquiv I (u ++
501492 exact TraceEquiv.symm h
502493 | append_singleton w e ih =>
503494 by_cases hev : e ∈ v
504- · have ⟨v', v'', ⟨ hv, hv''⟩⟩ := right_most_occurrence hev
495+ · have ⟨v', v'', hv, hv''⟩ := rightmost_occurrence hev
505496 have h_cancel := cancellation_rule e h
506497 rw [hv, ← List.append_assoc] at h_cancel
507- simp only [List.cancelRight_append ] at h_cancel
498+ simp only [List.append_cancelRight ] at h_cancel
508499 simp [hv''] at h_cancel
509- have ⟨z₁', z₂', z₃', z₄', ⟨ h_indep, ht₁, ht₂, ht₃, ht₄⟩ ⟩ := ih h_cancel
500+ have ⟨z₁', z₂', z₃', z₄', h_indep, ht₁, ht₂, ht₃, ht₄⟩ := ih h_cancel
510501 use z₁', z₂', z₃', z₄' ++ [e], h_indep
511502 replace ht₄ := ht₄.compat (TraceEquiv.refl [e])
512503 have he : TraceEquiv I (v'' ++ [e]) ([e] ++ v'') := by
@@ -522,12 +513,12 @@ theorem levi_lemma {u v x y : List α} [DecidableEq α] (h : TraceEquiv I (u ++
522513 have h_alph := mem_iff_mem e h
523514 simp at h_alph
524515 exact Or.resolve_right h_alph hev
525- have ⟨u', u'', ⟨ hu, hu''⟩⟩ := right_most_occurrence heu
516+ have ⟨u', u'', hu, hu''⟩ := rightmost_occurrence heu
526517 have h_cancel := cancellation_rule e h
527518 rw [hu, ← List.append_assoc] at h_cancel
528- simp only [List.cancelRight_append ] at h_cancel
519+ simp only [List.append_cancelRight ] at h_cancel
529520 simp [hev, hu'', -List.append_assoc] at h_cancel
530- have ⟨z₁', z₂', z₃', z₄', ⟨ h_indep, ht₁, ht₂, ht₃, ht₄⟩ ⟩ := ih h_cancel
521+ have ⟨z₁', z₂', z₃', z₄', h_indep, ht₁, ht₂, ht₃, ht₄⟩ := ih h_cancel
531522 have h_indep_e : independent I [e] (u'' ++ v) := by
532523 rw [hu, ← List.append_assoc, List.append_assoc] at h
533524 exact indep_of_equiv_rightmost_symbol h (List.not_mem_append hu'' hev)
@@ -616,7 +607,7 @@ lemma exists_gcp' {I : Independence α} {u v w : List α} [DecidableEq α]
616607 simp at hu' hv'
617608 replace hu' := Quotient.exact hu'
618609 replace hv' := Quotient.exact hv'
619- have ⟨z₁, z₂, z₃, _, ⟨ h_indep, huz, _, hvz, _⟩ ⟩ := levi_lemma (hu'.trans hv'.symm)
610+ have ⟨z₁, z₂, z₃, _, h_indep, huz, _, hvz, _⟩ := levi_lemma (hu'.trans hv'.symm)
620611 use z₁
621612 and_intros
622613 · use z₂
@@ -652,7 +643,7 @@ lemma exists_gcp {u v w : List α} [DecidableEq α]
652643 simp at hu' hv'
653644 replace hu' := Quotient.exact hu'
654645 replace hv' := Quotient.exact hv'
655- have ⟨z₁, z₂, z₃, _, ⟨ h_indep, huz, _, hvz, _⟩ ⟩ := levi_lemma (hu'.trans hv'.symm)
646+ have ⟨z₁, z₂, z₃, _, h_indep, huz, _, hvz, _⟩ := levi_lemma (hu'.trans hv'.symm)
656647 use z₁
657648 and_intros
658649 · use z₂
@@ -668,7 +659,7 @@ lemma exists_gcp {u v w : List α} [DecidableEq α]
668659 replace hw₂ := Quotient.exact hw₂
669660 replace hw₁ := hw₁.trans huz
670661 replace hw₂ := hw₂.trans hvz
671- have ⟨y₁, y₂, y₃, y₄, ⟨ h_indep_yy, hy_g', _, hy_z₁, hy_z₂⟩ ⟩ := levi_lemma hw₁
662+ have ⟨y₁, y₂, y₃, y₄, h_indep_yy, hy_g', _, hy_z₁, hy_z₂⟩ := levi_lemma hw₁
672663 have h_y₂_empty : y₂ = [] := by
673664 have hyw : TraceEquiv I (y₂ ++ w₂) (y₃ ++ z₃) := by
674665 have hywz := (hy_g'.compat (TraceEquiv.refl w₂)).symm.trans hw₂
@@ -725,7 +716,7 @@ lemma exists_lcd {u v w : List α} [DecidableEq α]
725716 simp at hu' hv'
726717 replace hu' := Quotient.exact hu'
727718 replace hv' := Quotient.exact hv'
728- have ⟨z₁, z₂, z₃, z₄, ⟨ h_indep, huz, hu'z, hvz, hv'z⟩ ⟩ := levi_lemma (hu'.trans hv'.symm)
719+ have ⟨z₁, z₂, z₃, z₄, h_indep, huz, hu'z, hvz, hv'z⟩ := levi_lemma (hu'.trans hv'.symm)
729720 use z₁ ++ z₂ ++ z₃
730721 and_intros
731722 · use z₃
@@ -749,7 +740,7 @@ lemma exists_lcd {u v w : List α} [DecidableEq α]
749740 have huvzw := huzw.symm.trans (huv.trans hvzw)
750741 rw [List.append_assoc, List.append_assoc] at huvzw
751742 exact equiv_cancel_left huvzw
752- have ⟨y₁, y₂, y₃, y₄, ⟨ _, hy_z₂, hy_w₁, hy_z₃, _⟩ ⟩ := levi_lemma hzw
743+ have ⟨y₁, y₂, y₃, y₄, _, hy_z₂, hy_w₁, hy_z₃, _⟩ := levi_lemma hzw
753744 have h_y₁_empty : y₁ = [] := by
754745 have h_indep_yy : independent I (y₁ ++ y₂) (y₁ ++ y₃) := by
755746 intro a ha b hb
@@ -851,7 +842,7 @@ variable {M N : Type*} [Monoid M] [Monoid N]
851842lemma decomp_of_image_eq_of_tail_ne {ϕ : DependenceMorphism I M} {u v : List α} {a b : α}
852843 (heq : ϕ (u ++ [a]) = ϕ (v ++ [b])) (hne : a ≠ b) :
853844 ∃ w, ϕ u = ϕ (w ++ [b]) ∧ ϕ v = ϕ (w ++ [a]) := by
854- have hu : ϕ u = ϕ (v ÷ a ++ [b]) := by simpa [List.cancelRight_append , hne] using ϕ.A3 heq
845+ have hu : ϕ u = ϕ (v ÷ a ++ [b]) := by simpa [List.append_cancelRight , hne] using ϕ.A3 heq
855846 have hu' : ϕ (u ÷ b) = ϕ (v ÷ a) := (ϕ.A3 hu.symm).symm
856847 use u ÷ b
857848 constructor
@@ -946,6 +937,133 @@ noncomputable def dependenceMorphismIso
946937 rw [ϕ.map_append, hw₁, hw₂]
947938 exact θ_well_defined (m₁ * m₂) (w₁ ++ w₂) h
948939
940+ lemma proj_eq_of_equiv {w₁ w₂ : List α}
941+ (D : Dependence α) (h : TraceEquiv (inducedIndependence D) w₁ w₂)
942+ (a b : α) (h_dep : D.rel a b) :
943+ w₁.proj {a, b} = w₂.proj {a, b} := by
944+ induction h with
945+ | swap a' b' h_indep =>
946+ dsimp [List.proj]
947+ by_cases ha' : a' ∈ ({a, b} : Finset α) <;> by_cases hb' : b' ∈ ({a, b} : Finset α)
948+ · have h_dep : D.rel a' b' := by
949+ simp at ha' hb'
950+ rcases ha' with rfl | rfl <;> rcases hb' with rfl | rfl
951+ · apply D.refl
952+ · exact h_dep
953+ · exact D.symm b' a' h_dep
954+ · apply D.refl
955+ dsimp [inducedIndependence] at h_indep
956+ contradiction
957+ · simp [List.filter, ha', hb']
958+ · simp [List.filter, ha', hb']
959+ · simp [List.filter, ha', hb']
960+ | refl _ =>
961+ rfl
962+ | symm _ ih =>
963+ exact ih.symm
964+ | trans _ _ ih₁ ih₂ =>
965+ exact ih₁.trans ih₂
966+ | compat _ _ ih₁ ih₂ =>
967+ simp [List.proj_append]
968+ rw [ih₁, ih₂]
969+
970+ theorem projection_lemma {w₁ w₂ : List α} (D : Dependence α) :
971+ TraceEquiv (inducedIndependence D) w₁ w₂ ↔
972+ ∀ a b, D.rel a b → w₁.proj {a, b} = w₂.proj {a, b} := by
973+ constructor
974+ · apply proj_eq_of_equiv
975+ · intro h
976+ induction w₁ using List.reverseRecOn generalizing w₂ with
977+ | nil =>
978+ have hw₂ : w₂ = [] := by
979+ have h_symb : ∀ x, [].proj {x, x} = w₂.proj {x, x} := fun x => h x x (D.refl x)
980+ dsimp [List.proj] at h_symb
981+ cases w₂ with
982+ | nil =>
983+ rfl
984+ | cons c w' =>
985+ have h_absurd := h_symb c
986+ simp at h_absurd
987+ subst hw₂
988+ apply TraceEquiv.refl
989+ | append_singleton w₁' c ih =>
990+ have hw₂ : c ∈ w₂ := by
991+ have hc := h c c (D.refl c)
992+ simp [List.proj] at hc
993+ apply List.mem_of_mem_filter
994+ rw [← hc]
995+ simp
996+ have ⟨w', w'', heq, hc⟩ := rightmost_occurrence hw₂
997+ have h_indep : independent (inducedIndependence D) [c] w'' := by
998+ intro c hc b hb
999+ simp at hc
1000+ subst hc
1001+ dsimp [inducedIndependence]
1002+ by_cases h_dep : D.rel c b
1003+ · have hc' := h c b h_dep
1004+ rw [heq] at hc'
1005+ dsimp [List.proj] at hc'
1006+ simp only [List.filter_append] at hc'
1007+ have hw''_nonempty : w''.filter (· ∈ ({c, b} : Finset α)) ≠ [] := by
1008+ intro h_empty
1009+ have h_b_in : b ∈ w''.filter (· ∈ ({c, b} : Finset α)) := by
1010+ rw [List.mem_filter]
1011+ simp [hb]
1012+ rw [h_empty] at h_b_in
1013+ contradiction
1014+ have h_lhs_end :
1015+ (w₁'.filter (· ∈ ({c, b} : Finset α)) ++
1016+ [c].filter (· ∈ ({c, b} : Finset α))).getLast? = some c := by
1017+ simp
1018+ have h_rhs_end :
1019+ (w'.filter (· ∈ ({c, b} : Finset α)) ++
1020+ [c].filter (· ∈ ({c, b} : Finset α)) ++
1021+ w''.filter (· ∈ ({c, b} : Finset α))).getLast?
1022+ = (w''.filter (· ∈ ({c, b} : Finset α))).getLast? := by
1023+ exact List.getLast?_append_of_ne_nil _ hw''_nonempty
1024+ rw [← hc', h_lhs_end] at h_rhs_end
1025+ have h_absurd : c ∈ w'' := by
1026+ have h_mem := List.mem_of_getLast? h_rhs_end.symm
1027+ simp at h_mem
1028+ exact h_mem
1029+ contradiction
1030+ · exact h_dep
1031+ have h_comm : TraceEquiv (inducedIndependence D) w₂ (w' ++ w'' ++ [c]) := by
1032+ rw [heq, List.append_assoc, List.append_assoc]
1033+ apply TraceEquiv.compat (TraceEquiv.refl w')
1034+ apply TraceEquiv.symm
1035+ apply equiv_comm_append_of_indep_symb
1036+ exact h_indep
1037+ apply TraceEquiv.symm
1038+ apply TraceEquiv.trans h_comm
1039+ refine TraceEquiv.compat ?_ (TraceEquiv.refl [c])
1040+ apply TraceEquiv.symm
1041+ apply ih
1042+ intro a b h_dep
1043+ have h_proj := h a b h_dep
1044+ rw [heq] at h_proj
1045+ dsimp [List.proj]
1046+ by_cases hc_in : c ∈ ({a, b} : Finset α)
1047+ · have hw''_empty : w''.filter (· ∈ ({a, b} : Finset α)) = [] := by
1048+ apply List.filter_eq_nil_iff.mpr
1049+ intro c' hc'
1050+ simp at hc_in ⊢
1051+ have hc'_indep := h_indep c (List.mem_singleton_self c) c' hc'
1052+ rcases hc_in with rfl | rfl <;> constructor <;> intro hc'_eq <;> subst hc'_eq
1053+ · exact (inducedIndependence D).irrefl c' hc'_indep
1054+ · exact hc'_indep h_dep
1055+ · exact hc'_indep (D.symm c' c h_dep)
1056+ · exact (inducedIndependence D).irrefl c' hc'_indep
1057+ dsimp [List.proj] at h_proj
1058+ rw [List.filter_append, hw''_empty, List.append_nil]
1059+ nth_rw 2 [List.filter_append] at h_proj
1060+ rw [hw''_empty, List.append_nil, List.filter_append, List.filter_append] at h_proj
1061+ exact List.append_cancel_right h_proj
1062+ · simp at hc_in
1063+ simp [List.proj, List.filter_append, hc_in] at h_proj
1064+ simp
1065+ exact h_proj
1066+
9491067end Trace
9501068
9511069#lint
0 commit comments