You are on page 1of 2

Examples of proofs that a language is non-context-free

1. L = {an bn cn | n 0} By contradiction, we assume that the language is context free and there exists a pumping length p. Then to show that the language is not context-free, we need to nd a string s L with |s| p on which the pumping lemma fails. Because this language is so structured, in this case any choice of s would violate the pumping lemma. Choose, for instance, s = ap/2 bp/2 cp/2 . The fact that we can modify the string according to the pumping lemma only in two places means that we either arrive at a string where the number of as, bs, and cs dont match, or the characters are out of order. In general, for a partitioning s = uvxyz, we have the following cases: (a) If both v and y contain only one type of alphabet character, uv 2 xy 2 z will modify the number of instances of at most two types of characters meaning that there is imbalance of them and the resulting string is no longer in the language. (b) If either v or y contain more than one type of alphabet character, the string uv 2 xy 2 z will contain the characters out of order and thus is no longer in the language. The above two cases cover all possibilities for v and y and thus the pumping lemma fails for all possible partitionings of s into uvxyz. We arrive at a contradiction, which means that our initial assumption that the language is context-free is not true. 2. L = {0n #02n #03n | n 0} As usual, assume that L is context-free and there exists a pumping length p. The string s = 0p #02p #03p seems to be a natural choice for showing that the pumping lemma fails. When we partition s as uvxyz, we have the following cases: (a) Either v or y contain #. In this case uv 2 xy 2 z has more than two #s and thus the string is not in the language. (b) The second option is that v and y only contain 0s. We partition all 0s from s into three segments: the rst 0p , the middle 02p and the last 03p . According to the third condition of the pumping lemma, the length of vxy is at most p. This means that v and y can contain 0s from at most two segments and pumping the string up to uv 2 xy 2 z will violate the 1:2:3 ratio of 0s (and the string is no longer in the language). One of the above options must happen, and thus the pumping lemma fails on all partitionings of s. 3. L = {an bm an | n, m 0 and n m} As with other cases where string membership in a language is specied by a range constraint, it might be the easiest to choose s to be at the boundary of that constraint (i.e., there are languages where the only strings that cannot be pumped are those at the boundary, while for other languages s doesnt have to be at the boundary to show that the pumping lemma fails). For this language, all strings at the boundary case fail the pumping lemma, other strings from the language fail the pumping lemma when m is suciently large (at least p 1). Let s = ap bp ap . Because of the constraint |vxy| p, we have only the following choices for partitioning s into uvxyz:

(a) v or y contain at least one a from the rst block of as: pumping up or down in this case results in a mismatch with the second block of as since none of as from the second block can be in v or y. (b) v or y contain at least one a from the last block of as: similar to the above case (v or y cannot reach the as in the beginning of the string). (c) v and y are contained within the bs: pumping up will result in violating the n m constraint since the number of bs will exceed the number of as in each part (because |vy| > 0). Because the string cannot be pumped for all possible partitionings of s, the pumping lemma fails resulting in a contradiction. 4. L = {ww | w {a, b} } The intuition behind the fact that this language is not context-free is that a PDA can push its input onto the stack and later match the stack with another portion of the input only if the second part of the input is in the reverse order of whats been already processed (i.e., wwR is context-free). This means that when we choose a pattern for our s, the string w must be asymmetric. Furthermore, the same type of character in the rst and second ws must be at a sucient distance from each other, so that we wouldnt be able to change them simultaneously in the rst and second w using the pumping lemma. For example, strings s = ap bap b and s = ap/2 bp/2 ap/2 bp/2 can be pumped because the number of as in the rst and second w can be changed in a coordinated manner (to pump up and down). Thus, we instead choose s = ap bp ap bp . Using the restriction that |vxy| p in partitioning s = uvxyz, we have the following choices for v and y: (a) Both v and y are contained in the rst w: in this case uv 2 xy 2 z will have more characters among the rst group of as and bs and it is not possible to split it into two halves that are the same. (b) Both v and y are contained in the second w: similar to the above. (c) v and y cross the boundary of the rst and second ws: pumping up in this case will increase the number of bs in the rst block of bs and/or the number of as in the second block of as, and we are also unable to split the resulting string into exactly the same halves. Other choices for v and y are not possible in this case due to the constraint |vxy| p. In all cases pumping v and y up results in strings that are no longer in the language, and thus the pumping lemma fails. 5. L = {wtwR | w, t {a, b} and |w| = |t|} The idea here is that the power of context-free languages allows us to match w with wR or check that |w| = |t|, but not both. To choose a good s, rst observe that similar w and t with no pattern are not a good idea. Also, if t is symmetric, the pumping lemma is unlikely to fail on that string regardless of w. For example, s = ap bp ap cannot be used to show that the language is non-context-free, despite the fact that the middle portion is suciently long. Thus, we can choose s = ap bp ap bp bp ap . It is not dicult to see that if we pump up or down within any window of p characters in that string, the result will no longer be in the language.

You might also like