Singleton-language test for finite automata (source code)

= Singleton-language test for finite automata

To decide whether a <finite-state automaton> accepts exactly one distinct <word>, first obtain some accepted <word> $w$ by a <finite automaton emptiness test>. If there is none, answer no. Otherwise construct a <finite-state automaton> for the accepted <formal language> minus the <singleton> $\{w\}$ and test it for emptiness. Answer yes exactly when that difference is empty. <Subset construction> handles multiple accepting runs without confusing runs with distinct <words>.