Recall warm-up
- How is ≡ₖ₊₁ obtained from ≡ₖ?
Stuck? Peek at 1.3.1 Unreachable, equivalent and distinguishable states
- Step 0: delete unreachable states (BFS from q₀).
- p ≡ q ⇔ ∀w: δ̂(p,w) ∈ F ⇔ δ̂(q,w) ∈ F. Distinguishable ⇔ some w separates.
- ≡₀ = {F, Q−F}; ≡ₖ₊₁ splits by where symbols lead w.r.t. ≡ₖ; stop when stable.
- Merge classes → minimal DFA, unique up to renaming.
- Subset construction: which sets are accepting?
Stuck? Peek at 1.2.3 Subset construction and the 2ⁿ blow-up
- 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.
- Minimal DFA for #a ≡ 0 (mod 2) and #b ≡ 0 (mod 3)?
Stuck? Peek at 1.1.3 DFA design patterns
Language (|w| = k pattern) Minimal states starts with w k + 2 contains w / ends with w k + 1 |x| ≡ r mod n n |x| = k, |x| ≤ k k + 2 |x| ≥ k k + 1 #a mod m and/or #b mod n m·n (typical) binary value ≡ 0 mod k, k odd k binary ÷ 2ʲ j + 1 k-th symbol from start fixed k + 2 Divisibility update: r ← (base·r + digit) mod k.
The Hook
In the exam you have about three minutes per 2-mark question. You need a procedure that never misses a merge and never merges wrongly. Two such procedures exist; both compute the same equivalence classes. Learn the partition method for speed, and the table-filling method because GATE sometimes asks about “pairs of distinguishable states”.
Predict First
A DFA has 7 states after removing unreachable ones; 3 are accepting. What is the smallest and largest number of states its minimal DFA could have?
Core Concept
Prediction check
Smallest: 2 — accepting and non-accepting states can never merge, so at least one class of each (when both exist). Largest: 7 — nothing merges.
Method 1 — partition refinement (Moore / Hopcroft style)
- Remove unreachable states.
- P₀ = {F, Q − F}.
- For each group, write every state’s “signature”: the group each symbol sends it to.
- Split each group by signature. That gives P₁.
- Repeat until a round changes nothing. The groups are the minimal DFA’s states.
Tip: write the signature as a short tuple like (II, I) meaning “0 → group II, 1 → group I”.
Method 2 — table filling (Myhill table)
- Draw a triangle table with one cell per unordered pair {p, q}.
- Mark every pair with exactly one accepting state (distinguished by ε).
- Repeat: for each unmarked pair {p, q} and each symbol a, if {δ(p,a), δ(q,a)} is marked, mark {p, q}.
- Stop when a full pass marks nothing. Unmarked pairs are equivalent.
Number of cells = n(n−1)/2. Marked = distinguishable pairs; unmarked = equivalent pairs.
Reading the minimal DFA
Each class is a state; the class containing q₀ is the start; classes inside F are accepting; transitions: pick any member, follow its arrow, see which class it lands in.
| class | on 0 | on 1 |
|---|---|---|
| → {A,B} | {A,B} | {C,D,E} |
| * {C,D,E} | {C,D,E} | {F} |
| {F} | {F} | {F} |
Counting without drawing: the “distinct futures” method
For “minimal DFA for language L” questions, list the different situations a prefix can leave you in — situations that differ in which continuations are accepted. Each different situation = one state. Don’t forget the hopeless situation (dead state) and the “already satisfied” situation.
| situation | example prefix | accept now? |
|---|---|---|
| 0 a’s | b | no |
| 1 a | ab | no |
| ≥ 2 a’s, last a | aa | no |
| ≥ 2 a’s, last b | aab | yes |
Putting it together
- Partition method: split by signatures until a round changes nothing.
- Table filling: mark (F, non-F), propagate marks through successor pairs; unmarked pairs merge.
- Fast counting: list the different futures, then add a dead state if some prefix is hopeless.
Visual
Table filling on the 1.3.1 DFA (reachable states A..F, F_acc = {C,D,E})
A B C D E
B · ✗ = distinguishable · = equivalent
C ✗ ✗ pass 0: mark every (accepting, non-accepting) pair
D ✗ ✗ · pass 1: {A,F}: on 1 → {C,F} marked → mark ✗
E ✗ ✗ · · {B,F}: on 1 → {D,F} marked → mark ✗
F ✗ ✗ ✗ ✗ ✗ {A,B}: on 0 → {B,A}, on 1 → {C,D}: unmarked → leave
pass 2: nothing new → stop
unmarked: {A,B}, {C,D}, {C,E}, {D,E} → classes {A,B}, {C,D,E}, {F} → 3 statesWorked Examples
Minimize: states 1,2,3 over {a}; 1 ─a→ 2, 2 ─a→ 3, 3 ─a→ 3; start 1; F = {2,3}.
Show the full solution
P₀: {1} | {2,3}. Signatures in {2,3}: 2 → 3 ∈ {2,3}, 3 → 3 ∈ {2,3}: same. Stable. 2 states: language a⁺.
DFA over {0,1}, start A, F = {E}. A: 0→B, 1→C. B: 0→B, 1→D. C: 0→B, 1→C. D: 0→B, 1→E. E: 0→B, 1→C. Minimize.
Show the full solution
P₀: {A,B,C,D} | {E}. Signatures (0,1): A (I,I), B (I,I), C (I,I), D (I,II) → {A,B,C} | {D} | {E}. Next: A: 0→B∈{ABC}, 1→C∈{ABC}; B: 0→B, 1→D∈{D} ✗ differs; C: 0→B, 1→C → {A,C} | {B} | {D} | {E}. Next: A: 0→B{B}, 1→C{AC}; C: 0→B{B}, 1→C{AC} → same. Stable: 4 states {A,C}, {B}, {D}, {E}. Language: strings ending in 011. (k + 1 = 4 ✓.)
Minimal DFA states over {a,b} for L = { w : w contains at least two a’s and ends with b }?
Show the full solution
Situations: count of a’s seen so far capped at 2 (0, 1, ≥2) and, once ≥2, whether the last symbol is b. For counts 0 and 1, the last symbol doesn’t matter yet (we will need more a’s, which changes the last symbol anyway). States: “0 a’s”, “1 a”, “≥2 a’s, last is a”, “≥2 a’s, last is b” (accepting). Note after the second a the last symbol is a. Total 4. Check: “aab” → 0→1→(≥2,a)→(≥2,b) accept; “aba” → 0→1→1→(≥2,a) reject; “ab” → 0→1→1 reject ✓.
GATE Traps
- Forgetting to delete unreachable states first — they never merge into the minimal count.
- Comparing signatures against the OLD partition, not the one you are building.
- Stopping one round too early: always do a full pass that changes nothing.
- Counting the dead state: if the language makes some prefixes hopeless, the minimal DFA has one. If it doesn’t (like “contains ab”), it has none.
Memory Hook
Partition method = sorting students into classrooms by which classrooms their friends are in, again and again, until nobody has to move.
Connect the Dots
We now minimize any given DFA. But what if you’re given only a language? The next lesson defines the equivalence classes directly on strings — no machine needed — and it gives the deepest characterization of regular languages: finite memory = finitely many classes.
Self-Test
- NAT
Table filling on an n-state DFA uses how many cells when n = 6?
Write your answer before opening the key.
- NAT
Minimal DFA states over {a,b} for strings with at least 2 a’s?
Write your answer before opening the key.
- NAT
Minimal DFA states over {a,b} for strings with exactly 2 a’s?
Write your answer before opening the key.
- MCQ
In the partition method, P₀ is:
- {Q}
- {F, Q − F}
- one block per state
- { {q₀}, Q − {q₀} }
- MSQ
Over {a,b}, which languages have a minimal DFA with exactly 4 states?
- strings with at most 2 a’s
- strings with exactly 2 a’s
- strings ending in aba
- strings of length ≡ 0 mod 4
Rule Card
- Partition: remove unreachable; P₀ = {F, Q−F}; split by signatures w.r.t. previous partition; stop when stable.
- Table filling: n(n−1)/2 cells; mark (F, non-F); propagate “successor pair marked ⇒ mark”; unmarked = equivalent.
- Count by distinct futures: list situations with different accepted continuations, include dead / satisfied states.
- Exactly k of a symbol: k + 2 states; at least k: k + 1; at most k: k + 2.
Concept Ledger
- partition refinement method
- signature of a state
- table-filling (Myhill) method
- distinguishable pair
- distinct futures counting
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- Two states stay together iff they were together in ≡ₖ and every symbol sends them into the same ≡ₖ class.
- Those containing an NFA accepting state.
- 6.
Self-test answers
- 15 — n(n−1)/2.
- 3 — 0 a’s, 1 a, ≥2 a’s (accept sink).
- 4 — 0, 1, 2 (accept), ≥3 (dead).
- B — Split by acceptance only.
- A: Too coarse unless F = ∅ or Q.
- C: That is the finest partition, the end of the worst case.
- D: The start state is not special here.
- ABCD — A: 0,1,2 accept + dead. B: 0,1,2 + dead. C: k+1. D: 4 remainders.
Flashcards
- Minimal DFA for “exactly k a’s” over {a,b}?
Reveal answer
k + 2 states (0..k and dead). - Minimal DFA for “at least k a’s”?
Reveal answer
k + 1 states. - Minimal DFA for “at most k a’s”?
Reveal answer
k + 2 states (0..k accepting, plus dead). - How many cells in a table-filling table for n states?
Reveal answer
n(n−1)/2 - When do you stop the partition method?
Reveal answer
After a full round in which no group splits.
Exam shortcuts
- Count “situations”, not arrows: write the list of different futures a prefix can have. Each = one state. Then ask: is there a hopeless situation? (+1 dead.)
- Exactly k → k+2, at least k → k+1, at most k → k+2. “Exactly” and “at most” both need the dead state.