Homework Assignment 8 for Chapter 8
Total Page:16
File Type:pdf, Size:1020Kb
CS373 – Fall 2003 – NMG ******* **********Solutions ************* 11/5/2003 Homework Assignment 8 for chapter 8 Due 11/10/02 (Monday)
Problems related to chapter 8: In any problem involving the pumping lemma you must strictly follow the “game against an adversary” approach, show all steps, and all cases, the pumped string must be convincingly described. In addition you may assume that the language {anbn : n 0 } (frequently discussed in the text) is context free. Maximum number of points: 100
P1: (15 points) Without making recourse to grammars defining L directly, show that L = {aibjck : i j or i k or j k } is context free. You may use grammars to show that other ancillary languages (other than L) are CF.
$Answer: L = {aibjck : i j, k 0 } {aibjck : i k, j 0 } {aibjck : j k, i 0 } The first language of the union is the concatenation of {aibj : i j } which is CF (see below), with {ck : k 0 } which is CF because it is regular. Thus the first language is CF because CFL’s are closed under concatenation. The third language can be shown to be CF by a similar argument. As for the n second language, we note that it may be written as: L1L2 L2L3 where L1 = {a : n 1}, n m n n L2 = {a b c : n, m 0 }, and L3 = {c : n 1}. Again L1 and L3 are regular hence CF, and L2 is CF (see below). Consequently the second language is CF because of closure of CF’s under intersection and union. Finally L is CF because CF because CFL’s are closed under union. QED. Verifications of claims made above: {ai bj : i j} is CF: it is defined by a CF grammar: S aSb | A | B, A aA | a, B Bb | b. n m n L2 = {a b c : n, m 0 } is CF: it is defined by a CF grammar: S aSc | a, A Ab | b.
P2: (15 points) Show that the language: L = { ai bj ai bj : i, j 0 } is not context free.
$Answer: Abbreviated proof: Opponent gives m > 0 We choose w = am bm am bm L and |w| m We can use three cases: I vxy is all a’s or all b’s II vxy is such that v is all a’s and y is all b’s from the 1st field of a’s and b’s or v is all a’s and y is all b’s from the 2nd t field of a’s and b’s III v or y have mixtures of two symbols.
For I, pumping will make the number of a’s in the first field of a’s different from the number in the second field of a’s. the same argument holds for the two fields of b’s.
For II, A similar same argument can be made as in I. For III, we would get b’s before a’s etc.
In all cases the word is pumped out of the language. QED P3: (15 points) Prove that the language L = {ww : w {a, b}* } is not context free without using the pumping lemma. You may use any results derived in this assignment as a “given”.
$Answer: Assume L is context free. Then by theorem 8.5 in Linz, (intersection of context free with regular language is context free) we have: L a*b*a*b* = { ai bj ai bj : i, j 0 } is context free. But we already proved that { ai bj ai bj : i, j 0 } is not context free– a contradiction. Thus L must not be context free. QED. P4: (20 points) Using the pumping lemma, prove that the following language L = { anbj : n (j-1)3 } on ={a, b, c} is not context free. All details must be shown, including details of inequality manipulations.
$Answer: Problem P3 - Part 2 Problem P3 - Part 3
Cases d and e are when the pumped strings v and y overlay the fields of a’s and b’s . In this case pumping up will cause the format (a’s come before b’s) to be violated and hence resulting in the pumped string not being in L. P5: (20 points) Use the CF pumping lemma to prove that the following language: L = { anbjck : k = jn} on ={a, b, c} is not context free.
$Answer: P6: (15 points) Prove that the language
L = { w : na(w) > nb(w) } on ={a, b, c} is not linear. Justify all assumptions. Note that the inequality is strict.
$Answer: Note … uses “>” instead of “”
Use pumping lemma for linear languages: Given m Choose w = am+1b2mam L = uvxyz where |uvyz| m and |vy| 1 Let j = |v| and k = |y| Pumping down: V ia all a’s and y is all b’s
m+1-j 2m m-k w0 = a b a for w0, na(w) = 2m+1-L 2m = na(w), where L = j + k 1 since both j and k cannot both be 0 this contradicts the requirement that na(w) > nb(w) thus w0 L ==> L is not linear.
Solution to a similar problem that may be more familiar to some:
L = { w : na(w) nb(w) } on ={a, b, c} … uses “” instead of “>” is not linear. Justify all assumptions.
Use pumping lemma for linear languages: Given m Choose w = amb2mam L = uvxyz where |uvyz| m and |vy| 1
Let j = |v| and k = |y| Pump down: V ia all a’s and y is all b’s
m-j 2m m-k w0 = a b a for w0, na(w) = 2m-j-k < 2m since both j and k cannot both be 0 thus w0 L ==> L is not linear.