Langlib

Langlib.Grammars.LR.Equivalence.DPDAToLR.EmptyReturns

Empty-list returns on an active characteristic spine #

An empty-list rule removes its active marker completely, so the final-list cancellation used for nonbase productions is unavailable. This file isolates the corresponding return problem and records the exact terminal displacement forced by equality of the two post-return forms.

theorem DPDA_to_LR.append_terminals_eq_cases {T : Type} [Fintype T] {N : Type} {p₁ p₂ : List (symbol T N)} {s₂ y : List T} (h : p₂ ++ List.map symbol.terminal s₂ = p₁ ++ List.map symbol.terminal y) :
(∃ (z : List T), p₁ = p₂ ++ List.map symbol.terminal z s₂ = z ++ y) ∃ (z : List T), p₂ = p₁ ++ List.map symbol.terminal z y = z ++ s₂

If two prefixes become equal after terminal suffixes are appended, one prefix extends the other by a terminal word, and the same word is transferred between the suffixes.

theorem DPDA_to_LR.cancel_final_nonterminal {T : Type} [Fintype T] {N : Type} {p₁ p₂ : List (symbol T N)} {A₁ A₂ : N} {s₁ s₂ : List T} (h : p₂ ++ [symbol.nonterminal A₂] ++ List.map symbol.terminal s₂ = p₁ ++ [symbol.nonterminal A₁] ++ List.map symbol.terminal s₁) :
p₂ = p₁ A₂ = A₁ s₂ = s₁

A displayed final nonterminal followed only by terminals is a unique right marker, even when arbitrary nonterminals occur in its prefix.

