Finite Automata

Minimizing a DFA

Two states that can never be told apart by any input are redundant. Minimization finds and merges them, producing the smallest DFA for a language.

Two DFA states are equivalent if, for every possible remaining input suffix, one leads to acceptance exactly when the other does — no string run from this point on can ever tell them apart. Equivalent states are redundant: merging them produces a smaller machine that still decides exactly the same language.

An unminimized example

This 3-state DFA accepts binary strings ending in 0. Watch what q1 and q2 actually do: both are accept states, and on a 1 both go straight back to q0. They only look different on a 0 — q1 moves to q2, while q2 loops to itself — but since q1 and q2 behave identically from here on, that difference is invisible to any future input.

q0q1q210

q0q0q1∈ F

Unminimized DFA: strings ending in 0

Finding equivalent states

The standard algorithm (table-filling / partition refinement) starts by splitting states into two groups — accepting and non-accepting — since those are trivially distinguishable (the empty suffix alone tells them apart). Then it repeatedly checks: do any two states in the same group go to different groups on some symbol? If so, split them apart. Repeat until no more splits happen.

Here, {q1, q2} start in the same group (both accepting). On 0: q1 → q2 (accepting group), q2 → q2 (accepting group) — same group, no split needed. On 1: both go to q0 (non-accepting group) — same group again. q1 and q2 never diverge, so they merge into one state.

The minimized result

Merging q1 and q2 collapses the machine to two states — provably the fewest possible for this language, since a DFA for "ends in 0" has to distinguish at least "just saw a 0" from "didn't."

q0q110

q0q0q1∈ F

Minimized DFA: strings ending in 0

Your turn

Exercise

Build a DFA over {0, 1} accepting strings that end in 0. Try to use as few states as possible.

InputExpected
0accept
10accept
100accept
110accept
1reject
01reject
11reject
ε (empty string)reject
← All lessonsOpen Simulator →
On this page
All lessons