Skip to content

Commit 0f0e41a

Browse files
committed
Progress star of closed and connected has finite rank
1 parent b861b33 commit 0f0e41a

2 files changed

Lines changed: 174 additions & 44 deletions

File tree

TraceTheory/TraceTheory/MyhillNerode.lean

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ 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
cases i with
19-
| zero => simp_all
18+
| zero =>
19+
simp only [List.flatten_cons] at h
20+
exact (indep_of_indep_append_right h).left
2021
| succ i' =>
21-
rw [List.flatten_cons] at h
22-
simp only [List.length_cons, Nat.add_lt_add_iff_right] at hi
23-
simp only [Independent, List.length_cons, Fin.getElem_fin, List.getElem_cons_succ]
24-
exact ih (indep_of_indep_append_right h).right i' hi
22+
simp only [List.flatten_cons] at h
23+
simp only [List.length_cons, add_lt_add_iff_right] at hi
24+
exact ih i' hi (indep_of_indep_append_right h).right
2525

2626
/-- (i) → (ii) of Corollary (2.3) in `Partial Commutation and Traces`.
2727
Note that t₁, t₂, …, tₙ is expressed as a list [ts], and (t₁ ++ t₂ ++ … ++ tₙ) via [ts.flatten].
@@ -33,55 +33,48 @@ theorem levi_lemma_gen {u v : List α} {ts : List (List α)} [DecidableEq α]
3333
qs.length = ts.length ∧
3434
TraceEqv I u ps.flatten ∧
3535
TraceEqv I v qs.flatten ∧
36-
(∀ i : Fin (min ts.length (min ps.length qs.length)), TraceEqv I ts[i] (ps[i] ++ qs[i])) ∧
37-
∀ i : Fin qs.length, ∀ j : Fin ps.length, i.val < j.val → Independent I qs[i] ps[j] := by
36+
(∀ i (ht : i < ts.length) (hp : i < ps.length) (hq : i < qs.length),
37+
TraceEqv I ts[i] (ps[i] ++ qs[i])) ∧
38+
(∀ i j (hi : i < qs.length) (hj : j < ps.length), i < j →
39+
Independent I qs[i] ps[j]) := by
3840
induction ts generalizing u v with
3941
| nil =>
40-
rw [List.flatten_nil] at h
41-
replace h := length_eq_of_eqv h
42-
simp only [List.length_append, List.length_nil, Nat.add_eq_zero_iff,
43-
List.length_eq_zero_iff] at h
44-
rcases h with ⟨rfl, rfl⟩
42+
simp only [List.flatten_nil] at h
43+
have h_len := length_eq_of_eqv h
44+
simp only [List.length_append, List.length_nil] at h_len
45+
have hu : u = [] := List.length_eq_zero_iff.mp (by omega)
46+
have hv : v = [] := List.length_eq_zero_iff.mp (by omega)
47+
subst hu hv
4548
use [], []
46-
simp only [List.length_nil, List.flatten_nil, Fin.getElem_fin, Independent, IsEmpty.forall_iff,
47-
and_true, true_and, TraceEqv.refl]
48-
intro ⟨i, hi⟩
49-
contradiction
49+
simp [TraceEqv.refl]
5050
| cons t tsuf ih =>
5151
rcases levi_lemma h with ⟨p, psuf, q, qsuf, h_ind, h_up, h_vq, h_tpq, h_tpq_suf⟩
5252
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⟩
5353
use p :: ps_i, q :: qs_i
5454
and_intros
55-
· simpa
56-
· simpa
55+
· simp [ih_p_len]
56+
· simp [ih_q_len]
5757
· apply TraceEqv.trans h_up
5858
simp only [List.flatten_cons]
5959
exact TraceEqv.compat (TraceEqv.refl p) ih_p
6060
· apply TraceEqv.trans h_vq
6161
simp only [List.flatten_cons]
6262
exact TraceEqv.compat (TraceEqv.refl q) ih_q
63-
· intro ⟨i, hi⟩
64-
by_cases hzi : i = 0
65-
· simp [hzi, h_tpq]
66-
· cases i with
67-
| zero => contradiction
68-
| succ i =>
69-
simp only [List.length_cons, Nat.add_min_add_right, Nat.add_lt_add_iff_right, lt_inf_iff,
70-
Fin.getElem_fin, List.getElem_cons_succ] at hi ⊢
71-
exact ih_tpq ⟨i, by simpa⟩
72-
· intro ⟨i, hi⟩ ⟨j, hj⟩ hij
63+
· intro i ht hp hq
64+
cases i with
65+
| zero => exact h_tpq
66+
| succ i' => apply ih_tpq i'
67+
· intro i j hi hj hij
7368
cases j with
7469
| zero => contradiction
75-
| succ j =>
70+
| succ j' =>
7671
cases i with
7772
| zero =>
78-
simp only [List.length_cons, Nat.add_lt_add_iff_right, Independent, Fin.zero_eta,
79-
Fin.getElem_fin, Fin.val_zero, List.getElem_cons_zero, List.getElem_cons_succ] at hj ⊢
80-
exact indep_of_flatten ⟨j, hj⟩ (indep_of_indep_of_eqv (independent_symm h_ind) ih_p)
81-
| succ i =>
82-
simp only [List.length_cons, Nat.add_lt_add_iff_right, Independent, Fin.getElem_fin,
83-
List.getElem_cons_succ] at hi hj hij ⊢
84-
exact ih_ind ⟨i, hi⟩ ⟨j, hj⟩ hij
73+
simp only [List.length_cons, add_lt_add_iff_right] at hj
74+
exact indep_of_flatten j' hj (indep_of_indep_of_eqv (independent_symm h_ind) ih_p)
75+
| succ i' =>
76+
apply ih_ind i' j'
77+
exact Nat.succ_lt_succ_iff.mp hij
8578

