Langlib

Langlib.Grammars.Indexed.Basics.FiniteSupport

Finite nonterminal and flag support for indexed grammars #

Indexed grammars store their rules in a finite list. Even if the ambient nonterminal and flag types are infinite, every derivation from the initial symbol only uses nonterminals and flags mentioned by the initial symbol or by the rules. This file restricts an indexed grammar to those finite supports while preserving its language.

Syntactic supports #

def IndexedGrammar.rhsSymbolNTs {T N F : Type} :
IRhsSymbol T N FList N

Nonterminals mentioned by a right-hand-side symbol.

Equations
Instances For
    def IndexedGrammar.ruleNTs {T N F : Type} (r : IRule T N F) :

    Nonterminals mentioned by a rule, including its left-hand side.

    Equations
    Instances For
      def IndexedGrammar.ruleFlags {T N F : Type} (r : IRule T N F) :

      Flags mentioned by a rule, including consumed and pushed flags.

      Equations
      Instances For

        The finite set of nonterminals used by an indexed grammar.

        Equations
        Instances For

          The finite set of flags used by an indexed grammar.

          Equations
          Instances For
            theorem IndexedGrammar.rhs_nonterminal_mem_ruleNTs {T N F : Type} {r : IRule T N F} {n : N} {push : Option F} (h : IRhsSymbol.nonterminal n push r.rhs) :
            theorem IndexedGrammar.lhs_mem_ruleNTs {T N F : Type} (r : IRule T N F) :
            theorem IndexedGrammar.ruleNT_mem_usedNTs {T : Type} {g : IndexedGrammar T} {r : IRule T g.nt g.flag} (hr : r g.rules) {n : g.nt} (hn : n ruleNTs r) :
            theorem IndexedGrammar.rule_rhs_nt_mem_usedNTs {T : Type} {g : IndexedGrammar T} {r : IRule T g.nt g.flag} (hr : r g.rules) {n : g.nt} {push : Option g.flag} (h : IRhsSymbol.nonterminal n push r.rhs) :
            theorem IndexedGrammar.consume_mem_ruleFlags {T N F : Type} {r : IRule T N F} {f : F} (h : r.consume = some f) :
            theorem IndexedGrammar.rhs_push_mem_ruleFlags {T N F : Type} {r : IRule T N F} {n : N} {f : F} (h : IRhsSymbol.nonterminal n (some f) r.rhs) :
            theorem IndexedGrammar.ruleFlag_mem_usedFlags {T : Type} {g : IndexedGrammar T} {r : IRule T g.nt g.flag} (hr : r g.rules) {f : g.flag} (hf : f ruleFlags r) :
            theorem IndexedGrammar.rule_consume_mem_usedFlags {T : Type} {g : IndexedGrammar T} {r : IRule T g.nt g.flag} (hr : r g.rules) {f : g.flag} (h : r.consume = some f) :
            theorem IndexedGrammar.rule_consume_mem_usedFlags_of_mem {T : Type} {g : IndexedGrammar T} {r : IRule T g.nt g.flag} (hr : r g.rules) {f : g.flag} (h : f r.consume) :
            theorem IndexedGrammar.rule_rhs_push_mem_usedFlags {T : Type} {g : IndexedGrammar T} {r : IRule T g.nt g.flag} (hr : r g.rules) {n : g.nt} {f : g.flag} (h : IRhsSymbol.nonterminal n (some f) r.rhs) :

            Restricted grammar #

            @[reducible, inline]

            The subtype of nonterminals used by g.

            Equations
            Instances For
              @[reducible, inline]

              The subtype of flags used by g.

              Equations
              Instances For
                Equations
                Instances For
                  def IndexedGrammar.restrictPush {T : Type} (g : IndexedGrammar T) (r : IRule T g.nt g.flag) (hr : r g.rules) {n : g.nt} (push : Option g.flag) (hs : IRhsSymbol.nonterminal n push r.rhs) :
                  Equations
                  Instances For
                    def IndexedGrammar.restrictRhsSymbol {T : Type} (g : IndexedGrammar T) (r : IRule T g.nt g.flag) (hr : r g.rules) (s : IRhsSymbol T g.nt g.flag) (hs : s r.rhs) :
                    Equations
                    Instances For
                      def IndexedGrammar.restrictRhs {T : Type} (g : IndexedGrammar T) (r : IRule T g.nt g.flag) (hr : r g.rules) :
                      Equations
                      Instances For
                        def IndexedGrammar.restrictRule {T : Type} (g : IndexedGrammar T) (r : IRule T g.nt g.flag) (hr : r g.rules) :
                        Equations
                        Instances For

                          The indexed grammar restricted to the finite nonterminal and flag supports used by g.

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

                            Embedding restricted syntax back into g #

                            Equations
                            Instances For
                              theorem IndexedGrammar.restrictPush_val {T : Type} (g : IndexedGrammar T) (r : IRule T g.nt g.flag) (hr : r g.rules) {n : g.nt} (push : Option g.flag) (hs : IRhsSymbol.nonterminal n push r.rhs) :
                              Option.map Subtype.val (g.restrictPush r hr push hs) = push
                              theorem IndexedGrammar.embed_restrictRhsSymbol {T : Type} (g : IndexedGrammar T) (r : IRule T g.nt g.flag) (hr : r g.rules) (s : IRhsSymbol T g.nt g.flag) (hs : s r.rhs) :

                              Finite-support sentential forms #

                              Equations
                              Instances For
                                Equations
                                Instances For
                                  theorem IndexedGrammar.stackSupported_tail {T : Type} {g : IndexedGrammar T} {f : g.flag} {σ : List g.flag} (h : g.stackSupported (f :: σ)) :
                                  theorem IndexedGrammar.stackSupported_cons {T : Type} {g : IndexedGrammar T} {f : g.flag} {σ : List g.flag} (hf : f g.usedFlags) ( : g.stackSupported σ) :
                                  theorem IndexedGrammar.expandRhs_supported {T : Type} {g : IndexedGrammar T} {r : IRule T g.nt g.flag} (hr : r g.rules) {σ : List g.flag} ( : g.stackSupported σ) :
                                  theorem IndexedGrammar.transforms_supported {T : Type} {g : IndexedGrammar T} {w₁ w₂ : List g.ISym} (h : g.Transforms w₁ w₂) (hsupp : g.sententialSupported w₁) :
                                  theorem IndexedGrammar.derives_supported {T : Type} {g : IndexedGrammar T} {w₁ w₂ : List g.ISym} (h : g.Derives w₁ w₂) (hsupp : g.sententialSupported w₁) :

                                  Restricting supported sentential forms #

                                  Equations
                                  Instances For
                                    Equations
                                    Instances For

                                      Derivation correspondence #

                                      theorem IndexedGrammar.transforms_restrict {T : Type} {g : IndexedGrammar T} {w₁ w₂ : List g.ISym} (h : g.Transforms w₁ w₂) (hsupp : g.sententialSupported w₁) :
                                      g.toFiniteSupport.Transforms (g.restrictSF w₁ hsupp) (g.restrictSF w₂ )
                                      theorem IndexedGrammar.derives_restrict {T : Type} {g : IndexedGrammar T} {w₁ w₂ : List g.ISym} (h : g.Derives w₁ w₂) (hsupp : g.sententialSupported w₁) :
                                      g.toFiniteSupport.Derives (g.restrictSF w₁ hsupp) (g.restrictSF w₂ )

                                      Language equality #

                                      theorem IndexedGrammar.exists_finiteSupport {T : Type} (g : IndexedGrammar T) :
                                      ∃ (g' : IndexedGrammar T) (x : Fintype g'.nt) (x : Fintype g'.flag), g'.Language = g.Language

                                      Every indexed grammar has an equivalent grammar whose nonterminal and flag types are finite.

                                      Preservation of normal form #