Langlib

Langlib.Classes.ContextFree.Pumping.TerminalRestriction

Terminal Restriction for CFGs #

This file replaces long mixed right-hand sides by rules that isolate terminals in preparation for Chomsky normal form.

Main declarations #

def embedSymbol {T : Type} {N : Type uN} (s : Symbol T N) :
Symbol T (N T)

Intuitive embedding of symbols of the original grammar into symbols of the new grammar's type

Equations
Instances For
    @[reducible, inline]
    abbrev embedString {T : Type} {N : Type uN} (u : List (Symbol T N)) :
    List (Symbol T (N T))

    Intuitive embedding of strings of the original grammar into strings of the new grammar's type

    Equations
    Instances For
      def rightEmbedSymbol {T : Type} {N : Type uN} (s : Symbol T N) :
      Symbol T (N T)

      Embedding of symbols of the original grammar into nonterminals of the new grammar

      Equations
      Instances For
        @[reducible, inline]
        abbrev rightEmbedString {T : Type} {N : Type uN} (w : List (Symbol T N)) :
        List (Symbol T (N T))

        Embedding of strings of the original grammar into nonterminal (symbol) strings of the new grammar

        Equations
        Instances For
          def projectSymbol {T : Type} {N : Type uN} (s : Symbol T (N T)) :
          Symbol T N

          Projection from symbols of the new grammars type into symbols of the original grammar

          Equations
          Instances For
            def projectString {T : Type} {N : Type uN} (u : List (Symbol T (N T))) :
            List (Symbol T N)

            Projection from strings of the new grammars type into strings of the original grammar

            Equations
            Instances For
              theorem embedString_append {T : Type} {N : Type uN} {u v : List (Symbol T N)} :

              Computes rules r' : T -> t, for all terminals t occuring in r.output

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

                If r.output is a single terminal, we lift the rule to the new grammar, otherwise add new rules for each terminal symbol in r.output and right-lift the rule, i.e., replace all terminals with nonterminals

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

                  Construct new grammar, using the lifted rules. Each rule's output is either a single terminal or only nonterminals

                  Equations
                  Instances For