Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpFastBaseProg.HeaderBkt

Fast-Mode Header, Bucket-Metadata, Dirty-Queue, and Control-Predicate Subroutines #

This module implements the parameter-free Memory.Prog subroutines and Realizes .exact certificates for scalar header words, bktMeta bucket fields, the dirty-bucket queue, and fast-mode control predicates on FastMemRep:

  1. Header word accessors (readHdrProg, writeHdrProg, updateFastHdr, readOldEpProg).
  2. Bucket scalar metadata accessors (getBktField, setBktField, readBktFieldGenProg, writeBktFieldGenProg, readLiveSaltIdxGenProg, fpOfSaltOpt_lt).
  3. Dirty-bucket queue accessors (readDirtyBucketGenProg, pushDirtyBucketGenProg).
  4. Control predicates (inLiveTreeProg, readRebActiveBGenProg).

Main definitions #

Main results #

Section 1: Header Word Accessors #

@[irreducible]

Read header word mem[base + hdrOff] (hdrOff < 32).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readHdrProg_spec {w F base hdrOff : ℕ} {s : Memory.State} (ha : base + hdrOff < F) :
have prog := readHdrProg (base, hdrOff); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = s.mem (base + hdrOff) ∧ WordRAM.Realization.memoryCost prog s = 1 ∧ Succinct.ValidProg w F s prog
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readHdrProg_large_spec (c U V w n_max : ℕ) {base hdrOff : ℕ} {s : Memory.State} (hoff : hdrOff < 32) :
have prog := readHdrProg (base, hdrOff); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = s.mem (base + hdrOff) ∧ WordRAM.Realization.memoryCost prog s = 1 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog

Specialization of readHdrProg_spec to the largeSpaceWhp frontier for any hdrOff < 32.

@[irreducible]

Write header word mem[base + hdrOff] := val (hdrOff < 32).

Update FastState on a single header slot hdrOff ∈ {1 .. 11}.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeHdrProg_fastStep {c U V w n_max base hdrOff val : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hhdr : 1 ≤ hdrOff ∧ hdrOff ≤ 11) (hfit_val : WordRAM.Fits w val) (hdc : hdrOff = 6 → val ≤ fs.dirtyCount) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := writeHdrProg ((base, hdrOff), val); have s' := (Memory.spec 0).clientState s prog; WordRAM.Realization.memoryCost prog s = 1 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ FastStateStep base c U V w n_max θ (updateFastHdr fs hdrOff val) s s'

Section 2: Bucket Scalar Metadata Accessors #

Pure projection of bucket b's scalar metadata field field ∈ {0 .. 9}.

Pure update of bucket b's scalar metadata field field ∈ {0 .. 9}.

@[irreducible]

Read bucket b's scalar metadata field field < 10 (d = (((cp, base), b), field)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readBktFieldGenProg_spec {c U V w n_max base b field : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hfield : field < 10) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := readBktFieldGenProg (((mkWhpCoreParams c U V w n_max, base), b), field); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = getBktField fs b field ∧ WordRAM.Realization.memoryCost prog s = 2 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.CostBoundedStep.readBkt {c U V w n_max base b field : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hfield : field < 10) (hrep : FastMemRep base c U V w n_max fs s.mem) :
CostBoundedStep w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s (readBktFieldGenProg (((mkWhpCoreParams c U V w n_max, base), b), field)) s (getBktField fs b field) 2

readBktFieldGenProg_spec packaged as a CostBoundedStep.

@[irreducible]

Write bucket b's scalar metadata field field < 10 (d = ((((cp, base), b), field), val)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeBktFieldGenProg_fastStep {c U V w n_max base b field val : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hfield : field < 10) (hval_le : val ≤ n_max) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := writeBktFieldGenProg ((((mkWhpCoreParams c U V w n_max, base), b), field), val); have s' := (Memory.spec 0).clientState s prog; WordRAM.Realization.memoryCost prog s = 4 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ FastStateStep base c U V w n_max θ (setBktField fs b field val) s s'

Section 3: Dirty-Bucket Queue Subroutines #

@[irreducible]

