Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.

Post on 14-Dec-2015

226 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

Transcript

Pushdown AutomataPushdown 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

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

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

$

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$

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$

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$

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$

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$

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

$

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

How a PDA works 2.2.b10

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

What language does this automaton recognize?

How a PDA works 2.2.b11

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

How a PDA works 2.2.b12

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

$

How a PDA works 2.2.b13

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

0$

How a PDA works 2.2.b14

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

00$

How a PDA works 2.2.b15

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 0 1

Stack Input

0$

Reject

How a PDA works 2.2.b16

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

How a PDA works 2.2.b17

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

$

How a PDA works 2.2.b18

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

0$

How a PDA works 2.2.b19

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

$

How a PDA works 2.2.b20

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 1

Stack Input

Reject

How a PDA works 2.2.b21

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

How a PDA works 2.2.b22

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

$

How a PDA works 2.2.b23

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

0$

How a PDA works 2.2.b24

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

$

How a PDA works 2.2.b25

, $q1 q2

q4 q3,$

1,0

0, 0

1,0

0 1 0

Stack Input

Reject

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

=

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,

,

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.

top related