2. Exercise
Build an FA that accepts the following
language:
L = {L, ab, aabb, aaabbb, aaaabbbb, ……}
2
We cannot…!!!
3. 3
Nonregular Languages.
Examples:
L = {L, ab, aabb, aaabbb, aaaabbbb, …}
L = {anbn | n=0,1,2,3,4,…}
L = {anbn}
L language(a*b*)
Palindrome is another non regular language.
4. 4
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 !!!
6. 6
How does pigeonhole principle relate to
DFAs?
DFA with states
4
1
q 2
q 3
q
a
b
4
q
b
b b
b
a a
7. 7
1
q 2
q 3
q
a
b
4
q
b
b
b
a a
a
In walks of strings a, aa, aab, no state is
repeated
In walks of strings aabb, bbaa, abbaba, a
state is repeated
8. 8
In general, for any DFA:
String has length number of states
w
A state must be repeated in the walk of w
q
q
...... ......
walk of w
Repeated state
9. 9
In other words for a string :
transitions are pigeons
states are pigeonholes
q
a
w
q
...... ......
walk of w
Repeated state
11. 11
Take an infinite regular language
Take a string w from the language.
L
There exists a DFA that accepts L
m
states
12. 12
If string has length
w m
w
|
| (number
of states
of DFA)
then, from the pigeonhole principle:
a state is repeated in the walk w
q
...... ......
walk w
16. Prof. Busch - LSU 16
The string
is accepted
z
x
Additional string:
q
... ...
x z
...
Do not follow loop
y
...
1
k
i
1
+
i
j
1
+
j
17. Prof. Busch - LSU 17
The string
is accepted
z
y
y
x
q
... ... ...
x z
Follow loop
2 times
Additional string:
y
...
1
k
i
1
+
i
j
1
+
j
18. Prof. Busch - LSU 18
The string
is accepted
z
y
y
y
x
q
... ... ...
x z
Follow loop
3 times
Additional string:
y
...
1
k
i
1
+
i
j
1
+
j
19. Prof. Busch - LSU 19
The string
is accepted
z
y
x i
In General:
...
,
2
,
1
,
0
=
i
q
... ... ...
x z
Follow loop
times
i
y
...
1
k
i
1
+
i
j
1
+
j
20. Prof. Busch - LSU 20
L
z
y
x i
Therefore: ...
,
2
,
1
,
0
=
i
Language accepted by the DFA
q
... ... ...
x z
y
...
1
k
i
1
+
i
j
1
+
j
26. 26
The Pumping Lemma:
• Given a infinite regular language L
• there exists an integer m
• for any string with length
L
w m
w
|
|
• we can write z
y
x
w =
• with and
m
y
x
|
| 1
|
|
y
• such that: L
z
y
x i
...
,
2
,
1
,
0
=
i
27. 27
w = b b b a b a b a
2+ 3
5 6+
b
a b
a,b
4
1–
a
b
a
b
a
b
a
Example
b
x
1 2
b b a
y
2
5
3
b
b a
a
z
3
6
3 6
28. 28
w = b b b a b a b a
b b b a b b a b a b a
L
z
y
x i
...
,
2
,
1
,
0
=
i
29. What does the pumping lemma suggest…???
◼ Since this lemma must be true for any regular language L, we can
logically state it as follows:
◼ L regular Pumping Lemma true
◼ But the contrapositive implies that:
◼ Pumping Lemma not true L is not regular
◼ We can show a language is not regular by showing that it violates some
condition of the Pumping Lemma.
◼ We do that by first assuming the language is regular, and deriving a
contradiction.
29
30. Outline of a pumping lemma proof to show
the non-regularity of some language L:
1. Assume L is regular. Therefore (by the Pumping Lemma) there
exists some number m, which is the number of states in DFA that
accepts L.
2. Choose a specific string ‘w’ such that wL and |w|m. Both of these
conditions must be explicitly stated/verified for ‘w’.
3. Consider an arbitrary factorization of w into xyz such that |y|1 and
|xy| m. Any possible factorization of w that satisfies these
conditions must be considered.
4. Create the string w' from w by choosing some value for i0. That is,
w' = xyiz for some i0. Show that w'L, no matter how the portions
x, y, and z are determined.
5. Conclude that L is not regular if it contradicts the Pumping Lemma.
30
31. Prof. Busch - LSU 31
Applications
of
the Pumping Lemma
32. Prof. Busch - LSU 32
Observation:
Every language of finite size has to be regular
Therefore, every non-regular language
has to be of infinite size
(contains an infinite number of strings)
(we can easily construct an NFA
that accepts every string in the language)
33. Prof. Busch - LSU 33
Suppose you want to prove that
αn infinite language is not regular
1. Assume the opposite: is regular
2. The pumping lemma should hold for
3. Use the pumping lemma to obtain a
contradiction
L
L
L
4. Therefore, is not regular
L
34. Prof. Busch - LSU 34
Explanation of Step 3: How to get a contradiction
2. Choose a particular string which satisfies
the length condition
L
w
3. Write xyz
w =
4. Show that L
z
xy
w i
=
for some 1
i
5. This gives a contradiction, since from
pumping lemma L
z
xy
w i
=
m
w
|
|
1. Let be the critical length for
m L
35. Prof. Busch - LSU 35
Note: It suffices to show that
only one string
gives a contradiction
L
w
You don’t need to obtain
contradiction for every L
w
37. Prof. Busch - LSU 37
Theorem: The language }
0
:
{
= n
b
a
L n
n
is not regular
Proof: Use the Pumping Lemma
Example of Pumping Lemma application
38. Prof. Busch - LSU 40
Assume for contradiction
that is a regular language
L
Since is infinite
we can apply the Pumping Lemma
L
}
0
:
{
= n
b
a
L n
n
39. Prof. Busch - LSU 41
Let be the critical length for
Pick a string such that:
w L
w
m
w
|
|
and length
m
m
b
a
w =
We pick
m
}
0
:
{
= n
b
a
L n
n
L
40. Prof. Busch - LSU 42
with lengths
From the Pumping Lemma:
1
|
|
,
|
|
y
m
y
x
b
ab
aa
aa
a
b
a
xyz m
m
...
...
...
...
=
=
m
k
a
y k
= 1
,
x y z
m m
we can write z
y
x
b
a
w m
m
=
=
Thus:
=
w
41. Prof. Busch - LSU 43
From the Pumping Lemma: L
z
y
x i
...
,
2
,
1
,
0
=
i
Thus:
m
m
b
a
z
y
x =
L
z
y
x
2
m
k
a
y k
= 1
,
42. Prof. Busch - LSU 44
From the Pumping Lemma:
L
b
ab
aa
aa
aa
a
z
xy
= ...
...
...
...
...
2
x y z
k
m + m
Thus:
L
z
y
x
2
m
m
b
a
z
y
x =
y
L
b
a m
k
m
+
m
k
a
y k
= 1
,
43. Prof. Busch - LSU 45
L
b
a m
k
m
+
}
0
:
{
= n
b
a
L n
n
BUT:
L
b
a m
k
m
+
CONTRADICTION!!!
1
≥
k
44. Prof. Busch - LSU 46
Our assumption that
is a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
END OF PROOF
45. Prof. Busch - LSU 47
Regular languages
Non-regular language }
0
:
{
n
b
a n
n
)
( *
*
b
a
L
47. Prof. Busch - LSU 49
Regular languages
Non-regular languages
}
0
,
:
{
= +
l
n
c
b
a
L l
n
l
n
48. Prof. Busch - LSU 50
Theorem: The language
is not regular
Proof: Use the Pumping Lemma
}
0
,
:
{
= +
l
n
c
b
a
L l
n
l
n
49. Prof. Busch - LSU 51
Assume for contradiction
that is a regular language
L
Since is infinite
we can apply the Pumping Lemma
L
}
0
,
:
{
= +
l
n
c
b
a
L l
n
l
n
50. Prof. Busch - LSU 52
m
m
m
c
b
a
w 2
=
We pick
Let be the critical length of
Pick a string such that:
w L
w
m
w
|
|
length
m
}
0
,
:
{
= +
l
n
c
b
a
L l
n
l
n
and
L
51. Prof. Busch - LSU 53
We can write z
y
x
c
b
a
w m
m
m
=
= 2
With lengths
From the Pumping Lemma:
c
cc
bc
ab
aa
aa
a
xyz ...
...
...
...
...
...
=
x y z
m m m
2
1
|
|
,
|
|
y
m
y
x
Thus:
=
w
m
k
a
y k
= 1
,
52. Prof. Busch - LSU 54
From the Pumping Lemma: L
z
y
x i
...
,
2
,
1
,
0
=
i
Thus:
m
m
m
c
b
a
z
y
x 2
=
L
xz
z
y
x ∈
=
0
m
k
a
y k
= 1
,
53. Prof. Busch - LSU 55
From the Pumping Lemma:
L
c
cc
bc
ab
aa
a
xz
= ...
...
...
...
...
x z
k
m − m m
2
m
m
m
c
b
a
z
y
x 2
=
L
xz
Thus: L
c
b
a m
m
k
m
− 2
m
k
a
y k
= 1
,
54. Prof. Busch - LSU 56
L
c
b
a m
m
k
m
− 2
L
c
b
a m
m
k
m
− 2
BUT:
CONTRADICTION!!!
}
0
,
:
{
= +
l
n
c
b
a
L l
n
l
n
1
k
55. Prof. Busch - LSU 57
Our assumption that
is a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
END OF PROOF
57. Prof. Busch - LSU 59
Regular languages
Non-regular languages }
0
:
{ !
= n
a
L n
58. Prof. Busch - LSU 60
Theorem: The language
is not regular
Proof: Use the Pumping Lemma
}
0
:
{ !
= n
a
L n
n
n
n
−
= )
1
(
2
1
!
59. Prof. Busch - LSU 61
Assume for contradiction
that is a regular language
L
Since is infinite
we can apply the Pumping Lemma
L
}
0
:
{ !
= n
a
L n
60. Prof. Busch - LSU 62
!
m
a
w =
We pick
Let be the critical length of
Pick a string such that:
w L
w
m
w
|
|
length
m
}
0
:
{ !
= n
a
L n
L
61. Prof. Busch - LSU 63
We can write z
y
x
a
w m
=
= !
With lengths
From the Pumping Lemma:
a
aa
aa
aa
aa
a
a
xyz m
...
...
...
...
...
!
=
=
x y z
m m
m −
!
1
|
|
,
|
|
y
m
y
x
m
k
a
y k
= 1
,
Thus:
=
w
62. Prof. Busch - LSU 64
From the Pumping Lemma: L
z
y
x i
...
,
2
,
1
,
0
=
i
Thus:
!
m
a
z
y
x =
L
z
y
x
2
m
k
a
y k
= 1
,
63. Prof. Busch - LSU 65
From the Pumping Lemma:
L
a
aa
aa
aa
aa
aa
a
z
xy
= ...
...
...
...
...
...
2
x y z
k
m + m
m −
!
Thus:
!
m
a
z
y
x = m
k
a
y k
= 1
,
L
z
y
x
2
y
L
a k
m
+
!
64. Prof. Busch - LSU 66
L
a k
m
+
!
!
! p
k
m =
+
}
0
:
{ !
= n
a
L n
Since:
m
k
1
There must exist such that:
p
65. Prof. Busch - LSU 67
However:
)!
1
(
)
1
(
!
!
!
!
!
!
+
=
+
=
+
+
+
m
m
m
m
m
m
m
m
m
m
k
m +
! for 1
m
)!
1
(
! +
+ m
k
m
!
! p
k
m
+ for any p
66. Prof. Busch - LSU 68
L
a k
m
+
!
L
a k
m
+
!
BUT:
CONTRADICTION!!!
}
0
:
{ !
= n
a
L n
m
k
1
67. Prof. Busch - LSU 69
Our assumption that
is a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
END OF PROOF
69. Prof. Busch - LSU 72
Theorem: The language
is not regular
Proof: Use the Pumping Lemma
*}
:
{
= v
vv
L R
}
,
{ b
a
=
70. Prof. Busch - LSU 73
Assume for contradiction
that is a regular language
L
Since is infinite
we can apply the Pumping Lemma
L
*}
:
{
= v
vv
L R
71. Prof. Busch - LSU 74
m
m
m
m
a
b
b
a
w =
We pick
Let be the critical length for
Pick a string such that:
w L
w
m
w
|
|
length
m
and
*}
:
{
= v
vv
L R
L
72. Prof. Busch - LSU 75
we can write: z
y
x
a
b
b
a
w m
m
m
m
=
=
with lengths:
From the Pumping Lemma:
a
ba
bb
ab
a
aa
a
xyz ...
...
...
...
...
...
=
x y z
m m m m
1
|
|
,
|
|
y
m
y
x
m
k
a
y k
= 1
,
Thus:
=
w
73. Prof. Busch - LSU 76
From the Pumping Lemma: L
z
y
x i
...
,
2
,
1
,
0
=
i
Thus: L
z
y
x
2
m
m
m
m
a
b
b
a
z
y
x = m
k
a
y k
= 1
,
74. 77
Example: Palindrome is non regular
Theorem: Palindrome L = {anban | n=0,1,2,3,4,…}
= {b, aba, aabaa, …} is not regular.
Proof (incomplete).
The left an will be pumped to aq while the right an
remains fixed, imbalance.
Note: Solve this yourself with all steps as required.
76. 79
Theorem: PRIME = {ap | p is a prime number}
= {aa, aaa, aaaaa, aaaaaaa, …}
is not regular.
Proof: p>N (N= # of states in assumed FA), ap=xyz from
pumping lemma. ap accepted →
xyp+1z = xyzyp (why?) = apyp = ap(am)p = a(m+1)p accepted
But (m+1)p is not a prime number … contradiction.
Example: PRIME is non regular
77. 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
78. 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
80. 84
Chapter 11: Decidability
A problem is called a decision problem if its solution is
either YES or NO.
Definition: a decision problem is decidable, or
effectively solvable, if there is an algorithm that can
find the answer for any input in a finite number of
steps.
81. Decision Problems…
◼ Membership: Does
◼ 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
L
w
82. 86
Membership Question
Question: Given regular language L and string w
how can we check if ?
L
w
Answer: Take the DFA that accepts L
and check if w is accepted
DFA
L
w
w
83. 87
Given regular language
how can we check
if is empty: ?
L
L
Take the DFA that accepts
Check if there is any path from
the initial state to a final state
L
)
(
=
L
Question:
Answer:
85. 89
Chapter 11: Decidability
Method: Answer the question: is there any path from – to +?
The Blue Paint Algorithm:
1. Mark the start state. (Paint it blue.)
2. From every blue state, follow every arrow that goes out
of the state, and paint the destination state blue. Delete
each arrow that was followed.
3. Repeat step 2 until there are no new blue states.
4. If there is any final state that is blue, then there are
words in the language accepted by the finite automaton.
If not, the language is empty.
88. 92
Given regular language
how can we check
if is finite?
L
L
Take the DFA that accepts
Check if there is a walk with cycle
from the initial state to a final state
L
Question:
Answer:
90. 94
Given regular languages and
how can we check if ?
1
L 2
L
2
1 L
L =
Question:
=
)
(
)
( 2
1
2
1 L
L
L
L
Find if
Answer:
91. 95
=
)
(
)
( 2
1
2
1 L
L
L
L
=
2
1 L
L
=
2
1 L
L
and
2
1 L
L =
1
L
2
L 1
L
2
L
2
1 L
L 1
2 L
L
2
L 1
L
92. 96
)
(
)
( 2
1
2
1 L
L
L
L
2
1 L
L
2
1 L
L
or
1
L
2
L 1
L
2
L
2
1 L
L 1
2 L
L
2
1 L
L
93. 97
Chapter 11: Decidability
Theorem: Let F be a finite automaton with N states. If the
language accepted by F is not empty, then it contains at
least one word with N or fewer letters.
Method 3. Try all words with N and fewer letters.
If the finite automaton accepts none of them, then the
language accepted by this automaton is empty.
94. 98
Chapter 11: Decidability
Problem 3. Does the language defined by a finite
automaton has a finite number of words? Infinite?
None?
None? Done previously.
Finite or Infinite language?
Solution 1: Does corresponding RE contain * ?
Solution 2: Use the following theorem.
95. 99
Infinite language…???
Theorem. Let F be a finite automaton with N states.
F accepts a word w such that N length(w) < 2N if and only if
the language accepted by F is infinite.
Proof: Apply Pumping lemma.
If w, N length(w) is accepted, then w created loop while
following N states
pumping lemma creates infinite number of accepted words
96. SUMMARY
◼ Membership: Does
◼ 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
L
w
97. ◼ This lecture concludes the course for
the mid term exam
101