Algorithm Search⌘K

Proofs: Scalable Bloom filter

These are the human proofs of Scalable Bloom filter, at full length.

A scalable Bloom filter has no false negatives and a bounded rate full

This proof shows: correctness, invariant, termination.

Fix the sequence of operations. Each operation does a constant number of steps for each part of each slice it reads, so it ends. Write ll for the number of slices after the operations, and KiK_i for the multiset of keys inserted into slice ii.

Lemma 1 (invariant (S)). After each operation, every slice except the last has count κi\kappa_i, the last has count between 1 and κl−1\kappa_{l-1}, the count of slice ii is ∣Ki∣|K_i|, and Pi,j[p]=1P_{i,j}[p] = 1 exactly when some y∈Kiy \in K_i has hi,j(y)=ph_{i,j}(y) = p.

Proof. By induction over the operations. A QUERY changes nothing. Consider INSERT(x)(x). If there is no slice, or the last slice has count κl−1\kappa_{l-1}, line L4 appends slice ll with count 0 and all bits 0; the old last slice now has count exactly κl−1\kappa_{l-1}, as required for a slice that is not last. Note κi≥1\kappa_i \ge 1, since bi≥2b_i \ge 2 gives (bi−1)ln⁡2≥0.69(b_i - 1)\ln 2 \ge 0.69, and the code takes κi=1\kappa_i = 1 in the case bi=2b_i = 2. Now the last slice has count below its capacity. Lines L5 and L6 add xx to Kl−1K_{l-1}, set exactly the bits Pl−1,j[hl−1,j(x)]P_{l-1,j}[h_{l-1,j}(x)], and add 1 to the count, which then is between 1 and κl−1\kappa_{l-1}. No other slice and no other bit changes, and no bit is set to 0. □\square

Theorem 1 (no false negatives). If xx was inserted, QUERY(x)(x) returns true.

Proof. Let ii be a slice with x∈Kix \in K_i. By Lemma 1, Pi,j[hi,j(x)]=1P_{i,j}[h_{i,j}(x)] = 1 for each j≤kij \le k_i, so line L8 returns true when the loop reaches slice ii, unless it returned true before. □\square

Model. For Theorem 2 assume ideal hashing: the values hi,j(y)h_{i,j}(y) for all slices ii, parts jj and keys yy are independent, and hi,j(y)h_{i,j}(y) is uniform on {0,…,bi−1}\{0, \ldots, b_i - 1\}. Fix the sequence of inserted keys. Since INSERT does not read any hash value to decide where a key goes, the multisets KiK_i do not depend on the hash values. Let xx be a key that is not inserted.

Lemma 2. If c≤(b−1)ln⁡2c \le (b - 1)\ln 2 and b≥2b \ge 2, then (1−1/b)c≥1/2(1 - 1/b)^c \ge 1/2.

Proof. For t=1/(b−1)∈(0,1]t = 1/(b - 1) \in (0, 1] we have 1−1/b=1/(1+t)≥e−t1 - 1/b = 1/(1 + t) \ge e^{-t}, since et≥1+te^t \ge 1 + t. So (1−1/b)c≥e−c/(b−1)≥e−ln⁡2=1/2(1 - 1/b)^c \ge e^{-c/(b - 1)} \ge e^{-\ln 2} = 1/2. □\square

Theorem 2 (rate). Slice ii accepts xx with probability at most 2−ki≤ε0ri2^{-k_i} \le \varepsilon_0 r^i, and QUERY(x)(x) returns true with probability at most ∑i<lε0ri<ε0/(1−r)\sum_{i < l} \varepsilon_0 r^i < \varepsilon_0/(1 - r).

Proof. Fix ii and let DD be the set of distinct keys of KiK_i, so ∣D∣≤κi|D| \le \kappa_i by Lemma 1. For part jj let XjX_j be the number of 1 bits of Pi,jP_{i,j}. By Lemma 1, XjX_j is a function of the values hi,j(y)h_{i,j}(y) for y∈Dy \in D only. So X1,…,XkiX_1, \ldots, X_{k_i} are independent, and they are independent of the values hi,j(x)h_{i,j}(x), since x∉Dx \notin D. Given the XjX_j, slice ii accepts xx with probability ∏jXj/bi\prod_j X_j/b_i. Hence

Pr⁡[slice i accepts x]=E[∏jXjbi]=∏jE[Xj]bi.\Pr[\text{slice } i \text{ accepts } x] = \mathbb{E}\Big[\prod_j \frac{X_j}{b_i}\Big] = \prod_j \frac{\mathbb{E}[X_j]}{b_i}.

Each bit of Pi,jP_{i,j} is 0 with probability (1−1/bi)∣D∣≥(1−1/bi)κi≥1/2(1 - 1/b_i)^{|D|} \ge (1 - 1/b_i)^{\kappa_i} \ge 1/2 by Lemma 2, since κi≤(bi−1)ln⁡2\kappa_i \le (b_i - 1)\ln 2 when bi≥3b_i \ge 3, and for bi=2b_i = 2 the capacity 1 gives the fraction 1/21/2 directly. So E[Xj]/bi≤1/2\mathbb{E}[X_j]/b_i \le 1/2, and the product is at most 2−ki2^{-k_i}. By the choice ki=⌈log⁡2(1/(ε0ri))⌉k_i = \lceil \log_2(1/(\varepsilon_0 r^i)) \rceil, 2−ki≤ε0ri2^{-k_i} \le \varepsilon_0 r^i.

QUERY(x)(x) returns true only if some slice accepts xx. The union bound over the ll slices and the sum of the geometric series give

Pr⁡[QUERY(x)=true]≤∑i=0l−1ε0ri=ε01−rl1−r<ε01−r.■\Pr[\text{QUERY}(x) = \text{true}] \le \sum_{i=0}^{l-1} \varepsilon_0 r^i = \varepsilon_0 \frac{1 - r^l}{1 - r} < \frac{\varepsilon_0}{1 - r}. \quad \blacksquare

Back to Scalable Bloom filter