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
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
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
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
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
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
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
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
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
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
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
Recommend
More recommend