Exercise

Three Processes on a DFA

Run three processes step by step on one DFA, with its state diagram coloured at each step: the reachable states, the equivalent states by table filling or by splitting into classes, and the classes of words with a distinguishing suffix for every pair.

Last updated:


On this practice page we practise three processes from the lessons Minimization: Removing Unreachable States and Minimization: Merging Equivalent States on one deterministic finite automaton (DFA):
finding the reachable states, finding the equivalent states, and grouping words into the classes that the language does not distinguish.
The three processes run on the same automaton, so the tool on this page shows them on one state diagram and colours it at each step.
Three automata are ready in the tool, and each of them can be edited.

Reachable states

A state is reachable when the run on some word, from the start state ss⁠, ends in it.
The tab “1. Reachable states” builds the sets

R0={s},Ri+1=Ri∪{δ(q,σ)∣q∈Ri, σ∈Σ}R_0=\{s\},\qquad R_{i+1}=R_i\cup\{\delta(q,\sigma)\mid q\in R_i,\ \sigma\in\Sigma\}

one step at a time, where σ\sigma is a letter of the alphabet Σ\Sigma⁠.
Each step adds the states that one more letter leads to, so RiR_i holds the states reached by the words of length at most ii⁠.
The search stops at the first ii with Ri+1=RiR_{i+1}=R_i⁠, and the states outside that set are removed together with the transitions that leave them.

Equivalent states

Two states are equivalent when no word separates them: on every word, the runs from the two states both end in accepting states or both end in states that do not accept.
The tab “2. Equivalent states” runs on the reachable states and offers two methods.

  • Table filling, the method of the lesson: round 0 marks every pair of an accepting and a non-accepting state, and round kk marks a pair when some letter leads it to a pair marked in an earlier round. A pair that is still unmarked after round kk is a pair that no word of length at most kk separates.
  • Splitting into classes (partition refinement) reaches the same classes from the other direction. It starts with two classes, the accepting states and the other states. In each round every state gets a signature: for each letter, the class of the previous round that the letter leads it to. A class whose states have different signatures splits into groups of equal signatures. After round kk⁠, two states are in the same class exactly when no word of length at most kk separates them, as in table filling, and the process stops when no class splits.

The log of the splits records a word for every two classes that split apart:
the letter on which their signatures differ, followed by the word of the two classes that this letter leads to.

Distinguishable words

Two words xx and yy are distinguishable with respect to a language LL when some suffix zz puts exactly one of the words xzxz and yzyz in LL⁠; otherwise they are indistinguishable, and [x][x] is the class of xx⁠.
For a DFA that recognizes LL⁠, this happens exactly when the runs on xx and on yy end in states that are not equivalent, and then a word that separates the two states is such a suffix.

The tab “3. Distinguishable words” groups the words you write into classes, by the state in which the run on each word ends, and gives a distinguishing suffix for every pair; select a cell to see the runs on xzxz and yzyz⁠.
The button “One shortest word per class” writes, for every class, a shortest word whose run ends in it.

The tool needs JavaScript. The questions below can be solved on paper, with the transition table given there.

Questions

The questions are about the third automaton in the tool, “The number of a’s is divisible by 3, with duplicate states”.
Its alphabet is {a,b}\{a,b\}⁠, its start state is q0q_0 and its accepting states are q0q_0 and q3q_3⁠:

Stateon aaon bb
→∗ q0\to {*}\,q_0q1q_1q3q_3
q1q_1q2q_2q4q_4
q2q_2q3q_3q5q_5
∗ q3{*}\,q_3q4q_4q0q_0
q4q_4q5q_5q1q_1
q5q_5q0q_0q2q_2
q6q_6q0q_0q6q_6

Question 1. Compute R0,R1,R2,…R_0,R_1,R_2,\dots until the sets stop growing. Which state is not reachable?
Then go through the steps of the first tab and compare.

Answer

R0={q0}R_0=\{q_0\}⁠, R1={q0,q1,q3}R_1=\{q_0,q_1,q_3\}⁠, R2={q0,q1,q2,q3,q4}R_2=\{q_0,q_1,q_2,q_3,q_4\}⁠, R3={q0,…,q5}R_3=\{q_0,\dots,q_5\} and R4=R3R_4=R_3⁠, so the search stops and R=R3R=R_3⁠.
The state q6q_6 is not reachable: the only arrow that enters it leaves q6q_6 itself.

Question 2. Predict before you run the second tab: how many pairs does round 0 of table filling mark?
Which pairs does round 1 mark, and with which word? What are the classes of equivalent states?
Then check with both methods.

Hint

After q6q_6 is removed, two of the six states accept. In round 1, check for each unmarked pair where the letter aa leads its two states.

Answer

Round 0 marks the 2⋅4=82\cdot4=8 pairs of an accepting state (q0q_0 or q3q_3⁠) and a non-accepting state, with the word ε\varepsilon⁠.
Round 1 marks four pairs, each with the word aa⁠: q1,q2q_1,q_2 and q2,q4q_2,q_4 (the letter aa leads q2q_2 to the accepting q3q_3 and the other state to a non-accepting one), and q1,q5q_1,q_5 and q4,q5q_4,q_5 (the letter aa leads q5q_5 to the accepting q0q_0⁠).
Round 2 marks no pair. The classes are {q0,q3}\{q_0,q_3\}⁠, {q1,q4}\{q_1,q_4\} and {q2,q5}\{q_2,q_5\}⁠:
each state remembers only the number of aa‘s modulo 3. Splitting into classes reaches the same three classes:
in round 1 the class {q1,q2,q4,q5}\{q_1,q_2,q_4,q_5\} splits by the letter aa into {q1,q4}\{q_1,q_4\} and {q2,q5}\{q_2,q_5\}⁠, and round 2 splits nothing.

Question 3. Are the words abab and baba distinguishable with respect to the language of the automaton?
And the words aa and aaaa⁠? Where they are, give a distinguishing suffix.
How many classes of words are there, and what is a shortest word of each class?
Check in the third tab.

Answer

The runs on abab and on baba both end in q4q_4⁠, so the two words are not distinguishable:
[ab]=[ba][ab]=[ba]⁠. The runs on aa and on aaaa end in q1q_1 and q2q_2⁠, which are not equivalent, and the suffix z=az=a distinguishes them:
aa∉Laa\notin L and aaa∈Laaa\in L⁠. There are three classes, one for each class of equivalent states, and the shortest words are ε\varepsilon⁠, aa and aaaa⁠.
Each has length at most 3−1=23-1=2⁠, as the note under the button says.

Back to Minimization: Merging Equivalent States, or see the glossary.