The Pumping Lemma for Regular Languages
Topics
- Purpose of this unit
- Proof of Pumping Lemma
- Example illustrating proof of Pumping Lemma
- The Pumping Lemma (version 1)
- The Pumping Lemma (version 2)
- Application of the Pumping Lemma to prove the set of
palindromes is not regular
(long commented version)
- Application of the Pumping Lemma to prove the set of
palindromes is not regular
(short uncommented version)
- Application of the Pumping Lemma to prove the set of
squares is not regular
(long commented version)
- Application of the Pumping Lemma to prove the set of
squares is not regular
(short uncommented version)
Content
- Purpose
- Our main goal is to prove a fact about all
infinite regular languages that will be helpful
in proving that specific languages are nonregular.
- In particular, this pumping lemma will be the main
method we use to prove specific languages are not regular.
- Proof of Pumping Lemma
Click here for
an illustration of the proof
applied to a specific language L)
- Pumping Lemma proof applied to a specific example language
- Statement 1 of Pumping Lemma
- Let L be any infinite regular language.
- There exists a number n with the following property.
- All strings x in L with length at least n,
x
can be represented as the concatenation of three
strings uvw where:
- |uv| has length at most n
- |v| has length at least 1
- strings of the form
uvkw are in L for all k
0.
- Two Questions about Statement 1 of Pumping Lemma
- Statement 2 of Pumping Lemma
- Let L be any infinite regular language.
- There exists an FA M with n states such that
L(M) = L.
- All strings x in L with length at least n
can be decomposed into a prefix x' of length n
and a suffix x'' of length |x| - n.
- The prefix x' can be decomposed into the concatenation
of three strings u, v, and w with
the following properties:
- |v| > 0.
- All strings of the form
uvkwx'' are in L for all k
0.
- Proof that L = set of all palindromes is not regular
(long commented version).
- We first note that L is infinite.
- We now assume that L is regular.
- COMMENT: We will derive a contradiction and thus be able to conclude
this assumption to be false.
- We now apply the Pumping Lemma to L.
- COMMENT: We can do so since it satisifies the two preconditions of
being infinite and regular.
- Step 1: there exists an FA M with
n = |Q| > 0 states such that L(M) = L.
- COMMENT: Note we cannot specify any specific number n but
must reason with n as a variable.
- COMMENT: The only fact we can assume about n is that it
is a finite integer.
- Step 2: Consider the string x =
anban in L.
- COMMENT: Note we are using our knowledge of the language L to claim
this string is in L.
- COMMENT: Step 2 of choosing the correct string to work with
is often the crucial step of Pumping Lemma proofs of nonregularity.
- COMMENT: This string x will always be a function of n
from Step 1.
- Step 3a: We can decompose anban
into a prefix an and a suffix
ban.
- Step 3b: By the Pumping Lemma, the prefix an can be
decomposed into the concatenation of three strings u,
v, and w with the following two properties:
- |v| > 0
- uvkwban is in L for all k
0.
- COMMENT: Note at this point we do cannot state what exactly u
v and w are.
- Question 3: How many different possibilities
for u,v,w are there?
- COMMENT: Note also, though, that we do know that by our choice
of x (and thus x'), we know that u,v,w
consist only of a's.
- COMMENT: Indeed, this is why we chose anban
instead of something like an/2ban/2.
- Step 4: Consider the string s = uwban where k = 0.
- COMMENT: Step 4 of choosing the value of k to use is the second
crucial step of Pumping Lemma proofs.
- Step 5: Deriving a contradiction
- Step 5a: The string uw must consist of exactly n a's.
- Note s has only one b, so in order for s
to be in L, it must be the case that b is in
the middle of s.
- We already know that there are n a's following
the one b.
- COMMENT: Note in proving Step 5a, we used arguments specific
to L and s.
- Step 5b: There string uw has less than n a's
- uvw was a string consisting of exactly n a's.
- COMMENT: Knowledge specific to the string x.
- From the Pumping Lemma, we know that v contains
at least one a.
- COMMENT: This is where we utilize the Pumping Lemma.
- Thus the string uw has fewer than n a's.
- Steps 5a and 5b lead us to a contradiction.
- COMMENT: In many proofs, we need to consider several cases
for how u, v, and w may have been
broken up and we need to show EACH of these cases leads to
a contradiction.
- COMMENT: In this example, the one analysis applied to all
possible choices of u,v,w and thus we need only
one argument.
- COMMENT: If we had chosen x =
an/2ban/2,
we would have had to consider different cases such as
- v consists only of a's before the b
- v consists only of a's after the b
- v consists of a's followed by b
- v consists of b followed by a's
- v consists of a's followed by b
followed by a's
- v consists only of b
- COMMENT: Furthermore, the proof would have been incorrect since
we could choose v to be just b and in this case
no contradiction could be derived.
- Step 6: Thus our initial assumption that L is regular must be false.
- Step 7: Thus we conclude that L, the set of all palindromes, is not
regular.
- Proof that L = set of all palindromes is not regular
(short uncommented version).
- We first note that L is infinite.
- We now assume that L is regular.
- We now apply the Pumping Lemma to L.
- Step 1: there exists an FA M with
n = |Q| > 0 states such that L(M) = L.
- Step 2: Consider the string x =
anban in L.
- Step 3a: We can decompose anban
into a prefix an and a suffix
ban.
- Step 3b: By the Pumping Lemma, the prefix an can be
decomposed into the concatenation of three strings u,
v, and w with the following two properties:
- |v| > 0
- uvkwban is in L for all k
0.
- Step 4: Consider the string s = uwban where k = 0.
- Step 5: Deriving a contradiction
- Step 5a: The string uw must consist of exactly n a's.
- Note s has only one b, so in order for s
to be in L, it must be the case that b is in
the middle of s.
- We already know that there are n a's following
the one b.
- Step 5b: There string uw has less than n a's
- uvw was a string consisting of exactly n a's.
- From the Pumping Lemma, we know that v contains
at least one a.
- Thus the string uw has fewer than n a's.
- Steps 5a and 5b lead us to a contradiction.
- Step 6: Thus our initial assumption that L is regular must be false.
- Step 7: Thus we conclude that L, the set of all palindromes, is not
regular.
- Proof that L = {ai2 | i
0}
is not regular (long commented version).
- We first note that L is infinite.
- We now assume that L is regular.
- COMMENT: We will derive a contradiction and thus be able to conclude
this assumption to be false.
- We now apply the Pumping Lemma to L.
- COMMENT: We can do so since it satisifies the two preconditions of
being infinite and regular.
- Step 1: there exists an FA M with
n = |Q| > 0 states such that L(M) = L.
- COMMENT: Note we cannot specify any specific number n but
must reason with n as a variable.
- COMMENT: The only fact we can assume about n is that it
is a finite integer.
- Step 2: Consider the string x =
an2 in L.
- COMMENT: Note we are using our knowledge of the language L to claim
this string is in L.
- COMMENT: Step 2 of choosing the correct string to work with
is often the crucial step of Pumping Lemma proofs of nonregularity.
- COMMENT: This string x will always be a function of n
from Step 1.
- Step 3a: We can decompose an2
into a prefix an and a suffix
an2-n.
- Step 3b: By the Pumping Lemma, the prefix an can be
decomposed into the concatenation of three strings u,
v, and w with the following two properties:
- |v| > 0
- uvkwan2
- n is in L for all k
0.
- Step 4: Consider the string s = uv2wan2
- n
where k = 2.
- COMMENT: Step 4 of choosing the value of k to use is the second
crucial step of Pumping Lemma proofs.
- Step 5: Deriving a contradiction
- Step 5a: The string s = uv2wan2
- n must consist of at least
(n+1)2 a's.
- Note s has more characters than x did since we
chose k = 2.
- Since s must be in L, it must get to the "next"
string in L which means it must have at least
(n+1)2 a's.
- COMMENT: Note in proving Step 5a, we used arguments specific
to L and s.
- Step 5b: There string s has less than (n+1)2
a's
- String v has at most n a's.
- COMMENT: From the Pumping Lemma.
- String x has exactly n2 characters.
- COMMENT: specific knowledge about the string x.
- Thus the string s has at most n2 + n
< (n+1)2 a's.
- COMMENT: specific mathematical knowledge.
- Steps 5a and 5b lead us to a contradiction.
- COMMENT: In many proofs, we need to consider several cases
for how u, v, and w may have been
broken up and we need to show EACH of these cases leads to
a contradiction.
- Step 6: Thus our initial assumption that L is regular must be false.
- Step 7: Thus we conclude that L, the set of all palindromes, is not
regular.
- Proof that L = {ai2 | i
0}
is not regular (short uncommented version).
- We first note that L is infinite.
- We now assume that L is regular.
- We now apply the Pumping Lemma to L.
- Step 1: there exists an FA M with
n = |Q| > 0 states such that L(M) = L.
- Step 2: Consider the string x =
an2 in L.
- Step 3a: We can decompose an2
into a prefix an and a suffix
an2-n.
- Step 3b: By the Pumping Lemma, the prefix an can be
decomposed into the concatenation of three strings u,
v, and w with the following two properties:
- |v| > 0
- uvkwan2
- n is in L for all k
0.
- Step 4: Consider the string s = uv2wan2
- n
where k = 2.
- Step 5: Deriving a contradiction
- Step 5a: The string s = uv2wan2
- n must consist of at least
(n+1)2 a's.
- Note s has more characters than x did since we
chose k = 2.
- Since s must be in L, it must get to the "next"
string in L which means it must have at least
(n+1)2 a's.
- Step 5b: There string s has less than (n+1)2
a's
- String v has at most n a's.
- String x has exactly n2 characters.
- Thus the string s has at most n2 + n
< (n+1)2 a's.
- Steps 5a and 5b lead us to a contradiction.
- Step 6: Thus our initial assumption that L is regular must be false.
- Step 7: Thus we conclude that L, the set of all palindromes, is not
regular.
- Answers to all four questions.
Regular Languages Chapter (up one level)
Table of Contents (up two levels)