Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpSmallCsrProg

Certified Memory.Prog Subroutines for the Small Regime and CSR Fallback Operations #

This module builds parameter-free Memory.Prog subroutines certified over Basis.exact (via realize and Realizes.iterate₀) for:

  1. Small regime (n_max < whpThreshold c): smallStepOpGenProg, executing smallQuery, smallInsert, and smallDelete in ≤ 4 * whpThreshold c + 16 (O_c(1)) worst-case memory operations while preserving SmallMemRep and leaving memory outside [base, base + smallSpaceWhp U V w n_max) untouched.
  2. CSR fallback operations (whpThreshold c ≤ n_max): csrStepOpGenProg, executing csrStepOp c U n_max θ.1 csr op (csrQuery, csrInsert, csrDelete) fault-free for every seed θ : SeedWhp c U n_max while preserving CsrMemRep and SeedWhpMemRep.

Main definitions #

Main results #

Section 1: Canonical Operation / Result Word Encodings and Packed Helpers #

Canonical (opTag, (u_val, v_val)) tuple for op : Dynamic.Op U (0 = query, 1 = insert, 2 = delete).

Canonical (resTag, resVal) pair for Option ℕ ((0, 0) = none, (1, v) = some v).

c-only worst-case memoryCost bound for any small-regime operation (n_max < whpThreshold c).

Section 2: Small-Regime Memory.Prog Subroutines (n_max < whpThreshold c) #

@[irreducible]

Small-regime operation dispatcher (d = (((cp, base), opTag), (u_val, v_val))).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.smallStepOpGenProg_spec {c U V w n_max base : ℕ} {sm : SuccinctWhp.SmallDictState} {dict : State U} {s : Memory.State} (henv : WhpSmallEnv c U V w n_max w base) (hrep : SmallMemRep base U V w n_max sm s.mem) (_hv : SuccinctWhp.ValidSmallState U V n_max sm dict) (op : Dynamic.Op U) (hvalid : Dynamic.valid V n_max dict op) :
have enc := encodeOpWhp op; have prog := smallStepOpGenProg (((mkWhpCoreParams c U V w n_max, base), enc.1), enc.2); have s' := (Memory.spec 0).clientState s prog; have pureOut := match op with | Dynamic.Op.query u => (sm, SuccinctWhp.smallQuery n_max sm ↑u) | Dynamic.Op.delete u => (SuccinctWhp.smallDelete n_max sm ↑u, none) | Dynamic.Op.insert u v => (SuccinctWhp.smallInsert n_max sm (↑u) v, none); SmallMemRep base U V w n_max pureOut.1 s'.mem ∧ s'.frontier = s.frontier ∧ (Memory.spec 0).clientResult s prog = encodeOptRes pureOut.2 ∧ WordRAM.Realization.memoryCost prog s ≤ smallOpCostWhp c ∧ Succinct.ValidProg w (base + SuccinctWhp.smallSpaceWhp U V w n_max) s prog ∧ ∀ (a : ℕ), a < base ∨ base + SuccinctWhp.smallSpaceWhp U V w n_max ≤ a → s'.mem a = s.mem a

Section 3: CSR Fallback Memory.Prog Subroutines (whpThreshold c ≤ n_max) #

Loop 1: csrScanRange #

Loop 2: csrShiftDown #

Loop 3: csrShiftUp #

Loop 4: csrAdjustStarts #

Top-Level csrPrefixGenProg and csrStepOpGenProg #

Precondition for csrPrefixGenProg (d = ((wp, base), u_val)).

Precondition for csrStepOpGenProg (d = (((wp, base), opTag), (u_val, v_val))).

@[irreducible]

CSR fallback operation dispatcher (d = (((wp, base), opTag), (u_val, v_val))).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.csrStepOpGenProg_spec {c U V w n_max base : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {csr : SuccinctWhp.CsrState} {dict : State U} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : CsrMemRep base c U V w n_max csr s.mem) (hv : SuccinctWhp.ValidCsrState U V n_max (SuccinctWhp.bktHash c U n_max θ.1) csr dict) (op : Dynamic.Op U) (hvalid : Dynamic.valid V n_max dict op) :
have enc := encodeOpWhp op; have prog := csrStepOpGenProg (((mkWhpParams c U V w n_max, base), enc.1), enc.2); have s' := (Memory.spec 0).clientState s prog; have pureOut := SuccinctWhp.csrStepOp c U n_max θ.1 csr op; SeedWhpMemRep base c U w n_max θ s'.mem ∧ CsrMemRep base c U V w n_max pureOut.1 s'.mem ∧ s'.frontier = s.frontier ∧ (Memory.spec 0).clientResult s prog = encodeOptRes pureOut.2 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ ∀ (a : ℕ), a < base ∨ base + SuccinctWhp.largeSpaceWhp c U V w n_max ≤ a → s'.mem a = s.mem a