pushdown automata i
play

Pushdown automata I Context-free languages are more general than - PowerPoint PPT Presentation

Pushdown automata I Context-free languages are more general than regular languages For regular languages, by definition, there are automata to recognize them What are machines to recognize CFL? Pushdown automata (PDA) Its more powerful by


  1. Pushdown automata I Context-free languages are more general than regular languages For regular languages, by definition, there are automata to recognize them What are machines to recognize CFL? Pushdown automata (PDA) It’s more powerful by having a stack DFA (or NFA): September 29, 2020 1 / 11

  2. Pushdown automata II CPU input 0 1 1 0 · · · Pushdown automata: CPU input 0 1 1 0 · · · 1 1 1 0 · · · stack What is a stack? We know they are like plates in a cafeteria September 29, 2020 2 / 11

  3. Pushdown automata III An important property: last in first out Let’s see how stack can help to recognize { 0 n 1 n | n ≥ 0 } If 0 is read, 0 is pushed to stack If 1 is read, 0 is popped up By checking (0, 1) pairs, we know if the input is 0 n 1 n September 29, 2020 3 / 11

  4. Example 2.14 I Consider the following language { 0 n 1 n | n ≥ 0 } ǫ, ǫ → $ q 1 q 2 0 , ǫ → 0 1 , 0 → ǫ q 4 q 3 1 , 0 → ǫ ǫ, $ → ǫ September 29, 2020 4 / 11

  5. Example 2.14 II ✩ : a special symbol to indicate the initial state of stack How it works: q 2 → q 2 , put 0 into stack q 2 → q 3 and q 3 → q 3 , read 1 and pop 0 up The input 0011 is the same as ǫ 0011 ǫ September 29, 2020 5 / 11

  6. Example 2.14 III Steps: q 1 , ∅ , ǫ q 2 , { $ } , 0 q 2 , { 0 , $ } , 0 q 2 , { 0 , 0 , $ } , 1 q 3 , { 0 , $ } , 1 q 3 , { $ } , ǫ q 4 , {} {} : contents of the stack September 29, 2020 6 / 11

  7. Example 2.14 IV We see that ✩ can be used to check if the stack is empty Consider 00011 Steps: q 1 , ǫ, { $ } . . . q 2 , 0 , { 0 , 0 , 0 , $ } q 3 , 1 , { 0 , 0 , $ } q 3 , 1 , { 0 , $ } Cannot reach q 4 ⇒ rejected September 29, 2020 7 / 11

  8. Formal definition of pushdown automata I ( Q , Σ , Γ , δ, q 0 , F ) Q , Σ , Γ , F : finite sets Q : states 1 Σ: alphabet 2 Γ: stack alphabet 3 δ : 4 Q × Σ ǫ × Γ ǫ → P ( Q × Γ ǫ ) q 0 ∈ Q : start state 5 F ⊂ Q : set of accept states 6 We rely on September 29, 2020 8 / 11

  9. Formal definition of pushdown automata II state, input, top of stack to decide the move a , b → c − → q 2 q 1 From q 1 , read a , and replace top of stack b with c September 29, 2020 9 / 11

  10. Formal definition of example 2.14 I The language is { 0 n 1 n | n ≥ 0 } M 1 = ( Q , Σ , Γ , δ, q 1 , F ) Q = { q 1 , q 2 , q 3 , q 4 } Σ = { 0 , 1 } Γ = { 0 , $ } F = { q 1 , q 4 } September 29, 2020 10 / 11

  11. Formal definition of example 2.14 II 0 1 ǫ 0 ✩ 0 ✩ ǫ 0 ✩ ǫ ǫ { ( q 2 , $) } q 1 { ( q 2 , 0) } { ( q 3 , ǫ ) } q 2 { ( q 3 , ǫ ) } { ( q 4 , ǫ ) } q 3 q 4 In the definition of δ we have Σ ǫ × Γ ǫ Thus 9 columns in the table September 29, 2020 11 / 11

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend