Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.ResizableSuccinct

Resizable Succinct Dynamic Dictionary on the Resizable Word RAM #

This module packages the resizable succinct dynamic dictionary supporting insert, delete, and query over Cslib.WordRAM.Basis.exact and Cslib.WordRAM.Basis.standard on the word-granular Resizable Word RAM (Cslib.WordRAM.Resizable), certified as reusable Cslib.DataStructure.WordRAM.Resizable.Randomized.ObliviousSequenceImpl certificates (obliviousImpl and obliviousImplStandard) for (Cslib.DataStructure.Dictionary.Dynamic.spec U V U).toObliviousSequenceSpec (Dictionary.empty U).

Mathematical and algorithmic design #

This synthesis—combining expected amortized O(1) oblivious instructions, explicit stored 3-wise independent quotient hashing, and strict 1 · OPT(U, V, n) single-tape resting and migration-peak space on the Resizable Word RAM—is original to this formalization (deamortized high-probability bounds remain open under #3167). It draws on the bucket partition and fingerprint-indexed buckets of Bender, Farach-Colton, J. Kuszmaul, and W. Kuszmaul, SOSA 2024, Sections 3–4 and 6, one-round Feistel quotienting (Arbitman, Naor, and Segev, FOCS 2010, Claim 5.7; Bender, Conway, Farach-Colton, Kuszmaul, and Tagliavini, J. ACM 2023, Section 7), fixed-width full slabs with a shared tail pool (Bender, Farach-Colton, J. Kuszmaul, W. Kuszmaul, and M. Liu, STOC 2022, Sections 5.2 and 6.1, Lemma 24), and word-granular frontier resizing (.grow and .shrink) on the Resizable Word RAM (Kuszmaul, Liang, and Zhou, SODA 2026, Section 5.1):

  1. Metadata-first compacted epoch layout and U - 1 / V - 1 root header (Params, InEpoch):
    • When empty (n_t = 0), the dictionary occupies only the 8-word persistent root header [U - 1, V - 1, w, keyBits U, valBits V, 0, 0, 0] at [base, base + 8) (initCode runs in initSteps = 68 deterministic instructions). Storing U - 1 and V - 1 supports full-word value ranges V = 2 ^ w without overflowing w-bit words.
    • When active (1 ≤ n_t ≤ N ≤ min (4 * n_t) U), metadata (HashParams, CompParams, ReducedKWise seed and Four-Russians table, LocalMeta, GlobalMeta, TailToDense, and DenseToTail) sits at [base, base + offCompItems U w N) below a dense [0, n_t) stream of (quotient, value) pairs packed into compactedItemWords U V w N n_t words, linked to physical slab/tail coordinates via the circular-window bijection denseOfCirc. Resting memory above base never exceeds Dynamic.succinctWords 1355 441 U V w n_t words (1 · OPT: at most Dynamic.optBits U V n_t + 1355 * n_t * Dynamic.logLogFactor n_t + 442 * w bits).
  2. Single-tape 1 · OPT capacity-doubling and capacity-halving rebuilds (Migration):
    • An insert at n_t = N < U or a delete at 2 ≤ n_t with 4 * (n_t - 1) < N triggers migrateActiveCode, which shifts the existing [0, n_t) packed item stream into a shared upper arena, initializes fresh metadata for N' = targetCap U n_t = min (2 * n_t) U, samples a fresh uniform 3-wise independent quotient-hash seed (QuotHashSeed U N') in place via resampleHashCode (RInstr.rand), streams all n_t items left-to-right into [0, n_t) without holding two separate item arrays, and shrinks any trailing arena slack via shrinkCode.
    • Across every intermediate machine step—both in-epoch and during capacity migrations—the active hardware frontier above base never exceeds Dynamic.succinctWords 2699 888 U V w (max n_t n_{t+1}) words (1 · OPT, never 2 · OPT), sharpening to Dynamic.succinctWords 1355 441 U V w (max n_t n_{t+1}) words on non-migrating operations.
  3. Self-contained hashing, oblivious operation model, and expected amortized O(1) time:
    • No external hash or prime hypotheses: all quotient-hash seeds and Four-Russians carryless multiplication tables (RuntimeReducedKWise) are sampled and built internally by the program.
    • Oblivious operation sequence vs. adaptive .grow adversary: the operation sequence ops : List (Dynamic.Op U) is oblivious (fixed before initialization randomness, as specified by ObliviousSequenceImpl). Independently, within ExecRCodeDist, every newly allocated word returned by .grow is chosen by an adaptive demonic allocation adversary (RAdv / DemonicGrow), which growZeroCode zeroes immediately upon allocation.
    • Expected amortized O(1) vs. SOSA 2024 WHP: operations run in O(1) expected amortized Resizable Word RAM instructions (resizableCharge : ℕ, a parameter-free universal constant independent of U, V, w, base, and ops.length) via explicit two-stage 3-wise independent quotient hashing combined with slab-hysteresis and epoch-distance potentials (resizablePotential). By contrast, Bender, Farach-Colton, J. Kuszmaul, and W. Kuszmaul, SOSA 2024, Sections 5–6 prove deamortized with-high-probability bounds under idealized fully random hash functions.
  4. Program specialization:
    • The operational dispatcher (subroutineCode U V w).code = resizableOpCode does not depend on (U, V, w, base). The initializer initCode U V w depends on (U, V, w) only through the five header constants written to [base, base + 5), and neither program inspects the ambient word width via Op.width (¬(subroutineCode U V w).ReadsWidth). No theorem bounds static code size; all time bounds count executed Resizable Word RAM instructions.

