Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.ResizableSuccinct.Params

Compacted Epoch Parameters and Dense Pair-Stream Packing #

This module defines the 8-word persistent root header, the 225-word active epoch header, the metadata-first compacted epoch layout, and the dense [0, n) (quotient, value) pair-stream packing for the resizable succinct dynamic dictionary of Bender, Farach-Colton, J. Kuszmaul and W. Kuszmaul, SOSA 2024.

Memory layout ([metaBase, +offCompItems) and [itemBase, +compactedItemWords)) #

  1. Persistent 8-word root header ([metaBase, metaBase + 8)): [U - 1, V - 1, w, keyBits U, valBits V, N, n, n_init] (storing U - 1 and V - 1 so V = 2 ^ w fits in a w-bit word). When n = 0 (N = 0), the resting dictionary occupies only these 8 words (compactedEpochWords U V w 0 0 = 8).
  2. Active epoch parameter and hash-scratch header ([metaBase + 8, metaBase + 225)):
    • [metaBase + 8, metaBase + 27): 19 words of RuntimeReducedKWise.HashParams.
    • [metaBase + 27, metaBase + 63): 36 words of CompParams.
    • [metaBase + 63, metaBase + 225): 162-word limb scratch (RuntimeReducedKWise.scratchWords).
  3. Epoch metadata prefix ([metaBase + 225, metaBase + offCompItems U w N)): Hash (Succinct.hashSpace U w N), LocalMeta (9 * Succinct.lmSubWords N w), GlobalMeta, TailToDense, and DenseToTail.
  4. Dense [0, n) item stream ([itemBase, itemBase + compactedItemWords U V w N n)): n active (quotient, value) pairs packed densely at global bit offsets d * (quotientBits U N + valBits V) and d * (quotientBits U N + valBits V) + quotientBits U N. Parameterizing itemBase separately from metaBase allows both resting in-epoch states (itemBase = metaBase + offCompItems U w N) and single-tape epoch migration (Zone 1 metadata + Zone 3 shared item arena) to share the exact same Memory.Prog operations.

Main definitions #

Main results #

References #

Section 1: Dense [0, n) Pair-Stream Bit Packing #

Overflow-free word offset of the quotient field q_d at dense index d in a stream of (q_bits, v_bits) pairs on a w-bit machine.

Intra-word bit offset < w of the quotient field q_d at dense index d.

Overflow-free word offset of the value field v_d at dense index d.

Intra-word bit offset < w of the value field v_d at dense index d.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.bOffQ_lt {q_bits v_bits w d : ℕ} (hw : 0 < w) :
bOffQ q_bits v_bits w d < w
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.bOffV_lt {q_bits v_bits w d : ℕ} (hw : 0 < w) :
bOffV q_bits v_bits w d < w
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.wOffQ_mul_add_bOffQ {q_bits v_bits w d : ℕ} :
wOffQ q_bits v_bits w d * w + bOffQ q_bits v_bits w d = d * (q_bits + v_bits)

Exact global bit-offset identity wOffQ * w + bOffQ = d * (q_bits + v_bits).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.wOffV_mul_add_bOffV {q_bits v_bits w d : ℕ} :
wOffV q_bits v_bits w d * w + bOffV q_bits v_bits w d = d * (q_bits + v_bits) + q_bits

Exact global bit-offset identity wOffV * w + bOffV = d * (q_bits + v_bits) + q_bits.

Word footprint of n densely packed (quotient, value) entries in epoch N.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compactedItemWords_succ_sub_le_two {U V w N n : ℕ} (hw : 0 < w) (hU : U ≤ 2 ^ w) (hV : V ≤ 2 ^ w) :
compactedItemWords U V w N (n + 1) - compactedItemWords U V w N n ≤ 2

Adding 1 live item increases compactedItemWords by at most 2 words when U, V ≤ 2 ^ w.

Pure extraction function for dense quotient d < n at itemBase.

Pure extraction function for dense value d < n at itemBase.

Write q into dense quotient d at itemBase.

