0% found this document useful (0 votes)
104 views13 pages

Pumping Lemma For RG

The document introduces the Pumping Lemma, a tool used to prove that a language is not regular. It explains that the Pumping Lemma states that for any regular language, there exists a pumping length p such that any string of at least p characters can be broken into three parts xyz meeting certain conditions. Examples are provided to demonstrate how to use a proof by contradiction with the Pumping Lemma to show languages are not regular. The general form of such a proof is outlined.

Uploaded by

mainakroni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views13 pages

Pumping Lemma For RG

The document introduces the Pumping Lemma, a tool used to prove that a language is not regular. It explains that the Pumping Lemma states that for any regular language, there exists a pumping length p such that any string of at least p characters can be broken into three parts xyz meeting certain conditions. Examples are provided to demonstrate how to use a proof by contradiction with the Pumping Lemma to show languages are not regular. The general form of such a proof is outlined.

Uploaded by

mainakroni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

The Pumping Lemma

For Regular Languages


Proof that Computer Scientists should not be
allowed to come up with names for anything. Ever.
A Quick Perspective

How do we How do we
prove that a prove that a
Language is Language is
Regular? NOT Regular?
Examples of Nonregular Languages
● B = {0n1n | n ≥ 0}
● C = {w|w has an equal
number of 0s and 1s} OOPS!
● D = {w|w has an equal
number of occurrences of 01 D is Regular!!!!
and 10 as substrings.} Intuition may be wrong.
The Pumping Lemma
We need a tool to prove that a
language is NOT Regular.

Intuition: There is a property Question: What is the longest string that can be
that ALL Regular Languages generated by this FSM?

have. If a Language can be Question: What is the longest string that can be
generated by this FSM (stopping when a loop is
shown to NOT have this formed in the δ transitions)?
property, then that Language is Answer: 3 characters
NOT Regular. (3 transitions: q1➝q2➝q3➝q2)
Important Ideas/Definitions
Pumping
Repeating a section of the string an
arbitrary number of times (≥0), with
the resulting string remaining in the
language. Intuitive Examples:
101
Pumping Length ⇒ 1(01)*
“All string in the language can be
000001
pumped if they are at least as long as ⇒ (0)*00001
a certain special value, called the
110100
pumping length.”
⇒ 1(1)*0100
Pumping Lemma (for Regular Languages)
If A is a Regular Language, then there is a number p (the
pumping length) where if s is any string in A of length at least p,
then s may be divided into 3 pieces, s = xyz, satisfying the
following conditions:

a. For each i ≥ 0, xy iz ∈ A,
b. |y| > 0, and
c. |xy| ≤ p.
Pumping Lemma (RL) Proof
Let M = (Q, Σ, δ, q1, F) be a DFA recognizing A and Because rl occurs among the first p + 1 places in a
p be the number of states of M. sequence starting at r1, we have l ≤ p + 1.

