Langlib

Langlib.Grammars.NonContracting.Equivalence.ContextSensitiveGeneral

Non-contracting grammars and context-preserving grammars #

This file completes the hard direction of the classical equivalence between non-contracting unrestricted grammars and non-erasing context-preserving grammars.

The terminal alphabet of a grammar is always finitely supported, even when its ambient terminal type is arbitrary. We therefore first restrict a non-contracting language to that finite support, use the Kuroda--Myhill CS = LBA development to obtain a context-preserving grammar there, and finally embed that grammar back into the ambient terminal type.

The last operation is proved below without a finiteness assumption on the target type. Original terminals are kept as private nonterminals while the source grammar runs and are converted to ambient terminals only by final one-symbol rules. Projecting such a derivation back either gives a source-grammar step or a stuttering step, which proves soundness even when the final conversions are interleaved with simulation steps.

inductive CSGTerminalEmbedding.NT {A : Type} (N : Type) :

Nonterminals used when embedding a context-preserving grammar's terminal alphabet.

  • source {A N : Type} : NNT N
  • terminal {A N : Type} : ANT N
Instances For
    def CSGTerminalEmbedding.liftRule {A T N : Type} (r : csrule A N) :
    csrule T (NT N)

    Lift a source context-preserving rule.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def CSGTerminalEmbedding.terminalRule {A T N : Type} (f : AT) (a : A) :
      csrule T (NT N)

      Convert one private source-terminal nonterminal to its ambient terminal.

      Equations
      Instances For
        noncomputable def CSGTerminalEmbedding.grammar {A T : Type} [Fintype A] [DecidableEq A] (g : CS_grammar A) (f : A T) :

        Embed a context-preserving grammar along an injective terminal map.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          noncomputable def CSGTerminalEmbedding.projectSymbol {A T : Type} [Nonempty A] {N : Type} (f : A T) :
          symbol T (NT N)symbol A N

          Project an embedded sentential symbol to the source grammar. Ambient terminals not in the embedding's range may be sent to the arbitrary invFun default; the support invariant below proves that no such terminal is reachable.

          Equations
          Instances For
            def CSGTerminalEmbedding.Supported {A T N : Type} (f : A T) (s : List (symbol T (NT N))) :

            All ambient terminals in a sentential form lie in the embedding's range.

            Equations
            Instances For

              Embedding a finite source terminal alphabet along an injection produces exactly the language image, while the target terminal type remains completely arbitrary.

              Non-contracting implies non-erasing context-preserving, for an arbitrary terminal type. No finiteness hypothesis is imposed on the ambient alphabet; only the finite support actually occurring in the source grammar is used internally.

              The classical equivalence between non-contracting unrestricted grammars and non-erasing context-preserving grammars, uniformly over every terminal type.