Proofs: LZ-index
These are the human proofs of LZ-index, at full length.
The LZ-index reports every occurrence once, by the number of phrases it touches full
This proof shows: correctness.
We use the pseudocode, the notation and the invariant (Z1) to (Z3) of the page. Let , and for a position of , let be the phrase that contains it. An occurrence of at occupies ; since has no , it lies inside . It touches the phrases . We show that the three parts of SEARCH report exactly the occurrences that touch one, two, and at least three phrases, each once, and nothing else.
Lemma 1 (prefix closure). Every prefix of a phrase is a phrase, and the LZTrie node of is an ancestor of the node of exactly when is a prefix of .
Proof. By (Z1) each phrase is an earlier phrase plus one symbol, so by induction its prefixes are phrases. In a trie, the node of is an ancestor of the node of exactly when is a prefix of .
One phrase (line L3). Soundness. Line L3 takes a phrase ending with , which is what the RevTrie subtree of holds by (Z2), and a phrase with as a prefix, by Lemma 1. Then , so occurs at by (Z3), inside . Completeness. If occurs inside , ending at offset , then is a phrase by Lemma 1, it ends with , and it is a prefix of , so line L3 reports the occurrence with . Uniqueness. For a fixed , different are different prefixes of , of different lengths, and give different positions.
Two phrases (lines L4 and L5). Soundness. For a cut , a reported pair has ending with and starting with . Since ends at , the occurrence at touches exactly and . Completeness. An occurrence at that touches exactly and has symbols in , with ; then ends with and starts with , so the pair is reported for this . Uniqueness. The cut is the distance from to the phrase boundary inside the occurrence, so it is determined by the occurrence.
At least three phrases (lines L6 and L7). Let an occurrence at touch with . Then lies wholly inside it, starting at and ending before the end of the occurrence, so with , and . Completeness. For this , the walk of line L6 along meets the node of at depth , since by Lemma 1 all its prefixes are nodes; with , ends with and the following phrases spell a string that starts with , so line L7 reports . Soundness. If line L7 reports , then is a suffix of , , and is a prefix of , so occurs there; it starts inside and ends after , so it touches at least three phrases. Uniqueness. For a given occurrence, must be the first phrase that starts inside it after its first position, so and are determined.
The three parts cover the occurrences that touch one, two, and at least three phrases, which are all the occurrences, and these classes are disjoint. So SEARCH reports each occurrence exactly once.