...

/

Examples Using the Pumping Theorem for Context-free Languages

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 anbncna^nb^nc^n is not context-free. If it were, we could partition the string apbpcpa^pb^pc^p into five substrings, uvxyzuvxyz, such that uvixyizuv^ixy^iz also has runs of equal size of each letter. Since vxyp|vxy| \leq p, there are five cases to consider:

  1. The variable vxyvxy appears wholly within the initial run of aa’s. In this case, as vv and yy are pumped, the number of aa’s increases while the number of the other letters doesn’t change, failing the pumping theorem.
  2. The variable vxyvxy contains both aa’s and bb’s. We may assume that
...
Access this course and 1400+ top-rated courses and projects.