Proofs: Random hyperplane LSH
These are the human proofs of Random hyperplane LSH, at full length.
Random hyperplanes collide with probability 1 − θ/π, and the L-table query succeeds with probability at least 1 − 1/e − 1/3 full
This proof shows: correctness.
We use the names of the pseudocode on the page. All vectors are nonzero, and is the angle between and .
Lemma 1 (one hyperplane). Let have independent coordinates, and let if and otherwise. Then .
Proof. If and are parallel, then either with , the angle is 0 and the bits are always equal, or , the angle is , and the bits differ unless , an event of probability 0. Otherwise and span a plane . Write with and ; then and . The standard Gaussian is invariant under orthogonal maps, so in an orthonormal basis of the two coordinates of are independent , and the direction of is uniform on the unit circle of , and with probability 1. Let be that direction. Then exactly when lies in the closed half circle centered at the direction of , and the same for . The two half circles are centered at directions an angle apart, so their symmetric difference is two arcs of length each, of total measure out of . The bits differ exactly when lies in this symmetric difference (up to the endpoints, of measure 0). So .
Lemma 2 (one table). For one table , with hyperplanes drawn independently in line L3, .
Proof. By line L1 the keys are equal exactly when all bits agree. The bits use independent vectors , so the events are independent, and each has probability by Lemma 1.
Lemma 3 (soundness). Whatever the random choices, QUERY returns either "none" or a vector with .
Proof. Every bucket holds only vectors of , inserted in line L4. The only line that returns a vector is L8, and it tests first.
Theorem. Let , , , , and , with . If some has , then QUERY returns a vector within angle of with probability at least .
Proof. Define two events over the random hyperplanes.
: for every , is not in the bucket . Since decreases in and , Lemma 2 gives a collision probability of at least in each table, and the tables are independent, so . Now , so . With this gives and .
: the number of pairs with in the bucket of in table and is at least . For each such and , Lemma 2 gives a probability at most . There are at most such and tables, so by linearity of expectation . By Markov's inequality, .
Assume neither event happens. Each execution of line L9 follows a failed test in line L8, so it counts a pair with in the bucket of in table and , and different executions count different pairs. Since , the counter stays below , and line L10 never returns. So the loops run until line L8 returns a vector, or until every bucket of has been scanned. Since fails, is in one of these buckets, and line L8 returns when it reaches , if not earlier. So QUERY returns a vector, and by Lemma 3 it is within . By the union bound the probability of is at most , so QUERY succeeds with probability at least .