Is $L=\{w\mid \text{ same number of 010 and 101}\}$ regular?

262 Views Asked by At

I tried to prove that this language is regular using NFA or regular expressions and didn't succeed.

I would like to see some solutions

1

There are 1 best solutions below

3
On

This is not a regular language. The "problem" is you need to count how many $010$ and how many $101$ strings appear in a word and regular languages don't know how to do this.

For a more formal proof start by defining a homomorphism $0 \mapsto 00100$ and $1 \mapsto 11011$. If your language was regular, then the inverse image of the homomorphism is also regular, but this inverse image is just $$\{ w \mid 0,1\; \mbox{appears the same number of times}\}.$$ Intersecting it with the language $\{0^n 1^m\}$ (which is also regular) you get another regular language which is $\{0^n 1^n\}$ - contradiction.