Memory-Program Realization of Quotient-Filter Cluster Operations #
This module implements and certifies the deterministic cluster-level operations (queryCluster,
insertCluster, deleteCluster) of the Word-RAM quotient filter as a unified Memory.Prog
program clusterOpProg, certified for width-independent compilation via the realize tactic
(realizes_clusterOp). Word-RAM register assignment and machine-code assembly live in
CslibFrontier/DataStructure/ApproximateMembership/WordRAM/QuotientFilter/Code.lean.
Main definitions #
ClusterInput,ClusterInput.words,mkClusterInput,ClusterSafe: 15-field runtime parameter record for cluster operations, its 15-word vector embedding forWordEncoding, concrete constructor, and word-width safety envelope.ScanEnv,ScanEnv.equiv,ScanState,ScanState.equiv,ScanStepCtx,ScanStepCtx.equiv,scanStepTargetProg,scanStepQueryProg: named records and step helpers for the cluster scan.clusterOpProg: unified deterministicMemory.Progcluster operation (0= insert,1= delete,2= query).SlotFrame: memory-frame relation restricting modifications to the four bit-packed slot arrays[fullBase base w w₀ n, base + space w w₀ n k).
Main results #
quotBits_lt_w_of_fits_space:quotBits w₀ n < wholds whenever0 < w₀,2 * w₀ ≤ w, andFits w (base + space w w₀ n k).clusterSafe_mkClusterInput,ClusterSafe.fits_encode:mkClusterInputsatisfiesClusterSafe, and every encoded word of aClusterSafeinput fits inwbits.realizes_scanStepQuery,validHistory_scanStepQuery,memoryCost_scanStepQuery: width-independent realization, memory admissibility, and zero memory cost forscanStepQueryProg.realizes_clusterOp,validHistory_clusterOp_mk,memoryCost_clusterOp_mk_le: width-independentRealizes .exactcertificate, memory admissibility, and11 * ℓ + 13memory-operation bound forclusterOpProg.clusterOpProg_mk_insert,clusterOpProg_mk_delete,clusterOpProg_mk_query: pureFilterStaterefinement andSlotFramespecifications couplingclusterOpProgtoFilterInv.insertState,FilterInv.deleteState, andbucketRunmembership.
Section 1: Cluster operation input record (ClusterInput) #
The 15-word runtime input record passed to the quotient-filter cluster program clusterOpProg.
The fields appear in register order 0..14 matching ClusterInput.words.
- qVal : ℕ
Target quotient slot
q.val. - rVal : ℕ
Target remainder
r.val. - opTag : ℕ
Operation tag (
0= insert,1= delete,2= query). - slotCap : ℕ
Slot capacity
2 ^ b(b = quotBits w₀ n). - slotMask : ℕ
Cyclic slot bitmask
2 ^ b - 1. - fullBase : ℕ
Base word address of the
isFullbitmap. - occBase : ℕ
Base word address of the
isOccbitmap. - runBase : ℕ
Base word address of the
isRunStartbitmap. - remBase : ℕ
Base word address of the
remAtpacked array. - pBit : ℕ
Log₂ packing factor
slotPackShift b 1 wfor1-bit bitmaps. - pBitMask : ℕ
Intra-word bit-index mask
2 ^ pBit - 1for1-bit bitmaps. - pRem : ℕ
- pRemMask : ℕ
- f : ℕ
Remainder bit-width
remBits w₀ k. - fMask : ℕ
Remainder value mask
2 ^ f - 1.
Instances For
Faithful 15-word vector encoding of a ClusterInput in declaration order 0..14.
Construct the ClusterInput parameter record for (base, w, w₀, n, k) and (q, r, opTag).
Word-level safety envelope for ClusterInput at word width w.
Whenever 0 < w₀, 2 * w₀ ≤ w, and Fits w (base + space w w₀ n k), the quotient bit-width
quotBits w₀ n is strictly less than w.
Every mkClusterInput record satisfies ClusterSafe w once 0 < w₀, 2 * w₀ ≤ w,
Fits w (base + space w w₀ n k), and opTag < 4.
Every encoded word of a ClusterSafe w input record fits in w bits.
Section 2: Bit-packed accessor programs #
Section 3: Backward and forward cluster-extent discovery (findClusterProg) #
Section 4: Prefix occBefore and full cluster scan (scanClusterProg) #
Loop state of the cluster scan after i slots. The words are listed in the order
((i, (runs, occI)), ((s₀, s), (e, qFound))).
- i : ℕ
Slots scanned so far.
- runs : ℕ
Run starts among the scanned slots.
- occI : ℕ
Occupied quotients among the scanned slots.
- s₀ : ℕ
Start of the target run,
calcRunStart. - s : ℕ
Insertion target slot,
calcTargetSlot. - e : ℕ
End of the shift for a delete,
calcDeleteStop. - qFound : ℕ
Whether the target remainder was found (
0or1),queryAnyPrefix.
Instances For
Input of the target, stop and query updates in one step of scanLoopProg: the environment,
the state before the step, the run count including the current slot, and the current slot's
remainder. The words are listed in the order ((env, st), (runs, rem)).
- env : ScanEnv
Scan environment.
- st : ScanState
State before the step.
- runs : ℕ
Run starts up to and including the current slot.
- rem : ℕ
Remainder stored at the current slot.
Instances For
The word layout of a ScanStepCtx.
Update (s₀, s) during one step of scanLoopProg.
Update qFound (queryAnyPrefix) during one step of scanLoopProg.
Section 5: Right-Shift Loop and insertAfterScanProg #
Section 6: Left-Shift Loop and deleteAfterScanProg #
Section 7: Unified Cluster Operation clusterOpProg #
Unified deterministic cluster operation (0 = insert, 1 = delete, 2 = query).
Section 8A: Memory Admissibility (ValidHistory) and memoryCost Bound #
Section 8B: Semantic Correctness of clusterOpProg on mkClusterInput #
SlotFrame base w w₀ n k s₁ s₂ states that s₂ preserves s₁.frontier and modifies mem
only within the four packed slot arrays [fullBase base w w₀ n, base + space w w₀ n k).
Memory admissibility (ValidHistory) of clusterOpProg on mkClusterInput.
On any FilterInv-valid state, clusterOpProg performs at most 11 * ℓ + 13 memory
operations on a cluster of length ℓ = hinv.clusterLen hS_lt q.