@@ -40,22 +40,47 @@ theorem IsRegular.one : IsRegular (1 : Language α) := by
4040 rw [h] at h_absurd
4141 contradiction
4242
43- theorem IsRegular.mul {L₁ L₂ : Language α}
43+ theorem IsRegular.mul {L₁ L₂ : Language α} [DecidableEq α]
4444 (h₁ : IsRegular L₁) (h₂ : IsRegular L₂) :
4545 IsRegular (L₁ * L₂) := by
46+ classical
47+ have ⟨σ₁, _, M₁, hM₁⟩ := h₁
48+ have ⟨σ₂, _, M₂, hM₂⟩ := h₂
49+ have εM₁ := M₁.toNFA.toεNFA
50+ have εM₂ := M₂.toNFA.toεNFA
51+ let step (q : σ₁ ⊕ σ₂) (ox : Option α) : Set (σ₁ ⊕ σ₂) :=
52+ match q, ox with
53+ | Sum.inl q₁, some x =>
54+ { Sum.inl (M₁.step q₁ x) }
55+ | Sum.inl q₁, none =>
56+ if (q₁ ∈ M₁.accept) then { Sum.inr M₂.start } else {}
57+ | Sum.inr q₂, some x =>
58+ { Sum.inr (M₂.step q₂ x)}
59+ | Sum.inr q₂, none =>
60+ {}
61+ let εM : εNFA α (σ₁ ⊕ σ₂) := {
62+ step := step
63+ start := { Sum.inl M₁.start }
64+ accept := { q | ∃ q₂, q = Sum.inr q₂ ∧ q₂ ∈ M₂.accept }
65+ }
66+ have M := εM.toNFA.toDFA
67+ apply isRegular_iff.mpr
68+ use Set (σ₁ ⊕ σ₂), inferInstance, M
69+ simp [DFA.accepts, DFA.acceptsFrom, DFA.evalFrom]
4670 sorry
4771
4872theorem IsRegular.kstar {L : Language α} (h : IsRegular L) : IsRegular (L∗) := by
4973 sorry
5074
5175theorem IsRegular.singleton {a : α} [DecidableEq α] : IsRegular ({ [a] }) := by
5276 apply isRegular_iff.mpr
53- let σ (n : Fin 3 ) (x : α) : Fin 3 := match n.val with
54- | Nat.zero =>
55- if (x = a) then 1 else 2
56- | Nat.succ n' =>
57- 2
58- use Fin 3 , inferInstance, ⟨σ, 0 , { 1 }⟩
77+ let step (n : Fin 3 ) (x : α) : Fin 3 :=
78+ match n.val with
79+ | Nat.zero =>
80+ if (x = a) then 1 else 2
81+ | Nat.succ n' =>
82+ 2
83+ use Fin 3 , inferInstance, ⟨step, 0 , { 1 }⟩
5984 ext x
6085 simp [DFA.accepts, DFA.acceptsFrom, DFA.evalFrom]
6186 constructor
@@ -65,13 +90,13 @@ theorem IsRegular.singleton {a : α} [DecidableEq α] : IsRegular ({ [a] }) := b
6590 | nil =>
6691 simp at h
6792 | cons b x' =>
68- have h_dead_state : ∀ w, List.foldl σ 2 w = 2 := by
93+ have h_dead_state : ∀ w, List.foldl step 2 w = 2 := by
6994 intro w
7095 induction w with
7196 | nil =>
7297 simp
7398 | cons b w' ih =>
74- simp [σ , ih]
99+ simp [step , ih]
75100 by_cases heq : b = a
76101 · subst heq
77102 cases x' with
0 commit comments