Use a Moore machine whose state records the longest suffix of the received stream that is also a prefix of the target word. The transitions areThe last row preserves overlap: after recognition, one more one leaves suffix , giving . Initialize to and update the state on each active clock edge; the output after that edge reports whether the word has just ended. This is a prefix-suffix sequence recognizer.
State transitions of the overlapping Moore machine recognizer
. Edge labels are input bits. Only the shaded, double-ring state produces output one. Details. Prefix-suffix sequence recognizer 2026-10-31
For a fixed word , store the length of the longest suffix of the received stream that is also a prefix of . On a new input symbol, append it to the represented prefix and select the longest resulting suffix that is a prefix of . The complete-word state signals recognition. Its outgoing transitions retain proper suffix matches, allowing overlapping occurrences rather than automatically restarting from the empty prefix. This is the finite-state form of the prefix information used by the Knuth-Morris-Pratt algorithm.
For example, recognizing needs suffix-prefix states of lengths zero through four. After a complete match followed by one, the last two symbols are , so the next state retains length two. This permits the second match in without clearing the useful suffix.
An overlapping prefix-suffix sequence recognizer for
. Details. 