I have two languages as below.$$L_1=\{a^ncb^n\}\cup\{a^mdb^{2m}\}$$$$L_2=\{a^{2n}cb^{2m+1}\}\cup\{a^{2m+1}db^{2n}\}$$Now, I wonder what is $L_1\cap L_2$. Is it a regular language? Is it context-free?To solve the problem, I feel like I need to solve the following system of equations, but I'm not sure.$$\begin{cases}2n=2m+1\\2m+1=\frac{2n}{2}\end{cases}$$
Given two $a^n b^n$-style languages, how do I find out if their intersection is regular?
formal languages;regular languages;context free
$L_1=\{a^ncb^n\}\cup\{a^mdb^{2m}\}$$L_2=\{a^{2n}cb^{2m+1}\}\cup\{a^{2m+1}db^{2n}\}$If we say $\;L_1=L_{11}\cup L_{12}\;\:$and$\;L_2=L_{21}\cup L_{22}$$L_1\cap L_2=((L_{11}\cap L_{21})\cup (L_{12}\cap L_{21}))\cup ((L_{11}\cap L_{22})\cup (L_{12}\cap L_{22})) $$L_{11}\cap L_{22}\:,\:L_{12}\cap L_{21}\;$will be zero because d and c are different symbols.So $\;L_1\cap L_2=(L_{11}\cap L_{21})\cup  (L_{12}\cap L_{22}) $$L_{11}\cap L_{21}=\emptyset \:\;$because it is not possible for an even number to be equal to an odd number.$\;L_1\cap L_2=L_{12}\cap L_{22}=L=\{a^{2m+1}db^{4m+2}\}$So the language is not regular but context free. It is impossible to construct a finite automaton for this language because finite automaton has a memory that is fixed and cannot thereafter be expanded. ( It cannot store number of a's ) But it is easy to recognize that L is context free since $L=(a(aa)^*db^*)\cap \{a^ndb^{2n}|n\geq 0\}$ ( intersection of a CFL with a regular language is CFL ) And $ \{a^ndb^{2n}|n\geq 0\} $ is context free because there exists a push-down automaton that accepts L. When this automaton sees an $\:a\:$ it pushes 2 $\:a\:$'s into the stack and when $\:d\:$ is the input it changes it's state to a final state and then for each $\:b\:$ it pops an $\:a\:$ from the stack.     