Skip to content

Commit dfc6cea

Browse files
committed
Add decidability tags to DFA and NFA constructions
1 parent b32e9e1 commit dfc6cea

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

TraceTheory/TraceTheory/Computability.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ theorem char_step_accept (a : α) [DecidableEq α] (x : α) :
5757
theorem char_step_dead (a : α) [DecidableEq α] (x : α) :
5858
(char a).step none x = none := rfl
5959

60-
theorem accepts_char {a : α} : (char a).accepts = { [a] } := by
60+
theorem accepts_char {a : α} [DecidableEq α] : (char a).accepts = { [a] } := by
6161
ext x
6262
simp [DFA.accepts, DFA.acceptsFrom, DFA.evalFrom]
6363
rw [Set.mem_setOf_eq, Set.mem_singleton_iff]
@@ -89,9 +89,10 @@ section concat
8989

9090
variable {σ₁ σ₂ : Type*}
9191
variable {M₁ : εNFA α σ₁} {M₂ : εNFA α σ₂}
92+
variable [DecidablePred (· ∈ M₁.accept)]
9293

9394
/-- DFA which accepts the concatenation of the languages of `M₁` and `M₂`. -/
94-
def concat (M₁ : εNFA α σ₁) (M₂ : εNFA α σ₂) : εNFA α (σ₁ ⊕ σ₂) where
95+
def concat (M₁ : εNFA α σ₁) (M₂ : εNFA α σ₂) [DecidablePred (· ∈ M₁.accept)]: εNFA α (σ₁ ⊕ σ₂) where
9596
step q oa := match q, oa with
9697
| Sum.inl q₁, some _ => (M₁.step q₁ oa).image Sum.inl
9798
| Sum.inl q₁, none =>
@@ -254,9 +255,10 @@ section kstar
254255

255256
variable {σ : Type*}
256257
variable {M : εNFA α σ}
258+
variable [DecidablePred (· ∈ M.accept)]
257259

258260
/-- DFA which accepts the Kleene star of the language of `M`. -/
259-
def kstar (M : εNFA α σ) : εNFA α (Option σ) where
261+
def kstar (M : εNFA α σ) [DecidablePred (· ∈ M.accept)] : εNFA α (Option σ) where
260262
step oq oa := match oq, oa with
261263
| none, some _ => ∅
262264
| none, none => M.start.image some
@@ -531,7 +533,7 @@ theorem IsRegular.top : IsRegular (⊤ : Language α) := by
531533
apply IsRegular.compl
532534
exact IsRegular.zero
533535

534-
theorem IsRegular.singleton {a : α} : IsRegular ({ [a] }) := by
536+
theorem IsRegular.singleton {a : α} [DecidableEq α] : IsRegular ({ [a] }) := by
535537
apply isRegular_iff.mpr
536538
use Option Bool, inferInstance, DFA.char a
537539
exact DFA.accepts_char

0 commit comments

Comments
 (0)