File: Mathlib/Computability/DFA.lean

full_name: DFA.accept
code: /-- A DFA is a set of states (`σ`), a transition function from state to state labelled by the
  alphabet (`step`), a starting state (`start`) and a set of acceptance states (`accept`). -/
structure DFA (α : Type u) (σ : Type v) where
  /-- A transition function from state to state labelled by the alphabet. -/
  step : σ → α → σ
  /-- Starting state. -/
  start : σ
  /-- Set of acceptance states. -/
  accept : Set σ
goal: Set σ

full_name: DFA.start
code: /-- A DFA is a set of states (`σ`), a transition function from state to state labelled by the
  alphabet (`step`), a starting state (`start`) and a set of acceptance states (`accept`). -/
structure DFA (α : Type u) (σ : Type v) where
  /-- A transition function from state to state labelled by the alphabet. -/
  step : σ → α → σ
  /-- Starting state. -/
  start : σ
  /-- Set of acceptance states. -/
  accept : Set σ
goal: σ

full_name: DFA
code: /-- A DFA is a set of states (`σ`), a transition function from state to state labelled by the
  alphabet (`step`), a starting state (`start`) and a set of acceptance states (`accept`). -/
structure DFA (α : Type u) (σ : Type v) where
  /-- A transition function from state to state labelled by the alphabet. -/
  step : σ → α → σ
  /-- Starting state. -/
  start : σ
  /-- Set of acceptance states. -/
  accept : Set σ
goal: Type (max u v)

full_name: DFA.step
code: /-- A DFA is a set of states (`σ`), a transition function from state to state labelled by the
  alphabet (`step`), a starting state (`start`) and a set of acceptance states (`accept`). -/
structure DFA (α : Type u) (σ : Type v) where
  /-- A transition function from state to state labelled by the alphabet. -/
  step : σ → α → σ
  /-- Starting state. -/
  start : σ
  /-- Set of acceptance states. -/
  accept : Set σ
goal: σ → α → σ

full_name: DFA.instInhabited
code: instance [Inhabited σ] : Inhabited (DFA α σ) 
goal: Inhabited (DFA α σ)

full_name: DFA.evalFrom
code: /-- `M.evalFrom s x` evaluates `M` with input `x` starting from the state `s`. -/
def evalFrom (s : σ) : List α → σ 
goal: List α → σ

full_name: DFA.evalFrom_nil
code: @[simp]
theorem evalFrom_nil (s : σ) : M.evalFrom s [] = s 
goal: M.evalFrom s [] = s

full_name: DFA.evalFrom_singleton
code: @[simp]
theorem evalFrom_singleton (s : σ) (a : α) : M.evalFrom s [a] = M.step s a 
goal: M.evalFrom s [a] = M.step s a

full_name: DFA.evalFrom_append_singleton
code: @[simp]
theorem evalFrom_append_singleton (s : σ) (x : List α) (a : α) :
    M.evalFrom s (x ++ [a]) = M.step (M.evalFrom s x) a 
goal: M.evalFrom s (x ++ [a]) = M.step (M.evalFrom s x) a

full_name: DFA.eval
code: /-- `M.eval x` evaluates `M` with input `x` starting from the state `M.start`. -/
def eval : List α → σ 
goal: List α → σ

full_name: DFA.eval_nil
code: @[simp]
theorem eval_nil : M.eval [] = M.start 
goal: M.eval [] = M.start

full_name: DFA.eval_singleton
code: @[simp]
theorem eval_singleton (a : α) : M.eval [a] = M.step M.start a 
goal: M.eval [a] = M.step M.start a

full_name: DFA.eval_append_singleton
code: @[simp]
theorem eval_append_singleton (x : List α) (a : α) : M.eval (x ++ [a]) = M.step (M.eval x) a 
goal: M.eval (x ++ [a]) = M.step (M.eval x) a

full_name: DFA.evalFrom_of_append
code: theorem evalFrom_of_append (start : σ) (x y : List α) :
    M.evalFrom start (x ++ y) = M.evalFrom (M.evalFrom start x) y 
