You are on page 1of 24

Fall 2003 Costas Busch - RPI 1

DPDA

Deterministic PDA

Fall 2003 Costas Busch - RPI 2
Deterministic PDA: DPDA
q
1
q
2
w b a ,
1
q
2
q
w b ,
Allowed transitions:
(deterministic choices)
Fall 2003 Costas Busch - RPI 3
Allowed transitions:
q
1
q
2
1
, w b
q
3
2
, w c
q
1
q
2
1
, w b a
q
3
2
, w c a
(deterministic choices)
Fall 2003 Costas Busch - RPI 4
q
1
q
2
1
, w b a
q
3
2
, w b a
Not allowed:
(non deterministic choices)
q
1
q
2
1
, w b
q
3
2
, w b a
Fall 2003 Costas Busch - RPI 5
DPDA example
a, a
b, a
q
0
q
1
q
2
q
3
b, a
, $ $
} 0 : { ) ( > = n b a M L
n n
a, a
Fall 2003 Costas Busch - RPI 6
} 0 : { ) ( > = n b a M L
n n
The language
is deterministic context-free
Definition:
A language is deterministic context-free
if there exists some DPDA that accepts it
L
Example:
Fall 2003 Costas Busch - RPI 7
Example of Non-DPDA (PDA)
, $ $
q
1
q
2
b b
a a

,
,
,
q
0

b b
a a
,
,
} } , { : { ) (
*
b a v vv M L
R
e =
Fall 2003 Costas Busch - RPI 8
, $ $
q
1
q
2
b b
a a

,
,
,
q
0

b b
a a
,
,
Not allowed in DPDAs
Fall 2003 Costas Busch - RPI 9
PDAs

Have More Power than

DPDAs

Fall 2003 Costas Busch - RPI 10
Deterministic
Context-Free
Languages
(DPDA)
Context-Free
Languages
PDAs
_
Since every DPDA is also a PDA
It holds that:
Fall 2003 Costas Busch - RPI 11
c
We will actually show:
We will show that there exists
a context-free language which is not
accepted by any DPDA
L
e L
e L
Deterministic
Context-Free
Languages
(DPDA)
Context-Free
Languages
(PDA)
Fall 2003 Costas Busch - RPI 12
The language is:
} { } {
2n n n n
b a b a L =
0 > n
We will show:
L
is context-free
L
is not deterministic context-free
Fall 2003 Costas Busch - RPI 13
} { } {
2n n n n
b a b a L =
Language is context-free L
Context-free grammar for : L
2 1
| S S S
|
1 1
b aS S
|
2 2
bb aS S
} {
n n
b a
} {
2n n
b a
} { } {
2n n n n
b a b a
Fall 2003 Costas Busch - RPI 14
} { } {
2n n n n
b a b a L =
is not deterministic context-free
Theorem:
The language
(there is no DPDA that accepts ) L
Fall 2003 Costas Busch - RPI 15
Proof:
Assume for contradiction that
} { } {
2n n n n
b a b a L =
is deterministic context free
Therefore:
there is a DPDA that accepts M L
Fall 2003 Costas Busch - RPI 16
DPDA with M
n n
b a
n
b
accepts
n n
b a
2
accepts
n n
b a
} { } { ) (
2n n n n
b a b a M L =
Fall 2003 Costas Busch - RPI 17
DPDA with M
n n
b a
n
b
} { } { ) (
2n n n n
b a b a M L =
Such a path exists due to determinism
M
Fall 2003 Costas Busch - RPI 18
The language
is not context-free
} {
n n n
c b a
(we will prove this at a later class using
pumping lemma for context-free languages)
Fact 1:
Regular languages
* *b a
Context-free languages
n n
b a
Fall 2003 Costas Busch - RPI 19
The language
is not context-free
} {
n n n
c b a L
}) { } { (
2n n n n
b a b a L =
Fact 2:
(we can prove this using pumping lemma
for context-free languages)
Fall 2003 Costas Busch - RPI 20
We will construct a PDA that accepts:
} {
n n n
c b a L
}) { } { (
2n n n n
b a b a L =
which is a contradiction!
Fall 2003 Costas Busch - RPI 21
Modify M
M
'
n
c
n n
c a
} { } { ) (
2n n n n
b a b a M L =
} { } { ) (
2n n n n
c a c a M L =
'
Replace
with
b
c
n n
b a
n
b
M DPDA
DPDA
Fall 2003 Costas Busch - RPI 22
A PDA that accepts
} {
n n n
c b a L
n n
b a
n
b
n
c
M
'
M
n n
c a

Connect the final states of
with the final states of M
'
M
Fall 2003 Costas Busch - RPI 23
Since is accepted by a PDA } {
n n n
c b a L
it is context-free
Contradiction!
(since is not context-free) } {
n n n
c b a L
Fall 2003 Costas Busch - RPI 24
Therefore:
} { } {
2n n n n
b a b a L =
There is no DPDA that accepts it
End of Proof
Is not deterministic context free

You might also like