Read fs.dirtyBuckets j (j < fs.dirtyCount ≤ qEpochWhp n_max, d = ((cp, base), j)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readDirtyBucketGenProg_spec {c U V w n_max base j : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hj : j < fs.dirtyCount) (hrep : FastMemRep base c U V w n_max fs s.mem) :
@[irreducible]

Append bucket b at dirtyBuckets[dirtyCount] and increment dirtyCount (d = ((cp, base), b)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.pushDirtyBucketGenProg_fastStep {c U V w n_max base b : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hdc_lt : fs.dirtyCount < SuccinctWhp.qEpochWhp n_max) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := pushDirtyBucketGenProg ((mkWhpCoreParams c U V w n_max, base), b); have s' := (Memory.spec 0).clientState s prog; WordRAM.Realization.memoryCost prog s = 6 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ FastStateStep base c U V w n_max θ { quotArr := fs.quotArr, valArr := fs.valArr, locState := fs.locState, bktCount := fs.bktCount, bktSalt := fs.bktSalt, liveRole := fs.liveRole, liveInsCount := fs.liveInsCount, overmarsRole := fs.overmarsRole, overmarsActive := fs.overmarsActive, overmarsCursor := fs.overmarsCursor, overmarsInsCount := fs.overmarsInsCount, rebDoneFlag := fs.rebDoneFlag, rebQueued := fs.rebQueued, backPtr := fs.backPtr, poolFreeTop := fs.poolFreeTop, poolFreeStack := fs.poolFreeStack, poolOwner := fs.poolOwner, slices := fs.slices, buf := fs.buf, curEp := fs.curEp, epochClock := fs.epochClock, rebStage := fs.rebStage, stageCursor := fs.stageCursor, dirtyCount := fs.dirtyCount + 1, dirtyBuckets := Function.update fs.dirtyBuckets fs.dirtyCount b, dirtyIdx := fs.dirtyIdx, rebCandSalt := fs.rebCandSalt, rebScanCursor := fs.rebScanCursor, rebInsCount := fs.rebInsCount, rebCollision := fs.rebCollision } s s'

Section 4: Control-Predicate and Composite Header/Bucket Helpers #

@[irreducible]

Pure-ALU evaluation of inLiveTree rebStage oldEp rebDoneB st (0 or 1).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.inLiveTreeProg_spec {w F rebStage oldEp rebDoneB st : ℕ} {s : Memory.State} :
have prog := inLiveTreeProg ((rebStage, oldEp), rebDoneB, st); (Memory.spec 0).clientState s prog = s ∧ ((Memory.spec 0).clientResult s prog = if SuccinctWhp.inLiveTree rebStage oldEp rebDoneB st = true then 1 else 0) ∧ WordRAM.Realization.memoryCost prog s = 0 ∧ Succinct.ValidProg w F s prog
@[irreducible]

Check rebActiveB for bucket b (d = ((cp, base), b)), returning 1 or 0.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readRebActiveBGenProg_spec {c U V w n_max base b : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := readRebActiveBGenProg ((mkWhpCoreParams c U V w n_max, base), b); have rebActiveB := decide (fs.rebStage = 2 ∧ fs.dirtyIdx < fs.dirtyCount ∧ fs.dirtyBuckets fs.dirtyIdx = b ∧ fs.rebCandSalt < SuccinctWhp.sMaxWhp c n_max ∧ fs.rebCollision = 0); (Memory.spec 0).clientState s prog = s ∧ ((Memory.spec 0).clientResult s prog = if rebActiveB = true then 1 else 0) ∧ WordRAM.Realization.memoryCost prog s ≤ 7 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]

Read fs.oldEp = 1 - fs.curEp from mem[base + hdrCurEp].

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readOldEpProg_spec {w F base : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (ha : base + hdrCurEp < F) (hce_or : fs.curEp = 0 ∨ fs.curEp = 1) (hm2 : s.mem (base + hdrCurEp) = fs.curEp) :
@[irreducible]

Read (bktSalt b, liveSliceIdx b) for bucket b (d = ((cp, base), b)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readLiveSaltIdxGenProg_spec {c U V w n_max base b : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hrep : FastMemRep base c U V w n_max fs s.mem) :
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fpOfSaltOpt_lt (c U n_max salt kv : ℕ) (θ₂ : SuccinctWhp.FpSeed c U n_max) :
(if hs : salt < SuccinctWhp.sMaxWhp c n_max then if hu : kv < U then SuccinctWhp.fpHash c U n_max θ₂ ⟨salt, hs⟩ ⟨kv, hu⟩ else 0 else 0) < 2 ^ SuccinctWhp.fpBitsWhp n_max