DFA vs NFA: Formal Differences and NFA-to-DFA Conversion
In automata theory, Deterministic Finite Automaton (DFA) and Non-Deterministic Finite Automaton (NFA) are two equivalent models for recognizing Regular Languages.
A key contrast is the Transition Function:
- DFA transitions are deterministic: from a given state and input symbol, there is exactly one next state.
- NFA transitions are non-deterministic: from a given state and input symbol, there may be multiple next states (and possibly via ε-transitions).
Visual intuition
Note: Both DFA and NFA recognize exactly the same class of languages (the regular languages), despite their different operational semantics.
Footnotes
-
Wikipedia — Deterministic finite automaton (DFA) and equivalence with NFA via regular languages. https://en.wikipedia.org/wiki/Deterministic_finite_automaton - Explains DFA formal model and that DFAs recognize regular languages, same as NFAs. ↩
Core formal definitions (transition behavior)
Let be the set of states and the input alphabet.
-
DFA has a transition function: so each pair yields a single next state.
-
NFA has a transition function: so each pair yields a set of next states. If the NFA also allows ε-transitions, transitions may additionally be:
Because an NFA’s current “configuration” is effectively a set of possible states, converting an NFA to a DFA typically builds DFA states that correspond to these subsets.
Footnotes
-
Wikipedia — Subset construction (NFA to DFA / power set construction). https://en.wikipedia.org/wiki/Powerset_construction - Describes constructing a DFA whose states are subsets of NFA states, and the transition/acceptance logic. ↩
DFA vs NFA: Key Operational Differences (Conceptual Scale)
Higher is more characteristic of the model’s behavior.
Side-by-side comparison (what you can and must remember)
| Aspect | DFA | NFA |
|---|---|---|
| Determinism | Exactly one next state for each | Potentially many next states for each |
| Current “status” while processing input | A single current state | A set of possible current states |
| Computation model | Single path simulation | Branching computation; acceptance if any branch accepts |
| Acceptance | Reach an accepting state | Reach an accepting state along at least one nondet branch |
| Typical conversion to other model | NFA DFA via subset construction | DFA is a special case of NFA |
These are consistent with the formal language equivalence between DFA and NFA models.
Footnotes
-
Wikipedia — Deterministic finite automaton (DFA) and equivalence with NFA via regular languages. https://en.wikipedia.org/wiki/Deterministic_finite_automaton - Explains DFA formal model and that DFAs recognize regular languages, same as NFAs. ↩
Pro Tip: Acceptance for NFA
For an NFA, an input string is accepted if there exists at least one nondeterministic sequence of choices that ends in an accepting state.
Warning: DFA construction can blow up in size
Subset construction may produce up to DFA states because each DFA state is a subset of NFA states. This affects practical efficiency.
Subset Construction (NFA → DFA) Lifecycle
Start state
1Use the ε-closure of NFA start state(s) as the DFA start subset."
Transitions
2For each DFA subset S and symbol a, compute move(S,a) then take ε-closure."
Accepting states
3Mark any DFA subset containing an NFA accepting state as accepting."
Repeat
4Process newly discovered subsets until no new subsets appear."
Procedure: Convert an NFA (with or without ε) to an equivalent DFA (Subset Construction)
- 1Step 1
Let the NFA be . If ε-transitions exist, treat them explicitly. (DFA will use the same alphabet .)
- 2Step 2
For each state , compute = set of states reachable from using only ε-transitions.
- 3Step 3
Let the DFA start state be (or just if no ε).
- 4Step 4
For a DFA state represented by subset and symbol , compute:
- If ε exists, take closure: Then set .
- 5Step 5
A DFA subset is accepting iff .
- 6Step 6
Repeat for each discovered subset and each input symbol until no new subsets are generated.
- 7Step 7
The constructed DFA recognizes the same language as the original NFA.
Footnotes
-
Wikipedia — Deterministic finite automaton (DFA) and equivalence with NFA via regular languages. https://en.wikipedia.org/wiki/Deterministic_finite_automaton - Explains DFA formal model and that DFAs recognize regular languages, same as NFAs. ↩
-
Worked example (NFA → DFA) without ε-transitions
Consider an NFA with:
- Start state:
- Accepting states:
- Transitions:
We convert to a DFA whose states are subsets of .
Step A: Start subset
- DFA start state:
Step B: Compute transitions
We compute by unioning NFA transitions from each state in .
- From :
- on :
- so
- on :
- so
- From :
- on :
- union
- on :
- union
- From :
- on :
- on :
- From :
- on :
- union
- on :
- union
- From :
- on :
- union
- on :
- union
- From :
- on :
- on :
- Include the empty subset if it appears:
- on any symbol,
Step C: Accepting subsets
Accepting condition: subset contains . So accepting DFA states are:
Summary transition table
| DFA subset (state) | on | on | Accepting? |
|---|---|---|---|
| No | |||
| No | |||
| No | |||
| Yes | |||
| Yes | |||
| Yes | |||
| No |
This illustrates how an NFA’s branching behavior is simulated deterministically by tracking subsets of states.
Footnotes
-
Wikipedia — Subset construction (NFA to DFA / power set construction). https://en.wikipedia.org/wiki/Powerset_construction - Describes constructing a DFA whose states are subsets of NFA states, and the transition/acceptance logic. ↩
FAQ: Common Pitfalls
Knowledge Check
In a DFA, the transition function satisfies: