Combine 2 DFAs to produce a new DFA that accept L1 U L2

1.4k Views Asked by At

I am trying to solve a problem where i have to create a new DFA that accept $L_1 \cup L_2$ where $L_1 = \{0^{3i} 1^{3j+1} 0^{3k+2} \mid i \in \mathbb{N}, j \in \mathbb{N},k\in \mathbb{N} \}$ and $L_2 = \{0^{2i} 1^{2j+1} 0^{2k} \mid i\in \mathbb{N},j\in \mathbb{N},k\in \mathbb{N} \}$.

I created 2 seperpate DFAs for each of them so far but I don't know how I should union those 2 DFA.

This is for L1: https://i.stack.imgur.com/MSSYH.png1

L2: https://i.stack.imgur.com/YCC9Q.png2

Any help is appreaciated.

1

There are 1 best solutions below

0
On

Use the product construction:

If $M_1=(Q_1, \Sigma, \delta_1, q_{01}, F_1)$ accepts $L_1$ and $M_2=(Q_2, \Sigma, \delta_2, q_{02}, F_2)$ accepts $L_2$, then create a third DFA $$M_3=(Q_1\times Q_2, \Sigma, \delta_3, (q_{01}, q_{02}), F_3)$$ where $\delta_3((q_1,q_2), a)=(\delta_1(q_1,a),\delta_2(q_2,a))$ and $F_3=(F_1\times Q_2)\cup(F_2\times Q_1)$.

In plain English, create a new DFA that has a state for each pair of states in the original two DFA's (one state from each). The transition function will take a pair of states, see where the next state would be for each, and then transition to that pair of states. The accepting states are the pairs of states such that one of the states is an accepting state in one of the original DFA's.