Proofs: Ukkonen's cutoff algorithm
These are the human proofs of Ukkonen's cutoff algorithm, at full length.
Ukkonen's cut-off algorithm reports exactly the ends of the approximate matches full
This proof shows: correctness.
Indices are 0-based, , , . Let be the Sellers table, so , , and for
by the correctness proof of Sellers' algorithm. Let , which exists since .
Lemma 1. For : .
Proof. Lemma 3 of the Landau-Vishkin proof gives for . If , then , so . If the claim is trivial.
A stored number is valid for a true value when if , and if .
Lemma 2. Let be valid for , and . Then is valid for .
Proof. Each stored term is at least : a stored input equals the true one, or both are above , and then the stored term is above . If , some true term equals , so its input is at most and stored exactly, and the stored term equals . All other stored terms are at least . So the minimum is . If , every true term is above , so every stored term is above , and so is the minimum.
Lemma 3 (invariant). After line L3, and after each pass of the loop of line L4 for column , the following hold. (a) . (b) For , the stored is valid for .
Proof. Column 0: line L1 stores the true values , so (b) holds for all rows. The last row with is , so line L2 gives (a).
Column , assuming (a) and (b) for column . Line L5 sets . Line L6 keeps , which is the true value. By induction on , line L8 computes a value valid for . Its inputs are the stored , still of column and valid by (b) since ; the new , valid by the induction on ; and , the old of column , valid by (b). Lemma 2 applied to (R) gives validity.
So rows 0 to hold valid values for column . By Lemma 1, . Every row with has a true value above and so a stored value above , and row has a stored value equal to its true value, at most . Hence the loop of line L9, which starts at and stops at the first stored value at most , stops at . This gives (a).
For (b): rows 0 to are valid. If , row has a true value above by the definition of , and line L11 stores , which is valid.
Theorem. UKKONEN-CUTOFF reports, in increasing order, exactly the positions such that for some .
Proof. By the definition of the Sellers table, is such a position exactly when , that is, when . By Lemma 3(a), line L3 for and line L10 for report exactly when . The columns are handled in increasing order of .