Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpLayout

Memory Layout, Runtime Parameter Block, and Representation Invariants for SuccinctWhp #

This module defines the concrete Word-RAM word layout within [base, base + whpSpace c U V w n_max), the 68-word runtime parameter vector WhpCoreParams (paired with the two HashParams vectors into the 100-word WhpParams input record), and the concrete memory representation invariants (SmallMemRep, CsrMemRep, BTreeSliceMemRep, BufTrieMemRep, FastMemRep, SeedWhpMemRep, and WhpMemRep) linking Word-RAM memory x.mem to the pure state machine WhpDictState of SuccinctWhpModel.

Main definitions #

Main results #

Section 1: Header slots and segment word offsets #

Header slot 0: active regime tag (0 = .small, 1 = .fast, 2 = .fallback).

Small-regime occupancy array offset (base + 32).

Small-regime packed keys array offset.

Small-regime packed values array offset.

Word count of θ.1 : BktSeed c U n_max (BitPackedDoubleTabulation.space).

Word count of θ.2 : FpSeed c U n_max (BitPackedDoubleTabulation.space).

Large-regime bucket-hash block offset (base + 32).

Large-regime fingerprint-hash block offset.

Large-regime Feistel quotients array offset (n_max entries of quotBitsWhp U n_max bits).

Large-regime values array offset (n_max entries of valBits V bits).

Start of the 13 auxiliary packed arrays in largeAuxWordsWhp.

2-bit per-coordinate location tag array (M * totalLocalCoordsWhp n_max entries).

Per-bucket scalar metadata and slice (alloc, root) array (16 * M entries of globalPtrBits n_max bits).

CSR bucket prefix-sum array fbStart (M + 1 entries of globalPtrBits n_max bits).

Backyard pointer directory backPtr (M * capBackWhp n_max entries of globalPtrBits n_max bits).

Auxiliary backyard scratch array (M * capBackWhp n_max entries of 12 * logLogFactor + 4 bits).

Backyard free-slot stack poolFreeStack (poolSizeWhp n_max entries of globalPtrBits n_max bits).

Backyard reverse owner array poolOwner (poolSizeWhp n_max entries of globalPtrBits n_max bits).

SWAR B+-tree node metadata array (totalBTreeNodesWhp n_max entries of nodeMetaBitsWhp n_max bits).

SWAR B+-tree node keys-word array (totalBTreeNodesWhp n_max entries of keysWordBitsWhp n_max bits).

SWAR B+-tree node vals-word array (totalBTreeNodesWhp n_max entries of valsWordBitsWhp n_max bits).

Total child-pointer entries maxTrieNodesWhp c n_max * 2 ^ bCharWhp n_max per buffer trie.

Epoch buffer 0 trieChild array (trieChildEntriesWhp c n_max entries of globalPtrBits n_max bits).

Epoch buffer 1 trieChild array.

Epoch buffer 0 per-node metadata array (6 * maxTrieNodesWhp c n_max entries of globalPtrBits n_max bits; 4 * u + 0..3 store nodeParent, nodeChar, nodeLeafItem, nodeActive).

Epoch buffer 1 per-node metadata array.

Epoch buffer 0 item log (0 .. 3 * qEpoch - 1) + dirtyBuckets (3 * qEpoch .. 4 * qEpoch - 1) array (6 * qEpochWhp n_max + 6 entries of globalPtrBits n_max bits).