8679
variable {M : Type} {σ : Type} [Monoid M] [Monoid α]
8780

TraceTheory/TraceTheory/Ochmanski.lean

Lines changed: 142 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace TraceTheory
88

99
open scoped Pointwise
1010

11-
open RegularExpression
11+
open RegularExpression Computability
1212

1313
variable {α : Type} {I : Independence α}
1414

@@ -451,14 +451,151 @@ lemma recognizable_connectedComponents {P : Set (Trace I)} [DecidableEq α] [Fin
451451
exact h_indep_t'_v a b ((h_mem_eq a).mpr ha) hb
452452
exact ⟨h_conn, h_neq_1, v, hv_in_P_t, h_indep_t_v⟩
453453

454-
open Computability in
455-
theorem star_connected_closed_rank {X : Language α}
454+
lemma dependent_letters_of_connected [DecidableEq α] {u v : List α}
455+
(h_conn : IsConnected I ⟦u ++ v⟧)
456+
(hu : u ≠ []) (hv : v ≠ []) :
457+
∃ a ∈ u, ∃ b ∈ v, ¬ I.rel a b := by
458+
by_contra h_all_indep
459+
push_neg at h_all_indep
460+
have h_indep_trace : Independent' (I := I) ⟦u⟧ ⟦v⟧ := by
461+
intro a b ha hb
462+
change a ∈ u at ha
463+
change b ∈ v at hb
464+
exact h_all_indep a ha b hb
465+
have hu_trace : ⟦u⟧ ≠ (1 : Trace I) := by simpa [empty_iff]
466+
have hv_trace : ⟦v⟧ ≠ (1 : Trace I) := by simpa [empty_iff]
467+
exact append_indep_is_disconnected ⟦u⟧ ⟦v⟧ h_indep_trace hu_trace hv_trace h_conn
468+
469+
-- TODO clean up LLM generated proof
470+
lemma split_indices_bound [Fintype α] [DecidableEq α] {n : ℕ} {ps qs : List (List α)}
471+
(hps_len : ps.length = n) (hqs_len : qs.length = n)
472+
(hpq_conn : ∀ i (hi : i < n), IsConnected I ⟦ps[i] ++ qs[i]⟧)
473+
(h_indep : ∀ i j (hi : i < n) (hj : j < n), i < j → Independent I qs[i] ps[j]) :
474+
(Finset.univ.filter (fun (i : Fin n) => ps[i.val] ≠ [] ∧ qs[i.val] ≠ [])).card ≤
475+
Fintype.card α := by
476+
let S := Finset.univ.filter (fun (i : Fin n) => ps[i.val] ≠ [] ∧ qs[i.val] ≠ [])
477+
478+
-- 2. Extract the dependent cross-letters for each split index
479+
have h_ex' : ∀ i : S, ∃ b ∈ qs[i.val.val], ∃ a ∈ ps[i.val.val], ¬ I.rel a b := by
480+
intro ⟨i, hi⟩
481+
simp only [S, Finset.mem_filter, Finset.mem_univ, true_and] at hi
482+
-- Since ps[i] and qs[i] are connected and non-empty, they share a dependent pair
483+
have ⟨a, ha, b, hb, hrel⟩ := dependent_letters_of_connected (hpq_conn i.val i.isLt) hi.1 hi.2
484+
exact ⟨b, hb, a, ha, hrel⟩
485+
486+
-- 3. Define the mapping function f(i) = b_i
487+
let f : S → α := fun i => Classical.choose (h_ex' i)
488+
have hf_spec : ∀ i : S, f i ∈ qs[i.val.val] ∧ ∃ a ∈ ps[i.val.val], ¬ I.rel a (f i) :=
489+
fun i => Classical.choose_spec (h_ex' i)
490+
491+
-- 4. Prove f is injective (the letters b_i are pairwise distinct)
492+
have h_inj : Function.Injective f := by
493+
intro ⟨i, hi⟩ ⟨j, hj⟩ heq
494+
by_contra h_neq
495+
have h_neq_val : i.val ≠ j.val := by
496+
intro h_eq_val; apply h_neq; exact Subtype.ext (Fin.ext h_eq_val)
497+
498+
-- Since they are distinct indices, one must be strictly less than the other
499+
rcases lt_trichotomy i.val j.val with hlt | heq_val | hgt
500+
· -- Case: i < j
501+
have h_indep_ij := h_indep i.val j.val i.isLt j.isLt hlt
502+
have h_bi_in := (hf_spec ⟨i, hi⟩).1
503+
rcases (hf_spec ⟨j, hj⟩).2 with ⟨aj, haj, hdep⟩
504+
-- b_i must commute with a_j
505+
have h_rel := h_indep_ij (f ⟨i, hi⟩) h_bi_in aj haj
506+
have h_symm := I.symm (f ⟨i, hi⟩) aj h_rel
507+
rw [heq] at h_symm
508+
-- But b_j does NOT commute with a_j. Contradiction.
509+
exact hdep h_symm
510+
· contradiction
511+
· -- Case: j < i (Symmetric to above)
512+
have h_indep_ji := h_indep j.val i.val j.isLt i.isLt hgt
513+
have h_bj_in := (hf_spec ⟨j, hj⟩).1
514+
rcases (hf_spec ⟨i, hi⟩).2 with ⟨ai, hai, hdep⟩
515+
have h_rel := h_indep_ji (f ⟨j, hj⟩) h_bj_in ai hai
516+
have h_symm := I.symm (f ⟨j, hj⟩) ai h_rel
517+
rw [← heq] at h_symm
518+
exact hdep h_symm
519+
520+
-- 5. Because f is injective, the cardinality of S is bounded by the alphabet
521+
have h_card := Fintype.card_le_of_injective f h_inj
522+
rw [← Fintype.card_coe S]
523+
exact h_card
524+
525+
lemma compress_factorization_core {n : ℕ} {X : Language α} [DecidableEq α]
526+
(ps qs : List (List α))
527+
(hps_len : ps.length = n) (hqs_len : qs.length = n)
528+
(hpq_in_X : ∀ i (hi : i < n), ps[i] ++ qs[i] ∈ X)
529+
(h_indep : ∀ i j (hi : i < n) (hj : j < n), i < j → Independent I qs[i] ps[j]) :
530+
∃ xs ys : List (List α),
531+
xs.length = ys.length ∧
532+
-- The critical bound: length is ≤ 2 * (number of splits) + 1
533+
xs.length ≤ 2 * (Finset.univ.filter (fun (i : Fin n) => ps[i.val] ≠ [] ∧ qs[i.val] ≠ [])).card + 1
534+
(List.zipWith (· ++ ·) xs ys).flatten ∈ X∗ ∧
535+
TraceEqv I ps.flatten xs.flatten ∧
536+
TraceEqv I qs.flatten ys.flatten ∧
537+
∀ (i : ℕ) (h : i + 1 < xs.length), Independent I xs[i + 1] (List.take (i + 1) ys).flatten := by
538+
sorry
539+
540+
lemma group_split_factors
541+
{x y : List α} {X : Language α} {n : ℕ} {ps qs : List (List α)} [Fintype α] [DecidableEq α]
542+
(hps_len : ps.length = n) (hqs_len : qs.length = n)
543+
(hx_eqv : TraceEqv I x ps.flatten)
544+
(hy_eqv : TraceEqv I y qs.flatten)
545+
(hpq_in_X : ∀ i (hi : i < n), ps[i] ++ qs[i] ∈ X)
546+
(h_indep : ∀ i j (hi : i < n) (hj : j < n), i < j → Independent I qs[i] ps[j])
547+
(h_bound : (Finset.univ.filter (fun (i : Fin n) => ps[i.val] ≠ [] ∧ qs[i.val] ≠ [])).card ≤
548+
Fintype.card α) :
549+
∃ xs ys : List (List α),
550+
xs.length ≤ 2 * Fintype.card α + 1
551+
IsValidFactorization I (X∗) x y xs ys := by
552+
have ⟨xs, ys, h_len_eq, h_len_bound, h_zip_in, h_ps_eqv, h_qs_eqv, h_xs_indep⟩ :=
553+
compress_factorization_core ps qs hps_len hqs_len hpq_in_X h_indep
554+
use xs, ys
555+
constructor
556+
· omega
557+
· unfold IsValidFactorization
558+
refine ⟨h_len_eq, h_zip_in, ?_, ?_, h_xs_indep⟩
559+
· exact TraceEqv.trans hx_eqv h_ps_eqv
560+
· exact TraceEqv.trans hy_eqv h_qs_eqv
561+
562+
theorem star_connected_closed_rank {X : Language α} [Fintype α] [DecidableEq α]
456563
(hX_closed : IsClosed I X)
457564
(hX_conn : ∀ w ∈ X, IsConnected I ⟦w⟧) :
458565
HasFiniteRank I X∗ := by
459-
sorry
566+
use 2 * Fintype.card α
567+
intro x y hxy
568+
rcases hxy with ⟨w, hw, heqv⟩
569+
rw [Language.mem_kstar] at hw
570+
rcases hw with ⟨ts, rfl, hts⟩
571+
have ⟨ps, qs, hps_len, hqs_len, hx_eqv, hy_eqv, h_pq_eqv, h_indep⟩ :=
572+
levi_lemma_gen heqv.symm
573+
have hpq_in_X : ∀ i (hi : i < ts.length),
574+
ps[i] ++ qs[i] ∈ X := by
575+
intro i hi
576+
have h_t_in_X : ts[i] ∈ X := hts (ts[i]) (List.getElem_mem hi)
577+
have h_eqv_i := h_pq_eqv i hi (by omega) (by omega)
578+
rw [← hX_closed]
579+
exact ⟨ts[i], h_t_in_X, h_eqv_i⟩
580+
have hpq_conn : ∀ i (hi : i < ts.length),
581+
IsConnected I ⟦ps[i] ++ qs[i]⟧ := by
582+
intro i hi
583+
have h_t_conn := hX_conn ts[i] (hts ts[i] (List.getElem_mem hi))
584+
have h_eqv_i := h_pq_eqv i hi (by omega) (by omega)
585+
have h_trace_eq : (⟦ts[i]⟧ : Trace I) = ⟦ps[i] ++ qs[i]⟧ := by
586+
apply Quotient.sound
587+
exact h_eqv_i
588+
rw [← h_trace_eq]
589+
exact h_t_conn
590+
have h_indep_adapted : ∀ i j (hi : i < ts.length) (hj : j < ts.length), i < j →
591+
Independent I qs[i] ps[j] := by
592+
intro i j hi hj hij
593+
exact h_indep i j (by omega) (by omega) hij
594+
have h_bound := split_indices_bound hps_len hqs_len hpq_conn h_indep_adapted
595+
have ⟨xs, ys, h_len, h_valid⟩ :=
596+
group_split_factors hps_len hqs_len hx_eqv hy_eqv hpq_in_X h_indep_adapted h_bound
597+
use xs, ys
460598

461-
open Computability in
462599
lemma recognizable_cstar {P : Set (Trace I)} [DecidableEq α] [Fintype α]
463600
(hP : IsRecognizable P) : IsRecognizable (kstar (connectedComponents P)) := by
464601
let C := connectedComponents P

0 commit comments

Comments
 (0)