Documentation

CslibFrontier.DataStructure.ApproximateMembership.WordRAM.QuotientFilter.Code

Word-RAM Register Layout and Lowered Cluster Code for the Quotient Filter #

This module defines the register layout (rQF, qfReg, kwiseMap), multiply-shift remainder seed sampling and evaluation (remInitCode, remEvalCode), and the lowered Word-RAM cluster subroutine (clusterCode) assembled from realizes_clusterOp for the two-stage quotient filter.

Main definitions #

Main results #

Register count for the Word-RAM quotient filter: 0..239 shared with ReducedKWise, 240..247 dedicated to SubroutineCode control and operation tags, and 248 .. 248 + realizes_clusterOp.scratchSize dedicated to the realized Memory.Prog scratch registers.

Canonical embedding Fin 248 → Fin rQF for fixed control and hash registers.

Embedding Fin 240 → Fin rQF for ReducedKWise subroutines.

Sample the remainder seed γ : RemSeed w₀ uniformly and store it at remSeedAddr base w w₀ n using 5 instructions (1 rand call).

Closed-form machine state after remInitCode w w₀ n samples γ.

Exact ProbComp semantics of remInitCode w w₀ n.

theorem Cslib.DataStructure.ApproximateMembership.QuotientFilter.remInitCode_execRand {base w w₀ n k : ℕ} (hw₀ : w₀ ≤ w) (hfit_space : WordRAM.Fits w (base + space w w₀ n k)) {x : WordRAM.Data rQF} (h0 : x.regs (qfReg 0) = base) :
WordRAM.ExecRand w (remInitCode w w₀ n) x (remInitComp base w w₀ n x)

Word-RAM snippet computing (remHash U w₀ k γ u).val into register qfReg 3 from qfReg 0 = base and qfReg 1 = u.val, using ReducedKWise.reduceKeyCode w₀ w₀ in 45 deterministic instructions.

theorem Cslib.DataStructure.ApproximateMembership.QuotientFilter.remEvalCode_exec {base w U w₀ n k : ℕ} (hw₀_pos : 0 < w₀) (hw₀ : w₀ ≤ w) (hU : U ≤ 2 ^ w₀) (hfit_space : WordRAM.Fits w (base + space w w₀ n k)) (γ : RemSeed w₀) (u : Fin U) {x : WordRAM.Data rQF} (h0 : x.regs (qfReg 0) = base) (h1 : x.regs (qfReg 1) = ↑u) (hseed : x.mem (remSeedAddr base w w₀ n) = ↑γ) :
∃ (y : WordRAM.Data rQF), WordRAM.Exec w (remEvalCode w w₀ n k) x y 45 ∧ y.mem = x.mem ∧ y.regs (qfReg 0) = base ∧ y.regs (qfReg 3) = ↑(remHash U w₀ k γ u) ∧ ∀ (j : Fin rQF), 240 ≤ ↑j → y.regs j = x.regs j

Combined Word-RAM code loading mkClusterInput into registers qfReg 10 .. qfReg 24 and running the realized clusterOpProg code with frontier qfReg 240 and output in qfReg 1.

Exchange factor of the realized cluster Memory.Prog program.

theorem Cslib.DataStructure.ApproximateMembership.QuotientFilter.clusterCode_execWithin {U base w w₀ n k : ℕ} (hw₀_pos : 0 < w₀) (hw : 2 * w₀ ≤ w) (hfit_space : WordRAM.Fits w (base + space w w₀ n k)) {S : Finset (Fin U)} {quot : Fin U → Fin (2 ^ quotBits w₀ n)} {rem : Fin U → Fin (2 ^ remBits w₀ k)} (u : Fin U) {opTag : ℕ} (hop : opTag < 4) {x : WordRAM.Data rQF} (hx : WordRAM.Data.Bounded w x) (h0 : x.regs (qfReg 0) = base) (hfr : x.regs (qfReg 240) = base + space w w₀ n k) (h2 : x.regs (qfReg 2) = ↑(quot u)) (h3 : x.regs (qfReg 3) = ↑(rem u)) (h247 : x.regs (qfReg 247) = opTag) (hinv : FilterInv n S quot rem (extractFilterState base w w₀ n k x.mem)) (hS_lt : S.card < 2 ^ quotBits w₀ n) :
have d := mkClusterInput base w w₀ n k (quot u) (rem u) opTag; have s₀ := { mem := x.mem, frontier := base + space w w₀ n k }; ∃ (y : WordRAM.Data rQF), WordRAM.ExecWithin w (clusterCode w w₀ n k) x y (19 + clusterFactor * (11 * hinv.clusterLen hS_lt (quot u) + 14)) ∧ WordRAM.Data.Bounded w y ∧ y.regs (qfReg 0) = base ∧ y.regs (qfReg 240) = ((Memory.spec 0).clientState s₀ (clusterOpProg d)).frontier ∧ y.regs (qfReg 1) = (Memory.spec 0).clientResult s₀ (clusterOpProg d) ∧ y.mem = ((Memory.spec 0).clientState s₀ (clusterOpProg d)).mem