Confusion about finite automata construction in Knuth–Morris–Pratt algorithm There is one point I don't understand in the DFA construction for mismatch cases.

Here is the lecture note I watched, which describes how to handle mismatched characters during the DFA construction process.



Some information about the presentation screen shot:

pat is the pattern, string index starts at 0, dfa is the state transition table, in which the row is indexed by the character(eg, "A","B" or "C"), column by state(1,2,3,...).



My question starts:

In the place in the presentation, where starts with "To compute dfa[c][j]", it says run the simulation using the last j-1 chars.

I am confused:

Why run the simulation using the last j-1 chars, rather the last j chars. 

What's the intuition of this design?
Say we are at state j (in the question's example, j is 5). This means that so far we have successfully matched j characters (characters 0 to j-1 of the pattern). Now, we receive a new character - call it newChar. 

Case 1: newChar is the character we wanted ('C' in the example). All is good and we have now a match of j+1 characters (characters 0 to j of the pattern).

Case 2: newChar is not the character we wanted. Let's assume the most optimistic situation: that we've now matched j characters of our pattern. (We couldn't have a match of j+1 characters in this case, because otherwise we would be in Case 1.) The last of these j characters that we matched is newChar. To have a total of j characters matched, then, we must have matched characters 1 to j-1 of the pattern plus newChar.

Because a mismatch puts us in Case 2, and Case 2 only uses characters 1 to j-1, we need only run the simulation using the last j-1 characters.