/
cs3102: Theory of Computation cs3102: Theory of Computation

cs3102: Theory of Computation - PowerPoint Presentation

lois-ondreau
lois-ondreau . @lois-ondreau
Follow
390 views
Uploaded On 2016-06-17

cs3102: Theory of Computation - PPT Presentation

Class 6 Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF Read the TexPoint manual before you delete this box A A A A A A Menu Revisiting and Reversing the Pumping Lemma ID: 365774

regular player picks dpda player regular dpda picks stack dfa languages state transitions count wins model win language pop

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "cs3102: Theory of Computation" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

cs3102: Theory of ComputationClass 6: Pushdown Automata

Spring 2010University of VirginiaDavid Evans

TexPoint fonts used in EMF.

Read the TexPoint manual before you delete this box.:

A

A

A

A

A

ASlide2

MenuRevisiting and Reversing the Pumping LemmaRecognizing Non-Regular LanguagesPushdown AutomataSlide3

Revisiting the Pumping Lemma

q0

q

z

x

y

z

If input string is longer than

|

Q

|

, some state must repeat.

q

i

If

A

is a regular language, then there is some number p (the pumping length) where for any string sA and |s| p, s may be divided into three pieces, s = xyz, such that |y|> 0, |xy| p, and for any i  0, xyizA.Slide4

Pumping Game for Language A

1. Player 1: picks p

2. Player 2: picks s

A

and

|s|

p

3. Player 1:

picks x, y, z, |y|>

0, |xy|

 p,

s =

xyz4. Player 2: picks i  0Player 1 wins if

xyiz A, Player 2 wins if

xyizAIf Player 1 can always win: A is regularIf Player 2 can always win: A is not regularq0qz

x

yzqi

What if Player 2 picks an

s

A

?Slide5

Pump-Priming Game for Language

A1. Player 1:

picks p

2. Player 2:

picks

s

A

and

|s|

p3. Player 1: picks

x, y, z, |y|> 0, |xy

| p

, s = xyz4. Player 2: picks i

 0Player 1 wins if xyi

z  A, Player 2 wins if xyiz AIf Player 1 can always win: A is regularIf Player 2 can always win: A is not regularq0q

z

xyzqiSlide6

A = { w | w has more 0s

than 1s }

Pump-Priming Game for Language

A

1. Player 1:

picks

p

2. Player 2:

picks

s

A and |s|

 p

3. Player 1: picks x, y, z, |y|> 0, |

xy| p, s

= xyz4. Player 2: picks i

 0Player 1 wins if xyiz  A, Player 2 wins if xyiz AIf Player 1 can always win: A is regularIf Player 2 can always win: A is not regularSlide7

A Complementary ViewRegular Languages are closed under complement

: if A is regular, then Ā is regularProof sketch:

DFA M = (Q

,

,

,

q

0

,

F) recognizes

A. DFA M = (

Q, , 

, q0,

Q  F) recognizes Ā.Thus, Player 2 wins by showing either

A or Ā is non-regular.Slide8

s

All Languages

Regular

Languages

Can be recognized by some DFA

Finite Languages

a

n

b

n

ww

R

What do we need to add to a DFA to recognize

some

non-regular languages?Slide9

DFA + Counter?A =

anbnSlide10

DFA + Counter?

count = 0

A =

a

n

b

n

a,

count = count + 1

b,

count = count

1

b, count = count  1

Accept if count == 0.Slide11

DFA + Stack = Deterministic Pushdown Automaton

A = anb

nSlide12

DFA + Stack = Deterministic Pushdown Automaton

a,

push

a

b,

pop

a

b,

pop

a

Accept

if stack is empty.

A =

a

n

bnSlide13

Formalizing DPDA

Note:

Sipser

only defines

Nondeterministic PDA

and calls it

PDA

.Slide14

DPDA Transitions

Inputs: state, alphabet symbol or

ε

,

pop

ped stack symbol or

ε

Outputs: state, stack symbol to

push

or

ε

It is a deterministic machine: must always follow possible

ε-input transition.

a, ε 

A

q1

q2Slide15

Deterministic Pushdown Automaton

q1

q2

a,

ε

+

b,

+

ε

A =

anbn

Bottom of stack markerq0b, +  εε, ε

 $q3ε, $  ε This looks like nondeterminism, but is not: must always take possible ε-transitions a state with an (ε, h) transitions cannot have any other (a, h) transitions; a state with a (a, ε) transition, cannot have any other (a, h) transitionsSlide16

A = { w | w has more 0s

than 1s } Slide17

Computing Model for DPDA

First, we need to model the stack!

$

+

+

+

push

+

$

+

+

+

+

pop

+

$

+

++Slide18

Modeling the StackSlide19

Modeling the Stack

This would be a normal

way to define a stack, but not what we use!Slide20

DPDA Computation ModelSlide21

No push or pop:

Push only:

Pop only:

Push and pop:

This rule actually covers all four cases if we make Slide22

Dealing with -transitions

Remember the NFA  DFA proof?Slide23

DPDA Computing Model

Where

E is the forced-follow 

-transitions function defined by:

whereSlide24

Acceptance: PDA accepts w when:

Accepting State Model

Empty Stack Model

Is the set of languages accepted by DPDAs with each model the same?

A good,

original

proof is worth a challenge bonus.

(Finding a published proof is not.)Slide25

Power of DPDAsL(DPDA)

 L(DFA) ?

1. Prove there is some DPDA that recognizes every regular language.

2.

Prove there is some language that can be recognized by a DPDA

that cannot be recognized by any PDA.

Construct DPDA from DFA by adding

empty stack transitions:

Henceforth: assume DPDA is Accepting-State DPDASlide26

s

All Languages

Regular

Languages

Can be recognized by some DFA

Finite Languages

a

n

b

n

DPDA Languages

(Accepting State)Slide27

ChargeThursday:Non-equivalence of NPDA and DPDA

Context-Free GrammarsNext Tuesday:PS2 DueLanguages that cannot be recognized by NPDA