Epoch buffer 1 item log array (6 * qEpochWhp n_max + 6 entries of globalPtrBits n_max bits).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.largeOffsetChain (c U V w n_max : ℕ) :
offHashBkt = 32 ∧ 0 < bktHashWords c w n_max ∧ bktHashWords c w n_max = HashFamily.WordRAM.BitPackedDoubleTabulation.space w (SuccinctWhp.cTabWhp c) (SuccinctWhp.dTabWhp c) (SuccinctWhp.bCharWhp n_max) (SuccinctWhp.bWhp n_max) ∧ fpHashWords c w n_max = HashFamily.WordRAM.BitPackedDoubleTabulation.space w (SuccinctWhp.cTabWhp c) (SuccinctWhp.dTabWhp c) (SuccinctWhp.bCharWhp n_max) (SuccinctWhp.fpBitsWhp n_max) ∧ offHashFp c w n_max = offHashBkt + bktHashWords c w n_max ∧ offQuotWhp c w n_max = offHashFp c w n_max + fpHashWords c w n_max ∧ offValWhp c U w n_max = offQuotWhp c w n_max + BitPackedArray.packedWords n_max (SuccinctWhp.quotBitsWhp U n_max) w ∧ offPermAct c U V w n_max = offValWhp c U w n_max + BitPackedArray.packedWords n_max (FeistelQuotient.valBits V) w ∧ offLocState c U V w n_max = offPermAct c U V w n_max + BitPackedArray.packedWords n_max (12 * Dynamic.logLogFactor n_max + 4) w ∧ offBktMeta c U V w n_max = offLocState c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.numBucketsWhp n_max * SuccinctWhp.totalLocalCoordsWhp n_max) 2 w ∧ offFbStart c U V w n_max = offBktMeta c U V w n_max + BitPackedArray.packedWords (16 * SuccinctWhp.numBucketsWhp n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offBackPtr c U V w n_max = offFbStart c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.numBucketsWhp n_max + 1) (SuccinctBucket.globalPtrBits n_max) w ∧ offBackAux c U V w n_max = offBackPtr c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.numBucketsWhp n_max * SuccinctWhp.capBackWhp n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offPoolFreeStack c U V w n_max = offBackAux c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.numBucketsWhp n_max * SuccinctWhp.capBackWhp n_max) (12 * Dynamic.logLogFactor n_max + 4) w ∧ offPoolOwner c U V w n_max = offPoolFreeStack c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.poolSizeWhp n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offBtMeta c U V w n_max = offPoolOwner c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.poolSizeWhp n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offBtKeys c U V w n_max = offBtMeta c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.totalBTreeNodesWhp n_max) (SuccinctWhp.nodeMetaBitsWhp n_max) w ∧ offBtVals c U V w n_max = offBtKeys c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.totalBTreeNodesWhp n_max) (SuccinctWhp.keysWordBitsWhp n_max) w ∧ offTrieChild0 c U V w n_max = offBtVals c U V w n_max + BitPackedArray.packedWords (SuccinctWhp.totalBTreeNodesWhp n_max) (SuccinctWhp.valsWordBitsWhp n_max) w ∧ offTrieChild1 c U V w n_max = offTrieChild0 c U V w n_max + BitPackedArray.packedWords (trieChildEntriesWhp c n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offTrieMeta0 c U V w n_max = offTrieChild1 c U V w n_max + BitPackedArray.packedWords (trieChildEntriesWhp c n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offTrieMeta1 c U V w n_max = offTrieMeta0 c U V w n_max + BitPackedArray.packedWords (6 * SuccinctWhp.maxTrieNodesWhp c n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offTrieItems0 c U V w n_max = offTrieMeta1 c U V w n_max + BitPackedArray.packedWords (6 * SuccinctWhp.maxTrieNodesWhp c n_max) (SuccinctBucket.globalPtrBits n_max) w ∧ offTrieItems1 c U V w n_max = offTrieItems0 c U V w n_max + BitPackedArray.packedWords (6 * SuccinctWhp.qEpochWhp n_max + 6) (SuccinctBucket.globalPtrBits n_max) w ∧ offTrieItems1 c U V w n_max + BitPackedArray.packedWords (6 * SuccinctWhp.qEpochWhp n_max + 6) (SuccinctBucket.globalPtrBits n_max) w = SuccinctWhp.largeSpaceWhp c U V w n_max

Complete adjacent segment-offset chain for largeSpaceWhp, allowing omega to discharge cross-segment disjointness and footprint bounds without unfolding the individual off* definitions.

Section 2: Threshold, bit-width, and word-fit inequalities #

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.log_n_max_lt_w {c U w n_max : ℕ} (hth : SuccinctWhp.whpThreshold c ≤ n_max) (hnU : n_max ≤ U) (hU : WordRAM.Fits w U) :
Nat.log 2 n_max < w

Convolution width (4 * tMinWhp n_max) * keyLaneBitsWhp n_max fits strictly inside Nat.log 2 n_max whenever whpThreshold c ≤ n_max.

Section 4: Concrete memory representation invariants (WhpMemRep) #

Memory representation of SmallDictState at base (mem[base] = 0).

Memory representation of CsrState at base (mem[base] = 2).

Memory representation of a single SWAR B+-tree slice sIdx = 3 * b + role < 3 * M on its allocated prefix 0 .. sl.alloc - 1.

Memory representation of epoch buffer trie ep ∈ {0, 1}.

Memory representation of FastState at base (mem[base] = 1).

Memory representation of the two static double-tabulation seeds (θ.1, θ.2) in the large regime.

Combined memory representation linking θ and st : WhpDictState to mem across all capacities n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.SeedWhpMemRep.congr_hash {base c U w n_max : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {mem₁ mem₂ : ℕ → ℕ} (hw : 0 < w) (heq : ∀ (a : ℕ), base + offHashBkt ≤ a → a < base + offQuotWhp c w n_max → mem₁ a = mem₂ a) (hseed : SeedWhpMemRep base c U w n_max θ mem₁) :
SeedWhpMemRep base c U w n_max θ mem₂

SeedWhpMemRep depends only on [base + offHashBkt, base + offQuotWhp c w n_max).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.WhpMemRep.congr_footprint {base c U V w n_max : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {st : SuccinctWhp.WhpDictState} {mem₁ mem₂ : ℕ → ℕ} (hw : 0 < w) (heq : ∀ a ∈ { base := base, length := SuccinctWhp.whpSpace c U V w n_max }.footprint, mem₂ a = mem₁ a) (hrep : WhpMemRep base c U V w n_max θ st mem₁) :
WhpMemRep base c U V w n_max θ st mem₂

Pure footprint invariance of WhpMemRep: depends only on memory words in [base, base + whpSpace c U V w n_max).

Section 5: Precomputed runtime parameter block WhpParams (68 + 16 + 16 = 100 words) #

Core 68-word runtime parameter vector for SuccinctWhp Memory.Prog subroutines.

Instances For
    @[reducible, inline]

    Combined 100-word runtime parameter bundle (coreParams, (bktHashParams, fpHashParams)).

    Construct WhpCoreParams for (c, U, V, w, n_max). When n_max < whpThreshold c, all large-regime entries (10 .. 67) are 0 so every entry fits in w bits for all w > 0.

    Construct the full 100-word WhpParams bundle for (c, U, V, w, n_max).

    Named projections on WhpCoreParams #

    Small-regime flag (1 if n_max < whpThreshold c, 0 otherwise) in WhpCoreParams.

    Feistel quotient bit-width quotBitsWhp U n_max in WhpCoreParams.

    Bucket fingerprint bit-width fpBitsWhp n_max in WhpCoreParams.

    Double-tabulation character bit-width bCharWhp n_max in WhpCoreParams.

    Per-bucket front-yard capacity capFrontWhp n_max in WhpCoreParams.

    Per-bucket backyard capacity capBackWhp n_max in WhpCoreParams.

    Total per-bucket local coordinate count totalLocalCoordsWhp n_max in WhpCoreParams.

    Total front-yard slot count numBucketsWhp n_max * capFrontWhp n_max in WhpCoreParams.

    Overmars local rebuild threshold 5 * (slabScale n_max) ^ 12 in WhpCoreParams.

    Global slot pointer bit-width globalPtrBits n_max in WhpCoreParams.

    In-place permutation activity bit-width permActBits n_max in WhpCoreParams.

    Per-trie maximum node count maxTrieNodesWhp c n_max in WhpCoreParams.

    Minimum SWAR B+-tree branching parameter tMinWhp n_max in WhpCoreParams.

    SWAR B+-tree node lane capacity 2 * tMinWhp n_max in WhpCoreParams.

    SWAR key lane bit-width keyLaneBitsWhp n_max in WhpCoreParams.

    SWAR key lane bitmask 2 ^ keyLaneBitsWhp n_max - 1 in WhpCoreParams.

    Packed SWAR all-ones pattern over 2 * tMinWhp n_max key lanes in WhpCoreParams.

    Packed B+-tree value-word bit-width valsWordBitsWhp n_max in WhpCoreParams.

    Packed B+-tree key-word bit-width keysWordBitsWhp n_max in WhpCoreParams.

    SWAR value lane bit-width valLaneBitsWhp n_max in WhpCoreParams.

    SWAR value lane bitmask 2 ^ valLaneBitsWhp n_max - 1 in WhpCoreParams.

    B+-tree node metadata bit-width nodeMetaBitsWhp n_max in WhpCoreParams.

    Per-slice B+-tree node budget nodesPerSliceWhp n_max in WhpCoreParams.

    theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.ltMask_mul_swarOnes_lt_two_pow {fpBits capLanes m q keysWord : ℕ} (hm : m < capLanes) :
    SuccinctWhp.ltMask fpBits m q keysWord * SuccinctWhp.swarOnes (fpBits + 2) capLanes < 2 ^ ((2 * capLanes - 1) * (fpBits + 2))
    theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fits_mkWhpParams {base c U V w n_max : ℕ} (hw : 0 < w) (hnU : n_max ≤ U) (hU : WordRAM.Fits w U) (hV : WordRAM.Fits w V) (hfit : WordRAM.Fits w (base + SuccinctWhp.whpSpace c U V w n_max)) :
    (∀ (i : Fin 68), WordRAM.Fits w (mkWhpCoreParams c U V w n_max i)) ∧ ∀ (j : Fin 16), WordRAM.Fits w (wpHash1 (mkWhpParams c U V w n_max) j) ∧ WordRAM.Fits w (wpHash2 (mkWhpParams c U V w n_max) j)