DPDA Deterministic PDA

24
Fall 2003 Costas Busch - RPI 1 DPDA Deterministic PDA

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

Page 1: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 1

DPDA

Deterministic PDA

Page 2: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 2

Deterministic PDA: DPDA

q1 q2wba ,

1q 2qwb,

Allowed transitions:

(deterministic choices)

Page 3: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 3

Allowed transitions:

q1

q21, wb

q32, wc

q1

q21, wba

q32, wca

(deterministic choices)

Page 4: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 4

q1

q21, wba

q32, wba

Not allowed:

(non deterministic choices)

q1

q21, wb

q32, wba

Page 5: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 5

DPDA example

a, a

b, a q0 q1 q2 q3

b, a

, $ $

}0:{)( nbaML nn

a, a

Page 6: DPDA Deterministic PDA

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:

Page 7: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 7

Example of Non-DPDA (PDA)

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

}},{:{)( *bavvvML R

Page 8: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 8

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

Not allowed in DPDAs

Page 9: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 9

PDAs

Have More Power than

DPDAs

Page 10: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 10

Deterministic

Context-FreeLanguages

(DPDA)

Context-Free

LanguagesPDAs

Since every DPDA is also a PDA

It holds that:

Page 11: DPDA Deterministic PDA

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)

Page 12: DPDA Deterministic 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

Page 13: DPDA Deterministic PDA

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

Page 14: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 14

}{}{ 2nnnn babaL

is not deterministic context-free

Theorem:

The language

(there is no DPDA that accepts ) L

Page 15: DPDA Deterministic PDA

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

Page 16: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 16

DPDA with M

nnba nb

acceptsnnba 2

acceptsnnba

}{}{)( 2nnnn babaML

Page 17: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 17

DPDA with M

nnba nb

}{}{)( 2nnnn babaML

Such a path exists due to determinism

M

Page 18: DPDA Deterministic PDA

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

Page 19: DPDA Deterministic PDA

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)

Page 20: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 20

We will construct a PDA that accepts:

}{ nnn cbaL

}){}{( 2nnnn babaL

which is a contradiction!

Page 21: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 21

Modify M

M ncnnca

}{}{)( 2nnnn babaML

}{}{)( 2nnnn cacaML

Replacewith

bc

nnba nb

MDPDA

DPDA

Page 22: DPDA Deterministic PDA

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

Page 23: DPDA Deterministic PDA

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

Page 24: DPDA Deterministic PDA

Fall 2003 Costas Busch - RPI 24

Therefore:

}{}{ 2nnnn babaL

There is no DPDA that accepts it

End of Proof

Is not deterministic context free