Professional Documents
Culture Documents
Pumping Lemma
Pumping Lemma
Lecture #11
Non-regular languages n n
{a b : n 0}
R
{vv : v {a, b}*}
Regular languages
a *b b*c a
b c ( a b) *
etc...
2
How can we prove that a language L
is not regular?
3
The Pigeonhole Principle
4
4 pigeons
3 pigeonholes
5
A pigeonhole must
contain at least two pigeons
6
n pigeons
...........
m pigeonholes nm
...........
7
The Pigeonhole Principle
n pigeons
m pigeonholes
There is a pigeonhole
nm with at least 2 pigeons
...........
8
The Pigeonhole Principle
and
DFAs
9
DFA with 4 states
b
b b
a b b
q1 q2 q3 q4
a a
10
In walks of strings: a
aa no state
is repeated
aab
b
b b
a a b
q1 q2 q3 q4
a a
11
In walks of strings: aabb
a state
bbaa is repeated
abbabb
abbbabbabb... b
b b
a a b
q1 q2 q3 q4
a 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
b b
a a b
q1 q2 q3 q4
a a
13
In general, for any DFA:
walk of w
...... q ......
Repeated state 14
In other words for a string w:
walk of w
...... q ......
Repeated state
15
The Pumping Lemma
16
Take an infinite regular language L
m
states
17
Take string w with w L
.........
walk w
18
If string w has length | w | m (number
of states
of DFA)
then, from the pigeonhole principle:
...... q ......
walk w
19
Let q be the first state repeated in the
walk of w
...... q ......
walk w
20
Write w x y z
...... q ......
x z 21
Observations:
length | x y | m number
of states
length | y | 1 y of DFA
...... q ......
x z 22
Observation:
The string xz
is accepted
y
...... q ......
x z 23
Observation:
...... q ......
x z 24
Observation:
...... q ......
x z 25
In General:
i
The string xy z
is accepted i 0, 1, 2, ...
y
...... q ......
x z 26
In General: x yi z ∈ L
i 0, 1, 2, ...
Language accepted by the DFA
...... q ......
x z 27
In other words, we described:
28
The Pumping Lemma:
• Given a infinite regular language L
• there exists an integer m
• with | x y | m and | y | 1
i i 0, 1, 2, ...
• such that: xy z L
29
If we select a string w such that
w∈L, and w=xyz. Which of the
following portions cannot be an
empty string?
a) x
b) y
c) z
d) all of the mentioned
30
Applications
of
31
n n
Theorem: The language L {a b : n 0}
is not regular
32
n n
L {a b : n 0}
Since L is infinite
we can apply the Pumping Lemma
33
n n
L {a b : n 0}
m m
We pick wa b
34
m m
Write: a b xyz
2
Thus: xy z L
36
m m k
x y za b y a , k 1
2
From the Pumping Lemma: x y z L
mk m
2
xy z a...aa...aa...aa...ab...b L
x y y z
m k m
Thus: a b L
37
m k m k≥ 1
a b L
n n
BUT: L {a b : n 0}
m k m
a b L
CONTRADICTION!!!
38
Therefore: Our assumption that L
is a regular language is not true
39
n n
Non-regular languages {a b : n 0}
Regular languages
40
There exists a language L. We
define a string w such that
w∈L and w=xyz and |w| >=n for
some constant integer n.What
can be the maximum length of
the substring xy i.e. |xy|<=?
a) n
b) |y|
c) |x|
d) none of the mentioned
41
More Applications
of
42
The Pumping Lemma:
• Given a infinite regular language L
• there exists an integer m
• with | x y | m and | y | 1
i i 0, 1, 2, ...
• such that: xy z L
43
Non-regular languages R
L {vv : v *}
Regular languages
44
Theorem: The language
R
L {vv : v *} {a, b}
is not regular
45
R
L {vv : v *}
Assume for contradiction
that L is a regular language
Since L is infinite
we can apply the Pumping Lemma
46
R
L {vv : v *}
length | w| m
m m m m
We pick wa b b a
47
m m m m
Write a b b a x y z
From the Pumping Lemma
it must be that length | x y | m, | y | 1
m m m m
xyz a...aa...a...ab...bb...ba...a
x y z
k
Thus: y a , k 1
48
m m m m
x y za b b a k
y a , k 1
i
From the Pumping Lemma: xy z L
i 0, 1, 2, ...
2
Thus: xy z L
49
m m m m k
x y za b b a y a , k 1
2
From the Pumping Lemma: x y z L
m+k m m m
2
xy z = a...aa...aa...a...ab...bb...ba...a ∈ L
x y y z
m k m m m
Thus: a b b a L
50
m k m m m
a b b a L k 1
R
BUT: L {vv : v *}
m k m m m
a b b a L
CONTRADICTION!!!
51
Therefore: Our assumption that L
is a regular language is not true
52
Relate the following statement:
Statement: All sufficiently long words in a regular language can have a middle section
of words repeated a number of times to produce a new word which also lies within the
same language.
a) Turing Machine
b) Pumping Lemma
c) Arden’s theorem
d) None of the mentioned
53
Non-regular languages
n l n l
L {a b c : n, l 0}
Regular languages
54
Theorem: The language
n l n l
L {a b c : n, l 0}
is not regular
55
n l n l
L {a b c : n, l 0}
Since L is infinite
we can apply the Pumping Lemma
56
n l n l
L {a b c : n, l 0}
length | w| m
m m 2m
We pick wa b c
57
m m 2m
Write a b c xyz
m m 2m
xyz a...aa...aa...ab...bc...cc...c
x y z
k
Thus: y a , k 1
58
m m 2m k
x y za b c y a , k 1
i
From the Pumping Lemma: xy z L
i 0, 1, 2, ...
0
Thus: x y z = xz ∈ L
59
m m 2m k
x y za b c y a , k 1
mk m 2m
Thus: a b c L
60
mk m 2m
a b c L k 1
n l n l
BUT: L {a b c : n, l 0}
mk m 2m
a b c L
CONTRADICTION!!!
61
Therefore: Our assumption that L
is a regular language is not true
62
While applying Pumping lemma over a language, we consider a string w
that belong to L and fragment it into _________ parts.
a)2
b)5
c)3
d)6
63
n!
Non-regular languages L {a : n 0}
Regular languages
64
Theorem: The language
n!
L {a : n 0} is not regular
n! 1 2 (n 1) n
65
n!
L {a : n 0}
Assume for contradiction
that L is a regular language
Since L is infinite
we can apply the Pumping Lemma
66
n!
L {a : n 0}
m!
We pick wa
67
m!
Write a xyz
i
From the Pumping Lemma: xy z L
i 0, 1, 2, ...
2
Thus: xy z L
69
m! k
x y za y a , 1 k m
2
From the Pumping Lemma: x y z L
mk m! m
2
xy z a...aa...aa...aa...aa...aa...a L
x y y z
m! k
Thus: a L
70
m! k
a L 1 k m
Since: n!
L {a : n 0}
71
However: m! k m! m
for m 1 m! m!
m!m m!
m!(m 1)
(m 1)!
m! k (m 1)!
n!
BUT: L {a : n 0}
m! k
a L
CONTRADICTION!!!
73
Therefore: Our assumption that L
is a regular language is not true
74