Proofs: Inverted file index
These are the human proofs of Inverted file index, at full length.
The inverted file index is exact when it probes every cell, and its stopping rule is safe full
This proof shows: correctness.
Let the centroids be and let the index satisfy (V): each stored vector is in exactly one list , and for all . Distances are Euclidean.
Lemma 1 (heap). After a sequence of offers, holds pairs, where is the number of offers, and they are pairs of least distance among all offered pairs (with ties broken in some fixed way).
Proof. By induction on the offers. An offer either fills a free place, or replaces the pair of largest distance in when the new pair is smaller, or is dropped. In each case the least pairs among the offers so far are kept, since a dropped or removed pair has at least offered pairs at most as large.
Theorem 1. IVF-SEARCH returns the nearest stored vectors to , with their distances.
Proof. With , the set of line L3 is all of . By (V) each stored vector is in exactly one list, so line L5 offers each stored vector exactly once with its true distance. By Lemma 1, then holds the least pairs.
Theorem 2. For , let be the -th distance returned when the probed set is , if at least vectors are offered. Then .
Proof. The vectors offered with include those offered with . The -th least value of a superset of numbers is at most the -th least value of the subset.
Lemma 2 (bisector bound). Let be a nearest centroid to and with . Every with satisfies , where .
Proof. Let and . Expanding the squares, , an affine function with gradient . So for all . The condition on says , and . Then
using the Cauchy-Schwarz inequality and in the first step. With this gives .
If , put , which is a valid bound. For , .
Theorem 3. IVF-SEARCH-EXACT returns the nearest stored vectors to .
Proof. The cells are visited in the order of nondecreasing . If the loop never stops at line L8, every vector is offered, and Lemma 1 ends the proof as in Theorem 1. Suppose it stops at cell . Then holds pairs, and , where is the largest distance in . Every cell not yet visited has . By (V) and Lemma 2, each vector of such a cell has . So at least offered vectors are strictly closer than every vector not offered, and the least pairs among the offered vectors, which holds by Lemma 1, are the least pairs among all stored vectors.