goal: M.evalFrom start (x ++ y) = M.evalFrom (M.evalFrom start x) y

full_name: DFA.acceptsFrom
code: /--
`M.acceptsFrom s` is the language of `x` such that `M.evalFrom s x` is an accept state.
-/
def acceptsFrom (s : σ) : Language α 
goal: Language α

full_name: DFA.mem_acceptsFrom
code: theorem mem_acceptsFrom {s : σ} {x : List α} :
    x ∈ M.acceptsFrom s ↔ M.evalFrom s x ∈ M.accept 
goal: x ∈ M.acceptsFrom s ↔ M.evalFrom s x ∈ M.accept

full_name: DFA.accepts
code: /-- `M.accepts` is the language of `x` such that `M.eval x` is an accept state. -/
def accepts : Language α 
goal: Language α

full_name: DFA.mem_accepts
code: theorem mem_accepts {x : List α} : x ∈ M.accepts ↔ M.eval x ∈ M.accept 
goal: x ∈ M.accepts ↔ M.eval x ∈ M.accept

full_name: DFA.evalFrom_split
code: theorem evalFrom_split [Fintype σ] {x : List α} {s t : σ} (hlen : Fintype.card σ ≤ x.length)
    (hx : M.evalFrom s x = t) :
    ∃ q a b c,
      x = a ++ b ++ c ∧
        a.length + b.length ≤ Fintype.card σ ∧
          b ≠ [] ∧ M.evalFrom s a = q ∧ M.evalFrom q b = q ∧ M.evalFrom q c = t 
goal: ∃ q a b c,
  x = a ++ b ++ c ∧
    a.length + b.length ≤ Fintype.card σ ∧ b ≠ [] ∧ M.evalFrom s a = q ∧ M.evalFrom q b = q ∧ M.evalFrom q c = t

full_name: DFA.evalFrom_of_pow
code: theorem evalFrom_of_pow {x y : List α} {s : σ} (hx : M.evalFrom s x = s)
    (hy : y ∈ ({x} : Language α)∗) : M.evalFrom s y = s 
goal: M.evalFrom s y = s

full_name: DFA.pumping_lemma
code: theorem pumping_lemma [Fintype σ] {x : List α} (hx : x ∈ M.accepts)
    (hlen : Fintype.card σ ≤ List.length x) :
    ∃ a b c,
      x = a ++ b ++ c ∧
        a.length + b.length ≤ Fintype.card σ ∧ b ≠ [] ∧ {a} * {b}∗ * {c} ≤ M.accepts 
goal: ∃ a b c, x = a ++ b ++ c ∧ a.length + b.length ≤ Fintype.card σ ∧ b ≠ [] ∧ {a} * {b}∗ * {c} ≤ M.accepts

