In formal language theory, and in particular the theory of nondeterministic finite automata, it is known that the union of two regular languages is a regular language. This article provides a proof of that statement.
Theorem[edit]
For any regular languages
and
, language
is regular.
Proof
Since
and
are regular, there exist NFAs
that recognize
and
.
Let
![{\displaystyle N_{1}=(Q_{1},\ \Sigma ,\ T_{1},\ q_{1},\ A_{1})}](https://wikimedia.org/api/rest_v1/media/math/render/svg/60b0c3dc0811c3219a360c95171f5493c7621098)
[clarification needed]
Construct
![{\displaystyle N=(Q,\ \Sigma ,\ T,\ q_{0},\ A_{1}\cup A_{2})}](https://wikimedia.org/api/rest_v1/media/math/render/svg/636b80cedc10bb240d7e7e5ed6ab3a75aee793da)
where
![{\displaystyle Q=Q_{1}\cup Q_{2}\cup \{q_{0}\}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/c85d7fbfd3a1fa45cd5794911510abe5400d863a)
![{\displaystyle T(q,x)=\left\{{\begin{array}{lll}T_{1}(q,x)&{\mbox{if}}&q\in Q_{1}\\T_{2}(q,x)&{\mbox{if}}&q\in Q_{2}\\\{q_{1},q_{2}\}&{\mbox{if}}&q=q_{0}\ and\ x=\epsilon \\\emptyset &{\mbox{if}}&q=q_{0}\ and\ x\neq \epsilon \end{array}}\right.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/f4d4110f75cb118a2687d1407ecb0929288172b7)
In the following, we shall use
to denote
[clarification needed]
Let
be a string from
. Without loss of generality assume
.
Let
where
Since
accepts
, there exist
such that[clarification needed]
![{\displaystyle q_{1}{\stackrel {\epsilon ,T_{1}}{\rightarrow }}r_{0}{\stackrel {x_{1},T_{1}}{\rightarrow }}r_{1}{\stackrel {x_{2},T_{1}}{\rightarrow }}r_{2}\cdots r_{m-1}{\stackrel {x_{m},T_{1}}{\rightarrow }}r_{m},r_{m}\in A_{1}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a48d07f432906c662102af49ab1ecf40c7d888fe)
Since
![{\displaystyle r_{0}\in E(T_{1}(q_{1},\epsilon ))\Rightarrow r_{0}\in E(T(q_{1},\epsilon ))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/90afe6e1914ba65c7cf163318bd1afd8ba0488d7)
![{\displaystyle r_{1}\in E(T_{1}(r_{0},x_{1}))\Rightarrow r_{1}\in E(T(r_{0},x_{1}))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/caad9eb0e90dbb80a894cc79d2d841cb0574edce)
![{\displaystyle \vdots }](https://wikimedia.org/api/rest_v1/media/math/render/svg/f8039d9feb6596ae092e5305108722975060c083)
![{\displaystyle r_{m}\in E(T_{1}(r_{m-1},x_{m}))\Rightarrow r_{m}\in E(T(r_{m-1},x_{m}))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e1f96b9bfa788c19ab9318c5c1ed549bb4d3ca7c)
We can therefore substitute
for
and rewrite the above path as
Furthermore,
![{\displaystyle {\begin{array}{lcl}T(q_{0},\epsilon )=\{q_{1},q_{2}\}&\Rightarrow &q_{1}\in T(q_{0},\epsilon )\\\\&\Rightarrow &q_{1}\in E(T(q_{0},\epsilon ))\\\\&\Rightarrow &q_{0}{\stackrel {\epsilon ,T}{\rightarrow }}q_{1}\end{array}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e54723303e02669dbc787a58136341689b548b5c)
and
![{\displaystyle q_{0}{\stackrel {\epsilon ,T}{\rightarrow }}q_{1}{\stackrel {\epsilon ,T}{\rightarrow }}r_{0}\Rightarrow q_{0}{\stackrel {\epsilon ,T}{\rightarrow }}r_{0}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/aa1ee6b8721b9cfb6252c7f5f2b33e6f81e7e022)
The above path can be rewritten as
![{\displaystyle q_{0}{\stackrel {\epsilon ,T}{\rightarrow }}r_{0}{\stackrel {x_{1},T}{\rightarrow }}r_{1}{\stackrel {x_{2},T}{\rightarrow }}r_{2}\cdots r_{m-1}{\stackrel {x_{m},T}{\rightarrow }}r_{m},r_{m}\in A_{1}\cup A_{2},r_{0},r_{1},\cdots r_{m}\in Q}](https://wikimedia.org/api/rest_v1/media/math/render/svg/4ee90c04d4b36763882c311bbc2c5bda2d8750fe)
Therefore,
accepts
and the proof is complete.[clarification needed]
Note: The idea drawn from this mathematical proof for constructing a machine to recognize
is to create an initial state and connect it to the initial states of
and
using
arrows.
References[edit]
This article "Union of two regular languages" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Union of two regular languages. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.