Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping.

Similar presentations


Presentation on theme: "1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping."— Presentation transcript:

1 1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping theorem, factor in all ways as u v x y z such that |v| +|y| ≥ 1 and for each case, argue that u v n x y n z is not in L for some n.

2 2 The Pumping Theorem for Context-Free Languages: Let G be a context-free grammar. Then there exists some constant k which depends on G such that for any string w which is generated by G with |w| ≥ k, there exists u, v, x, y, z, such that 1. w= u v x y z, 2. |v| + |y| ≥ 1, and 3. u v n x y n z is in L for all n ≥ 0.

3 3 Assignment #4 has been posted, due on Friday Nov. 18, beginning of class. No tutorials this week. You can go and ask questions next week if you need help, but you are not expected to attend. Some old final exams are posted. Our final is very early in the exam schedule- keep up?

4 4 Closure Properties: We have constructions that use the context-free grammars proving that contex-free languages are closed under union, concatenation and Kleene star. We have a construction that uses a PDA and a DFA that proves that context-free languages are closed under intersection with regular languages.

5 5 Intersection: L 1 = { a n b n c p : n, p ≥ 0} L 2 = { a n b p c n : n, p ≥ 0} What is L 1 ∩ L 2 ?

6 6 Exclusive OR: L 1 = a* b* c* L 2 = { a p b q c r : p≠ q or p ≠ r or q≠r } What is L 1  L 2 ?

7 7 Difference: L 1 = a* b* c* L 2 = { a p b q c r : p≠ q or p ≠ r or q≠r } What is L 1  L 2 ?

8 8 L = { a n b n c n : n ≥ 0} L 1 = { a p b q c r : p ≠ q } L 2 = { a p b q c r : p ≠ r } L 3 = { a p b q c r : q ≠ r } The complement of L is NOT equal to L 1 ⋃ L 2 ⋃ L 3. Which strings are in the complement of L but not in L 1 ⋃ L 2 ⋃ L 3 ?

9 9 L = { a n b n c n : n ≥ 0} L 1 = { a p b q c r : p ≠ q } L 2 = { a p b q c r : p ≠ r } L 3 = { a p b q c r : q ≠ r } L 4 = { w  {a, b, c}* : w ∉ a* b* c*} L 1 ⋃ L 2 ⋃ L 3 ⋃ L 4 is context-free and is the complement of L. Therefore, context-free languages are not closed under complement.

10 10 Theorem: L= { a p : p is a prime number} is not context-free. Theorem: L= { a n 2 : n ≥ 0} is not context-free. Note: if L is a language defined over a one symbol alphabet and you can prove L is not regular using the pumping lemma, then it also means that L is not context-free.

11 11 Theorem: L= { a p : p is a prime number} is not context-free. Assume L is context-free and is generated by a context-free grammar G. Then there exists some constant k dependent on G such that for all strings w in L of length at least k the Pumping Theorem holds. Choose w= a p for some prime number p ≥ k.

12 12 Factor a p in all ways as u v x y z: w = a i a j a r a s a t where p= i + j + r + s + t, j + s ≥ 1, v=a j and y= a s. Pumping n+1 times yields: a i (a j ) n+1 a r (a s ) n+1 a t = a i a r a t (a j ) n+1 (a s ) n+1 = a p-j-s + (j+s)(n+1) Let x= j+s. Pumping n+1 times yields: a p+xn

13 13 w = a i a j a r a s a t Let x= j+s. Pumping n+1 times yields: a p+xn Pump p+1 times: Gives a p+xp = a p(x+1) Since x  1, (x+1)  2 and so p (x+1) Cannot be prime.

14 14 Theorem: L= { a n 2 : n ≥ 0} is not context-free. Note: if L is a language defined over a one symbol alphabet and you can prove L is not regular using the pumping lemma, then it also means that L is not context-free.


Download ppt "1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping."

Similar presentations


Ads by Google