Skip to content

Commit e1b743f

Browse files
committed
Merge remote-tracking branch 'origin/ys-working' into jeff-working
2 parents 8028563 + cb33e01 commit e1b743f

7 files changed

Lines changed: 591 additions & 591 deletions

File tree

TraceTheory/TraceTheory/Defs.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ def mk' : List α →* Trace I where
148148
intro x y
149149
rfl
150150

151+
omit [DecidableEq α] in
152+
@[simp]
153+
theorem mk'_nil : mk' (I := I) [] = 1 := map_one _
154+
151155
/-- The prefix relation on traces. A trace `t₁` is a prefix of `t₂` if there exists
152156
a trace `⟦w⟧` such that `t₁` concatenated with `⟦w⟧` equals `t₂`. -/
153157
def isPrefix (I : Independence α) (t₁ t₂ : Trace I) := ∃ w, mul t₁ ⟦w⟧ = t₂

TraceTheory/TraceTheory/History.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Mathlib.Algebra.Group.Submonoid.Basic
22
import Mathlib.Algebra.Group.Pi.Basic
3-
import TraceTheory.Basic
3+
import TraceTheory.DependenceMorphism
44

55
open TraceTheory
66

@@ -193,7 +193,7 @@ def historyDependenceMorphism (S : Fin n → Finset α) (h_cover : ∀ a, ∃ i,
193193
/-- The trace monoid and `HistoryMonoid` are isomorphic. -/
194194
noncomputable def traceMonoidIsoHistoryMonoid
195195
(S : Fin n → Finset α) (h_cover : ∀ a, ∃ i, a ∈ S i) :
196-
TraceMonoid (inducedIndependence (SigmaDependence S h_cover)) ≃* HistoryMonoid S := by
196+
Trace (inducedIndependence (SigmaDependence S h_cover)) ≃* HistoryMonoid S := by
197197
apply dependenceMorphismIso
198198
traceDependenceMorphism
199199
Quotient.mk_surjective

TraceTheory/TraceTheory/Language.lean

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Mathlib.Algebra.BigOperators.Group.Finset.Defs
1+
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
22
import Mathlib.Computability.DFA
33
import Mathlib.Computability.Language
44
import TraceTheory.Basic
@@ -171,6 +171,125 @@ theorem isRegular_lexNf : Language.IsRegular (LexNfLanguage I) := by
171171
apply Language.IsRegular.compl
172172
apply isRegular_allForbiddenPatterns
173173

174+
omit [LinearOrder α] [Fintype α] in
175+
lemma mem_sigma (x : List α) : x ∈ (Sigma : Language α)∗ := by
176+
rw [Language.mem_kstar]
177+
use [x]
178+
simp only [List.flatten_cons, List.flatten_nil, List.append_nil, List.mem_cons,
179+
List.not_mem_nil, or_false, Sigma, forall_eq, true_and]
180+
apply Set.mem_univ
181+
182+
omit [Fintype α] [LinearOrder α] in
183+
lemma mem_sum_language
184+
{ι : Type*} [DecidableEq ι] {S : Finset ι} {f : ι → Language α} {x : List α} :
185+
x ∈ ∑ i ∈ S, f i ↔ ∃ i ∈ S, x ∈ f i := by
186+
induction S using Finset.induction_on with
187+
| empty => simp
188+
| insert i S hi ih =>
189+
simp only [Finset.sum_insert hi, Language.mem_add]
190+
rw [ih]
191+
constructor
192+
· rintro (hx | ⟨j, hj, hxj⟩)
193+
· exact ⟨i, Finset.mem_insert_self i S, hx⟩
194+
· exact ⟨j, Finset.mem_insert_of_mem hj, hxj⟩
195+
· rintro ⟨j, hj, hxj⟩
196+
simp only [Finset.mem_insert] at hj
197+
rcases hj with (rfl | hj)
198+
· left
199+
exact hxj
200+
· right
201+
exact ⟨j, hj, hxj⟩
202+
203+
lemma mem_forbiddenPattern_iff {x : List α} {a b : α} :
204+
x ∈ ForbiddenPattern I a b ↔
205+
∃ y u z : List α, x = y ++ [b] ++ u ++ [a] ++ z ∧ (∀ c ∈ u, I.rel a c) := by
206+
unfold ForbiddenPattern IndependentLetters
207+
constructor
208+
· intro h
209+
simp [Language.mem_mul] at h
210+
rcases h with ⟨a1, b1, b2, b3, ⟨⟨ha1, hb1, hb2⟩, hb3⟩, ⟨x, hx, rfl⟩⟩
211+
use a1, b2, x
212+
constructor
213+
· simp only [Letter] at hb3 hb1
214+
rw [Set.mem_singleton_iff] at hb3 hb1
215+
subst hb3 hb1
216+
simp
217+
· intro c hc
218+
rw [Language.mem_kstar] at hb2
219+
rcases hb2 with ⟨L, rfl, hL⟩
220+
unfold Letter at hL
221+
simp only [List.mem_flatten] at hc
222+
rcases hc with ⟨y, hy, hcy⟩
223+
have hy_indep := hL y hy
224+
rw [mem_sum_language] at hy_indep
225+
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hy_indep
226+
rcases hy_indep with ⟨c', hc'_rel, hc'_eq⟩
227+
rw [Set.mem_singleton_iff] at hc'_eq
228+
subst hc'_eq
229+
simp only [List.mem_singleton] at hcy
230+
subst hcy
231+
exact hc'_rel
232+
· intro h
233+
rcases h with ⟨y, u, z, rfl, h_indep⟩
234+
simp [Language.mem_mul]
235+
use y, [b], u, [a]
236+
unfold Letter
237+
and_intros
238+
· apply mem_sigma
239+
· rfl
240+
· rw [Language.mem_kstar]
241+
use u.map (fun c => [c])
242+
constructor
243+
· induction u with
244+
| nil => rfl
245+
| cons hd tl ih =>
246+
simp only [List.map_cons, List.flatten_cons, List.cons_append, List.nil_append,
247+
List.cons.injEq, true_and]
248+
simp only [List.mem_cons, forall_eq_or_imp] at h_indep
249+
rw [← ih h_indep.right]
250+
· intro y hy
251+
simp only [List.mem_map] at hy
252+
rcases hy with ⟨c, hc, rfl⟩
253+
rw [mem_sum_language]
254+
simp only [Finset.mem_filter, Finset.mem_univ, true_and]
255+
use c, h_indep c hc
256+
rfl
257+
· rfl
258+
· use z
259+
constructor
260+
· apply mem_sigma
261+
· simp
262+
263+
lemma mem_allForbiddenPatterns_iff {x : List α} :
264+
x ∈ AllForbiddenPatterns I ↔
265+
∃ a b, a < b ∧ I.rel a b ∧ x ∈ ForbiddenPattern I a b := by
266+
unfold AllForbiddenPatterns
267+
rw [mem_sum_language]
268+
simp only [Finset.mem_filter, Finset.mem_univ, true_and, Prod.exists, and_assoc]
269+
270+
/-- The language LexNfLanguage contains exactly the strings satisfying the factor condition. -/
271+
theorem mem_lexNfLanguage_iff_factorCondition (x : List α) :
272+
x ∈ LexNfLanguage I ↔ SatisfiesFactorCondition I x := by
273+
unfold LexNfLanguage SatisfiesFactorCondition
274+
rw [Set.mem_compl_iff, mem_allForbiddenPatterns_iff]
275+
push_neg
276+
constructor
277+
· intro h y u z a b hx h_indep hlt
278+
by_contra h_all_indep
279+
push_neg at h_all_indep
280+
have h_in_pattern : x ∈ ForbiddenPattern I a b := by
281+
rw [mem_forbiddenPattern_iff]
282+
exact ⟨y, u, z, hx, h_all_indep⟩
283+
exact h a b hlt h_indep h_in_pattern
284+
· intro h a b hlt h_indep h_in_pattern
285+
rw [mem_forbiddenPattern_iff] at h_in_pattern
286+
rcases h_in_pattern with ⟨y, u, z, hx, h_all_indep⟩
287+
rcases h y u z a b hx h_indep hlt with ⟨c, hc_mem, hc_not_indep⟩
288+
exact hc_not_indep (h_all_indep c hc_mem)
289+
290+
theorem exists_lexNf_rep (t : Trace I) : ∃ s : List α, ⟦s⟧ = t ∧ s ∈ LexNfLanguage I := by
291+
sorry
292+
174293
end LexNf
175294

176295
section rank

0 commit comments

Comments
 (0)