Wa0012.
Wa0012.
regular
Languages
L(M1 ) = L1 L(M 2 ) = L2
NFA M1 NFA M2
𝑀4
𝐿4 = 𝑏𝑎 b a
Union
NFA for 𝐿1 ∪ 𝐿2
𝑛 𝑛
NFA for 𝐿 𝐿
3 4 = {𝑎 𝑏}{𝑏𝑎} = {𝑎 𝑏𝑏𝑎} n0
Star Operation
NFA for L1 *
𝑛
NFA for 3𝐿 ∗= {𝑎 𝑏} ∗
The string in L3* is w.
w = w1w2 wk
wi L1
Reversal
R
NFA for L1
L1 M1 M1
M1
a
R
L1 = {ba }
n b
Complement
L1 M1 L1 M1
L1 = {a b}
n b a, b
M1
a a, b
L1 = {a, b} * −{a b}
n
b a, b
Intersection
DeMorgan’s Law: L1 L2 = L1 L2
L1 , L2 regular
L1 , L2 regular
L1 L2 regular
L1 L2 regular
L1 L2 regular
Example
L1 = {a b} regular
n
L1 L2 = {ab}
L2 = {ab, ba} regular regular
a b
a
b a, b
a, b
Intersection (Product)
L1 = L(M1), M1 = (Q, , 1, q0, F1), Q = {q0, q1…... qm,}
L2 = L(M2), M2 = (P, , 2, p0, F2), Q = {p0, p1…... pn,}
M1 and M2 are DFAs.
L1 , L2 regular
𝐿1 , 𝐿2 regular
𝐿1 ∩ 𝐿2 regular
DIFFERENCE
If L1 and L2 are regular languages, So is L1 - L2
L1 - L2 consists of strings in L1 but not L2 i.e.,
𝐿1 − 𝐿2 = 𝐿1 ∩ 𝐿2
Exercise-1
L1 = L ( (a+b)a*)
L2 = L( baa*)
Exercise -2
L3 = {w ε {0, 1 }* : w consists of 0’s in multiple of 3}
L4 = {w ε {0, 1 }* : w consists of odd number of 0’s}
Elementary Questions
about
Regular Languages
Membership Question
Question-1 Given regular language L
and string w
how can we check if w L?
Answer: Take the DFA that accepts L
and check if w is accepted
w
DFA w L
If there is a path from initial state to final state with labeled w; Accepted
w
DFA w L
If there is no path from initial state to final state with labeled w; Rejected
Given regular language L
Question-2 how can we check
ifL is empty:( L = ) ?
Take the DFA that accepts L
Answer:
Check if there is any path from
the initial state to a final state
DFA L
DFA L=
Given regular language L
Question-4 how can we check
if L is finite?
DFA L is infinite
DFA L is finite
Example
Non-regular languages
Regular Languages
Every finite language is regular.
Some infinite languages are regular
L1 ={anb : n >=0} → aaab
Regularity:
The language is regular if, in processing any string, the information
that has to be remembered at any stage is strictly limited.
Regular languages
a *b b*c + a
b + c ( a + b) *
etc...
How can we prove that a language L is not
regular?
walk of w
...... q ......
Repeated state
In general, for any DFA:
walk of w
...... q ......
Repeated state
The Pigeonhole Principle and DFAs
q1 a q2 a q3 b q4
DFA with 4 states a a
In string length < 4 no state is repeated
If string w | w | 4:
has length
Then the transitions of string w are more
than the states of the DFA
Thus, a state must be repeated
b
b b
q1 a q2 a q3 b q4
a a
Thus, the repeated state represents a pattern in RL.
The Pumping Lemma:
• Assume that given infinite L language is regular
• There exists an integer m for any string
with | x y | m and | y | 1
such that: xy z L
i i = 0, 1, 2, ...
Applications
of
x y z
z = am –(l+k) bm
Thus: y = a , k 1
k
x y z=a b m m
y = a , k 1
k
i = 0, 1, 2, ... y= ak
z = am –(l+k) bm
i=0 → am-kbm
i= 1 → ambm
Thus: xy z L 2 i=2 → am+kbm
i=3 → am+2kbm
i=4 → am+3kbm
xy z = a...aa...aa...aa...ab...b L
2
x y y z
m+ k m
Therefore: a b L
m+ k m k≥ 1
a b L
BUT: L = {a b : n 0}
n n
m+ k m
a b L CONTRADICTION!
Therefore: Our assumption that L is a
regular language is not true
We pick w=a b b a
m m m m
Write a b b a =xyz
m m m m
Thus: y = a , k 1
k
x y z=a b b a
m m m m
y = a , k 1
k
i = 0, 1, 2, ...
xy z L
Thus:
2
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
m+ k m m m
a b b a L k 1
m+ k m m m
a b b a L CONTRADICTION!