Skip to content

Commit 34f4815

Browse files
committed
Merge remote-tracking branch 'origin/ys-working' into jeff-working
2 parents c74911a + 6d9989f commit 34f4815

3 files changed

Lines changed: 381 additions & 98 deletions

File tree

TraceTheory/TraceTheory/Language.lean

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,11 @@ theorem traceClosure.idem {X : Language α} :
368368
def IsValidFactorization
369369
(I : Independence α) (X : Language α) (x y : List α) (xs ys : List (List α)) : Prop :=
370370
xs.length = ys.length ∧
371-
(List.zipWith (· ++ ·) xs ys).flatten ∈ X ∧
371+
(List.zipWith (· ++ ·) xs ys).flatten ∈ traceClosure I X ∧
372372
TraceEqv I x xs.flatten ∧
373373
TraceEqv I y ys.flatten ∧
374-
∀ i : ℕ, ∀ (h : i + 1 < xs.length),
375-
Independent I (xs[i + 1]'(h)) ((ys.take (i + 1)).flatten)
374+
∀ i j (hi : i < ys.length) (hj : j < xs.length), i < j →
375+
Independent I ys[i] xs[j]
376376

377377
/-- Predicate for language `X` having rank at most `k`. -/
378378
def HasRankAtMost (I : Independence α) (X : Language α) (k : ℕ) : Prop :=
@@ -407,22 +407,24 @@ theorem concat_closed_rank (X₁ X₂ : Language α) (h₁ : IsClosed I X₁) (h
407407
replace h₁ := h₁ (z₁ ++ z₃)
408408
replace h₂ := h₂ (z₂ ++ z₄)
409409
rw [Set.mem_setOf] at h₁ h₂
410-
use z₁ ++ z₃
410+
use z₁ ++ z₃ ++ (z₂ ++ z₄)
411411
constructor
412-
· apply h₁.mp
413-
use x₁
414-
· use z₂ ++ z₄
415-
simp only [List.append_assoc, and_true]
416-
apply h₂.mp
417-
use x₂
412+
· rw [Language.mem_mul]
413+
exact ⟨z₁ ++ z₃, h₁.mp ⟨x₁, hx₁, hx₁_eqv⟩, z₂ ++ z₄, h₂.mp ⟨x₂, hx₂, hx₂_eqv⟩, rfl⟩
414+
· apply TraceEqv.refl
418415
· simpa
419416
· simpa
420-
· intro i hlt
417+
· intro i j
418+
simp only [List.length_cons, List.length_nil, zero_add, Nat.reduceAdd, Independent]
419+
intro hi hj hlt
421420
cases i with
422-
| zero => simpa using h_indep
423-
| succ i' =>
424-
simp only [List.length_cons, List.length_nil, zero_add, Nat.reduceAdd] at hlt
425-
contradiction
421+
| zero =>
422+
cases j with
423+
| zero => contradiction
424+
| succ j' =>
425+
simp only [List.getElem_cons_zero, List.getElem_cons_succ, List.getElem_singleton]
426+
exact independent_symm h_indep
427+
| succ i' => omega
426428

427429
end rank
428430

TraceTheory/TraceTheory/MyhillNerode.lean

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ namespace TraceTheory
99
variable {α : Type*} {I : Independence α}
1010

1111
lemma indep_of_flatten {u : List α} {vs : List (List α)}
12-
(i : Fin vs.length) (h : Independent I u vs.flatten) :
13-
Independent I u vs[i] := by
14-
rcases i with ⟨i, hi⟩
12+
(i : ℕ) (hi : i < vs.length) (h : Independent I u vs.flatten) :
13+
Independent I u (vs[i]'(hi)) := by
1514
induction vs generalizing i with
1615
| nil => contradiction
1716
| cons v vs' ih =>
1817
simp [-Independent] at h ⊢
1918
cases i with
2019
| zero => exact (indep_of_indep_append_right h).left
21-
| succ i =>
22-
simp at hi
23-
exact ih (indep_of_indep_append_right h).right i hi
20+
| succ i' =>
21+
simp only [List.length_cons, add_lt_add_iff_right] at hi
22+
exact ih i' hi (indep_of_indep_append_right h).right
2423

2524
/-- (i) → (ii) of Corollary (2.3) in `Partial Commutation and Traces`.
2625
Note that t₁, t₂, …, tₙ is expressed as a list [ts], and (t₁ ++ t₂ ++ … ++ tₙ) via [ts.flatten].
@@ -32,55 +31,48 @@ theorem levi_lemma_gen {u v : List α} {ts : List (List α)} [DecidableEq α]
3231
qs.length = ts.length ∧
3332
TraceEqv I u ps.flatten ∧
3433
TraceEqv I v qs.flatten ∧
35-
(∀ i : Fin (min ts.length (min ps.length qs.length)), TraceEqv I ts[i] (ps[i] ++ qs[i])) ∧
36-
∀ i : Fin qs.length, ∀ j : Fin ps.length, i.val < j.val → Independent I qs[i] ps[j] := by
34+
(∀ i (ht : i < ts.length) (hp : i < ps.length) (hq : i < qs.length),
35+
TraceEqv I ts[i] (ps[i] ++ qs[i])) ∧
36+
(∀ i j (hi : i < qs.length) (hj : j < ps.length), i < j →
37+
Independent I qs[i] ps[j]) := by
3738
induction ts generalizing u v with
3839
| nil =>
39-
rw [List.flatten_nil] at h
40-
replace h := length_eq_of_eqv h
41-
simp only [List.length_append, List.length_nil, Nat.add_eq_zero_iff,
42-
List.length_eq_zero_iff] at h
43-
rcases h with ⟨rfl, rfl⟩
40+
simp only [List.flatten_nil] at h
41+
have h_len := length_eq_of_eqv h
42+
simp only [List.length_append, List.length_nil] at h_len
43+
have hu : u = [] := List.length_eq_zero_iff.mp (by omega)
44+
have hv : v = [] := List.length_eq_zero_iff.mp (by omega)
45+
subst hu hv
4446
use [], []
45-
simp only [List.length_nil, List.flatten_nil, Fin.getElem_fin, Independent, IsEmpty.forall_iff,
46-
and_true, true_and, TraceEqv.refl]
47-
intro ⟨i, hi⟩
48-
contradiction
47+
simp [TraceEqv.refl]
4948
| cons t tsuf ih =>
5049
rcases levi_lemma h with ⟨p, psuf, q, qsuf, h_ind, h_up, h_vq, h_tpq, h_tpq_suf⟩
5150
rcases ih h_tpq_suf.symm with ⟨ps_i, qs_i, ih_p_len, ih_q_len, ih_p, ih_q, ih_tpq, ih_ind⟩
5251
use p :: ps_i, q :: qs_i
5352
and_intros
54-
· simpa
55-
· simpa
53+
· simp [ih_p_len]
54+
· simp [ih_q_len]
5655
· apply TraceEqv.trans h_up
5756
simp only [List.flatten_cons]
5857
exact TraceEqv.compat (TraceEqv.refl p) ih_p
5958
· apply TraceEqv.trans h_vq
6059
simp only [List.flatten_cons]
6160
exact TraceEqv.compat (TraceEqv.refl q) ih_q
62-
· intro ⟨i, hi⟩
63-
by_cases hzi : i = 0
64-
· simp [hzi, h_tpq]
65-
· cases i with
66-
| zero => contradiction
67-
| succ i =>
68-
simp only [List.length_cons, Nat.add_min_add_right, Nat.add_lt_add_iff_right, lt_inf_iff,
69-
Fin.getElem_fin, List.getElem_cons_succ] at hi ⊢
70-
exact ih_tpq ⟨i, by simpa⟩
71-
· intro ⟨i, hi⟩ ⟨j, hj⟩ hij
61+
· intro i ht hp hq
62+
cases i with
63+
| zero => exact h_tpq
64+
| succ i' => apply ih_tpq i'
65+
· intro i j hi hj hij
7266
cases j with
7367
| zero => contradiction
74-
| succ j =>
68+
| succ j' =>
7569
cases i with
7670
| zero =>
77-
simp only [List.length_cons, Nat.add_lt_add_iff_right, Independent, Fin.zero_eta,
78-
Fin.getElem_fin, Fin.val_zero, List.getElem_cons_zero, List.getElem_cons_succ] at hj ⊢
79-
exact indep_of_flatten ⟨j, hj⟩ (indep_of_indep_of_eqv (independent_symm h_ind) ih_p)
80-
| succ i =>
81-
simp only [List.length_cons, Nat.add_lt_add_iff_right, Independent, Fin.getElem_fin,
82-
List.getElem_cons_succ] at hi hj hij ⊢
83-
exact ih_ind ⟨i, hi⟩ ⟨j, hj⟩ hij
71+
simp only [List.length_cons, add_lt_add_iff_right] at hj
72+
exact indep_of_flatten j' hj (indep_of_indep_of_eqv (independent_symm h_ind) ih_p)
73+
| succ i' =>
74+
apply ih_ind i' j'
75+
exact Nat.succ_lt_succ_iff.mp hij
8476

8577
variable {M : Type} {σ : Type} [Monoid M] [Monoid α]
8678

0 commit comments

Comments
 (0)