LSH answers the (c, r)-near neighbor query with constant probability full
This proof shows: correctness.
Let H be (r,cr,p1,p2)-sensitive with 0<p2<p1≤1 and ρ=ln(1/p1)/ln(1/p2). Let ∣P∣=n≥1, k=⌈log1/p2n⌉ and L=⌈nρ/p1⌉. The functions hj,i of line L2 are independent. Fix a query q.
Claim 1 (no far answer). If LSH-QUERY returns a point x, then δ(q,x)≤cr.
Proof. The only line that returns a point is L9, and it does so only when δ(q,x)≤cr. □
So if no point is within cr, the query returns none, which is the correct answer. From now on assume that p∗∈P has δ(q,p∗)≤r.
Claim 2. Let E1 be the event that gj(p∗)=gj(q) for some j. Then Pr[E1]≥1−1/e.
Proof. For one table, Pr[gj(p∗)=gj(q)]=∏i=1kPr[hj,i(p∗)=hj,i(q)]≥p1k, by independence and the sensitivity for δ≤r. Since k<log1/p2n+1 and p1≤1,
p1k≥p1log1/p2n+1=p1⋅nlog1/p2p1=p1⋅n−ρ. Here log1/p2p1=lnp1/ln(1/p2)=−ρ. So Lp1k≥(nρ/p1)⋅p1n−ρ=1. The tables are independent, so Pr[not E1]≤(1−p1k)L≤e−Lp1k≤e−1, using 1−x≤e−x. □
Claim 3. Let F={x∈P:δ(q,x)>cr}, and let Z be the number of pairs (j,x) with x∈F and gj(x)=gj(q). Let E2 be the event Z<3L. Then Pr[E2]≥2/3.
Proof. For x∈F, δ(q,x)≥cr, so each function collides with probability at most p2, and Pr[gj(x)=gj(q)]≤p2k≤p2log1/p2n=1/n. By linearity of expectation, E[Z]≤L⋅∣F∣⋅(1/n)≤L. By Markov's inequality, Pr[Z≥3L]≤E[Z]/(3L)≤1/3. □
Claim 4. If E1 and E2 hold, the query returns a point within cr.
Proof. Each increment of line L8 counts one pair (j,x) with x in the bucket of q in table j. Assume the query does not return a point. Then line L9 never succeeded, so each counted pair has x∈F, and the count is at most Z<3L. So line L10 never stopped the query, and the loops of lines L6 and L7 ran to the end and counted every pair of every bucket of q. By E1 the pair (j,p∗) for some j is among them, and p∗∈/F. This contradicts the fact that each counted pair has x∈F. So the query returns a point, which is within cr by Claim 1. □
Theorem. If some point of P is within r of q, LSH-QUERY returns a point within cr of q with probability at least 2/3−1/e>0.29. If no point is within cr, it returns none with probability 1.
Proof. The second part is Claim 1. For the first, by Claim 4 and the union bound, the failure probability is at most Pr[not E1]+Pr[not E2]≤1/e+1/3, and 1−1/e−1/3=2/3−1/e≈0.2988. ■
Termination and cost. The loop of line L6 runs L times, and the inner loop stops after at most 3L increments in total by line L10, or at the end of a finite bucket. So the query computes at most 3L distances and Lk hash values.