Langlib

Langlib.Classes.LR.Closure.Bijection

LR Languages Under Injective Terminal Maps #

This file proves that LR(k) languages are closed under injective letter-to-letter terminal maps. The construction relabels terminals in a context-free grammar and uses injectivity to reflect rightmost derivations back to the original grammar, where the LR(k) uniqueness condition is available.

@[reducible]
def map_CF_rule {T₁ T₂ N : Type} (f : T₁T₂) (r : N × List (symbol T₁ N)) :
N × List (symbol T₂ N)

Map a context-free rule along a terminal map, leaving nonterminals unchanged.

Equations
Instances For
    @[reducible]
    def map_CF_grammar {T₁ T₂ : Type} (g : CF_grammar T₁) (f : T₁T₂) :

    Map a context-free grammar along a terminal map, leaving nonterminals unchanged.

    Equations
    Instances For
      theorem map_CF_grammar_language_of_leftInverse {T₁ T₂ : Type} (g : CF_grammar T₁) {f : T₁T₂} {g' : T₂T₁} (hfg : Function.LeftInverse g' f) :

      The relabelled context-free grammar generates exactly the image language.

      theorem map_CF_grammar_isLRk_of_injective {T₁ T₂ : Type} [Nonempty T₁] (g : CF_grammar T₁) {f : T₁T₂} (hf : Function.Injective f) {k : } (hg : g.IsLRk k) :

      Relabelling a grammar by an injective terminal map preserves the LR(k) condition.

      theorem is_LRk_map_injective {T₁ T₂ : Type} [Nonempty T₁] {f : T₁T₂} (hf : Function.Injective f) {k : } {L : Language T₁} (hL : is_LRk k L) :

      LR(k) languages are closed under injective terminal maps.

      theorem is_LR_map_injective {T₁ T₂ : Type} [Nonempty T₁] {f : T₁T₂} (hf : Function.Injective f) {L : Language T₁} (hL : is_LR L) :

      LR languages are closed under injective terminal maps.