Langlib

Langlib.Classes.ContextFree.Basics.Lifting

Context-Free Lifting #

This file lifts context-free grammars across embeddings of nonterminal types and supplies reusable sum-type constructions.

Main declarations #

def lift_symbol {T N₀ N : Type} (lift_N : N₀N) :
symbol T N₀symbol T N
Equations
Instances For
    def sink_symbol {T N₀ N : Type} (sink_N : NOption N₀) :
    symbol T NOption (symbol T N₀)
    Equations
    Instances For
      def lift_string {T N₀ N : Type} (lift_N : N₀N) :
      List (symbol T N₀)List (symbol T N)
      Equations
      Instances For
        def sink_string {T N₀ N : Type} (sink_N : NOption N₀) :
        List (symbol T N)List (symbol T N₀)
        Equations
        Instances For
          def lift_rule {T N₀ N : Type} (lift_N : N₀N) :
          N₀ × List (symbol T N₀)N × List (symbol T N)
          Equations
          Instances For
            structure lifted_grammar (T : Type) :
            Instances For
              theorem lift_deri {T : Type} {lg : lifted_grammar T} {w₁ w₂ : List (symbol T lg.g₀.nt)} (hyp : CF_derives lg.g₀ w₁ w₂) :
              def good_letter {T : Type} {lg : lifted_grammar T} :
              symbol T lg.g.ntProp
              Equations
              Instances For
                def good_string {T : Type} {lg : lifted_grammar T} (s : List (symbol T lg.g.nt)) :
                Equations
                Instances For
                  theorem sink_deri {T : Type} (lg : lifted_grammar T) (w₁ w₂ : List (symbol T lg.g.nt)) (hyp : CF_derives lg.g w₁ w₂) (ok_input : good_string w₁) :
                  theorem lift_string_terminal_inv {T N₀ N : Type} (f : N₀N) (u : List (symbol T N₀)) (ts : List T) (h : lift_string f u = List.map symbol.terminal ts) :

                  If lift_string f u is all terminals, then u was already all terminals. Applies to any lift_string (or List.map of a lift_symbol).

                  def sTN_of_sTN₁ {T : Type} {g₁ g₂ : CF_grammar T} :
                  symbol T g₁.ntsymbol T (Option (g₁.nt g₂.nt))

                  similar to lift_symbol (Option.some ∘ sum.inl)

                  Equations
                  Instances For
                    def sTN_of_sTN₂ {T : Type} {g₁ g₂ : CF_grammar T} :
                    symbol T g₂.ntsymbol T (Option (g₁.nt g₂.nt))

                    similar to lift_symbol (Option.some ∘ sum.inr)

                    Equations
                    Instances For
                      def lsTN_of_lsTN₁ {T : Type} {g₁ g₂ : CF_grammar T} :
                      List (symbol T g₁.nt)List (symbol T (Option (g₁.nt g₂.nt)))

                      similar to lift_string (Option.some ∘ sum.inl)

                      Equations
                      Instances For
                        def lsTN_of_lsTN₂ {T : Type} {g₁ g₂ : CF_grammar T} :
                        List (symbol T g₂.nt)List (symbol T (Option (g₁.nt g₂.nt)))

                        similar to lift_string (Option.some ∘ sum.inr)

                        Equations
                        Instances For
                          def rule_of_rule₁ {T : Type} {g₁ g₂ : CF_grammar T} (r : g₁.nt × List (symbol T g₁.nt)) :
                          Option (g₁.nt g₂.nt) × List (symbol T (Option (g₁.nt g₂.nt)))

                          similar to lift_rule (Option.some ∘ sum.inl)

                          Equations
                          Instances For
                            def rule_of_rule₂ {T : Type} {g₁ g₂ : CF_grammar T} (r : g₂.nt × List (symbol T g₂.nt)) :
                            Option (g₁.nt g₂.nt) × List (symbol T (Option (g₁.nt g₂.nt)))

                            similar to lift_rule (Option.some ∘ sum.inr)

                            Equations
                            Instances For

                              lsTN_of_lsTN₁ agrees with lift_string (some ∘ Sum.inl) pointwise.

                              lsTN_of_lsTN₂ agrees with lift_string (some ∘ Sum.inr) pointwise.

                              theorem lsTN_of_lsTN₁_terminal_inv {T : Type} {g₁ g₂ : CF_grammar T} (u : List (symbol T g₁.nt)) (ts : List T) (h : lsTN_of_lsTN₁ u = List.map symbol.terminal ts) :

                              If lsTN_of_lsTN₁ u = List.map symbol.terminal ts, then u was all terminals.

                              theorem lsTN_of_lsTN₂_terminal_inv {T : Type} {g₁ g₂ : CF_grammar T} (v : List (symbol T g₂.nt)) (ts : List T) (h : lsTN_of_lsTN₂ v = List.map symbol.terminal ts) :

                              If lsTN_of_lsTN₂ v = List.map symbol.terminal ts, then v was all terminals.