Minimization Practice: Table Filling
Six minimization problems on paper, from a small automaton to a product automaton and a DFA given as a 5-tuple, and a tool that draws a new DFA every time and checks the unreachable states, every cell of the pair table, the classes and the quotient automaton.
Last updated:
On this page we practise the minimization of Minimization: Removing Unreachable States and Minimization: Merging Equivalent States from start to finish:
on paper, in six problems that grow step by step, and then in a tool that draws a new DFA every time and checks each step.
Problems on paper
In each problem, minimize the automaton in the four steps of Minimization: the full order:
- Find the states that cannot be reached, and remove them.
- Fill in the table of pairs round by round. In every cell you mark, write a distinguishing word; the word written in round has length . In the cell of a pair that is still unmarked when the process stops, write .
- List the classes of equivalent states.
- Build the quotient automaton: a transition table and a drawing. Each class is named after its first state, for example .
In all the problems ; in a table, the arrow marks the start state and the star the accepting states.
The state names are numbered, because what each state remembers becomes clear only after minimization.
Problem 1. Minimize the following DFA, and describe its language in words.
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ(q_0, a) = q_0
- δ(q_0, b) = q_1
- δ(q_1, a) = q_2
- δ(q_1, b) = q_1
- δ(q_2, a) = q_3
- δ(q_2, b) = q_2
- δ(q_3, a) = q_3
- δ(q_3, b) = q_2
Answer
States that cannot be reached: none. is reached by the word , by and by .
The table. Round 0 marks the four pairs of an accepting and a non-accepting state.
In round 1 the letter leads to , a pair from round 0, so is marked with the word .
The pair goes on to and on to , that is, to a single state, and is never marked.
In round 2 no pair is left to mark, and the process stops.
The classes: , , .
The quotient automaton:
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ([q_0], a) = [q_0]
- δ([q_0], b) = [q_1]
- δ([q_1], a) = [q_2]
- δ([q_1], b) = [q_1]
- δ([q_2], a) = [q_2]
- δ([q_2], b) = [q_2]
The language: the words that contain . The class remembers “the last letter is and has not been found yet”, and is an accepting trap state.
Problem 2. Minimize the following DFA. How many states does the quotient automaton have?
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ(q_0, a) = q_2
- δ(q_0, b) = q_0
- δ(q_2, a) = q_2
- δ(q_2, b) = q_3
- δ(q_3, a) = q_2
- δ(q_3, b) = q_1
- δ(q_1, a) = q_1
- δ(q_1, b) = q_1
Answer
Every state can be reached: by the word , by and by .
Round 0: the three pairs of . Round 1: the letter leads to , and and to and , which are not accepting; so and are marked with the word .
Round 2: the letter leads to , marked in round 1, so is marked with the word .
Every pair is marked.
Every pair has a distinguishing word, so each class is a single state:
, , , . The quotient automaton has four states, and it is the automaton itself after renaming :
minimization merges nothing. The language is the words that contain , and and remember the progress and in the pattern.
Problem 3. Minimize the following DFA, and describe its language in words.
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ(q_0, a) = q_1
- δ(q_0, b) = q_3
- δ(q_1, a) = q_3
- δ(q_1, b) = q_2
- δ(q_2, a) = q_4
- δ(q_2, b) = q_2
- δ(q_4, a) = q_2
- δ(q_4, b) = q_4
- δ(q_3, a) = q_3
- δ(q_3, b) = q_3
- δ(q_5, a) = q_2
- δ(q_5, b) = q_3
Hint
The reachable states are found by a search: , and adds to every state that a letter leads to from a state in , until no state is added.
Answer
States that cannot be reached: , , , and .
No letter leads to , so it is removed. Five states and ten pairs remain.
Round 0: the six pairs of a state from and a state from .
Round 1: the letter leads to , which is accepting, and and to , which is not; so and are marked with the word .
Round 2: the letter leads to , marked in round 1, so is marked with the word .
Round 3: only is left, and leads it to and to :
the same pair, which is unmarked. No new pair, and the process stops.
The classes: , , , .
The quotient automaton:
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ([q_0], a) = [q_1]
- δ([q_0], b) = [q_3]
- δ([q_1], a) = [q_3]
- δ([q_1], b) = [q_2]
- δ([q_2], a) = [q_2]
- δ([q_2], b) = [q_2]
- δ([q_3], a) = [q_3]
- δ([q_3], b) = [q_3]
The language: the words that start with . is a rejecting trap state, and an accepting trap state.
Problem 4. Minimize the following DFA. In which round is the pair marked, and why not in an earlier round?
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ(q_0, a) = q_1
- δ(q_0, b) = q_1
- δ(q_1, a) = q_2
- δ(q_1, b) = q_2
- δ(q_2, a) = q_5
- δ(q_2, b) = q_3
- δ(q_3, a) = q_4
- δ(q_3, b) = q_3
- δ(q_4, a) = q_3
- δ(q_4, b) = q_4
- δ(q_5, a) = q_5
- δ(q_5, b) = q_5
Hint
In round , check every pair that is not marked yet: does one of the letters lead it to a pair marked in round ?
Write the word of every marked pair beside it, so that the word of the next round is the letter followed by that word.
Answer
Every state can be reached: by the word , by , by , by and by .
- Round 0: the eight pairs of a state from and a state from .
- Round 1: the letter leads to , which is accepting, and to , which are not. So , and are marked with the word .
- Round 2: the letter leads to and to , two pairs from round 1. So and are marked with the word .
- Round 3: the letter leads to , marked in round 2. So is marked with the word .
- Round 4: only is left, which leads to and to . No new pair, and the process stops.
The pair is marked in round 3, because its shortest distinguishing word has length 3.
A word of length at most 2 takes to , or , and to , and none of these is accepting; a pair marked in round is a pair whose shortest distinguishing word has length .
The word also distinguishes and .
The classes: , , , , .
The quotient automaton:
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ([q_0], a) = [q_1]
- δ([q_0], b) = [q_1]
- δ([q_1], a) = [q_2]
- δ([q_1], b) = [q_2]
- δ([q_2], a) = [q_5]
- δ([q_2], b) = [q_3]
- δ([q_3], a) = [q_3]
- δ([q_3], b) = [q_3]
- δ([q_5], a) = [q_5]
- δ([q_5], b) = [q_5]
, and count how many letters have been read, up to three, so the language is the words whose third letter is .
Problem 5. The DFA recognizes the words whose second letter is :
(start), (one letter read), (the second letter is ; an accepting trap state) and (the second letter is ; a rejecting trap state).
The DFA recognizes the words that end with : after , and at the start and after .
| State | on | on |
|---|---|---|
| State | on | on |
|---|---|---|
Build the product automaton of and for the language “the second letter is or ends with ” (all eight pairs), and minimize it.
Hint
In the product , and for “or” a pair is accepting when or .
Answer
The product. Five pairs are accepting: the four with , and .
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ((q_0,p_0), a) = (q_1,p_a)
- δ((q_0,p_0), b) = (q_1,p_0)
- δ((q_1,p_0), a) = (q_ok,p_a)
- δ((q_1,p_0), b) = (q_trap,p_0)
- δ((q_0,p_a), a) = (q_1,p_a)
- δ((q_0,p_a), b) = (q_1,p_0)
- δ((q_1,p_a), a) = (q_ok,p_a)
- δ((q_1,p_a), b) = (q_trap,p_0)
- δ((q_trap,p_0), a) = (q_trap,p_a)
- δ((q_trap,p_0), b) = (q_trap,p_0)
- δ((q_ok,p_a), a) = (q_ok,p_a)
- δ((q_ok,p_a), b) = (q_ok,p_0)
- δ((q_trap,p_a), a) = (q_trap,p_a)
- δ((q_trap,p_a), b) = (q_trap,p_0)
- δ((q_ok,p_0), a) = (q_ok,p_a)
- δ((q_ok,p_0), b) = (q_ok,p_0)
States that cannot be reached: . The component says that no letter has been read, and the component that the last letter is ; and in the table, no pair goes to it.
Seven states and 21 pairs remain.
The table: the pairs by the round in which each pair is marked.
- Round 0 (): the 12 pairs of a state from and an accepting state.
- Round 1 (): with and with , and with and with . The letter leads both states of to , which is accepting, and and to , which is not.
- Round 2 (): , and . The letter leads them to and to (twice), pairs from round 1.
- Round 3 (): . The letter leads it to , marked in round 2.
- Not marked (): . Each letter leads both states to the same state, and round 4 marks no new pair.
The classes: , and each of the other five states on its own.
The quotient automaton:
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ([(q_0,p_0)], a) = [(q_1,p_a)]
- δ([(q_0,p_0)], b) = [(q_1,p_0)]
- δ([(q_1,p_0)], a) = [(q_ok,p_0)]
- δ([(q_1,p_0)], b) = [(q_trap,p_0)]
- δ([(q_1,p_a)], a) = [(q_ok,p_0)]
- δ([(q_1,p_a)], b) = [(q_trap,p_0)]
- δ([(q_ok,p_0)], a) = [(q_ok,p_0)]
- δ([(q_ok,p_0)], b) = [(q_ok,p_0)]
- δ([(q_trap,p_0)], a) = [(q_trap,p_a)]
- δ([(q_trap,p_0)], b) = [(q_trap,p_0)]
- δ([(q_trap,p_a)], a) = [(q_trap,p_a)]
- δ([(q_trap,p_a)], b) = [(q_trap,p_0)]
Once the second letter is the word is known to be in the language, so there is no need to remember the last letter:
this is why and merge. In the other states both the number of letters read and the last letter have to be remembered, and no pair merges.
Problem 6. Let be the DFA with , , and the transition function:
Minimize , write the quotient automaton also as a 5-tuple , and describe the language of in words.
Hint
Draw from the table: each row gives two arrows, and one more arrow marks the start state .
In a drawing it is easier to see which states can be reached.
Answer
States that cannot be reached: . From we reach and , from there and , and none of these states has a transition to .
The table on the five states . Round 0: the six pairs of a state from and a state from .
Round 1: the letter leads and to and , which are accepting, and to ; so and are marked with the word .
Round 2: and are left. The pair goes on to and on to , and the pair goes on to and on to ; neither reaches a marked pair, and the process stops.
The classes: , , .
The quotient automaton: , , , and in the table:
| State | on | on |
|---|---|---|
Transitions of the diagram:
- δ([q_0], a) = [q_1]
- δ([q_0], b) = [q_0]
- δ([q_1], a) = [q_2]
- δ([q_1], b) = [q_0]
- δ([q_2], a) = [q_2]
- δ([q_2], b) = [q_2]
The language: the words in which every is immediately followed by .
is “every so far was followed by ”, is “the last letter is and no has followed it yet”, and is a rejecting trap state:
was found.
A new automaton every time
The tool draws a complete DFA over with 3 to 7 states:
sometimes it has a state that cannot be reached, and sometimes no pair is equivalent.
You go through the four steps of the problems above, and the tool checks each step before it opens the next.
In the pair table it checks every cell: a word is right if it really distinguishes the two states, even when it is not a shortest one, and a right cell shows the round in which the pair is marked.
The button “New automaton” draws another automaton; there is no limit on the number of automata, and nothing is stored.
The tool needs JavaScript. Practise with the problems on paper above.
Back to Minimization: Merging Equivalent States, or see the glossary.