# Languages and Finite Automata

Document Sample

```					                 DPDA

Deterministic PDA

Fall 2003        Costas Busch - RPI   1
Deterministic PDA: DPDA
Allowed transitions:

a, b  w
q1                        q2

, b  w
q1                        q2

(deterministic choices)
Fall 2003              Costas Busch - RPI        2
Allowed transitions:

a, b  w1    q2                         , b  w1   q2

q1                                          q1

a , c  w2   q3                         , c  w2   q3

(deterministic choices)
Fall 2003                     Costas Busch - RPI                     3
Not allowed:

a, b  w1    q2                         , b  w1   q2

q1                                       q1

a , b  w2   q3                        a , b  w2   q3

(non deterministic choices)
Fall 2003               Costas Busch - RPI                     4
DPDA example

L( M )  {a b : n  0}
n n

a,   a                   b, a  

q0 a,   a q b, a   q , \$  \$ q
1          2          3

Fall 2003          Costas Busch - RPI              5
Definition:
A language L is deterministic context-free
if there exists some DPDA that accepts it

Example:
The language     L( M )  {a b : n  0}n n

is deterministic context-free

Fall 2003                 Costas Busch - RPI         6
Example of Non-DPDA (PDA)

L( M )  {vv : v {a, b} }
R                 *

a,   a                a, a  
b,   b                 b, b  

q0   ,                q1      , \$  \$   q2

Fall 2003                Costas Busch - RPI                   7
Not allowed in DPDAs

a,   a               a, a  
b,   b                b, b  

q0   ,               q1      , \$  \$   q2

Fall 2003               Costas Busch - RPI                   8
PDAs

Have More Power than

DPDAs

Fall 2003          Costas Busch - RPI   9
It holds that:

Deterministic
Context-Free
Languages
               Context-Free
Languages
PDAs
(DPDA)

Since every DPDA is also a PDA

Fall 2003                   Costas Busch - RPI                  10
We will actually show:

Deterministic


Context-Free
Context-Free
Languages
Languages
(PDA)
(DPDA)
L                                   L

We will show that there exists
a context-free language L which is not
accepted by any DPDA
Fall 2003                   Costas Busch - RPI                  11
The language is:

L  {a b }  {a b }
n n        n 2n
n0

We will show:

• L is context-free

• L is not deterministic context-free

Fall 2003                Costas Busch - RPI         12
L  {a b }  {a b }
n n                   n 2n

Language        L is context-free

Context-free grammar for                        L:
S  S1 | S2                     {a nbn }  {a nb2n }

S1  aS1b | 
n n
{a b }

S2  aS2bb |                       n 2n
{a b }
Fall 2003                  Costas Busch - RPI                      13
Theorem:

The language     L  {a b }  {a b }
n n   n 2n

is not deterministic context-free

(there is no DPDA that accepts          L)

Fall 2003               Costas Busch - RPI                14
Proof: Assume for contradiction that

L  {a b }  {a b }
n n                n 2n

is deterministic context free

Therefore:

there is a DPDA      M that accepts L

Fall 2003                Costas Busch - RPI          15
DPDA        M with L( M )  {a b }  {a b }   n n     n 2n

n n
accepts       a b

n n                              n
a b                           b

n 2n
accepts             a b
Fall 2003                Costas Busch - RPI                  16
DPDA        M with L( M )  {a b }  {a b } n n     n 2n

Such a path exists due to determinism

M
n n                            n
a b                         b

Fall 2003              Costas Busch - RPI                  17
Fact 1:        The language {a b
n n n
c }
is not context-free

Context-free languages
a nb n

Regular languages
a *b *

(we will prove this at a later class using
pumping lemma for context-free languages)
Fall 2003               Costas Busch - RPI            18
Fact 2:        The language L  {a
n n n
b c }
is not context-free

( L  {a b }  {a b })
n n              n 2n

(we can prove this using pumping lemma
for context-free languages)
Fall 2003                 Costas Busch - RPI           19
We will construct a PDA that accepts:

L  {a b c }n n n

( L  {a b }  {a b })
n n                   n 2n

which is a contradiction!

Fall 2003            Costas Busch - RPI          20
DPDA        M             L( M )  {a b }  {a b }
n n   n 2n

a nb n                     bn

Modify      M         Replace           b
with c

DPDA        M            L( M )  {a nc n }  {a nc 2n }
a nc n                     cn

Fall 2003                   Costas Busch - RPI               21
A PDA that accepts            L  {a b c }     n n n

Connect the final states of M
with the final states of M 
M
n n                             n
a b                          b

                   
M
a nc n                        cn

Fall 2003                 Costas Busch - RPI               22
Since         L  {a b c } is accepted by a PDA
n n n

it is context-free

Contradiction!

(since        L  {a b c } is not context-free)
n n n

Fall 2003                 Costas Busch - RPI       23
Therefore:

L  {a b }  {a b }
n n                   n 2n

Is not deterministic context free

There is no DPDA that accepts it

End of Proof
Fall 2003               Costas Busch - RPI          24

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 11 posted: 9/17/2012 language: English pages: 24
How are you planning on using Docstoc?