30
Pushdown Automata Pushdown Automata Section 2.2 CSC 4170 heory of Computatio

Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

Embed Size (px)

Citation preview

Page 1: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

Pushdown AutomataPushdown Automata

Section 2.2

CSC 4170

Theory of Computation

Page 2: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

Components of a pushdown automaton (PDA) 2.2.a

(Q,,,,s,F)

xyxz

.

.

.

a a b a c …Stack Input

Q is the set of states is the input alphabet is the stack alphabet is the transition functions is the start stateFQ is the set of accept states

a,xyq1 q2

If the input symbol is a andthe top stack symbol is x,go from q1 to q2, pop x and push y

If a=, the read head is not advanced If x=, nothing is poppedIf y=, nothing is pushed

Push: write a symbol on the top of the stackPop: delete a symbol from the top of the stack

Page 3: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b1

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

Page 4: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b2

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

$

Page 5: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b3

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

0$

Page 6: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b4

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

00$

Page 7: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b5

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

000$

Page 8: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b6

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

00$

Page 9: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b7

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

0$

Page 10: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b8

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

$

Page 11: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b9

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 0 1 1 1

Stack Input

Accept

Page 12: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b10

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

What language does this automaton recognize?

Page 13: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b11

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

Page 14: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b12

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

$

Page 15: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b13

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

0$

Page 16: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b14

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

00$

Page 17: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b15

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

0$

Reject

Page 18: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b16

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

Page 19: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b17

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

$

Page 20: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b18

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

0$

Page 21: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b19

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

$

Page 22: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b20

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

Reject

Page 23: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b21

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

Page 24: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b22

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

$

Page 25: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b23

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

0$

Page 26: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b24

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

$

Page 27: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

How a PDA works 2.2.b25

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

Reject

Page 28: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

Designing pushdown automata 2.2.c

s

0

Design a pushdown automaton that recognizes the language

{w | w has an equal number of 0s and 1s}

1

=

Page 29: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

Converting NFA into PDA2.2.d

3 2

1

a

a b

ab

Every NFA can be understood as a PDA that never pushes or pops.

Just replace every label a of the NFA by a,

3 2

1

a,

a, b,

a,b,

,

Page 30: Pushdown Automata Section 2.2 CSC 4170 Theory of Computation

Main theorems 2.2.e

Theorem 2.20: A language is context-free iff some pushdown automaton recognizes it.

Theorem: Not every nondeterministic PDA has anequivalent deterministic PDA.

Example 2.18: There is a nondeterministic PDA recognizing {wwR | w{0,1}* }(wR means w reversed),but no deterministic PDA can recognize this language.

Proofs omitted.