@@ -8,7 +8,7 @@ namespace TraceTheory
88
99open scoped Pointwise
1010
11- open RegularExpression
11+ open RegularExpression Computability
1212
1313variable {α : 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
462599lemma 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