Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 22

Proving Non-Regularity with the Pumping Lemma

Recommended resources

Hello! Welcome back to our course on the theory of computation.

In our last lesson, we introduced the Pumping Lemma for Regular Languages. We established that because finite automata have a fixed number of states, they must enter a loop when processing any sufficiently long string. This fundamental property is captured by the Pumping Lemma, which we use in its contrapositive form: if a language cannot be "pumped" according to the lemma's rules, it cannot be regular.

Today, we transition from theory to application. You will learn how to apply the Pumping Lemma to construct a formal proof demonstrating that a given language is not regular. We will use a structured, step-by-step method that can be seen as a "game" against an adversary, where your goal is to force a contradiction. Our primary example will be the classic non-regular language .


1. The Proof by Contradiction Game Plan

To prove a language is not regular, we use proof by contradiction. The Pumping Lemma provides the perfect framework for this. Think of it as a game where you must show that the rules of the lemma can be broken for language .

Here is the game plan, which will be our template for every proof:

  1. Your Assumption: Assume, for the sake of contradiction, that is regular.
  2. Adversary's Move (The Lemma's Guarantee): Because is assumed regular, the Pumping Lemma must apply. The lemma guarantees that there exists a pumping length for . This is a specific integer, but we don't know its value—we just know it exists.
  3. Your Move (Strategic String Selection): You choose a specific string that is in and has a length of at least (). The success of the proof hinges on choosing a clever that exploits the structural weakness of the language.
  4. Adversary's Second Move (The Decomposition): The lemma guarantees that your chosen string can be divided into three parts, , satisfying three conditions:
    • (1) (The pumpable part is not empty).
    • (2) (The pumpable part occurs early in the string).
    • (3) For all , the string is in (You can pump and the result stays in the language).
      You don't get to choose how is split, but you know that however it's split, these three conditions must hold.
  5. Your Winning Move (Finding the Contradiction): You must show that for any possible way the adversary splits into (while respecting the conditions), you can find a value for (usually 0 or 2) such that the pumped string is not in .
  6. Checkmate: This contradicts condition (3) of the lemma. Since the Pumping Lemma's guarantee is broken, the only thing that could have been wrong was our initial assumption. Therefore, cannot be regular.

This adversarial framework is essential. Your proof must be robust enough to work no matter which valid decomposition the "adversary" (the lemma) provides.



2. Proof: is Not Regular

Let's apply our game plan to prove that the language of strings with some number of 's followed by the same number of 's is not regular. This is a canonical example because it captures the idea of "counting," which finite automata struggle with.

The following video provides a clear, step-by-step walkthrough of this exact proof. Watch how the presenter follows the logical structure we just outlined.

Pumping Lemma for Regular Languages Example: 0ⁿ1ⁿ

This video from the Easy Theory channel, titled 'Pumping Lemma for Regular Languages Example: 0ⁿ1ⁿ', will guide you through the formal proof structure. The logic is identical to our aⁿbⁿ example.

Please watch the entire video. Pay close attention to how the pumping length p is used to choose the string, how the condition |xy| ≤ p restricts the location of y, and how pumping y breaks the 'equal numbers' rule of the language.

Now, let's formalize the steps from the video in writing:

  1. Assumption: Assume is a regular language.

  2. Pumping Length: By the Pumping Lemma, there must exist a pumping length for .

  3. String Selection: We choose the string . This string is in (with ), and its length is , which is . This is a strategic choice because the number of 's and 's is tied to the pumping length .

  4. Decomposition: According to the Pumping Lemma, can be split into such that:

    • For all ,
  5. Case Analysis: Let's analyze what and must look like.

    • Our string is .
    • The condition forces the substring to be located within the first characters of .
    • The first characters of are all 's.
    • Therefore, both and must consist entirely of 's.
    • Furthermore, the condition tells us that contains at least one . So, we can say for some integer .
  6. Pumping and Contradiction: Let's choose and analyze the resulting string .

    • The original string had 's and 's.
    • The new string contains a second copy of . Since where , we have added extra 's.
    • The number of 's in is .
    • The number of 's is unchanged, so there are still 's.
    • The resulting string is . Since , .
    • This string is not in because the number of 's and 's is no longer equal.
  7. Conclusion: This is a contradiction. The Pumping Lemma guaranteed that would be in for any , but we showed that for , it is not. Our initial assumption must be false. Therefore, is not regular.