Main definitions #

Main results #

References #

Section 1: Empty-Dictionary Initializer (initCode) and SubroutineCode #

Initializer (RCode .exact rResize) growing and zeroing the 8-word root header at [base, base + 8) (base = x₀.frontier), recording base in mBase, and writing [U - 1, V - 1, w, keyBits U, valBits V, 0, 0, 0].

initCode U V w does not inspect the ambient word width via Op.width.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.initCode_demonicExec {U V w base : ℕ} {x₀ : WordRAM.Resizable.RData rResize} (hx₀ : WordRAM.Resizable.RData.Bounded w x₀) (hfr₀ : x₀.frontier = base) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) (hV : V ≤ 2 ^ w) (hfit₈ : WordRAM.Fits w (base + 8)) :
∃ (y : WordRAM.Resizable.RData rResize), (WordRAM.Resizable.RDemonicExec w (base + 8) (initCode U V w) x₀ initSteps fun (x : WordRAM.Resizable.RData rResize) => x = y) ∧ EpochRep U V w base (EpochState.empty U) (LatentSeed.empty U) y ∧ ∀ addr < base, y.mem addr = x₀.mem addr

Deterministic RDemonicExec specification for initCode U V w: from any w-bounded state x₀ at x₀.frontier = base with Fits w (base + 8), initCode U V w runs in initSteps = 68 instructions within peak frontier base + 8, establishes EpochRep for EpochState.empty U and LatentSeed.empty U, and preserves caller memory [0, base).

Relocatable Resizable.SubroutineCode over Basis.exact for the resizable succinct dynamic dictionary (k_init = 0 runtime register parameters; code = resizableOpCode).

@[reducible, inline]

Standard-basis (Basis.standard) relocatable SubroutineCode obtained via basis simulation.

subroutineCode U V w does not inspect the ambient word width (¬ReadsWidth).

Section 2: 1 · OPT Resting and Peak Space Bounds Along Operation Trajectories #

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.epochSpaceBound_le_succinctWords {U V w : ℕ} (hw : 0 < w) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) {prefOps : List (Dynamic.Op U)} (hvh : (Dynamic.spec U V U).ValidHistory (empty U) prefOps) :
have n_t := (dom ((Dynamic.spec U V U).run (empty U) prefOps).1).card; epochSpaceBound U V w prefOps ≤ Dynamic.succinctWords 1355 441 U V w n_t

