Algorithm Search⌘K

Proofs: Bit-sampling LSH

These are the human proofs of Bit-sampling LSH, at full length.

Bit sampling answers the (c, r)-near neighbor query with constant probability full

This proof shows: correctness.

Let P⊆{0,1}dP \subseteq \{0,1\}^d with ∣P∣=n≥1|P| = n \ge 1, let c>1c > 1 and 0<cr<d0 < cr < d, and let HH be the Hamming distance. Put p1=1−r/dp_1 = 1 - r/d, p2=1−cr/dp_2 = 1 - cr/d, ρ=ln⁡(1/p1)/ln⁡(1/p2)\rho = \ln(1/p_1)/\ln(1/p_2), k=⌈ln⁡n/ln⁡(1/p2)⌉k = \lceil \ln n / \ln(1/p_2) \rceil and L=⌈nρ/p1⌉L = \lceil n^\rho / p_1 \rceil. The positions of line L2 are independent and uniform. Fix a query qq. Write gj(x)g_j(x) for the key of xx in table jj.

Claim 1. If the query returns xx, then H(q,x)≤crH(q, x) \le cr.

Proof. The only line that returns a string is L6, after the test H(q,x)≤crH(q, x) \le cr. □\square

So if no string is within crcr, the answer none is correct. From now on let p∗∈Pp^* \in P have H(q,p∗)≤rH(q, p^*) \le r.

Claim 2. For one uniform position ii, Pr⁡[x[i]=y[i]]=1−H(x,y)/d\Pr[x[i] = y[i]] = 1 - H(x, y)/d.

Proof. The bits of xx and yy differ at exactly H(x,y)H(x, y) of the dd positions, and ii is uniform over the dd positions. □\square

Claim 3. Pr⁡[gj(p∗)=gj(q)]≥p1k\Pr[g_j(p^*) = g_j(q)] \ge p_1^k, and Pr⁡[gj(x)=gj(q)]≤p2k≤1/n\Pr[g_j(x) = g_j(q)] \le p_2^k \le 1/n for each xx with H(q,x)>crH(q, x) > cr.

Proof. The kk positions of table jj are independent, so the key probability is the product of kk equal factors 1−H/d1 - H/d from Claim 2. For p∗p^*, each factor is at least 1−r/d=p11 - r/d = p_1. For xx with H(q,x)>crH(q,x) > cr, each factor is less than 1−cr/d=p21 - cr/d = p_2. Finally k≥ln⁡n/ln⁡(1/p2)k \ge \ln n / \ln(1/p_2) gives p2k≤e−ln⁡n=1/np_2^k \le e^{-\ln n} = 1/n. □\square

Claim 4. Let E1E_1 be the event that gj(p∗)=gj(q)g_j(p^*) = g_j(q) for some jj. Then Pr⁡[E1]≥1−1/e\Pr[E_1] \ge 1 - 1/e.

Proof. Since k<ln⁡n/ln⁡(1/p2)+1k < \ln n / \ln(1/p_2) + 1 and p1≤1p_1 \le 1,

p1k≥p1⋅p1ln⁡n/ln⁡(1/p2)=p1⋅e−ln⁡n⋅ln⁡(1/p1)/ln⁡(1/p2)=p1n−ρ.p_1^k \ge p_1 \cdot p_1^{\ln n / \ln(1/p_2)} = p_1 \cdot e^{-\ln n \cdot \ln(1/p_1)/\ln(1/p_2)} = p_1 n^{-\rho}.

So Lp1k≥1L p_1^k \ge 1. The tables are independent, so Pr⁡[not E1]≤(1−p1k)L≤e−Lp1k≤1/e\Pr[\text{not } E_1] \le (1 - p_1^k)^L \le e^{-L p_1^k} \le 1/e. □\square

Claim 5. Let ZZ be the number of pairs (j,x)(j, x) with H(q,x)>crH(q, x) > cr and gj(x)=gj(q)g_j(x) = g_j(q), and let E2E_2 be the event Z<3LZ < 3L. Then Pr⁡[E2]≥2/3\Pr[E_2] \ge 2/3.

Proof. By Claim 3 and linearity of expectation, E[Z]≤L⋅n⋅(1/n)=L\mathbb{E}[Z] \le L \cdot n \cdot (1/n) = L. By Markov's inequality, Pr⁡[Z≥3L]≤1/3\Pr[Z \ge 3L] \le 1/3. □\square

Claim 6. If E1E_1 and E2E_2 hold, the query returns a string within crcr.

Proof. Assume the query returns none. Then the test of line L6 failed for every counted pair, so every counted pair (j,x)(j, x) has H(q,x)>crH(q, x) > cr and is counted in ZZ. So the count stays below 3L3L, line L7 never stops the loop, and line L5 visits every pair of every bucket of qq. By E1E_1 one of them is (j,p∗)(j, p^*) with H(q,p∗)≤r≤crH(q, p^*) \le r \le cr, and line L6 returns it. This is a contradiction. So the query returns a string, which is within crcr by Claim 1. □\square

Conclusion. By the union bound, Pr⁡[E1 and E2]≥1−1/e−1/3=2/3−1/e>0.29\Pr[E_1 \text{ and } E_2] \ge 1 - 1/e - 1/3 = 2/3 - 1/e > 0.29. By Claim 6 the query then returns a string within crcr. Together with Claim 1 this proves the theorem.

The exponent. Let x=r/dx = r/d, so 0<cx<10 < cx < 1. Bernoulli's inequality gives (1−x)c≥1−cx(1 - x)^c \ge 1 - cx for real c≥1c \ge 1 and 0≤x≤10 \le x \le 1. Taking logarithms, cln⁡(1−x)≥ln⁡(1−cx)c \ln(1 - x) \ge \ln(1 - cx), and dividing by the negative number cln⁡(1−cx)c \ln(1 - cx) gives ρ=ln⁡(1−x)/ln⁡(1−cx)≤1/c\rho = \ln(1 - x)/\ln(1 - cx) \le 1/c. So L=O(n1/c/p1)L = O(n^{1/c}/p_1). ■\blacksquare

Back to Bit-sampling LSH