NFA to DFA (Subset Construction)
Context: FIT2014_MOC · leg 2 of the Kleene’s Theorem cycle · turns a convenient NFA into a deterministic machine · Assignment 1 hand skill Problem it solves: given an NFA (possibly with -transitions), build a DFA recognising the same language.
Quick Revision
- 🎯 Trigger: an NFA to determinise ➔ make each set of NFA states into a single DFA state, and fill a table until no new sets appear.
- ⚡ Key Constraint: whenever a state joins a set you must also add everything reachable from it along -transitions (-closure) — forgetting this is the standard error.
📐 The idea
- In a DFA ➔ a string traces a unique path to a single ; accepted iff that state is Final; Start State.
- In an NFA ➔ a string traces a set of paths ending in a set of states, , which may have zero, one or many members; accepted iff contains a Final state.
- The construction ➔
- Step relation (no -transitions) ➔
⚙️ The procedure
- Start set ➔ ; then add the -closure (every state reachable from a member along -transitions). This set is the DFA’s Start state.
- Take the first incomplete row of the DFA table; call its set .
- For each letter of the alphabet: compute , then add the -closure of that set. Write it in row , column .
- If the resulting set is new, add it as a new (incomplete) row.
- Repeat until every row is complete — no new sets appear.
- Final states ➔ any DFA state whose set contains an NFA Final state is labelled Final.
📊 Worked trace (no -transitions)
NFA: state 1 is Start with self-loops on and ; ; state 3 Final.
| DFA state (set) | Final? | ||
|---|---|---|---|
| Start | — | ||
| — | |||
| ✓ (contains 3) | |||
| ✓ (contains 3) |
- Reading it ➔ and , which contains the Final state 3 — so is accepted.
📊 Worked trace (with -transitions)
NFA: Start with self-loop ; ; self-loop ; ; Final.
| DFA state (set) | Final? | ||
|---|---|---|---|
| Start | ✓ | ||
| ✓ | |||
| — |
- Start set ➔ closes under to — the machine is “already” in states 2 and 3 before reading anything.
- is a real state ➔ it is the dead/sink state: once there, every letter keeps you there and it is never Final.
✍️ Practice
Practice: An NFA has Start with , , and Final with no outgoing transitions. Determinise it.
Reference solution
DFA state Final? Start — ✓ —
- Key move: the nondeterministic choice at on becomes the single set ; the missing -transition becomes an explicit edge to , making the DFA total. Language: one or more s.
⚠️ Common Mistakes
- 💡 Forgetting the -closure ➔ it must be applied to the Start set and after every letter step; omitting it produces a DFA that rejects strings the NFA accepts.
- 💡 is a legitimate DFA state ➔ don’t leave the cell blank; the DFA must be total, and is the sink.
- 💡 Final = contains an NFA Final state ➔ the whole set need not consist of Final states; one member suffices (matching the NFA’s “some path accepts” rule).
- 💡 Sets, not sequences ➔ and are the same DFA state; normalise the order so you don’t create duplicate rows.
🧠 Active Recall
Why does making each set of NFA states a single DFA state give the right language?
Answer
- Short answer: after reading , the NFA could be in any state of . Tracking that whole set deterministically records exactly the information needed, and the NFA accepts iff the set contains a Final state — which is precisely how the DFA’s Final states are defined.
- Why: Determinising the uncertainty ➔ the nondeterministic “which path?” question is replaced by the deterministic “which set of states am I in?”, and the step relation makes that set a function of the previous set and the letter.
How many states can the resulting DFA have, and why?
Answer
- Short answer: up to for an -state NFA — the DFA’s states are subsets of the NFA’s state set, and in the worst case every subset is reachable.
- Why: Powerset blow-up ➔ this exponential cost is the price of determinism, and it is why NFAs remain the practical design notation even though the two models are equivalent by Kleene’s Theorem.