Class 6
Class 6
Class 6
1
n n
{a b : n ≥ 0}
Non-regular languages
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 n>m
...........
7
The Pigeonhole Principle
n pigeons
m pigeonholes
There is a pigeonhole
n>m 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 no state
aa 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
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)
...... 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 of DFA
...... q ......
x z 22
Observation: The string xz
is accepted
...... q ......
x z 23
Observation: The string xyyz
is accepted
...... q ......
x z 24
Observation: The string xyyyz
is accepted
...... q ......
x z 25
i
In General: The string xy z
is accepted i = 0, 1, 2, ...
...... q ......
x z 26
In General: i
xy z ∈ L i = 0, 1, 2, ...
...... q ......
x z 27
In other words, we described:
28
The Pumping Lemma:
• Given a infinite regular language L
• there exists an integer m
• we can write w= x y z
• with | x y | ≤ m and | y | ≥ 1
i i = 0, 1, 2, ...
• such that: xy z ∈ L
29
Applications
of
30
n n
Theorem: The language L = {a b : n ≥ 0}
is not regular
31
n n
L = {a b : n ≥ 0}
Since L is infinite
we can apply the Pumping Lemma
32
n n
L = {a b : n ≥ 0}
m m
We pick w=a b
33
m m
Write: a b =xyz
i
From the Pumping Lemma: xy z ∈ L
i = 0, 1, 2, ...
2
Thus: xy z ∈ L
35
m m k
x y z=a b y = a , k ≥1
2
From the Pumping Lemma: xy z ∈ L
m+k m
2
xy z = a...aa...aa...aa...ab...b ∈ L
x y y z
m+ k m
Thus: a b ∈L
36
m+ k m k≥ 1
a b ∈L
n n
BUT: L = {a b : n ≥ 0}
m+ k m
a b ∉L
CONTRADICTION!!!
37
Therefore: Our assumption that L
is a regular language is not true
38
n n
Non-regular languages {a b : n ≥ 0}
Regular languages
39