Langlib

Langlib.Grammars.Indexed.NormalForm.FreshStart

Fresh Start Symbol for Indexed Grammars #

This file proves that every indexed grammar can be transformed into one whose start symbol does not appear on the right-hand side of any production rule, while preserving the generated language.

This is Step 1 of Aho's Normal Form theorem for indexed grammars.

References #

Lifting functions #

Lift an RHS symbol to the Option nonterminal type.

Equations
Instances For
    def IndexedGrammar.liftRule {T : Type} (g : IndexedGrammar T) (r : IRule T g.nt g.flag) :

    Lift a production rule to the Option nonterminal type.

    Equations
    Instances For

      The grammar with a fresh start symbol none : Option g.nt. Has one start rule S' → S (where S' = none, S = some g.initial) and all original rules lifted.

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

        Key helper: expandRhs commutes with lifting #

        Forward direction: g.Language ⊆ (freshStart g).Language #

        theorem IndexedGrammar.freshStart_lift_derives {T : Type} (g : IndexedGrammar T) {w₁ w₂ : List g.ISym} (h : g.Derives w₁ w₂) :

        Backward direction: (freshStart g).Language ⊆ g.Language #

        A sentential form of freshStart g is "proper" if it contains no occurrence of the fresh start symbol none.

        Equations
        Instances For
          theorem IndexedGrammar.proper_of_proper_transforms {T : Type} (g : IndexedGrammar T) {w₁ w₂ : List g.freshStart.ISym} (hp : g.Proper w₁) (ht : g.freshStart.Transforms w₁ w₂) :
          g.Proper w₂
          theorem IndexedGrammar.proper_of_proper_derives {T : Type} (g : IndexedGrammar T) {w₁ w₂ : List g.freshStart.ISym} (hp : g.Proper w₁) (hd : g.freshStart.Derives w₁ w₂) :
          g.Proper w₂
          noncomputable def IndexedGrammar.unliftSF {T : Type} (g : IndexedGrammar T) [Inhabited T] (w : List g.freshStart.ISym) :

          Unlift a proper sentential form.

          Equations
          Instances For
            theorem IndexedGrammar.freshStart_unlift_transforms {T : Type} (g : IndexedGrammar T) [Inhabited T] {w₁ w₂ : List g.freshStart.ISym} (hp : g.Proper w₁) (ht : g.freshStart.Transforms w₁ w₂) :
            g.Transforms (g.unliftSF w₁) (g.unliftSF w₂)
            theorem IndexedGrammar.freshStart_unlift_derives {T : Type} (g : IndexedGrammar T) [Inhabited T] {w₁ w₂ : List g.freshStart.ISym} (hp : g.Proper w₁) (hd : g.freshStart.Derives w₁ w₂) :
            g.Derives (g.unliftSF w₁) (g.unliftSF w₂)

            Main result #

            The fresh-start grammar generates the same language as the original.

            Adding a fresh start symbol preserves the absence of ε-productions.