Langlib

Langlib.Automata.DeterministicPushdown.Totalization.AnnotatedStack

Totalizer Annotated Stack #

This file defines the finite stack annotations and regular lookahead queries used by the DPDA totalizer once a RegularEpsilonAnalysis has been built.

structure DPDA.AnalysisSummary {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) :

The vector of DFA transition summaries stored for the stack suffix below a symbol.

Instances For
    def DPDA.AnalysisSummary.equivProd {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) :
    AnalysisSummary A ((q : Q) → A.StopState qA.StopState q) × ((q : Q) → A.AcceptState qA.AcceptState q)

    AnalysisSummary is just a pair of finite dependent function spaces.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      noncomputable instance DPDA.instFintypeAnalysisSummary {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) :
      Equations

      The empty-suffix summary vector.

      Equations
      Instances For
        def DPDA.SummaryRepresents {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (summary : AnalysisSummary A) (γ : List S) :

        A summary vector represents an original stack suffix when every component is the DFA transition function induced by reading that suffix.

        Equations
        Instances For
          theorem DPDA.SummaryRepresents.eq {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {summary₁ summary₂ : AnalysisSummary A} {γ : List S} (h₁ : SummaryRepresents A summary₁ γ) (h₂ : SummaryRepresents A summary₂ γ) :
          summary₁ = summary₂

          The identity summary represents the empty stack suffix.

          def DPDA.AnalysisSummary.above {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (below : AnalysisSummary A) (γ : List S) :

          Update a summary vector by placing a block of original stack symbols above it.

          Equations
          Instances For
            theorem DPDA.SummaryRepresents.above {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {below : AnalysisSummary A} {δ : List S} (hbelow : SummaryRepresents A below δ) (γ : List S) :

            Updating a correct summary with a block keeps it correct for the larger suffix.

            theorem DPDA.SummaryRepresents.cons {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {below : AnalysisSummary A} {γ : List S} (hbelow : SummaryRepresents A below γ) (Z : S) :

            Placing one top symbol above a represented suffix gives a represented full stack.

            @[reducible, inline]
            abbrev DPDA.TotalStackSymbol {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) :

            Stack symbols of the totalized machine. none is the permanent bottom marker; some (Z, s) is an original stack symbol annotated with the summary vector of the original stack suffix below it.

            Equations
            Instances For
              def DPDA.annotateAbove {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (below : AnalysisSummary A) :

              Annotate a replacement block above an already summarized suffix.

              Equations
              Instances For
                @[simp]
                theorem DPDA.annotateAbove_nil {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (below : AnalysisSummary A) :
                @[simp]
                theorem DPDA.annotateAbove_cons {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (below : AnalysisSummary A) (Z : S) (γ : List S) :
                annotateAbove A below (Z :: γ) = some (Z, AnalysisSummary.above A below γ) :: annotateAbove A below γ
                def DPDA.eraseAnnotatedStack {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) :

                Erase annotations from a totalized stack, dropping the bottom marker.

                Equations
                Instances For
                  theorem DPDA.erase_annotateAbove {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (below : AnalysisSummary A) (γ : List S) :

                  The annotation invariant for totalizer stacks. Every original stack symbol stores a summary for the erased suffix below it; none is the unique bottom marker.

                  Equations
                  Instances For
                    theorem DPDA.stackWellAnnotated_annotateAbove_append {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {below : AnalysisSummary A} {rest : List (TotalStackSymbol A)} (hbelow : SummaryRepresents A below (eraseAnnotatedStack A rest)) (hrest : StackWellAnnotated A rest) (γ : List S) :
                    StackWellAnnotated A (annotateAbove A below γ ++ rest)
                    def DPDA.StackHasBottom {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) :

                    Reachable totalizer stacks retain a permanent bottom marker.

                    Equations
                    Instances For
                      theorem DPDA.stackHasBottom_nonempty {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {stack : List (TotalStackSymbol A)} (hstack : StackHasBottom A stack) :
                      ∃ (top : TotalStackSymbol A) (rest : List (TotalStackSymbol A)), stack = top :: rest
                      theorem DPDA.stackHasBottom_annotateAbove_append {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {below : AnalysisSummary A} {rest : List (TotalStackSymbol A)} (hrest : StackHasBottom A rest) (γ : List S) :
                      StackHasBottom A (annotateAbove A below γ ++ rest)
                      def DPDA.topStops {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) :

                      Does the semantic epsilon phase terminate from the configuration represented by the current top stack symbol?

                      Equations
                      Instances For
                        def DPDA.topAcceptsEpsilonClosure {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) :

                        If the input is exhausted at the configuration represented by the current top stack symbol, does the original machine accept along its epsilon closure?

                        Equations
                        Instances For
                          theorem DPDA.topStops_some_correct {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (Z : S) (below : AnalysisSummary A) :
                          topStops A q (some (Z, below)) below.stop q ((A.stopDFA q).step (A.stopDFA q).start Z) (A.stopDFA q).accept
                          theorem DPDA.topAccepts_some_correct {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (Z : S) (below : AnalysisSummary A) :

                          The full original-stack summary represented by the current top symbol.

                          Equations
                          Instances For
                            theorem DPDA.stackWellAnnotated_fullSummaryOfTop {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {top : TotalStackSymbol A} {rest : List (TotalStackSymbol A)} (hstack : StackWellAnnotated A (top :: rest)) :
                            def DPDA.stopsFromSummary {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (summary : AnalysisSummary A) :

                            The stop lookahead evaluated from a full-stack summary.

                            Equations
                            Instances For
                              def DPDA.acceptsFromSummary {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (summary : AnalysisSummary A) :

                              The epsilon-acceptance lookahead evaluated from a full-stack summary.

                              Equations
                              Instances For
                                theorem DPDA.stopsFromSummary_correct {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {summary : AnalysisSummary A} {γ : List S} (hsummary : SummaryRepresents A summary γ) (q : Q) :
                                stopsFromSummary A q summary ∃ (c' : EpsilonConf Q S), M.EpsilonStopsAt (q, γ) c'

                                Stop-lookahead correctness for a summary representing the current original stack.

                                theorem DPDA.acceptsFromSummary_correct {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {summary : AnalysisSummary A} {γ : List S} (hsummary : SummaryRepresents A summary γ) (q : Q) :
                                acceptsFromSummary A q summary ∃ (q' : Q) (γ' : List S), M.EpsilonReaches (q, γ) (q', γ') q' M.final_states

                                Epsilon-acceptance lookahead correctness for a summary representing the current original stack.

                                def DPDA.acceptBit {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (summary : AnalysisSummary A) :

                                Boolean form of acceptsFromSummary, used in the finite control.

                                Equations
                                Instances For
                                  theorem DPDA.acceptBit_eq_true_iff {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (summary : AnalysisSummary A) :
                                  acceptBit A q summary = true acceptsFromSummary A q summary
                                  theorem DPDA.acceptBit_eq_false_iff {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (summary : AnalysisSummary A) :
                                  acceptBit A q summary = false ¬acceptsFromSummary A q summary
                                  theorem DPDA.topStops_eq_stopsFromSummary {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) (top : TotalStackSymbol A) :
                                  theorem DPDA.topStops_semantic_of_stackWellAnnotated {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {top : TotalStackSymbol A} {rest : List (TotalStackSymbol A)} (hstack : StackWellAnnotated A (top :: rest)) (q : Q) :
                                  topStops A q top ∃ (c' : EpsilonConf Q S), M.EpsilonStopsAt (q, eraseAnnotatedStack A (top :: rest)) c'
                                  theorem DPDA.topAccepts_semantic_of_stackWellAnnotated {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {top : TotalStackSymbol A} {rest : List (TotalStackSymbol A)} (hstack : StackWellAnnotated A (top :: rest)) (q : Q) :
                                  topAcceptsEpsilonClosure A q top ∃ (q' : Q) (γ' : List S), M.EpsilonReaches (q, eraseAnnotatedStack A (top :: rest)) (q', γ') q' M.final_states
                                  theorem DPDA.topStops_none_correct {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) :
                                  topStops A q none ∃ (c' : EpsilonConf Q S), M.EpsilonStopsAt (q, []) c'
                                  theorem DPDA.topAccepts_none_correct {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) (q : Q) :
                                  topAcceptsEpsilonClosure A q none ∃ (q' : Q) (γ' : List S), M.EpsilonReaches (q, []) (q', γ') q' M.final_states
                                  theorem DPDA.topStops_some_semantic {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {below : AnalysisSummary A} {γ : List S} (hbelow : SummaryRepresents A below γ) (q : Q) (Z : S) :
                                  topStops A q (some (Z, below)) ∃ (c' : EpsilonConf Q S), M.EpsilonStopsAt (q, Z :: γ) c'
                                  theorem DPDA.topAccepts_some_semantic {Q T S : Type} [Fintype Q] [Fintype T] [Fintype S] {M : DPDA Q T S} (A : M.RegularEpsilonAnalysis) {below : AnalysisSummary A} {γ : List S} (hbelow : SummaryRepresents A below γ) (q : Q) (Z : S) :
                                  topAcceptsEpsilonClosure A q (some (Z, below)) ∃ (q' : Q) (γ' : List S), M.EpsilonReaches (q, Z :: γ) (q', γ') q' M.final_states