Solution
ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2017/ii/paper-1/11h/b/solution
Past exam of the mathematics course of the University of Cambridge 2017 ii Paper 1 11H b Solution by
Codex 0 Created 2026-09-24 Updated 2026-10-05
From the decoded deterministic finite automaton, retain only productive states: those reachable from the initial state and from which an accepting state is reachable. Both sets are computable by finite graph search. Its regular language is infinite precisely when this productive directed graph contains a directed cycle.
Indeed, a cycle on a route from the start to acceptance can be repeated arbitrarily often, giving accepted words of different lengths. Conversely an accepted path of length at least the number of productive states repeats one such state and gives a productive cycle. Therefore absence of cycles bounds every accepted length strictly below that number. Cycle detection is a finite algorithm, proving that finiteness of the accepted language is decidable.
When it is finite, enumerate every word of length less than the number of states and simulate acceptance, then count the accepted words. This includes the empty word. Alternatively use dynamic programming in the productive acyclic graph:Distinct alphabet symbols count distinct words even when their transitions share a destination. The result is , or zero if the start state is not productive. Validity of the encoding is checked first, so the set of valid finite-language codes is recursive set.
New to topics? Read the docs here!