The Wayback Machine - https://web.archive.org/web/20260205074612/https://www.geeksforgeeks.org/theory-of-computation/minimization-of-dfa/

Minimization of DFA

Last Updated : 9 Jan, 2026

DFA minimization stands for converting a given DFA to its equivalent DFA with minimum number of states. DFA minimization is also called as Optimization of DFA and uses partitioning algorithm.
 
Suppose there is a DFA D < Q, Δ, q0, Δ, F > which recognizes a language L. Then the minimized DFA D < Q’, Δ, q0, Δ, F’ > can be constructed for language L as: 


Step 1: We will divide Q (set of states) into two sets. One set will contain all final states and other set will contain non-final states. This partition is called P0. 
Step 2: Initialize k = 1 
Step 3: Find Pk by partitioning the different sets of Pk-1. In each set of Pk-1, we will take all possible pair of states. If two states of a set are distinguishable, we will split the sets into different sets in Pk. 
Step 4: Stop when Pk = Pk-1 (No change in partition) 
Step 5: All states of one set are merged into one. No. of states in minimized DFA will be equal to no. of sets in Pk. 

How to find whether two states in partition Pk are distinguishable ? 
Two states ( qi, qj ) are distinguishable in partition Pk if for any input symbol a, Δ ( qi, a ) and Δ ( qj, a ) are in different sets in partition Pk-1. 
Example 
Consider the following DFA shown in figure.  

fig 1

Step 1. P0 will have two sets of states. One set will contain q1, q2, q4 which are final states of DFA and another set will contain remaining states. So P0 = { { q1, q2, q4 }, { q0, q3, q5 } }. 
Step 2. To calculate P1, we will check whether sets of partition P0 can be partitioned or not: 

i) For set { q1, q2, q4 } : 
Δ( q1, 0 ) = Δ ( q2, 0 ) = q2 and Δ ( q1, 1 ) = Δ( q2, 1 ) = q5, So q1 and q2 are not distinguishable. 
Similarly, Δ( q1, 0 ) = Δ ( q4, 0 ) = q2 and Δ ( q1, 1 ) = Δ ( q4, 1 ) = q5, So q1 and q4 are not distinguishable. 
Since, q1 and q2 are not distinguishable and q1 and q4 are also not distinguishable, So q2 and q4 are not distinguishable. So, { q1, q2, q4 } set will not be partitioned in P1. 

ii) For set { q0, q3, q5 } : 
Δ ( q0, 0 ) = q3 and Δ ( q3, 0 ) = q0 
Δ( q0, 1) = q1 and Δ( q3, 1 ) = q4 
Moves of q0 and q3 on input symbol 0 are q3 and q0 respectively which are in same set in partition P0. Similarly, Moves of q0 and q3 on input symbol 1 are q1 and q4 which are in same set in partition P0. So, q0 and q3 are not distinguishable. 

Δ( q0, 0 ) = q3 and Δ( q5, 0 ) = q5 and Δ( q0, 1 ) = q1 and Δ ( q5, 1 ) = q5 
Moves of q0 and q5 on input symbol 1 are q1 and q5 respectively which are in different set in partition P0. So, q0 and q5 are distinguishable. So, set { q0, q3, q5 } will be partitioned into { q0, q3 } and { q5 }. So, 
P1 = { { q1, q2, q4 }, { q0, q3}, { q5 } } 

To calculate P2, we will check whether sets of partition P1 can be partitioned or not: 
iii) For set { q1, q2, q4 } : 
Δ ( q1, 0 ) = Δ ( q2, 0 ) = q2 and Δ ( q1, 1 ) = Δ( q2, 1 ) = q5, So q1 and q2 are not distinguishable. 
Similarly, Δ ( q1, 0 ) = Δ ( q4, 0 ) = q2 and Δ( q1, 1 ) = Δ( q4, 1 ) = q5, So q1 and q4 are not distinguishable. 
Since, q1 and q2 are not distinguishable and q1 and q4 are also not distinguishable, So q2 and q4 are not distinguishable. So, { q1, q2, q4 } set will not be partitioned in P2. 

iv) For set { q0, q3 } : 
Δ ( q0, 0 ) = q3 and Δ( q3, 0 ) = q0 
Δ ( q0, 1 ) = q1 and Δ ( q3, 1 ) = q4 
Moves of q0 and q3 on input symbol 0 are q3 and q0 respectively which are in same set in partition P1. Similarly, Moves of q0 and q3 on input symbol 1 are q1 and q4 which are in same set in partition P1. So, q0 and q3 are not distinguishable. 

v) For set { q5 }: 
Since we have only one state in this set, it can’t be further partitioned. So, 
P2 = { { q1, q2, q4 }, { q0, q3 }, { q5 } } 
Since, P1=P2. So, this is the final partition. Partition P2 means that q1, q2 and q4 states are merged into one. Similarly, q0 and q3 are merged into one. Minimized DFA corresponding to DFA of Figure 1 is shown in Figure 2 as: 
 

fig 2Example :
Consider a DFA A over the alphabet {0, 1}. Analyze the following statements about A: 

  1. The complement of L(A) is context-free.
  2. L(A) = L((110 + 0)(0 + 1)01)
  3. A is the minimal DFA for the language it accepts.
  4. A accepts all strings over {0, 1} of length at least two.

Analysis:

  • Statement 4 claims that A accepts all strings of length ≥ 2. However, A also accepts the string 0, which has length 1. Hence, statement 4 is false.
  • Statement 3 claims that A is minimal. Using the minimization algorithm:
    • Initial partition: P0 = { {q2}, {q0, q1} }
    • After checking transitions: P1 = { {q2}, {q0, q1} }
    • Since P0 = P1, the minimized DFA merges q0 and q1 into a single state. Therefore, statement 3 is also false.

example

Conclusion: Statements 3 and 4 are false.
Correct Option: D

Advantages:

  • Reduced Complexity: Removes redundant states and transitions, making the DFA simpler, easier to analyze, and modify.
  • Optimal Space Utilization: Occupies less memory and storage, which is useful for large DFAs or memory-limited environments.
  • Improved Performance: Fewer states and transitions lead to faster execution, more efficient computation, and better handling of large inputs.
  • Language Equivalence: Ensures the minimized DFA recognizes the same language, preserving all valid and invalid string behavior.

Disadvantages:

  • Increased Computational Complexity: Calculating state equivalence and merging states can be time-consuming and resource-intensive, especially for large DFAs.
  • Additional Design Effort: Requires careful analysis of states and transitions, which can be error-prone and complex.
  • Loss of Readability: Merged states may make the minimized DFA harder to interpret and understand.
  • Limited to DFAs: Minimization applies only to deterministic automata; NFAs must first be converted to DFAs, which can increase size.
Comment

Explore