Skip to content

Commit 8300d76

Browse files
committed
Fix Ochmanski for refactor
1 parent 01d0ad1 commit 8300d76

6 files changed

Lines changed: 92 additions & 106 deletions

File tree

TraceTheory/TraceTheory/Basic.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ theorem indep_of_comm_singleton {u v w : List α} {a : α} [DecidableEq α]
287287
(h : TraceEqv I (u ++ [a] ++ v) (w ++ [a])) (h_mem : a ∉ v) :
288288
Independent I [a] v := by
289289
induction v using reverseRecOn generalizing w with
290-
| nil =>
291-
simp
290+
| nil => simp
292291
| append_singleton x b ih =>
293292
intro a' ha' b' hb'
294293
simp at ha' hb' h_mem
@@ -308,8 +307,7 @@ theorem indep_of_comm_singleton {u v w : List α} {a : α} [DecidableEq α]
308307
theorem comm_singleton_of_indep {w : List α} {a : α} (h : Independent I [a] w) :
309308
TraceEqv I (w ++ [a]) ([a] ++ w) := by
310309
induction w using reverseRecOn with
311-
| nil =>
312-
apply TraceEqv.refl
310+
| nil => apply TraceEqv.refl
313311
| append_singleton w' b ih =>
314312
simp at h
315313
have haw' : Independent I [a] w' := by

