Skip to content

Commit 8028563

Browse files
committed
Scratchwork for 4.1 (i) => (ii)
1 parent 4564c4e commit 8028563

2 files changed

Lines changed: 219 additions & 13 deletions

File tree

TraceTheory/TraceTheory/Lemmas.lean

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ 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 : α) := (inducedDependence I).rel a b ∧ a ∈ s ∧ b ∈ s
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 : α) := Relation.TransGen (@dependencyIn α I s) a b
6969

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

7272

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

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

7777
def isConnectedT (t : Trace I) := ∀ a b : {a : α // a ∈ t}, dependencyTransClosureInT t a b
7878

@@ -149,32 +149,31 @@ lemma kstar_toTrace_commutes (L : Language α) : @toTrace α I (KStar.kstar L) =
149149
rfl
150150

151151
lemma append_indep_is_disconnected_chars (u v : Trace I) (huv : IndependentT u v)
152-
(a b : { a // a ∈ u * v }) (ha : a.1 ∈ u) (hb : b.1 ∈ v) :
152+
(a b : α) (ha : a ∈ u) (hb : b ∈ v) :
153153
¬ (dependencyTransClosureInT (u * v)) a b := by
154154
intro h
155155
induction h with
156156
| single h =>
157157
rename_i b
158-
apply h
159-
exact huv a b ha hb
158+
have hab := huv a b ha hb
159+
exact h.1 hab
160160
| tail h h_tail ih =>
161161
rename_i b c
162162
simp at ih
163-
have hbu : b.1 ∈ u := by
164-
have hb_uv := mem_append.mp b.2
163+
have hbu : b ∈ u := by
164+
have hb_uv := mem_append.mp h_tail.2.1
165165
simp [ih] at hb_uv
166166
exact hb_uv
167-
simp [dependencyInT, inducedDependence] at h_tail
168-
unfold IndependentT at huv
169-
exact h_tail (huv b c hbu hb)
167+
have hbc := huv b c hbu hb
168+
exact h_tail.1 hbc
170169

171170
lemma append_indep_is_disconnected (u v : Trace I) (h : IndependentT u v) (hu : u ≠ ⟦[]⟧) (hv : v ≠ ⟦[]⟧) :
172171
¬isConnectedT (u * v) := by
173172
by_contra h_con
174173
have ⟨a, ha⟩ := empty_is_eps u hu
175174
have ⟨b, hb⟩ := empty_is_eps v hv
176175
have h_ab_con := h_con ⟨a, mem_append.mpr (Or.inl ha)⟩ ⟨b, mem_append.mpr (Or.inr hb)⟩
177-
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
176+
have h_ab_dis := append_indep_is_disconnected_chars u v h a b ha hb
178177
exact h_ab_dis h_ab_con
179178

180179
lemma connectedComponents_of_connected (T : Set (Trace I)) (h : ∀ t ∈ T, isConnectedT t) :

TraceTheory/TraceTheory/Ochmanski.lean

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import TraceTheory.Language
12
import TraceTheory.Lemmas
23
import TraceTheory.MyhillNerode
34
import TraceTheory.RegularExpressions
@@ -173,4 +174,210 @@ theorem starConnected_is_cRational (X : RegularExpression α) (h : RegularExpres
173174
rw [kstar_eq_minusEps_trace]
174175

175176

177+
178+
lemma depTrClIn_refl {w : List α} {a : α} (h : a ∈ w) : @dependencyTransClosureIn α I w a a := by
179+
unfold dependencyTransClosureIn dependencyIn
180+
apply Relation.TransGen.single
181+
simp [Dependence.refl, h]
182+
183+
noncomputable instance : ∀ w x y, Decidable (@dependencyTransClosureIn α I w x y) :=
184+
fun w x y => Classical.propDecidable (dependencyTransClosureIn w x y)
185+
186+
noncomputable def sep_aux (w₀ w : List α) (p : α) : List (List α × List α) :=
187+
match w with
188+
| [] => [⟨[], []⟩]
189+
| a :: w =>
190+
match sep_aux w₀ w p with
191+
| [] => [] -- dummy value, unreachable by construction
192+
| v :: vs =>
193+
if @dependencyTransClosureIn α I w₀ a p
194+
then match v.2 with
195+
| [] => ⟨a :: v.1, v.2⟩ :: vs
196+
| _ :: _ => ⟨[a], []⟩ :: v :: vs
197+
else ⟨v.1, a :: v.2⟩ :: vs
198+
199+
noncomputable def sep (w : List α) (p : α) : List (List α × List α) := @sep_aux α I w w p
200+
201+
lemma sep_aux_nonempty (w₀ w : List α) (p : α) : (@sep_aux α I w₀ w p) ≠ [] := by
202+
induction w with
203+
| nil => simp [sep_aux]
204+
| cons a u ih =>
205+
simp [sep_aux]
206+
cases hs : sep_aux w₀ u p
207+
· simp [hs] at ih
208+
· simp
209+
by_cases ha : @dependencyTransClosureIn α I w₀ a p
210+
· rename_i s_head s_tail
211+
cases s_head.2
212+
all_goals simp [ha]
213+
· simp [ha]
214+
215+
lemma sep_aux_zero_idx {w₀ w : List α} {p : α} : 0 < (@sep_aux α I w₀ w p).length := List.length_pos_iff.mpr (sep_aux_nonempty _ _ _)
216+
217+
lemma sep_nonempty (w : List α) (p : α) : (@sep α I w p) ≠ [] := sep_aux_nonempty w w p
218+
219+
lemma sep_invar (u w : List α) (a p : α) (i : Fin (@sep_aux α I (u ++ [p]) (w ++ [p]) p).length) :
220+
(@sep_aux α I (u ++ [p]) (a :: w ++ [p]) p)[i] = (@sep_aux α I (u ++ [p]) (w ++ [p]) p)[i] ∨
221+
(@sep_aux α I (u ++ [p]) (a :: w ++ [p]) p)[i] = (@sep_aux α I (u ++ [p]) (w ++ [p]) p)[i]
222+
:= by
223+
simp [sep_aux]
224+
225+
lemma sep_aux_1_nonempty_head (u w : List α) (p : α) (h : w ≠ []) :
226+
((@sep_aux α I (u ++ [p]) (w ++ [p]) p)[0]'(sep_aux_zero_idx)).1 ≠ [] := by
227+
induction w with
228+
| nil => simp at h
229+
| cons a w ih =>
230+
clear h
231+
by_cases hw : w = []
232+
· simp [hw, sep_aux, depTrClIn_refl]
233+
by_cases hau : @dependencyTransClosureIn α I (u ++ [p]) a p
234+
all_goals simp [hau]
235+
· simp [hw] at ih
236+
let t := @sep_aux α I (u ++ [p]) (w ++ [p]) p
237+
have ht : @sep_aux α I (u ++ [p]) (w ++ [p]) p = t := rfl
238+
rcases t
239+
· exfalso
240+
exact sep_aux_nonempty _ _ _ ht
241+
· rename_i s_head s_tail
242+
by_cases hau : @dependencyTransClosureIn α I (u ++ [p]) a p
243+
· suffices hs_dec : ∃ _1 _2 _3 _4, (@sep_aux α I (u ++ [p]) (a :: w ++ [p]) p) = (_1 ::_2, _3) :: _4 from by
244+
replace ⟨_1, _2, _3, _4, hs_dec⟩ := hs_dec
245+
rw [List.getElem_of_eq hs_dec]
246+
simp
247+
simp [sep_aux, ht, hau]
248+
cases s_head.2
249+
· simp
250+
· simp
251+
· simp [sep_aux, ht, hau]
252+
have hs_dec : (@sep_aux α I (u ++ [p]) (w ++ [p]) p)[0]'(sep_aux_zero_idx) = (s_head :: s_tail)[0] := List.getElem_of_eq ht _
253+
simp [hs_dec] at ih
254+
exact ih
255+
256+
lemma sep_aux_1_nonempty (u w : List α) (p : α) (i : Fin (@sep_aux α I (u ++ [p]) (w ++ [p]) p).length) (h : w ≠ []) :
257+
(@sep_aux α I (u ++ [p]) (w ++ [p]) p)[i].1 ≠ [] := by
258+
induction w with
259+
| nil => simp at h
260+
| cons a w ih =>
261+
clear h
262+
by_cases hw : w = []
263+
· rcases i with ⟨i, hi⟩
264+
simp [hw, sep_aux, depTrClIn_refl]
265+
by_cases hau : @dependencyTransClosureIn α I (u ++ [p]) a p
266+
all_goals simp [hau]
267+
· simp [hw] at ih
268+
rcases i with ⟨i, hi⟩
269+
cases i with
270+
| zero => exact sep_aux_1_nonempty_head _ _ _ (by simp)
271+
| succ i =>
272+
by_cases hau : @dependencyTransClosureIn α I (u ++ [p]) a p
273+
· let temp := @sep_aux α I (u ++ [p]) (w ++ [p]) p
274+
have htemp : @sep_aux α I (u ++ [p]) (w ++ [p]) p = temp := rfl
275+
rcases temp
276+
· exfalso
277+
exact sep_aux_nonempty _ _ _ htemp
278+
· rename_i s_head s_tail
279+
suffices hs_dec : (∃ _1 _2, (@sep_aux α I (u ++ [p]) (a :: w ++ [p]) p) = _1 :: _2) from by
280+
replace ⟨_1, _2, hs_dec⟩ := hs_dec
281+
have h_2ne : (_2[i]'(by rw [hs_dec] at hi; exact Nat.succ_lt_succ_iff.mp hi)).1 ≠ [] := by
282+
simp [sep_aux, htemp, hau] at hs_dec
283+
contrapose hs_dec
284+
cases s_head.2
285+
· simp
286+
intro _
287+
contrapose hs_dec
288+
rw [<- List.getElem_of_eq hs_dec]
289+
· simp
290+
intro _
291+
contrapose hs_dec
292+
rw [<- List.getElem_of_eq hs_dec, <- List.getElem_of_eq htemp]
293+
· exact ih ⟨i, by sorry
294+
· rw [<- htemp]
295+
sorry
296+
rw [Fin.getElem_fin]
297+
rw [List.getElem_of_eq hs_dec]
298+
simp [h_2ne]
299+
simp [sep_aux, htemp, hau]
300+
cases s_head.2
301+
· simp
302+
· simp
303+
· suffices hs_dec : (∃ _1 _2, (@sep_aux α I (u ++ [p]) (a :: w ++ [p]) p) = _1 :: _2) from by
304+
replace ⟨_1, _2, hs_dec⟩ := hs_dec
305+
have h_2ne : (_2[i]'(by rw [hs_dec] at hi; exact Nat.succ_lt_succ_iff.mp hi)).1 ≠ [] := by
306+
sorry
307+
rw [Fin.getElem_fin]
308+
rw [List.getElem_of_eq hs_dec]
309+
simp [h_2ne]
310+
simp [sep_aux, hau]
311+
let temp := @sep_aux α I (u ++ [p]) (w ++ [p]) p
312+
have htemp : @sep_aux α I (u ++ [p]) (w ++ [p]) p = temp := rfl
313+
rcases temp
314+
· exfalso
315+
exact sep_aux_nonempty _ _ _ htemp
316+
· simp [htemp]
317+
318+
lemma sep_aux_2_nonempty (u w : List α) (p : α) (i : Fin (@sep_aux α I (u ++ [p]) (w ++ [p]) p).length) (h : w ≠ []) (hi : i.1 > 0) :
319+
(@sep_aux α I (u ++ [p]) (w ++ [p]) p)[i].2 ≠ [] := by sorry
320+
321+
322+
323+
def proj2 (S : Set α) (hd : ∀ x, Decidable (x ∈ S)) (w : List α) : List α := w.filter (· ∈ S)
324+
325+
lemma proj2_prop {S : Set α} {hd : ∀ x, Decidable (x ∈ S)} {w : List α} {a : α} : a ∈ proj2 S hd w → a ∈ S := by
326+
induction w with
327+
| nil => simp [proj2]
328+
| cons b u ih =>
329+
intro h
330+
by_cases hab : a = b
331+
· simp [proj2, <- hab] at h
332+
exact h
333+
· simp [proj2] at h
334+
exact h.2
335+
336+
variable [LinearOrder α] in
337+
theorem lexNf_dup_lexNf_isConnected {w : List α} (h : IsLexNf I (w ++ w)) : @isConnected α I w := by
338+
have h' : IsLexNf I w := by
339+
contrapose h
340+
simp [IsLexNf] at h ⊢
341+
rcases h with ⟨u, h⟩
342+
use w ++ u
343+
exact ⟨TraceEqv.compat (TraceEqv.refl w) h.1, List.append_left_lt h.right⟩
344+
345+
by_contra h_con
346+
simp [isConnected] at h_con
347+
choose a ha b hb h_con using h_con
348+
let A := {x | @dependencyTransClosureIn α I w a x}
349+
let B := {x | ¬ @dependencyTransClosureIn α I w a x}
350+
have hA_dec : ∀ x, Decidable (x ∈ A) := fun x => Classical.propDecidable (x ∈ A)
351+
have hB_dec : ∀ x, Decidable (x ∈ B) := fun x => Classical.propDecidable (x ∈ B)
352+
let u := proj2 A hA_dec w
353+
let v := proj2 B hB_dec w
354+
have : Independent I u v := by
355+
intro j hj k hk
356+
have hjw : j ∈ w := List.mem_of_mem_filter hj
357+
have hkw : k ∈ w := List.mem_of_mem_filter hk
358+
unfold u at hj
359+
unfold v at hk
360+
replace hj := proj2_prop hj
361+
replace hk := proj2_prop hk
362+
replace hj : @dependencyTransClosureIn α I w a j := hj
363+
replace hk : ¬@dependencyTransClosureIn α I w a k := hk
364+
by_contra hjk
365+
366+
have : @dependencyTransClosureInCoe α I w a k := by
367+
rcases hj with ⟨ha', hjw', hj⟩
368+
have : @dependencyIn α I w ⟨j, hjw'⟩ ⟨k, hkw⟩ := hjk ∘ fun a => a
369+
use ha', hkw
370+
unfold dependencyTransClosureIn at hj ⊢
371+
exact Relation.TransGen.tail hj this
372+
373+
exact hk this
374+
375+
have : a ∈ u := by
376+
have ha_A : a ∈ A := ⟨ha, ha, Relation.TransGen.single ((inducedDependence I).refl a)⟩
377+
exact List.mem_filter_of_mem ha (decide_eq_true ha_A)
378+
have : b ∈ v := by
379+
have hb_B : b ∈ B := by simp [B, dependencyTransClosureInCoe, h_con]
380+
exact List.mem_filter_of_mem hb (decide_eq_true hb_B)
381+
382+
176383
end TraceTheory

0 commit comments

Comments
 (0)