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:
- Small regime (
n_max < whpThreshold c):smallStepOpGenProg, executingsmallQuery,smallInsert, andsmallDeletein≤ 4 * whpThreshold c + 16(O_c(1)) worst-case memory operations while preservingSmallMemRepand leaving memory outside[base, base + smallSpaceWhp U V w n_max)untouched. - CSR fallback operations (
whpThreshold c ≤ n_max):csrStepOpGenProg, executingcsrStepOp c U n_max θ.1 csr op(csrQuery,csrInsert,csrDelete) fault-free for every seedθ : SeedWhp c U n_maxwhile preservingCsrMemRepandSeedWhpMemRep.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.encodeOpWhp,encodeOptRes: canonical word encodings ofDynamic.Op UandOption ℕ.Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.smallStepOpGenProg,smallOpCostWhp: certified small-regimeMemory.Progoperation dispatcher andc-only cost bound.Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.csrStepOpGenProg: certified CSR fallbackMemory.Progoperation dispatcher.
Main results #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_smallStepOpGen,smallStepOpGenProg_spec:Realizes .exactcertificate and exactSmallMemRepspecification.Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_csrStepOpGen,csrStepOpGenProg_spec:Realizes .exactcertificate and exactCsrMemRepspecification.
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).
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.realizes_smallStepOpGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact smallStepOpGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ × ℕ) (x_1 : Memory.State) =>
match x with
| (((cp, base), snd), snd_1) => WhpSmallEnvGen w cp base)
fun (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ × ℕ) (x_1 : Memory.State) => 0
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))).
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