Prove that the language $A= \left \{ x\in\left \{ 0, 1 \right \}^{*}\mid\#\left ( 0, x \right )= \#\left ( 1, x \right ) \right \}$ is not regular.

automataformal-languagesregular expressionsregular-language

I initially tried using the pumping lemma, with little success, albeit I still think it's possible. I've been directed that using the Myhill-Nerode theorem would be optimal, but I'm struggling. I need to show that $A$ has infinitely many equivalence classes. I also need to know what those equivalence classes are. Anything to help me better understand this problem would be greatly appreciated.

Best Answer

HINT: For the Myhill-Nerode approach, define

$$d:\{0,1\}^*\to\Bbb Z:w\mapsto|w|_0-|w|_1\,.$$

Thus, for instance, $d(01001)=3-2=1$, while $d(111)=0-3=-3$. Show that $x$ and $y$ are in the same Myhill-Nerode equivalence class if and only if $d(x)=d(y)$.