TraceTheory/TraceTheory/Lemmas.lean

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,25 @@ lemma traceFlatten_append {u : Trace I} (L : List (Trace I)) : traceFlatten (u :
6363
simp
6464

6565

66-
def dependencyIn' (s : List α) (a b : {a : α // a ∈ s}) := (inducedDependence I).rel a b
66+
def dependencyIn (s : List α) (a b : {a : α // a ∈ s}) := (inducedDependence I).rel a b
6767

68-
def dependencyTransClosureIn' (s : List α) (a b : {a : α // a ∈ s}) := Relation.TransGen (@dependencyIn' α I s) a b
68+
def dependencyTransClosureIn (s : List α) (a b : {a : α // a ∈ s}) := Relation.TransGen (@dependencyIn α I s) a b
6969

70-
def isConnected' (s : List α) := ∀ a b : {a : α // a ∈ s}, @dependencyTransClosureIn' α I s a b
70+
def isConnected (s : List α) := ∀ a b : {a : α // a ∈ s}, @dependencyTransClosureIn α I s a b
7171

7272

73-
def dependencyIn (t : Trace I) (a b : {a : α // a ∈ t}) := (inducedDependence I).rel a b
73+
def dependencyInT (t : Trace I) (a b : {a : α // a ∈ t}) := (inducedDependence I).rel a b
7474

75-
def dependencyTransClosureIn (t : Trace I) (a b : {a : α // a ∈ t}) := Relation.TransGen (dependencyIn t) a b
75+
def dependencyTransClosureInT (t : Trace I) (a b : {a : α // a ∈ t}) := Relation.TransGen (dependencyInT t) a b
7676

77-
def isConnected (t : Trace I) := ∀ a b : {a : α // a ∈ t}, dependencyTransClosureIn t a b
77+
def isConnectedT (t : Trace I) := ∀ a b : {a : α // a ∈ t}, dependencyTransClosureInT t a b
7878

7979

80-
lemma dependencyIn_toTrace (s : List α) : @dependencyIn' α I s = @dependencyIn α I ⟦s⟧ := rfl
80+
lemma dependencyIn_toTrace (s : List α) : @dependencyIn α I s = @dependencyInT α I ⟦s⟧ := rfl
8181

82-
lemma dependencyTransClosureIn_toTrace (s : List α) : @dependencyTransClosureIn' α I s = @dependencyTransClosureIn α I ⟦s⟧ := rfl
82+
lemma dependencyTransClosureIn_toTrace (s : List α) : @dependencyTransClosureIn α I s = @dependencyTransClosureInT α I ⟦s⟧ := rfl
8383

84-
lemma isConnected_toTrace (s : List α) : @isConnected' α I s = @isConnected α I ⟦s⟧ := rfl
84+
lemma isConnected_toTrace (s : List α) : @isConnected α I s = @isConnectedT α I ⟦s⟧ := rfl
8585

8686

8787
def isIterativeFactor (X : Language α) (t : List α) :=
@@ -92,9 +92,9 @@ def toTrace (X : Language α) : Set (Trace I) := (fun s => ⟦s⟧) '' X
9292

9393
def kstar (T : Set (Trace I)) := {r | ∃ ts : List (Trace I), (∀ t' ∈ ts, t' ∈ T) ∧ r = traceFlatten ts}
9494

95-
def independent' (u v : Trace I) := ∀ a b, a ∈ u → b ∈ v → I.rel a b
95+
def IndependentT (u v : Trace I) := ∀ a b, a ∈ u → b ∈ v → I.rel a b
9696

97-
def connectedComponents (X : Set (Trace I)) : Set (Trace I) := {u | isConnected u ∧ u ≠ ⟦[]⟧ ∧ ∃ v, u * v ∈ X ∧ independent' u v}
97+
def connectedComponents (X : Set (Trace I)) : Set (Trace I) := {u | isConnectedT u ∧ u ≠ ⟦[]⟧ ∧ ∃ v, u * v ∈ X ∧ IndependentT u v}
9898

9999

100100
-- open Computability
@@ -105,17 +105,13 @@ lemma kstar_toTrace_commutes (L : Language α) : @toTrace α I (KStar.kstar L) =
105105
intro t
106106
apply Iff.intro
107107
all_goals simp [kstar]
108-
· intro ws hws hw
108+
· intro ws hL ht
109109
induction ws generalizing t with
110110
| nil =>
111-
intro hL ht
112111
use []
113-
simp at hw
114-
rw [hw] at ht
115-
simp [ht, traceFlatten]
112+
simp [<- ht, traceFlatten]
116113
| cons u ws ih =>
117114
simp at ih
118-
intro hL ht
119115
replace ih := ih (fun y hy => hL y (List.mem_cons_of_mem u hy))
120116
choose ts hts using ih
121117
use ⟦u⟧ :: ts
@@ -124,7 +120,7 @@ lemma kstar_toTrace_commutes (L : Language α) : @toTrace α I (KStar.kstar L) =
124120
cases hs with
125121
| head => use u; simp [hL]
126122
| tail s hs => exact hts.left s hs
127-
· simp [<- ht, hw]
123+
· simp [<- ht]
128124
-- rw [<- mul_def]
129125
rw [traceFlatten_append, <- hts.right]
130126
rfl
@@ -133,30 +129,28 @@ lemma kstar_toTrace_commutes (L : Language α) : @toTrace α I (KStar.kstar L) =
133129
| nil =>
134130
use []
135131
simp [ht, traceFlatten]
136-
use []
137-
simp
138132
| cons s ts ih =>
139133
simp at ih
140134
replace ih := ih (fun y hy => hts y (List.mem_cons_of_mem s hy))
141-
choose w hws hw using ih
135+
choose ws hL hws using ih
142136
rcases s with ⟨u⟩
143137
rw [show Quot.mk (⇑(TraceSetoid I)) u = ⟦u⟧ from rfl] at ht hts
144138
replace hts := hts ⟦u⟧
145139
simp at hts
146140
choose u' hu' using hts
147-
use u' ++ w
141+
use u' :: ws
148142
apply And.intro
149-
· rcases hws with ⟨ws, hws⟩
150-
use u' :: ws
151-
simp [hws.left, hu']
152-
exact hws.right
143+
· intro y hy
144+
cases hy with
145+
| head => exact hu'.left
146+
| tail y hy => exact hL y hy
153147
· simp [ht]
154-
rw [traceFlatten_append, <- hw, <- hu'.right]
148+
rw [traceFlatten_append, <- hws, <- hu'.right]
155149
rfl
156150

157-
lemma append_indep_is_disconnected_chars (u v : Trace I) (huv : independent' u v)
151+
lemma append_indep_is_disconnected_chars (u v : Trace I) (huv : IndependentT u v)
158152
(a b : { a // a ∈ u * v }) (ha : a.1 ∈ u) (hb : b.1 ∈ v) :
159-
¬ (dependencyTransClosureIn (u * v)) a b := by
153+
¬ (dependencyTransClosureInT (u * v)) a b := by
160154
intro h
161155
induction h with
162156
| single h =>
@@ -170,20 +164,20 @@ lemma append_indep_is_disconnected_chars (u v : Trace I) (huv : independent' u v
170164
have hb_uv := mem_append.mp b.2
171165
simp [ih] at hb_uv
172166
exact hb_uv
173-
simp [dependencyIn, inducedDependence] at h_tail
174-
unfold independent' at huv
167+
simp [dependencyInT, inducedDependence] at h_tail
168+
unfold IndependentT at huv
175169
exact h_tail (huv b c hbu hb)
176170

177-
lemma append_indep_is_disconnected (u v : Trace I) (h : independent' u v) (hu : u ≠ ⟦[]⟧) (hv : v ≠ ⟦[]⟧) :
178-
¬isConnected (u * v) := by
171+
lemma append_indep_is_disconnected (u v : Trace I) (h : IndependentT u v) (hu : u ≠ ⟦[]⟧) (hv : v ≠ ⟦[]⟧) :
172+
¬isConnectedT (u * v) := by
179173
by_contra h_con
180174
have ⟨a, ha⟩ := empty_is_eps u hu
181175
have ⟨b, hb⟩ := empty_is_eps v hv
182176
have h_ab_con := h_con ⟨a, mem_append.mpr (Or.inl ha)⟩ ⟨b, mem_append.mpr (Or.inr hb)⟩
183177
have h_ab_dis := append_indep_is_disconnected_chars u v h ⟨a, mem_append.mpr (Or.inl ha)⟩ ⟨b, mem_append.mpr (Or.inr hb)⟩ ha hb
184178
exact h_ab_dis h_ab_con
185179

186-
lemma connectedComponents_of_connected (T : Set (Trace I)) (h : ∀ t ∈ T, isConnected t) :
180+
lemma connectedComponents_of_connected (T : Set (Trace I)) (h : ∀ t ∈ T, isConnectedT t) :
187181
connectedComponents T = T \ {⟦[]⟧} := by
188182
apply Set.ext
189183
intro t
@@ -200,7 +194,7 @@ lemma connectedComponents_of_connected (T : Set (Trace I)) (h : ∀ t ∈ T, isC
200194
use (h t ht), htz, ⟦[]⟧
201195
rw [right_id]
202196
use ht
203-
unfold independent'
197+
unfold IndependentT
204198
simp [show ⟦[]⟧ = mk' [] from rfl, eps_is_empty]
205199

206200
lemma empty_iff {w : List α} : (⟦w⟧ : Trace I) = ⟦[]⟧ ↔ w = [] := by
@@ -209,7 +203,7 @@ lemma empty_iff {w : List α} : (⟦w⟧ : Trace I) = ⟦[]⟧ ↔ w = [] := by
209203
| cons a u =>
210204
apply Iff.intro
211205
· intro h
212-
have h_au := length_eq_of_equiv (Quotient.exact h)
206+
have h_au := length_eq_of_eqv (Quotient.exact h)
213207
simp at h_au
214208
· simp
215209

@@ -223,7 +217,8 @@ def isEmpty : Trace I → Bool := Quotient.lift List.isEmpty (by
223217
| cons b v => rfl
224218
)
225219

226-
lemma isEmpty_iff {t : Trace I} : t.isEmpty = true ↔ t = ⟦[]⟧ := by
220+
--lemma isEmpty_iff {t : Trace I} : t.isEmpty = true ↔ t = ⟦[]⟧ := by
221+
lemma isEmpty_iff {t : Trace I} : isEmpty t = true ↔ t = ⟦[]⟧ := by
227222
apply Iff.intro
228223
· intro h
229224
rcases t with ⟨s⟩
@@ -234,10 +229,10 @@ lemma isEmpty_iff {t : Trace I} : t.isEmpty = true ↔ t = ⟦[]⟧ := by
234229
rfl
235230

236231
lemma traceFlatten_filter_not_isEmpty :
237-
∀ {L : List (Trace I)}, traceFlatten (List.filter (!·.isEmpty) L) = traceFlatten L
232+
∀ {L : List (Trace I)}, traceFlatten (List.filter (!isEmpty ·) L) = traceFlatten L
238233
| [] => rfl
239234
| t :: L => by
240-
by_cases ht : t.isEmpty
235+
by_cases ht : isEmpty t
241236
· apply isEmpty_iff.mp at ht
242237
simp [ht]
243238
simp [show isEmpty ⟦[]⟧ = true from rfl]
@@ -271,11 +266,11 @@ lemma kstar_eq_minusEps_trace (T : Set (Trace I)) : kstar (T \ {⟦[]⟧}) = kst
271266
simp [ht]
272267
exact fun y hy => Set.diff_subset (hls y hy)
273268
· intro ⟨ls, hls, ht⟩
274-
use ls.filter (!·.isEmpty)
269+
use ls.filter (!isEmpty ·)
275270
simp
276271
apply And.intro
277272
· intro y hy hyz
278-
exact ⟨hls y hy, Trace.isEmpty_iff.ne.mp (ne_true_of_eq_false hyz)⟩
273+
exact ⟨hls y hy, isEmpty_iff.ne.mp (ne_true_of_eq_false hyz)⟩
279274
· simp [traceFlatten_filter_not_isEmpty, ht]
280275

281276
end TraceTheory

TraceTheory/TraceTheory/MyhillNerode.lean

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
import TraceTheory.Basic
1+
import TraceTheory.Lemmas
22
import Mathlib.Data.Finset.Pi
33

44
namespace TraceTheory
55

66
variable {α : Type} {I : Independence α}
77

8-
lemma indep_of_flatten {u : List α} {vs : List (List α)} (i : Fin vs.length) (h : independent I u vs.flatten) :
9-
independent I u vs[i] := by
8+
lemma indep_of_flatten {u : List α} {vs : List (List α)} (i : Fin vs.length) (h : Independent I u vs.flatten) :
9+
Independent I u vs[i] := by
1010
replace ⟨i, hi⟩ := i
1111
induction vs generalizing i with
1212
| nil =>
1313
simp at hi
1414
| cons v vs' ih =>
15-
simp at h ⊢
15+
simp [-Independent] at h ⊢
1616
cases i with
17-
| zero => exact (indep_of_concat h).left
17+
| zero => exact (indep_of_indep_append_right h).left
1818
| succ i =>
1919
simp at hi
20-
exact ih (indep_of_concat h).right i hi
20+
exact ih (indep_of_indep_append_right h).right i hi
2121

2222
/-- (i) → (ii) of Corollary (2.3) in `Partial Commutation and Traces`.
2323
Note that t₁, t₂, …, tₙ is expressed as a list [ts], and (t₁ ++ t₂ ++ … ++ tₙ) via [ts.flatten].
2424
Similarly, p₁, …, pₙ is [ps] and q₁, …, qₙ is [qs]. -/
25-
theorem levi_lemma_gen (u v : List α) (ts : List (List α)) [DecidableEq α] (h : TraceEquiv I (u ++ v) ts.flatten) :
25+
theorem levi_lemma_gen (u v : List α) (ts : List (List α)) [DecidableEq α] (h : TraceEqv I (u ++ v) ts.flatten) :
2626
∃ (ps qs : List (List α)),
2727
ps.length = ts.length
2828
∧ qs.length = ts.length
29-
TraceEquiv I u ps.flatten
30-
TraceEquiv I v qs.flatten
31-
∧ (∀ i : Fin (min ts.length (min ps.length qs.length)), TraceEquiv I ts[i] (ps[i] ++ qs[i]))
32-
∧ ∀ i : Fin qs.length, ∀ j : Fin ps.length, i.val < j.val → independent I qs[i] ps[j] := by
29+
TraceEqv I u ps.flatten
30+
TraceEqv I v qs.flatten
31+
∧ (∀ i : Fin (min ts.length (min ps.length qs.length)), TraceEqv I ts[i] (ps[i] ++ qs[i]))
32+
∧ ∀ i : Fin qs.length, ∀ j : Fin ps.length, i.val < j.val → Independent I qs[i] ps[j] := by
3333
induction ts generalizing u v with
3434
| nil =>
3535
simp at h ⊢
36-
replace h := length_eq_of_equiv h
36+
replace h := length_eq_of_eqv h
3737
simp at h
38-
simp [h, TraceEquiv.refl]
38+
simp [h, TraceEqv.refl]
3939
intro ⟨i, hi⟩
4040
simp at hi
4141
| cons t tsuf ih =>
@@ -47,12 +47,12 @@ theorem levi_lemma_gen (u v : List α) (ts : List (List α)) [DecidableEq α] (h
4747
repeat' apply And.intro
4848
· simp [ih_p_len]
4949
· simp [ih_q_len]
50-
· apply TraceEquiv.trans h_up
50+
· apply TraceEqv.trans h_up
5151
simp
52-
exact TraceEquiv.compat (TraceEquiv.refl p) ih_p
53-
· apply TraceEquiv.trans h_vq
52+
exact TraceEqv.compat (TraceEqv.refl p) ih_p
53+
· apply TraceEqv.trans h_vq
5454
simp
55-
exact TraceEquiv.compat (TraceEquiv.refl q) ih_q
55+
exact TraceEqv.compat (TraceEqv.refl q) ih_q
5656
· intro ⟨i, hi⟩
5757
by_cases hzi : i = 0
5858
· simp [hzi, h_tpq]
@@ -68,7 +68,7 @@ theorem levi_lemma_gen (u v : List α) (ts : List (List α)) [DecidableEq α] (h
6868
cases i with
6969
| zero =>
7070
simp at hj ⊢
71-
have h_ind_ps := indep_of_indep_of_equiv (indep_symm h_ind) ih_p
71+
have h_ind_ps := indep_of_indep_of_eqv (independent_symm h_ind) ih_p
7272
exact indep_of_flatten ⟨j, hj⟩ h_ind_ps
7373
| succ i =>
7474
simp at hi hj hij ⊢

0 commit comments

Comments
 (0)