@@ -537,7 +537,7 @@ def matches_cstar_trace (I : Independence α) : RegularExpression α → Set (Tr
537537/-- Interpreting this RegularExpression as operating on Trace Languages gives the same matching set
538538 as interpreting (as usual) on String Languages and then projecting to Traces.
539539-/
540- lemma matches_toTrace (P : RegularExpression α) : (matches_trace I P) = toTrace P.matches' := by
540+ theorem matches_toTrace (P : RegularExpression α) : (matches_trace I P) = toTrace P.matches' := by
541541 induction P with
542542 | zero => simp [toTrace, matches_trace, Language.zero_def]
543543 | epsilon => simp [toTrace, matches_trace, Language.one_def]
@@ -709,9 +709,9 @@ theorem connectedIterativeFactors_equiv_starConnected' (X : RegularExpression α
709709 replace h := h ts hts
710710 have h_match_subset : ∀ q ∈ Q.matches', q ∈ P.matches' + Q.matches' := by
711711 simp [Language.add_def]
712- intro p hp
712+ intro q hq
713713 apply (Set.mem_union _ _ _).mpr
714- simp [hp ]
714+ simp [hq ]
715715 exact h_match_subset _ h
716716 have ⟨Q', hQ'⟩ := ihQ ihQ_cond
717717
@@ -857,15 +857,51 @@ lemma connectedComponents_of_connected (T : Set (Trace I)) (h : ∀ t ∈ T, isC
857857
858858
859859
860- theorem flatten_filter_not_isEmpty :
860+ lemma empty_inj_emptyTrace (w : List α) (h : (⟦w⟧ : Trace I) = ⟦[]⟧) : w = [] := by
861+ cases w with
862+ | nil => simp
863+ | cons a u =>
864+ have h_au := length_eq_of_equiv (Quotient.exact h)
865+ simp at h_au
866+
867+ def isEmpty : Trace I → Bool := Quotient.lift List.isEmpty (by
868+ intro u v huv
869+ cases u with
870+ | nil => rw [empty_inj_emptyTrace _ (Eq.symm (Quotient.sound huv))]
871+ | cons a u =>
872+ cases v with
873+ | nil => rw [empty_inj_emptyTrace _ (Quotient.sound huv)]
874+ | cons b v => rfl
875+ )
876+
877+ lemma isEmpty_iff {t : Trace I} : t.isEmpty = true ↔ t = ⟦[]⟧ := by
878+ apply Iff.intro
879+ · intro h
880+ rcases t with ⟨s⟩
881+ rw [List.isEmpty_iff.mp h]
882+ rfl
883+ · intro h
884+ rw [h]
885+ rfl
886+
887+ lemma traceFlatten_filter_not_isEmpty :
861888 ∀ {L : List (Trace I)},
862- List.foldl (fun (u : Trace I) v => u * v) ⟦[]⟧ (List.filter (· != ⟦[]⟧ ) L)
889+ List.foldl (fun (u : Trace I) v => u * v) ⟦[]⟧ (List.filter (!·.isEmpty ) L)
863890 = List.foldl (fun (u : Trace I) v => u * v) ⟦[]⟧ L
864891 | [] => rfl
865- | ⟦[]⟧ :: L
866- | (a :: l) :: L => by
867- simp [flatten_filter_not_isEmpty (L := L)]
868-
892+ | t :: L => by
893+ by_cases ht : t.isEmpty
894+ · apply isEmpty_iff.mp at ht
895+ simp [ht]
896+ simp [show isEmpty ⟦[]⟧ = true from rfl]
897+ rw [show ⟦[]⟧ = mk' [] from rfl, left_id', show mk' [] = ⟦[]⟧ from rfl]
898+ exact traceFlatten_filter_not_isEmpty (L := L)
899+ · simp [ht]
900+ rw [show ⟦[]⟧ = mk' [] from rfl, left_id', <- right_id' t, show mk' [] = ⟦[]⟧ from rfl]
901+ repeat rw [List.foldl_assoc]
902+ rw [traceFlatten_filter_not_isEmpty (L := L)]
903+
904+ /-- Theorem 4.1 (iii) => (iv) -/
869905theorem starConnected_is_cRational (X : RegularExpression α) (h : RegularExpression.isStarConnected I X) :
870906 RegularExpression.matches_trace I X = RegularExpression.matches_cstar_trace I X := by
871907 induction X with
@@ -885,41 +921,28 @@ theorem starConnected_is_cRational (X : RegularExpression α) (h : RegularExpres
885921 rcases t with ⟨w₀⟩
886922 have ⟨w, hw, hw₀⟩ := ht
887923 simp at hw₀
888- rw [<- hw₀]
889- rw [<- isConnected_toTrace]
924+ rw [<- hw₀, <- isConnected_toTrace]
890925 exact h.right w hw
891926 rw [connectedComponents_of_connected _ hP_conn]
892927 apply Set.ext
893928 intro t
894929 apply Iff.intro
895930 · intro ⟨ls, hls, ht⟩
896- have _ : BEq (Trace I) := by sorry
897- use ls.filter (· != ⟦[]⟧)
931+ use ls.filter (!·.isEmpty)
898932 simp
899933 apply And.intro
900934 · intro t' ht' htz'
901935 use hls t' ht'
902936 by_contra ht'_con
903937 rw [ht'_con] at htz'
904- -- simp at htz'
905- sorry
906- · induction ls generalizing t with
907- | nil => simp at ht ⊢; exact ht
908- | cons l ls ih =>
909- rw [ht]
910- replace ih := ih (List.foldl (fun u v => u * v) ⟦[]⟧ ls)
911- simp at ih
912- have ih_cond : (∀ t' ∈ ls, t' ∈ RegularExpression.matches_trace I P) := by
913- intro c hc
914- exact hls c (List.mem_cons_of_mem l hc)
915- replace ih := ih ih_cond
916- sorry
938+ exact (Bool.eq_not_self (isEmpty ⟦[]⟧)).mp htz'
939+ · rw [ht]
940+ exact Eq.symm traceFlatten_filter_not_isEmpty
917941 · intro ⟨ls, hls, ht⟩
918942 use ls
919943 simp [ht]
920944 intro t' ht'
921945 exact Set.mem_of_mem_inter_left (hls t' ht')
922946
923947
924-
925948end Trace
0 commit comments