Uploaded by Krish

Lect-9 Pumping Lemma for Regular Languages

advertisement
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
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
nm
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:
b
q1
no state
is repeated
a
aa
aab
b
b
a
q2
a
a
q3
b
q4
a
11
In walks of strings:
b
q1
a state
aabb
is repeated
bbaa
abbabb
abbbabbabb...
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
|x y|  m
length
| y | 1
number
of states
of DFA
y
......
x
q
......
z
22
Observation:
The string
is accepted
xz
y
......
x
q
......
z
23
Observation:
The string
is accepted
xyyz
y
......
x
q
......
z
24
Observation:
The string
is accepted
xyyyz
y
......
x
q
......
z
25
In General:
The string
is accepted
i
xy z
i = 0, 1, 2, ...
y
......
x
q
......
z
26
In General:
i
xy 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
w=a 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 z=a 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 z=a b
y = a , k 1
m m
k
From the Pumping Lemma:
xy z  L
2
m+k
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
Non-regular languages
L = {vv : v  *}
R
Regular languages
40
Theorem: The language
L = {vv : v  *}
R
 = {a, b}
is not regular
Proof:
Use the Pumping Lemma
41
L = {vv : v  *}
R
Assume for contradiction
that L is a regular language
Since L is infinite
we can apply the Pumping Lemma
42
L = {vv : v  *}
R
Let
m be the integer in the Pumping Lemma
Pick a string
w such that: w  L
length
We pick
and
| w| m
w=a b b a
m m m m
43
Write
a b b a =xyz
m m m m
From the Pumping Lemma
it must be that length | x
m
y |  m, | y | 1
m m m
xyz = a...aa...a...ab...bb...ba...a
x
Thus:
y
z
y = a , k 1
k
44
x y z=a b b a
y = a , k 1
m m m m
k
From the Pumping Lemma:
xy z  L
i
i = 0, 1, 2, ...
Thus:
xy z  L
2
45
x y z=a b b a
y = a , k 1
m m m m
k
From the Pumping Lemma:
xy z  L
2
m m m
m+k
2
xy z = a...aa...aa...a...ab...bb...ba...a ∈ L
x
Thus:
y
a
y
m+ k m m m
b b a
z
L
46
a
BUT:
m+ k m m m
b b a
L
k 1
L = {vv : v  *}
R
a
m+ k m m m
b b a
L
CONTRADICTION!!!
47
Therefore:
Our assumption that L
is a regular language is not true
Conclusion: L is not a regular language
48
Non-regular languages
n l n +l
L = {a b c
: n, l  0}
Regular languages
49
Theorem: The language
n l n +l
L = {a b c
: n, l  0}
is not regular
Proof:
Use the Pumping Lemma
50
n l n +l
L = {a b c
: n, l  0}
Assume for contradiction
that L is a regular language
Since L is infinite
we can apply the Pumping Lemma
51
n l n +l
L = {a b c
Let
: n, l  0}
m be the integer in the Pumping Lemma
Pick a string
w such that: w  L
length
We pick
and
| w| m
w=a b c
m m 2m
52
Write
m m 2m
a b c
=xyz
From the Pumping Lemma
it must be that length | x
m
y |  m, | y | 1
m
2m
xyz = a...aa...aa...ab...bc...cc...c
x
Thus:
y
z
y = a , k 1
k
53
x y z=a b c
m m 2m
From the Pumping Lemma:
y = a , k 1
k
xy z  L
i
i = 0, 1, 2, ...
Thus:
0
x y z = xz ∈ L
54
x y z=a b c
y = a , k 1
m m 2m
k
xz  L
From the Pumping Lemma:
m−k
m
2m
xz = a...aa...ab...bc...cc...c  L
x
Thus:
z
a
m−k m 2m
b c
L
55
a
BUT:
m−k m 2m
b c
n l n +l
L = {a b c
a
m−k m 2m
b c
L
k 1
: n, l  0}
L
CONTRADICTION!!!
56
Therefore:
Our assumption that L
is a regular language is not true
Conclusion: L is not a regular language
57
Non-regular languages
L = {a : n  0}
n!
Regular languages
58
Theorem: The language
L = {a : n  0}
n!
is not regular
n! = 1  2  (n − 1)  n
Proof:
Use the Pumping Lemma
59
L = {a : n  0}
n!
Assume for contradiction
that L is a regular language
Since L is infinite
we can apply the Pumping Lemma
60
L = {a : n  0}
n!
Let
m be the integer in the Pumping Lemma
Pick a string
w such that: w  L
length
We pick
w=a
| w| m
m!
61
Write
a
m!
=xyz
From the Pumping Lemma
it must be that length | x
m
xyz = a
m!
y |  m, | y | 1
m!−m
= a...aa...aa...aa...aa...a
x
Thus:
y
z
y = a , 1 k  m
k
62
x y z=a
y = a , 1 k  m
m!
k
From the Pumping Lemma:
xy z  L
i
i = 0, 1, 2, ...
Thus:
xy z  L
2
63
x y z=a
y = a , 1 k  m
m!
k
From the Pumping Lemma:
m+k
xy z  L
2
m!−m
xy z = a...aa...aa...aa...aa...aa...a  L
2
x
Thus:
y
y
a
m!+ k
z
L
64
a
Since:
m!+ k
L
1 k  m
L = {a : n  0}
n!
There must exist
p
such that:
m!+ k = p!
65
However:
m!+ k  m!+ m
 m!+ m!
for
m 1
 m!m + m!
= m!(m + 1)
= (m + 1)!
m!+ k  (m + 1)!
m!+ k  p!
for any
p
66
a
BUT:
m!+ k
L
1 k  m
L = {a : n  0}
n!
a
m!+ k
L
CONTRADICTION!!!
67
Therefore:
Our assumption that L
is a regular language is not true
Conclusion: L is not a regular language
68
Download