Proof of Myhill Nerode Theorem of Toc

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

CS 4510 : Automata and Complexity : Spring 2010

Myhill-Nerode Theorem
Subrahmanyam Kalyanasundaram
January 26, 2010
Myhill-Nerode theorem gives a necessary and sucient condition for a language to be regular. The
pumping lemma gives only a necessary condition for a language to be regular, and Myhill-Nerode
theorem does one better in that respect. The theorem was proved by John Myhill and Anil Nerode
in 1958. We state the necessary denitions and the theorem below, and explain the proof in a
top-down manner.
Denition 1 (Distinguishable by a language). Let r, j be strings and 1 be a language over the
same alphabet . r, j are said to be distinguishable by 1 if .

such that r. 1 and j. , 1


or vice versa.
Also, if r and j are not distinguishable by 1, they are said to be indistinguishable by 1. This is
denoted by r

j.
Exercise 1
Show that

is an equivalence relation.
Denition 2 (Pairwise Distinguishable). Let 1 be a language and A be a set of strings. A is
pairwise distinguishable by 1 if every two distinct strings r, j A are distinguishable by 1.
Denition 3 (Index). The index of a language 1 is the size of the largest set A of strings which
is pairwise distinguishable by 1.
These are the denitions we need. The theorem is stated below.
Theorem 1 (Myhill-Nerode Theorem). Language 1 is regular if and only if it has a nite index.
Moreover, the index of 1 is equal to the size of the smallest DFA which recognizes 1.
The proof of the theorem follows by the following two lemmas.
Lemma 1. If 1 is recognized by a DFA with / states, then index(1) /.
Lemma 2. If index(1) = / < , then there exists a DFA with / states that recognizes 1.
The proof of the theorem follows very easily once we assume the above two lemmas.
1
Proof of Myhill-Nerode Theorem. We have by denition, 1 is regular there exists a DFA which
recognizes 1.
Suppose 1 is regular. Choose the smallest (least number of states) DFA that recognizes 1. Let /
be the number of states of this DFA. By lemma 1, index(1) /. In particular
index(1) Size of the smallest DFA that recognizes 1
This also implies that 1 has nite index as well. This shows one direction of the theorem.
For the other direction, let index(1) = / < . Then by lemma 2 there exists a DFA with / states
that recognizes 1. This shows the other direction of the theorem, that 1 is regular. This also shows
that
Size of the smallest DFA that recognizes 1 index(1)
By the above two inequalities, we can conclude that index(1) = the size of the smallest DFA that
recognizes 1.
Now let us see the proofs of the lemmas. Note that we use the notation c(, r) for strings r

.
c(, r) denotes the state that the DFA reaches starting from after reading the string r.
Proof of Lemma 1. We prove this by contradiction. We have a language 1 recognized by a DFA
with / states. We assume, for the sake of contradiction, that index(1) /. This means that there
is a set A, A /, such that A is pairwise distinguishable by 1.
Let ` be the DFA with / states that recognizes 1. Let
0
be the start state of `. We have A /.
Then by pigeonhole principle, there exist two distinct r, j A such that c(
0
, r) = c(
0
, j).
Now we shall assert that r, j are pairwise indistinguishable, thus contradicting our assumption that
index(1) /. Consider any .

.
c(
0
, r.) = c(c(
0
, r), .) = c(c(
0
, j), .) = c(
0
, j.)
So r. 1 j. 1. r, j are pairwise indistinguishable, and hence by contradiction, index(1)
/.
Proof of Lemma 2. Suppose index(1) = /. We have to show the existence of a DFA with / states
that recognizes 1. We shall in fact, construct such a DFA. Let A = {r
1
, r
2
, . . . , r

} be a largest
set which is pairwise distinguishable by 1 (the existence of A follows by the denition of index).
We build DFA ` = (Q, , c,
0
, 1). is chosen to be the same as the alphabet of 1. We choose
Q = {
1
,
2
, . . . ,

}. It would be useful to think of each

as corresponding to the string r

A.
For each o , we dene c(

, o) as follows. Consider the string r

o. We have r

for some
r

A. This follows from the fact that A is a largest pairwise distinguishable set by 1. If r

for any r

, this would mean that A {r

o} would be a bigger pairwise distinguishable set by 1.


Now dene c(

, o) =

.
Similarly, we have the empty string -

for some

. Set

=
0
as the starting state.
We claim (and shall prove soon) that c(

, n) =

.
Dene 1 = {

1}. We have dened all the components of the DFA ` now. All that remains
is to show that this DFA recognizes 1. Suppose r 1. Then r

for some r

, such that r

1
2
(Why?). By the above claim,
r = -r

= c(
0
, r) =

But

1 since r

1. So r is recognized by `.
If r , 1, then r

for some r

, 1. Like above, we get that c(


0
, r) =

. Again

, 1 since
r

, 1. So in this case ` does not recognize r. So ` recognizes exactly the language 1.


The only part that we are yet to prove is the claim above.
Proof of Claim. The claim is that c(

, n) =

.
We prove this by induction on n, the length of n.
When n = 0, n = -. In this case c(

, n) = c(

, -) =

. The claim is true since r

- = r

.
When n = 1, the claim is true by the denition of the transition function c.
When n 1, we use induction. Suppose the claim holds for all n such that n |. Let n
be such that n = | + 1. Let n = o where = | and o = 1, o . We have
c(

, n) = c(

, o) = c(c(

, ), o) = c(

1
, o) =

2
where

1
= c(

, ) and

2
= c(

1
, o). This means that r

and r

2
o (this
follows by induction hypothesis). The claim is true since
r

n = r

1
o

2
3

You might also like