pumping lemma (context-free languages)
Let be a context-free language (a.k.a. type 2 language). Then there existtwo integers and such that, if the length of a word is greaterthan , then where are subwords such that
- 1.
The length of the subword is less than .
- 2.
is not be empty.
- 3.
For all integers , it is the case that belongs to ,where exponentiation denotes repetition of a subword times.
An important use of this lemma is that it allows one to show that a languageis not context-free. (Remember, just because a language happens to be describedin terms of a context-sensitive grammar does not automatically preclude thepossibility of describing the same language also by acontext-free language.) The idea is to assume that the language iscontext-free, then arrive at a contradiction via this lemma.
As an illustrative example, consider the following language, which consists ofbut one terminal symbol, ‘x’ and which consists of all strings of ‘x’ ’s whoselength is a perfect square. Were this a context-free language, there wouldexist integers and as above. Choose an integer such that .Then the word belongs to our language and the lemma tells us thatit can be written as so as to satisfy the conditions enumerated above.Write , , , , for suitable nonnegative integers . Then we have ;by condition , and, by condition , wouldhave to be a perfect square because would be a word of thelanguage. This, however, leads to a contradiction: could not possibly be a perfect square for all unless .
As an exercise, the reader may consider constructing a context-sensitivegrammar for this language and posting it as an attachment to this entry(at which time this sentence will come down).