full_name: DFA.comap_accept
code: /--
`M.comap f` pulls back the alphabet of `M` along `f`. In other words, it applies `f` to the input
before passing it to `M`.
-/
@[simps]
def comap (f : α' → α) (M : DFA α σ) : DFA α' σ 
goal: (DFA.comap f M).accept = M.accept

full_name: DFA.comap
code: /--
`M.comap f` pulls back the alphabet of `M` along `f`. In other words, it applies `f` to the input
before passing it to `M`.
-/
@[simps]
def comap (f : α' → α) (M : DFA α σ) : DFA α' σ 
goal: DFA α' σ

full_name: DFA.comap_step
code: /--
`M.comap f` pulls back the alphabet of `M` along `f`. In other words, it applies `f` to the input
before passing it to `M`.
-/
@[simps]
def comap (f : α' → α) (M : DFA α σ) : DFA α' σ 
goal: (DFA.comap f M).step s a = M.step s (f a)

full_name: DFA.comap_start
code: /--
`M.comap f` pulls back the alphabet of `M` along `f`. In other words, it applies `f` to the input
before passing it to `M`.
-/
@[simps]
def comap (f : α' → α) (M : DFA α σ) : DFA α' σ 
goal: (DFA.comap f M).start = M.start

full_name: DFA.comap_id
code: @[simp]
theorem comap_id : M.comap id = M 
goal: DFA.comap id M = M

full_name: DFA.evalFrom_comap
code: @[simp]
theorem evalFrom_comap (f : α' → α) (s : σ) (x : List α') :
    (M.comap f).evalFrom s x = M.evalFrom s (x.map f) 
goal: (DFA.comap f M).evalFrom s x = M.evalFrom s (List.map f x)

full_name: DFA.eval_comap
code: @[simp]
theorem eval_comap (f : α' → α) (x : List α') : (M.comap f).eval x = M.eval (x.map f) 
goal: (DFA.comap f M).eval x = M.eval (List.map f x)

full_name: DFA.accepts_comap
code: @[simp]
theorem accepts_comap (f : α' → α) : (M.comap f).accepts = List.map f ⁻¹' M.accepts 
goal: (DFA.comap f M).accepts = List.map f ⁻¹' M.accepts

full_name: DFA.reindex_apply_accept
code: /-- Lifts an equivalence on states to an equivalence on DFAs. -/
@[simps apply_step apply_start apply_accept]
def reindex (g : σ ≃ σ') : DFA α σ ≃ DFA α σ' 
goal: ((DFA.reindex g) M).accept = ⇑g.symm ⁻¹' M.accept

full_name: DFA.reindex_apply_step
code: /-- Lifts an equivalence on states to an equivalence on DFAs. -/
@[simps apply_step apply_start apply_accept]
def reindex (g : σ ≃ σ') : DFA α σ ≃ DFA α σ' 
goal: ((DFA.reindex g) M).step s a = g (M.step (g.symm s) a)

full_name: DFA.reindex_apply_start
code: /-- Lifts an equivalence on states to an equivalence on DFAs. -/
@[simps apply_step apply_start apply_accept]
def reindex (g : σ ≃ σ') : DFA α σ ≃ DFA α σ' 
goal: ((DFA.reindex g) M).start = g M.start

full_name: DFA.reindex
code: /-- Lifts an equivalence on states to an equivalence on DFAs. -/
@[simps apply_step apply_start apply_accept]
def reindex (g : σ ≃ σ') : DFA α σ ≃ DFA α σ' 
goal: DFA α σ ≃ DFA α σ'

full_name: DFA.reindex_refl
code: @[simp]
theorem reindex_refl : reindex (Equiv.refl σ) M = M 
goal: (DFA.reindex (Equiv.refl σ)) M = M

full_name: DFA.symm_reindex
code: @[simp]
theorem symm_reindex (g : σ ≃ σ') : (reindex (α := α) g).symm = reindex g.symm 
goal: (DFA.reindex g).symm = DFA.reindex g.symm

full_name: DFA.evalFrom_reindex
code: @[simp]
theorem evalFrom_reindex (g : σ ≃ σ') (s : σ') (x : List α) :
    (reindex g M).evalFrom s x = g (M.evalFrom (g.symm s) x) 
goal: ((DFA.reindex g) M).evalFrom s x = g (M.evalFrom (g.symm s) x)

full_name: DFA.eval_reindex
code: @[simp]
theorem eval_reindex (g : σ ≃ σ') (x : List α) : (reindex g M).eval x = g (M.eval x) 
goal: ((DFA.reindex g) M).eval x = g (M.eval x)

full_name: DFA.accepts_reindex
code: @[simp]
theorem accepts_reindex (g : σ ≃ σ') : (reindex g M).accepts = M.accepts 
goal: ((DFA.reindex g) M).accepts = M.accepts

full_name: DFA.comap_reindex
code: theorem comap_reindex (f : α' → α) (g : σ ≃ σ') :
    (reindex g M).comap f = reindex g (M.comap f) 
goal: DFA.comap f ((DFA.reindex g) M) = (DFA.reindex g) (DFA.comap f M)