All regular languages have a property that proves that they are regular.
Example:
- C = \{ w | w \text{ has an equal number of 0s and 1s} \} \\~\\
- D = \{ w | w \text{ has an equal number of occurrences of 01 and 10 as substrings } \}
Observations:
- C is not regular
- D is regular
Layperson’s:
- If a language is regular, it can recognize an infinite set of strings.
- If machine can’t loop, it’ll run out of states.
- Thus, to accept infinite-length strings, you need a repeating portion (the pumped portion).
If A is a regular language, then there is a number p (the pumping length) where if |s| \ge p, then s may be divided into three pieces, s=xyz, satisfying the following conditions:
Observations:
Remember: Pumping Lemma is used to prove a language is NOT regular.
- It cannot be used to prove that a language is regular.
- We do proof by contradiction because it’s much harder to prove nonexistence; that we cannot make an NFA that recognizes a language.
- e.g., “All classrooms contain a Unicorn” can be proven wrong by just finding one classroom without a Unicorn
How-to Use Pumping Lemma:
Remember: Don’t give p a concrete value!
Related Notes: Proof by Contradiction (CS1300)
Q: Is L = \{ a^n b^n | n \ge 0 \} regular?
A:
Assume L is regular so pumping lemma applies on L
Let p be the pumping length, then any string in L where |s| \ge p, there exists strings x, y, z such that s = xyz and:
Consider the string a^p b^p, s \in L and |s| \ge p
Looking at condition 3, we can smartly see that the maximum we can cut is up to middle of our string, as |a^p| = p, so cutting any further would violate condition 3.
Thus, xy can only contain zero or more a’s
But/further, from condition 2, y can only contain one or more a’s.
Let’s consider condition 1 when i=0.
Note: If a language is finite (e.g., \{ a^n b^n | n \le 7 \}), it is a regular language because a DFA can clearly be made.