Algorithm Search⌘K

Proofs: Learned Bloom filter

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

A learned Bloom filter has no false negatives full

This proof shows: correctness, invariant, termination.

Fix the classifier σ\sigma, the threshold τ\tau and the set SS. BUILD and QUERY consist of a finite number of classifier evaluations and Bloom filter steps, so they end. Let N={x∈S:σ(x)<τ}N = \{x \in S : \sigma(x) < \tau\}. We use one fact about a Bloom filter: it accepts every key it holds, and under ideal hashing it accepts each fixed key that it does not hold with a probability, its per-key rate, that is the same for all such keys.

Theorem 1 (no false negatives). QUERY(x)(x) returns true for each x∈Sx \in S.

Proof. If there is an initial filter, it holds SS by line L1, so it accepts xx and line L4 does not return false. If σ(x)≥τ\sigma(x) \ge \tau, line L5 returns true. Otherwise x∈Nx \in N by line L2, the backup filter holds xx by line L3, and line L6 returns true. □\square

Model. Let D\mathcal{D} be a distribution on U∖SU \setminus S. Assume ideal and independent hash functions for F0F_0 and FbF_b, chosen independently of σ\sigma, τ\tau, SS and D\mathcal{D}. Let ε0\varepsilon_0 be the per-key rate of F0F_0 (with ε0=1\varepsilon_0 = 1 if there is no initial filter), εb\varepsilon_b that of FbF_b, and Fp=Pr⁡x∼D[σ(x)≥τ]F_p = \Pr_{x \sim \mathcal{D}}[\sigma(x) \ge \tau].

Theorem 2 (rate on the query distribution). For x∼Dx \sim \mathcal{D}, independent of the hash functions,

Pr⁡[QUERY(x)=true]=ε0(Fp+(1−Fp) εb).\Pr[\text{QUERY}(x) = \text{true}] = \varepsilon_0 \big(F_p + (1 - F_p)\, \varepsilon_b\big).

Proof. Fix x∉Sx \notin S. Then x∉Nx \notin N, since N⊆SN \subseteq S. Let A0A_0 be the event that F0F_0 accepts xx (always true without an initial filter) and AbA_b the event that FbF_b accepts xx. By lines L4 to L6,

QUERY(x)=true  ⟺  A0 and (σ(x)≥τ or Ab).\text{QUERY}(x) = \text{true} \iff A_0 \text{ and } \big(\sigma(x) \ge \tau \text{ or } A_b\big).

The value σ(x)\sigma(x) is fixed. A0A_0 depends only on the hash functions of F0F_0 and AbA_b only on those of FbF_b, which are independent, with Pr⁡[A0]=ε0\Pr[A_0] = \varepsilon_0 and Pr⁡[Ab]=εb\Pr[A_b] = \varepsilon_b because xx is held by neither filter. So

Pr⁡[QUERY(x)=true]=ε0([σ(x)≥τ]+[σ(x)<τ] εb).\Pr[\text{QUERY}(x) = \text{true}] = \varepsilon_0 \big([\sigma(x) \ge \tau] + [\sigma(x) < \tau]\, \varepsilon_b\big).

Averaging over x∼Dx \sim \mathcal{D}, which is independent of the hash functions, replaces [σ(x)≥τ][\sigma(x) \ge \tau] by FpF_p and [σ(x)<τ][\sigma(x) < \tau] by 1−Fp1 - F_p. □\square

Remark (no per-key bound). For a fixed x∉Sx \notin S with σ(x)≥τ\sigma(x) \ge \tau, the proof gives Pr⁡[QUERY(x)=true]=ε0\Pr[\text{QUERY}(x) = \text{true}] = \varepsilon_0, which is 1 without an initial filter. So the filter has no per-key rate better than ε0\varepsilon_0, and the bound of Theorem 2 holds only on average over D\mathcal{D}. ■\blacksquare

Back to Learned Bloom filter