1. 1
Closure Properties of
Regular Languages
Union, Concatenation, Closure,
Intersection, Difference, Reversal,
Homomorphism, and Inverse
Homomorphism
2. 2
Review Closure Properties
A closure property is a statement that a
certain operation on languages, when
applied to languages in a class (e.g.,
the regular languages), produces a
result that is also in that class.
3. 3
Closure Under Union
If L and M are regular languages, so is L
M.
Proof: Let R and S be the REs that define L
and M.
Then R+S is a regular expression whose
regular language is L M.
Therefore, regular languages are closed
under union
4. 4
Closure Under
Concatenation and Closure
Same idea:
RS is a regular expression whose language
is LM; therefore LM is regular.
R* is a regular expression whose language
is L*; therefore L* is regular
5. 5
Closure Under Intersection
If L and M are regular languages, then LM is
regular.
Proof: Let L and M be DFA’s whose languages
are L and M, respectively.
Construct C = p-DFA of L and M
Make the accepting states of C be the pairs
consisting of accepting states of both L and
M.
String w accepted by p-DFA iff it is accepted
by both DFA(L) and DFA(M)
6. 6
Product DFA for Intersection
A B
0
1
0, 1
1
C D
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
L
M
P-DFA(L M )
Which state of p-DFA do we
choose for the accepting state?
7. 7
Product DFA for Intersection
A B
0
1
0, 1
1
C D
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
L
M
P-DFA(L M )
String 11 accepted by p-
DFA. P-DFA not empty and
defines
(LM ), which is regular.
8. 8
Closure Under Difference
L– M = strings in L but not M. If L and M are
regular languages, then so is L-M
Proof: Let L and M be DFA’s whose
languages are L and M, respectively.
Construct C = p-DFA of L and M.
Make the accepting states of C be the pairs
where L-state is accepting but M-state is not.
p-DFA defines the RL of L-M.
9. 9
Product DFA for Difference L-
M
A B
0
1
0, 1
C D
1
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
Which state do we choose as
the accepting state?
L
M
p-DFA(L-M)
10. 10
Product DFA for Difference
A B
0
1
0, 1
C D
1
1
0
0
[A,C] [A,D]
0
[B,C]
1
0
1
0
1
[B,D]
0
1
p-DFA(L-M) is the empty language
in this case. Proof still valid.
We used the same p-DFA to show
that L=M. L-M is RL with no strings
L
M
p-DFA(L-M)
11. 11
Closure Under Complementation: Recall Σ* denotes
all string that can be formed from alphabet Σ.
The complement of a language L (with respect
to an alphabet Σ such that Σ* contains L) is Σ* –
L.
Since Σ* is regular, the complement of a
regular language is regular because it is the
difference of regular languages.
12. 12
Closure Under Reversal
Given language L, LR
is the set of strings whose
reversal is in L.
Example: L = {0, 01, 100}; LR
= {0, 10, 001}.
Reversal of all sting in LR
are in L
Prove that RLs are closed under reversal:
Let E be a regular expression for L.
We show how to reverse E, to obtain a regular
expression ER
for LR
.
13. 13
Reversal of a Regular Expression
Basis: If E = a, ε, or ∅, then ER
= E.
Induction:
If E=F+G, then ER
= FR
+ GR
.
If E=FG, then ER
= GR
FR
If E=F*, then ER
= (FR
)*.
Example find ER
of 0(10)* + 10*
14. 14
Example: Reversal of a RE
Let E = 0(10)* + 10*.
ER
= (0(10)*)R
+ (10*)R
(union rule)
= ((10)*)R
0R
+ (0*)R
1R
(concat. rule)
= ((10)*)R
0+ (0*)R
1 (basis)
= ((0R
1R
)*0 + (0R
)*1 (closure rules)
= (01)*0 + 0*1 (basis)
15. 15
Homomorphisms
A homomorphism on an alphabet is a function
that assigns a string to every symbol in that
alphabet
Example on ={0,1}
Define h(0) = ab h(1) = ε
Extend to strings by h(a1…an) = h(a1)…h(an)
example: h(01010) = ababab
h(L)={h(w)|w is in L}=homomorphism of L
Language formed by applying h to every string in
L
16. 16
Closure Under
Homomorphism
If L is a regular language, and h is a
homomorphism on its alphabet, then
h(L)= {h(w)|w is in L} is also a regular
language.
Proof: Let E be a regular expression for L.
Apply h to each symbol in E.
Language of resulting RE, h(L), is regular
17. 17
h(0) = ab; h(1) = ε.
L is the language of RE = 01* + 10*
Find the RE of h(L) and simplify
Do on board
Exercise:
18. 18
h(0) = ab; h(1) = ε.
L is the language of RE = 01* + 10*
RE of h(L)=abε* + ε(ab)*
ε* = ε
ε is the identity under concatenation.
abε*+ε(ab)*=abε+ε(ab)*=ab+(ab)*.
ab is contained in (ab)*
RE for h(L) is (ab)*
19. 19
Inverse Homomorphism of a string
h-1
(w) notation for inverse homomorphism of
w
w’=h-1
(w), iff h(w’)=w
Given h, to answer the question
“Is w’ an inverse homomorphism of w?”,
apply h to every character in w’
If the result is w, then w’=h-1
(w)
20. 20
Inverse homomorphisms of
a language
Let be the alphabet of L
Let h be a homomorphism defined on
Let h(L) be a homomorphism defined on
L Let h-1
(L) be an inverse homomorphism
of L defined by h(L)
h-1
(L) ={w’ in | such that h(w’) is in h(L)}
21. 21
Finding h-1
(L)
Only practical if h(L) contains just a few strings
Suppose h(L) contains w1 and w2
Let h(L) be a homomorphism of L defined on
h-1
(L) consist of all strings w’ that can be
constructed from characters in such that h(w’) is
w1 or w2
Only practical if contains just a few characters
22. 22
Example of an h-1
(L) problem
Let h(0) = ab; h(1) = ε.
Let h(L) = {abab, baba}
Find h-1
(L)
23. 23
Solution of h-1
(L) problem
={0,1}
h(0) = ab; h(1) = ε.
h(L) = {abab, baba}
h-1
(L) = {all w defined on {0,1} such that h(w) is
either abab or baba}
No w such that h(w) = baba.
h-1
(L) = any w with two 0’s and any number of
1’s because h(w)=abab
All 1’s become ε that is identity of concat.