Finite Automata


Shared context
Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.
Answer & solution
Answer: Four parity states EE, OE, EO, OO; start EE, sole accepting OO. a toggles first component, b toggles second. (no official key was published)
Step through it (2 parts)
1. Only the two parities matter, so use states (parity of a count, parity of b count). The empty string has counts zero and zero, making EE the start state.
2. Reading a increments only the a count and toggles its parity. Reading b toggles only the b parity. Complete transition table on (a,b): EE→(OE,EO); OE→(EE,OO); EO→(OO,EE); OO→(EO,OE).
3. Mark only OO accepting. By induction on the processed prefix, the stored pair equals its two actual count parities: the base is EE and every transition applies the correct single parity toggle.
4. Therefore a string is accepted exactly when both counts are odd. For instance ab ends in OO, whereas aab ends in EO and is rejected.