def _learnBacktrack(self):
<EOL>numPrevPatterns = len(self._prevLrnPatterns) - <NUM_LIT:1><EOL>if numPrevPatterns <= <NUM_LIT:0>:<EOL><INDENT>if self.verbosity >= <NUM_LIT:3>:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>return False<EOL><DEDENT>badPatterns = []<EOL>inSequence = False<EOL>for startOffset in range(<NUM_LIT:0>, numPrevPatterns):<EOL><INDENT>inSequence = self._learnBacktrackFrom(startOffset, readOnly=True)<EOL>if inSequence:<EOL><INDENT>break<EOL><DEDENT>badPatterns.append(startOffset)<EOL><DEDENT>if not inSequence:<EOL><INDENT>if self.verbosity >= <NUM_LIT:3>:<EOL><INDENT>print ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>self._prevLrnPatterns = []<EOL>return False<EOL><DEDENT>if self.verbosity >= <NUM_LIT:3>:<EOL><INDENT>print(("<STR_LIT>"<EOL>"<STR_LIT>" % (numPrevPatterns - startOffset),<EOL>self._prevLrnPatterns[startOffset]))<EOL><DEDENT>self._learnBacktrackFrom(startOffset, readOnly=False)<EOL>for i in range(numPrevPatterns):<EOL><INDENT>if i in badPatterns or i <= startOffset:<EOL><INDENT>if self.verbosity >= <NUM_LIT:3>:<EOL><INDENT>print(("<STR_LIT>",<EOL>self._prevLrnPatterns[<NUM_LIT:0>]))<EOL><DEDENT>self._prevLrnPatterns.pop(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return numPrevPatterns - startOffset<EOL>
This "backtracks" our learning state, trying to see if we can lock onto
the current set of inputs by assuming the sequence started up to N steps
ago on start cells.

This will adjust @ref lrnActiveState['t'] if it does manage to lock on to a
sequence that started earlier.

:returns:          >0 if we managed to lock on to a sequence that started
                  earlier. The value returned is how many steps in the
                  past we locked on.
                  If 0 is returned, the caller needs to change active
                  state to start on start cells.

How it works:
-------------------------------------------------------------------
This method gets called from updateLearningState when we detect either of
the following two conditions:

#. Our PAM counter (@ref pamCounter) expired
#. We reached the max allowed learned sequence length

Either of these two conditions indicate that we want to start over on start
cells.

Rather than start over on start cells on the current input, we can
accelerate learning by backtracking a few steps ago and seeing if perhaps
a sequence we already at least partially know already started.

This updates/modifies:
    - @ref lrnActiveState['t']

This trashes:
    - @ref lrnActiveState['t-1']
    - @ref lrnPredictedState['t']
    - @ref lrnPredictedState['t-1']