Pattern MatchingPattern matching, along with learning the periodicity of the input, does the basic computations the code is based upon. It is able to learn patterns of different length from the input, and match partially completed patterns to either predict future inputs, or turn the focus of attention to different patterns interesting to a specific behavior.
The pattern matcher receives commands from the attention loop, which directs it on what to match, what to record (learn), and what to pay attention to.
Every time a pattern is matched, individual elements get averaged, and their certainties updated. The certainty of a match between two values is one minus the difference between the two values over the difference between the maximum value and the minimum value at the current window. The certainty of a a match between two pattern elements is the average of the certainties of their values. The certainty of a match between two patterns, is the average of the certainties of their elements, weighted by the saliency of each element. Intuitively, one will try to match within a sequence of notes the important notes, and will care less about less salient notes which do not match.
When the certainty with which two patterns are matched is too low, then a new pattern is added to the pattern table.
When the certainty is high enough, then the matched pattern is extended to include the current pattern with which it matched.