Examples Using the Pumping Theorem for Context-free Languages
Learn the formal statement of the pumping theorem for CFLs and explore some example applications to prove that a language is not context-free.
Just as with regular languages, we can use this pumping theorem to show that a language is not context-free. The “rules of the game” are the same as for the pumping theorem for regular languages: we get to choose any qualifying string, but then we must show that there is no possibility of satisfying this pumping theorem. As usual, if a language is “pumpable”, we can draw no conclusions—the language may or may not be context-free.
Example 1
The language is not context-free. If it were, we could partition the string into five substrings, , such that also has runs of equal size of each letter. Since , there are five cases to consider:
- The variable appears wholly within the initial run of ’s. In this case, as and are pumped, the number of ’s increases while the number of the other letters doesn’t change, failing the pumping theorem.
- The variable contains both ’s and ’s. We may assume that