Proofs: Random projection tree
These are the human proofs of Random projection tree, at full length.
The RP-tree partitions the points, has logarithmic depth with distinct projections, and its branch and bound search is exact full
This proof shows: correctness.
We use the names of the pseudocode on the page. Fix the points , the leaf size , and any sequence of directions, each normalized to unit length. Ties in distance are broken by index, so "the nearest" means the smallest pairs .
Lemma 1 (structure). BUILD terminates, and the tree it returns satisfies (I1) to (I3) for .
Proof. By induction on . If line L1 or line L5 returns a leaf, (I1) holds, (I2) is empty, and (I3) holds: either , or line L5 found , so every ; since is one of the projections and is their lower median, and no projection exceeds it, all projections equal . Otherwise , and since the point of rank has projection and goes to . So both and are smaller than , the recursive calls terminate and satisfy the invariants for and by induction, and partition , and line L4 defines them by and . This gives (I1) and (I2) at the new node, and (I3) at its leaves.
Lemma 2 (depth). If, at every node, the projections of its points are distinct, then every leaf has at most points and the depth is for and for .
Proof. With distinct projections, consists of the points of rank of a set of size , so and when ; in particular line L5 never fires, so a node becomes a leaf exactly when . By induction every node at depth has at most points, using , and the leftmost node at depth has exactly that many. So a leaf appears on every path once , and the leftmost path continues while . Since is an integer, iff iff . The depth is the least such , which is .
Lemma 3 (the pruning bound). Let a node have direction , , and threshold , and let . If , every point of the right subtree has . If , every point of the left subtree has .
Proof. By Cauchy-Schwarz, . If and is on the right, by (I2), so . If and is on the left, , so .
Theorem (exact search). QUERY leaves in the smallest pairs .
Proof. keeps, by the offers of line L7, the smallest pairs among the points evaluated so far, and every evaluated point is a point of . So it suffices to show that every point among the true nearest is evaluated, or that the final holds pairs all at most the pairs of the unevaluated points. Take any point that is not evaluated. Then some call skipped a far subtree containing at line L11, at a time when and was larger than the largest distance in . By Lemma 3, . The largest pair of never increases after is full, so at the end every pair of has distance at most , and does not belong to the smallest pairs. Hence the smallest pairs of are all evaluated, and holds them. If then at every test of line L11, nothing is skipped, all points are evaluated, and holds all of them.