Remembering That a Pattern Has Occurred
An automaton recognizing whether a substring occurred can preserve a found state after the first detection.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a pattern of two ones
Before detection, retain whether the preceding bit was one. Two consecutive ones move into found. Every later input can stay in found. See substrings and subsequences.
Check the ending separately
The input 110 contains 11 but no longer ends with it. Use this case to distinguish the machines in a test. Tracking a final symbol shows how a test about the end can reject a word containing the symbol earlier.[1]
Keep a state for a match already completed
A machine searching for substring aba before end of input can track matched prefixes a and ab. Once the next a completes the pattern, enter an accepting state that stays accepting on later symbols. See whole input and substring checks.
Process b: no prefix
Then a: suffix a
Then b: suffix ab
Then a: pattern seen
Any later input keeps pattern seen
Account for overlap before a pattern is found
After reading two consecutive As, a suffix of length one can still start an occurrence. Resetting to zero in that case misses valid patterns. Test an occurrence starting after a failed partial match.