Pumping Lema
Pumping Lema
We cannot…!!!
2
Nonregular Languages.
Examples:
L = {L, ab, aabb, aaabbb, aaaabbbb, …}
L = {anbn | n=0,1,2,3,4,…}
L = {anbn}
L language(a*b*)
3
How can we prove that a language L
is not regular?
4
The Pigeonhole Principle
n pigeons
m pigeonholes
There is a pigeonhole
nm with at least 2 pigeons
...........
5
How does pigeonhole principle relate to
DFAs?
b
b b
q1 a b b
q2 q3 q4
a a
6
In walks of strings a, aa, aab, no state is
repeated
q1 a a b
q2 q3 q4
a a
7
In general, for any DFA:
walk of w
...... q ......
Repeated state 8
In other words for a string w:
walk of w
...... q ......
Repeated state
9
The Pumping Lemma
10
Take an infinite regular language L
There exists a DFA that accepts L
Take a string w from the language.
m
states
11
If string w has length | w | m (number
of states
of DFA)
then, from the pigeonhole principle:
...... q ......
walk w
12
Let q be the first state repeated in the
walk of w
...... q ......
walk w
13
Write w= x y z
...... q ......
x z 14
Observations: length |x y| m number
of states
length | y | 1 of DFA
...... q ......
x z 15
Additional string: The string xz
is accepted
j i +1
1 ... i
q j+1... ... k
x z
Prof. Busch - LSU 16
Additional string: The string xyyz
is accepted
Follow loop y
2 times
...
j i +1
1 ... i
q j+1... ... k
x z
Prof. Busch - LSU 17
Additional string: The string xyyyz
is accepted
Follow loop y
3 times
...
j i +1
1 ... i
q j+1... ... k
x z
Prof. Busch - LSU 18
i
In General: The string xy z
is accepted i = 0, 1, 2, ...
Follow loop y
i times
...
j i +1
1 ... i
q j+1... ... k
x z
Prof. Busch - LSU 19
Therefore: x y z L
i
i = 0, 1, 2, ...
j i +1
1 ... i
q j+1... ... k
x z
Prof. Busch - LSU 20
Observation: The string xz
is accepted
...... q ......
x z 21
Observation: The string xyyz
is accepted
...... q ......
x z 22
Observation: The string xyyyz
is accepted
...... q ......
x z 23
Chapter 10: Nonregular Languages.
y
x z
y
x z
24
In other words, we described:
The Pumping Lemma !!!
25
The Pumping Lemma:
• Given a infinite regular language L
• 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
• such that: xy z L
i i = 0, 1, 2, ...
26
Example
a
b 2+
b 3
1–
a b
a a b
a,b
4
b
5 6+
a
w=bbbababa
b b b a b a b a
1 2 3 5 2 3 6 3 6
x y z
27
w=bbbababa
bbbabbababa
xy z L
i i = 0, 1, 2, ...
28
What does the pumping lemma suggest…???
◼ Since this lemma must be true for any regular language L, we can
logically state it as follows:
30
Applications
of
3. Write w = xyz
4. Show that w = xy z L
i
for some i 1
36
Example of Pumping Lemma application
Since L is infinite
we can apply the Pumping Lemma
We pick w=a b m m
we can write w = a b m m
=x y z
with lengths | x y | m, | y | 1
m m
w = xyz =a b
m m
= a...aa...aa...ab...b
x y z
Thus: y = a k
, 1k m
Prof. Busch - LSU 42
x y z=a b
m m y =a , 1k m
k
i = 0, 1, 2, ...
Thus: xy z L
2
m+k m
xy z = a...aa...aa...aa...ab...b L
2
x y y z
m+ k m
Thus: a b L
Prof. Busch - LSU 44
m+ k m
a b L k≥ 1
BUT: L = {a b : n 0}
n n
m+ k m
a b L
CONTRADICTION!!!
Prof. Busch - LSU 45
Therefore: Our assumption that L
is a regular language is not true
END OF PROOF
Prof. Busch - LSU 46
Non-regular language {a b : n 0}
n n
Regular languages
* *
L( a b )
48
Non-regular languages
n l n +l
L = {a b c : n, l 0}
Regular languages
Since L is infinite
we can apply the Pumping Lemma
length | w| m
We pick w=a b c m m 2m
We can write w =a b c m m 2m
=x y z
With lengths | x y | m, | y | 1
m m 2m
w = xyz = a...aa...aa...ab...bc...cc...c
x y z
Thus: y =a , 1k m
k
i = 0, 1, 2, ...
0
Thus: x y z = xz ∈ L
m−k m 2m
Thus: a b c L
Prof. Busch - LSU 55
m−k m 2m
a b c L k 1
BUT: n l n +l
L = {a b c : n, l 0}
m−k m 2m
a b c L
CONTRADICTION!!!
Prof. Busch - LSU 56
Therefore: Our assumption that L
is a regular language is not true
END OF PROOF
Prof. Busch - LSU 57
L = {a : n 0}
n!
58
Non-regular languages L = {a : n 0}
n!
Regular languages
is not regular
n! = 1 2 (n − 1) n
Since L is infinite
we can apply the Pumping Lemma
We pick w=a m!
We can write w = a =x y z
m!
With lengths | x y | m, | y | 1
m m!−m
w = xyz = a = a...aa...aa...aa...aa...a
m!
x y z
Thus: y = a , 1 k m
k
Prof. Busch - LSU 63
x y z=a m!
y = a , 1 k m
k
i = 0, 1, 2, ...
Thus: xy z L
2
m+k m!−m
xy z = a...aa...aa...aa...aa...aa...a L
2
x y y z
m!+ k
Thus: a L
Prof. Busch - LSU 65
m!+ k
a L 1 k m
Since: L = {a : n 0}
n!
m!+ k = p!
m!+ k (m + 1)!
BUT: L = {a : n 0}
n!
m!+ k
a L
CONTRADICTION!!!
Prof. Busch - LSU 68
Therefore: Our assumption that L
is a regular language is not true
END OF PROOF
Prof. Busch - LSU 69
Palindrome
71
Theorem: The language
L = {vv : v *}
R
= {a, b}
is not regular
Since L is infinite
we can apply the Pumping Lemma
We pick w=a b b a m m m m
we can write: w = a b b a =x y z
m m m m
with lengths: | x y | m, | y | 1
m m m m
w = xyz = a...aa...a...ab...bb...ba...a
x y z
Thus: y =a , 1k m
k
Prof. Busch - LSU 75
x y z=a b b a
m m m m
y =a , 1k mk
i = 0, 1, 2, ...
Thus: xy z L
2
77
PRIME = {ap | p is a prime number}
78
Example: PRIME is non regular
79
Example: anbanb is nonregular
◼ Assume L is regular and let m be the integer from the pumping
lemma.
◼ Choose w = ambamb. Clearly, w ε L so by the pumping lemma, w =
xyz such that |xy| m. |y| > 0 and xyiz ε L for all i ≥ 0.
◼ Let p = |y|.
◼ Consider what happens when i = 0.
◼ The resulting string, xz = am-pbamb.
◼ Since p ≥ 1, the number of a’s in the two runs are not the same,
and thus this string is not in L.
◼ Therefore L is not regular.
80
Example: How to attempt the Regular pumping
Lemma Problems in Exams
Prove that language L={a3bncn-3 | n>3} is non
regular
1. Suppose for contradiction that the language is regular, hence, a DFA with ‘m’
states will accept this language.
2. We choose w=a3bmcm-3 such that |w|≥m
3. We can decompose w into xyz such that |y| ≥ 1 and |xy|≤m and xyiz is in L for
all i≥0.
4. Since |xy|≤m, these are the possible factorizations of xy
a) y consists of all a’s
Pumping y will lead to more than 3 a’s, contradiction as w’ not in L
a) y consists of a’s and b’s
Pumping y will lead to a string with b’s before a’s, contradiction.
a) y consists of all b’s
Pumping y will lead to more b’s and the c’s are untouched, difference
becomes more than 3, contradiction
5. The given language is non-regular as it violates the conditions of the pumping
lemma.
81
Theory of Automata
Fall 2018
Chapter - 11
Decidability
Chapter 11: Decidability
84
Decision Problems…
◼ Membership: Does w L
◼ Do two regular expressions define the same
language?
◼ Do two finite automata accept the same language?
◼ Is L Empty?
◼ Is L finite or infinite?
85
Membership Question
Question: Given regular language L and string w
how can we check if w L ?
DFA
w
w L
86
Question: Given regular language L
how can we check
if L is empty: ( L = ) ?
L
DFA
L=
88
Chapter 11: Decidability
89
Chapter 11: Decidability
a a a b
b b a
– b a,b +
b a
a a b
b b a
– a,b +
b a
a b
b a
– +
b a
90
Chapter 11: Decidability
a b
b a
– +
b a
b
b a
– +
a
91
Question: Given regular language L
how can we check
if L is finite?
L is infinite
DFA
L is finite
93
Question: Given regular languages L1 and L2
how can we check if L1 = L2 ?
Answer: Find if ( L1 L2 ) ( L1 L2 ) =
94
( L1 L2 ) ( L1 L2 ) =
L1 L2 = and L1 L2 =
L1 L2 L L2 L1 L1
2
L1 L2 L2 L1
L1 = L2
95
( L1 L2 ) ( L1 L2 )
L1 L2 or L1 L2
L1 L2 L2 L1
L1 L2 L2 L1
L1 L2
96
Chapter 11: Decidability
97
Chapter 11: Decidability
98
Infinite language…???
99
SUMMARY
◼ Membership: Does w L
◼ Do two regular expressions define the same
language?
◼ Do two finite automata accept the same language?
◼ Is L Empty?
◼ Is L finite or infinite?
100
◼ This lecture concludes the course for
the mid term exam
101