Proposition 4.
Regular Languages are closed under complementation, i.e., if
L
is regular then
L
= Σ
*
\
L
is also regular.
Proof.
•
If
L
is regular, then there is a DFA
M
= (
Q,
Σ
, δ, q
0
, F
) such that
L
=
L
(
M
).
•
Then,
M
= (
Q,
Σ
, δ, q
0
, Q
\
F
) (i.e., switch accept and non-accept states) accepts
L
.
What happens if
M
(above) was an
NFA
?
Closure under
∩
Proposition 5.
Regular Languages are closed under intersection, i.e., if
L
1
and
L
2
are regular
then
L
1
∩
L
2
is also regular.
Proof.
Observe that
L
1
∩
L
2
=
L
1
∪
L
2
.
Since regular languages are closed under union and
complementation, we have
•
L
1
and
L
2
are regular
•
L
1
∪
L
2
is regular
•
Hence,
L
1
∩
L
2
=
L
1
∪
L
2
is regular.
Is there a direct proof for intersection (yielding a smaller DFA)?
Cross-Product Construction
Let
M
1
= (
Q
1
,
Σ
, δ
1
, q
1
, F
1
) and
M
2
= (
Q
2
,
Σ
, δ
2
, q
2
, F
2
) be DFAs recognizing
L
1
and
L
2
, respec-
tively.
Idea: Run
M
1
and
M
2
in parallel on the same input and accept if both
M
1
and
M
2
accept.
Consider
M
= (
Q,
Σ
, δ, q
0
, F
) defined as follows
•
Q
=
Q
1
×
Q
2
•
q
0
=
h
q
1
, q
2
i
•
δ
(
h
p
1
, p
2
i
, a
) =
h
δ
1
(
p
1
, a
)
, δ
2
(
p
2
, a
)
i
•
F
=
F
1
×
F
2
M
accepts
L
1
∩
L
2
(exercise)
What happens if
M
1
and
M
2
where NFAs? Still works! Set
δ
(
h
p
1
, p
2
i
, a
) =
δ
1
(
p
1
, a
)
×
δ
2
(
p
2
, a
).