Proofs: Multi-probe LSH
These are the human proofs of Multi-probe LSH, at full length.
The multi-probe sequence is complete and ordered, and probing never lowers the success probability full
This proof shows: correctness.
We use the names of the pseudocode on the page. Fix a table and the query . The gaps satisfy and , so all are nonnegative. Line L9 sorts the pairs so that , where is the gap of the -th pair. For a nonempty let . The set is valid if no two of its pairs share the same ; a valid names the vector with for each pair of and otherwise, and then .
Lemma 1 (vectors and valid sets). is a bijection from the valid nonempty subsets of onto the nonzero vectors of .
Proof. A nonzero comes from the set of the indices of the pairs with ; this set is valid and nonempty, and it is the only set mapped to , since a valid set holds at most one pair per and fixes which.
Lemma 2 (the generation tree). For a nonempty with and , define if , and otherwise. Then is nonempty, is in the first case and in the second, and is generated by line L12 from no other set. Following from any reaches .
Proof. In the first case contains , so it is nonempty with maximum , and expanding it adds . In the second case , since and would force ; contains and its maximum is , since all other elements of are below ; shifting replaces by and gives . Conversely, if then and ; if then with . So the case of determines the operation and the operation determines . Finally, the quantity strictly decreases under : by in the first case and by 1 in the second. It is a positive integer, so the chain ends, and it can end only at , the only set without a parent.
Lemma 3 (monotone scores). For every , .
Proof. In the first case . In the second , and with both nonnegative.
Lemma 4 (the heap order). The loop of lines L11 to L13, run to the end, extracts every nonempty subset of exactly once, in nondecreasing order of .
Proof. By Lemma 2 the sets form a tree with root , the children of being and when , and line L12 inserts exactly the children of each extracted set. So each set is inserted once, after its parent is extracted, and extracted once: by induction on the depth, every set is eventually inserted, and the heap empties only after all inserted sets are extracted. For the order, suppose is extracted before with . At the moment is extracted, is not yet extracted, so some ancestor of , or itself, is in the heap: the root was inserted, and the first ancestor on the path from the root that is not yet extracted has an extracted parent and so is in the heap. By Lemma 3, , which contradicts the choice of as the minimum.
Theorem 1 (the sequence). PERTURBATIONS yields every nonzero exactly once, in nondecreasing order of score.
Proof. Line L13 yields for the valid extracted sets. By Lemma 4 each set is extracted once and in nondecreasing order of , and by Lemma 1 the valid sets correspond one to one to the nonzero vectors.
Theorem 2 (the answer). QUERY returns a point of nearest to , where is the union, over the tables, of the home bucket and the buckets for the first vectors of the sequence; it returns none if is empty.
Proof. Line L2 stores each point in , so is the set of points with key in table . Lines L6 and L7 add to exactly the listed buckets, by Theorem 1 for the order. Line L8 takes the minimum.
Theorem 3 (the success probability). Let with , and let be the probability that one random function of the family gives . For every , over the random choice of the functions, . If , then whenever some table has for all .
Proof. By Theorem 2, if for some . The functions are independent, so the probability that is for each , independently over , and the probability that it fails for all is . For the second statement, with , Theorem 1 shows that every key with is probed, and is one of them.