Documentation

CslibFrontier.Computability.Automata.DPDA.Basic

Deterministic pushdown automata #

A deterministic pushdown automaton has a finite control and a stack. A move replaces the top stack symbol by a list of symbols and either reads one input symbol or takes an epsilon transition. An enabled epsilon transition excludes every input transition for the same control state and stack top. Acceptance requires a finite run that consumes the input and reaches a final state. In the model of Hopcroft et al., Sections 6.2 and 6.4, the transition table associates at most one result to each state, stack top and input label. The two cases of Option represent no result or one result, and the epsilon_exclusive field enforces the condition across different labels. The machine type leaves the alphabets and control type generic. The DCFL predicate imposes finiteness.

Main definitions #

Main results #

structure Cslib.Automata.DPDA.Move (State : Type u_1) (Γ : Type u_2) :
Type (max u_1 u_2)

The result of a pushdown transition.

  • state : State

    The destination control state.

  • replacement : List Γ

    The word replacing the stack top, with its new top first.

structure Cslib.Automata.DPDA (State : Type u_1) (Symbol : Type u_2) (Γ : Type u_3) :
Type (max (max u_1 u_2) u_3)

A deterministic pushdown automaton with control states State, input symbols Symbol and stack symbols Γ. The first symbol in a replacement list becomes the new stack top.

  • start : State

    Initial control state.

  • bottom : Γ

    Initial stack symbol.

  • accept : Set State

    Accepting control states.

  • transition : State → Γ → Option Symbol → Option (Move State Γ)

    A partial transition on a state, stack top and optional input symbol.

  • epsilon_exclusive (q : State) (γ : Γ) (a : Symbol) : (self.transition q γ none).isSome = true → self.transition q γ (some a) = none

    When an epsilon transition is available, no input transition is available.

Instances For
    structure Cslib.Automata.DPDA.Config (State : Type u_4) (Symbol : Type u_5) (Γ : Type u_6) :
    Type (max (max u_4 u_5) u_6)

    The control state, unread input and stack contents. The stack top is the head of the list.

    • state : State

      The current control state.

    • input : List Symbol

      Input symbols still to be read.

    • stack : List Γ

      Stack contents, top first.

    def Cslib.Automata.DPDA.initial {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} (M : DPDA State Symbol Γ) (word : List Symbol) :
    Config State Symbol Γ

    The configuration before reading any input.

    def Cslib.Automata.DPDA.step? {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} (M : DPDA State Symbol Γ) (c : Config State Symbol Γ) :
    Option (Config State Symbol Γ)

    Compute the unique enabled move. An empty stack admits no move.

    def Cslib.Automata.DPDA.Step {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} (M : DPDA State Symbol Γ) (c d : Config State Symbol Γ) :

    The one-step transition relation on configurations.

    theorem Cslib.Automata.DPDA.step_of_epsilon {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : DPDA State Symbol Γ} {q : State} {γ : Γ} {move : Move State Γ} {input : List Symbol} {tail : List Γ} (h : M.transition q γ none = some move) :
    M.Step { state := q, input := input, stack := γ :: tail } { state := move.state, input := input, stack := move.replacement ++ tail }

    An epsilon transition updates the control and stack while preserving all unread input.

    theorem Cslib.Automata.DPDA.step_of_symbol {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : DPDA State Symbol Γ} {q : State} {γ : Γ} {move : Move State Γ} {a : Symbol} {input : List Symbol} {tail : List Γ} (h : M.transition q γ (some a) = some move) :
    M.Step { state := q, input := a :: input, stack := γ :: tail } { state := move.state, input := input, stack := move.replacement ++ tail }

    An input transition reads the next symbol and updates the control and stack.

    theorem Cslib.Automata.DPDA.step_deterministic {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : DPDA State Symbol Γ} {c d e : Config State Symbol Γ} (hd : M.Step c d) (he : M.Step c e) :
    d = e

    Any two steps starting at the same configuration have the same target.

    @[instance_reducible]
    instance Cslib.Automata.DPDA.instAcceptor {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} :
    Acceptor (DPDA State Symbol Γ) Symbol
    theorem Cslib.Automata.DPDA.accepts_iff {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} (M : DPDA State Symbol Γ) (word : List Symbol) :
    Acceptor.Accepts M word ↔ ∃ q ∈ M.accept, ∃ (stack : List Γ), Relation.ReflTransGen M.Step (M.initial word) { state := q, input := [], stack := stack }

    A word is accepted when a finite run reads it completely and reaches an accepting state.