1 / 15

DR. Torng

DR. Torng. Pushdown Automata (PDA’s) definition Example We define configurations and computations of PDA’s We define L(M) for PDA’s. Pushdown Automata. Definition and Motivating Example. Pushdown Automata (PDA).

oneida
Télécharger la présentation

DR. Torng

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. DR. Torng • Pushdown Automata (PDA’s) • definition • Example • We define configurations and computations of PDA’s • We define L(M) for PDA’s

  2. Pushdown Automata Definition and Motivating Example

  3. Pushdown Automata (PDA) • In this presentation we introduce the PDA model of computation (programming language). • The key addition to a PDA (from an NFA-/\) is the addition of external memory in the form of an infinite capacity stack • The word “pushdown” comes from the stacks of trays in cafeterias where you have to pushdown on the stack to add a tray to it.

  4. What strings end up in each state of the above NFA? I: B: C: Consider the language {anbn | n ≥ 0}. This NFA can recognize strings which have the correct form, a’s followed by b’s. However, the NFA cannot remember the relative number of a’s and b’s seen at any point in time. a b /\ /\ I B C NFA for {ambn | m,n ≥ 0}

  5. a b /\ /\ I B C NFA a;push a b;pop /\ I B C Initialize stack to empty /\;only if stack is empty PDA PDA for {anbn | n ≥ 0 } * Imagine we now have memory in the form of a stack which we can use to help remember how many a’s we have seen by pushing onto and popping from the stack When we see an a in state I, we do the following two actions: 1) We push an a on the stack. 2) We stay in state I. When we see a b in state B, we do the following two actions: 1) We pop an a from the stack. 2) We stay in state B. From state B, we allow a /\-transition to state C only if 1) The stack is empty. Finally, when we begin, the stack should be empty.

  6. Formal PDA definition • PDA M = (Q, S, G, q0, Z, A, δ) • Modified elements • G is the stack alphabet • Z is a special character that is initially on the stack • Often used to represent an empty stack • δ is modified as follows • Pop to read the top character on the stack • Stack update action • What to push back on the stack • If we push /\, then the net result of the action is a pop

  7. Q = {I, B, C} S = {a,b} G = {Z, a} q0 = I Z is the initial stack character A = {C} d: S a TopSt NS stack update I a a I push aa I a Z I push aZ I /\ a B push a I /\ Z B push Z B b a B push /\ B /\ Z C push Z a;a; aa a;Z;aZ b;a;/\ /\;Z;Z /\;a;a /\;Z;Z I B C Initialize stack to only contain Z Example PDA Example PDA

  8. Computing with PDA’s * • Configurations change compared with NFA-/\’s • Configuration components: • current state • remaining input to be processed • stack contents • Computations are essentially the same as with NFA-/\’s given the modified configurations • Determining which transitions of a PDA can be applied to a given configuration is more complicated though

  9. (B,aabb,Z) (I,abb,aZ) (I,bb,aaZ) (B,abb,aZ) (C,aabb,Z) (B,bb,aaZ) (B,b,aZ) (B,/\,Z) (C,/\,Z) Computation Graph of PDA Computation graph for this PDA on the input string aabb Q = {I, B, C} S = {a,b} G = {Z, a} q0 = I Z is the initial stack character A = {C} d: S a TopSt NS stack update I a a I push aa I a Z I push aZ I /\ a B push a I /\ Z B push Z B b a B push /\ B /\ Z C push Z (I,aabb,Z)

  10. a;a; aa a;Z;aZ b;a;/\ /\;Z;Z /\;a;a /\;Z;Z I B C (I,aabb,Z) (B,aabb,Z) (I,abb,aZ) (I,bb,aaZ) (B,abb,aZ) (C,aabb,Z) (B,bb,aaZ) (B,b,aZ) (B,/\,Z) (C,/\,Z) Definition of ├ Input string aabb (I, aabb, Z) ├ (I,abb,aZ) (I, aabb, Z) ├ (B, aabb, Z) (I, aabb, Z) ├2 (C, aabb, Z) (I, aabb, Z) ├3 (B, bb, aaZ) (I, aabb, Z) ├* (B, abb, aZ) (I, aabb, Z) ├* (B, /\, Z) (I, aabb, Z) ├* (C, /\, Z)

  11. a;a; aa a;Z;aZ b;a;/\ /\;Z;Z /\;a;a /\;Z;Z I B C (I,aabb,Z) (B,aabb,Z) (I,abb,aZ) (I,bb,aaZ) (B,abb,aZ) (C,aabb,Z) Not an accepting configuration since input not completely processed (B,bb,aaZ) (B,b,aZ) Not an accepting configuration since state is not accepting (B,/\,Z) (C,/\,Z) An accepting configuration Acceptance and Rejection Input string aabb M accepts string x if one of the configurations reached is an accepting configuration (q0, x, Z) ├* (f, /\, a),f in A, a in G* Stack contents can be anything M rejects string x if all configurations reached are either not halting configurations (input not exhausted) or are rejecting configurations (input exhausted but not in acceptance state)

  12. Deterministic PDA’s • A PDA is deterministic if its transition function satisfies both of the following properties • For all q in Q, a in S union {/\}, and X in G, • the set d(q,a,X) has at most one element • For all q in Q and X in G, • if d(q, /\, X) ≠ { }, then d(q,a,X) = { } for all a in S • A computation graph is now just a path again • Our default assumption is that PDA’s are nondeterministic

  13. Two forms of nondeterminism Trans Current Input Top of Next Stack # State Char. Stack State Update ------------------------------------------------------- 1 q0 a Z q0 aZ 2 q0 a Z q0 aa 3 q0/\ Z q0 aZ 4 q0 a Z q0 aa

  14. LPDA and DCFL • A language L is in language class LPDA if and only if there exists a PDA M such that L(M) = L • A language L is in language class DCFL (Deterministic Context-Free Languages) if and only if there exists a deterministic PDA M such that L(M) = L • To be proven • LPDA = CFL • CFL is a proper superset of DCFL

  15. PDA Comments • Note, we can use the stack for much more than just a counter • See examples in chapter 7 for some details

More Related