Langlib

Langlib.Classes.Indexed.Closure.Union

Indexed Languages Are Closed Under Union #

Given indexed grammars g₁ and g₂, we construct an indexed grammar whose language is g₁.Language ∪ g₂.Language.

The construction introduces a fresh start symbol with two rules that jump to the respective initial symbols of g₁ and g₂.

Proof idea: lift the nonterminals and flags of the two grammars into disjoint summands and add one fresh start symbol. The only first step chooses the left or right grammar, and the lifting lemmas identify the resulting derivations with the original component derivations.

Main declarations #

inductive UnionNT (N₁ N₂ : Type) :

The combined nonterminal type for the union grammar.

Instances For
    inductive UnionFlag (F₁ F₂ : Type) :

    The combined flag type for the union grammar.

    Instances For
      def liftRule1 {T N₁ N₂ F₁ F₂ : Type} (r : IRule T N₁ F₁) :
      IRule T (UnionNT N₁ N₂) (UnionFlag F₁ F₂)
      Equations
      Instances For
        def liftRule2 {T N₁ N₂ F₁ F₂ : Type} (r : IRule T N₂ F₂) :
        IRule T (UnionNT N₁ N₂) (UnionFlag F₁ F₂)
        Equations
        Instances For
          def indexed_union {T : Type} (g₁ g₂ : IndexedGrammar T) :

          Indexed grammar for the union of two indexed languages.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem lift1_expandRhs {T : Type} (g₁ g₂ : IndexedGrammar T) (rhs : List (IRhsSymbol T g₁.nt g₁.flag)) (σ : List g₁.flag) :
            List.map (liftISym1 g₁ g₂) (g₁.expandRhs rhs σ) = (indexed_union g₁ g₂).expandRhs (List.map liftRhs1 rhs) (List.map UnionFlag.inl σ)
            theorem lift2_expandRhs {T : Type} (g₁ g₂ : IndexedGrammar T) (rhs : List (IRhsSymbol T g₂.nt g₂.flag)) (σ : List g₂.flag) :
            List.map (liftISym2 g₁ g₂) (g₂.expandRhs rhs σ) = (indexed_union g₁ g₂).expandRhs (List.map liftRhs2 rhs) (List.map UnionFlag.inr σ)
            theorem lift1_tran {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ w₂ : List g₁.ISym} (h : g₁.Transforms w₁ w₂) :
            (indexed_union g₁ g₂).Transforms (List.map (liftISym1 g₁ g₂) w₁) (List.map (liftISym1 g₁ g₂) w₂)
            theorem lift2_tran {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ w₂ : List g₂.ISym} (h : g₂.Transforms w₁ w₂) :
            (indexed_union g₁ g₂).Transforms (List.map (liftISym2 g₁ g₂) w₁) (List.map (liftISym2 g₁ g₂) w₂)
            theorem lift1_deri {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ w₂ : List g₁.ISym} (h : g₁.Derives w₁ w₂) :
            (indexed_union g₁ g₂).Derives (List.map (liftISym1 g₁ g₂) w₁) (List.map (liftISym1 g₁ g₂) w₂)
            theorem lift2_deri {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ w₂ : List g₂.ISym} (h : g₂.Derives w₁ w₂) :
            (indexed_union g₁ g₂).Derives (List.map (liftISym2 g₁ g₂) w₁) (List.map (liftISym2 g₁ g₂) w₂)
            theorem union_generates_left {T : Type} (g₁ g₂ : IndexedGrammar T) (w : List T) (h : g₁.Generates w) :
            (indexed_union g₁ g₂).Generates w
            theorem union_generates_right {T : Type} (g₁ g₂ : IndexedGrammar T) (w : List T) (h : g₂.Generates w) :
            (indexed_union g₁ g₂).Generates w
            theorem unlift1_tran {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ : List g₁.ISym} {w₂ : List (indexed_union g₁ g₂).ISym} (ht : (indexed_union g₁ g₂).Transforms (List.map (liftISym1 g₁ g₂) w₁) w₂) :
            ∃ (w₂g : List g₁.ISym), w₂ = List.map (liftISym1 g₁ g₂) w₂g g₁.Transforms w₁ w₂g
            theorem unlift2_tran {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ : List g₂.ISym} {w₂ : List (indexed_union g₁ g₂).ISym} (ht : (indexed_union g₁ g₂).Transforms (List.map (liftISym2 g₁ g₂) w₁) w₂) :
            ∃ (w₂g : List g₂.ISym), w₂ = List.map (liftISym2 g₁ g₂) w₂g g₂.Transforms w₁ w₂g
            theorem unlift1_deri {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ : List g₁.ISym} {w₂ : List (indexed_union g₁ g₂).ISym} (h : (indexed_union g₁ g₂).Derives (List.map (liftISym1 g₁ g₂) w₁) w₂) :
            ∃ (w₂g : List g₁.ISym), w₂ = List.map (liftISym1 g₁ g₂) w₂g g₁.Derives w₁ w₂g
            theorem unlift2_deri {T : Type} (g₁ g₂ : IndexedGrammar T) {w₁ : List g₂.ISym} {w₂ : List (indexed_union g₁ g₂).ISym} (h : (indexed_union g₁ g₂).Derives (List.map (liftISym2 g₁ g₂) w₁) w₂) :
            ∃ (w₂g : List g₂.ISym), w₂ = List.map (liftISym2 g₁ g₂) w₂g g₂.Derives w₁ w₂g
            theorem union_backward {T : Type} (g₁ g₂ : IndexedGrammar T) (w : List T) (h : (indexed_union g₁ g₂).Generates w) :
            g₁.Generates w g₂.Generates w
            theorem Indexed_of_Indexed_u_Indexed {T : Type} (L₁ L₂ : Language T) :
            is_Indexed L₁ is_Indexed L₂is_Indexed (L₁ + L₂)

            The class of indexed languages is closed under union.

            The class of indexed languages is closed under union.