# How does one use the Nerode-Myhill theorem to prove that a language is regular?

Showing that a language is not regular is straight-forward, because all one needs to do is find an infinite set of inputs which has an injective mapping to the set of equivalence classes which compose that language.

How does one show that the set of equivalence classes of $$L$$ is finite? For instance, how would one show that the simple language $$L = \{s: |s| \equiv 0 \mod 2\}$$ has a finite number of equivalence classes?

I think that showing that there is a surjective mapping is not sufficient, because the image may still be of infinite size.

## 1 Answer

It is just as straightforward to show a language is regular using Nerod-Myhill theorem as to show a language is not regular using that theorem since Nerode-Myhill theorem characterizes when a language is a regular.

For example, let us take the simple language $$L=\{s: |s|\equiv 0 \text{ (mod 2)}\}$$. There are two equivalent classes of $$L$$, assuming $$a$$ is a letter in the alphabet.

• $$\left[\epsilon\right]_{\equiv_{L}}=\left\{s: |s|\equiv 0\text{ (mod 2)}\right\}$$
• $$\left[a\right]_{\equiv_{L}}=\left\{s: |s|\equiv 1\text{ (mod 2)}\right\}$$

It should be easy for you to show that the above two classes are well-defined equivalence classes of $$L$$. There are no other equivalence class of $$L$$, since every word belongs to one of two classes. If a word is of even length, it belongs to class $$\left[\epsilon\right]_{\equiv_{L}}$$; otherwise, it belongs to class $$\left[a\right]_{\equiv_{L}}$$.

Hence, there are two equivalence classes of $$L$$ in total. That is, the number of equivalence classes of $$L$$ is finite. According to the Nerode-Myhill theorem, $$L$$ must be regular.

I think that showing that there is a surjective mapping is not sufficient, because the image may still be of infinite size.

I am not sure which surjective mapping you are talking about.

As you can see from the example above, it is enough to show that the union of the finitely many equivalence classes you have found contains all words. Why? If we have another equivalence class $$E,$$ let $$w\in E$$. Then $$w$$ must belong to $$F$$, one of the equivalence classes you have found. Since $$E$$ and $$F$$ share one word, they are the same equivalence class. That is, $$E$$ has been found.

You may want to check a few related questions and answers such as finding separating words (Nerode) and how I can find all equivalence classes by Myhill-Nerode?.