Test your understanding!

In step 6, we chose i=2. Would the proof also work if we chose i=0? What about i=1?

Show answer

Yes, the proof would work with i=0. The string would become xy⁰z = xz. Since y = a^k with k ≥ 1, removing y would result in the string a^(p-k)b^p. Because p-k ≠ p, this string is not in L, leading to the same contradiction.

The proof would not work with i=1. Pumping with i=1 gives the string xy¹z = xyz, which is our original string w. By definition, w is in L, so this choice leads to no contradiction. This is why you must always choose i ≠ 1.



3. A Second Example:

The proof structure is a recipe. To solidify your understanding, let's apply it to another language: the language of strings that consist of some non-empty string repeated twice. For example, 0101 is in (where ), but 0110 is not.

Your experience with algorithms and data structures makes it clear that checking for this property likely requires memory to store the first half (w) and compare it against the second half—something a finite automaton cannot do. Let's prove this formally.

3. Regular Pumping Lemma, Conversion of FA to Regular Expressions

Let's turn to this video from MIT OpenCourseWare. Professor Sipser provides a similarly rigorous proof for both {aⁿbⁿ} and {ww}. His explanation for {ww} highlights the critical importance of selecting the right string to pump.

Please watch from 50:42 to 58:26. The first part covers {aⁿbⁿ} (as 0^k1^k), which will reinforce what you just learned. The second part, starting at 54:25, applies the lemma to {ww} and explains why a naive choice of string won't work.

As Professor Sipser explains, the choice of string is crucial.

  • A naive choice like (i.e., ) fails. The string is . If we pump a section within the first half, the resulting string is still just a long string of zeros, which can be seen as for some new , so it's still in . No contradiction is reached.
  • A strategic choice is needed, one that breaks if we modify just one part. The choice is excellent. Here, .

Let's complete the proof for using :

  1. Assumption: Assume is regular.
  2. Pumping Length: Let be the pumping length.
  3. String Selection: Choose . This string is in and .
  4. Decomposition: can be split into with and .
  5. Case Analysis:
    • The string is .
    • Since , the substring must fall entirely within the initial block of zeros.
    • Therefore, must be a non-empty string of zeros: for some .
  6. Pumping and Contradiction: Let's pump with , creating .
    • We are adding zeros to the first block of zeros. The rest of the string is unchanged.
    • .
    • This string is no longer of the form . The first half up to the middle is , but the second half is . These are not equal. Thus, .
  7. Conclusion: We have a contradiction. Therefore, is not regular.

For a concise written version of these proofs, you can refer to the following lecture notes.

Lecture 9: Proving non-regularity

These UIUC lecture notes present the formal proofs we've discussed. Seeing the arguments in a compact, written format helps solidify the structure.

Please read sections 3.3.3 ('Proving that a language is not regular') and 3.4 ('Examples'). This will show you the 'recipe' and how it's applied concisely to both {aⁿbⁿ} and {ww}.



Conclusion

Today, we put the Pumping Lemma to work. We've established a robust, reusable framework for proving that a language is not regular. This method is a cornerstone of automata theory, providing a formal way to identify the limitations of finite-state machines.

Key Takeaways:

  • Proofs of non-regularity using the Pumping Lemma are structured as a proof by contradiction.
  • The process can be viewed as an adversarial game where you must show that for a strategically chosen string, any valid decomposition according to the lemma's rules can be "pumped" out of the language.
  • The two most powerful constraints you have are:
    1. Your choice of the string . It should be chosen to create a dependency (like counting) that is tied to the pumping length .
    2. The lemma's condition that , which severely restricts where the pumpable section can be located.
  • We successfully applied this framework to prove that and are not regular.

Preview of the Next Lesson:
Now that we have a tool to identify non-regular languages, we will turn our attention to the properties of the languages we know are regular. In the next lesson, we will explore the closure properties of regular languages. We will prove that if you take regular languages and apply operations like union, intersection, or complement, the result is still a regular language. This will give us another powerful set of tools for reasoning about languages and their complexity.