Let s = s1s2...sn be a string in A with length n, where Now let x = s1...sj-1, y = sj...sl-1, and z = sl...sn.
n ≥ p.
As x takes M from r1 to rj , y takes M from rj to rl ,
Let r1,...,rn + 1 be the sequence of states M enters and z takes M from rl to rn+1, which is an accept
when processing s. ri + 1 = δ(ri , si ) for 1 ≤ i ≤ n. The state, M must accept xy iz for i ≥ 0.
sequence has length n+1, which is at least p + 1.
We know j ≠ l, so |y| > 0; and l ≤ p + 1, so |xy| ≤ p.
Among the first p + 1 elements in the sequence,
two must be the same state, via the pigeonhole Thus, we have satisfied all conditions of the
principle. The first is called rj , and the second is rl . pumping lemma.
Example applications of the Pumping Lemma (RL)
B = {0n1n | n ≥ 0} Because s ∈ B and |s| ≥ p, PL guarantees s can be
split into 3 pieces, s = xyz, where for any i ≥ 0,
Is this Language a Regular Language? xy iz ∈ B. Consider 3 cases:
● If Regular, build a FSM
● If Nonregular, prove with Pumping 1. y is only 0s. xyyz has more 0s than 1s, thus a
Lemma contradiction via condition 1 of PL.
2. y is only 1s. Also a contradiction.
Proof by Contradiction: 3. y is both 0s and 1s. xyyz may have same
Assume B is Regular, then Pumping Lemma number of 1s and 0s, but will be out of order,
with some 1s before 0s, also a contradiction.
must hold.
Contradiction is unavoidable, thus B is not Regular.
p is the pumping length given by the PL.
(Could simplify with condition 3 of PL).
Choose s to be 0p1p.
Example applications of the Pumping Lemma (RL)
C = {w | w has an equal number of 0s and 1s} Because s ∈ C and |s| ≥ p, PL guarantees s can be
split into 3 pieces, s = xyz, where for any i ≥ 0,
Is this Language a Regular Language? xy iz ∈ C.
● If Regular, build a FSM
● If Nonregular, prove with Pumping Condition 3 (|xy| ≤ p) keeps us from setting x and z
Lemma to ε, because then |y| would be greater than p.

Because |xy| ≤ p, y must be only 0s. xyyz is not in the


Proof by Contradiction:
language because then the string would contain
Assume C is Regular, then Pumping Lemma
more 0s than 1s. This is a contradiction.
must hold.
Contradiction is unavoidable, thus C is not Regular.
p is the pumping length given by the PL.
Note: (01)p is a bad choice, because it can be pumped.
Choose s to be 0p1p.
Example applications of the Pumping Lemma (RL)
F = {ww | w ∈ {0,1}*} Because s ∈ F and |s| ≥ p, PL guarantees s can be
split into 3 pieces, s = xyz, where for any i ≥ 0,
Is this Language a Regular Language? xy iz ∈ F.
● If Regular, build a FSM
● If Nonregular, prove with Pumping Because |xy| ≤ p, y must be only 0s. xyyz is not in the
Lemma language because the string will no longer be in the
form ww.
Proof by Contradiction:
Contradiction is unavoidable, thus F is not Regular.
Assume F is Regular, then Pumping Lemma
must hold. (Notice the importance of Condition 3 of PL, which
keeps x and z from both being ε).
p is the pumping length given by the PL.

Choose s to be 0p10p1. (Note: 0p0p is a bad choice.)


Example applications of the Pumping Lemma (RL)
E = {0i1j | i > j } Because s ∈ E and |s| ≥ p, PL guarantees s can be
split into 3 pieces, s = xyz, where for any i ≥ 0,
Is this Language a Regular Language? xy iz ∈ E.
● If Regular, build a FSM
● If Nonregular, prove with Pumping Because |xy| ≤ p, y must be only 0s.
Lemma
There is only one more 0 than 1s.
Proof by Contradiction: We can pump down y to get xy0z = xz.
Assume E is Regular, then Pumping Lemma
must hold. The number of 0s in xz is less than or equal to the
number of 1s, and is therefore not in the language.
p is the pumping length given by the PL.
Contradiction is unavoidable, thus E is not Regular.
p+1 p
Choose s to be 0 1.
General Form of a Proof by Contradiction with the PL
Assume that a Language L is Regular, then For all possible values of y (given the conditions of
Pumping Lemma must hold. the Pumping Lemma), show that pumping xyiz is
not in the Language.
Define p to be the pumping length given by the
Pumping Lemma. Contradiction is shown for all cases, proving that L
is not a Regular Language.
Choose s (often in terms of p).
Notes:
Because s ∈ L and |s| ≥ p, PL guarantees that s can ● Choosing a s that can be pumped proves
be split into 3 pieces, s = xyz, where for any i ≥ 0, nothing.
xy iz ∈ L. ● Sometimes finding an appropriate s is the
hard part.
Tools to prove that a Tools to prove that a
Language is Regular: Language is Nonregular:

DFA
NFA The Pumping Lemma
GNFA
Regular Expression

You might also like