1 / 23

Pushdown Automata

CS 3240 – Chapter 7. Pushdown Automata. Where Are We?. A Pushdown Automaton Machine for Context-Free Languages. Take an FA and add a stack A restricted form of unbounded memory Operations: Pop Push Ignore ( λ ) (Pop always precedes push). PDA Operations.

Télécharger la présentation

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. CS 3240 – Chapter 7 Pushdown Automata

  2. Where Are We? CS 3240 - Introduction

  3. A Pushdown AutomatonMachine for Context-Free Languages • Take an FA and add a stack • A restricted form of unbounded memory • Operations: • Pop • Push • Ignore (λ) • (Pop always precedes push) CS 3240 - Pushdown Automata

  4. PDA Operations • Three items per transition edge • <read>,<pop>,<push> • any or all could be λ • A PDA accepts when: • An accepting state is reached, and • The stack is empty • Different from book! • The machine crashes when no move is possible • implicit jail CS 3240 - Pushdown Automata

  5. A PDA for anbn (n > 0) A deterministic PDA (no choices; λ is okay sometimes). The stack alphabet (Γ = {X}) can differ from the input alphabet (Σ = {a, b}) . Trace aabb… CS 3240 - Pushdown Automata

  6. Tracing the PDA(<state> | <input> | <stack>) q0 aabb λ q0 abb X q0 bb XX q1 b X q1 λ λ Traditional notation (see book): (q0,aabb, λ) ⊢ (q0,abb,X) ⊢ (q0,bb,XX) ⊢ (q1,b,X) ⊢ (q1,λ, λ) Also: (q0,aabb,λ) ⊢*(q1,λ, λ) (⇒ aabb ∈ L) CS 3240 - Pushdown Automata

  7. A PDA for anbn (n ≥ 0) CS 3240 - Pushdown Automata

  8. A PDA for anb2n (n ≥ 0) How would you do a2nbn? CS 3240 - Pushdown Automata

  9. a2nbn Each b must pop 2 X’s CS 3240 - Pushdown Automata

  10. A PDA for wcwR Is this deterministic? Trace the string abaacaaba. CS 3240 - Pushdown Automata

  11. Transition Functions for PDAs • Input: (state-1, input character, pop character) • Output: (state-2, push character(s)) • Example: The edge (a,λ,a) on previous slide: δ(q0,a,λ) = (q0,a) • Exercise: • Rewrite wcwR in functional form CS 3240 - Pushdown Automata

  12. A PDA for All Palindromes Is this deterministic? Trace the string abaaaaaba. Trace the string abaabaaba. Trace the string abaaaaba. CS 3240 - Pushdown Automata

  13. A PDA for ambn, m ≤ n ≤ 2mNon-deterministic The grammar: S → aSb | aSbb | λ Trace aaabbbb CS 3240 - Pushdown Automata

  14. A PDA for Equal Trace ababbaab CS 3240 - Pushdown Automata

  15. A PDA for nb = na + 1 CS 3240 - Pushdown Automata

  16. A PDA for Twicebnb = 2na • Reasoning: There must be 2 b’s for every a. When we read an a, there are three possibilities: • Its 2 b’s have already been read • 1 b has been read and 1 remains • Both b’s are yet to be read Try abababbbb. How would you do Twicea? CS 3240 - Pushdown Automata

  17. What Language Is This? CS 3240 - Pushdown Automata

  18. aibjck, i,j,k ≥ 0, i = jor i = k CS 3240 - Pushdown Automata

  19. anor anbn CS 3240 - Pushdown Automata

  20. Formal Definition of PDAs • Q: set of states • ∑: input alphabet • Γ: stack alphabet • δ: Q x (∑∪λ) x (Γ∪λ) →finite subsets of Q x Γ* • q0: start state • F ⊆ Q: final states • (z ⋲ Γ: optional stack start symbol) CS 3240 - Pushdown Automata

  21. Using Stack Start Symbols • Not strictly necessary • Can serve as a “bottom marker” to allow detection of an empty stack • A convenience • Can make things easier to design/understand • Sometimes handy when seeking an associated CFG • Can eliminate some lambda pops • Handy later CS 3240 - Pushdown Automata

  22. anbn with a Start Symbol CS 3240 - Pushdown Automata

  23. A PDA for EqualUsing a Stack Start Symbol (“Almost” Deterministic) CS 3240 - Pushdown Automata

More Related