Proofs: M-tree
These are the human proofs of M-tree, at full length.
The M-tree keeps its covering invariants under insertion, and its range and k-NN searches are exact full
This proof shows: correctness.
We use the names of the pseudocode on the page. is a metric space. For a node , is the multiset of objects in the leaf entries below . A routing entry with child covers when for all . The invariants are (I1) every routing entry covers; (I2) every non-root entry has , where is the routing object of the entry that points to its node; (I3) all leaves are at one depth; (I4) every node has at most entries, and every non-root node at least .
Lemma 1 (radius of a split). Let be an object and a set of entries of one node, all covering. If , with radius 0 for leaf entries, then for every object of every entry of (the object of a leaf entry, or an object below a routing entry).
Proof. For a leaf entry and . For a routing entry, by the triangle inequality and (I1).
Lemma 2 (insertion). If the tree satisfies (I1) to (I4) before INSERT, it does after, and its objects are the old ones plus .
Proof. Let be the nodes on the path chosen by lines L20 and L21, from the root to a leaf, and the entry of chosen there. After line L20 or L21, , and radii only grow, so each covers its old objects and . No other entry gains an object. Line L18 adds to with , passed down in line L22, which is (I2) for it.
Now consider a split of a node with entries in lines L24 to L27. The balanced partition of line L25 gives the two promoted objects alternate turns until no entry is free, so the parts have and entries: (I4) for the new nodes. By Lemma 1 the new routing entries cover. Line L26 sets the of every entry to its distance to the routing object of its new parent entry, which gives (I2) inside the new nodes, and line L22 sets the of the two new routing entries to their distance to , the routing object of the node that now holds them. The new entries replace in that node, which holds one more entry; its routing entry, if any, covers the same objects as before, so (I1) holds there. If that node now has entries, line L23 splits it in turn. If the root splits, line L17 makes a new root with two entries and no , and every leaf gets one level deeper, so (I3) holds; otherwise no depth changes. The new root has 2 entries, which (I4) allows.
Theorem 1 (range). If (I1) and (I2) hold, RANGE reports exactly the objects of the tree with , with multiplicity.
Proof. By induction on the height of , RANGE, where is the routing object of the entry pointing to (none for the root), reports exactly the answers in . Each leaf entry is reported only if line L5 found . Suppose an answer is not reported; then an entry on its path was skipped. If line L2 skipped it, then by (I2), and , so by the triangle inequality . If line L6 skipped it, directly. For a leaf entry with radius 0 and this says . For a routing entry, (I1) gives . Either way is not an answer, a contradiction.
Theorem 2 ( nearest). If (I1) and (I2) hold and the tree stores objects, KNN returns objects whose distances are the least distances from to the stored objects.
Proof. For an entry define . By (I1) and the triangle inequality, every object below has ; for a leaf entry . As in Theorem 1, the test of line L12 skips only if , and then every object below has distance greater than .
The value is while and then the largest distance in ; it never increases, because an object enters a full only if its distance is below , and the farthest is dropped. Call an object lost if it is never offered to in line L14. An object is lost only if (a) an entry above it or its own entry was skipped by line L12 or not added in line L15 at a moment with threshold , so ; or (b) the search stopped in line L10 while a node above was still in PQ, or below a node in PQ, with at that moment, and each node in PQ has the popped one, so . Since only decreases, in both cases , the final threshold.
If fewer than objects were offered, then , nothing is lost, and holds all objects. Otherwise at the end, and holds the least distances among the offered objects, all at most ; every lost object has distance greater than . So the distances in are the least distances of all stored objects.
Lemma 3 (height). Under (I3) and (I4) with , a tree of height levels holds objects, so .
Proof. The root has at least 2 entries when it is internal, since it was made by a split of the root in line L17. Every other internal node has at least children, and every leaf at least entries, and for . By (I3) there are at least leaves, each with at least objects.