Non-regular languages
(Pumping Lemma)
Prof. Busch - LSU
1
{a b : n 0}
n n
Non-regular languages
{vv : v {a, b}*}
R
Regular languages
a *b
b*c a
b c ( a b) *
etc...
Prof. Busch - LSU
2
How can we prove that a language
is not regular?
L
Prove that there is no DFA or NFA or RE
that accepts L
Difficulty: this is not easy to prove
(since there is an infinite number of them)
Solution: use the Pumping Lemma !!!
Prof. Busch - LSU
3
The Pigeonhole Principle
Prof. Busch - LSU
4
4 pigeons
3 pigeonholes
Prof. Busch - LSU
5
A pigeonhole must
contain at least two pigeons
Prof. Busch - LSU
6
n pigeons
...........
m
pigeonholes
nm
...........
Prof. Busch - LSU
7
The Pigeonhole Principle
n pigeons
m
pigeonholes
nm
There is a pigeonhole
with at least 2 pigeons
...........
Prof. Busch - LSU
8
The Pigeonhole Principle
and
DFAs
Prof. Busch - LSU
9
Consider a DFA with
b
q1
4
states
b
b
a
q2
a
q3
a
Prof. Busch - LSU
b
q4
a
10
Consider the walk of a “long’’ string:
(length at least 4)
aaaab
A state is repeated in the walk of
q1
a
b
q1
q2
a
q3
a
q2
a
q3
q2
q4
b
b
a
b
aaaab
a
q3
a
Prof. Busch - LSU
b
a
q4
11
The state is repeated as a result of
the pigeonhole principle
Walk of
Pigeons:
(walk states)
q1
a
q2
a
q3
a
aaaab
q2
a
q3
b
q4
Are more than
Nests:
q1
(Automaton states)
q2
Repeated
state
Prof. Busch - LSU
q3
Repeated
state
q4
12
Consider the walk of a “long’’ string:
(length at least 4)
Due to the pigeonhole principle:
A state is repeated in the walk of
q1
a
b
q1
q2
a
q3
b
q4
b
q2
aabb
q4
b
b
a
aabb
a
a
q3
Prof. Busch - LSU
b
a
q4
13
The state is repeated as a result of
the pigeonhole principle:
Walk of
Pigeons:
q1
a
q2
a
q3
b
aabb
q4
b
q4
(walk states)
Are more than
Nests:
(Automaton states)
q1
q2
q3
Automaton States
Prof. Busch - LSU
q4
Repeated
state
14
In General: If | w | # states of DFA ,
by the pigeonhole principle,
a state is repeated in the walk w
Walk of w 1 2 k
q1 1
2 .... i q i 1 ....
i
j
qi
j 1.... k
qz
Arbitrary DFA
q1 1
k q
......
qi
z
Repeated state
2 ......
Prof. Busch - LSU
15
| w | # states of DFA m
Number of states in walk is at least m 1
w
Walk
of
Pigeons: (walk states)
q1
....
qi
....
qi
....
qz
Are
more
than
Nests: q1
q2
(Automaton states)
....
qi
....
qm1
qm
A state is
repeated
Prof. Busch - LSU
16
The Pumping Lemma
Prof. Busch - LSU
17
Take an infinite regular language L
(contains an infinite number of strings)
There exists a DFA that accepts
L
m
states
Prof. Busch - LSU
18
Take string
w L
with
| w| m
(number of
states of DFA)
then, at least one state is repeated
in the walk of w
Walk in DFA of
w 1 2 k
1
2 ......
q
...... k
Repeated state in DFA
Prof. Busch - LSU
19
There could be many states repeated
Take
q
to be the first state repeated
One dimensional projection of walk
1
First
Second
occurrence
occurrence
2 .... i q i 1 ....
j
q
w:
j 1.... k
Unique states
Prof. Busch - LSU
20
We can write
w xyz
One dimensional projection of walk
1
First
Second
occurrence
occurrence
2 .... i q i 1 ....
x 1 i
j
y i 1 j
Prof. Busch - LSU
q
w:
j 1.... k
z j 1 k
21
In DFA:
w x y z
Where
corresponds to substring
between first and second occurrence of
y
q
y
...
j
...
1
x
i
i 1
q
j 1
...
...
k
z
Prof. Busch - LSU
22
Observation:
length
| x y | m number
of states
of DFA
y
...
j
...
1
x
i
Because of
unique states in xy
i 1
q
Prof. Busch - LSU
Since, in xy no
state is repeated
(except q)
23
Observation:
length
| y | 1
Since there is at least one transition in loop
y
...
j
i 1
q
Prof. Busch - LSU
24
We do not care about the form of string
z
may actually overlap with the paths of
z
x and y
y
...
z
...
x
q
Prof. Busch - LSU
25
Additional string:
Do not follow loop
The string
is accepted
xz
y
...
j
...
1
x
i
i 1
q
j 1
...
...
k
z
Prof. Busch - LSU
26
Additional string:
Follow loop
2 times
The string
is accepted
xyyz
y
...
j
...
1
x
i
i 1
q
j 1
...
...
k
z
Prof. Busch - LSU
27
Additional string:
The string
is accepted
Follow loop
3 times
y
xyyyz
...
j
...
1
x
i
i 1
q
j 1
...
...
k
z
Prof. Busch - LSU
28
In General:
The string
is accepted
Follow loop
times
i
xy z
i 0, 1, 2, ...
y
i
...
j
...
1
x
i
i 1
q
j 1
...
...
k
z
Prof. Busch - LSU
29
Therefore:
i 0, 1, 2, ...
x y z L
i
Language accepted by the DFA
y
...
j
...
1
x
i
i 1
q
j 1
...
...
k
z
Prof. Busch - LSU
30
In other words, we described:
The Pumping Lemma !!!
Prof. Busch - LSU
31
The Pumping Lemma:
• Given a infinite regular language
• there exists an integer
• for any string
• we can write
• with
w L
m
L
(critical length)
with length
| w| m
w x y z
| x y | m and | y | 1
• such that:
xy z L
i
Prof. Busch - LSU
i 0, 1, 2, ...
32
In the book:
Critical length
m
= Pumping length
Prof. Busch - LSU
p
33
Applications
of
the Pumping Lemma
Prof. Busch - LSU
34
Observation:
Every language of finite size has to be regular
(we can easily construct an NFA
that accepts every string in the language)
Therefore, every non-regular language
has to be of infinite size
(contains an infinite number of strings)
Prof. Busch - LSU
35
Suppose you want to prove that
αn infinite language L is not regular
1. Assume the opposite:
L
is regular
2. The pumping lemma should hold for
L
3. Use the pumping lemma to obtain a
contradiction
4. Therefore,
L is not regular
Prof. Busch - LSU
36
Explanation of Step 3: How to get a contradiction
1. Let
m be the critical length for L
2. Choose a particular string w L which satisfies
the length condition | w | m
3. Write
w xyz
4. Show that
w xy z L
i
for some
i 1
5. This gives a contradiction, since from
pumping lemma
w xy z L
i
Prof. Busch - LSU
37
Note:
It suffices to show that
only one string w L
gives a contradiction
You don’t need to obtain
contradiction for every w L
Prof. Busch - LSU
38
Example of Pumping Lemma application
Theorem: The language L {a nb n : n 0}
is not regular
Proof:
Use the Pumping Lemma
Prof. Busch - LSU
39
L {a b : n 0}
n n
Assume for contradiction
that L is a regular language
Since L is infinite
we can apply the Pumping Lemma
Prof. Busch - LSU
40
L {a b : n 0}
n n
Let
m
be the critical length for L
Pick a string
w such that: w L
and length
We pick
| w| m
wa b
m m
Prof. Busch - LSU
41
From the Pumping Lemma:
we can write w a b
m
with lengths
m
x y z
| x y | m, | y | 1
m
w xyz
a b
m m
m
a...aa...aa...ab...b
x
y
z
k
y
a
, 1k m
Thus:
Prof. Busch - LSU
42
y a , 1k m
k
x y za b
m m
From the Pumping Lemma:
xy z L
i
i 0, 1, 2, ...
Thus:
xy z L
2
Prof. Busch - LSU
43
y a , 1k m
k
x y za b
m m
From the Pumping Lemma:
xy z L
2
mk
m
xy z a...aa...aa...aa...ab...b L
2
x
Thus:
a
y
y
z
m k m
b L
Prof. Busch - LSU
44
a
BUT:
m k m
b L
k ≥1
L {a b : n 0}
n n
a
m k m
b L
CONTRADICTION!!!
Prof. Busch - LSU
45
Therefore:
Our assumption that L
is a regular language is not true
Conclusion: L is not a regular language
END OF PROOF
Prof. Busch - LSU
46
Non-regular language
{a b : n 0}
n n
Regular languages
* *
L( a b )
Prof. Busch - LSU
47
© Copyright 2026 Paperzz