Algorithm Search⌘K

Proofs: Binary fuse filter

These are the human proofs of Binary fuse filter, at full length.

The false positive rate and the cost of a binary fuse filter full

This proof shows: complexity.

Model. Assume ideal hashing: in each try, the start segment, the three offsets and the fingerprint of every key are independent and uniform, and different tries use independent functions.

Theorem 1. For each key x∉Sx \notin S, Pr⁡[QUERY(x)=true]=2−r\Pr[\text{QUERY}(x) = \text{true}] = 2^{-r}.

Proof. Whether a try succeeds depends only on the cells of the keys of SS in that try, so the final try TT is independent of the values of the functions at xx. Given TT and all values on SS, the table BB is fixed, and the cells and the fingerprint of xx in try TT are still independent and uniform. So w=B[h0(x)]⊕B[h1(x)]⊕B[h2(x)]w = B[h_0(x)] \oplus B[h_1(x)] \oplus B[h_2(x)] is independent of fp(x)\mathrm{fp}(x), and Pr⁡[fp(x)=w]=2−r\Pr[\mathrm{fp}(x) = w] = 2^{-r}. □\square

Theorem 2 (time and space). QUERY takes Θ(1)\Theta(1) time. Each try of BUILD takes Θ(n+tL)\Theta(n + tL) time, which is Θ(n)\Theta(n) for the size rule, and the table has (t+2)Lr(t + 2)L r bits.

Proof. A query computes one set of hash values and reads three cells. In PEEL, each cell enters the queue at most once at line L8 and once for each key that leaves it, so the queue handles at most (t+2)L+3n(t + 2)L + 3n entries, each in constant time; lines L4 and L5 take nn steps. For the size rule, (t+2)L≤capacity+3L(t + 2)L \le \text{capacity} + 3L, and L≤22.25nln⁡2/ln⁡3.33<4.8 n0.58L \le 2^{2.25} n^{\ln 2/\ln 3.33} < 4.8\, n^{0.58} is o(n)o(n), while capacity is O(n)O(n) since the factor is at most max⁡(1.125,0.875+0.25ln⁡(106)/ln⁡2)<6\max(1.125, 0.875 + 0.25 \ln(10^6)/\ln 2) < 6. So the table has O(n)O(n) cells. The expected number of tries is 1/p1/p, and the expected build time is Θ(n)\Theta(n) whenever pp is bounded below by a constant, as the experiments of Graf and Lemire and the threshold results of Dietzfelbinger and Walzer indicate for this size factor. ■\blacksquare

A binary fuse filter accepts every key of its set full

This proof shows: correctness, invariant, termination.

Let SS be a set of nn distinct keys and write E(x)={h0(x),h1(x),h2(x)}E(x) = \{h_0(x), h_1(x), h_2(x)\}. Since hj(x)h_j(x) lies in segment s(x)+js(x) + j, the three cells are distinct, and they lie in {0,…,(t+2)L−1}\{0, \ldots, (t + 2)L - 1\} because s(x)≤t−1s(x) \le t - 1.

Lemma 1 (peeling order). If PEEL(S)(S) succeeds, the order (x1,c1),…,(xn,cn)(x_1, c_1), \ldots, (x_n, c_n) lists each key once, and for each ii, ci∈E(xi)c_i \in E(x_i) and ci∉E(xi′)c_i \notin E(x_{i'}) for each i′>ii' > i.

Proof. Lines L7 and L10 keep, for each cell, the count and the xor of the indices of the keys that are not yet in the order and use it. When line L9 takes a cell with count 1, the xor is the index of the only such key, and the keys appended later were not yet in the order at that time, so they do not use the cell. □\square

Lemma 2. In the loop of lines L4 and L5, cell cic_i is written only at step ii, and after step ii no cell of E(xi)E(x_i) is written.

Proof. Step i′i' writes only ci′∈E(xi′)c_{i'} \in E(x_{i'}). For i′>ii' > i, ci∉E(xi′)c_i \notin E(x_{i'}), so ci′≠cic_{i'} \ne c_i. The steps after step ii are those with i′<ii' < i, and ci′∉E(xi)c_{i'} \notin E(x_i) by Lemma 1, since i>i′i > i'. □\square

Theorem 1 (invariant (X)). After BUILD, B[h0(x)]⊕B[h1(x)]⊕B[h2(x)]=fp(x)B[h_0(x)] \oplus B[h_1(x)] \oplus B[h_2(x)] = \mathrm{fp}(x) for each x∈Sx \in S, so QUERY returns true on SS.

Proof. For x=xix = x_i with other cells u,vu, v, line L5 makes B[ci]⊕B[u]⊕B[v]=fp(xi)B[c_i] \oplus B[u] \oplus B[v] = \mathrm{fp}(x_i), and by Lemma 2 none of the three cells changes later. □\square

Lemma 3 (room). If n≥2n \ge 2 and L,tL, t follow the size rule, then (t+2)(L−1)≥n(t + 2)(L - 1) \ge n.

Proof. The rule gives (t+2)L≥⌈capacity/L⌉L≥capacity≥nϕ−1/2(t + 2)L \ge \lceil \text{capacity}/L \rceil L \ge \text{capacity} \ge n \phi - 1/2, where ϕ=max⁡(1.125,0.875+0.25ln⁡(106)/ln⁡n)\phi = \max(1.125, 0.875 + 0.25 \ln(10^6)/\ln n) is the size factor. If n≥9n \ge 9, then ln⁡9/ln⁡3.33+2.25>4\ln 9/\ln 3.33 + 2.25 > 4, so L≥16L \ge 16 and (t+2)(L−1)≥1516(1.125n−1/2)≥n(t + 2)(L - 1) \ge \tfrac{15}{16}(1.125 n - 1/2) \ge n, since 0.0547n≥0.470.0547 n \ge 0.47 for n≥9n \ge 9. If 2≤n≤82 \le n \le 8, then L≥4L \ge 4 and ϕ≥0.875+0.25⋅13.81/ln⁡8>2.5\phi \ge 0.875 + 0.25 \cdot 13.81/\ln 8 > 2.5, so (t+2)(L−1)≥34(2.5n−1/2)≥n(t + 2)(L - 1) \ge \tfrac34 (2.5 n - 1/2) \ge n. □\square

Theorem 2 (termination). Under ideal hashing, with independent hash functions in each try, and (t+2)(L−1)≥n(t + 2)(L - 1) \ge n (true by Lemma 3 for the size rule and n≥2n \ge 2, and trivial for n≤1n \le 1, where at most one key has three cells of count 1), BUILD ends with probability 1, after a geometric number of tries.

Proof. Each try succeeds with the same probability pp, independently, so it suffices to show p>0p > 0. Reserve cell jLjL of each segment jj as a spare. The other (t+2)(L−1)≥n(t + 2)(L - 1) \ge n cells can be given to the keys as distinct private cells. For a key with private cell π\pi in segment jj, choose its start segment s=min⁡(j,t−1)s = \min(j, t - 1); then j−s∈{0,1,2}j - s \in \{0, 1, 2\}, because j≤t+1j \le t + 1. Let its cell in segment jj be π\pi and its cells in the other two segments of its window be their spares. Every private cell then has count 1, so every key is peeled from its private cell. This choice of the hash values has positive probability, so p>0p > 0. Each try has O(n+tL)O(n + tL) steps, as for the xor filter. ■\blacksquare

Back to Binary fuse filter