Algorithm Search⌘K

Proofs: Bloomier filter

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

The false positive rate of a Bloomier filter full

This proof shows: complexity.

Model. Assume ideal hashing: for a key x∉Sx \notin S, the cells h0(x),h1(x),h2(x)h_0(x), h_1(x), h_2(x) and the mask μ(x)\mu(x) are independent of each other, uniform on their ranges, and independent of the hash values of the keys of SS. The arrays TT and RR are functions of the hash values of the keys of SS and of ff only.

Theorem. For each x∉Sx \notin S, Pr⁡[LOOKUP(x)≠⊥]=3/2q\Pr[\text{LOOKUP}(x) \ne \bot] = 3/2^q.

Proof. Fix TT, RR and the cells of xx, and let a=T[h0(x)]⊕T[h1(x)]⊕T[h2(x)]a = T[h_0(x)] \oplus T[h_1(x)] \oplus T[h_2(x)], a fixed qq-bit value. Then τ=μ(x)⊕a\tau = \mu(x) \oplus a. The map y↦y⊕ay \mapsto y \oplus a is a bijection on qq-bit values, and μ(x)\mu(x) is uniform and independent of aa, so τ\tau is uniform on the 2q2^q values. LOOKUP returns a value exactly when τ∈{0,1,2}\tau \in \{0, 1, 2\}, which has probability 3/2q3/2^q for q≥2q \ge 2. Averaging over TT, RR and the cells keeps this value. □\square

Space. The two arrays take M(q+r)M(q + r) bits. With q=⌈log⁡2(3/ε)⌉q = \lceil \log_2(3/\varepsilon) \rceil the rate is at most ε\varepsilon, and with M=1.23n+O(1)M = 1.23 n + O(1) the space is 1.23n(⌈log⁡2(3/ε)⌉+r)+O(q+r)1.23 n (\lceil \log_2(3/\varepsilon) \rceil + r) + O(q + r) bits.

Time. LOOKUP and SET compute one hash, read three cells of TT and one of RR, and take Θ(1)\Theta(1) time on the word RAM with q,r≤wq, r \le w. One attempt of BUILD computes nn hashes, runs PEEL in O(M+n)O(M + n) steps and the assignment in O(n)O(n) steps. The number of attempts depends on the peeling threshold, which is a result of Molloy (2005) and is not proved here. ■\blacksquare

A Bloomier filter returns the stored value of each key of the set full

This proof shows: correctness, invariant, termination.

Let BUILD succeed with the peeling order (x1,c1),…,(xn,cn)(x_1, c_1), \ldots, (x_n, c_n), and write H(x)={h0(x),h1(x),h2(x)}H(x) = \{h_0(x), h_1(x), h_2(x)\}. The three cells are in different thirds of the table, so they are distinct. All arithmetic on TT is bitwise exclusive or ⊕\oplus on qq-bit values.

Lemma 1 (the peeling order). PEEL returns a sequence of all nn keys in which each key appears once, ci∈H(xi)c_i \in H(x_i), and ci∉H(xj)c_i \notin H(x_j) for each j>ij > i.

Proof. Let KiK_i be the set of keys not yet in the order when the ii-th pair is appended, so xi∈Kix_i \in K_i and Ki+1=Ki∖{xi}K_{i+1} = K_i \setminus \{x_i\}. Line L13 picks cic_i with exactly one key of KiK_i having cic_i as a cell, and that key is xix_i. Each later key xjx_j, j>ij > i, lies in Ki+1⊆KiK_{i+1} \subseteq K_i and is not xix_i, so ci∉H(xj)c_i \notin H(x_j). A removed key is never chosen again, so each key appears at most once, and line L14 checks that all nn keys appear. □\square

Lemma 2 (cells written). In the loop of lines L4 to L7, the iteration for xix_i writes only T[ci]T[c_i] and R[ci]R[c_i]. The cells c1,…,cnc_1, \ldots, c_n are distinct, and T[ci]T[c_i] is 0 just before the iteration for xix_i.

Proof. The first claim is lines L6 and L7. If ci=cjc_i = c_j with i<ji < j, then ci∈H(xj)c_i \in H(x_j), against Lemma 1. Before the iteration for xix_i only the cells cjc_j with j>ij > i have been written, and these differ from cic_i. □\square

Lemma 3 (invariant (E) after BUILD). For each ii,

μ(xi)⊕⨁c∈H(xi)T[c]=τ(xi),R[ci]=f(xi),\mu(x_i) \oplus \bigoplus_{c \in H(x_i)} T[c] = \tau(x_i), \qquad R[c_i] = f(x_i),

where ci=hτ(xi)(xi)c_i = h_{\tau(x_i)}(x_i).

Proof. Right after the iteration for xix_i, line L6 gives T[ci]=τ⊕μ(xi)⊕⨁c∈H(xi),c≠ciT[c]T[c_i] = \tau \oplus \mu(x_i) \oplus \bigoplus_{c \in H(x_i), c \ne c_i} T[c], and xoring both sides with μ(xi)⊕⨁c≠ciT[c]\mu(x_i) \oplus \bigoplus_{c \ne c_i} T[c] gives the first equation at that moment. Line L5 chose τ\tau with hτ(xi)=cih_\tau(x_i) = c_i. The later iterations are for xi−1,…,x1x_{i-1}, \ldots, x_1, and by Lemma 2 they write only the cells ci−1,…,c1c_{i-1}, \ldots, c_1. By Lemma 1, none of them is in H(xi)H(x_i). So the cells of xix_i in TT do not change again, and R[ci]R[c_i] is written only in the iteration for xix_i, by the distinctness of Lemma 2. □\square

Theorem. After BUILD and any sequence of SET operations on keys of SS, LOOKUP(x)(x) returns the current value f(x)f(x) for each x∈Sx \in S. Each operation ends, and BUILD ends with probability 1.

Proof. By Lemma 3, line L8 computes τ=τ(x)∈{0,1,2}\tau = \tau(x) \in \{0, 1, 2\} for each x∈Sx \in S, so line L9 returns R[hτ(x)(x)]R[h_{\tau(x)}(x)], which is f(x)f(x) after BUILD. SET(x,v)(x, v) computes the same τ(x)\tau(x) and writes vv to R[hτ(x)(x)]R[h_{\tau(x)}(x)], the own cell of xx. It writes no cell of TT, so the equations of Lemma 3 stay true for all keys. Its write to RR is at the own cell of xx, which by Lemma 2 is not the own cell of another key, so the values of other keys do not change. LOOKUP and SET take constant time and PEEL takes O(M+n)O(M + n) steps, since each key is removed once and each cell enters the queue at most once per decrease of its count. Each attempt of line L1 uses new random hash functions; after each 10 failures the table grows by 10 percent, so after finitely many failures s≥ns \ge n. A table with s≥ns \ge n peels with positive probability: with positive probability the values h0(x)h_0(x) of the nn keys are distinct, and then each key has a cell of its own. This probability only grows with ss, so each attempt from then on succeeds with at least a fixed positive probability, and BUILD ends with probability 1. ■\blacksquare

Back to Bloomier filter