Pumping Lemma For RG
Pumping Lemma For RG
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.
DFA
NFA The Pumping Lemma
GNFA
Regular Expression