|
1 | | -import Mathlib.Algebra.BigOperators.Group.Finset.Defs |
| 1 | +import Mathlib.Algebra.BigOperators.Group.Finset.Basic |
2 | 2 | import Mathlib.Computability.DFA |
3 | 3 | import Mathlib.Computability.Language |
4 | 4 | import TraceTheory.Basic |
@@ -171,6 +171,125 @@ theorem isRegular_lexNf : Language.IsRegular (LexNfLanguage I) := by |
171 | 171 | apply Language.IsRegular.compl |
172 | 172 | apply isRegular_allForbiddenPatterns |
173 | 173 |
|
| 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 | + |
174 | 293 | end LexNf |
175 | 294 |
|
176 | 295 | section rank |
|
0 commit comments