Minimization of DFA using Myhill-Nerode Theorem

Last Updated : 23 Jul, 2025

The Myhill-Nerode theorem is a fundamental result in the theory of regular languages. It provides a characterization of regular languages and can be used to determine whether or not a language L is regular. Additionally, it helps in finding the minimal number of states required in a Deterministic Finite Automaton (DFA) that recognizes L, provided L is regular. This theorem forms the core of efficient algorithms for DFA minimization.

It helps in two main ways:

  1. Identifying whether a language is regular or not.
  2. Finding the smallest possible DFA (Deterministic Finite Automaton) for a regular language.

Myhill-Nerode Theorem

A language L is regular if and only if the number of equivalence classes (under ∼L​) is finite. Additionally, the number of equivalence classes equals the number of states in the minimal DFA recognizing L.

Read more about Basic Theorems in TOC (Myhill nerode theorem)

Steps for the Minimization of DFA

Step 1: List All State Pairs

  • First, create pairs of all possible states in your DFA.
  • Example: If states are {A, B, C}, pairs will be (A,B), (A,C), (B,C).

Step 2: Mark Final–Non-Final Pairs

  • Look at each pair: If one state is final and the other is non-final, mark this pair as distinguishable.

Step 3: Mark Additional Distinguishable Pairs

  • Check each unmarked pair (P,Q): For every input symbol x, if the transition leads to states (δ(P,x), δ(Q,x)) that are already marked as distinguishable, then mark (P,Q) as distinguishable.
  • Repeat this step until no further pairs can be marked.

Step 4: Combine Remaining States

  • All unmarked pairs represent equivalent states.

Example

Consider the following DFA,

Following is the transition table for the above DFA

Minimizing the above DFA using Myhill-Nerode Theorem:

Step 1: Create the pairs of all the states involved in DFA.

Step 2: Mark all the pairs (Qa, Qb) such a that Qa  is Final state and Qb is Non-Final State.

Step 3: If there is any unmarked pair (Qa, Qb) such a that δ(Qa, x) and δ(Qb, x) is marked, then mark (Qa, Qb). Here x is a input symbol. Repeat this step until no more marking can be made.

  • Check for the unmarked pair Q2, Q1
    • Check when x=0 : δ(Q2, 0) = Q4 and δ(Q1, 0) = Q3, check if the pair Q4, Q3 is marked and no it is not marked.
    • Check when x=1 : δ(Q2, 1) = Q3 and δ(Q1, 1) = Q4, check if the pair Q4, Q3 is marked and no it is not marked.
    • Hence we cannot mark the pair Q2, Q1.
  • Check for the unmarked pair Q3, Q0
    • Check when x=0 : δ(Q3, 0) = Q5 and δ(Q0, 0) = Q1, check if the pair Q5, Q1 is marked and no it is not marked.
    • Check when x=1 : δ(Q3, 1) = Q5 and δ(Q0, 1) = Q2, check if the pair Q5, Q2 is marked and no it is not marked.
    • Hence we cannot mark the pair Q3, Q0.
  • Check for the unmarked pair Q4, Q0
    • Check when x=0 : δ(Q4, 0) = Q5 and δ(Q0, 0) = Q1, check if the pair Q5, Q1 is marked and no it is not marked.
    • Check when x=1 : δ(Q4, 1) = Q5 and δ(Q0, 1) = Q2, check if the pair Q5, Q2 is marked and no it is not marked.
    • Hence we cannot mark the pair Q4, Q0.
  • Check for the unmarked pair Q4, Q3
    • Check when x=0 : δ(Q4, 0) = Q5 and δ(Q3, 0) = Q5, Such pair of state Q5, Q5 don't exists.
    • Check when x=1 : δ(Q4, 1) = Q5 and δ(Q3, 1) = Q5, Such pair of state Q5, Q5 don't exists.
    • Hence we cannot mark the pair Q4, Q3.
  • Check for the unmarked pair Q5, Q1
    • Check when x=0 : δ(Q5, 0) = Q5 and δ(Q1, 0) = Q3, check if the pair Q5, Q3 is marked and yes it is marked.
    • Hence we can mark the pair Q5, Q1.
  • Check for the unmarked pair Q5, Q2
    • Check when x=0 : δ(Q5, 0) = Q5 and δ(Q2, 0) = Q4, check if the pair Q5, Q4 is marked and yes it is marked.
    • Hence we can mark the pair Q5, Q2.
  • We have checked for all the unmarked pairs but don't need to stop here we need to continue this process until no more markings can be made.
  • Check for the unmarked pair Q2, Q1
    • Check when x=0 : δ(Q2, 0) = Q4 and δ(Q1, 0) = Q3, check if the pair Q4, Q3 is marked and no it is not marked.
    • Check when x=1 : δ(Q2, 1) = Q3 and δ(Q1, 1) = Q4, check if the pair Q4, Q3 is marked and no it is not marked.
    • Hence we cannot mark the pair Q2, Q1.
  • Check for the unmarked pair Q3, Q0
    • Check when x=0 : δ(Q3, 0) = Q5 and δ(Q0, 0) = Q1, check if the pair Q5, Q1 is marked and yes it is marked.
    • Hence we can mark the pair Q3, Q0.
  • Check for the unmarked pair Q4, Q0
    • Check when x=0 : δ(Q4, 0) = Q5 and δ(Q0, 0) = Q1, check if the pair Q5, Q1 is marked and yes it is marked.
    • Hence we cannot mark the pair Q4, Q0.
  • Check for the unmarked pair Q4, Q3
    • Check when x=0 : δ(Q4, 0) = Q5 and δ(Q3, 0) = Q5, Such pair of state Q5, Q5 don't exists.
    • Check when x=1 : δ(Q4, 1) = Q5 and δ(Q3, 1) = Q5, Such pair of state Q5, Q5 don't exists.
    • Hence we cannot mark the pair Q4, Q3.
  • Now even though we repeat the procedure we cannot mark the pairs Q2, Q1(since Q4, Q3 is not marked) and Q4, Q3(since Q5, Q5 such pair of states does not exists.). Hence we stop here.

Step 4: Combine all the unmarked pairs and make them as a single state in the minimized DFA.

  • The unmarked Pairs are Q2, Q1 and Q4, Q3 hence we combine them.

Following is the Minimized DFA with Q1Q2 and Q3Q4 as the combined states.

  • Q0 remains as our starting state.
  • Q1 and Q2 were our final states so even we combine them they will remain as the combined final state.
  • Q5 is the another final state we have.
  • If we check the original Transition Table
    • δ(Q0, 0)  was Q1 and δ(Q1, 1) was Q2. As the states are combined, the transition of Q0 on both the inputs 0 and 1 will be to the state Q1Q2.
    • δ(Q1, 0) was Q3, δ(Q1, 1) was Q4 and δ(Q2, 0) was Q4, δ(Q1, 1) was Q3. As the states are combined, the transition of Q1Q2 on both the inputs 0 and 1 will be to the state Q3Q4.
    • δ(Q3, 0) was Q5, δ(Q3, 1) was Q5 and δ(Q4, 0) was Q5, δ(Q4, 1) was Q5. As the states are combined, the transition of Q3Q4 on both the inputs 0 and 1 will be to the state Q5.
    • δ(Q5, 0)  was Q5 and δ(Q5, 1) was Q5. Hence the transition of state Q5 on both the inputs will be to the state Q5 itself.

Transition table for Minimized DFA

Comment

Explore