1 · OPT Resting Word-Footprint Bound (epochSpaceBound_le_succinctWords): After any admissible prefix prefOps reaching n_t = #(Dictionary.dom s_t) keys, the resting hardware frontier above base uses at most Dynamic.succinctWords 1355 441 U V w n_t words.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.w_mul_epochSpaceBound_le_bits {U V w : ℕ} (hw : 0 < w) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) {prefOps : List (Dynamic.Op U)} (hvh : (Dynamic.spec U V U).ValidHistory (empty U) prefOps) :
have n_t := (dom ((Dynamic.spec U V U).run (empty U) prefOps).1).card; w * epochSpaceBound U V w prefOps ≤ Dynamic.optBits U V n_t + 1355 * n_t * Dynamic.logLogFactor n_t + 442 * w

1 · OPT Resting Bit-Space Bound (w_mul_epochSpaceBound_le_bits): After any admissible prefix prefOps reaching n_t active keys, w * epochSpaceBound U V w prefOps ≤ Dynamic.optBits U V n_t + 1355 * n_t * Dynamic.logLogFactor n_t + 442 * w bits.

Pure specification-level 1 · OPT stepwise peak-word bound Dynamic.succinctWords 2699 888 U V w (max #(dom s) #(dom s')).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.epochPeakSpaceBound_le_succinctWords {U V w : ℕ} (hw : 0 < w) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) {prefOps : List (Dynamic.Op U)} {o : Dynamic.Op U} (hvh : (Dynamic.spec U V U).ValidHistory (empty U) prefOps) (hval : (Dynamic.spec U V U).valid ((Dynamic.spec U V U).run (empty U) prefOps).1 o) :
epochPeakSpaceBound U V w prefOps o ≤ stepSuccinctPeakWords V w ((Dynamic.spec U V U).run (empty U) prefOps).1 o

1 · OPT Stepwise Peak Word-Footprint Bound (epochPeakSpaceBound_le_succinctWords): Across every admissible operation o after prefix prefOps (including single-tape capacity doubling and halving rebuilds), the intermediate hardware frontier above base never exceeds stepSuccinctPeakWords V w s_t o = Dynamic.succinctWords 2699 888 U V w (max n_t n_{t+1}) words (never 2 · OPT).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.epochPeakSpaceBound_inEpoch_le_succinctWords {U V w : ℕ} (hw : 0 < w) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) {prefOps : List (Dynamic.Op U)} {o : Dynamic.Op U} (hvh : (Dynamic.spec U V U).ValidHistory (empty U) prefOps) (hval : (Dynamic.spec U V U).valid ((Dynamic.spec U V U).run (empty U) prefOps).1 o) (hno_mig : have st := EpochState.run V (EpochState.empty U) prefOps; have n := (dom st.dict).card; (∀ (u : Fin U) (v : ℕ), o = Dynamic.Op.insert u v → n ≠ 0 → ¬(n = st.cap ∧ st.cap < U)) ∧ ∀ (u : Fin U), o = Dynamic.Op.delete u → 2 ≤ n → ¬4 * (n - 1) < st.cap) :
have s_t := ((Dynamic.spec U V U).run (empty U) prefOps).1; have m := max (dom s_t).card (dom ((Dynamic.spec U V U).stepFn s_t o).1).card; epochPeakSpaceBound U V w prefOps o ≤ Dynamic.succinctWords 1355 441 U V w m

