Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpSeedCheckProg

Certified Memory.Prog Subroutines for emptyFastState Initialization and GoodSeedOnState #

This module implements two foundational large-regime Memory.Prog subroutines inside genuine whpSpace c U V w n_max words (zero auxiliary scratch beyond offBktMeta):

  1. initFastGenProg: initializes FastMemRep base c U V w n_max (emptyFastState n_max) in deterministic 4 * numBucketsWhp n_max + 4 * poolSizeWhp n_max + 5 (O(n_max)) memory charges once [base, base + 32) and [base + offQuotWhp c w n_max, base + largeSpaceWhp c U V w n_max) are zeroed and SeedWhpMemRep holds on [base + 32, base + offQuotWhp c w n_max).
  2. checkGoodSeedOnStateGenProg: evaluates checkGoodSeedOnState c U n_max θ csr in place on any CsrMemRep without external scratch arrays, storing per-bucket collision-free candidate salts (checkGoodSeedOnState c U n_max θ csr).2 b into the odd offBktMeta entries 16 * b + 1 (b < numBucketsWhp n_max) while preserving both SeedWhpMemRep and CsrMemRep.

Main definitions #

Main results #

References #

Section 1: Primitive Helpers and Zeroed Packed-Segment Lemmas #

Section 2: initFastGenProg (emptyFastState n_max Initializer) #

Exact memoryCost of initFastGenProg (O(n_max) deterministic operations).

@[irreducible]

Initialize emptyFastState n_max at base (d = (cp, base)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.initFastGenProg_spec {c U V w n_max base : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hz_hdr : ∀ (a : ℕ), base ≤ a → a < base + 32 → s.mem a = 0) (hz_body : ∀ (a : ℕ), base + offQuotWhp c w n_max ≤ a → a < base + SuccinctWhp.largeSpaceWhp c U V w n_max → s.mem a = 0) :
have prog := initFastGenProg (mkWhpCoreParams c U V w n_max, base); have s' := (Memory.spec 0).clientState s prog; SeedWhpMemRep base c U w n_max θ s'.mem ∧ FastMemRep base c U V w n_max (SuccinctWhp.emptyFastState n_max) s'.mem ∧ s'.frontier = s.frontier ∧ WordRAM.Realization.memoryCost prog s = initFastCostWhp n_max ∧ 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

Exact specification of initFastGenProg: starting from zeroed headers [base, base + 32) and zeroed body [base + offQuotWhp c w n_max, base + largeSpaceWhp c U V w n_max) with SeedWhpMemRep on [base + 32, base + offQuotWhp c w n_max), establishes FastMemRep for emptyFastState n_max in initFastCostWhp n_max deterministic memory operations.

Section 3: Scratch-Free checkGoodSeedOnStateGenProg #

Part 3a: Bucket load-balance loop (checkAllBalancedCsr) #

Part 3b: Pairwise-distinct rKeyAt check (checkPairwiseDistinctOn rKeyAt N) #

Part 3c: Per-bucket collision-free salt discovery (findSaltInRange into offBktMeta) #

Part 3d: Top-level checkGoodSeedOnStateGenProg #

@[irreducible]

Evaluate checkGoodSeedOnState c U n_max θ csr in place on CsrMemRep (d = (wp, base)), returning 1 iff ok = true and storing (checkGoodSeedOnState c U n_max θ csr).2 b at offBktMeta[16 * b + 1] for every b < numBucketsWhp n_max.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.checkGoodSeedOnStateGenProg_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) :
have prog := checkGoodSeedOnStateGenProg (mkWhpParams c U V w n_max, base); have s' := (Memory.spec 0).clientState s prog; have res := SuccinctWhp.checkGoodSeedOnState c U n_max θ csr; ((Memory.spec 0).clientResult s prog = if res.1 = true then 1 else 0) ∧ SeedWhpMemRep base c U w n_max θ s'.mem ∧ CsrMemRep base c U V w n_max csr s'.mem ∧ (∀ b < SuccinctWhp.numBucketsWhp n_max, BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s'.mem (16 * b + 1) = res.2 b) ∧ s'.frontier = s.frontier ∧ 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

Exact specification of checkGoodSeedOnStateGenProg: evaluates checkGoodSeedOnState c U n_max θ csr on any valid CsrMemRep, writes (checkGoodSeedOnState c U n_max θ csr).2 b into offBktMeta[16 * b + 1] for all b < numBucketsWhp n_max, and preserves both SeedWhpMemRep and CsrMemRep.