pushdown accepters & context-free grammars sipser, theorem 2.12 denning, chapter 8
TRANSCRIPT
Pushdown Accepters & Context-Free Grammars
Sipser, Theorem 2.12Denning, Chapter 8
Fundamental theorem of CFLs and PDAs
Theorem 2.12 (Sipser) A language L is context-free if and only if (iff) there exists a pushdown accepter M that recognizes L
CFL if PDA; PDA -> CFL
Given a PDA, M, that recognizes language L, then there exists a CFG, G, that generates language L.Proof: Denning, Section 8.4, using traverse sets
CFL only if PDA; CFL -> PDA
Given a CFL, L, generated by grammar G, we can build a PDA, M, which recognizes language L.Proof: Denning, Section 8.3
Proof: CFL -> PDA
Since L is context free, there is a context free grammar, G = (N,T,P,S) that generates L.Construct the PDA, M=(Q,T,U,P’,q0,{q3}), as follows: T = same input alphabet U = N T {S} = stack alphabet Q = {q0,q1,q2,q3} {qx | x U}
Program of M
q0: , push($), goto q1q1: , push(S), goto q2q2: , pop($), goto q3For each production A->wq2: , pop(A), goto qAqA: , push(wR), goto q2For each terminal symbol aq2: a, NOP, goto qaqa: , pop(a), goto q2
Example: L = {0k1k | k 0}
Grammar G has productions:SA; A01; A0A1
push $ push Spop S
push A
pop A
push 1
push 0push A
push 0
pop $
in 0
pop 0 in 1pop 1
Ex 2: L={0j1k2j+k| j,k > 0}
SA; A0A2; A0B2; B12; B1B2