2.6Designing finite automata
Covers IGNOU MCS-212 §2.4 exercises Ex.8–Ex.12, 2.7
Designing a DFA is a small programming task with a very limited memory: the current state is all the machine remembers. The art is to decide what information about the input read so far must be remembered, and to make one state for each possibility.
A design method
- Decide what the machine must remember after reading a prefix (parity of the length, the last two symbols, how many ‘s up to 3, …). Each possible value becomes a state.
- Choose the start state (what is remembered after reading ) and the final states.
- For each state and each symbol, decide the next state. Add a dead state if some prefixes can never lead to acceptance.
- Test on several strings that should be accepted and several that should be rejected.
What a finite automaton cannot do
A DFA with states can only remember different things. Languages such as , “balanced brackets”, or “twice as many ‘s as ‘s” need a counter that can grow without limit, so no DFA recognises them. They need more powerful machines (pushdown automata, Turing machines — Unit 3).
Key takeaways
- States = the information the machine must remember.
- Use a dead state for prefixes that can never be accepted.
- Test every design on accepted and rejected strings.
- Languages that need unbounded counting (e.g. ) are not regular and have no FA.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Design a DFA over that accepts binary numbers (read from the most significant bit) divisible by 3. Give its states and transitions.
Show worked answer
Remember the remainder of the number read so far modulo 3: states (start, final), , . Reading bit changes the value to , so the remainder becomes : , , , , , . Check (= 6): , accepted; (= 5): , rejected.