Canonical Quotient Filter Model and Cluster Invariants #
This file develops the pure combinatorial model of a canonical quotient filter
(Pagh, Pagh and Rao; Bender et al.) over a table of 2 ^ b
slots storing f-bit remainders Fin (2 ^ f) with three metadata bits per slot (isFull,
isOcc, isRunStart).
Design #
Canonical bucket runs (
bucketRun,taggedRun): For a finite setS : Finset (Fin U)of currently present keys, quotient mapquot : Fin U → Fin (2 ^ b), and remainder maprem : Fin U → Fin (2 ^ f), each bucketq : Fin (2 ^ b)has a canonical sorted remainder listbucketRun S quot rem q : List (Fin (2 ^ f))obtained by sorting the multiset of remainders of keys inSwith quotientq. Tagging the head of a non-empty bucket run withtrue(isRunStart = true) and continuation elements withfalse(taggedRun) makes run boundaries uniquely recoverable from the concatenated slot stream.Maximal full clusters and
IntervalValid(FilterInv): Every maximal contiguous full interval[o .. o + ℓ)(preceded by an empty slot atbackSlot b o 1and followed by an empty slot atprobeSlot b o ℓ) holds the exact concatenation(List.range ℓ).flatMap (fun j => taggedRun (bucketRun S quot rem (probeSlot b o j))), with every prefixm < ℓsatisfyingm + 1 ≤ ∑ j ≤ m, |bucketRun ... (probeSlot b o j)|. Consequently:- When
#S < 2 ^ b, slot occupancy and slot contents depend only on the current key setSand hash pair(quot, rem)(history-independent canonical runs). - The number of keys of
Swhose quotient falls into a maximal full clustercyclicInterval b (quot u) a ℓequalsℓ(card_filter_quot_mem_cyclicInterval_eq), transferring the $5$-wise independent dyadic scale-overload bound directly to quotient-filter clusters (clusterLen_sub_one_le_sum_scaleOverload). - Run boundaries inside any cluster
[o .. o + ℓ)are characterized by the monotone counting equivalencei < runOffset S quot rem o m ↔ runsBefore st o (i + 1) ≤ occBefore st o m(lt_runOffset_iff).
- When
Main definitions #
Cslib.DataStructure.ApproximateMembership.QuotientFilter.bucketRun,Cslib.DataStructure.ApproximateMembership.QuotientFilter.taggedRun: canonical sorted bucket runs and run-start tagged runs.Cslib.DataStructure.ApproximateMembership.QuotientFilter.FilterState,Cslib.DataStructure.ApproximateMembership.QuotientFilter.IntervalValid,Cslib.DataStructure.ApproximateMembership.QuotientFilter.FilterInv: pure slot-table state and canonical cluster invariant.FilterInv.backLen,FilterInv.fwdLen,FilterInv.clusterLen: backward, forward, and total full-cluster lengths around a bucket.FilterInv.querySlot: pure membership query on a canonical quotient filter.
Main results #
IntervalValid.lt_runOffset_iff: exact run-offset characterization via prefix counts ofisRunStartandisOcc.FilterInv.card_filter_quot_mem_cyclicInterval_eq: a maximal full cluster of lengthℓaroundqcontains the quotients ofℓkeys ofS.FilterInv.clusterLen_sub_one_le_sum_scaleOverload: pointwise bound ofclusterLen st (quot u) - 1by the dyadic scale-overload sum forS.erase u.FilterInv.querySlot_eq_true_iff: exact fingerprint-collision characterization ofquerySlot.
References #
Section 1: Canonical sorted bucket runs and tagged runs #
Section 2: Pure filter state and cluster invariants #
Pure slot-level state of a quotient filter with 2 ^ b slots and f-bit remainders.
Whether slot
scurrently holds an element.Whether bucket
qcurrently has a non-empty run.Whether slot
sis the first slot of a bucket's run.Remainder stored at slot
s(0whenisFull s = false).
Empty quotient-filter state (all metadata bits false and all remainders 0).
Section 3: Run offsets, prefix counts, and IntervalValid #
Starting slot offset (relative to cluster start o) of bucket probeSlot b o m's run:
the sum of |bucketRun S quot rem (probeSlot b o j)| over j < m.
Number of occupied buckets (isOcc = true) in [0, m) relative to o.
Number of run-start slots (isRunStart = true) in [0, i) relative to o.
Canonical run decomposition invariant on a full interval [o .. o + ℓ):
- Every slot in
[o .. o + ℓ)is full (isFull = true). - Every prefix
m < ℓhasm + 1 ≤ runOffset S quot rem o (m + 1)(the queue never empties inside[o .. o + ℓ)). - The
ℓslots[o .. o + ℓ)store the exact concatenation oftaggedRuns for buckets[o .. o + ℓ).
Every slot in
[o .. o + ℓ)is full.Every proper prefix has at least
m + 1elements from buckets[0 .. m].- slots_eq_flatMap : List.map (fun (i : ℕ) => (st.isRunStart (Dictionary.WordRAM.LinearProbing.probeSlot b o i), st.remAt (Dictionary.WordRAM.LinearProbing.probeSlot b o i))) (List.range ℓ) = List.flatMap (fun (j : ℕ) => taggedRun (bucketRun S quot rem (Dictionary.WordRAM.LinearProbing.probeSlot b o j))) (List.range ℓ)
The slot stream
(isRunStart, remAt)on[o .. o + ℓ)equals the concatenatedtaggedRuns.
Split List.range n around an index a < n: the indices below a, then a, then the
indices above it.
The first element of any non-empty concatenation of taggedRuns has isRunStart tag true.
Master run-offset threshold theorem: in any valid interval [o .. o + ℓ), for every
bucket index m ≤ ℓ and slot index i < ℓ, slot i lies strictly before bucket m's run start
runOffset S quot rem o m if and only if runsBefore st o (i + 1) ≤ occBefore st o m.
In any valid interval [o .. o + ℓ), for every m ≤ ℓ we have
m ≤ runOffset S quot rem o m.
In any valid interval [o .. o + ℓ), runsBefore st o m ≤ occBefore st o m holds at every
step m ≤ ℓ (so occBefore st o m - runsBefore st o m never underflows).
Exact characterization of when runOffset S quot rem o m = m in [o .. o + ℓ):
runOffset S quot rem o m = m ↔ (m = ℓ ∨ occBefore st o m < runsBefore st o (m + 1)).
Section 4: Global filter invariant, cluster bounds, and scale-overload witness #
Canonical quotient-filter invariant coupling key set S : Finset (Fin U), quotient hash
quot : Fin U → Fin (2 ^ b), and remainder hash rem : Fin U → Fin (2 ^ f) with slot state
st : FilterState b f:
#S ≤ n;st.isOcc q = !(bucketRun S quot rem q).isEmptyfor allq;- every empty slot (
st.isFull q = false) hasst.isOcc q = false,st.isRunStart q = false, andst.remAt q = 0; - the number of full slots in
Fin (2 ^ b)equals#S; - every maximal contiguous full interval
[o .. o + ℓ)satisfiesIntervalValid.
Current key set has size at most
n.isOcc qrecords whether bucketq's run is non-empty.- empty_slot (q : Fin (2 ^ b)) : st.isFull q = false → st.isOcc q = false ∧ st.isRunStart q = false ∧ st.remAt q = ⟨0, ⋯⟩
Empty slots have cleared metadata and zero remainder.
Total number of full slots equals
#S.- maximal_intervalValid (o : Fin (2 ^ b)) (ℓ : ℕ) : ℓ ≤ S.card → st.isFull (Dictionary.WordRAM.LinearProbing.backSlot b o 1) = false → st.isFull (Dictionary.WordRAM.LinearProbing.probeSlot b o ℓ) = false → (∀ i < ℓ, st.isFull (Dictionary.WordRAM.LinearProbing.probeSlot b o i) = true) → IntervalValid S quot rem st o ℓ
Every maximal full interval satisfies
IntervalValid.
Any finset of full slots has cardinality at most #S.
Under FilterInv with #S < 2 ^ b, walking backwards from any q reaches an empty slot
within #S + 1 steps.
Number of full slots immediately preceding q in cyclic order.
Start slot o = backSlot b q (backLen q) of the full cluster around q.
Under FilterInv with #S < 2 ^ b, walking forward from q reaches an empty slot within
#S - backLen q steps.
Number of full slots starting at q in cyclic forward order.
Total length ℓ = backLen q + fwdLen q of the maximal full cluster around q.
The maximal full cluster [clusterStart q .. clusterStart q + clusterLen q) around any bucket
q satisfies IntervalValid.
Exact cluster occupancy identity: the number of keys in S whose quotient lies in the
maximal full cluster cyclicInterval b q (backLen q) (clusterLen q) around q equals
clusterLen q.
Under FilterInv, the bucket of an empty slot has no run.
A home slot whose forward cluster length is zero is unoccupied, so its bucket run is empty.
The home slot of a stored key starts a nonempty forward full run.
Pointwise dyadic scale-overload bound for quotient-filter clusters: for any hash family
h : Θ → Fin U₀ → Fin (2 ^ b₀), seed i : Θ, and key u : Fin U₀, the cluster length minus one
(hinv.clusterLen hS_lt (h i u) - 1 : ℝ) is bounded by the dyadic scale-overload sum for
S.erase u around h i u.
Section 5: Pure membership query and fingerprint-collision characterization #
Prefix scan over m < i checking whether any slot in bucket a's run
(occBefore st o a < runsBefore st o (m + 1) ≤ occBefore st o (a + 1)) stores remainder r.
Pure membership query on st : FilterState b f for quotient q and remainder r in a cluster
starting at o with offset a (q = probeSlot b o a) and length ℓ:
checks st.isOcc q = true and queryAnyPrefix st o a ℓ r.
In any valid interval [o .. o + ℓ) with a < ℓ, queryCluster st o a ℓ r = true if and only
if r ∈ bucketRun S quot rem (probeSlot b o a).
Pure membership query on st : FilterState b f under hinv : FilterInv n S quot rem st.
Exact fingerprint-collision characterization of querySlot:
hinv.querySlot hS_lt u = true ↔ ∃ x ∈ S, quot x = quot u ∧ rem x = rem u.
Pathwise zero false negatives: if u ∈ S, hinv.querySlot hS_lt u = true.