Graph search 2026-10-05
A graph search explores vertices through incident edges while recording visited vertices. On a finite graph, depth-first or breadth-first exploration terminates and decides reachability; recording predecessors also gives a path. Restricting to vertices reachable from a start and able to reach an accepting vertex identifies the productive part of a deterministic finite automaton.
Past exam of the mathematics course of the University of Cambridge 2017 ii Paper 1 11H b Solution 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.
Reachability in a graph 2026-10-05