Finite automata and state counts
A DFA stores exactly the information about a prefix needed to judge future suffixes. An NFA stores possible computations; a subset construction packages those possibilities into one DFA state.
3.1 DFA and NFA execution
Past papers · CS 2014–2026 (23 papers): 4 questions, 7 marks
A DFA is : finite states , alphabet , total transition function , start state and final states . A missing transition in a partial diagram goes to a rejecting sink when completing the DFA. Acceptance requires consuming the whole input and ending in .
3.2 Subsets and product constructions
Past papers · CS 2014–2026 (23 papers): 4 questions, 5 marks
Determinise by starting at and creating only reachable subsets. A subset is final exactly when it intersects the old final set. The empty subset is a rejecting sink if reached.
Complement a complete DFA by replacing by . Complementing an NFA by swapping final states is generally invalid. Reverse all edges and exchange start/final roles using a fresh -start if necessary to construct an NFA for reversal.
3.3 Distinguishability and minimisation
Past papers · CS 2014–2026 (23 papers): 3 questions, 4 marks
States are distinguishable if some suffix is accepted from exactly one of them. Remove unreachable states, split final from nonfinal states, then repeatedly split blocks according to transition destinations until stable. Each surviving block is one state of the minimal complete DFA.
A minimal complete DFA is unique up to state renaming. Its complement has the same number of states, because swapping acceptance preserves every distinguishing suffix. Empty and universal languages each need one complete DFA state.
For table filling, mark final/nonfinal pairs first. Repeatedly mark a pair if some symbol sends it to an already marked pair. Unmarked pairs are equivalent. For two complete DFAs, reach a final/nonfinal mismatch in their product to disprove equivalence; if none is reachable, they are equivalent.
3.4 Pattern memory and modular arithmetic
Past papers · CS 2014–2026 (23 papers): 10 questions, 17 marks
For a fixed pattern of length , track the longest suffix of the prefix read so far that is also a prefix of . On a new symbol, append it and keep the longest such suffix. For “ends with ”, continue updating after a match. For “contains ”, make the matched state absorbing. Avoiding uses the complement. Both containing and ending with a fixed nonempty pattern have minimal complete DFAs with states.
| Required memory | Construction and state-count caution |
|---|---|
| Several modular counts | Tuple of residues; product of moduli is an upper bound |
| Several restrictions on the same count | A single residue modulo their least common multiple often suffices |
| th symbol from the right is , binary alphabet, | NFA guesses it: states; minimal complete DFA: states |
| A fixed position from the left and minimum length | Count until the position; reject a wrong symbol; count the remaining required positions |
| Length exactly or at most , | states in a minimum complete DFA, including the rejecting sink |
| Length at least , | states, with the reached threshold absorbing |
| th symbol from the left is a specified symbol, | states for an alphabet with at least two symbols: count, accept and reject |
| Running product in a finite group ; every group element allowed as a symbol | Store the product; states are necessary for identity acceptance |
| Permutations of objects, all allowed, product must be identity | states; append one inverse to distinguish any two products |
For the th-from-right language, store a length- bit window with leading zero padding before enough symbols arrive. All windows are reachable; shift a differing position to the tested position to distinguish two windows.
A DFA accepting an even number of a symbols; b preserves the state.
3.5 Counting accepted words
Past papers · CS 2014–2026 (23 papers): 2 questions, 3 marks
Count deterministic paths by input length. If using an NFA, determinise first; otherwise several paths for the same word cause overcounting. The transition matrix counts distinct symbols that induce each edge, not merely the existence of an edge.
3.6 Regular-language decision tests
For a finite automaton, emptiness is reachability of a final state. Infiniteness means a reachable directed cycle lies on a path to a final state; remove irrelevant states before testing cycles. In an -NFA that cycle must allow consumption of a nonempty string. Determinisation avoids this qualification.
The shortest accepting path cannot repeat a state. An accepting path of at least edges has a productive cycle; a shortest accepted word of length at least can be shortened into the stated interval by deleting cycles. The equivalence bound follows from a shortest path to a mismatch in the product.
Universality is emptiness of the complement. Inclusion is emptiness of . Equality requires both inclusions, or emptiness of symmetric difference. Membership, emptiness, finiteness, universality, inclusion, equivalence and disjointness are all decidable for regular representations.
Last-minute recall
- A complete DFA must have a transition for every state and symbol.
- A final state accepts only when the whole input has been consumed.
- The subset bound is , not a mandatory state count.
- Remove unreachable states before minimising.
- A matching construction proves an upper bound; suffixes prove the lower bound.
- Complement preserves the minimum complete DFA state count.
- Count words with a DFA, not nondeterministic paths.
- Productive cycles distinguish infinite from finite regular languages.