>
W(
H/0DTimes New Roman,
D,0DWo
0DDTahomaew Roman,
D,0DWo
0D" DMonotype Sorts,
D,0DWo
00DLucida Sans Unicode,0DWo
0D"@DSymbolSans Unicode,0DWo
0Da.
@n?" dd@ @@``X$JD
!"#$%&'()+*,.3456789:;<=>/102?@ABCDc$ f3f33f33@qg4JdJd08ppp@uʚ;2Nʚ;<4!d!ddЁ
0P<4dddddЁ
0P2*___PPT9/0,4 ?O=8JPushdown AutomataDefinition
Moves of the PDA
Languages of the PDA
Deterministic PDA sPushdown AutomataThe PDA is an automaton equivalent to the CFG in languagedefining power.
Only the nondeterministic PDA defines all the CFL s.
But the deterministic version models parsers.
Most programming languages have deterministic PDA s.&55,SeIntuition: PDA 3fThink of an NFA with the additional power that it can manipulate a stack.
Its moves are determined by:
The current state (of its NFA ),
The current input symbol (or ), and
The current symbol on top of its stack.Tipu\?0
(Intuition: PDA (2) 3fBeing nondeterministic, the PDA can have a choice of next moves.
In each choice, the PDA can:
Change state, and also
Replace the top symbol on the stack by a sequence of zero or more symbols.
Zero symbols = pop.
Many symbols = sequence of pushes. F^bu;u^b;
PDA FormalismDA PDA is described by:
A finite set of states (Q, typically).
An input alphabet (, typically).
A stack alphabet (, typically).
A transition function (, typically).
A start state (q0, in Q, typically).
A start symbol (Z0, in , typically).
A set of final states (F " Q, typically).nufffffffConventionsna, b, & are input symbols.
But sometimes we allow as a possible value.
& , X, Y, Z are stack symbols.
& , w, x, y, z are strings of input symbols.
a, b,& are strings of stack symbols.l.oJ!The Transition FunctionTakes three arguments:
A state, in Q.
An input, which is either a symbol in or .
A stack symbol in .
(q, a, Z) is a set of zero or more actions of the form (p, a).
p is a state; a is a string of stack symbols.RuA.5<Actions of the PDA&If (q, a, Z) contains (p, a) among its actions, then one thing the PDA can do in state q, with a at the front of the input, and Z on top of the stack is:
Change the state to p.
Remove a from the front of the input (but a may be ).
Replace Z on the top of the stack by a.xuD;# (Example: PDA
33Design a PDA to accept {0n1n  n > 1}.
The states:
q = start state. We are in state q if we have seen only 0 s so far.
p = we ve seen at least one 1 and may now proceed only if the inputs are 1 s.
f = final state; accept.\3 $Example: PDA (2)33The stack symbols:
Z0 = start symbol. Also marks the bottom of the stack, so we know when we have counted the same number of 1 s as 0 s.
X = marker, used to count the number of 0 s seen on the input.<
$Example: PDA (3)33hThe transitions:
(q, 0, Z0) = {(q, XZ0)}.
(q, 0, X) = {(q, XX)}. These two rules cause one X to be pushed onto the stack for each 0 read from the input.
(q, 1, X) = {(p, )}. When we see a 1, go to state p and pop one X.
(p, 1, X) = {(p, )}. Pop one X per 1.
(p, , Z0) = {(f, Z0)}. Accept at bottom.$$p3
Actions of the Example PDA&33Actions of the Example PDA&33!
Actions of the Example PDA&33#Actions of the Example PDA&33%Actions of the Example PDA&33'Actions of the Example PDA&33)Actions of the Example PDA&33*Actions of the Example PDA&33Instantaneous DescriptionsWe can formalize the pictures just seen with an instantaneous description (ID).
A ID is a triple (q, w, a), where:
q is the current state.
w is the remaining input.
a is the stack contents, top at the left.jt\u0f
2).,The GoesTo RelationTo say that ID I can become ID J in one move of the PDA, we write I"J.
Formally, (q, aw, Xa)"(p, w, ba) for any w and a, if (q, a, X) contains (p, b).
Extend " to "*, meaning zero or more moves, by:
Basis: I"*I.
Induction: If I"*J and J"K, then I"*K.F4C
%3f 3f /Example: GoesTo33
>Using the previous example PDA, we can describe the sequence of moves by: (q, 000111, Z0)"(q, 00111, XZ0)" (q, 0111, XXZ0)"(q, 111, XXXZ0)" (p, 11, XXZ0)"(p, 1, XZ0)"(p, , Z0)" (f, , Z0)
Thus, (q, 000111, Z0)"*(f, , Z0).
What would happen on input 0001111? W
$3,'TCAnswer3(q, 0001111, Z0)"(q, 001111, XZ0)" (q, 01111, XXZ0)"(q, 1111, XXXZ0)" (p, 111, XXZ0)"(p, 11, XZ0)"(p, 1, Z0)" (f, 1, Z0)
Note the last ID has no move.
0001111 is not accepted, because the input is not completely consumed.4
+339?Aside: FA and PDA Notations3We represented moves of a FA by an extended , which did not mention the input yet to be read.
We could have chosen a similar notation for PDA s, where the FA state is replaced by a statestack combination, like the pictures just shown.$,@4FA and PDA Notations (2)Similarly, we could have chosen a FA notation with ID s.
Just drop the stack component.
Why the difference? My theory:
FA tend to model things like protocols, with indefinitely long inputs.
PDA model parsers, which are given a fixed program to process.J99 33Language of a PDApThe common way to define the language of a PDA is by final state.
If P is a PDA, then L(P) is the set of strings w such that (q0, w, Z0) "* (f, , a) for final state f and any a.5f3%4.Language of a PDA (2)LAnother language defined by the same PDA is by empty stack.
If P is a PDA, then N(P) is the set of strings w such that (q0, w, Z0) "* (q, , ) for any state q./f3%7#Equivalence of Language DefinitionsIf L = L(P), then there is another PDA P such that L = N(P ).
If L = N(P), then there is another PDA P such that L = L(P ).u9<Proof: L(P) > N(P ) Intuition3fP will simulate P.
If P accepts, P will empty its stack.
P has to avoid accidentally emptying its stack, so it uses a special bottommarker to catch the case where P empties its stack without accepting.E(Proof: L(P) > N(P )3fVP has all the states, symbols, and moves of P, plus:
Stack symbol X0, used to guard the stack bottom against accidental emptying.
New start state s and erase state e.
(s, , X0) = {(q0, Z0X0)}. Get P started.
(f, , X) = (e, , X) = {(e, )} for any final state f of P and any stack symbol X.46u6e6:>Proof: N(P) > L(P ) Intuition 3fP simulates P.
P has a special bottommarker to catch the situation where P empties its stack.
If so, P accepts.G *Proof: N(P) > L(P )3fP has all the states, symbols, and moves of P, plus:
Stack symbol X0, used to guard the stack bottom.
New start state s and final state f.
(s, , X0) = {(q0, Z0X0)}. Get P started.
(q, , X0) = {(f, )} for any state q of P. 7u7G =&Deterministic PDA sTo be deterministic, there must be at most one choice of move for any state q, input symbol a, and stack symbol X.
In addition, there must not be a choice between using input or real input.
Formally, (q, a, X) and (q, , X) cannot both be nonempty.l\R/
"
$&(+,012568;<>ABDFH ` ̙33` ` ff3333f` 333MMM` f` f` 3>?" dd@,?udd@ w " @ ` n?" dd@ @@``PR @ ` `p>>f(
6D
P
T Click to edit Master title style!
!
0XG
RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level!
S
04L
``
>*
0Q
`
@*
0V
`
@*Z
Byh@ ? ̙33 Default Design
0zrP
(
0 P
P*
0T
R*
d
c$ ?
0g_
@
RClick to edit Master text styles
Second level
Third level
Fourth level
Fifth level!
S
6t_ `P _
P*
6_ ` _
R*
H
0h ? ̙330$(
r
S
r
SА
`
H
0h ? ̙33
` $(
r
S_
_
r
SP$_ 0`_
H
0h ? ̙33
,:(
,r
, S CP
C
, SCC
"p`PpH
,0h ? ̙33
4:(
4r
4 S0&CP
C
4 S+CC
"p`PpH
40h ? ̙33
<:(
<r
< S/CP
C
< SZ0 RB
t
s*D`
H
t0h ? ̙333
s(
x
 c$d~P
~

B\~P
`
3q

<~0 0
:
0 0 1 1 1RB

s*D0 P

<~
`
@X
Z0 RB

s*D`
H
0h ? ̙333
s(
x
c$CP
C
B ~P
`
3q
<0s0 80
8 0 1 1 1 RB
s*D0 P
<_s
`
BX
X
Z0 RB
s*D`
H
0h ? ̙332
r(
x
c$4P
BxIP
`
3q
< 0 W0
51 1 1RB
s*D0 P
<(
`
DX
X
X
Z0 RB
s*D`
H
0h ? ̙33.
n(
x
c$
P
B
P
`
3p
<
0
0
31 1RB
s*D0 P
<
`
BX
X
Z0 RB
s*D`
H
0h ? ̙33*
0j(
x
c$d
P
B<P
`
3p
<̘0
0
11RB
s*D0 P
<4
`
@X
Z0 RB
s*D`
H
0h ? ̙33
3+P(
x
c$P
BlP
`
3pRB
s*D0 P
<d
`
>Z0 RB
s*D`
H
0h ? ̙33
3+p(
x
c$HP
BP
`
3fRB
s*D0 P
<
`
>Z0 RB
s*D`
H
0h ? ̙33
:(
r
SP
S
"p`PpH
0h ? ̙33
$(
r
SP
r
S\0
H
0h ? ̙33
P(
r
SP
S<$
0
H
0h ? ̙33
B(
r
S)
P
)
r
SS
l B
B,$D
08
<) B&
tLegal because a PDA can use
input even if input remains.4;333333ZB
s*D`H
0h ? ̙33
$(
r
SdP
r
S
H
0h ? ̙33
P(
r
S$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
SLi
@
H
0h ? ̙33
0(
X
C
)
SD
@)
H
0h ? ̙33
0 ((
^
S
)
c$0)
@)
H
0h ? ̙33
0@$((
$^
$ S
$ c$2
@
H
$0h ? ̙33r W_ eg̹qitskumHcqwoesgulSw?y@W{ǃ<\r</ΩX,ĳʥh<ҵHOh+'0/`h
CS154 slidesoJeff UllmanJeffUll55fMicrosoft PowerPointP@`"@}J@p1FG.g a%& &&#TNPP2OMi
&
TNPP &&TNPP
&&&&$0>$>L$LZ*$*Zh8$8hvF$FvT$Tb$bp$p~$~$$$$$$$$,$,:
$
:H$HV&$&Vd4$4drB$BrP$P^$^k$ky$y$$$$$$$$'$'5$5C$CQ!$!Q_/$/_m=$=m{K$K{Y$Yg$gu$u$$$$$$$$#$#1$1?$?M$M[+$+[i9$9iwG$GwU$Uc$cq$q$$$$$$$$$$;$;I$IW'$'We5$5erB$BrP$P^$^l$lz$z$$$$$$$$($(6$6D$DR"$"R`0$0`n>$>nL$LZ$Zh$hv$v$$$&&&&$&&&&
&&&&&&$0>$>L$LZ*$*Zh8$8hvF$FvT$Tb$bp$p~$~$$$$$$$$,$,:
$
:H$HV&$&Vd4$4drB$BrP$P^$^k$ky$y$$$$$$$$'$'5$5C$CQ!$!Q_/$/_m=$=m{K$K{Y$Yg$gu$u$$$$$$$$#$#1$1?$?M$M[+$+[i9$9iwG$GwU$Uc$cq$q$$$$$$$$$$;$;I$IW'$'We5$5erB$BrP$P^$^l$lz$z$$$$$$$$($(6$6D$DR"$"R`0$0`n>$>nL$LZ$Zh$hv$v$$$&
&&&y&/v`v
P%سv`vf{ @Times New Roman\سv`vf{ . 2
f1 .IyH @"Tahomav
P%\سv`vf{ .!2
#Pushdown Automata!! ! +!#!2.)1p @"Tahomav
@P%\سv`vf{ .2
Definition
. .2
9Moves of the PDA!
. .%2
Languages of the PDA
. .$2
W)Deterministic PDAsA$
."System{f{
G&TNPP &՜.+,0d
(Onscreen ShowStanford University, CS Dept.!! 'Times New RomanTahomaMonotype SortsLucida Sans UnicodeSymbolDefault DesignPushdown AutomataPushdown AutomataIntuition: PDAIntuition: PDA (2)PDA FormalismConventionsThe Transition FunctionActions of the PDA
Example: PDAExample: PDA (2)Example: PDA (3)Actions of the Example PDAActions of the Example PDAActions of the Example PDAActions of the Example PDAActions of the Example PDAActions of the Example PDAActions of the Example PDAActions of the Example PDAInstantaneous DescriptionsThe GoesTo RelationExample: GoesToAnswerAside: FA and PDA NotationsFA and PDA Notations (2)Language of a PDALanguage of a PDA (2)$Equivalence of Language DefinitionsProof: L(P) > N(P) IntuitionProof: L(P) > N(P) Proof: N(P) > L(P) IntuitionProof: N(P) > L(P)Deterministic PDAsFonts UsedDesign Template
Slide Titles!_
JeffJeff
!"#$%&'()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{}~Root EntrydO)Current UserSummaryInformation(0PowerPoint Document(DocumentSummaryInformation8Root EntrydO)h<Current UserPSummaryInformation(0PowerPoint Document((_'Michael GoodrichMichael Goodrich