Langlib

Langlib.Automata.DeterministicPushdown.Totalization.Saturation

P-Automata for DPDA Epsilon Saturation #

This file contains the finite automaton layer and saturation construction for DPDA epsilon phases. The saturated P-automaton relations recognize exactly the stack prefixes whose epsilon phase can reach either a stable configuration or a final control state.

@[reducible, inline]
abbrev DPDA.PAutState (Q : Type) :

States of a P-automaton: original control states plus one distinguished sink state used by target automata for arbitrary stack suffixes.

Equations
Instances For

    Embed an original DPDA state as a P-automaton state.

    Equations
    Instances For

      Distinguished target/sink state.

      Equations
      Instances For
        inductive DPDA.RelPath {Q S : Type} (R : PAutState QSPAutState QProp) :
        PAutState QList SPAutState QProp

        A path through a stack-reading relation. Symbols are read top-to-bottom.

        Instances For
          theorem DPDA.RelPath.append {Q S : Type} {R : PAutState QSPAutState QProp} {p m r : PAutState Q} {γ δ : List S} (h₁ : RelPath R p γ m) (h₂ : RelPath R m δ r) :
          RelPath R p (γ ++ δ) r
          theorem DPDA.RelPath.of_append_left {Q S : Type} {R : PAutState QSPAutState QProp} {p r : PAutState Q} {γ δ : List S} (h : RelPath R p (γ ++ δ) r) :
          ∃ (m : PAutState Q), RelPath R p γ m RelPath R m δ r
          theorem DPDA.RelPath.mono {Q S : Type} {R₁ R₂ : PAutState QSPAutState QProp} (hsub : ∀ {p : PAutState Q} {Z : S} {r : PAutState Q}, R₁ p Z rR₂ p Z r) {p r : PAutState Q} {γ : List S} (h : RelPath R₁ p γ r) :
          RelPath R₂ p γ r
          def DPDA.relNFA {Q S : Type} (R : PAutState QSPAutState QProp) (start : PAutState Q) (accept : Set (PAutState Q)) :

          The NFA whose transitions are exactly a stack-reading relation.

          Equations
          Instances For
            theorem DPDA.relPath_iff_nonempty_nfa_path {Q S : Type} {R : PAutState QSPAutState QProp} {start : PAutState Q} {accept : Set (PAutState Q)} {p r : PAutState Q} {γ : List S} :
            RelPath R p γ r Nonempty ((relNFA R start accept).Path p r γ)
            def DPDA.relDFA {Q S : Type} (R : PAutState QSPAutState QProp) (start : PAutState Q) (accept : Set (PAutState Q)) :
            DFA S (Set (PAutState Q))

            The DFA obtained by subset construction from a stack-reading relation.

            Equations
            Instances For
              theorem DPDA.relDFA_accepts_iff {Q S : Type} {R : PAutState QSPAutState QProp} {start : PAutState Q} {accept : Set (PAutState Q)} {γ : List S} :
              γ (relDFA R start accept).accepts raccept, RelPath R start γ r

              Correctness of the relation DFA: it accepts exactly the stacks labeling a path from start to an accepting P-automaton state.

              theorem DPDA.relDFA_evalFrom_control_iff {Q S : Type} {R : PAutState QSPAutState QProp} {q : Q} {accept : Set (PAutState Q)} {γ : List S} :
              (relDFA R (PAutState.control q) accept).evalFrom (relDFA R (PAutState.control q) accept).start γ (relDFA R (PAutState.control q) accept).accept raccept, RelPath R (PAutState.control q) γ r

              The relation recognized from an original control state by the relation DFA.

              def DPDA.EpsilonStepSaturated {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (R : PAutState QSPAutState QProp) :

              A relation is saturated for the epsilon rules of a DPDA if every pushdown epsilon step can be summarized by a single stack-reading transition.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def DPDA.epsilonSaturationRel {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (base : PAutState QSPAutState QProp) :
                PAutState QSPAutState QProp

                Least saturated relation containing a base P-automaton relation.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem DPDA.base_subset_epsilonSaturationRel {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {base : PAutState QSPAutState QProp} {p : PAutState Q} {Z : S} {r : PAutState Q} :
                  base p Z rM.epsilonSaturationRel base p Z r
                  theorem DPDA.epsilonSaturationRel_saturated {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (base : PAutState QSPAutState QProp) :
                  def DPDA.stopTargetBase {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
                  PAutState QSPAutState QProp

                  Base target relation for stopping epsilon phases. A control state with no epsilon transition on the current top symbol is a target; the sink consumes the unexamined suffix.

                  Equations
                  Instances For

                    Empty stack is stable for every control state; after detecting a stable top, the sink accepts the remaining suffix.

                    Equations
                    Instances For
                      def DPDA.stopSaturationRel {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
                      PAutState QSPAutState QProp

                      Saturated relation recognizing stacks from which the forced epsilon phase reaches a stable configuration.

                      Equations
                      Instances For
                        def DPDA.finalTargetBase {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
                        PAutState QSPAutState QProp

                        Base target relation for epsilon reachability to a final state.

                        Equations
                        Instances For
                          def DPDA.finalTargetAccept {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :

                          Accepting P-automaton states for final-state epsilon reachability.

                          Equations
                          Instances For
                            def DPDA.finalSaturationRel {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
                            PAutState QSPAutState QProp

                            Saturated relation recognizing stacks from which epsilon reachability can hit an original final state.

                            Equations
                            Instances For
                              def DPDA.stopSaturationDFA {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) :
                              DFA S (Set (PAutState Q))

                              Candidate DFA for the stop-lookahead language at control state q.

                              Equations
                              Instances For
                                def DPDA.finalSaturationDFA {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) :
                                DFA S (Set (PAutState Q))

                                Candidate DFA for the epsilon-final-reachability language at control state q.

                                Equations
                                Instances For
                                  theorem DPDA.stopSaturationDFA_accepts_iff {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) (γ : List S) :
                                  def DPDA.RelationPreservesTarget {Q S : Type} (R : PAutState QSPAutState QProp) (Target : PAutState QList SProp) :

                                  A relation preserves a target stack language if one transition consumes one stack symbol while preserving target membership for every suffix.

                                  Equations
                                  Instances For
                                    theorem DPDA.RelPath.preservesTarget {Q S : Type} {R : PAutState QSPAutState QProp} {Target : PAutState QList SProp} (hR : RelationPreservesTarget R Target) {p r : PAutState Q} {γ δ : List S} (hpath : RelPath R p γ r) (htarget : Target r δ) :
                                    Target p (γ ++ δ)
                                    def DPDA.stopTarget {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
                                    PAutState QList SProp

                                    Semantic target for stopping: controls represent genuine DPDA configurations; the sink means the target has already been reached and the rest of the stack is ignored.

                                    Equations
                                    Instances For
                                      theorem DPDA.stopTarget_nil {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (r : PAutState Q) :
                                      theorem DPDA.stopSaturationRel_path_sound {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p r : PAutState Q} {γ δ : List S} (hpath : RelPath M.stopSaturationRel p γ r) (htarget : M.stopTarget r δ) :
                                      M.stopTarget p (γ ++ δ)
                                      theorem DPDA.stopSaturationDFA_sound {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) (γ : List S) :
                                      γ (M.stopSaturationDFA q).accepts∃ (cstable : EpsilonConf Q S), M.EpsilonStopsAt (q, γ) cstable
                                      theorem DPDA.stopSaturationRel_path_of_stable {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {q : Q} {γ : List S} (hstable : M.EpsilonStable (q, γ)) :
                                      theorem DPDA.stopSaturationRel_path_of_epsilonStopsAt {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {q : Q} {γ : List S} {cstable : EpsilonConf Q S} (hstops : M.EpsilonStopsAt (q, γ) cstable) :
                                      theorem DPDA.stopSaturationDFA_complete {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) (γ : List S) :
                                      (∃ (cstable : EpsilonConf Q S), M.EpsilonStopsAt (q, γ) cstable)γ (M.stopSaturationDFA q).accepts
                                      theorem DPDA.stopSaturationDFA_correct {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) (γ : List S) :
                                      γ (M.stopSaturationDFA q).accepts ∃ (cstable : EpsilonConf Q S), M.EpsilonStopsAt (q, γ) cstable
                                      def DPDA.finalTarget {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) :
                                      PAutState QList SProp

                                      Semantic target for final-state epsilon reachability.

                                      Equations
                                      Instances For
                                        theorem DPDA.finalTarget_nil_iff {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (r : PAutState Q) :
                                        theorem DPDA.finalSaturationRel_path_sound {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {p r : PAutState Q} {γ δ : List S} (hpath : RelPath M.finalSaturationRel p γ r) (htarget : M.finalTarget r δ) :
                                        M.finalTarget p (γ ++ δ)
                                        theorem DPDA.finalSaturationDFA_sound {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) (γ : List S) :
                                        γ (M.finalSaturationDFA q).accepts∃ (qf : Q) (γf : List S), M.EpsilonReaches (q, γ) (qf, γf) qf M.final_states
                                        theorem DPDA.finalSaturationRel_path_of_final {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {q : Q} {γ : List S} (hfinal : q M.final_states) :
                                        theorem DPDA.finalSaturationRel_path_of_epsilonReaches_final {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) {q qf : Q} {γ γf : List S} (hreach : M.EpsilonReaches (q, γ) (qf, γf)) (hfinal : qf M.final_states) :
                                        theorem DPDA.finalSaturationDFA_complete {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) (γ : List S) :
                                        (∃ (qf : Q) (γf : List S), M.EpsilonReaches (q, γ) (qf, γf) qf M.final_states)γ (M.finalSaturationDFA q).accepts
                                        theorem DPDA.finalSaturationDFA_correct {Q S T : Type} [Fintype Q] [Fintype T] [Fintype S] (M : DPDA Q T S) (q : Q) (γ : List S) :
                                        γ (M.finalSaturationDFA q).accepts ∃ (qf : Q) (γf : List S), M.EpsilonReaches (q, γ) (qf, γf) qf M.final_states