MyhillNerode Theorem in Automata



Deterministic Finite Automata (DFA) are abstract machines that read a string of symbols and decide whether to accept or reject it based on a set of states and transitions and final states. Sometimes DFA has some unnecessary states while converting from NFA and we need to minimize the DFA to find the smallest DFA that recognizes the same language as a given DFA.

In this chapter, we will see the table filling method which is known as MyhillNerode Theorem for minimizing DFAs.

Concepts of DFA Minimization

Before understanding the table filling method, let's see why DFA minimization is important. Suppose we have a DFA with many states, possibly redundant. A minimized DFA, recognizing the same language with fewer states, offers several advantages

  • Simplicity − Easier to understand and visualize the behavior of the automaton.
  • Efficiency− Less memory and processing power required to implement the DFA.
  • Optimization − Improved performance in applications using the minimized DFA.

MyhillNerode Theorem

The theorem states that a language L is regular if L~ (L~ is relation on strings x and y, where no distinguishable extension for x and y) has a finite number of equivalence classes, and if this number is N, then there are N states in a minimal Deterministic Finite Automaton (DFA) recognizing L.

To see this theorem in action, let us consider a DFA and the corresponding table filling method.

Algorithm

The algorithm for the theorem is as follows −

  • Create a table with all possible pairs of states from the given DFA. Each cell in the table will represent a pair of states, like (A, B), (C, D), etc.
  • Mark all pairs where P belongs to the final state, and Q does not belong to the final state. This means that for each pair of states in the table, check whether one state is a final state, and the other is not. If this condition is met, we mark that pair in the table.
  • If there are any unmarked pairs PQ, such that the transition of P on X and the transition of Q on X is marked, then mark PQ, where X is an input symbol. After marking the pairs in the second step, we move on to the unmarked pairs. For each unmarked pair (P, Q), check their transitions on every input symbol (X). If both P and Q transition to a pair that is already marked in the table, then mark the pair (P, Q).
  • Repeat step 3 until you cannot make any new markings in the table. This means we have exhausted all possible combinations and identified all the distinguishable pairs of states.
  • At the end combine all the unmarked pairs and make them a single state in the minimized DFA.

Example of Myhill-Nerode Theorem

Consider we have a DFA like below −

Myhill-Nerode Theorem

Here,

  • States: {A, B, C, D, E, F}
  • Input Symbols: {0, 1}
  • Start State: A
  • Final States: {C, D, E}

State Transition Table

The state transition table will be like the shown here −

State 0 1
A B C
B A D
C E A
D E F
E E F
F F F

To make the table for the theorem we need 6 × 6 table, but the upper triangle is not needed, so we can remove them.

upper triangle

After the first step, we jump to the second step to fill the table −

upper triangle 1

For any pair (A, C) any one is final, then mark it, for (C, F) one is final so mark it, for (C,D) both are final so not marked. Like (A, B) both are non-final so do not mark it.

Based on the 3rd stage, we pick unmarked cells and check.

For a pair (B, A), check −

  • δ(B, 0) = A and δ(A, 0) = B, since the new pair (B, A) is not marked, nothing will be marked now.
  • δ(B, 1) = D and δ(A, 1) = C, since the new pair (C, D) is not marked, nothing will be marked now.

For a pair (D, C), check −

  • δ(D, 0) = E and δ(C, 0) = E, since the new pair (E, E) is not in the table, nothing will be marked now.
  • δ(D, 1) = F and δ(C, 1) = F, since the new pair (F, F) is not in the table, nothing will be marked now.

For a pair (E, C), check −

  • δ(E, 0) = E and δ(C, 0) = E, since the new pair (E, E) is not in the table, nothing will be marked now.
  • δ(E, 1) = F and δ(C, 1) = F, since the new pair (F, F) is not in the table, nothing will be marked now.

For a pair (E, D), check −

  • δ(E, 0) = E and δ(D, 0) = E, since the new pair (E, E) is not in the table, nothing will be marked now.
  • δ(E, 1) = F and δ(D, 1) = F, since the new pair (F, F) is not in the table, nothing will be marked now.

For a pair (F, A), check −

  • δ(F, 0) = F and δ(A, 0) = B, since the new pair (F, B) is not marked, nothing will be marked now.
  • δ(F, 1) = F and δ(A, 1) = C, since the new pair (F, C) is marked, then we have to mark the current pair (F, A) also.

For a pair (F, B), check −

  • δ(F, 0) = F and δ(B, 0) = A, since the new pair (F, A) is marked in the previous step, we have to mark (F, B).
  • δ(F, 1) = F and δ(B, 1) = C, since the new pair (F, C) is marked, then we have to mark the current pair (F, A) also.

Now let us see the updated table once −

Updated Table

In step 4, it states repeat step 3 until there is no other marks. You can check, but here we do not have any new marking in the next iteration. So go to the next step.

The unmarked pairs are (B, A), (D, C), (E, C), (E, D)

Now let us draw the minimized DFA

Minimized DFA

(D, C), (E, C), (E, D) contains the common elements so these are merged. And we are getting the minimized DFA.

Conclusion

The table filling method, or Myhill-Nerode Theorem, gives us a structured approach to minimizing DFAs. By systematically analyzing state transitions and identifying equivalent states, we can achieve a smaller DFA that recognizes the same language. The minimized DFA provides benefits optimization in many sense. Here we explained the table filling style with examples and explanations.

Advertisements