Hello can someone give me advice to proof the following language are regular or not regular
$$ \begin{array}{l}{\text { 1. } L_{1}=\{x y \mid x, y \in\{a, b\}^* \text { and } \#_{a}(x)=\#_b(y)\}} \\ {\text { 2. } L_{2}=\left\{x c y \mid x, y \in\{a, b\}^{*} \text { and } \#_{a}(x)=\#_b(y)\right\}}\end{array} $$
I don't know how to start some advice would be nice. Thanks
The language $L_2$ is not regular. If it was, its intersection with the regular language $a^*cb^*$ would be regular. But this intersection is $\{a^ncb^n \mid n \geqslant 0\}$, a language which is not regular (this can be easily proved by the pumping lemma or using Nerode's equivalence).
The language $L_1$ is equal to $\{a,b\}^*$ and hence is regular. It suffices to prove that every word $w$ can be written as $w = uv$ with $|u|_a = |v|_b$ (here I use the standard notation $|u|_a$ for the number of occurrences of $a$ in $u$). Let $w =c_1 \dotsm c_n$, where each $c_i$ is a letter. Consider the function $$ f(i) = |c_1 \dotsm c_i|_a - |c_{i+1} \dotsm c_n|_b $$ One has $f(0) = -|w|_b \leqslant 0$ and $f(n) = |w|_a \geqslant 0$. Furthermore, if $c_{i+1} = a$, then $$ f(i+1) = |c_1 \dotsm c_ia|_a - |c_{i+2} \dotsm c_n|_b = 1 + |c_1 \dotsm c_i|_a - |ac_{i+1} \dotsm c_n|_b = f(i) + 1 $$ Similarly, if $c_{i+1} = b$, then $f(i+1) = f(i)-1$. In other words, $f(i)$ goes from a non positive value to a non negative value by increments of $+1$ or $-1$. Therefore, it has to take at least once the value $0$, which gives for $w$ the wanted factorisation.