DFA vs NFA: Formal Differences and NFA-to-DFA Conversion

DFA vs NFA: Formal Differences and NFA-to-DFA Conversion

Verified Sources
Sep 12, 2026

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

  1. 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 QQ be the set of states and Σ\Sigma the input alphabet.

  • DFA has a transition function: δ:Q×ΣQ\delta: Q \times \Sigma \to Q so each pair (q,a)(q,a) yields a single next state.

  • NFA has a transition function: δ:Q×Σ2Q\delta: Q \times \Sigma \to 2^{Q} so each pair (q,a)(q,a) yields a set of next states. If the NFA also allows ε-transitions, transitions may additionally be: δ:Q×{ϵ}2Q\delta: Q \times \{\epsilon\} \to 2^Q

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

  1. 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)

AspectDFANFA
DeterminismExactly one next state for each (q,a)(q,a)Potentially many next states for each (q,a)(q,a)
Current “status” while processing inputA single current stateA set of possible current states
Computation modelSingle path simulationBranching computation; acceptance if any branch accepts
AcceptanceReach an accepting stateReach an accepting state along at least one nondet branch
Typical conversion to other modelNFA \to DFA via subset constructionDFA is a special case of NFA

These are consistent with the formal language equivalence between DFA and NFA models.

Footnotes

  1. 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 2Q2^{|Q|} DFA states because each DFA state is a subset of NFA states. This affects practical efficiency.

Subset Construction (NFA → DFA) Lifecycle

Start state

1

Use the ε-closure of NFA start state(s) as the DFA start subset."

Transitions

2

For each DFA subset S and symbol a, compute move(S,a) then take ε-closure."

Accepting states

3

Mark any DFA subset containing an NFA accepting state as accepting."

Repeat

4

Process newly discovered subsets until no new subsets appear."

Procedure: Convert an NFA (with or without ε) to an equivalent DFA (Subset Construction)

  1. 1
    Step 1

    Let the NFA be (Q,Σ,δ,q0,F)(Q, \Sigma, \delta, q_0, F). If ε-transitions exist, treat them explicitly. (DFA will use the same alphabet Σ\Sigma.)

  2. 2
    Step 2

    For each state qq, compute ε-closure(q)\text{ε-closure}(q) = set of states reachable from qq using only ε-transitions.

  3. 3
    Step 3

    Let the DFA start state be S0=ε-closure({q0})S_0 = \text{ε-closure}(\{q_0\}) (or just {q0}\{q_0\} if no ε).

  4. 4
    Step 4

    For a DFA state represented by subset SQS \subseteq Q and symbol aΣa \in \Sigma, compute:

    1. move(S,a)=qSδ(q,a)\text{move}(S,a) = \bigcup_{q \in S}\delta(q,a)
    2. If ε exists, take closure: T=ε-closure(move(S,a))T = \text{ε-closure}(\text{move}(S,a)) Then set δDFA(S,a)=T\delta_{DFA}(S,a) = T.
  5. 5
    Step 5

    A DFA subset SS is accepting iff SFeqS \cap F eq \emptyset.

  6. 6
    Step 6

    Repeat for each discovered subset SS and each input symbol aa until no new subsets are generated.

  7. 7
    Step 7

    The constructed DFA recognizes the same language as the original NFA.

    Footnotes

    1. 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 NN with:

  • Q={q0,q1,q2}Q = \{q_0, q_1, q_2\}
  • Σ={a,b}\Sigma = \{a,b\}
  • Start state: q0q_0
  • Accepting states: F={q2}F = \{q_2\}
  • Transitions:
    • δ(q0,a)={q0,q1}\delta(q_0,a)=\{q_0,q_1\}
    • δ(q0,b)={q1}\delta(q_0,b)=\{q_1\}
    • δ(q1,a)={q2}\delta(q_1,a)=\{q_2\}
    • δ(q1,b)=\delta(q_1,b)=\emptyset
    • δ(q2,a)=\delta(q_2,a)=\emptyset
    • δ(q2,b)={q2}\delta(q_2,b)=\{q_2\}

We convert to a DFA whose states are subsets of QQ.

Step A: Start subset

  • DFA start state: S0={q0}S_0=\{q_0\}

Step B: Compute transitions