In-Epoch 1 · OPT Peak Word-Footprint Bound (epochPeakSpaceBound_inEpoch_le_succinctWords): On any operation o that does not trigger active capacity migration, epochPeakSpaceBound is bounded by Dynamic.succinctWords 1355 441 U V w (max n_t n_{t+1}) words.

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.w_mul_epochPeakSpaceBound_le_bits {U V w : ℕ} (hw : 0 < w) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) {prefOps : List (Dynamic.Op U)} {o : Dynamic.Op U} (hvh : (Dynamic.spec U V U).ValidHistory (empty U) prefOps) (hval : (Dynamic.spec U V U).valid ((Dynamic.spec U V U).run (empty U) prefOps).1 o) :
have s_t := ((Dynamic.spec U V U).run (empty U) prefOps).1; have m := max (dom s_t).card (dom ((Dynamic.spec U V U).stepFn s_t o).1).card; w * epochPeakSpaceBound U V w prefOps o ≤ Dynamic.optBits U V m + 2699 * m * Dynamic.logLogFactor m + 889 * w

1 · OPT Stepwise Peak Bit-Space Bound (w_mul_epochPeakSpaceBound_le_bits): Across every admissible operation o after prefix prefOps, w * epochPeakSpaceBound U V w prefOps o ≤ Dynamic.optBits U V m + 2699 * m * Dynamic.logLogFactor m + 889 * w bits, where m = max n_t n_{t+1} (never 2 · OPT).

Discharges ObliviousPeakFits from the pure 1 · OPT specification-level PeakFitsHistory condition Fits w (base + Dynamic.succinctWords 2699 888 U V w (max n_t n_{t+1})) along ops.

Section 3: ObliviousSequenceImpl Certificates and End-to-End Headline Theorems #

noncomputable def Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.obliviousImpl {U V w base : ℕ} (hw2 : WordRAM.Fits w 2) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) (hV : V ≤ 2 ^ w) :

Reusable Resizable.Randomized.ObliviousSequenceImpl certificate over Basis.exact for the resizable succinct dynamic dictionary (initTime = 68, initPotential = 0, constant per-operation charge resizableCharge, resting space epochSpaceBound, peak space epochPeakSpaceBound).

@[reducible, inline]

Standard-basis (Basis.standard) ObliviousSequenceImpl certificate obtained via basis simulation (ObliviousSequenceImpl.toStandard).

theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.seq_expected_amortized {U V w base : ℕ} {x₀ : WordRAM.Resizable.RData rResize} (ops : List (Dynamic.Op U)) (hw2 : WordRAM.Fits w 2) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) (hV : V ≤ 2 ^ w) (hx₀ : WordRAM.Resizable.RData.Bounded w x₀) (hfr₀ : x₀.frontier = base) (hfit₀ : WordRAM.Fits w (base + 8)) (hvh : (Dynamic.spec U V U).ValidHistory (empty U) ops) (hfit_ops : WordRAM.Resizable.PeakFitsHistory w base (stepSuccinctPeakWords V w) (empty U) ops) :
let C := obliviousImpl hw2 hU_pos hU hV_pos hV; have n_fin := (dom ((Dynamic.spec U V U).run (empty U) ops).1).card; ∃ (ν₀ : PMF (WordRAM.Resizable.Randomized.LatentRState (LatentSeed U) rResize)) (ν_final : PMF (WordRAM.Resizable.Randomized.SeqROutcome (LatentSeed U) Dynamic.Op.Result rResize)) (T_ops : ENNReal), WordRAM.Resizable.ExecRCodeDist w (initCode U V w) x₀ (PMF.map WordRAM.Resizable.Randomized.LatentRState.data ν₀) (↑initSteps) (base + 8) ∧ (∀ t ∈ ν₀.support, ∀ addr < base, t.data.mem addr = x₀.mem addr) ∧ C.Steps ops (PMF.map WordRAM.Resizable.Randomized.SeqROutcome.ofLatentRState ν₀) ν_final T_ops ∧ (∀ t ∈ ν_final.support, WordRAM.Resizable.RData.Bounded w t.data ∧ (base ≤ t.data.frontier ∧ t.data.frontier ≤ base + Dynamic.succinctWords 1355 441 U V w n_fin ∧ t.data.regs mBase = base) ∧ (∀ addr < base, t.data.mem addr = x₀.mem addr) ∧ t.transcript = ((Dynamic.spec U V U).run (empty U) ops).2) ∧ ↑initSteps + T_ops ≤ ↑initSteps + ↑(ops.length * resizableCharge)

