Deterministic Pushdown Automata (DPDA): Definition and an Example

Deterministic Pushdown Automata (DPDA): Definition and an Example

Verified Sources
Sep 13, 2026

A deterministic pushdown automaton (DPDA) is a pushdown automaton where the computation is deterministic: for any configuration, there is at most one applicable transition. Like all pushdown automata, a DPDA has a finite control plus a stack (unbounded memory) that it can push to and pop from while reading the input.

Formally, many textbooks define a (possibly nondeterministic) pushdown automaton as a 7-tuple, typically of the form (Q,Σ,Γ,δ,q0,Z0,F)(Q, \Sigma, \Gamma, \delta, q_0, Z_0, F), and a DPDA is one where the transition relation δ\delta is restricted so that it behaves like a partial function (not a relation).

Key idea: DPDA determinism couples (i) the current state, (ii) the next input symbol (or an ε\varepsilon-move), and (iii) the current top-of-stack symbol into a unique next move. This prevents the machine from “guessing” how to continue.

Mermaid sketch of the DPDA components:

Footnotes

  1. Deterministic pushdown automaton / pushdown automaton formalism - Overview and formal definitions of PDAs and determinism ideas.

Pushdown Automata (PDA) and Deterministic PDA Overview

Formal definition (typical DPDA template)

A common formalization uses a transition function
δ:Q×(Σ{ε})×ΓQ×Γ\delta: Q \times (\Sigma \cup \{\varepsilon\}) \times \Gamma \to Q \times \Gamma^{*}
for a DPDA, meaning the machine reads either a real input symbol or takes an ε\varepsilon-transition, and in either case it updates the stack by replacing the top symbol with a (possibly longer) string. This captures the “partial function” nature of determinism.