We compute move(S,a)\text{move}(S,a) by unioning NFA transitions from each state in SS.

  1. From S0={q0}S_0=\{q_0\}:
  • on aa: move({q0},a)=δ(q0,a)={q0,q1}\text{move}(\{q_0\},a)=\delta(q_0,a)=\{q_0,q_1\}
    • so δDFA(S0,a)={q0,q1}\delta_{DFA}(S_0,a)=\{q_0,q_1\}
  • on bb: move({q0},b)=δ(q0,b)={q1}\text{move}(\{q_0\},b)=\delta(q_0,b)=\{q_1\}
    • so δDFA(S0,b)={q1}\delta_{DFA}(S_0,b)=\{q_1\}
  1. From S1={q0,q1}S_1=\{q_0,q_1\}:
  • on aa:
    • δ(q0,a)={q0,q1}\delta(q_0,a)=\{q_0,q_1\}
    • δ(q1,a)={q2}\delta(q_1,a)=\{q_2\}
    • union {q0,q1,q2}\Rightarrow \{q_0,q_1,q_2\}
  • on bb:
    • δ(q0,b)={q1}\delta(q_0,b)=\{q_1\}
    • δ(q1,b)=\delta(q_1,b)=\emptyset
    • union {q1}\Rightarrow \{q_1\}
  1. From S2={q1}S_2=\{q_1\}:
  • on aa: δ(q1,a)={q2}\delta(q_1,a)=\{q_2\}
  • on bb: δ(q1,b)=\delta(q_1,b)=\emptyset
  1. From S3={q0,q1,q2}S_3=\{q_0,q_1,q_2\}:
  • on aa:
    • δ(q0,a)={q0,q1}\delta(q_0,a)=\{q_0,q_1\}
    • δ(q1,a)={q2}\delta(q_1,a)=\{q_2\}
    • δ(q2,a)=\delta(q_2,a)=\emptyset
    • union {q0,q1,q2}\Rightarrow \{q_0,q_1,q_2\}
  • on bb:
    • δ(q0,b)={q1}\delta(q_0,b)=\{q_1\}
    • δ(q1,b)=\delta(q_1,b)=\emptyset
    • δ(q2,b)={q2}\delta(q_2,b)=\{q_2\}
    • union {q1,q2}\Rightarrow \{q_1,q_2\}
  1. From S4={q1,q2}S_4=\{q_1,q_2\}:
  • on aa:
    • δ(q1,a)={q2}\delta(q_1,a)=\{q_2\}
    • δ(q2,a)=\delta(q_2,a)=\emptyset
    • union {q2}\Rightarrow \{q_2\}
  • on bb:
    • δ(q1,b)=\delta(q_1,b)=\emptyset
    • δ(q2,b)={q2}\delta(q_2,b)=\{q_2\}
    • union {q2}\Rightarrow \{q_2\}
  1. From S5={q2}S_5=\{q_2\}:
  • on aa: δ(q2,a)=\delta(q_2,a)=\emptyset
  • on bb: δ(q2,b)={q2}\delta(q_2,b)=\{q_2\}
  1. Include the empty subset S=S_\emptyset=\emptyset if it appears:
  • on any symbol, move(,a)=\text{move}(\emptyset,a)=\emptyset

Step C: Accepting subsets

Accepting condition: subset contains q2q_2. So accepting DFA states are:

  • {q0,q1,q2}\{q_0,q_1,q_2\}
  • {q1,q2}\{q_1,q_2\}
  • {q2}\{q_2\}

Summary transition table

DFA subset (state)on aaon bbAccepting?
{q0}\{q_0\}{q0,q1}\{q_0,q_1\}{q1}\{q_1\}No
{q0,q1}\{q_0,q_1\}{q0,q1,q2}\{q_0,q_1,q_2\}{q1}\{q_1\}No
{q1}\{q_1\}{q2}\{q_2\}\emptysetNo
{q0,q1,q2}\{q_0,q_1,q_2\}{q0,q1,q2}\{q_0,q_1,q_2\}{q1,q2}\{q_1,q_2\}Yes
{q1,q2}\{q_1,q_2\}{q2}\{q_2\}{q2}\{q_2\}Yes
{q2}\{q_2\}\emptyset{q2}\{q_2\}Yes
\emptyset\emptyset\emptysetNo

This illustrates how an NFA’s branching behavior is simulated deterministically by tracking subsets of states.

Footnotes

  1. 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

Question 1 of 4
Q1Single choice

In a DFA, the transition function satisfies: