Non-regular languages
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...
2
How can we prove that a language
is not regular?
L
Prove that there is no DFA that accepts
L
Problem: this is not easy to prove
Solution: the Pumping Lemma !!!
3
The Pigeonhole Principle
4
4 pigeons
pigeonholes
33 pigeonholes
5
A pigeonhole must
contain at least two pigeons
6
n pigeons
...........
m
pigeonholes
nm
...........
7
The Pigeonhole Principle
n pigeons
m
pigeonholes
nm
There is a pigeonhole
with at least 2 pigeons
...........
8
The Pigeonhole Principle
and
DFAs
9
DFA with
b
q1
4
states
b
b
a
q2
b
a
q3
b
q4
a
10
In walks of strings:
a
{q1, q2}
aa {q1, q2, q3}
aab {q1, q2 , q3 , q4}
no state
is repeated
b
q1
b
a
q2
a
a
q3
b
b
q4
a
11
In walks of strings:
a state
is repeated
aabb
bbaa
abbabb
abbbabbabb...
b
q1
b
b
a
q2
a
a
q3
b
q4
a
12
If string
w has length | w | 4 :
Then the transitions of string w
are more than the states of the DFA
Thus, a state must be repeated
b
q1
b
b
a
q2
a
a
q3
b
q4
a
13
In general, for any DFA:
String
A state
w has length number of states
q
walk of
must be repeated in the walk of
w
w
......
q
......
Repeated state
14
In other words for a string
w:
a
transitions are pigeons
q
states are pigeonholes
walk of
w
......
q
......
Repeated state
15
The Pumping Lemma
16
Take an infinite regular language L
There exists a DFA that accepts
L
m
states
17
Take string
w with w L
There is a walk with label
w:
.........
walk
w
18
If string
w has length | w | m
(number
of states
of DFA)
then, from the pigeonhole principle:
a state is repeated in the walk
......
walk
q
w
......
w
19
Let q be the first state repeated in the
walk of w
......
walk
q
......
w
20
Write
w x y z
y
......
x
q
......
z
21
Observations:
length
length
| x y | m number
of states
of DFA
| y | 1
y
......
x
q
......
z
22
Observation:
xz
The string
is accepted
y
......
x
q
......
z
23
Observation:
xyyz
The string
is accepted
y
......
x
q
......
z
24
Observation:
The string
is accepted
xyyyz
y
......
x
q
......
z
25
In General:
i
The string
xy z
i 0, 1, 2, ... is accepted
y
......
x
q
......
z
26
In General:
i
x y z ∈L
i 0, 1, 2, ...
Language accepted by the DFA
y
......
x
q
......
z
27
In other words, we described:
The Pumping Lemma !!!
28
The Pumping Lemma:
• Given a infinite regular language
• there exists an integer
• for any string
• we can write
• with
w L
L
m
with length
| w| m
w x y z
| x y | m and | y | 1
• such that:
xy z L
i
i 0, 1, 2, ...
29
Applications
of
the Pumping Lemma
30
Theorem: The language L {a nb n : n 0}
is not regular
Proof:
Use the Pumping Lemma
31
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
32
L {a b : n 0}
n n
Let
m
be the integer in the Pumping Lemma
Pick a string
w such that: w L
length
We pick
| w| m
wa b
m m
33
Write:
a b xyz
m m
From the Pumping Lemma
it must be that length | x
y | m, | y | 1
m
xyz a b
m m
a...aa...aa...ab...b
x
Thus:
m
y
z
y a , k 1
k
34
x y za b
y a , k 1
m m
k
From the Pumping Lemma:
xy z L
i
i 0, 1, 2, ...
Thus:
xy z L
2
35
x y za b
y a , k 1
m m
k
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
36
a
BUT:
m k m
b L
k ≥1
L {a b : n 0}
n n
a
m k m
b L
CONTRADICTION!!!
37
Therefore:
Our assumption that L
is a regular language is not true
Conclusion: L is not a regular language
38
Non-regular languages
{a b : n 0}
n n
Regular languages
39
© Copyright 2026 Paperzz