Myhill–Nerode Practice
Complete the automaton of the classes in a tool that checks every transition, and questions to solve on paper: the classes of a finite language and of new languages, the classes of the complement, a bound on the number of classes of an intersection, and a claim to refute.
Last updated:
On this page we practise building the automaton from the classes of a language, and using the Myhill–Nerode classes in proofs, following the lesson “Myhill–Nerode: What a State Remembers”.
Completing the automaton of the classes
Choose a language. The tool shows its classes, each named by its shortest word (among several, the first in alphabetical order), and we complete :
where each class goes on each letter, and which classes are accepting.
By the construction of , the transition from on is the class of , so each cell asks which class one word belongs to.
For a wrong answer the tool shows a distinguishing word.
The tool needs JavaScript. Use Questions 1 to 3 on paper.
Questions on paper
Question 1. Let . How many classes does have? Find a representative word for each class, prove that every two of them are distinguishable, and build .
Hint
After no continuation brings the word into the language.
Which other words behave like that?
Answer
Five classes: , , , and , all the other words:
they are not prefixes of , or , so no continuation of them is in the language, and no word distinguishes them.
Distinguishing words: distinguishes every word of from every word of , because and ; and :
(, ); and : ; and :
(, ); and : (, ).
The words and are in the same class, because both are in the language and every nonempty continuation takes both out of it.
| State | on | on |
|---|---|---|
The class is a rejecting trap state.
Question 2. Let
the words that end with and contain no . How many states does the smallest DFA for have?
Prove the lower bound, and build .
Hint
What must be remembered: the last letter, and whether has already appeared.
Is the empty word in the class of another word?
Answer
Four. The words are pairwise distinguishable: distinguishes from each of the others; and :
(, ); and , and also and :
(, ). Four states are enough: ; is the words that end in and contain no ; is the words that end in and contain no ; is the words that contain .
The table is a DFA for :
| State | on | on |
|---|---|---|
Question 3. Let . Find the classes of and .
Answer
Three classes, by the remainder of on division by 3: (remainder 0, accepting), (remainder 1) and (remainder 2).
Words with the same remainder are indistinguishable, because for every the remainder of depends only on the remainder of and on the word .
Distinguishing words: between and the other two, and between and ( is in the language, is not).
The transitions: adds 1 to the remainder and subtracts 1, that is and .
Question 4. Let be a language and its complement.
Prove that for every two words , if and only if .
What follows about the numbers of classes of and of ?
Hint
For every word , if and only if . What does this say about the statement ""?
Answer
For every , , and likewise for . So if and only if , if and only if , because negating both sides of an “if and only if” does not change its truth value.
The condition holds for every for exactly when it holds for every for , so the two relations are the same, and the two languages have the same classes.
In particular, for a language that has a DFA, the smallest DFAs for and for have the same number of states; this agrees with the complement automaton, which changes only the accepting states.
Question 5. Suppose the language has a DFA and classes, and the language has a DFA and classes.
Prove that has at most classes. Give an example in which exactly is reached.
Hint
What are the states of the product automaton of and ?
What does the lower bound say about any DFA for the language?
Answer
By the smallest-automaton theorem, has a DFA with states and has a DFA with states.
Their product automaton, with the accepting states of “and”, recognizes and has states.
By the lower bound, if had more than classes, one word from each class would give more than pairwise distinguishable words, and the product automaton would need more than states; a contradiction.
Example: and , “the number of is even” and “the number of is even”, two classes each.
The intersection is from the lesson, with four classes.
Question 6. Prove or refute: if and both have a DFA, then has at most as many classes as .
Answer
The claim is false; a counterexample: . The language has one class, because every word and every continuation of it is in the language.
The language has three classes: , and (all the other words, which are not prefixes of , so no continuation of them is in the language); distinguishes from the other two, and distinguishes from .
Continue with The Lower Bound in Action, go back to Myhill–Nerode: What a State Remembers, or see the glossary.