Algorithm Search⌘K

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 qq. The gaps satisfy xj(−1)∈[0,w)x_j(-1) \in [0, w) and xj(+1)=w−xj(−1)∈(0,w]x_j(+1) = w - x_j(-1) \in (0, w], so all are nonnegative. Line L9 sorts the 2M2M pairs (j,δ)(j, \delta) so that 0≤z1≤⋯≤z2M0 \le z_1 \le \cdots \le z_{2M}, where ziz_i is the gap of the ii-th pair. For a nonempty A⊆[2M]={1,…,2M}A \subseteq [2M] = \{1, \ldots, 2M\} let s(A)=∑i∈Azi2s(A) = \sum_{i \in A} z_i^2. The set AA is valid if no two of its pairs share the same jj; a valid AA names the vector Δ(A)\Delta(A) with Δj=δ\Delta_j = \delta for each pair (j,δ)(j, \delta) of AA and Δj=0\Delta_j = 0 otherwise, and then score(Δ(A))=s(A)\mathrm{score}(\Delta(A)) = s(A).

Lemma 1 (vectors and valid sets). A↦Δ(A)A \mapsto \Delta(A) is a bijection from the valid nonempty subsets of [2M][2M] onto the nonzero vectors of {−1,0,1}M\{-1, 0, 1\}^M.

Proof. A nonzero Δ\Delta comes from the set of the indices of the pairs (j,Δj)(j, \Delta_j) with Δj≠0\Delta_j \ne 0; this set is valid and nonempty, and it is the only set mapped to Δ\Delta, since a valid set holds at most one pair per jj and Δ\Delta fixes which. □\square

Lemma 2 (the generation tree). For a nonempty A⊆[2M]A \subseteq [2M] with A≠{1}A \ne \{1\} and m=max⁡Am = \max A, define par(A)=A∖{m}\mathrm{par}(A) = A \setminus \{m\} if m−1∈Am - 1 \in A, and par(A)=(A∖{m})∪{m−1}\mathrm{par}(A) = (A \setminus \{m\}) \cup \{m - 1\} otherwise. Then par(A)\mathrm{par}(A) is nonempty, AA is expand(par(A))\mathrm{expand}(\mathrm{par}(A)) in the first case and shift(par(A))\mathrm{shift}(\mathrm{par}(A)) in the second, and AA is generated by line L12 from no other set. Following par\mathrm{par} from any AA reaches {1}\{1\}.

Proof. In the first case par(A)\mathrm{par}(A) contains m−1m - 1, so it is nonempty with maximum m−1m - 1, and expanding it adds mm. In the second case m≥2m \ge 2, since A≠{1}A \ne \{1\} and m=1m = 1 would force A={1}A = \{1\}; par(A)\mathrm{par}(A) contains m−1m - 1 and its maximum is m−1m - 1, since all other elements of AA are below m−1m - 1; shifting replaces m−1m - 1 by mm and gives AA. Conversely, if A=expand(B)A = \mathrm{expand}(B) then B=A∖{m}B = A \setminus \{m\} and m−1=max⁡B∈Am - 1 = \max B \in A; if A=shift(B)A = \mathrm{shift}(B) then B=(A∖{m})∪{m−1}B = (A \setminus \{m\}) \cup \{m - 1\} with m−1=max⁡B∉Am - 1 = \max B \notin A. So the case of AA determines the operation and the operation determines BB. Finally, the quantity ∑i∈Ai\sum_{i \in A} i strictly decreases under par\mathrm{par}: by mm 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 {1}\{1\}, the only set without a parent. □\square

Lemma 3 (monotone scores). For every A≠{1}A \ne \{1\}, s(par(A))≤s(A)s(\mathrm{par}(A)) \le s(A).

Proof. In the first case s(A)=s(par(A))+zm2s(A) = s(\mathrm{par}(A)) + z_m^2. In the second s(A)=s(par(A))−zm−12+zm2s(A) = s(\mathrm{par}(A)) - z_{m-1}^2 + z_m^2, and zm−1≤zmz_{m-1} \le z_m with both nonnegative. □\square

Lemma 4 (the heap order). The loop of lines L11 to L13, run to the end, extracts every nonempty subset of [2M][2M] exactly once, in nondecreasing order of ss.

Proof. By Lemma 2 the sets form a tree with root {1}\{1\}, the children of BB being shift(B)\mathrm{shift}(B) and expand(B)\mathrm{expand}(B) when max⁡B<2M\max B < 2M, 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 BB is extracted before AA with s(B)>s(A)s(B) > s(A). At the moment BB is extracted, AA is not yet extracted, so some ancestor A′A' of AA, or AA 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, s(A′)≤s(A)<s(B)s(A') \le s(A) < s(B), which contradicts the choice of BB as the minimum. □\square

Theorem 1 (the sequence). PERTURBATIONS yields every nonzero Δ∈{−1,0,1}M\Delta \in \{-1, 0, 1\}^M exactly once, in nondecreasing order of score.

Proof. Line L13 yields Δ(A)\Delta(A) for the valid extracted sets. By Lemma 4 each set is extracted once and in nondecreasing order of s(A)=score(Δ(A))s(A) = \mathrm{score}(\Delta(A)), and by Lemma 1 the valid sets correspond one to one to the nonzero vectors. □\square

Theorem 2 (the answer). QUERY returns a point of CC nearest to qq, where CC is the union, over the LL tables, of the home bucket Tt[gt(q)]T_t[g_t(q)] and the buckets Tt[gt(q)+Δ]T_t[g_t(q) + \Delta] for the first min⁡(T,3M−1)\min(T, 3^M - 1) vectors of the sequence; it returns none if CC is empty.

Proof. Line L2 stores each point pp in Tt[gt(p)]T_t[g_t(p)], so Tt[k]T_t[k] is the set of points with key kk in table tt. Lines L6 and L7 add to CC exactly the listed buckets, by Theorem 1 for the order. Line L8 takes the minimum. □\square

Theorem 3 (the success probability). Let p∈Pp \in P with ∥p−q∥=u\|p - q\| = u, and let p(u)p(u) be the probability that one random function of the family gives h(p)=h(q)h(p) = h(q). For every T≥0T \ge 0, over the random choice of the functions, Pr⁡[p∈C]≥1−(1−p(u)M)L\Pr[p \in C] \ge 1 - (1 - p(u)^M)^L. If T≥3M−1T \ge 3^M - 1, then p∈Cp \in C whenever some table has ∣ht,j(p)−ht,j(q)∣≤1|h_{t,j}(p) - h_{t,j}(q)| \le 1 for all jj.

Proof. By Theorem 2, p∈Cp \in C if gt(p)=gt(q)g_t(p) = g_t(q) for some tt. The LMLM functions are independent, so the probability that gt(p)=gt(q)g_t(p) = g_t(q) is p(u)Mp(u)^M for each tt, independently over tt, and the probability that it fails for all tt is (1−p(u)M)L(1 - p(u)^M)^L. For the second statement, with T≥3M−1T \ge 3^M - 1, Theorem 1 shows that every key gt(q)+Δg_t(q) + \Delta with Δ∈{−1,0,1}M\Delta \in \{-1, 0, 1\}^M is probed, and gt(p)g_t(p) is one of them. ■\blacksquare

Back to Multi-probe LSH