Algorithm Search⌘K

Proofs: Spectral Bloom filter

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

The error probability of a spectral Bloom filter full

This proof shows: complexity.

Model. Assume ideal hashing: the values hi(y)h_i(y) for all i≤ki \le k and all keys yy are independent and uniform on {0,…,m−1}\{0, \ldots, m - 1\}. Fix the sequence of operations, so that the multiset ff does not depend on the hash values; neither rule reads a hash value to decide which key to update. Fix a key xx, let YY be the set of keys y≠xy \ne x with fy>0f_y > 0, n=∣Y∣n = |Y|, and B=⋃y∈YH(y)B = \bigcup_{y \in Y} H(y).

Theorem 1. Under either rule, Pr⁡[f^x≠fx]≤E[(∣B∣/m)k]\Pr[\hat f_x \ne f_x] \le \mathbb{E}[(|B|/m)^k]. In particular it is at most (1−(1−1/m)kn)k\big(1 - (1 - 1/m)^{kn}\big)^k up to the gap between the exact and the classical Bloom filter formulas, and it does not depend on the counts.

Proof. By Theorems 1 and 2 of the correctness proof, fx≤f^xMI≤f^xMSf_x \le \hat f_x^{\mathrm{MI}} \le \hat f_x^{\mathrm{MS}}, and f^xMS≠fx\hat f_x^{\mathrm{MS}} \ne f_x only if every p∈H(x)p \in H(x) lies in BB. So for both rules the error implies H(x)⊆BH(x) \subseteq B. The set BB is a function of the hash values of the keys in YY, which are independent of h1(x),…,hk(x)h_1(x), \ldots, h_k(x). Given BB, each hi(x)h_i(x) lies in BB with probability ∣B∣/m|B|/m, independently, so

Pr⁡[H(x)⊆B]=E[Pr⁡[h1(x),…,hk(x)∈B∣B]]=E[(∣B∣/m)k].\Pr[H(x) \subseteq B] = \mathbb{E}\big[\Pr[h_1(x), \ldots, h_k(x) \in B \mid B]\big] = \mathbb{E}\big[(|B|/m)^k\big].

This is exactly the probability that a Bloom filter with the same mm and kk, built from the nn keys of YY, accepts xx, its false positive rate. Its classical estimate is (1−(1−1/m)kn)k≈(1−e−kn/m)k(1 - (1 - 1/m)^{kn})^k \approx (1 - e^{-kn/m})^k. □\square

Theorem 2 (time and space). Each operation evaluates kk hash functions and reads or writes at most kk counters, so it takes Θ(k)\Theta(k) time on the word RAM when a counter fits in a word. The array takes mm counters. ■\blacksquare

A spectral Bloom filter never underestimates full

This proof shows: correctness, invariant, termination.

Fix the hash functions and a sequence of operations. Write ff for the multiset after the first tt operations, CC for the counters of minimum selection and DD for the counters of minimal increase on the same sequence of inserts. Each operation loops over at most kk positions, so it ends.

Lemma 1 (invariant (M)). Under minimum selection, after each operation C[p]=∑y:p∈H(y)fyC[p] = \sum_{y : p \in H(y)} f_y for each pp, provided every DELETE(x,w)(x, w) has fx≥wf_x \ge w before it.

Proof. At the start both sides are 0. INSERT(x,w)(x, w) adds ww to fxf_x, which adds ww to the right side exactly for the p∈H(x)p \in H(x), and line L3 adds ww to exactly these counters, once each, since H(x)H(x) is a set. DELETE(x,w)(x, w) is the same with −w-w. □\square

Theorem 1 (minimum selection). For each xx, f^x=fx+min⁡p∈H(x)∑y≠x, p∈H(y)fy\hat f_x = f_x + \min_{p \in H(x)} \sum_{y \ne x,\, p \in H(y)} f_y. So f^x≥fx\hat f_x \ge f_x, with equality exactly when some p∈H(x)p \in H(x) lies in H(y)H(y) for no y≠xy \ne x with fy>0f_y > 0.

Proof. By Lemma 1, for p∈H(x)p \in H(x) the counter is C[p]=fx+∑y≠x, p∈H(y)fyC[p] = f_x + \sum_{y \ne x,\, p \in H(y)} f_y, and line L7 takes the minimum over p∈H(x)p \in H(x). The sums have nonnegative terms, so the minimum is 0 exactly when one of them has no positive term. □\square

Theorem 2 (minimal increase). If all operations are inserts and minimal increase is used, then after each insert, for each key yy and each p∈H(y)p \in H(y),

fy≤D[p]≤C[p].f_y \le D[p] \le C[p].

Hence fx≤f^xMI≤f^xMSf_x \le \hat f_x^{\mathrm{MI}} \le \hat f_x^{\mathrm{MS}} for each xx.

Proof. By induction over the inserts. At the start all values are 0. Consider INSERT(x,w)(x, w), and let f′f', C′C' and D′D' be the values after it.

Lower bound. Let v=min⁡p∈H(x)D[p]v = \min_{p \in H(x)} D[p], the value of line L4. By the induction hypothesis v≥fxv \ge f_x. Line L5 sets D′[p]=max⁡(D[p],v+w)≥fx+w=fx′D'[p] = \max(D[p], v + w) \ge f_x + w = f'_x for each p∈H(x)p \in H(x). For y≠xy \ne x, fy′=fyf'_y = f_y and no counter decreases, so D′[p]≥D[p]≥fyD'[p] \ge D[p] \ge f_y for p∈H(y)p \in H(y).

Upper bound. For p∉H(x)p \notin H(x) nothing changes. For p∈H(x)p \in H(x), line L3 gives C′[p]=C[p]+wC'[p] = C[p] + w. If D′[p]=D[p]D'[p] = D[p], then D′[p]≤C[p]≤C′[p]D'[p] \le C[p] \le C'[p]. Otherwise D′[p]=v+w≤D[p]+w≤C[p]+w=C′[p]D'[p] = v + w \le D[p] + w \le C[p] + w = C'[p], since v≤D[p]v \le D[p] for each p∈H(x)p \in H(x).

The estimates are minima over the same set H(x)H(x) of values that satisfy the bounds pointwise, which gives the last claim. ■\blacksquare

Back to Spectral Bloom filter