1 / 24

6 . Pushdown Automata

6 . Pushdown Automata. CIS 5513 - Automata and Formal Languages – Pei Wang. Pushdown automata: idea. Context-Free Languages can be accepted by pushdown automata A pushdown automaton is an ɛ-NFA with a stack with unlimited capacity

brentmcgraw
Télécharger la présentation

6 . 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. 6. Pushdown Automata CIS 5513 - Automata and Formal Languages – Pei Wang

  2. Pushdown automata: idea Context-Free Languages can be accepted by pushdown automata A pushdown automaton is an ɛ-NFA with a stack with unlimited capacity Its transition function also takes the top of the stack into account, and may change the top item in the stack It accepts at a final state or an empty stack

  3. Pushdown automata: definition A pushdown automaton (PDA) P = (Q, Σ, Γ, δ, q0, Z0, F) where • Γ (Gamma): A finite stack alphabet • δ: Q×(Σ{ε})×Γ→2Q×Γ*, a transition function that specifies the set of possible next state and the new content at the top of the stack • Z0Γ, the start symbol in stack The other components are like in an ɛ-NFA

  4. Example: transition table A PDA for the binary language {wwr}: P = ({q0,q1,q2}, {0, 1}, {Z0,0,1}, δ, q0, Z0, {q2}) 1. δ(q0, 0, Z0) = {(q0, 0Z0)}; δ(q0, 1, Z0) = {(q0, 1Z0)} 2. δ(q0, 0, 0) = {(q0, 00)}; δ(q0, 0, 1) = {(q0, 01)}; δ(q0, 1, 0) = {(q0, 10)}; δ(q0, 1, 1) = {(q0, 11)} 3. δ(q0, ɛ, Z0) = {(q1, Z0)}; δ(q0, ɛ, 0) = {(q1, 0)}; δ(q0, ɛ, 1) = {(q1, 1)} 4. δ(q1, 0, 0) = {(q1, ɛ)}; δ(q1, 1, 1) = {(q1, ɛ)} 5. δ(q1, ɛ, Z0) = {(q2, Z0)}

  5. Example: transition graph

  6. Instantaneous descriptions of PDA The configuration, or instantaneous description (ID), of a PDA: (q, w, r), where q is the state, w is the remaining input, and r is the stack contents Here “state” only specifies the “control unit”, not the stored “data” in stack If the value of δ(q, a, X) contains (p, α), then the ID transition is (q, aw, Xβ)˫(p, w, αβ), for arbitrary w and β

  7. ID transitions: an example

  8. Properties of ID transitions ID transition with multiple moves is shown as ˫* Symbols may be added or removed to input or stack in ID transitions

  9. Exercise 6.1.1 Solution

  10. Two types of acceptance A PDA can define a language in two ways

  11. From Empty Stack to Final State PF can be obtained by adding an ɛ-transition to a final state whenever the stack in PN is empty, with the help of a new stack-symbol below Z0

  12. From Final State to Empty Stack PN can be obtained by popping out all stack symbols in final states in PF, with the help of a new stack-symbol below Z0

  13. Exercises for Section 6.2 6.2.1(a): Design a PDA to accept {0n1n | n ≥ 1} 6.2.2(a): Design a PDA to accept {aibjck| i = j or j = k} Solutions: http://infolab.stanford.edu/~ullman/ialcsols/sol6.html#sol62

  14. CFG to PDA From a given CFG G = (V, T, Q, S), a PN= ({q},T, VT, , q, S) can accept L(G) by simulating the leftmost derivation to expand the symbols in stack to match the input WhenPN is in ID (q, y, Aα) where A is a variable and there is a rule A→β in Q, the next ID can be (q, y, βα). Remove the common prefix of βαand y. Repeat until the stack is empty

  15. CFG to PDA: example

  16. PDA to CFG:simple case If a PDA is P = ({q}, Σ, Γ, δ, q, Z), the equivalent CFG G = (Γ{S}, Σ, R, S), where R contains S → Z, and for each (q, Y1Y2…Yk) in δ(q, a, X), R contains X →aY1Y2…Yk, where k ≥ 0, and Yi can be a variable, a terminal, or ε

  17. PDA to CFG: general case Use a grammar variable [pXq] to represent the state change from p to q for the popping out of a stack symbol X

  18. PDA to CFG (cont.)

  19. PDA to CFG: example 6.10: δ(q, i, Z) = {(q, ZZ)}; δ(q, e, Z) = {(q, ε)}

  20. PDA to CFG: example (2)

  21. PDA to CFG: example (3)

  22. Exercises for Section 6.3 Solutions: http://infolab.stanford.edu/~ullman/ialcsols/sol6.html#sol63

  23. Deterministic pushdown automata A PDA is deterministic (DPDA), if • Each δ(q, a, X) has at most one element • If δ(q, a, X) is nonempty, then δ(q, ɛ, X) must be empty • Lwcwr= {wcwR} with a marker c

  24. PDA, DPDA, and DFA The set of language accepted by DPDA is a subset of CFL, and a super set of regular language, so the capability of DPDA is between those of PDA and DFA DPDA accept all regular languages, but only the context-free languages that have unambiguous CFG

More Related