0% found this document useful (0 votes)
22 views73 pages

Lecture 10

Uploaded by

Radhika Jindal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views73 pages

Lecture 10

Uploaded by

Radhika Jindal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 73

CSE322

PUMPING LEMMA FOR REGULAR SETS


AND ITS APPLICATIONS

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 languageL
s not regular?

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

3pigeonholes

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
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 whas 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:

String w has length  number of states

A state q must be repeated in the walk ofw

walk of 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
• Pumping Lemma : If L is an infinite
language then there exists some
positive integer ‘n’ n is pumping length
such that any string W E L has length
greater than equal to ‘n’ i.e |w| >= n
then w canbe devided into 3 parts, w=
xyz and satisfy these conditions :

17
• 1. for each i>=0 , xy^iz E L
• 2.|y| >0 and
• 3. |xy| <= n

• Eg: a^nb^2n n>=0


• Lets take a string aabbbb E L yes
• Aa = x bb=y bb=z
• Pump y then aa bbbb bb E L No
• Test fail so its not a regular.
18
Take an infinite regular languageL

There exists a DFA that accepts L

m
states

19
Take string w with w L

There is a walk with label w :

.........
walk w
20
If string w has length | w |  m (number
of states
of DFA)
then,

a state is repeated in the walkw

...... q ......
walk w
21
22
Let q be the first state repeated in the
walk of w

...... q ......
walk w
23
Write w x y z

...... q ......

x z 24
Observations:

length | x y |  m number
of states
length | y | 1 y of DFA

...... q ......

x z 25
Observation:

The string xz
is accepted
y

...... q ......

x z 26
Observation:

The string xyyz


is accepted
y

...... q ......

x z 27
Observation:

The string xyyyz


is accepted
y

...... q ......

x z 28
In General:
i
The string xy z
is accepted i 0, 1, 2, ...
y

...... q ......

x z 29
In General: x yi z ∈ L

i 0, 1, 2, ...
Language accepted by the DFA

...... q ......

x z 30
In other words, we described:

The Pumping Lemma !!!

31
The Pumping Lemma:
• Given a infinite regular languageL

• there exists an integer m


• for any string w L with length| w | 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
32
Applications

of

the Pumping Lemma

33
n n
Theorem: The language L {a b : n 0}

is not regular

Proof: Use the Pumping Lemma

34
n n
L {a b : n 0}

Assume for contradiction


that L is a regular language

Since Lis infinite


we can apply the Pumping Lemma

35
n n
L {a b : n 0}

et mbe the integer in the Pumping Lemma

Pick a string w such that: w  L


length | w | m

m m
We pick w a b
36
m m
Write: a b x y z

From the Pumping Lemma


it must be that length | x y | m, | y |1
m m
m m
xyz a b  a...aa...aa...ab...b
x y z
k
Thus: y a , k 1
37
m m k
x y z a b y a , k 1
i
From the Pumping Lemma: xy z  L
i 0, 1, 2, ...

2
Thus: xy z  L

38
m m k
x y z a b y a , k 1
2
From the Pumping Lemma: x y 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
39
m k m k≥ 1
a b L

n n
BUT: L {a b : n 0}

m k m
a b L

CONTRADICTION!!!
40
Therefore: Our assumption that L
is a regular language is not true

Conclusion: L is not a regular language

41
n n
Non-regular languages {a b : n 0}

Regular languages

42
More Applications

of

the Pumping Lemma

43
The Pumping Lemma:
• Given a infinite regular languageL

• there exists an integer m


• for any string w L with length| w | 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
44
Non-regular languages R
L {vv : v  *}

Regular languages

45
Theorem:The language
R
L {vv : v  *}  {a, b}
is not regular

Proof: Use the Pumping Lemma

46
R
L {vv : v  *}
Assume for contradiction
that L is a regular language

Since Lis infinite


we can apply the Pumping Lemma

47
R
L {vv : v  *}

et m be the integer in the Pumping Lemma


Pick a string w such that: w  L and

length | w | m

m m m m
We pick w a b b a
48
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
49
m m m m
x y z a 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
50
m m m m k
x y z a 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
51
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!!!
52
Therefore: Our assumption that L
is a regular language is not true

Conclusion: L is not a regular language

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

Proof: Use the Pumping Lemma

55
n l n l
L {a b c : n, l 0}

Assume for contradiction


that L is a regular language

Since Lis infinite


we can apply the Pumping Lemma

56
n l n l
L {a b c : n, l 0}

et mbe the integer in the Pumping Lemma

Pick a string w such that: w  L and


length | w | m

m m 2m
We pick w a b c
57
m m 2m
Write a b c x y z

From the Pumping Lemma


it must be that length | x y | m, | y |1

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 z a 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 z a b c y a , k 1

rom the Pumping Lemma: xz  L


m k m 2m
xz a...aa...ab...bc...cc...c  L
x z

m k m 2m
Thus: a b c L
60
m k m 2m
a b c L k 1

n l n l
BUT: L {a b c : n, l 0}

m k m 2m
a b c L

CONTRADICTION!!!
61
Therefore: Our assumption that L
is a regular language is not true

Conclusion: L is not a regular language

62
n!
Non-regular languages L {a : n 0}

Regular languages

63
Theorem:The language
n!
L {a : n 0} is not regular

n!  1 2  (n  1) n

Proof: Use the Pumping Lemma

64
n!
L {a : n 0}
Assume for contradiction
that L is a regular language

Since Lis infinite


we can apply the Pumping Lemma

65
n!
L {a : n 0}

et mbe the integer in the Pumping Lemma

Pick a string w such that: w  L


length | w | m

m!
We pick w a
66
m!
Write a x y z

From the Pumping Lemma


it must be that length | x y | m, | y |1
m m! m
m!
xyz a a...aa...aa...aa...aa...a
x y z
k
Thus: y a , 1 k m
67
m! k
x y z a y a , 1 k m

i
From the Pumping Lemma: xy z  L
i 0, 1, 2, ...

2
Thus: xy z  L

68
m! k
x y z a y a , 1 k m
2
rom the Pumping Lemma: x y z  L

mk m! m
2
xy z a...aa...aa...aa...aa...aa...a  L
x y y z

m! k
Thus: a L
69
m! k
a L 1 k m
Since: n!
L {a : n 0}

There must exist p such that:


m!k  p!

70
However: m!k m!m
for m  1 m!m!
 m!m  m!
m!(m  1)
(m  1)!

m!k  (m  1)!

m!k  p! for any p


71
m! k
a L 1 k m

n!
BUT: L {a : n 0}

m! k
a L

CONTRADICTION!!!
72
Therefore: Our assumption that L
is a regular language is not true

Conclusion: L is not a regular language

73

You might also like