Search⌘ K

Examples Using the Pumping Theorem for Context-free Languages

Explore how to apply the pumping theorem for context-free languages by examining examples such as a^nb^nc^n and others. Understand how to choose strings, analyze substrings, and recognize why certain languages fail to be context-free, gaining practical skills in formal language theory.

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 vxy=akbm,m+kpvxy=a^kb^m, m+k\leq p. In this case, the number of aa’s and/or bb’s changes, but the cc’s do not change, again failing the pumping theorem.
  3. The variable vxyvxy appears wholly within the run of bb's. In this case, as vv and yy are pumped, the number of bb’s increases while the number of the other letters doesn’t change, failing the pumping theorem, as in case 1 above.
  4. The variable vxyvxy contains both
...