Checking if $L_1 \cup L_2$ is regular language

109 Views Asked by At

Let

$L_1=\{a^n b^r|n \geq 1, r\geq1,n=r\}$

$L_2=\{a^n b^r|n \geq 1, r\geq1,n\neq r\}$

be a non regular languages

$L_1 \cup L_2$ is regular?

I think that $L_1 \cup L_2$ is regular because we can build automaton like this:

(The double circle is 'Accept')

EDIT:

enter image description here

I'm not sure if I'm right

1

There are 1 best solutions below

0
On BEST ANSWER

$L_1\cup L_2=\{a^mb^n:m,n\ge 1\}$, which corresponds to the regular expression $aa^*bb^*$ and is therefore certainly regular, but your DFA isn’t quite right: it accepts the language corresponding to the regular expression $a^*bb^*$, i.e., $\{a^mb^n:m\ge 0\text{ and }n\ge 1\}$. You can fix it by introducing a fourth state $q_0$, making $q_0$ the initial state and making it non-accepting, and adding the transitions $q_0\overset{a}\longrightarrow q_1$ and $q_0\overset{b}\longrightarrow q_3$.