The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V32. Logic, model theory and computability

Mathlib.Computability.MyhillNerode

14 declarations. Mathlib docs · Source

Myhill–Nerode theorem

This file proves the Myhill–Nerode theorem using left quotients.

Given a language L and a word x, the left quotient of L by x is the set of suffixes y such that x ++ y is in L. The Myhill–Nerode theorem shows that each left quotient, in fact, corresponds to the state of an automaton that matches L, and that L is regular if and only if there are finitely many such states.

References

def Language.leftQuotient E1 #

{α : Type u} → Language α → List α → Language α

The left quotient of x is the set of suffixes y such that x ++ y is in L.

theorem Language.leftQuotient_nil E0 #

∀ {α : Type u} (L : Language α), L.leftQuotient [] = L

theorem Language.leftQuotient_append E1 #

∀ {α : Type u} (L : Language α) (x y : List α), L.leftQuotient (x ++ y) = (L.leftQuotient x).leftQuotient y

theorem Language.mem_leftQuotient E0 #

∀ {α : Type u} {L : Language α} (x y : List α), y ∈ L.leftQuotient x ↔ x ++ y ∈ L

theorem Language.leftQuotient_accepts_apply E0 #

∀ {α : Type u} {σ : Type v} (M : DFA α σ) (x : List α), M.accepts.leftQuotient x = M.acceptsFrom (M.eval x)

theorem Language.leftQuotient_accepts E1 #

∀ {α : Type u} {σ : Type v} (M : DFA α σ), M.accepts.leftQuotient = M.acceptsFrom ∘ M.eval

theorem Language.IsRegular.finite_range_leftQuotient E1 #

∀ {α : Type u} {L : Language α}, L.IsRegular → (Set.range L.leftQuotient).Finite

def Language.toDFA E1 #

{α : Type u} → (L : Language α) → DFA α ↑(Set.range L.leftQuotient)

The left quotients of a language are the states of an automaton that accepts the language.

theorem Language.mem_accept_toDFA E0 #

∀ {α : Type u} {L : Language α} (s : ↑(Set.range L.leftQuotient)), s ∈ L.toDFA.accept ↔ [] ∈ ↑s

theorem Language.step_toDFA E0 #

∀ {α : Type u} {L : Language α} (s : ↑(Set.range L.leftQuotient)) (a : α), ↑(L.toDFA.step s a) = (↑s).leftQuotient [a]

theorem Language.start_toDFA E0 #

∀ {α : Type u} (L : Language α), ↑L.toDFA.start = L

theorem Language.accepts_toDFA E0 #

∀ {α : Type u} (L : Language α), L.toDFA.accepts = L

theorem Language.IsRegular.of_finite_range_leftQuotient E1 #

∀ {α : Type u} {L : Language α}, (Set.range L.leftQuotient).Finite → L.IsRegular

theorem Language.isRegular_iff_finite_range_leftQuotient E3 #

∀ {α : Type u} {L : Language α}, L.IsRegular ↔ (Set.range L.leftQuotient).Finite

Myhill–Nerode theorem. A language is regular if and only if the set of left quotients is finite.