320 likes | 476 Views
CSC 4170 Theory of Computation. Pushdown Automata. Section 2.2. 2.2.a. Components of a pushdown automaton (PDA). Stack. Input. a a b a c …. x y x z. Push : write a symbol on the top of the stack Pop : delete a symbol from the top of the stack. a,x y. (Q, , , ,s,F). q1.
E N D
CSC 4170 Theory of Computation Pushdown Automata Section 2.2
2.2.a Components of a pushdown automaton (PDA) Stack Input a a b a c … x y x z . . . Push: write a symbol on the top of the stack Pop: delete a symbol from the top of the stack a,xy (Q,,,,s,F) q1 q2 If the input symbol is a and the top stack symbol is x, go from q1 to q2, pop x and push y Q is the set of states is the input alphabet is the stack alphabet is the transition function s is the start state FQ is the set of accept states If a=, the read head is not advanced If x=, nothing is popped If y=, nothing is pushed
2.2.b1 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 0 1 1 1 Stack Input
2.2.b2 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 0 1 1 1 $ Stack Input
2.2.b3 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 $ 0 0 0 1 1 1 Stack Input
2.2.b4 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 $ 0 0 0 1 1 1 Stack Input
2.2.b5 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 0 $ 0 0 0 1 1 1 Stack Input
2.2.b6 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 $ 0 0 0 1 1 1 Stack Input
2.2.b7 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 $ 0 0 0 1 1 1 Stack Input
2.2.b8 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 0 1 1 1 $ Stack Input
2.2.b9 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ Accept 0 0 0 1 1 1 Stack Input
2.2.b10 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ What language does this automaton recognize?
2.2.b11 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 1 Stack Input
2.2.b12 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 1 $ Stack Input
2.2.b13 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 $ 0 0 1 Stack Input
2.2.b14 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 0 $ 0 0 1 Stack Input
2.2.b15 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ Reject 0 $ 0 0 1 Stack Input
2.2.b16 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 1 1 Stack Input
2.2.b17 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ $ 0 1 1 Stack Input
2.2.b18 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 $ 0 1 1 Stack Input
2.2.b19 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ $ 0 1 1 Stack Input
2.2.b20 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ Reject 0 1 1 Stack Input
2.2.b21 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 1 0 Stack Input
2.2.b22 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ $ 0 1 0 Stack Input
2.2.b23 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ 0 $ 0 1 0 Stack Input
2.2.b24 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ $ 0 1 0 Stack Input
2.2.b25 How a PDA works ,$ 0,0 q1 q2 1,0 1,0 q3 q4 ,$ Reject 0 1 0 Stack Input
2.2.c Designing pushdown automata Design a pushdown automaton that recognizes the language {w | w has an equal number of 0s and 1s} 0 = s 1
2.2.d Converting NFA into PDA Every NFA can be understood as a PDA that never pushes or pops. Just replace every label a of the NFA by a, 1 1 b b, a , a, a a, a b a, b, 2 3 2 3
2.2.e Main theorems Theorem 2.20:A language is context-free iff some pushdown automaton recognizes it. Theorem:Not every nondeterministic PDA has an equivalent deterministic PDA. Example 2.18:There is a nondeterministic PDA recognizing {wwR | w{0,1}* } (wR means w reversed), but no deterministic PDA can recognize this language. Proofs omitted.