In automata theory, a deterministic pushdown automaton (DPDA or DPA) is a variation of the pushdown automaton. The class of deterministic pushdown automata accepts the deterministic context-free languages, a proper subset of context-free languages.[1]
Machine transitions are based on the current state and input symbol, and also the current topmost symbol of the stack. Symbols lower in the stack are not visible and have no immediate effect. Machine actions include pushing, popping, or replacing the stack top. A deterministic pushdown automaton has at most one legal transition for the same combination of input symbol, state, and top stack symbol. This is where it differs from the nondeterministic pushdown automaton.
A (not necessarily deterministic) PDA
M
M=(Q,\Sigma,\Gamma,q0,Z0,A,\delta)
where
Q
\Sigma
\Gamma
q0\inQ
Z0\in\Gamma
A\subseteqQ
A
\delta
\delta\colon(Q x (\Sigma\cup\left\{\varepsilon\right\}) x \Gamma)\longrightarrowl{P}(Q x \Gamma*)
where
*
\Gamma*
\varepsilon
\Gamma
\varepsilon
l{P}(X)
X
M is deterministic if it satisfies both the following conditions:
q\inQ,a\in\Sigma\cup\left\{\varepsilon\right\},x\in\Gamma
\delta(q,a,x)
q\inQ,x\in\Gamma
\delta(q,\varepsilon,x)\not=\emptyset
\delta\left(q,a,x\right)=\emptyset
a\in\Sigma.
There are two possible acceptance criteria: acceptance by empty stack and acceptance by final state. The two are not equivalent for the deterministic pushdown automaton (although they are for the non-deterministic pushdown automaton). The languages accepted by empty stack are those languages that are accepted by final state and are prefix-free: no word in the language is the prefix of another word in the language.[2] [3]
The usual acceptance criterion is final state, and it is this acceptance criterion which is used to define the deterministic context-free languages.
If
L(A)
A
L(A)
L(A)
Not all context-free languages are deterministic. This makes the DPDA a strictly weaker device than the PDA. For example, the language Lp of even-length palindromes on the alphabet of 0 and 1 has the context-free grammar S → 0S0 | 1S1 | ε. If a DPDA for this language exists, and it sees a string 0n, it must use its stack to memorize the length n, in order to be able to distinguish its possible continuations and Hence, after reading comparing the post-"11" length to the pre-"11" length will make the stack empty again. For this reason, the strings and cannot be distinguished.[4]
Restricting the DPDA to a single state reduces the class of languages accepted to the LL(1) languages,[5] which is a proper subclass of the DCFL.[6] In the case of a PDA, this restriction has no effect on the class of languages accepted.
Closure properties of deterministic context-free languages (accepted by deterministic PDA by final state) are drastically different from the context-free languages. As an example they are (effectively) closed under complementation, but not closed under union. To prove that the complement of a language accepted by a deterministic PDA is also accepted by a deterministic PDA is tricky because one has to avoid infinite computations and correctly handle transitions that manipulate the stack without reading input symbols.
As a consequence of the complementation it is decidable whether a deterministic PDA accepts all words over its input alphabet, by testing its complement for emptiness. This is not possible for context-free grammars (hence not for general PDA).
Géraud Sénizergues (1997) proved that the equivalence problem for deterministic PDA (i.e. given two deterministic PDA A and B, is L(A)=L(B)?) is decidable,[7] [8] [9] a proof that earned him the 2002 Gödel Prize. For nondeterministic PDA, equivalence is undecidable.