Recall warm-up
- What is ECLOSE(q)?
Stuck? Peek at 1.2.2 ε-NFA and ε-closure
- ε-NFA: δ : Q × (Σ ∪ {ε}) → P(Q).
- ECLOSE(q) = ε-reachable states incl. q (graph reachability on ε-edges).
- Run: start ECLOSE(q₀); each symbol: move, then ECLOSE. Accept iff final set ∩ F ≠ ∅.
- Same power as DFA/NFA; great for wiring machines together.
- When does an NFA accept?
Stuck? Peek at 1.2.1 Nondeterminism and the NFA
- NFA: δ : Q × Σ → P(Q); moves may be 0, 1, many.
- Accept iff some path ends in F ⇔ δ̂(q₀, w) ∩ F ≠ ∅. Track the set of active states.
- DFA ⊆ NFA; NFAs accept exactly the regular languages.
- No dead state needed. Swapping F does NOT complement an NFA.
- How many subsets does a 4-element set have?
Stuck? Peek at 0.2.1 Sets
- x ∈ A (element) vs X ⊆ A (subset). ∅ ⊆ every set. A = B ⇔ A ⊆ B and B ⊆ A.
- A ∪ B, A ∩ B, A − B = A ∩ B̅, A̅ = U − A. De Morgan: (A∪B)̅ = A̅∩B̅, (A∩B)̅ = A̅∪B̅.
- |A ∪ B| = |A| + |B| − |A ∩ B|. |A × B| = |A|·|B|. |P(A)| = 2^|A|.
- |∅| = 0, |{∅}| = 1, P(∅) = {∅}.
The Hook
Real hardware can’t clone itself at every fork, so an NFA can’t run as-is on a chip. But look at how we traced NFAs: we kept the set of active states. There are only finitely many such sets. So make each set a single state of a new machine — and that machine is deterministic. This conversion is called the subset construction, and GATE asks you to run it or to count its states.
Predict First
An NFA has 3 states. At most how many states can the DFA produced by the subset construction have?
Core Concept
Prediction check
Answer: 2³ = 8 — one per subset of {q0, q1, q2}, including ∅ (which plays the role of the dead state). Usually far fewer are reachable.
The construction (NFA → DFA)
- States: subsets of Q (only the reachable ones, in practice).
- Start: {q₀} (for an ε-NFA: ECLOSE(q₀)).
- δ_D(S, a) = ⋃_{q∈S} δ(q, a) (for an ε-NFA: then take ECLOSE).
- Accepting: every subset S with S ∩ F ≠ ∅.
Proof idea: by induction on |w|, δ̂_D({q₀}, w) is exactly the active set of N after w. So D accepts w iff N’s active set contains an accepting state iff N accepts w.
Doing it by hand (lazy construction)
- Write the start set. Put it in a worklist.
- Take a set S from the worklist; for each symbol, compute the target set. Any new set goes into the worklist.
- Repeat until no new sets appear.
- Mark sets containing an NFA accepting state.
- If ∅ appears, it is the dead state (it maps to itself).
ε-NFA → NFA (removing ε-moves)
Keep the same states. New δ'(q, a) = ECLOSE( ⋃_{p ∈ ECLOSE(q)} δ(p, a) ). New accepting set F' = { q | ECLOSE(q) ∩ F ≠ ∅ } — the start state can become accepting this way. The number of states does not change.
| state | ECLOSE | δ′ on a | δ′ on b | accepting? |
|---|---|---|---|---|
| p | {p, q} | {p, q} | {q} | yes (closure meets F) |
| q | {q} | ∅ | {q} | yes |
The 2ⁿ blow-up is real
Language L_k = “the k-th symbol from the end is 1”. NFA: k + 1 states. Any DFA: at least 2ᵏ states. Reason: take two different strings x, y of length k. They differ at some position i; append enough symbols so that position lands exactly k-th from the end: one becomes accepted, the other not. So all 2ᵏ strings of length k need different states.
So: NFA with n states ⇒ equivalent DFA with ≤ 2ⁿ states, and this bound can be (nearly) reached. NFAs can be exponentially more compact.
| pair | separating suffix z | xz | yz |
|---|---|---|---|
| 00 vs 10 | ε | 00 ✗ | 10 ✓ |
| 00 vs 01 | 0 | 000 ✗ | 010 ✓ |
| 01 vs 11 | ε | 01 ✗ | 11 ✓ |
| 10 vs 11 | 0 | 100 ✗ | 110 ✓ |
Counting DFA states in GATE questions
- “Subset construction on this NFA gives how many states?” — run the lazy construction; count only reachable sets; include ∅ if it appears.
- “Minimum DFA states for k-th from end is 1 over {0,1}” — 2ᵏ.
- “k-th from the start” — only k + 2 (Lesson 1.1.3). Don’t mix them up.
Putting it together
- Subset construction: a DFA state = a set of NFA states; accepting iff it meets F; ∅ is the dead state.
- At most 2ⁿ states; count only reachable sets.
- k-th from the end needs 2ᵏ DFA states; k-th from the start only k + 2.
Visual
NFA ends-with-ab: q0 —a,b→ q0, q0 —a→ q1, q1 —b→ q2 (final)
writing states as numbers {0},{0,1},... :
set S on a on b
→{0} {0,1} {0}
{0,1} {0,1} {0,2}
*{0,2} {0,1} {0} ← contains 2 (final)
3 reachable sets out of 2³ = 8 possible; ∅ never appears (q0 always active)
States: {0}, {0,1}, {0,2}
Transitions: {0}>{0}: b; {0}>{0,1}: a; {0,1}>{0,1}: a; {0,1}>{0,2}: b; {0,2}>{0,1}: a; {0,2}>{0}: b
3rd-from-end NFA (q0..q3) → reachable sets: every {0} ∪ X with X ⊆ {1,2,3} = 2³ = 8 DFA states
each set records which of the last 3 symbols were 1: {0,1,3} after ...1?1 etc.Worked Examples
NFA over {a}: q0 ─a→ q1, q1 ─a→ q0, q1 ─a→ q1; F = {q1}. Run the subset construction.
Show the full solution
{q0} ─a→ {q1}; {q1} ─a→ {q0, q1}; {q0,q1} ─a→ {q1} ∪ {q0,q1} = {q0,q1}. States: {q0}, {q1}*, {q0,q1}*. 3 states. Language: aⁿ, n ≥ 1. (Minimizing would merge the last two → 2 states.)
Remove ε-moves from the a*b* ε-NFA (p ─a→ p, p ─ε→ q, q ─b→ q, F = {q}).
Show the full solution
ECLOSE(p) = {p,q}, ECLOSE(q) = {q}. δ'(p,a) = ECLOSE(δ(p,a) ∪ δ(q,a)) = ECLOSE({p}) = {p,q}. δ'(p,b) = ECLOSE({q}) = {q}. δ'(q,a) = ∅, δ'(q,b) = {q}. F' = {p, q} (ECLOSE(p) contains q). Check ε is still accepted: p ∈ F' ✓; “ba”: p ─b→ q ─a→ ∅ reject ✓.
NFA over {0,1}: A ─0→ {A,B}, A ─1→ {A}, B ─0→ {C}, B ─1→ {C}, C has no moves, F = {C}. How many states does the subset-construction DFA have, and what is the language?
Show the full solution
{A} ─0→ {A,B}, ─1→ {A}. {A,B} ─0→ {A,B,C}, ─1→ {A,C}. {A,B,C} ─0→ {A,B,C}, ─1→ {A,C}. {A,C} ─0→ {A,B}, ─1→ {A}. Reachable: {A}, {A,B}, {A,B,C}*, {A,C}* = 4 states. Language: second symbol from the end is 0 (2² = 4 ✓).
GATE Traps
- Count only reachable subsets — not all 2ⁿ.
- If ∅ appears, it is a real DFA state (the dead state) — count it.
- A subset is accepting if it contains any NFA accepting state.
- After removing ε-moves, the start state may become accepting (if ECLOSE(q₀) meets F).
- k-th symbol from the END: 2ᵏ DFA states; from the START: k + 2.
Memory Hook
Subset construction = a photograph of the whole search party at each moment; the DFA steps from photo to photo.
Connect the Dots
DFA = NFA = ε-NFA in power. The subset construction can produce DFAs with redundant states — like {q1} and {q0,q1} above, which behave identically. Next chapter: how to detect and merge such states to get the minimal DFA, the single most frequent TOC question type in GATE.
Self-Test
- NAT
Minimal DFA states for strings over {0,1} whose 4th symbol from the end is 1?
Write your answer before opening the key.
- NAT
Minimal DFA states for strings over {0,1} whose 4th symbol from the start is 1?
Write your answer before opening the key.
- MCQ
In the subset construction, a DFA state S is accepting iff:
- S ⊆ F
- S ∩ F ≠ ∅
- S = F
- S contains q₀
- MSQ
An NFA has n states. Which are true?
- An equivalent DFA with at most 2ⁿ states exists
- Every equivalent DFA has at least 2ⁿ states
- Some languages need about 2ⁿ DFA states for an n-state NFA
- The subset construction always produces a minimal DFA
- NAT
Subset construction on the ends-with-ab NFA (3 states) yields how many reachable DFA states?
Write your answer before opening the key.
Rule Card
- Subset construction: start {q₀} (or ECLOSE(q₀)); δ(S,a) = ⋃ δ(q,a) (then ECLOSE); accept iff S ∩ F ≠ ∅; ∅ = dead state.
- ≤ 2ⁿ states; count only reachable sets.
- ε-removal: δ'(q,a) = ECLOSE(δ(ECLOSE(q), a)); F' = {q : ECLOSE(q) ∩ F ≠ ∅}.
- k-th from end is 1: NFA k+1, DFA 2ᵏ. k-th from start: DFA k+2.
- DFA ≡ NFA ≡ ε-NFA in power.
Concept Ledger
- subset construction
- lazy (reachable-only) construction
- ε-removal
- exponential (2ⁿ) blow-up
- equivalent machines (same language)
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- All states reachable from q by zero or more ε-moves (including q).
- When some path for the input ends in an accepting state.
- 16.
Self-test answers
- 16 — 2⁴.
- 6 — k + 2.
- B — Some active copy is in an accepting state.
- A: Too strict.
- C: Too strict.
- D: Irrelevant.
- AC — Upper bound 2ⁿ; achieved by k-th-from-end languages.
- B: Often far fewer are needed.
- D: It can produce equivalent (redundant) states.
- 3 — {0}, {0,1}, {0,2}.
Flashcards
- Upper bound on DFA states from an n-state NFA?
Reveal answer
2ⁿ - Minimal DFA for “k-th symbol from the end is 1”?
Reveal answer
2ᵏ states. - Which subsets are accepting in the subset construction?
Reveal answer
Those containing at least one NFA accepting state. - What does ∅ become in the subset construction?
Reveal answer
The dead state.
Exam shortcuts
- k-th from END → 2ᵏ. k-th from START → k + 2. Write “END = Exponential” on your hand.