Langlib

Langlib.Automata.FiniteState.Equivalence.Regular

Right-regular grammars = Mathlib-regular languages #

This file proves that right-regular grammars (Type-3) generate exactly Mathlib's Language.IsRegular languages, via explicit conversions in both directions.

Proof outline #

Main results #

References #

def RG_rule.nonterminals {T N : Type} :
RG_rule T NList N

All nonterminals mentioned in a single RG rule.

Equations
Instances For

    Finset of all nonterminals appearing in a grammar (including the initial symbol).

    Equations
    Instances For
      theorem RG_grammar.rule_nt_mem {T : Type} (g : RG_grammar T) {r : RG_rule T g.nt} (hr : r g.rules) {n : g.nt} (hn : n r.nonterminals) :
      @[reducible, inline]
      abbrev RG_grammar.FinNT {T : Type} (g : RG_grammar T) :

      Finite nonterminal subtype: only those nonterminals that appear in the grammar.

      Equations
      Instances For
        def NFA_of_RG {T : Type} (g : RG_grammar T) :

        NFA with finite states constructed from a right-regular grammar.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem RG_derives_form {T : Type} {g : RG_grammar T} {A : g.nt} {s : List (symbol T g.nt)} (h : RG_derives g [symbol.nonterminal A] s) :
          (∃ (p : List T) (C : g.nt), s = List.map symbol.terminal p ++ [symbol.nonterminal C]) ∃ (p : List T), s = List.map symbol.terminal p
          theorem isRegular_of_is_RG {T : Type} {L : Language T} (h : is_RG L) :

          Every right-regular grammar language is Mathlib-regular.

          def RG_of_DFA {T : Type} [Fintype T] {σ : Type} [Fintype σ] (M : DFA T σ) :

          Right-regular grammar constructed from a DFA over a finite alphabet.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem RG_of_DFA_cons_mem {T : Type} [Fintype T] {σ : Type} [Fintype σ] (M : DFA T σ) (q : σ) (a : T) :
            theorem RG_of_DFA_epsilon_mem {T : Type} [Fintype T] {σ : Type} [Fintype σ] (M : DFA T σ) (q : σ) (hq : q M.accept) :
            theorem RG_of_DFA_epsilon_mem_iff {T : Type} [Fintype T] {σ : Type} [Fintype σ] (M : DFA T σ) (q : σ) :
            theorem RG_of_DFA_no_single {T : Type} [Fintype T] {σ : Type} [Fintype σ] (M : DFA T σ) (q : σ) (a : T) :
            theorem RG_of_DFA_derives_inv {T : Type} [Fintype T] {σ : Type} [Fintype σ] (M : DFA T σ) (q : σ) (s : List (symbol T σ)) (h : RG_derives (RG_of_DFA M) [symbol.nonterminal q] s) :
            theorem RG_of_DFA_language {T : Type} [Fintype T] {σ : Type} [Fintype σ] (M : DFA T σ) :
            theorem is_RG_of_isRegular {T : Type} [Fintype T] {L : Language T} (h : L.IsRegular) :

            Every Mathlib-regular language over a finite alphabet is generated by a right-regular grammar.

            theorem is_RG_iff_isRegular {T : Type} [Fintype T] {L : Language T} :

            Right-regular grammars generate exactly the Mathlib-regular languages (over a finite alphabet).