Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctLayout

Bit-Packed Memory Layout for Succinct Dictionaries #

This module defines the word-level memory layout and pure array extraction functions for the fixed-capacity succinct dynamic dictionary.

Memory layout ([base, base + totalSpace)) #

  1. [base, base + h_space): Seeded 3-wise quotient hash table and seed (h_space words, instantiated in SuccinctHash.lean with ReducedKWise.TableRep and ReducedKWise.SeedRep at h_space = hashSpace U w n_max) mapping quotients in Fin (2 ^ quotientBits U n_max) to micro-bucket hashes in Fin (2 ^ totalMicroBits n_max).
  2. Quotients: packedWords n_max (quotientBits U n_max) w words storing n_max quotients of quotientBits U n_max bits (offQuot).
  3. Values: packedWords n_max (valBits V) w words storing n_max values of valBits V bits (offVal).
  4. LocalMeta: 9 * lmSubWords n_max w words (9 bit-packed sub-arrays of totalMicroBuckets n_max entries of effBucketPosBits n_max bits each) storing per-bucket micro-bucket heads and doubly-linked list next/prev pointers (offLM).
  5. GlobalMeta: packedWords (globalMetaLen n_max) (globalPtrBits n_max) w words storing global counts, per-bucket slab/tail counts, direct slab directories, tail pointers, tail back-pointers, and the logical/physical slab pool bijection (offGM).

Main definitions #

Main results #

Section 1: Array offsets and extraction functions #

Word offset of Quotients relative to base.

Word offset of Values relative to base.

Word offset of LocalMeta relative to base.

Word size of each of the 9 LocalMeta sub-arrays of length totalMicroBuckets n_max.

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

Word offset of GlobalMeta relative to base.

Total word footprint of the succinct dictionary block starting at base.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.totalSpace_le_succinctWords {U V w n_max h_space : ℕ} :
totalSpace U V w n_max h_space ≤ Dynamic.succinctWords 79 (35 + h_space) U V w n_max

totalSpace is bounded by Dynamic.succinctWords 79 (35 + h_space) U V w n_max for all w.

def Cslib.DataStructure.Dictionary.WordRAM.Succinct.quotAt (base U w n_max h_space : ℕ) (mem : ℕ → ℕ) (idx : ℕ) :

Pure extraction function for Quotients[idx] (0 for idx ≥ n_max).

def Cslib.DataStructure.Dictionary.WordRAM.Succinct.valAt (base U V w n_max h_space : ℕ) (mem : ℕ → ℕ) (idx : ℕ) :

Pure extraction function for Values[idx] (0 for idx ≥ n_max).

def Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmAt (base U V w n_max h_space : ℕ) (mem : ℕ → ℕ) (p : ℕ × ℕ) :

Pure extraction function for LocalMeta sub-array p.1 < 9 at index p.2 < totalMicroBuckets n_max (0 out of bounds).

def Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmAt (base U V w n_max h_space : ℕ) (mem : ℕ → ℕ) (idx : ℕ) :

Pure extraction function for GlobalMeta[idx] (0 for idx ≥ globalMetaLen n_max).

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.quotAt_lt (base U w n_max h_space : ℕ) (mem : ℕ → ℕ) (idx : ℕ) :
quotAt base U w n_max h_space mem idx < 2 ^ FeistelQuotient.quotientBits U n_max

Value range invariant for quotAt: every entry is < 2 ^ quotientBits U n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.valAt_lt (base U V w n_max h_space : ℕ) (mem : ℕ → ℕ) (idx : ℕ) :
valAt base U V w n_max h_space mem idx < 2 ^ FeistelQuotient.valBits V

Value range invariant for valAt: every entry is < 2 ^ valBits V.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmAt_lt (base U V w n_max h_space : ℕ) (mem : ℕ → ℕ) (p : ℕ × ℕ) :
lmAt base U V w n_max h_space mem p < 2 ^ SuccinctBucket.effBucketPosBits n_max

Value range invariant for lmAt: every entry is < 2 ^ effBucketPosBits n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmAt_lt (base U V w n_max h_space : ℕ) (mem : ℕ → ℕ) (idx : ℕ) :
gmAt base U V w n_max h_space mem idx < 2 ^ SuccinctBucket.globalPtrBits n_max

Value range invariant for gmAt: every entry is < 2 ^ globalPtrBits n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.quotAt_zero_of_init {base U V w n_max h_space : ℕ} (hw : 0 < w) {mem : ℕ → ℕ} (hzero : ∀ (a : ℕ), base + h_space ≤ a → a < base + totalSpace U V w n_max h_space → mem a = 0) :
quotAt base U w n_max h_space mem = fun (x : ℕ) => 0

On zero-initialized table memory [base + h_space, base + totalSpace), quotAt is identically zero.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.valAt_zero_of_init {base U V w n_max h_space : ℕ} (hw : 0 < w) {mem : ℕ → ℕ} (hzero : ∀ (a : ℕ), base + h_space ≤ a → a < base + totalSpace U V w n_max h_space → mem a = 0) :
valAt base U V w n_max h_space mem = fun (x : ℕ) => 0

On zero-initialized table memory [base + h_space, base + totalSpace), valAt is identically zero.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.lmAt_zero_of_init {base U V w n_max h_space : ℕ} (hw : 0 < w) {mem : ℕ → ℕ} (hzero : ∀ (a : ℕ), base + h_space ≤ a → a < base + totalSpace U V w n_max h_space → mem a = 0) :
lmAt base U V w n_max h_space mem = fun (x : ℕ × ℕ) => 0

On zero-initialized table memory [base + h_space, base + totalSpace), lmAt is identically zero.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.gmAt_zero_of_init {base U V w n_max h_space : ℕ} (hw : 0 < w) {mem : ℕ → ℕ} (hzero : ∀ (a : ℕ), base + h_space ≤ a → a < base + totalSpace U V w n_max h_space → mem a = 0) :
gmAt base U V w n_max h_space mem = fun (x : ℕ) => 0

On zero-initialized table memory [base + h_space, base + totalSpace), gmAt is identically zero.

theorem Cslib.DataStructure.Dictionary.WordRAM.Succinct.arrays_congr_of_eq_on {base U V w n_max h_space : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (heq : ∀ (a : ℕ), base + h_space ≤ a → a < base + totalSpace U V w n_max h_space → mem₁ a = mem₂ a) :
quotAt base U w n_max h_space mem₁ = quotAt base U w n_max h_space mem₂ ∧ valAt base U V w n_max h_space mem₁ = valAt base U V w n_max h_space mem₂ ∧ lmAt base U V w n_max h_space mem₁ = lmAt base U V w n_max h_space mem₂ ∧ gmAt base U V w n_max h_space mem₁ = gmAt base U V w n_max h_space mem₂

If two memories agree on [base + h_space, base + totalSpace), they have identical quotAt, valAt, lmAt, and gmAt.