Regular Languages
Regular Languages
Regular Languages
Union, Concatenation, Closure,
Intersection
1
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.
2
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
3
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
4
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) 5
Product DFA for
Intersection
0 P-DFA(L M ) 0
L 1 0
A B [A,C] [A,D]
0, 1 1
1 1 0
0
1 0 [B,C] [B,D]
1
M 0
C D
Which state of p-DFA do we
1 choose for the accepting state?
6
Product DFA for
Intersection
0 P-DFA(L M ) 0
L 1 0
A B [A,C] [A,D]
0, 1 1
1 1 0
0
1 0 [B,C] [B,D]
1
M 0
C D
String 11 accepted by p-
1 DFA. P-DFA not empty
and defines
(LM ), which is regular.
7
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.
8
Product DFA for Difference
L-M
0 p-DFA(L-M)
1 0
L A B 0
[A,C] [A,D]
0, 1
1 1 1
0
0
1 0 [B,C] [B,D]
1
M 0
C D
Which state do we choose as
1 the accepting state?
9
Product DFA for Difference
0 p-DFA(L-M)
1 0
L A B 0
[A,C] [A,D]
0, 1
1 1 1
0
0
1 0 [B,C] [B,D]
1
M 0
C D
p-DFA(L-M) is the empty language
1 in this case. Proof still valid.
We used the same p-DFA to show
that L=M. L-M is RL with no strings
10
Closure Under Complementation: Recall Σ* denotes
all string that can be formed from alphabet Σ.
11