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 #
def
liftRhs1
{T N₁ N₂ F₁ F₂ : Type}
:
IRhsSymbol T N₁ F₁ → IRhsSymbol T (UnionNT N₁ N₂) (UnionFlag F₁ F₂)
Equations
Instances For
def
liftRhs2
{T N₁ N₂ F₁ F₂ : Type}
:
IRhsSymbol T N₂ F₂ → IRhsSymbol T (UnionNT N₁ N₂) (UnionFlag F₁ F₂)
Equations
Instances For
Indexed grammar for the union of two indexed languages.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- liftISym1 g₁ g₂ (IndexedGrammar.ISym.terminal t) = IndexedGrammar.ISym.terminal t
- liftISym1 g₁ g₂ (IndexedGrammar.ISym.indexed n σ) = IndexedGrammar.ISym.indexed (UnionNT.inl n) (List.map UnionFlag.inl σ)
Instances For
Equations
- liftISym2 g₁ g₂ (IndexedGrammar.ISym.terminal t) = IndexedGrammar.ISym.terminal t
- liftISym2 g₁ g₂ (IndexedGrammar.ISym.indexed n σ) = IndexedGrammar.ISym.indexed (UnionNT.inr n) (List.map UnionFlag.inr σ)
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₂)
:
theorem
lift2_deri
{T : Type}
(g₁ g₂ : IndexedGrammar T)
{w₁ w₂ : List g₂.ISym}
(h : g₂.Derives w₁ 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
union_first_step
{T : Type}
(g₁ g₂ : IndexedGrammar T)
{b : List (indexed_union g₁ g₂).ISym}
(h : (indexed_union g₁ g₂).Transforms [IndexedGrammar.ISym.indexed UnionNT.start []] b)
:
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₂)
:
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₂)
:
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₂)
:
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₂)
:
theorem
liftISym1_terminal_inv
{T : Type}
(g₁ g₂ : IndexedGrammar T)
{wg : List g₁.ISym}
{w : List T}
(h : List.map (liftISym1 g₁ g₂) wg = List.map IndexedGrammar.ISym.terminal w)
:
theorem
liftISym2_terminal_inv
{T : Type}
(g₁ g₂ : IndexedGrammar T)
{wg : List g₂.ISym}
{w : List T}
(h : List.map (liftISym2 g₁ g₂) wg = List.map IndexedGrammar.ISym.terminal w)
:
theorem
union_backward
{T : Type}
(g₁ g₂ : IndexedGrammar T)
(w : List T)
(h : (indexed_union g₁ 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.