Transcript Finite Automata & Regular Languages
Pushdown Automata
Hopcroft, Motawi, Ullman, Chap 6
PDAs: Pushdown Automata
Same as Finite Automata (e.g., NFAs), but with the addition of a stack: On each transition, a stack is manipulated and monitored (operations: push, pop, inspect top, check for empty) Allows the automaton to “count” Definition will need to incorporate stack events When is a string acceptable?
PDA definition
A pushdown automaton M is a tuple M = (Q, , , , q 0 , Z 0 , F), where: Q is a set of states is the input alphabet is the stack alphabet : Q +є (Q *)* is the state transition function mapping a (state, symbol, stack symbol) triple to a set of (state, string) pairs q 0 is the start state of M Z 0 is the starting stack symbol (initially on the stack) F Q is the set of accepting states or final states of M
PDA transitions
A transition between states q stack x and q y can be carried read and a given stack symbol X is on top of the When the transition to q y is carried out, the symbol X (q x , a, X) contains the pair (q y , w) How are the stack operations push, pop, inspect top, and check if empty carried out?
push Y on input a: (q x , a, X) -> (q y , YX) pop Y: (q x , a, X) -> (q y , є) How about inspect top and check if empty?
Example
L = {a n b n : n >= 0} PDA M = ({q 0 ,q 1 ,q 2 }, {a,b}, {Z 0 ,X}, , q 0 , Z 0 , {q 2 }) defined (informally) as follows: On input a (from q 0 ) push X onto the stack On input b (from q 0 the stack) and q 1 ), pop X and transition to q1 (note: cannot transition if X is not on top of From q0 and q1, transition to final state q 2 is “empty” (Z 0 is on top) if stack
Transition function example
(q (q (q 0 0 0 , a, Z , є, Z 0 0 ) = {(q , b, X) = {(q ) = {(q 1 0 2 , XZ , є)} (q 1 , b, X) = {(q 1 , є)} , Z 0 0 (q 0 , a, X) = {(q 0 , XX)} )} (q 1 , є, Z 0 ) = {(q 2 , Z 0 )} )} push X onto the stack on input a pop X from the stack on input b go to final state if Z 0 is on top (q 0 , b, Z 0 ) = (q 1 , b, Z 0 ) = (q 1 , a, X) and many others are all equal to {}
PDA diagram
a, Z 0 , XZ 0 a, X, XX q 0 є , Z 0 , Z 0 b, X, є q 2 є , Z 0 , Z 0 b, X, є q 1
Alternative diagram
a, push X q 0 є , empty b, pop X b, pop X є , empty q 1 q 2
Accepting strings in a PDA
By final state, just like in regular final automata Or by empty stack: string is acceptable once the stack is empty (Z is currently in 0 has been popped out), regardless of what state it These two “kinds” of PDAs are equivalent (proofs in section 6.2)
Equivalence of PDAs and CFGs
PDAs and CFGs describe the same set of languages (section 6.3) Proof requires: Construction from a grammar to an equivalent PDA Construction from a PDA to an equivalent grammar