Write v into dense value d at itemBase.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compQuotAt_lt (itemBase U V w N n : ℕ) (mem : ℕ → ℕ) (d : ℕ) :
compQuotAt itemBase U V w N n mem d < 2 ^ FeistelQuotient.quotientBits U N
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compValAt_lt (itemBase U V w N n : ℕ) (mem : ℕ → ℕ) (d : ℕ) :
compValAt itemBase U V w N n mem d < 2 ^ FeistelQuotient.valBits V
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compQuotAt_writeCompQuot_self {itemBase U V w N n d q : ℕ} (mem : ℕ → ℕ) (hd : d < n) (hq : q < 2 ^ FeistelQuotient.quotientBits U N) :
compQuotAt itemBase U V w N n (writeCompQuot itemBase U V w N mem d q) d = q
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compQuotAt_writeCompQuot_of_ne {itemBase U V w N n d d' q : ℕ} (hw : 0 < w) (mem : ℕ → ℕ) (hne : d' ≠ d) :
compQuotAt itemBase U V w N n (writeCompQuot itemBase U V w N mem d q) d' = compQuotAt itemBase U V w N n mem d'
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compValAt_writeCompQuot {itemBase U V w N n d d' q : ℕ} (hw : 0 < w) (mem : ℕ → ℕ) :
compValAt itemBase U V w N n (writeCompQuot itemBase U V w N mem d q) d' = compValAt itemBase U V w N n mem d'
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compValAt_writeCompVal_self {itemBase U V w N n d v : ℕ} (mem : ℕ → ℕ) (hd : d < n) (hv : v < 2 ^ FeistelQuotient.valBits V) :
compValAt itemBase U V w N n (writeCompVal itemBase U V w N mem d v) d = v
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compValAt_writeCompVal_of_ne {itemBase U V w N n d d' v : ℕ} (hw : 0 < w) (mem : ℕ → ℕ) (hne : d' ≠ d) :
compValAt itemBase U V w N n (writeCompVal itemBase U V w N mem d v) d' = compValAt itemBase U V w N n mem d'
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compQuotAt_writeCompVal {itemBase U V w N n d d' v : ℕ} (hw : 0 < w) (mem : ℕ → ℕ) :
compQuotAt itemBase U V w N n (writeCompVal itemBase U V w N mem d v) d' = compQuotAt itemBase U V w N n mem d'
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompQuot_outside {itemBase U V w N n d q addr : ℕ} (hw : 0 < w) (hd : d < n) (mem : ℕ → ℕ) (haddr : ¬(itemBase ≤ addr ∧ addr < itemBase + compactedItemWords U V w N n)) :
writeCompQuot itemBase U V w N mem d q addr = mem addr
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.writeCompVal_outside {itemBase U V w N n d v addr : ℕ} (hw : 0 < w) (hd : d < n) (mem : ℕ → ℕ) (haddr : ¬(itemBase ≤ addr ∧ addr < itemBase + compactedItemWords U V w N n)) :
writeCompVal itemBase U V w N mem d v addr = mem addr
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compQuotAt_congr {itemBase U V w N n : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (heq : ∀ (addr : ℕ), itemBase ≤ addr ∧ addr < itemBase + compactedItemWords U V w N n → mem₁ addr = mem₂ addr) :
compQuotAt itemBase U V w N n mem₁ = compQuotAt itemBase U V w N n mem₂
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compValAt_congr {itemBase U V w N n : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (heq : ∀ (addr : ℕ), itemBase ≤ addr ∧ addr < itemBase + compactedItemWords U V w N n → mem₁ addr = mem₂ addr) :
compValAt itemBase U V w N n mem₁ = compValAt itemBase U V w N n mem₂
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compQuotAt_of_lt {itemBase U V w N n₁ n₂ d : ℕ} (mem : ℕ → ℕ) (hd₁ : d < n₁) (hd₂ : d < n₂) :
compQuotAt itemBase U V w N n₁ mem d = compQuotAt itemBase U V w N n₂ mem d
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.compValAt_of_lt {itemBase U V w N n₁ n₂ d : ℕ} (mem : ℕ → ℕ) (hd₁ : d < n₁) (hd₂ : d < n₂) :
compValAt itemBase U V w N n₁ mem d = compValAt itemBase U V w N n₂ mem d

Section 2: Persistent Root Header, Compacted Epoch Layout, and 1 · OPT Space Bounds #

The 8-word persistent root header [U - 1, V - 1, w, keyBits U, valBits V, N, n, n_init].

Word offset 8 of the 19-word RuntimeReducedKWise.HashParams vector.

Word offset 63 of the 162-word limb scratch slice (63 + 162 = 225).

Word offset 225 where the active epoch's ReducedKWise hash table and seed begin.

structure Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.RootHeaderValid (U V w N n n_init metaBase : ℕ) (mem : ℕ → ℕ) :

Persistent 8-word root header invariant at metaBase.

Epoch capacity invariant: N = 0 when n = 0, else 1 ≤ n ≤ N ≤ 4 * n ∧ N ≤ U.

A valid epoch bounds its size by its capacity, and its capacity by four times the size and by the universe size. These inequalities force zero capacity for an empty epoch.

Target epoch capacity min (2 * n) U (0 when n = 0).

The minimum formula for the target epoch capacity also holds at zero.

The target capacity of a nonempty epoch fits the universe and is at most twice its size.

@[reducible, inline]

Effective quotient bit-width max (quotientBits U N) 1 (= Succinct.qBits U N).

@[reducible, inline]

Reduction target bit-width totalMicroBits N + 1 (= Succinct.hashB N).

@[reducible, inline]

Word footprint of the epoch quotient hash (= Succinct.hashSpace U w N).

Word offset of LocalMeta relative to metaBase in a compacted epoch of capacity N.

Word offset of the c-th LocalMeta sub-array (c < 9) relative to metaBase.

Word offset of GlobalMeta relative to metaBase in a compacted epoch of capacity N.

Word offset of TailToDense relative to metaBase.

Word offset of DenseToTail relative to metaBase.

Word offset of the dense [0, n) active (quotient, value) stream relative to metaBase.

The compacted item stream starts after the fixed epoch header and scratch region.

Total resting word footprint of a compacted epoch (N, n): 8 words when n = 0 (rootHdrWords), and offCompItems U w N + compactedItemWords U V w N n when 0 < n.

Section 3: Pure Metadata Extractors and Runtime CompParams #

Pure extraction function for LocalMeta in a compacted epoch at metaBase.

Pure extraction function for GlobalMeta in a compacted epoch at metaBase.

Pure extraction function for TailToDense[t] (0 when t ≥ maxTailItems N).

Pure extraction function for DenseToTail[r] (0 when r ≥ maxTailItems N).

Runtime 36-word parameter vector stored at [metaBase + offCompParams, +36).

Instances For
    @[reducible, inline]

    Capacity parameter $N$.

    @[reducible, inline]

    Capacity minus one, $N - 1$.

    @[reducible, inline]

    Quotient bit width $q$.

    @[reducible, inline]

    Value bit width $v$.

    @[reducible, inline]

    Local metadata subtable offset for coordinate $c < 9$.

    @[reducible, inline]

    Local metadata entry bit-length.

    @[reducible, inline]

    Global metadata table offset.

    @[reducible, inline]

    Global metadata entry bit-length.

    @[reducible, inline]

    Tail-to-dense permutation offset.

    @[reducible, inline]

    Dense-to-tail permutation offset.

    @[reducible, inline]

    Maximum tail item capacity.

    @[reducible, inline]

    Number of bucket bits $\lceil \log_2 N \rceil$.

    @[reducible, inline]

    Bitmask for bucket bits $2^{\mathrm{bucketBits}} - 1$.

    @[reducible, inline]

    Bucket slab size parameter $K$.

    @[reducible, inline]

    Slab size minus one $K - 1$.

    @[reducible, inline]

    Direct slab count minus one.

    @[reducible, inline]

    Tail capacity parameter.

    @[reducible, inline]

    Global metadata slab directory base index.

    @[reducible, inline]

    Global metadata tail pointer base index.

    @[reducible, inline]

    Global metadata tail owner base index.

    @[reducible, inline]

    Global metadata slab metadata base index.

    @[reducible, inline]

    Minimum capacity bound.

    @[reducible, inline]

    Hash family workspace allocation words.

    Stored runtime parameter blocks in [metaBase + 8, metaBase + 63) for active epoch N.