Langlib

Langlib.Classes.Regular.Decidability.Characterization

EncodedRG characterizes the regular languages #

This file proves that the right-regular-grammar encoding EncodedRG denotes exactly the regular languages:

∀ L, L.IsRegular ↔ ∃ c : EncodedRG T, regularLanguageOf c = L

Soundness (every code denotes a regular language): an EncodedRG decodes — by construction — to a right-regular grammar toRG c whose RG_language equals regularLanguageOf c (both are the context-free language of the same underlying context-free grammar, via CF_grammar_of_RG). Hence the language is is_RG, so IsRegular.

The right-regular grammar denoted by an encoded right-regular grammar: it reads each rule body back as a right-regular rule over the nonterminals Fin (toCFG c).ntCount.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Decode an encoded right-regular grammar to a RG_grammar.

    Equations
    Instances For

      The context-free grammar of toRG c is exactly the context-free grammar that regularLanguageOf already uses, namely (toCFG c).toCFGrammar.

      RG_language of toRG c is the language denoted by the code.

      Soundness: every code denotes a regular language.

      Completeness: every regular language is encoded #

      Encode a right-regular rule (over Fin (k+1)) back into the EncodedRG body format.

      Equations
      Instances For
        theorem Regular.EncodedRG.toNT_self {T : Type} (c : EncodedRG T) (A : Fin c.toCFG.ntCount) :
        c.toCFG.toNT A = A

        toNT is the identity on indices already in range.

        noncomputable def Regular.EncodedRG.encodeDFA {T : Type} [Fintype T] {k : } (M : DFA T (Fin (k + 1))) [DecidablePred fun (x : Fin (k + 1)) => x M.accept] :

        Encode a DFA over Fin (k+1) as a right-regular code.

        Equations
        Instances For
          theorem Regular.EncodedRG.toRG_encodeDFA {T : Type} [Fintype T] {k : } (M : DFA T (Fin (k + 1))) [DecidablePred fun (x : Fin (k + 1)) => x M.accept] :

          Decoding the encoding of a DFA recovers RG_of_DFA.

          Completeness: every regular language is denoted by some code.

          EncodedRG characterizes the regular languages (the library's class RG).