Theorem T2.
The union of two regular languages is a regular language.
Proof.
Let
L
1
and
L
2
be any regular languages, on alphabets
Σ
1
and
Σ
2
respectively. By exercise 5 of exercise set #1,
L
1
and
L
2
are both regular languages on the alphabet
Σ
1
∪
Σ
2
; hence, by D6, there must be a finite automaton on
Σ
1
∪
Σ
2
that accepts exactly the members of
L
1
-say, one with states
Q
1
=
{
q
10
,
…
,
q
1
n
}
, initial state
q
10
, final states
F
1
, and transition functon
δ
1
-and a finite automaton
Σ
1
∪
Σ
2
that accepts exactly the members of
L
2
-say, one with states
Q
2
=
{
q
20
,
…
,
q
2
m
}
, initial state
q
20
, final states
F
2
, and transition function
δ
2
. We assume, without loss of generality, that
Q
1
∩
Q
2
=
∅
. (If the two automata somehow share states, the common states can be replaced with distinct but functionally equivalent states so as to ensure that this condition is met; proving that this is always possible involves a simple double induction, on the number of states to be replaced and on the length of input strings.)
Construct a new
nondeterministic
finite automaton on the alphabet
Σ
1
∪
Σ
2
with states
Q
∪
=
Q
1
∪
Q
2
∪
{
q
∪
}
(where
q
∪
is the new initial state), final states
F
∪
=
{
F
1
∪
F
2
∪
{
q
∪
}
,
if
q
10
∈
F
1
or
q
20
∈
F
2
;
F
1
∪
F
2
otherwise
,
and transition function
δ
∪
defined by
δ
∪
(
q
,
a
)
=
{
{
δ
1
(
q
,
a
)
}
,
if
q
∈
Q
1
;
{
δ
2
(
q
,
a
)
}
,
if
q
∈
Q
2
;
{
δ
1
(
q
10
,
a
)
,
δ
2
(
q
20
,
a
)
}
,
if
q
=
q
∪
.
We shall show that this nondeterministic finite automaton accepts
L
1
∪
L
2
. First of all, there is an easy special case: The nondeterministic finite automaton accepts the null string,
ε
, iff it is a member of
L
1
∪
L
2
. For
ε
is accepted iff the initial state
q
∪
∈
F
∪
, which by the definition of
F
∪
is true iff the initial state of one of the finite automata is a member of the set of final states for that automaton, which in turn is true iff
ε
is accepted by that automaton and hence in either
L
1
or
L
2
.
For longer strings, we need an inductive argument, this time with a base step dealing with strings of length 1; treating such strings in a separate case seems to be the easiest way of dealing with the exceptional transition from the initial state of the nondeterministic finite automaton. The inductive proposition must be formulated with some care, so that it will be general enough: We show that for any non-null string
x
∈
(
Σ
1
∪
Σ
2
)
*
, the result set
δ
∪
^
(
q
∪
,
x
)
on
x
in the nondeterministic finite automaton will have as its sole members the result states
δ
1
^
(
q
10
,
x
)
and
δ
2
^
(
q
20
,
x
)
of the two finite automata on
x
.
Base step.
If
|
x
|
is 1, the proposition follows directly from the third clause of the definition of
δ
∪
, by D4(b) and D8(b).
Induction step.
Suppose
|
x
|
=
k
+
1
, for some
k
≥
1
. Then
x
=
wa
, where
w
is a string of length
k
on
Σ
1
∪
Σ
2
and
a
∈
Σ
1
∪
Σ
2
. Now,
δ
∪
^
(
q
∪
,
wa
)
=
⋃
q
∈
δ
∪
^
(
q
∪
,
w
)
δ
∪
(
q
,
a
)
(by D8(b))
=
δ
∪
(
δ
1
^
(
q
10
,
w
)
,
a
)
∪
δ
∪
(
δ
2
^
(
q
20
,
w
)
,
a
)
(by the hypothesis of induction)
=
{
δ
1
(
δ
1
^
(
q
10
,
w
)
,
a
)
,
δ
2
(
δ
2
^
(
q
20
,
w
)
,
a
)
}
(by the definition of
δ
∪
)
=
{
δ
1
^
(
q
10
,
wa
)
,
δ
2
^
(
q
20
,
wa
)
}
(by D4(b))
since
δ
1
^
(
q
10
,
w
)
∈
Q
1
and
δ
2
^
(
q
20
,
w
)
∈
Q
2
. This completes the induction.
Now, first let
x
be any member of
L
1
(other than
ε
). The result state of the finite automaton for
L
1
on
x
is a final state of that finite automaton, by D5, and hence also a final state of the nondeterministic finite automaton, by the definition of
F
∪
. Since this result state is in the result set of the nondeterministic finite automaton on
x
, the nondeterministic finite automaton accepts
x
, by D9. Similarly, if
x
∈
L
2
,
x
≠
ε
, then the nondeterministic finite automaton accepts
x
.
Conversely, let
x
by any member of
(
Σ
1
∪
Σ
2
)
*
-
ε
that is accepted by the nondeterministic finite automaton. By D9, the result set of the nondeterministic finite automaton on
x
has as a member some final state
q
f
of the nondeterministic finite automaton. This
q
f
cannot be
q
∪
, since it is reached by a non-empty sequence of transitions, and there are no transitions into
q
∪
. It must therefore be a member of
F
1
or of
F
2
. Suppose it is a member of
F
1
. Since
F
1
⊆
Q
1
,
q
f
∈
Q
1
. Hence, by the inductive argument,
q
f
=
δ
1
^
(
q
10
,
x
)
, since
δ
2
^
(
q
20
,
x
)
∉
Q
1
. Therefore, the finite automaton for
L
1
accepts
x
, which is to say that
x
∈
L
1
. Similarly, if
q
f
∈
F
2
, then
x
∈
L
2
.
Thus the nondeterministic finite automaton accepts
x
iff either
x
∈
L
1
or
x
∈
L
2
, that is, iff
x
∈
L
1
∪
L
2
. This has now been shown to hold both for
x
=
ε
and for
x
≠
ε
. Hence, by D10, the nondeterministic finite automaton accepts
L
1
∪
L
2
. Hence, by theorem T1,
L
1
∪
L
2
is regular.
•
File translated from T
E
X by
T
T
M
, version 3.61.
On 9 Jul 2004, 10:20.