Exercise

Myhill–Nerode Classes and Minimization: Practice with Tools

Collect words that are pairwise distinguishable and get a lower bound, check whether an automaton is minimal with a certificate of words, minimize an automaton through the words that reach its states, and map each state of a large automaton to a class of the smallest automaton.

Last updated:


On this practice page we practise the Myhill–Nerode classes from the lesson “Myhill–Nerode: What a State Remembers”:
we collect words that are pairwise distinguishable, use them to check whether an automaton is minimal, and minimize an automaton through the words that reach its states.
In every tool on this page a word is written with the letters aa and bb⁠, and the empty word ε\varepsilon is written as an empty field or as ε.

Collecting distinguishable words

Choose a language, and predict how many states the smallest DFA for the language has.
Then add words one at a time. The tool adds a word only if it is distinguishable from every word already in the list; if not, it says which of them it is equivalent to.
The number of words in the list is a lower bound on the number of states, by the lower bound.
When no further word can be added, show the smallest automaton and compare it with your prediction.

The tool needs JavaScript. Use the questions on paper at the end of the page.

Minimality certificate

By the lower bound, a DFA with nn states is the smallest for its language if there are nn words, every two of them distinguishable.
This is a minimality certificate. Choose an automaton, and write for each state a word that reaches it.
If every two words are distinguishable, there is a certificate.
If not, there are two possible reasons: a state that no word reaches, or, by the claim on equivalent states and indistinguishable words, two equivalent states.
Find the equivalent states and check them in the row under the table.

The tool needs JavaScript. Use Question 3 on paper.

Minimization through words

Choose a large automaton. For each state write a word that reaches it, or tick that there is none.
Then split the states into groups by the class of their words:
two states are in the same group if their words are indistinguishable.
By the same claim, the groups are exactly the states that minimization merges.
After a successful check the tool shows the minimized automaton and, for each pair of groups, a shortest distinguishing word; table filling writes a word of the same length for a pair of states from these groups.

The tool needs JavaScript. Use Question 4 on paper.

Mapping to the smallest automaton

The tool shows a large automaton and the automaton MLM_L of its language, whose states are the classes.
Choose a class for each state of the large automaton. The tool checks that the choice takes the start state to the start state, an accepting state to an accepting class, and a transition to a transition, as in the proof of the uniqueness theorem.
States that received the same class are the states that minimization merges.

The tool needs JavaScript. Use Question 4 on paper.

Questions on paper

Question 1. Let Laba={u aba v∣u,v∈{a,b}∗}L_{aba}=\{u\,aba\,v \mid u,v\in\{a,b\}^*\}⁠, the words that contain abaaba⁠. How many classes does LabaL_{aba} have?
Find a representative word for each class, prove that every two of them are distinguishable, and build MLabaM_{L_{aba}}⁠.

Hint

What must be remembered while reading? Which part of abaaba does the end of the word already match?

Answer

Four classes: [ε][\varepsilon]⁠, [a][a]⁠, [ab][ab] and [aba]=Laba[aba]=L_{aba}⁠. The distinguishing words:
ε\varepsilon and aa⁠: baba (ba∉Lababa\notin L_{aba}⁠, aba∈Labaaba\in L_{aba}⁠); ε\varepsilon and abab⁠:
aa⁠; aa and abab⁠: aa (aa∉Labaaa\notin L_{aba}⁠, aba∈Labaaba\in L_{aba}⁠); in every pair with abaaba⁠:
ε\varepsilon⁠. The automaton MLabaM_{L_{aba}}⁠:

Stateon aaon bb
→[ε]\to[\varepsilon][a][a][ε][\varepsilon]
[a][a][a][a][ab][ab]
[ab][ab][aba][aba][ε][\varepsilon]
∗ [aba]{*}\,[aba][aba][aba][aba][aba]

Question 2. Let L=={c u c∣c∈{a,b}, u∈{a,b}∗}∪{a,b}L_{=}=\{c\,u\,c \mid c\in\{a,b\},\ u\in\{a,b\}^*\}\cup\{a,b\}⁠, the words that start and end with the same letter.
How many states does the smallest DFA for L=L_{=} have? Prove the lower bound.

Hint

After the first letter we must remember which letter it was, and whether the last letter equals it.
Is ε\varepsilon in the class of another word?

Answer

Five. The words ε,a,b,ab,ba\varepsilon,a,b,ab,ba are pairwise distinguishable: for ε\varepsilon and aa⁠, ε\varepsilon and bb⁠, and every pair of a word from {a,b}\{a,b\} and a word from {ab,ba}\{ab,ba\}⁠, the word ε\varepsilon distinguishes, because a,b∈L=a,b\in L_{=} and the other words are not.
ε\varepsilon and abab⁠: z=bz=b (b∈L=b\in L_{=}⁠, abb∉L=abb\notin L_{=}⁠). ε\varepsilon and baba⁠:
z=az=a⁠. aa and bb⁠: z=az=a (aa∈L=aa\in L_{=}⁠, ba∉L=ba\notin L_{=}⁠). abab and baba⁠:
z=az=a (aba∈L=aba\in L_{=}⁠, baa∉L=baa\notin L_{=}⁠). So every DFA for the language has at least five states, and the automaton of the classes shows that five suffice:
from [a][a] the letter aa returns to [a][a] and bb leads to [ab][ab]⁠, and from [ab][ab] the letter aa returns to [a][a] and bb stays; symmetrically for [b][b] and [ba][ba]⁠.

Question 3. For the counter of aa modulo 4 from the practice of Minimizing Automata by Table Filling (q0,q1,q2,q3q_0,q_1,q_2,q_3⁠, accepting q0q_0 and q2q_2⁠), write for each state a word that reaches it.
Are the words a minimality certificate? What follows from the answer?

Answer

For example ε\varepsilon⁠, aa⁠, aaaa⁠, aaaaaa⁠. This is not a certificate:
ε≡Laa\varepsilon\equiv_L aa⁠, because for every zz the numbers of aa in zz and in aazaaz differ by 2, so both are even or both are odd.
By the claim on equivalent states and indistinguishable words, q0≡q2q_0\equiv q_2⁠, and in the same way q1≡q3q_1\equiv q_3⁠.
The automaton is not minimal, and the language (an even number of aa⁠) has two classes.

Question 4. In the nine-state product automaton for the language “contains aaaa or contains bbbb” from the lesson on table filling, to which class of LL does the word that reaches each state belong?
Which states merge?

Hint

The classes are [ε],[a],[b],[aa][\varepsilon],[a],[b],[aa]⁠. Is there a state that no word reaches?

Answer

(q0,p0)(q_0,p_0) is reached by the word ε\varepsilon⁠, so it is in the class [ε][\varepsilon]⁠; (qa,p0)(q_a,p_0) by the word aa⁠, in the class [a][a]⁠; (q0,pb)(q_0,p_b) by the word bb⁠, in the class [b][b]⁠; the five accepting states are reached by words of LL⁠, in the class [aa][aa]⁠, and merge into one state.
(qa,pb)(q_a,p_b) is not reachable, so it gets no class, and minimization removes it.

Continue with Myhill–Nerode Practice, go back to Myhill–Nerode: What a State Remembers, or see the glossary.