Consider the following language. \(L = \{{ x\in \{a,b\}^*\mid}\)number of…
2020
Consider the following language.
\(L = \{{ x\in \{a,b\}^*\mid}\)number of \(a’s\) in \(x\) divisible by 2 but not divisible by 3 }
The minimum number of states in DFA that accepts \(L\) is _________ .
Attempted by 173 students.
Show answer & explanation
Correct answer: 6
Key idea: the membership of a string depends only on the number of a's modulo 6 (since being divisible by 2 but not by 3 is a condition on residue modulo lcm(2,3)=6).
Construction: Use 6 states labeled 0,1,2,3,4,5 representing the count of a's modulo 6. Start state = 0. Accepting states = 2 and 4 (these residues are even but not divisible by 3).
Transitions: on input a move from state i to (i+1) mod 6; on input b stay in the same state.
Minimality (why 6 states are necessary):
Two strings are distinguishable exactly when their counts of a's give different residues modulo 6. For any two distinct residues r and s (with d = (s-r) mod 6), we can choose a suffix a^k that makes one residue land in {2,4} (accepted) and the other land outside {2,4} (rejected):
If d ≠ 4, take k ≡ 4 − r (mod 6). Then r+k ≡ 4 (accepted), while s+k ≡ d+4 (mod 6) is not in {2,4}.
If d = 4, take k ≡ 2 − r (mod 6). Then r+k ≡ 2 (accepted), while s+k ≡ 0 (rejected).
Thus all six residues are pairwise distinguishable, so any DFA needs at least 6 states. Combined with the 6-state construction above, the minimum number of states is 6.