DPDA Deterministic PDA

Post on 19-Jan-2016

52 views 0 download

Tags:

description

DPDA Deterministic PDA. Deterministic PDA: DPDA. Allowed transitions:. (deterministic choices). Allowed transitions:. (deterministic choices). Not allowed:. (non deterministic choices). DPDA example. Definition:. A language is deterministic context-free - PowerPoint PPT Presentation

Transcript of DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 1

DPDA

Deterministic PDA

Fall 2003 Costas Busch - RPI 2

Deterministic PDA: DPDA

q1 q2wba ,

1q 2qwb,

Allowed transitions:

(deterministic choices)

Fall 2003 Costas Busch - RPI 3

Allowed transitions:

q1

q21, wb

q32, wc

q1

q21, wba

q32, wca

(deterministic choices)

Fall 2003 Costas Busch - RPI 4

q1

q21, wba

q32, wba

Not allowed:

(non deterministic choices)

q1

q21, wb

q32, wba

Fall 2003 Costas Busch - RPI 5

DPDA example

a, a

b, a q0 q1 q2 q3

b, a

, $ $

}0:{)( nbaML nn

a, a

Fall 2003 Costas Busch - RPI 6

}0:{)( nbaML nnThe language

is deterministic context-free

Definition:

A language is deterministic context-freeif there exists some DPDA that accepts it

L

Example:

Fall 2003 Costas Busch - RPI 7

Example of Non-DPDA (PDA)

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

}},{:{)( *bavvvML R

Fall 2003 Costas Busch - RPI 8

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

Not allowed in DPDAs

Fall 2003 Costas Busch - RPI 9

PDAs

Have More Power than

DPDAs

Fall 2003 Costas Busch - RPI 10

Deterministic

Context-FreeLanguages

(DPDA)

Context-Free

LanguagesPDAs

Since every DPDA is also a PDA

It holds that:

Fall 2003 Costas Busch - RPI 11

We will actually show:

We will show that there existsa context-free language which is notaccepted by any DPDA

L

LL

Deterministic

Context-FreeLanguages

(DPDA)

Context-Free

Languages(PDA)

Fall 2003 Costas Busch - RPI 12

The language is:

}{}{ 2nnnn babaL 0n

We will show:

L• is context-free

L• is not deterministic context-free

Fall 2003 Costas Busch - RPI 13

}{}{ 2nnnn babaL

Language is context-freeL

Context-free grammar for : L

21 | SSS

|11 baSS

|22 bbaSS

}{ nnba

}{ 2nnba

}{}{ 2nnnn baba

Fall 2003 Costas Busch - RPI 14

}{}{ 2nnnn babaL

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

}{}{ 2nnnn babaL

is deterministic context free

Therefore:

there is a DPDA that accepts M L

Fall 2003 Costas Busch - RPI 16

DPDA with M

nnba nb

acceptsnnba 2

acceptsnnba

}{}{)( 2nnnn babaML

Fall 2003 Costas Busch - RPI 17

DPDA with M

nnba nb

}{}{)( 2nnnn babaML

Such a path exists due to determinism

M

Fall 2003 Costas Busch - RPI 18

The language is not context-free

}{ nnn cba

(we will prove this at a later class usingpumping lemma for context-free languages)

Fact 1:

Regular languages**ba

Context-free languagesnnba

Fall 2003 Costas Busch - RPI 19

The language is not context-free

}{ nnn cbaL

}){}{( 2nnnn babaL

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:

}{ nnn cbaL

}){}{( 2nnnn babaL

which is a contradiction!

Fall 2003 Costas Busch - RPI 21

Modify M

M ncnnca

}{}{)( 2nnnn babaML

}{}{)( 2nnnn cacaML

Replacewith

bc

nnba nb

MDPDA

DPDA

Fall 2003 Costas Busch - RPI 22

A PDA that accepts }{ nnn cbaL

nnba nb

nc

M

M

nnca

Connect the final states of with the final states of M

M

Fall 2003 Costas Busch - RPI 23

Since is accepted by a PDA }{ nnn cbaL

it is context-free

Contradiction!

(since is not context-free)}{ nnn cbaL

Fall 2003 Costas Busch - RPI 24

Therefore:

}{}{ 2nnnn babaL

There is no DPDA that accepts it

End of Proof

Is not deterministic context free