Probabilistic Analysis of the Two-Stage Quotient Filter #
This file establishes the probabilistic guarantees of the canonical quotient filter when instantiated with:
- a two-stage $5$-wise independent reduced polynomial hash
quotHash U w₀ nmapping keys inFin U(U ≤ 2 ^ w₀) tob = tableLog (min n (2 ^ w₀))-bit quotients (2 ^ b ≥ 8 * n_eff, wheren_eff = min n (2 ^ w₀)), and - an independent multiply-shift hash
remHash U w₀ kmapping keys inFin UtoremBits w₀ k = min w₀ (k + 1)-bit remainders.
Main results #
Cslib.DataStructure.ApproximateMembership.QuotientFilter.card_quotHash_eq_le: pairwise collision bound for the two-stage quotient hash (≤ 2 / 2 ^ b).Cslib.DataStructure.ApproximateMembership.QuotientFilter.toOuterMeasure_falsePositive_le: for any setS : Finset (Fin U)with#S ≤ nand any absent keyu ∉ S, the false-positive probability underfilterSeedLaw w₀ nis at most(1 / 2 : ℝ≥0∞) ^ k.Cslib.DataStructure.ApproximateMembership.QuotientFilter.sum_clusterLen_le,Cslib.DataStructure.ApproximateMembership.QuotientFilter.tsum_clusterLen_le: for any setS : Finset (Fin U)with#S ≤ nand any keyu : Fin U, the expected cluster length aroundquotHash θ uis at most290(289on injective top-level seeds plus at most1from the non-injective top-level event of probability≤ (n_eff + 1) * n_eff / 2 ^ (3 * b)).
References #
- A. Pagh, R. Pagh and S. S. Rao, An optimal Bloom filter replacement
- M. A. Bender, M. Farach-Colton, R. Johnson, R. Kraner, B. C. Kuszmaul, D. Medjedovic, P. Montes, P. Shetty, R. P. Spillane and E. Zadok, Don't thrash: how to cache your hash on flash
- A. Pagh, R. Pagh and M. Ružić, Linear Probing with Constant Independence
Section 1: Two-stage quotient and remainder hash parameters #
Quotient bit-width b = tableLog (effCap w₀ n) = ⌈log₂ max(8 · effCap w₀ n, 8)⌉.
Remainder bit-width f = min w₀ (k + 1).
Seed type for the two-stage $5$-wise independent quotient hash.
Seed type for the independent multiply-shift remainder hash.
Uniform distribution over FilterSeed w₀ n.
Section 2: Pairwise collision and false-positive probability bounds #
For any distinct x, y : Fin U (0 < w₀, U ≤ 2 ^ w₀), the number of remainder seeds
γ : RemSeed w₀ on which remHash U w₀ k γ x = remHash U w₀ k γ y satisfies
#{γ | remHash U w₀ k γ x = remHash U w₀ k γ y} * 2 ^ k ≤ Fintype.card (RemSeed w₀).
For any distinct x, y : Fin U (0 < w₀, U ≤ 2 ^ w₀), the number of quotient seeds
θ : QuotSeed w₀ n on which quotHash U w₀ n θ x = quotHash U w₀ n θ y satisfies
#{θ | quotHash U w₀ n θ x = quotHash U w₀ n θ y} * 2 ^ quotBits w₀ n ≤ 2 * Fintype.card (QuotSeed w₀ n).
Counting false-positive bound over FilterSeed w₀ n: for any S : Finset (Fin U) with
#S ≤ n and any u ∉ S (0 < w₀, U ≤ 2 ^ w₀), the number of seeds p : FilterSeed w₀ n for
which ∃ x ∈ S, quotHash U w₀ n p.1 x = quotHash U w₀ n p.1 u ∧ remHash U w₀ k p.2 x = remHash U w₀ k p.2 u satisfies
#{p | ...} * 2 ^ k ≤ Fintype.card (FilterSeed w₀ n).
Per-query false-positive probability bound: for any S : Finset (Fin U) with #S ≤ n and
any absent key u ∉ S (0 < w₀, U ≤ 2 ^ w₀), the probability under filterSeedLaw w₀ n that
u collides in both quotient and remainder with some key in S is at most (1 / 2 : ℝ≥0∞) ^ k.
Minimum exponent k = max 1 ⌈log₂(1 / ε)⌉ such that (1 / 2 : ℝ≥0∞) ^ k ≤ ε for any
ε : ℝ≥0∞ with ε ≠ 0.
Section 3: Expected cluster length bound across the two-stage seed distribution #
Pointwise bound of hinv.clusterLen hS_lt (quotHash U w₀ n θ u) by the state-independent
quantity seedClusterBound U w₀ n S u θ.
For any top-level seed α ∈ reducedGoodTop U w₀ (3 * quotBits w₀ n) (insert u (S.erase u))
that is injective on insert u (S.erase u), summing seedClusterBound - 1 over all bottom
polynomial seeds β : ReducedBotSeed w₀ (quotBits w₀ n) (quotBits w₀ n) 5 is bounded by
288 * Fintype.card Bot.
Unconditional sum bound on seedClusterBound over QuotSeed w₀ n:
for any S : Finset (Fin U) with #S ≤ n and any u : Fin U (0 < w₀, U ≤ 2 ^ w₀),
the sum of seedClusterBound over all quotient seeds θ : QuotSeed w₀ n is at most
290 * Fintype.card (QuotSeed w₀ n).
ℝ≥0∞ expectation bound on seedClusterBound under filterSeedLaw w₀ n:
∑' p : FilterSeed w₀ n, filterSeedLaw w₀ n p * (seedClusterBound U w₀ n S u p.1 : ℝ≥0∞) ≤ 290.
Unconditional sum bound on clusterLen over QuotSeed w₀ n:
for any S : Finset (Fin U) with #S ≤ n and any u : Fin U (0 < w₀, U ≤ 2 ^ w₀),
the sum of clusterLen over all quotient seeds θ : QuotSeed w₀ n is at most
290 * Fintype.card (QuotSeed w₀ n).
ℝ≥0∞ expectation bound on clusterLen under filterSeedLaw w₀ n:
∑' p : FilterSeed w₀ n, filterSeedLaw w₀ n p * (clusterLen p.1 : ℝ≥0∞) ≤ 290.