Determinism is sometimes stated as a restriction on a nondeterministic transition relation (e.g., “for any (q,a,X)(q,a,X) there is at most one possible (q,γ)(q',\gamma)”). The operational intuition is the same: from any configuration, the next configuration is uniquely determined.

Important concepts (terms used below):

  • Pushdown automaton
  • Stack configuration
  • Transition function
  • Epsilon transition

Footnotes

  1. Pushdown automaton: transition function and 0˘3b5\u03b5-moves - Details on transitions and the role of 0˘3b5\u03b5-moves in PDA definitions.

  2. Deterministic pushdown automaton / pushdown automaton formalism - Overview and formal definitions of PDAs and determinism ideas.

Determinism check (quick test)

To show a PDA is deterministic, verify that for any state qq, input symbol aΣ{ε}a\in\Sigma\cup\{\varepsilon\}, and top stack symbol XΓX\in\Gamma, there is at most one transition defined. Also watch for interactions between 0˘3b5\u03b5-moves and consuming moves on the same top symbol.

Language-recognition power (high-level context)

DPDAs are still more powerful than DFAs/NPAs because stacks add memory. In particular, deterministic and nondeterministic pushdown automata do not recognize exactly the same family of languages—there exist context-free languages not recognizable by any DPDA. This is typically discussed in the theory of context-free languages and DPDA vs. NPDA comparisons.

(For the purpose of this section, we focus on defining DPDA deterministically and constructing one for a standard example.)

Footnotes

  1. Context-free languages and pushdown automata; relation to deterministic PDAs - Context-free languages and their correspondence with PDA capabilities.

An example DPDA: recognizing L=\{a^n b^n : n\\ge 0\\}

Let L=anbn:nge0L = \\{a^n b^n : n\\ge 0\\} be the set of strings with equal numbers of aa’s followed by bb’s. The classic DPDA idea is:

  1. While reading aa’s, push one stack symbol per aa.
  2. When the input switches to bb’s, pop one stack symbol per bb.
  3. Accept when the input is fully consumed and the stack is back to its bottom marker.

This yields determinism because at any point the next move is forced by:

  • whether the next input symbol is aa, bb, or end-of-input, and
  • what symbol is currently on top of the stack.

DPDA design

We choose:

  • Input alphabet: Σ=a,b\Sigma = \\{a,b\\}
  • Stack alphabet: Γ=Z0,A\Gamma = \\{Z_0, A\\} where Z0Z_0 is bottom-of-stack marker and AA counts aa’s.
  • States: Q=qstart,qpop,qaccQ = \\{q_{start}, q_{pop}, q_{acc}\\}
  • Start state: qstartq_{start}
  • Initial stack symbol: Z0Z_0
  • Accepting state(s): F=qaccF = \\{q_{acc}\\}

A transition set (function-style) is described as follows (using the “replace top symbol with a string” convention for stack updates). This is a standard DPDA construction pattern for anbna^n b^n.

Transition behavior (informal)

  • In state qstartq_{start}:
    • On input aa with top Z0Z_0 or AA, push another AA.
    • On input bb with top AA, pop one AA and move to qpopq_{pop}.
    • If input is empty and top is Z0Z_0, accept (this corresponds to n=0n=0).
  • In state qpopq_{pop}:
    • On input bb with top AA, pop one AA.
    • When input is empty and top is Z0Z_0, accept.
    • Any attempt to read an aa after starting to pop is rejected (no transition).

Key DPDA determinism intuition

At any configuration:

  • If you see an aa while still in the “push” phase, the only possible action is “push AA”.
  • If you see a bb in the “push” phase and top is AA, the only possible action is “pop AA and switch phase”.
  • If you see a bb in the “pop” phase and top is AA, you must keep popping.
  • If you see the wrong symbol for the phase (e.g., an aa while popping), there is no valid transition.

Footnotes

  1. Deterministic pushdown automaton / pushdown automaton formalism - Overview and formal definitions of PDAs and determinism ideas.

Walking through the DPDA on input $aabb$

  1. 1
    Step 1

    Initial configuration: state qstartq_{start}, input aabbaabb, stack Z0Z_0.

  2. 2
    Step 2

    Top is Z0Z_0, read aa, so push AA. Stack becomes AZ0A Z_0 and input becomes abbabb.

  3. 3
    Step 3

    Top is AA, read aa, so push AA. Stack becomes AAZ0A A Z_0 and input becomes bbbb.

  4. 4
    Step 4

    In qstartq_{start}, on bb with top AA, pop one AA and go to qpopq_{pop}. Stack becomes AZ0A Z_0, input becomes bb.

  5. 5
    Step 5

    In qpopq_{pop}, on bb with top AA, pop one AA. Stack becomes Z0Z_0, input becomes empty.

  6. 6
    Step 6

    Input is consumed and top is Z0Z_0, so move to qaccq_{acc} (accept).

Execution trace table (compact)

StepInput remainingStateTop stack symbolAction
0aabbaabbqstartq_{start}Z0Z_0push AA
1abbabbqstartq_{start}AApush AA
2bbbbqstartq_{start}AApop AA, switch to qpopq_{pop}
3bbqpopq_{pop}AApop AA
4ε\varepsilonqpopq_{pop}Z0Z_0accept

Common confusion: DPDA determinism vs. language ambiguity

A DPDA is deterministic operationally (unique move per configuration). But that is different from having a unique decomposition of the input into anbna^n b^n—the machine still must avoid nondeterministic choices in transitions.

Deterministic Pushdown Automata: FAQs

Conceptual lifecycle for defining and using a DPDA

Machine specification

1) Define formal components

Choose Q,Σ,Γ,q0,Z0,FQ, \Sigma, \Gamma, q_0, Z_0, F and define 0˘3b4\u03b4."

Make $\u03b4$ functional

2) Enforce determinism

Ensure at most one transition applies for any (q,a,X)(q,a,X)."

Encode the language structure

3) Design stack discipline

Decide what to push/pop to match the target pattern."

Check behavior step-by-step

4) Validate with an example trace

Run the DPDA on a representative string like aabbaabb."

Deterministic transition logic: what determines the next move?

In a DPDA, the next action is determined by these factors.

DPDA Quick Self-Test Deck

1 / 4
Question · Term

Deterministic pushdown automaton (DPDA)

Click to reveal
Answer · Definition

A PDA where transitions are uniquely determined by current state, next input symbol (aa or 0˘3b5\u03b5), and top stack symbol.

Knowledge Check

Question 1 of 4
Q1Single choice

Which condition is most directly responsible for a PDA being deterministic (DPDA)?