@@ -360,6 +360,97 @@ lemma recognizable_mul {P Q : Set (Trace I)} [DecidableEq α]
360360 rw [← h_image_eq]
361361 exact h_hash
362362
363+ abbrev AlphMonoid (α : Type ) := Finset α
364+
365+ instance [DecidableEq α] : Monoid (AlphMonoid α) where
366+ one := ∅
367+ mul x y := x ∪ y
368+ mul_assoc x y z := Finset.union_assoc x y z
369+ one_mul x := Finset.empty_union x
370+ mul_one x := Finset.union_empty x
371+
372+ def alph_map_aux [DecidableEq α] (w : List α) : AlphMonoid α :=
373+ w.toFinset
374+
375+ lemma alph_map_aux_append [DecidableEq α] (x y : List α) :
376+ alph_map_aux (x ++ y) = alph_map_aux x * alph_map_aux y := by
377+ apply List.toFinset_append
378+
379+ def alph_map [DecidableEq α] : Trace I →* AlphMonoid α where
380+ toFun := Quotient.lift
381+ alph_map_aux
382+ (by
383+ intro u v heqv
384+ dsimp [alph_map_aux]
385+ ext a
386+ simp only [List.mem_toFinset]
387+ exact mem_iff_mem a heqv
388+ )
389+ map_one' := rfl
390+ map_mul' := by
391+ rintro ⟨x⟩ ⟨y⟩
392+ exact alph_map_aux_append x y
393+
394+ lemma alph_map_eq_iff_mems_eq [DecidableEq α] {t t' : Trace I} :
395+ alph_map (I := I) t = alph_map (I := I) t' ↔ ∀ a, a ∈ t ↔ a ∈ t' := by
396+ rcases t with ⟨w⟩
397+ rcases t' with ⟨w'⟩
398+ change w.toFinset = w'.toFinset ↔ _
399+ simp only [Finset.ext_iff, List.mem_toFinset]
400+ rfl
401+
402+ lemma lift_dependency_path [DecidableEq α] {t t' : Trace I} (h_mem_eq : ∀ a, a ∈ t' ↔ a ∈ t)
403+ (x y : {a // a ∈ t'}) (h_path : dependencyTransClosureIn t' x y) :
404+ dependencyTransClosureIn t ⟨x.1 , (h_mem_eq x.1 ).mp x.2 ⟩ ⟨y.1 , (h_mem_eq y.1 ).mp y.2 ⟩ := by
405+ induction h_path with
406+ | single h_dep =>
407+ apply Relation.TransGen.single
408+ exact h_dep
409+ | tail path step ih =>
410+ apply Relation.TransGen.tail ih
411+ exact step
412+
413+ lemma recognizable_connectedComponents {P : Set (Trace I)} [DecidableEq α] [Fintype α]
414+ (hP : IsRecognizable P) : IsRecognizable (connectedComponents P) := by
415+ rcases hP with ⟨M, hFin, hMon, hDec, f_P, hP_eq⟩
416+ use M × AlphMonoid α, inferInstance, inferInstance, inferInstance
417+ use MonoidHom.prod f_P (alph_map (I := I))
418+ ext t
419+ simp only [MonoidHom.prod_apply, Set.mem_preimage, Set.mem_image, Prod.ext_iff]
420+ constructor
421+ · intro h
422+ exact ⟨t, h, rfl, rfl⟩
423+ · rintro ⟨t', ht', h_f_eq, h_alph_eq⟩
424+ have h_mem_eq : ∀ a, a ∈ t' ↔ a ∈ t := by
425+ intro a
426+ have h_alph := alph_map_eq_iff_mems_eq.mp h_alph_eq
427+ exact h_alph a
428+ have h_conn : IsConnected I t := by
429+ intro a b
430+ let a' : {x // x ∈ t'} := ⟨a.1 , (h_mem_eq a.1 ).mpr a.2 ⟩
431+ let b' : {x // x ∈ t'} := ⟨b.1 , (h_mem_eq b.1 ).mpr b.2 ⟩
432+ have h_path := ht'.1 a' b'
433+ exact lift_dependency_path h_mem_eq a' b' h_path
434+ have h_neq_1 : t ≠ 1 := by
435+ intro ht_eq_1
436+ subst ht_eq_1
437+ have ht'_eq_1 : t' = 1 := by
438+ by_contra ht'_neq_1
439+ rcases empty_is_eps t' ht'_neq_1 with ⟨a, ha⟩
440+ exact eps_is_empty a ((h_mem_eq a).mp ha)
441+ exact ht'.2 .1 ht'_eq_1
442+ rcases ht'.2 .2 with ⟨v, hv_in_P, h_indep_t'_v⟩
443+ have hv_in_P_t : t * v ∈ P := by
444+ have h_f_mul : f_P (t * v) = f_P (t' * v) := by
445+ simp only [map_mul, h_f_eq.symm]
446+ rw [hP_eq, Set.mem_preimage] at hv_in_P ⊢
447+ rw [← h_f_mul] at hv_in_P
448+ exact hv_in_P
449+ have h_indep_t_v : Independent' t v := by
450+ intro a b ha hb
451+ exact h_indep_t'_v a b ((h_mem_eq a).mpr ha) hb
452+ exact ⟨h_conn, h_neq_1, v, hv_in_P_t, h_indep_t_v⟩
453+
363454open Computability in
364455theorem star_connected_closed_rank {X : Language α}
365456 (hX_closed : IsClosed I X)
@@ -368,11 +459,11 @@ theorem star_connected_closed_rank {X : Language α}
368459 sorry
369460
370461open Computability in
371- lemma recognizable_cstar {P : Set (Trace I)}
462+ lemma recognizable_cstar {P : Set (Trace I)} [DecidableEq α] [Fintype α]
372463 (hP : IsRecognizable P) : IsRecognizable (kstar (connectedComponents P)) := by
373464 let C := connectedComponents P
374465 let L_C : Language α := ⇑(mk' (I := I)) ⁻¹' C
375- have hC_recog : IsRecognizable C := sorry -- Requires a lemma that connected components of recognizable sets are recognizable
466+ have hC_recog : IsRecognizable C := recognizable_connectedComponents hP
376467 have hL_C_reg : L_C.IsRegular :=
377468 isRegular_of_recognizable (recognizable_has_recognizablePreImage _ _ hC_recog)
378469 have hL_C_closed : IsClosed I L_C := by
@@ -392,48 +483,22 @@ lemma recognizable_cstar {P : Set (Trace I)}
392483 have h_rank : HasFiniteRank I (L_C∗) := star_connected_closed_rank hL_C_closed hL_C_conn
393484 have h_hash := recognizable_image_of_regular_finite_rank h_star_reg h_rank
394485 have h_image_eq : mk' (I := I) '' ((L_C∗) : Language α) = kstar C := by
395- unfold kstar
396- ext t
397- constructor
398- · rintro ⟨w, ⟨ws, rfl, hws⟩, rfl⟩
399- use ws.map (mk' (I := I))
486+ change toTrace I (L_C∗) = kstar C
487+ rw [kstar_toTrace_comm]
488+ have h_surj : toTrace I L_C = C := by
489+ ext t
400490 constructor
401- · intro t' ht'
402- simp only [List.mem_map] at ht'
403- rcases ht' with ⟨w', hw', rfl⟩
404- exact hws w' hw'
405- · induction ws with
406- | nil => rfl
407- | cons w' ws' ih =>
408- simp only [List.flatten_cons, List.map_cons, List.prod_cons]
409- have h_mul : mk' (I := I) (w' ++ ws'.flatten) =
410- mk' (I := I) w' * mk' (I := I) ws'.flatten := rfl
411- simp only [List.mem_cons, forall_eq_or_imp] at hws
412- rw [h_mul, ih hws.right]
413- · rintro ⟨ts, hts, rfl⟩
414- induction ts with
415- | nil => exact ⟨[], by apply Language.nil_mem_kstar, rfl⟩
416- | cons t' ts' ih =>
417- have ht' : t' ∈ C := hts t' (by simp)
418- have hts' : ∀ x ∈ ts', x ∈ C := fun x hx => hts x (by simp [hx])
419- rcases ih hts' with ⟨w', hw'_star, hw'_eq⟩
420- rcases t' with ⟨u⟩
421- have hu_in_LC : u ∈ L_C := ht'
422- use u ++ w'
423- constructor
424- · rw [Language.mem_kstar] at hw'_star ⊢
425- rcases hw'_star with ⟨ws', rfl, hws'⟩
426- use u :: ws'
427- simp only [List.flatten_cons, List.mem_cons, forall_eq_or_imp, true_and]
428- exact ⟨hu_in_LC, hws'⟩
429- · have h_mul : mk' (I := I) (u ++ w') = mk' (I := I) u * mk' (I := I) w' := rfl
430- rw [h_mul, hw'_eq]
431- rfl
491+ · rintro ⟨w, hw, rfl⟩
492+ exact hw
493+ · intro ht
494+ rcases t with ⟨w⟩
495+ exact ⟨w, ht, rfl⟩
496+ rw [h_surj]
432497 rw [← h_image_eq]
433498 exact h_hash
434499
435500/-- Theorem 4.1 (iv) => (i) -/
436- theorem recognizable_of_cRational [DecidableEq α] (X : RegularExpression α) :
501+ theorem recognizable_of_cRational [DecidableEq α] [Fintype α] (X : RegularExpression α) :
437502 IsRecognizable (matches_cstar_trace I X) := by
438503 induction X with
439504 | zero => exact recognizable_zero
0 commit comments