Algorithm Search⌘K

Proofs: Stable Bloom filter

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

The stable fraction of zero cells full

This proof shows: complexity.

Model. At each step tt, the set H(xt)H(x_t) is a uniform random KK-subset of the mm cells and VtV_t is a uniform random PP-subset, and all these sets are independent. This holds under ideal hashing for a stream of distinct elements. Assume 1≤K<m1 \le K < m and P≥1P \ge 1.

Theorem 1. For each cell jj,

lim⁡t→∞Pr⁡[Ct[j]=0]=qMax,q=11+1P(1/K−1/m).\lim_{t \to \infty} \Pr[C_t[j] = 0] = q^{\mathrm{Max}}, \qquad q = \frac{1}{1 + \frac{1}{P(1/K - 1/m)}}.

Proof. Fix jj. At each step ss, let AsA_s be the event j∈H(xs)j \in H(x_s), a set, and BsB_s the event j∈Vsj \in V_s and j∉H(xs)j \notin H(x_s), a pure decrement. Then Pr⁡[As]=a=K/m\Pr[A_s] = a = K/m and, by the independence of H(xs)H(x_s) and VsV_s, Pr⁡[Bs]=b=(P/m)(1−K/m)\Pr[B_s] = b = (P/m)(1 - K/m). Steps are independent.

By the invariant (D) of the correctness proof, Ct[j]=0C_t[j] = 0 exactly when either no step s≤ts \le t is a set, or the last set τ\tau is followed by at least Max pure decrements in the steps τ+1,…,t\tau + 1, \ldots, t (a step that is both a set and a decrement counts as a set, since line L4 runs after line L3).

Look at the steps t,t−1,…,1t, t - 1, \ldots, 1 in this order, and keep only the relevant steps, those that are a set or a pure decrement. Since the steps are independent and identically distributed, each relevant step is, independently of the others, a pure decrement with probability

ba+b=P(1−K/m)K+P(1−K/m)=11+KP(1−K/m)=11+1P(1/K−1/m)=q,\frac{b}{a + b} = \frac{P(1 - K/m)}{K + P(1 - K/m)} = \frac{1}{1 + \frac{K}{P(1 - K/m)}} = \frac{1}{1 + \frac{1}{P(1/K - 1/m)}} = q,

and a set otherwise. The cell is 0 at time tt if and only if the first Max relevant steps in this backward order are all pure decrements, or there are fewer than Max relevant steps and none is a set.

Let RtR_t be the number of relevant steps among 1,…,t1, \ldots, t. Given Rt=ρ≥MaxR_t = \rho \ge \mathrm{Max}, the first event has probability exactly qMaxq^{\mathrm{Max}} and the second is impossible. So

∣Pr⁡[Ct[j]=0]−qMax∣≤Pr⁡[Rt<Max].\big|\Pr[C_t[j] = 0] - q^{\mathrm{Max}}\big| \le \Pr[R_t < \mathrm{Max}].

Each step is relevant with probability a+b≥K/m>0a + b \ge K/m > 0, independently, so Pr⁡[Rt<Max]→0\Pr[R_t < \mathrm{Max}] \to 0 as t→∞t \to \infty. □\square

Theorem 2 (time and space). PROCESS takes Θ(K+P)\Theta(K + P) time, given Θ(1)\Theta(1) time for each random cell and each hash value, and the array has mdm d bits.

Proof. Line L2 reads KK cells, line L3 chooses and updates PP cells, and line L4 writes KK cells. ■\blacksquare

The cells of a stable Bloom filter record the decay since the last set full

This proof shows: correctness, invariant, termination.

Write CtC_t for the array after step tt, and VtV_t for the set of PP cells chosen at line L3 of step tt. Each step does KK checks, PP decrements and KK sets, so it ends.

Lemma 1 (invariant (D)). For each t≥0t \ge 0 and each cell jj, let τ=max⁡{s≤t:j∈H(xs)}\tau = \max\{ s \le t : j \in H(x_s) \}, if it exists. Then Ct[j]=max⁡(0,Max−∣{s:τ<s≤t, j∈Vs}∣)C_t[j] = \max(0, \mathrm{Max} - |\{s : \tau < s \le t,\ j \in V_s\}|), and Ct[j]=0C_t[j] = 0 if τ\tau does not exist.

Proof. By induction on tt. At t=0t = 0 all cells are 0 by line L1, and no element has arrived. Consider step t+1t + 1 and cell jj. If j∈H(xt+1)j \in H(x_{t+1}), then τ=t+1\tau = t + 1, there are no later decrements, and line L4 sets Ct+1[j]=MaxC_{t+1}[j] = \mathrm{Max}, after line L3. Otherwise τ\tau is unchanged. If j∈Vt+1j \in V_{t+1}, the count of decrements grows by 1, and line L3 lowers the cell by 1 if it is above 0, which is the change of max⁡(0,Max−D)\max(0, \mathrm{Max} - D) when DD grows by 1; and if τ\tau does not exist the cell stays 0. If j∉Vt+1j \notin V_{t+1}, nothing changes. □\square

Theorem 1 (what is reported). PROCESS(xt)(x_t) returns true exactly when every j∈H(xt)j \in H(x_t) was set at some step τj<t\tau_j < t and had fewer than Max decrements in the steps τj+1,…,t−1\tau_j + 1, \ldots, t - 1, where τj\tau_j is the last such step.

Proof. Line L2 reads Ct−1C_{t-1} before the decrements and sets of step tt. By Lemma 1, Ct−1[j]>0C_{t-1}[j] > 0 exactly when τj≤t−1\tau_j \le t - 1 exists and fewer than Max of the steps τj+1,…,t−1\tau_j + 1, \ldots, t - 1 chose jj. □\square

Corollary 1. If xt=xt−1x_t = x_{t-1}, PROCESS(xt)(x_t) returns true. More generally, if xt=xsx_t = x_s with s<ts < t, and no cell of xtx_t was chosen Max times in the steps s+1,…,t−1s + 1, \ldots, t - 1, then PROCESS(xt)(x_t) returns true.

Proof. Each j∈H(xt)j \in H(x_t) was set at step ss, so its last set τj\tau_j satisfies s≤τj<ts \le \tau_j < t, and it had at most as many decrements after τj\tau_j as after ss. For s=t−1s = t - 1 there are no steps in between. Theorem 1 gives the claim. ■\blacksquare

Back to Stable Bloom filter