70 likes | 290 Views
CS310. Non-Context-Free Languages Sections: 2.3 page 123 October 20, 2006. Pumping Lemma (take two). Theorem: For any CFG there is an equivalent grammar in CNF. Pumping lemma (CFG): Suppose A is a CFG. There exists a number p such that if s A and |s| p then s = udxyz where
E N D
CS310 Non-Context-Free Languages Sections: 2.3 page 123 October 20, 2006
Pumping Lemma (take two) • Theorem: For any CFG there is an equivalent grammar in CNF. • Pumping lemma (CFG): Suppose A is a CFG. There exists a number p such that • if s A and |s| p then s = udxyz where udixyiz A, i 0 |dy| > 0 |dzy| p Note: Your book uses uvxyz But, capital V is the set of variables for the grammar so that can get confusing
Pumping a Parse Tree T | R | R T | R | R | R u d x y z u d y z d x y ud1xy1z ud2xy2z
Proof • Suppose A is a CFG in CNF and s A, |s| p = 2 |V|+1 2 because the language is in CNF and that produces a binary parse tree The height of the parse tree for s is V+1, so we have used the same variable twice! Therefore, the string can be pumped.
Example • L = {aibici | i 0} • a PDA cannot represent this. Why? • Pumping Lemma: s = apbpcp |dxy| p What may dxy contain? What happens when we pump d and y?
Example • L = { ww | w {0, 1}* } s =
Example • L = { w # x | w is substring of x; w,x {0, 1}* }