def DPDA_to_LR.EmptyListSpinesUnique {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :

Spine-native form of the remaining empty-return uniqueness property.

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

    A spine-level empty-return theorem supplies the exact semantic property expected by the LR-core reduction.

    The three possible incoming edges of an empty-list occurrence #

    inductive DPDA_to_LR.EmptyBaseEdge {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
    List (symbol T (Nonterminal M))State MList TProp

    A normalized top spine edge whose child is list q [] q.

    Instances For
      inductive DPDA_to_LR.EmptyTransitionEdge {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
      List (symbol T (Nonterminal M))State MList TProp

      An empty return generated by an actual PDA transition, rather than by the structural empty right child of a stack split.

      Instances For
        theorem DPDA_to_LR.EmptyTransitionEdge.baseEdge {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix : List T} (h : EmptyTransitionEdge M p q suffix) :
        EmptyBaseEdge M p q suffix

        Forgetting the transition-only tag gives the corresponding normalized empty edge.

        theorem DPDA_to_LR.EmptyBaseEdge.split_shape_of_not_transition {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix : List T} (h : EmptyBaseEdge M p q suffix) (hnot : ¬EmptyTransitionEdge M p q suffix) :
        ∃ (base : List (symbol T (Nonterminal M))) (source : State M) (Z : StackSymbol M), p = base ++ [symbol.nonterminal (PDA_to_CFG.N.single source Z q)]

        A normalized empty edge which is not transition-generated has the exact visible-prefix shape of the right child of a split.

        inductive DPDA_to_LR.SingleBaseEdge {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
        List (symbol T (Nonterminal M))State MStackSymbol MState MList TProp

        The only possible incoming spine edge of a characteristic single nonterminal. Its parent is the corresponding nonempty list node, and the terminal word stored in the child's suffix is exactly the completed right sibling of that split.

        Instances For
          theorem DPDA_to_LR.singleBaseEdge_of_activeSpine {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {source target : State M} {Z : StackSymbol M} {suffix : List T} (h : ActiveSpine M p (PDA_to_CFG.N.single source Z target) suffix) :
          SingleBaseEdge M p source Z target suffix

          Every reachable active single occurrence is the left child of one split edge.

          theorem DPDA_to_LR.emptyBaseEdge_of_activeSpine {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix : List T} (h : ActiveSpine M p (PDA_to_CFG.N.list q [] q) suffix) :
          EmptyBaseEdge M p q suffix

          Every active empty-list occurrence was introduced by exactly one of the three normalized edge forms above.

          Operational factorization of an empty return #

          def DPDA_to_LR.EmptyReturnRun {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (preWord suffix : List T) (q : State M) :

          Completing the visible prefix of an empty-list edge exposes one complete net-pop segment. The segment starts just before the edge's parent, removes its displayed stack symbol, and ends at the empty-list state with the saved stack context restored.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            def DPDA_to_LR.EmptyTransitionRun {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (preWord suffix : List T) (q : State M) :

            Transition-generated empty returns have the stronger factorization in which the net-pop segment consists of exactly one PDA step.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem DPDA_to_LR.EmptyBaseEdge.returnRun {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix preWord : List T} (edge : EmptyBaseEdge M p q suffix) (hp : (characteristicGrammar M).DerivesRightmost p (List.map symbol.terminal preWord)) :
              EmptyReturnRun M preWord suffix q

              Every normalized empty edge has an exact useful net-pop run after any chosen terminal completion of its visible prefix.

              theorem DPDA_to_LR.EmptyTransitionEdge.transitionRun {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix preWord : List T} (edge : EmptyTransitionEdge M p q suffix) (hp : (characteristicGrammar M).DerivesRightmost p (List.map symbol.terminal preWord)) :
              EmptyTransitionRun M preWord suffix q

              The one-step specialization of EmptyBaseEdge.returnRun for an actual read or epsilon transition edge.

              theorem DPDA_to_LR.EmptyBaseEdge.prefixCompletion {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix : List T} (edge : EmptyBaseEdge M p q suffix) :

              Every visible prefix of an empty edge has a terminal completion. In the split case this explicitly completes the exposed left single; the retained split rule guarantees that this nonterminal is productive.

              theorem DPDA_to_LR.EmptyBaseEdge.concrete {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix preWord : List T} (edge : EmptyBaseEdge M p q suffix) (hp : (characteristicGrammar M).DerivesRightmost p (List.map symbol.terminal preWord)) :
              ConcreteEmptyEdge M p q suffix

              A chosen terminal completion of the visible prefix upgrades a normalized empty edge to its exact-context concrete form.

              theorem DPDA_to_LR.EmptyTransitionEdge.concrete {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix preWord : List T} (edge : EmptyTransitionEdge M p q suffix) (hp : (characteristicGrammar M).DerivesRightmost p (List.map symbol.terminal preWord)) :

              A chosen completion similarly upgrades a transition-tagged empty edge.

              theorem DPDA_to_LR.EmptyBaseEdge.exists_concrete {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix : List T} (edge : EmptyBaseEdge M p q suffix) :
              ConcreteEmptyEdge M p q suffix

              Every syntax-facing empty edge has a concrete exact-context witness.

              theorem DPDA_to_LR.EmptyTransitionEdge.exists_concrete {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix : List T} (edge : EmptyTransitionEdge M p q suffix) :

              Every syntax-facing transition edge has a concrete transition witness.

              theorem DPDA_to_LR.EmptyBaseEdge.exists_returnRun {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p : List (symbol T (Nonterminal M))} {q : State M} {suffix : List T} (edge : EmptyBaseEdge M p q suffix) :
              ∃ (preWord : List T), EmptyReturnRun M preWord suffix q

              An empty edge therefore always admits at least one concrete useful net-pop factorization.

              The exact semantic return residual #

              def DPDA_to_LR.EmptyReturnEdgesUnique {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :

              Uniqueness of normalized empty-return edges. All grammar syntax has already been eliminated from this statement: its two witnesses are precisely the three possible incoming edges of an active list q [] q node.

              This is the empty-handle counterpart of IntroducingEdgesUnique. The remaining proof is the useful-path/no-epsilon-cycle argument for the normalized DPDA; the adapters below contain the entire derivation-spine and rule-shape assembly.

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

                A concrete paired-return classifier supplies normalized empty-return edge uniqueness. The synchronization proof may be plugged in here once available.

                Normalized empty-return edge uniqueness implies the spine-native property used by the grammar proof.

                Normalized empty-return edge uniqueness supplies the exact base-rule obligation expected by the LR core.

                The complete unaugmented LR(1) core, parameterized only by the two normalized operational uniqueness statements.

                The complete augmented LR(1) result, with every grammar-syntactic case already discharged.