Upload
gayle
View
34
Download
0
Tags:
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
Costas Busch - RPI 1
Pushdown AutomataPDAs
Costas Busch - RPI 2
Pushdown Automaton -- PDA
Input String
Stack
States
Costas Busch - RPI 3
Initial Stack Symbol
Stack
$
Stack
z
bottomspecial symbol
stackhead
top
Costas Busch - RPI 4
The States
q1 q2a, b c
Inputsymbol
Popsymbol
Pushsymbol
Costas Busch - RPI 5
q1 q2a, b c
a
b top
input
stack
a
Replaceeh
$eh
$
c
Costas Busch - RPI 6
q1 q2a, c
a a
Pushb
eh
$eh
$
bc
top
input
stack
Costas Busch - RPI 7
q1 q2a, b
a a
Popb
eh
$eh
$
top
input
stack
Costas Busch - RPI 8
q1 q2a,
a a
No Changeb
eh
$eh
$
btop
input
stack
Costas Busch - RPI 9
q1 q2$,a
a a
Pop$ top
input
stack
A Possible Transition
empty
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
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
Costas Busch - RPI 12
q1 q2zyx ,
No transition is allowed to be followedWhen the stack is empty
Empty stack
Costas Busch - RPI 13
q1 q2ba $,
a a
Pop$ top
input
stack
A Good Transition
b
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)
Costas Busch - RPI 26
The input stringis accepted by the NPDA:
aaabbb
a, a
b, a q0 q1 q2 q3
b, a
, , $ $
Costas Busch - RPI 28
NPDA example
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
NPDA M
}{)( RwwML
Costas Busch - RPI 29
Execution Example:
Input
Time 0
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
a ab b
Costas Busch - RPI 30
Input
a ab
Time 1
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
ab
Costas Busch - RPI 31
Input
Time 2
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
aa ab b
b
Costas Busch - RPI 32
Input
Time 3
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
aa ab b
b
Guess the middle of string
Costas Busch - RPI 33
Input
Time 4
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
aa ab b
b
Costas Busch - RPI 34
Input
Time 5
Stack
$
, $ $1q q2
bb
aa
,
,
, q0
bb
aa
,
,
a ab b a
Costas Busch - RPI 35
Input
Time 6
Stack
$
, $ $q1
bb
aa
,
,
, q0
bb
aa
,
,
a ab b
accept
q2
Costas Busch - RPI 36
Rejection Example:
Input
Time 0
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
a b b b
Costas Busch - RPI 37
Input
Time 1
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
aa b b b
Costas Busch - RPI 38
Input
Time 2
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
ab
a b b b
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
Costas Busch - RPI 40
Input
Time 4
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
ab
a b b b
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
Costas Busch - RPI 42
Another computation on same string:
Input Time 0
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
a b b b
Costas Busch - RPI 43
Input
Time 1
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
aa b b b
Costas Busch - RPI 44
Input
Time 2
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
ab
a b b b
Costas Busch - RPI 45
Input
Time 3
Stack
$ab
a b b b
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
b
Costas Busch - RPI 46
Input
Time 4
Stack
a b b b
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
$abbb
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
Costas Busch - RPI 48
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
There is no computation that accepts string abbb
)(MLabbb
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
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
Costas Busch - RPI 61
Pushing Strings
q1 q2a, b w
Inputsymbol
Popsymbol
Pushstring
Costas Busch - RPI 62
q1 q2a, b cdf
a
b top
input
stack
a
Push
eh h
e
cdf
pushedstring
Example:
$ $