40
Costas Busch - RPI 1 Pushdown Automata PDAs

Pushdown Automata PDAs

  • Upload
    gayle

  • View
    34

  • Download
    0

Embed Size (px)

DESCRIPTION

Pushdown Automata PDAs. Pushdown Automaton -- PDA. Input String. Stack. States. Initial Stack Symbol. Stack. Stack. stack head. top. bottom. special symbol. The States. Pop symbol. Input symbol. Push symbol. input. stack. top. Replace. input. stack. top. Push. input. - PowerPoint PPT Presentation

Citation preview

Page 1: Pushdown Automata PDAs

Costas Busch - RPI 1

Pushdown AutomataPDAs

Page 2: Pushdown Automata PDAs

Costas Busch - RPI 2

Pushdown Automaton -- PDA

Input String

Stack

States

Page 3: Pushdown Automata PDAs

Costas Busch - RPI 3

Initial Stack Symbol

Stack

$

Stack

z

bottomspecial symbol

stackhead

top

Page 4: Pushdown Automata PDAs

Costas Busch - RPI 4

The States

q1 q2a, b c

Inputsymbol

Popsymbol

Pushsymbol

Page 5: Pushdown Automata PDAs

Costas Busch - RPI 5

q1 q2a, b c

a

b top

input

stack

a

Replaceeh

$eh

$

c

Page 6: Pushdown Automata PDAs

Costas Busch - RPI 6

q1 q2a, c

a a

Pushb

eh

$eh

$

bc

top

input

stack

Page 7: Pushdown Automata PDAs

Costas Busch - RPI 7

q1 q2a, b

a a

Popb

eh

$eh

$

top

input

stack

Page 8: Pushdown Automata PDAs

Costas Busch - RPI 8

q1 q2a,

a a

No Changeb

eh

$eh

$

btop

input

stack

Page 9: Pushdown Automata PDAs

Costas Busch - RPI 9

q1 q2$,a

a a

Pop$ top

input

stack

A Possible Transition

empty

Page 10: Pushdown Automata PDAs

Costas Busch - RPI 10

q1 q2cba ,

a input

A Bad Transition

The automaton Halts in state and Rejects the input string

Empty stack

q1

HALT

Page 11: Pushdown Automata PDAs

Costas Busch - RPI 11

q1 q2ca ,

a input

A Bad Transition

The automaton Halts in state and Rejects the input string

Empty stack

q1

HALT

Page 12: Pushdown Automata PDAs

Costas Busch - RPI 12

q1 q2zyx ,

No transition is allowed to be followedWhen the stack is empty

Empty stack

Page 13: Pushdown Automata PDAs

Costas Busch - RPI 13

q1 q2ba $,

a a

Pop$ top

input

stack

A Good Transition

b

Page 14: Pushdown Automata PDAs

Costas Busch - RPI 14

Non-Determinism

q1

q2a, b c

q3a, b c

q1 q2, b c

transition

These are allowed transitions in a Non-deterministic PDA (NPDA)

Page 15: Pushdown Automata PDAs

Costas Busch - RPI 26

The input stringis accepted by the NPDA:

aaabbb

a, a

b, a q0 q1 q2 q3

b, a

, , $ $

Page 16: Pushdown Automata PDAs

Costas Busch - RPI 28

NPDA example

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

NPDA M

}{)( RwwML

Page 17: Pushdown Automata PDAs

Costas Busch - RPI 29

Execution Example:

Input

Time 0

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

a ab b

Page 18: Pushdown Automata PDAs

Costas Busch - RPI 30

Input

a ab

Time 1

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

ab

Page 19: Pushdown Automata PDAs

Costas Busch - RPI 31

Input

Time 2

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

aa ab b

b

Page 20: Pushdown Automata PDAs

Costas Busch - RPI 32

Input

Time 3

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

aa ab b

b

Guess the middle of string

Page 21: Pushdown Automata PDAs

Costas Busch - RPI 33

Input

Time 4

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

aa ab b

b

Page 22: Pushdown Automata PDAs

Costas Busch - RPI 34

Input

Time 5

Stack

$

, $ $1q q2

bb

aa

,

,

, q0

bb

aa

,

,

a ab b a

Page 23: Pushdown Automata PDAs

Costas Busch - RPI 35

Input

Time 6

Stack

$

, $ $q1

bb

aa

,

,

, q0

bb

aa

,

,

a ab b

accept

q2

Page 24: Pushdown Automata PDAs

Costas Busch - RPI 36

Rejection Example:

Input

Time 0

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

a b b b

Page 25: Pushdown Automata PDAs

Costas Busch - RPI 37

Input

Time 1

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

aa b b b

Page 26: Pushdown Automata PDAs

Costas Busch - RPI 38

Input

Time 2

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

ab

a b b b

Page 27: Pushdown Automata PDAs

Costas Busch - RPI 39

Input

Time 3

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

ab

Guess the middle of string

a b b b

Page 28: Pushdown Automata PDAs

Costas Busch - RPI 40

Input

Time 4

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

ab

a b b b

Page 29: Pushdown Automata PDAs

Costas Busch - RPI 41

Input

Time 5

Stack

$

, $ $1q q2

bb

aa

,

,

, q0

bb

aa

,

,

aa b b b

There is no possible transition.

Input is not consumed

Page 30: Pushdown Automata PDAs

Costas Busch - RPI 42

Another computation on same string:

Input Time 0

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

a b b b

Page 31: Pushdown Automata PDAs

Costas Busch - RPI 43

Input

Time 1

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

aa b b b

Page 32: Pushdown Automata PDAs

Costas Busch - RPI 44

Input

Time 2

Stack

$

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

ab

a b b b

Page 33: Pushdown Automata PDAs

Costas Busch - RPI 45

Input

Time 3

Stack

$ab

a b b b

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

b

Page 34: Pushdown Automata PDAs

Costas Busch - RPI 46

Input

Time 4

Stack

a b b b

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

$abbb

Page 35: Pushdown Automata PDAs

Costas Busch - RPI 47

Input

Time 5

Stack

a b b b

$abbb

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

No final state is reached

Page 36: Pushdown Automata PDAs

Costas Busch - RPI 48

, $ $q1 q2

bb

aa

,

,

, q0

bb

aa

,

,

There is no computation that accepts string abbb

)(MLabbb

Page 37: Pushdown Automata PDAs

Costas Busch - RPI 49

A string is rejected if there is no computation such that:

All the input is consumed AND The last state is a final state

At the end of the computation,we do not care about the stack contents

Page 38: Pushdown Automata PDAs

Costas Busch - RPI 50

In other words, a string is rejected if in every computation with this string:

The input cannot be consumed OR

The input is consumed and the last state is not a final state

ORThe stack head moves below the bottom of the stack

Page 39: Pushdown Automata PDAs

Costas Busch - RPI 61

Pushing Strings

q1 q2a, b w

Inputsymbol

Popsymbol

Pushstring

Page 40: Pushdown Automata PDAs

Costas Busch - RPI 62

q1 q2a, b cdf

a

b top

input

stack

a

Push

eh h

e

cdf

pushedstring

Example:

$ $