Algorithm Search⌘K

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 (M,δ)(M, \delta) be a metric space and SS a finite set stored in a GNAT. For a node tt, write S(t)S(t) for the points stored in its subtree, that is, its bucket or its split points together with S(childj)S(\text{child}_j) for each jj.

Lemma 1 (structure). For an internal node with split points p1,…,pkp_1, \dots, p_k and groups D1,…,DkD_1, \dots, D_k: S(t)=⋃j(Dj∪{pj})S(t) = \bigcup_j (D_j \cup \{p_j\}), the union is disjoint, S(childj)=DjS(\text{child}_j) = D_j, and δ(pi,x)∈range(i,j)\delta(p_i, x) \in \text{range}(i, j) for every x∈Dj∪{pj}x \in D_j \cup \{p_j\}.

Proof. Line L3 puts every non-split point into exactly one group, so the sets Dj∪{pj}D_j \cup \{p_j\} partition S(t)S(t). Line L5 builds childj_j from DjD_j. Line L4 defines range(i,j)(i, j) as the least interval that contains δ(pi,x)\delta(p_i, x) for all x∈Dj∪{pj}x \in D_j \cup \{p_j\}. □\square

Lemma 2 (safe pruning). Let di=δ(q,pi)d_i = \delta(q, p_i). If x∈Dj∪{pj}x \in D_j \cup \{p_j\} and δ(q,x)≤r\delta(q, x) \le r, then [di−r,di+r]∩range(i,j)≠∅[d_i - r, d_i + r] \cap \text{range}(i, j) \ne \emptyset.

Proof. By the triangle inequality, δ(pi,x)≤δ(pi,q)+δ(q,x)≤di+r\delta(p_i, x) \le \delta(p_i, q) + \delta(q, x) \le d_i + r and di=δ(pi,q)≤δ(pi,x)+δ(x,q)d_i = \delta(p_i, q) \le \delta(p_i, x) + \delta(x, q), so δ(pi,x)≥di−r\delta(p_i, x) \ge d_i - r. So δ(pi,x)\delta(p_i, x) lies in [di−r,di+r][d_i - r, d_i + r], and by Lemma 1 it lies in range(i,j)(i, j). □\square

Theorem 1. RANGE(t,q,r)(t, q, r) reports each x∈S(t)x \in S(t) with δ(q,x)≤r\delta(q, x) \le r exactly once, and nothing else.

Proof. By induction on the height of tt. For a leaf, line L6 tests every point of the bucket. For an internal node, every reported point passed a test δ≤r\delta \le r at line L6 or L8, so nothing else is reported. Let x∈S(t)x \in S(t) with δ(q,x)≤r\delta(q, x) \le r, and let jj be the unique index with x∈Dj∪{pj}x \in D_j \cup \{p_j\} (Lemma 1). By Lemma 2, no measured split point pip_i removes jj at line L9. So jj stays in PP. If x=pjx = p_j, then pjp_j is measured at line L8, since j∈Pj \in P when the loop reaches it, and it is reported. If x∈Djx \in D_j, line L10 calls RANGE on childj_j, which reports xx by the induction hypothesis. Exactly once: the sets Dj∪{pj}D_j \cup \{p_j\} are disjoint, each split point is measured once, and each child is visited once. □\square

Lemma 3 (lower bound of line L12). For every measured ii and every x∈Dj∪{pj}x \in D_j \cup \{p_j\}, δ(q,x)≥max⁡(di−max⁡range(i,j), min⁡range(i,j)−di)\delta(q, x) \ge \max(d_i - \max \text{range}(i, j),\ \min \text{range}(i, j) - d_i).

Proof. δ(q,x)≥di−δ(pi,x)≥di−max⁡range(i,j)\delta(q, x) \ge d_i - \delta(p_i, x) \ge d_i - \max \text{range}(i, j), and δ(q,x)≥δ(pi,x)−di≥min⁡range(i,j)−di\delta(q, x) \ge \delta(p_i, x) - d_i \ge \min \text{range}(i, j) - d_i, by the triangle inequality and Lemma 1. □\square

Theorem 2. NEAREST returns (δ∗,x∗)(\delta^*, x^*) with δ∗=min⁡x∈Sδ(q,x)\delta^* = \min_{x \in S} \delta(q, x) and x∗∈Sx^* \in S at that distance.

Proof. The pair (δ∗,x∗)(\delta^*, x^*) only changes to a measured point with a smaller distance, so at all times δ∗\delta^* is the distance of a stored point x∗x^*, and δ∗\delta^* never increases. Let yy be a nearest point, at distance δy\delta_y. We show that yy is measured or that, at the moment its group is skipped, δ∗≤δy\delta^* \le \delta_y already; in both cases the final δ∗≤δy\delta^* \le \delta_y, hence =δy= \delta_y.

Follow the path of nodes from the root toward yy. At a node, let jj be the index with y∈Dj∪{pj}y \in D_j \cup \{p_j\}. At line L11, jj is removed only if the interval [di−δ∗,di+δ∗][d_i - \delta^*, d_i + \delta^*] misses range(i,j)(i, j) for the current δ∗\delta^*. If δ∗≥δy\delta^* \ge \delta_y at that moment, Lemma 2 with r=δ∗r = \delta^* and x=yx = y shows that the interval meets the range, so jj is not removed. So if jj is removed, then δ∗<δy\delta^* < \delta_y, which is impossible since δy\delta_y is the minimum distance and δ∗\delta^* is a distance to a stored point. Hence jj is not removed at line L11, and pjp_j is measured. If y=pjy = p_j, we are done. Otherwise, at line L12, group jj is skipped only if a lower bound of Lemma 3 for yy exceeds the current δ∗\delta^*, so δy>δ∗\delta_y > \delta^*, again impossible. So the search descends into childj_j, and by induction reaches the leaf or node where yy is measured. ■\blacksquare

Back to Geometric near-neighbor access tree