DFA minimization stands for converting a given DFA to its equivalent DFA with minimum number of states.

**Minimization of DFA**

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 P_{0}. **Step 2:** Initialize k = 1 **Step 3:** Find P_{k} by partitioning the different sets of P_{k-1}. In each set of P_{k-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 P_{k}. **Step 4:** Stop when P_{k} = P_{k-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 P_{k}.

**How to find whether two states in partition P _{k} are distinguishable ?**

Two states ( qi, qj ) are distinguishable in partition P

_{k}if for any input symbol a, δ ( qi, a ) and δ ( qj, a ) are in different sets in partition P

_{k-1}.

**Example**

Consider the following DFA shown in figure.

**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 q3 and q0 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 q3 and q0 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:

**Question :** Consider the given DFA. Which of the following is false?

1. Complement of L(A) is context-free.

2. L(A) = L ( ( 11 * 0 + 0 ) ( 0 + 1 )* 0* 1* )

3. For the language accepted by A, A is the minimal DFA.

4. A accepts all strings over { 0, 1 } of length atleast two.

A. 1 and 3 only

B. 2 and 4 only

C. 2 and 3 only

D. 3 and 4 only

**Solution :** Statement 4 says, it will accept all strings of length atleast 2. But it accepts 0 which is of length 1. So, 4 is false.

Statement 3 says that the DFA is minimal. We will check using the algorithm discussed above.

P0 = { { q2 }, { q0, q1 } }

P1 = { q2 }, { q0, q1 } }. Since, P0 = P1, P1 is the final DFA. q0 and q1 can be merged. So minimal DFA will have two states. Therefore, statement 3 is also false.

So correct option is (D).

This article has been contributed by Sonal Tuteja.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- Conversion from NFA to DFA
- DFA for accepting the language L = { a
^{n}b^{m}| n+m=even } - Program to Implement NFA with epsilon move to DFA Conversion
- DFA in LEX code which accepts even number of zeros and even number of ones
- DFA for Strings not ending with "THE"
- DFA of a string with at least two 0’s and at least two 1’s
- Union process in DFA
- DFA machines accepting odd number of 0’s or/and even number of 1’s
- Concatenation process in DFA
- Complementation process in DFA
- DFA of a string in which 2nd symbol from RHS is 'a'
- Reversal process in DFA
- DFA for accepting the language L = {a
^{n}b^{m}| n+m=odd} - Cross Product Operation in DFA
- DFA of a string in which 3rd symbol from RHS is ‘a’
- Program to construct a DFA which accept the language L = {a
^{n}b^{m}| n mod 2=0, m≥1} - DFA for strings not containing consecutive two a's and starting with 'a'
- Construct DFA which interpreted as binary number is divisible by 2, 3, 4
- Construct a DFA which accept the language L = {w | w ∈ {a,b}* and Na(w) mod 3 = Nb (w) mod 3}
- Construct a DFA which accept the language L = {a
^{n}b^{m}| n > =1, (m) mod 3 = 1}