Prof. Busch - LSU 3
Initial Stack Symbol
Stack
$
Stack
z
bottomspecial symbol
stackhead
top
Appears at time 0
Prof. Busch - LSU 9
Non-Determinism
q1
q2a, b c
q3a, b c
q1 q2, b c
transition
PDAs are non-deterministic
Allowed non-deterministic transitions
Prof. Busch - LSU 11
,
a, a
b, a q0 q1 q2 q3
b, a
, $ $
}0:{)( nbaML nn
Basic Idea:
1. Push the a’s on the stack
2. Match the b’s on input with a’s on stack
3. Match found
Prof. Busch - LSU 12
a, a
b, a 0q q1 q2 q3
Execution Example:
Input
a a a b b b
currentstate
b, a
Time 0
, , $ $
Stack
$
Prof. Busch - LSU 21
A string is accepted if there is a computation such that:
All the input is consumed AND The last state is an accepting state
we do not care about the stack contentsat the end of the accepting computation
Prof. Busch - LSU 22
0q
a, a
b, a q1 q2 q3
Rejection Example:
Input
a a b
currentstate
b, a
Time 0
, , $ $
Stack
$
Prof. Busch - LSU 23
0q
a, a
b, a q1 q2 q3
Rejection Example:
Input
a a b
currentstate
b, a
Time 1
, , $ $
Stack
$
Prof. Busch - LSU 24
0q
a, a
b, a q1 q2 q3
Rejection Example:
Input
a a b
currentstate
b, a
Time 2
, , $ $
Stack
$
a
Prof. Busch - LSU 25
0q
a, a
b, a q1 q2 q3
Rejection Example:
Input
a a b
currentstate
b, a
Time 3
, , $ $
Stack
$
aa
Prof. Busch - LSU 26
0q
a, a
b, a q1 q2 q3
Rejection Example:
Input
a a b
currentstate
b, a
Time 4
, , $ $
Stack
$
aa
Prof. Busch - LSU 27
0q
a, a
b, a q1 q2 q3
Rejection Example:
Input
a a b
currentstate
b, a
Time 4
, , $ $
Stack
$
aa
reject
Prof. Busch - LSU 28
The string is rejected by the PDAaab
a, a
b, a q0 q1 q2 q3
b, a
, , $ $
There is no accepting computation foraab
Prof. Busch - LSU 29
Another PDA example
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
PDA : M }},{:{)( bavvvML R
Prof. Busch - LSU 30
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
}},{:{)( bavvvML RBasic Idea:
1. Push v on stack
2. Guess middle of input
3. Match on input with v on stack
Rv
4. Match found
Prof. Busch - LSU 31
Execution Example:
Input
Time 0
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
a ab b
Prof. Busch - LSU 34
Input
Time 3
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
aa ab b
b
Guess the middle of string
Prof. Busch - LSU 38
Rejection Example:
Input
Time 0
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
a b b b
Prof. Busch - LSU 41
Input
Time 3
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
ab
Guess the middle of string
a b b b
Prof. Busch - LSU 43
Input
Time 5
Stack
$
, $ $1q q2
bb
aa
,
,
, q0
bb
aa
,
,
aa b b b
There is no possible transition.
Input is not consumed
Prof. Busch - LSU 44
Another computation on same string:
Input Time 0
Stack
$
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
a b b b
Prof. Busch - LSU 49
Input
Time 5
Stack
a b b b
$abbb
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
No accept state is reached
Prof. Busch - LSU 50
, $ $q1 q2
bb
aa
,
,
, q0
bb
aa
,
,
There is no computation that accepts string abbb
)(MLabbb
Prof. Busch - LSU 52
q1 q2cdfeba ,
a
btop
input
stack
a
Replacee
h he
cdf
pushstring
Example:
$ $
epopstring
top
Prof. Busch - LSU 54
Another PDA example
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
PDA M
)}()(:},{{)( * wnwnbawML ba
Prof. Busch - LSU 55
Time 0
Input
a ab b b
currentstate
a
$
Stack
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
Execution Example:
Prof. Busch - LSU 56
Time 1
Input
a ab b b a
$
Stack
0
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
Prof. Busch - LSU 57
Time 3
Input
a bb b a
$
Stack
a
$
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
0
Prof. Busch - LSU 58
Time 4
Input
a bb b a
$
Stack
a
1
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
Prof. Busch - LSU 59
Time 5
Input
a bb b a
$
Stack
a
11
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
Prof. Busch - LSU 60
Time 6
Input
a bb b a
$
Stack
a
1
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
1
Prof. Busch - LSU 61
Time 7
Input
a bb b a
$
Stack
a
1
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
Prof. Busch - LSU 62
Time 8
Input
a bb b a a
$
Stack
$$, q1 q2
a, $ 0$a, 0 00a,1
b, $ 1$b, 1 11b, 0
accept
Prof. Busch - LSU 66
Formal Definition
Pushdown Automaton (PDA)
),,,δ,Γ,Σ,( 0 FzqQM
States
Inputalphabet
Stackalphabet
Transitionfunction
Acceptstates
Stackstartsymbol
Initialstate
Prof. Busch - LSU 67
Instantaneous Description
),,( suq
Currentstate Remaining
input
Currentstackcontents
Prof. Busch - LSU 68
a, a
b, a q0 q1 q2 q3
Input
Stack
a a a b b b$
aa
b, a
Time 4:
, , $ $
Example: Instantaneous Description
$),,( 1 aaabbbq
a
Prof. Busch - LSU 69
a, a
b, a q0 q1 q2 q3
Input
Stack
a a a b b b$
aa
b, a
Time 5:
, , $ $
Example: Instantaneous Description
$),,( 2 aabbq
a
Prof. Busch - LSU 71
a, a
b, a q0 q1 q2 q3
b, a
, , $ $
,$),(,$),($),,($),,(
$),,($),,($),,(
,$),(,$),(
3222
111
10
qqabqaabbq
aaabbbqaaabbbqaaabbbq
aaabbbqaaabbbq
A computation:
Prof. Busch - LSU 72
,$),(,$),($),,($),,(
$),,($),,($),,(
,$),(,$),(
3222
111
10
qqabqaabbq
aaabbbqaaabbbqaaabbbq
aaabbbqaaabbbq
For convenience we write:
,$),(,$),( 30 qaaabbbq
Prof. Busch - LSU 73
Language of PDA
Language accepted by PDA :M
)},,(),,(:{)( 0 sqzwqwML f
Initial state Accept state
)(ML
Prof. Busch - LSU 74
Example:,$),(,$),( 30 qaaabbbq
a, a
b, a q0 q1 q2 q3
b, a
, , $ $
PDA :M
)(MLaaabbb
Top Related