Proofs: Geometric near-neighbor access tree
These are the human proofs of Geometric near-neighbor access tree, at full length.
Correctness of GNAT range and nearest neighbor search full
This proof shows: correctness.
Let be a metric space and a finite set stored in a GNAT. For a node , write for the points stored in its subtree, that is, its bucket or its split points together with for each .
Lemma 1 (structure). For an internal node with split points and groups : , the union is disjoint, , and for every .
Proof. Line L3 puts every non-split point into exactly one group, so the sets partition . Line L5 builds child from . Line L4 defines range as the least interval that contains for all .
Lemma 2 (safe pruning). Let . If and , then .
Proof. By the triangle inequality, and , so . So lies in , and by Lemma 1 it lies in range.
Theorem 1. RANGE reports each with exactly once, and nothing else.
Proof. By induction on the height of . For a leaf, line L6 tests every point of the bucket. For an internal node, every reported point passed a test at line L6 or L8, so nothing else is reported. Let with , and let be the unique index with (Lemma 1). By Lemma 2, no measured split point removes at line L9. So stays in . If , then is measured at line L8, since when the loop reaches it, and it is reported. If , line L10 calls RANGE on child, which reports by the induction hypothesis. Exactly once: the sets are disjoint, each split point is measured once, and each child is visited once.
Lemma 3 (lower bound of line L12). For every measured and every , .
Proof. , and , by the triangle inequality and Lemma 1.
Theorem 2. NEAREST returns with and at that distance.
Proof. The pair only changes to a measured point with a smaller distance, so at all times is the distance of a stored point , and never increases. Let be a nearest point, at distance . We show that is measured or that, at the moment its group is skipped, already; in both cases the final , hence .
Follow the path of nodes from the root toward . At a node, let be the index with . At line L11, is removed only if the interval misses range for the current . If at that moment, Lemma 2 with and shows that the interval meets the range, so is not removed. So if is removed, then , which is impossible since is the minimum distance and is a distance to a stored point. Hence is not removed at line L11, and is measured. If , we are done. Otherwise, at line L12, group is skipped only if a lower bound of Lemma 3 for exceeds the current , so , again impossible. So the search descends into child, and by induction reaches the leaf or node where is measured.