1 / 10

Pushdown Automata

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”

brigit
Download Presentation

Pushdown Automata

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6

  2. 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?

  3. PDA definition • A pushdown automaton M is a tupleM = (Q, , , , q0, Z0, 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 • q0 is the start state of M • Z0 is the starting stack symbol (initially on the stack) • F  Q is the set of accepting states or final states of M

  4. PDA transitions • A transition between states qx and qy can be carried out in a PDA when a given next input symbol a is read and a given stack symbol X is on top of the stack • When the transition to qy is carried out, the symbol X is replaced with a string w of stack symbols • (qx,a, X) contains the pair (qy ,w) • How are the stack operations push, pop, inspect top, and check if empty carried out? • push Y on input a: (qx,a, X) -> (qy ,YX) • pop Y: (qx,a, X) -> (qy ,є) • How about inspect top and check if empty?

  5. Example • L = {anbn: n >= 0} • PDA M =({q0,q1,q2}, {a,b}, {Z0,X}, , q0, Z0, {q2}) •  defined (informally) as follows: • On input a (from q0) push X onto the stack • On input b (from q0 and q1), pop X and transition to q1 (note: cannot transition if X is not on top of the stack) • From q0 and q1, transition to final state q2 if stack is “empty” (Z0 is on top)

  6. Transition function example • (q0,a, Z0) = {(q0 ,XZ0)} • (q0,a, X) = {(q0 ,XX)} • (q0,b, X) = {(q1 ,є)} • (q1,b, X) = {(q1 ,є)} • (q0,є, Z0) = {(q2 ,Z0)} • (q1,є, Z0) = {(q2 ,Z0)} • (q0,b, Z0) = (q1,b, Z0) = (q1,a, X) and many others are all equal to {} push X onto the stack on input a pop X from the stack on input b go to final stateif Z0 is on top

  7. PDA diagram a, Z0, XZ0 a, X, XX b, X, є b, X, є q1 q0 є, Z0, Z0 є, Z0, Z0 q2

  8. Alternative diagram b, pop X a, push X b, pop X q1 q0 є, empty є, empty q2

  9. 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 (Z0 has been popped out), regardless of what state it is currently in • These two “kinds” of PDAs are equivalent (proofs in section 6.2)

  10. 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

More Related