End-to-End Expected-Amortized Resizable Succinct Dictionary (seq_expected_amortized): For any key universe 0 < U < 2 ^ w, value range 0 < V ≤ 2 ^ w, word width w with Fits w 2, caller base address base with Fits w (base + 8), initial w-bounded state x₀ at x₀.frontier = base, and oblivious admissible operation sequence ops whose 1 · OPT stepwise peak footprint stepSuccinctPeakWords (Dynamic.succinctWords 2699 888 U V w (max n_t n_{t+1})) fits above base:

  1. initCode U V w executes in initSteps = 68 instructions within base + 8 words;
  2. subroutineCode U V w (code = resizableOpCode) executes ops under ExecSteps within stepwise peak frontier base + epochPeakSpaceBound ≤ base + stepSuccinctPeakWords;
  3. Every final state t ∈ ν_final.support is w-bounded, rests at frontier ≤ base + Dynamic.succinctWords 1355 441 U V w n_fin (1 · OPT), keeps regs mBase = base, preserves caller memory [0, base), and outputs exact canonical transcript ((Dynamic.spec U V U).run (Dictionary.empty U) ops).2;
  4. Total expected executed instructions satisfy initSteps + T_ops ≤ initSteps + ops.length * resizableCharge (O(|ops| + 1)).
theorem Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.seq_expected_amortized_standard {U V w base : ℕ} {x₀ : WordRAM.Resizable.RData rResize} (ops : List (Dynamic.Op U)) (hw2 : WordRAM.Fits w 2) (hU_pos : 0 < U) (hU : WordRAM.Fits w U) (hV_pos : 0 < V) (hV : V ≤ 2 ^ w) (hx₀ : WordRAM.Resizable.RData.Bounded w x₀) (hfr₀ : x₀.frontier = base) (hfit₀ : WordRAM.Fits w (base + 8)) (hvh : (Dynamic.spec U V U).ValidHistory (empty U) ops) (hfit_ops : WordRAM.Resizable.PeakFitsHistory w base (stepSuccinctPeakWords V w) (empty U) ops) :
let C := obliviousImplStandard hw2 hU_pos hU hV_pos hV; have n_fin := (dom ((Dynamic.spec U V U).run (empty U) ops).1).card; ∃ (ν₀ : PMF (WordRAM.Resizable.Randomized.LatentRState (LatentSeed U) rResize)) (ν_final : PMF (WordRAM.Resizable.Randomized.SeqROutcome (LatentSeed U) Dynamic.Op.Result rResize)) (T_ops : ENNReal), WordRAM.Resizable.ExecRCodeDist w (subroutineCodeStandard U V w).initCode x₀ (PMF.map WordRAM.Resizable.Randomized.LatentRState.data ν₀) (↑initSteps) (base + 8) ∧ (∀ t ∈ ν₀.support, ∀ addr < base, t.data.mem addr = x₀.mem addr) ∧ C.Steps ops (PMF.map WordRAM.Resizable.Randomized.SeqROutcome.ofLatentRState ν₀) ν_final T_ops ∧ (∀ t ∈ ν_final.support, WordRAM.Resizable.RData.Bounded w t.data ∧ (base ≤ t.data.frontier ∧ t.data.frontier ≤ base + Dynamic.succinctWords 1355 441 U V w n_fin ∧ t.data.regs mBase = base) ∧ (∀ addr < base, t.data.mem addr = x₀.mem addr) ∧ t.transcript = ((Dynamic.spec U V U).run (empty U) ops).2) ∧ ↑initSteps + T_ops ≤ ↑initSteps + ↑(ops.length * resizableCharge)

Standard-Basis End-to-End Expected-Amortized Resizable Succinct Dictionary (seq_expected_amortized_standard): Transports seq_expected_amortized to Basis.standard via obliviousImplStandard.