Recall warm-up
- What are the two methods for minimizing a DFA?
Stuck? Peek at 1.3.2 Partition and table-filling methods
- 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.
- Minimal DFA for strings with exactly 3 a’s over {a,b}?
Stuck? Peek at 1.3.2 Partition and table-filling methods
- 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.
- What is the index of an equivalence relation?
Stuck? Peek at 0.2.2 Functions, relations and equivalence classes
- Relation ⊆ A × B. Function: every input exactly one output. Partial function: some inputs have none.
- #functions A→B = |B|^|A|. #one-to-one (|A| ≤ |B|) = |B|·(|B|−1)···. #relations on n-set = 2^(n²).
- Equivalence = reflexive + symmetric + transitive. Classes partition the set; number of classes = index.
- Finer relation (refinement) ⇒ more classes; every fine class sits inside a coarse class.
The Hook
Minimization needed a DFA to start with. But GATE often gives only a description: “the language of all strings where …”. And sometimes the honest answer is “no DFA exists at all”. Is there a way to count states — or prove none suffice — directly from the language? Yes: group strings (not states) by their futures. This is the Myhill–Nerode theorem, and it explains why minimization works.
Predict First
Language L = { aⁿbⁿ | n ≥ 0 }. Do the strings a and aa have the same “future”? That is, is there a continuation z such that az ∈ L but aaz ∉ L?
Core Concept
Prediction check
Yes: z = b. ab ∈ L but aab ∉ L. In fact aⁱ and aʲ (i ≠ j) are always separated by z = bⁱ. So infinitely many strings have pairwise different futures — and that will mean no DFA can exist for L.
| prefix | z = b | z = bb | z = bbb |
|---|---|---|---|
| a | ab ✓ | abb ✗ | abbb ✗ |
| aa | aab ✗ | aabb ✓ | aabbb ✗ |
| aaa | aaab ✗ | aaabb ✗ | aaabbb ✓ |
The Myhill–Nerode relation
“x and y need the same continuations.” It is an equivalence relation. It is also right-invariant: if x ≡_L y then xa ≡_L ya for every symbol a.
The theorem
Why: in any DFA for L, strings ending in the same state have the same future, so #states ≥ #classes. And the classes themselves form a DFA: state [x], move [x] ─a→ [xa], start [ε], accept the classes inside L. That DFA has exactly #classes states, so it is minimal.
Two uses
- Count minimal states: find a list of strings that are pairwise distinguishable (each pair separated by some z) and show every string falls into one of their classes. The list size = minimal state count.
- Prove a language is not regular: find infinitely many strings, pairwise distinguishable. Then the index is infinite, so no DFA exists. This is our first rigorous proof of non-regularity.
Example: ends with ab
Classes: [ε] (strings ending in neither a nor ab, including ε, “b”, “abb”), [a] (ending in a), [ab] (ending in ab). Pairwise: ε vs a: z = b (ab ∈ L, b ∉ L). ε vs ab: z = ε. a vs ab: z = ε. Three classes ⇒ minimal DFA has 3 states.
Putting it together
- x ≡_L y when every continuation treats them alike.
- Regular ⇔ finitely many classes; the count is the minimal DFA size (dead class included).
- Infinitely many pairwise-distinguishable strings prove a language is not regular.
Visual
L = { w ∈ {a,b}* : w ends with ab }
class sample strings continuations z that lead into L
[ε] ε, b, bb, abb, aab b z ends with ab (e.g. "ab")
[a] a, ba, aba, aa z = b, or z ends with ab
[ab] ab, bab, aab z = ε, or z ends with ab
three different "future sets" → 3 states → same as 1.2.3's DFA
L = { aⁿbⁿ } : ε a aa aaa aaaa ...
separating z: ε b bb bbb bbbb (aⁱbⁱ ∈ L, aʲbⁱ ∉ L for j ≠ i)
infinitely many classes → NOT regularWorked Examples
L = strings over {a,b} with an even number of a’s. List the Myhill–Nerode classes.
Show the full solution
[ε] = even a’s, [a] = odd a’s. ε vs a separated by z = ε. Any string is in one of the two. Index 2 ⇒ 2 states.
L = { w : |w| ≥ 2 } over {a}. Find the classes.
Show the full solution
[ε], [a], [aa] — ε needs ≥ 2 more, a needs ≥ 1 more, aa needs nothing. Pairwise separated: ε vs a by z = a; a vs aa by z = ε; ε vs aa by ε. All longer strings fall in [aa]. 3 classes.
Prove that L = { w ∈ {a,b}* : |w|ₐ = |w|_b } is not regular using Myhill–Nerode.
Show the full solution
Take the infinite family aⁱ (i = 0, 1, 2, …). For i ≠ j choose z = bⁱ: aⁱbⁱ ∈ L, aʲbⁱ ∉ L. So the aⁱ are pairwise in different classes: infinitely many classes ⇒ not regular. ∎ (Memory link: the machine would need to remember the difference #a − #b, an unbounded fact — Lesson 0.1.1.)
GATE Traps
- The relation is about continuations z appended on the right, not prefixes.
- One separating z is enough to put two strings in different classes; to put them in the same class you must argue for all z.
- The class count includes the “dead” class (strings with no accepted continuation), when it exists.
- Infinite index ⇒ not regular. A language can be infinite yet have finite index (e.g. Σ*, index 1).
Memory Hook
Myhill–Nerode = group strings by their futures. Finitely many futures = finite memory = regular.
Connect the Dots
Myhill–Nerode ties the whole of Phase 1 together: states are just names for “futures”; minimization finds them from a machine; the theorem finds them from the language; and infinitely many futures means no finite machine. One small topic remains in Phase 1: finite machines that produce output instead of just yes/no.
Self-Test
- MCQ
x ≡_L y means:
- x and y have the same length
- for all z, xz ∈ L ⇔ yz ∈ L
- x and y are both in L
- for all z, zx ∈ L ⇔ zy ∈ L
- NAT
Index of ≡_L for L = strings over {a,b} containing
bb?Write your answer before opening the key.
- MSQ
Which follow from the Myhill–Nerode theorem?
- L regular ⇒ ≡_L has finite index
- Finite index ⇒ L regular
- #classes = #states of the minimal DFA
- Every infinite language has infinite index
- MCQ
To prove L non-regular with Myhill–Nerode you need:
- one string not in L
- infinitely many pairwise distinguishable strings
- a DFA for the complement
- two strings with the same future
Rule Card
- x ≡_L y ⇔ ∀z: xz ∈ L ⇔ yz ∈ L. Right-invariant equivalence.
- L regular ⇔ finite index; index = #states of minimal DFA (incl. dead class).
- Infinitely many pairwise distinguishable strings ⇒ not regular. aⁿbⁿ: strings aⁱ separated by bⁱ.
Concept Ledger
- Myhill–Nerode relation ≡_L
- right-invariant
- finite index
- Myhill–Nerode theorem
- non-regular language
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- Partition refinement and table filling.
- 5.
- Its number of equivalence classes.
Self-test answers
- B — Same right continuations.
- A: Length is irrelevant.
- C: Being in L is only z = ε.
- D: Continuations go on the right.
- 3 — No progress, last symbol b (one b), already contains bb.
- ABC — Both directions plus the count.
- D: Σ* is infinite with index 1.
- B — Infinitely many classes.
- A: Says nothing.
- C: Would prove L regular.
- D: Irrelevant.
Flashcards
- Myhill–Nerode theorem?
Reveal answer
L is regular iff ≡_L has finitely many classes; the number of classes = states of the minimal DFA. - How do you prove aⁿbⁿ is not regular with Myhill–Nerode?
Reveal answer
The strings aⁱ are pairwise distinguishable (z = bⁱ), so there are infinitely many classes. - Can an infinite language have finite index?
Reveal answer
Yes — e.g. Σ* has index 1.