You can edit almost every page by Creating an account and confirming your email.

Union of two regular languages

From EverybodyWiki Bios & Wiki

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

For any regular languages L1 and L2, language L1∪L2 is regular.

Proof

Since L1 and L2 are regular, there exist NFAs N1, N2 that recognize L1 and L2.

Let

N1=(Q1, Σ, T1, q1, A1)
N2=(Q2, Σ, T2, q2, A2)[clarification needed]

Construct

N=(Q, Σ, T, q0, A1∪A2)

where

Q=Q1∪Q2∪{q0}
T(q,x)={T1(q,x)ifq∈Q1T2(q,x)ifq∈Q2{q1,q2}ifq=q0 and x=ϵ∅ifq=q0 and x≠ϵ

In the following, we shall use p→x,Tq to denote q∈E(T(p,x))[clarification needed]

Let w be a string from L1∪L2. Without loss of generality assume w∈L1.

Let w=x1x2⋯xm where m≥0,xi∈Σ

Since N1 accepts x1x2⋯xm, there exist r0,r1,⋯rm∈Q1 such that[clarification needed]

q1→ϵ,T1r0→x1,T1r1→x2,T1r2⋯rm−1→xm,T1rm,rm∈A1

Since T1(q,x)=T(q,x) ∀q∈Q1∀x∈Σ

r0∈E(T1(q1,ϵ))⇒r0∈E(T(q1,ϵ))
r1∈E(T1(r0,x1))⇒r1∈E(T(r0,x1))
⋮
rm∈E(T1(rm−1,xm))⇒rm∈E(T(rm−1,xm))


We can therefore substitute T for T1 and rewrite the above path as


q1→ϵ,Tr0→x1,Tr1→x2,Tr2⋯rm−1→xm,Trm,rm∈A1∪A2,r0,r1,⋯rm∈Q


Furthermore,

T(q0,ϵ)={q1,q2}⇒q1∈T(q0,ϵ)⇒q1∈E(T(q0,ϵ))⇒q0→ϵ,Tq1

and

q0→ϵ,Tq1→ϵ,Tr0⇒q0→ϵ,Tr0


The above path can be rewritten as


q0→ϵ,Tr0→x1,Tr1→x2,Tr2⋯rm−1→xm,Trm,rm∈A1∪A2,r0,r1,⋯rm∈Q


Therefore, N accepts x1x2⋯xm and the proof is complete.[clarification needed]


Note: The idea drawn from this mathematical proof for constructing a machine to recognize L1∪L2 is to create an initial state and connect it to the initial states of L1 and L2 using ϵ arrows.

References

  • Michael Sipser, Introduction to the Theory of Computation ISBN 0-534-94728-X Search this book on .. (See . Theorem 1.22, section 1.2, pg. 59.)


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.