Word-RAM Implementation of the Two-Stage Quotient Filter #
This module packages the bit-packed two-stage quotient filter into a reusable
Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl certificate realizing
Cslib.DataStructure.ApproximateMembership.spec U n ε on the Word-RAM without any universe-to-table
restriction log₂ U ≤ c · log₂ n. Keys fit in half a word: every certificate assumes U ≤ 2 ^ w₀
with 0 < w₀ and 2 * w₀ ≤ w.
Architecture #
- Deterministic branch-wise transcript (
simResult,simTranscript): Because runs are maintained in canonical sorted order, on each fixed random seedp : FilterSeed w₀ nthe active slot configuration depends only on the current active setS : Finset (Fin U). Every query on seedpdeterministically returnsdecide (remHash U w₀ k p.2 u ∈ bucketRun S (quotHash U w₀ n p.1) (remHash U w₀ k p.2) _). Hence zero false negatives hold on every random branch, and the false-positive event at query indexidxis bounded by(1 / 2 : ℝ≥0∞) ^ k ≤ ε. - Expected
O(1)time per operation (charge = opStepBound 290): Evaluating the two-stage quotient hash and the independent remainder hash takes at most236841 + 45 = 236886instructions, and theMemory.Progcluster operation lowered via therealizetactic (realizes_clusterOp.code) executes in at most19 + clusterFactor * (11 * ℓ + 14)instructions for a cluster of lengthℓ. Bytsum_seedClusterBound_le(𝔼[ℓ] ≤ 290), the expected instruction count of every operation is at mostcharge = opStepBound 290. - Compact space (
space_le,implOfEps_space_le): The single contiguous memory block ofspace w w₀ n kwords stores the two-stage quotient seed, theo(n)-bit Four-Russians carryless multiplication table, the remainder seed, and the four bit-packed slot arrays (isFull,isOcc,isRunStart,remAt), totaling at most640 * ((n * k + w - 1) / w + 1)words.
Main definitions #
Cslib.DataStructure.ApproximateMembership.QuotientFilter.subroutineCode: Word-RAMSubroutineCode .exact rQF 0for the quotient filter.Cslib.DataStructure.ApproximateMembership.QuotientFilter.impl,Cslib.DataStructure.ApproximateMembership.QuotientFilter.implStandard:ObliviousSequenceImplcertificates realizingspec U n ((1 / 2 : ℝ≥0∞) ^ k).Cslib.DataStructure.ApproximateMembership.QuotientFilter.implOfEps,Cslib.DataStructure.ApproximateMembership.QuotientFilter.implOfEpsStandard:ObliviousSequenceImplcertificates realizingspec U n εfor anyε ≠ 0usingk = epsLog ε = max 1 ⌈log₂(1 / ε)⌉.
Main results #
Cslib.DataStructure.ApproximateMembership.QuotientFilter.quotBits_lt_w_of_fits_space:quotBits w₀ n < wholds automatically whenever0 < w₀,2 * w₀ ≤ w, andFits w (base + space w w₀ n k).Cslib.DataStructure.ApproximateMembership.QuotientFilter.contract_map_simTranscript:simTranscriptunderfilterSeedLaw w₀ nsatisfiesspec U n ((1 / 2 : ℝ≥0∞) ^ k).Contract ops.Cslib.DataStructure.ApproximateMembership.QuotientFilter.opCode_execWithin: single-operation deterministic execution and invariant preservation on each seedp.Cslib.DataStructure.ApproximateMembership.QuotientFilter.implOfEps_space_le: word-space bound≤ 640 * ((n * epsLog ε + w - 1) / w + 1).
References #
Whenever 0 < w₀, 2 * w₀ ≤ w, and Fits w (base + space w w₀ n k), the Four-Russians double
limb width 2 * reducedChunkBits is strictly less than w.
ReducedKWise.TableRep depends only on memory below base + ReducedKWise.space.
ReducedKWise.SeedRep depends only on memory below base + ReducedKWise.space.
Seed-coupled Word-RAM representation invariant linking seed p : FilterSeed w₀ n, active key
set S : Finset (Fin U), and machine state x : Data rQF.
Section 2: Deterministic branch-wise transcript (simResult, simTranscript) #
Deterministic branch-wise result of operation o : Op U on seed p : FilterSeed w₀ n from
active key set S : Finset (Fin U).
Deterministic branch-wise transcript produced across ops : List (Op U) on seed
p : FilterSeed w₀ n starting from active key set S : Finset (Fin U).
The transcript distribution induced by simTranscript under filterSeedLaw w₀ n satisfies
(spec U n ((1 / 2 : ℝ≥0∞) ^ k)).Contract ops.
Section 3: Initialization (allocSpan, initSetup, initSetup_exec) #
Allocate [base, base + space w w₀ n k) by setting qfReg 0 ← qfReg 240 and advancing
qfReg 240 ← qfReg 0 + space w w₀ n k in 3 instructions.
Initialize the Four-Russians carryless multiplication table, sample the two-stage quotient seed, and sample the multiply-shift remainder seed.
Exact instruction count of initSetup w w₀ n.
Combined ProbComp semantics for sampling the quotient seed and the remainder seed.
Numeric operation tag (0 = insert, 1 = delete, 2 = query).
Input-register mask (qfReg 1 = key, qfReg 247 = operation tag).
Unified Word-RAM operation body: evaluates the two-stage quotient hash into qfReg 2 and the
remainder hash into qfReg 3, then runs the realized clusterCode (clusterOpProg).
Upper bound clusterFactor * (11 * ℓ + 14) + 236909 on the instruction count of opCode when
the cluster around quot u has length ℓ.
Per-operation expected instruction charge opStepBound 290.
Section 5: Packaging as SubroutineCode and ObliviousSequenceImpl #
Relocatable Word-RAM SubroutineCode for the two-stage quotient filter over Basis.exact.
Parametric ObliviousSequenceImpl certificate for spec U n ε whenever
(1 / 2 : ℝ≥0∞) ^ k ≤ ε.
Exact-basis ObliviousSequenceImpl certificate for the two-stage quotient filter realizing
spec U n ((1 / 2 : ℝ≥0∞) ^ k).
Standard-basis ObliviousSequenceImpl certificate for spec U n ((1 / 2 : ℝ≥0∞) ^ k).
Exact-basis ObliviousSequenceImpl certificate realizing spec U n ε for any ε ≠ 0 by
choosing k = epsLog ε = max 1 ⌈log₂(1 / ε)⌉.
Standard-basis ObliviousSequenceImpl certificate realizing spec U n ε for any ε ≠ 0.
Space bound for impl without requiring quotBits w₀ n ≤ w as a separate hypothesis.
Space bound for implOfEps: at most 640 * ((n * epsLog ε + w - 1) / w + 1) words for all
1 ≤ n, 0 < w₀, 2 * w₀ ≤ w.