90 likes | 128 Views
Explore how Pushdown Automata accept context-free languages, their equivalence with CFGs, and examples of PDAs for various languages. Learn about Lemma 2.27 and Theorem 2.20 regarding PDA-CFG equivalence.
E N D
[Section 2.2] Pushdown Automata • like NFA’s but also have a stack • accept context-free languages (we’ll prove their equivalence to CFG’s) • Example: { 0n#1n | n > 0 }
[Section 2.2] Pushdown Automata • Def 2.13: • A pushdown automaton (PDA) is a 6-tuple (Q,§,¡,±,q0,F), where • Q is a finite set of states • § is a finite input alphabet • ¡ is a finite stack alphabet • ± : is the transition function • q02 Q is the start state • F µ Q is the set of accept states
[Section 2.2] Pushdown Automata Def: Let M=(Q,§,¡,±,q0,F) be a PDA. It accepts w = w1w2…wm, where each wi2§[{ε}, if there exist states r0,r1,…,rm2 Q and strings s0,s1,…,sm2¡* such that
[Section 2.2] Pushdown Automata • Examples: give PDAs for the following languages: • { aibjck | i,j,k ¸ 0 and i=j or i=k } • { wwR | w 2 {0,1}* } • { w | w contains the same number of 0’s and 1’s }
[Section 2.2] Equivalence with CFGs Thm 2.20: A language is context-free iff there is a PDA that recognizes it.
[Section 2.2] Equivalence with CFGs Lemma 2.21: For every context-free language there is a PDA that recognizes it.
[Section 2.2] Equivalence with CFGs • Lemma 2.27: For every PDA there is an equivalent CFG. • Proof: assume PDA satisfies: • has a single accept state • empties stack before accepting • each transition is a “push” or “pop” but not both
[Section 2.2] Equivalence with CFGs • Lemma 2.27: For every PDA there is an equivalent CFG. • Proof: Let P=(Q,§,¡,±,q0,{qaccept}) be a pda satisfying 1-3. Then CFG G=(V,§,P,S) is • V = { Ap,q | p,q 2 Q } - meaning “Ap,q generates all strings that move from p to q on an empty stack” • S =