Theory of Computation · NFA
Introduction to Non-Determinism and NFA
Overview
A Non-deterministic Finite Automaton (NFA) is the non-deterministic counterpart of the DFA: from a given state on a given input symbol, the machine is not forced to end up in exactly one state.
Non-determinism matters because it models exhaustive search and backtracking, which can give better solutions, even though no real machine is actually non-deterministic.
Key concepts
- Non-deterministic Finite Automaton (NFA): a finite automaton in which, from a given state on a given input symbol, the machine is not forced to end up in exactly one state.
- Non-determinism: starting from one state, on seeing an input, the machine may be in none of the states, many states, or even just one state. All of these are allowed.
- DFA contrast: from a state on an input, the next state is uniquely determined (exactly one state).
- Transition behaviour of an NFA: a relation, not a function — one (state, symbol) pair can map to a set of states (possibly empty).
- Physical reality: most machines used in daily life are deterministic — a computer, any mechanical device, and even human beings.
A deterministic machine cannot make copies of itself; a non-deterministic machine can make many copies of itself depending on the input, each copy following a different computation path.
Non-deterministic machines are not real: no real machine can actually be non-deterministic. - Why study non-determinism: some problems are solved by exhaustive search — searching all possible solutions — together with backtracking; exhaustive search and backtracking can give better solutions.
How it works
- In a deterministic machine, starting from state Q1 on input W you go to some particular state Q2 or Qn — a single, fixed next state.
- In a non-deterministic machine, starting from state Q1 on input W, the machine may branch to many states Q1, Q2, ..., Qn simultaneously, or to none.
- Hence the transition behaviour of an NFA is a relation: one (state, symbol) pair can map to a set of states, possibly empty.
- A non-deterministic machine can make many copies of itself depending on the input, and each copy follows a different computation path.
- Non-determinism is very important when you have to deal with exhaustive search and backtracking; determinism is important when you do not want to do any backtracking.
- Though non-determinism is not real, it can be implemented by a deterministic machine (i.e., a deterministic machine can simulate it).
Drawing the diagram…
Worked examples
Chess example. In a game such as chess, at every step you must take some move, and based on your move the final output (win or lose) is decided; if you change the move, the output can change.
- A deterministic machine takes only one decision at any step and then either loses or wins.
- A non-deterministic machine can take many moves at the same time and produces all possible combinations by the end; therefore some of them may win and some may lose.
Comparison
| Aspect | Deterministic machine (DFA) | Non-deterministic machine (NFA) |
|---|---|---|
| Next state from Q1 on input W | Exactly one particular state (Q2 or Qn) | Many states (Q1, Q2, ..., Qn), or none, or one |
| Copies of itself | Cannot make copies of itself | Can make many copies of itself depending on the input |
| Real / physical? | Real — computers, mechanical devices, human beings are deterministic | Not real — no real machine can actually be non-deterministic |
| Decision making | Takes only one decision at any step; then wins or loses | Takes many moves at the same time; produces all possible combinations |
| Search style | No backtracking | Exhaustive search and backtracking |
| Use | When backtracking is not wanted | When exhaustive search / backtracking is needed |
Revision summary
- NFA = non-deterministic finite automaton; it is the non-deterministic version of the DFA.
- On a single input from a single state, an NFA may go to many states, one state, or no state.
- Non-determinism = "none, many, or one" possible next states.
- Non-deterministic machines can make many copies of themselves; deterministic machines cannot.
- Non-deterministic machines are not real — no real machine is non-deterministic.
- Reason to study NFAs: they model exhaustive search and backtracking, which can give better solutions.
- Chess analogy: a DFA plays one move at a time; an NFA plays all moves at once and produces all possible combinations, so some paths win and some lose.
- Non-determinism can be implemented (simulated) by a deterministic machine.
Previous-year exam insights
- An NFA with n states is equivalent to a DFA with at most states (subset construction); this bound is tight, since there are NFAs whose minimal equivalent DFA has exactly states.
Asked inGATE 2026GATE 2025GATE 2001UGC NET 2012 - NFAs and DFAs accept exactly the same class of languages (the regular languages): every NFA can be converted algorithmically to an equivalent DFA, so non-determinism adds no power to finite automata.
Asked inGATE 2008GATE 1998GATE 1994GATE 1992UGC NET 2012 - Non-determinism does not add power to Turing machines either (every NTM has an equivalent DTM), but it does add power to pushdown automata: non-deterministic PDAs accept strictly more languages than deterministic PDAs, so an NPDA cannot in general be converted to an equivalent DPA.
Asked inGATE 2008GATE 1998GATE 1994GATE 1992UGC NET 2012 - The subset construction builds DFA states as sets of NFA states: the start state is the epsilon-closure of the NFA start state, a DFA state is accepting if it contains any NFA accepting state, and the empty set of NFA states is a valid (dead/non-accepting) DFA state.
Asked inGATE 2026GATE 2005 - An NFA may have epsilon (empty-string) transitions, so its transition function maps a (state, symbol-or-epsilon) pair to a set of states; the epsilon-closure of a state set must be taken before and after each symbol move when converting to a DFA.
- A language is regular iff some NFA accepts it iff some DFA accepts it; an NFA with fewer states than any equivalent DFA may exist, and the minimal DFA is unique up to isomorphism, so the number of states of the minimal DFA is a property of the language, not of the chosen NFA.
Asked inGATE 2025