8/8/2019 Non Regular Languages 2
1/25
NON-REGULARLANGUAGES
Junaid Khan
Department of Computer Science University of
Peshawar Pakistan
Presented By
8/8/2019 Non Regular Languages 2
2/25
Standard Representations
ofRegular Languages
8/8/2019 Non Regular Languages 2
3/25
Standard Representations
of Regular Languages
Regular Languages
DFAs
NFAsRegular
Expressions
Regular
Grammars
8/8/2019 Non Regular Languages 2
4/25
Non-Regular languages
Languages that cannot be represented by
Finite Automation
Languages that cannot be defined by a
regular expression and TG
8/8/2019 Non Regular Languages 2
5/25
Regular languagesba *
acb *
...etc
*)( bacb
Non-regular languages
}0:{ unba nn
}*},{:{ bawwwR
8/8/2019 Non Regular Languages 2
6/25
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 !!!
8/8/2019 Non Regular Languages 2
7/25
The Pigeonhole
Principle
8/8/2019 Non Regular Languages 2
8/25
pigeons
pigeonholes
4
3
8/8/2019 Non Regular Languages 2
9/25
A pigeonhole must
contain at least two pigeons
8/8/2019 Non Regular Languages 2
10/25
...........
...........
pigeons
pigeonholes
n
m mn "
8/8/2019 Non Regular Languages 2
11/25
The Pigeonhole Principle
...........
pigeons
pigeonholes
n
m
mn "
There is a pigeonhole
with at least 2 pigeons
8/8/2019 Non Regular Languages 2
12/25
The Pigeonhole
Principle
and
DFAs
8/8/2019 Non Regular Languages 2
13/25
Conti.
DFA with states4
1q 2q 3qa
b
4q
b
b b
b
a a
8/8/2019 Non Regular Languages 2
14/25
1q 2q 3qa
b
4q
b
b
b
a a
a
In walks of strings:
aabaa
a no state
is repeated
8/8/2019 Non Regular Languages 2
15/25
In walks of strings:
1q 2q 3qa
b
4q
b
b
b
a a
a
...abbbabbabb
abbabb
bbaa
aabb a state
is repeated
8/8/2019 Non Regular Languages 2
16/25
If the walk of string has length
1q 2q 3qa
b
4q
b
b
b
a a
a
w 4|| uw
then a state is repeated
8/8/2019 Non Regular Languages 2
17/25
Pumping Lemma
Pumping: pump more stuff into the middleof the world.
Without changing front and the back part ofthe string (swelling)..
Lemma: Help in proving otherresults E.g. help us certain specific languages are
nonregular.
8/8/2019 Non Regular Languages 2
18/25
Pumping lemma
String w divided into three parts x, y, z
X=all state of w, at the beginning to the first
state that is revisited, (it may be null)
Y=substring travels around the circuit (cannot
be null)
Z=rest strings of w (may be null)
8/8/2019 Non Regular Languages 2
19/25
Theorem: The language }0:{ u! nbaL nn
is not regular
Proof: Use the Pumping Lemma
8/8/2019 Non Regular Languages 2
20/25
Assume for contradiction
that is a regular languageL
Since is infinitewe can apply the Pumping Lemma
L
}0:{ u! nbaL nn
8/8/2019 Non Regular Languages 2
21/25
Let be the integer in the Pumping Lemma
Pick a string such that:wL
w
mw u||length
Example: mmbaw !pick
}0:{ u! nbaL nn
8/8/2019 Non Regular Languages 2
22/25
Write: zyxbamm!
it must be that: length
From the Pumping Lemma
1||,|| ue ymyx
Therefore: babaaaabamm
............!
1,u! k
ay
k
x y z
m m
8/8/2019 Non Regular Languages 2
23/25
From the Pumping Lemma: Lzyxi
...,2,1,0!i
Thus:
mmbazyx !
Lbazyyxzyxmkm
!!2
Lzyx 2
We have: 1, u! kayk
8/8/2019 Non Regular Languages 2
24/25
Lbamkm
Therefore:
}0:{ u! nbaLnn
BUT:
Lba
mkm
CONTRADICTION!!!
8/8/2019 Non Regular Languages 2
25/25
Our assumption that
is a regular language is not true
L
Conclusion:
Lis not a regular language
Therefore: