# Deterministic Push Down Automata Lecture 15 COT 4420 ```Lecture 15
Deterministic Push Down
Automata
COT 4420
Theory of Computation
Section 7.3
DPDA
• A deterministic pushdown accepter (DPDA) is
a pushdown automaton that never has a
choice in its move.
• Two restrictions on transitions:
1. δ(q, a, b) contains at most one element
2. If δ(q, λ, b) is not empty, then δ(q, c, b) must
be empty for every c ∈ Σ.
Nondeterministic choices
a, b  x
a, b  y
Not allowed
Nondeterministic choices
λ, b  x
a, b  y
Not allowed
Deterministic context-free language
• A language L is said to be a deterministic
context-free language if and only if there
exists a dpda M such that L = L(M).
Deterministic context-free language
• The language L = { anbn : n ≥ 0 } is a
deterministic context-free language.
• Because there exists a dpda that accepts L:
a, λ  x
λ, λ  λ
b, x  λ
b, x  λ
λ, z  z
Example
L = { wwR : w ∈ {a,b}* }
a, a  aa
a, b  ab
a, z  az
b, a  ba
b, b  bb
b, z  bz
a, a  λ
b, b  λ
λ, a  a
λ, b  b
λ, z  z
Example
L = { wwR : w ∈ {a,b}* }
a, a  aa
a, b  ab
a, z  az
b, a  ba
b, b  bb
b, z  bz
Not allowed in DPDA
a, a  λ
b, b  λ
λ, a  a
λ, b  b
λ, z  z
Non-Deterministic language
• Having an NPDA for a language does not
necessarily mean that the language itself is
nondeterministic, since there is the possibility
of an equivalent DPDA.
• However, it is known that the language {wwR}
is not deterministic.
NPDA vs DPDA ?
Deterministic and nondeterministic push down
automata are not equivalent
Deterministic
context-free
languages (DPDA)
⊆
Context-free
languages (NPDA)
• Every DPDA is also an NPDA
We need to show that:
• There exists a context-free language L that is
not accepted by any DPDA
Context-free but not Deterministic CF
L = { anbn : n ≥ 0 } ∪ { anb2n : n ≥ 0 }
L is context-free, but not deterministic contextfree.
L is context-free
S  S 1 | S2
S1  aS1b | λ
S2  aS2bb | λ
Context-free grammar
Therefore, L is a context-free language.
Theorem
• Theorem: The language L = { anbn : n ≥ 0 } ∪ {
anb2n : n ≥ 0 } is not deterministic context-free.
(There is no DPDA that accepts L)
We know that {anbncn} is not context-free.
Also, L ∪ {anbncn} is not context-free
• We will prove these later using pumping
lemma for context-free languages.
Proof
Assume by contradiction that L is deterministic
context-free, therefore there is a dpda M that
accepts L.
Such path exists due to determinism
M
n n
a b
b
n
Proof
Using this DPDA M, we construct an NPDA that
accepts L ∪ {anbncn}, which is a contradiction!
L( M ) = {a nb n } ∪ {a nb 2n }
DPDA M
n n
a b
b
n
Replace b
with c
L( M ′) = {a nc n } ∪ {a nc 2n }
DPDA M’
n n
a c
c
n
NPDA that accepts L ∪ {anbncn}
Connect the final states of M
with the final states of M’
M
n n
a b
b
n
λ
M′
a nc n
λ
cn
Proof – Cont’d
Since L ∪ {anbncn} is accepted by an NPDA, it is a
context-free language.
However, this language is not context-free.