Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpFastBaseProg.SlotArrays

Fast-Mode Slot-Array Accessors (quotArr, valArr, backPtr) and Coordinate Hashing #

This module implements the parameter-free Memory.Prog subroutines and Realizes .exact certificates for slot-indexed packed arrays and coordinate-hash evaluation on FastMemRep:

  1. Quotient and value array accessors (readQuotGenProg, writeQuotGenProg, readValGenProg, writeValGenProg).
  2. Backyard pointer array accessors (readBackPtrGenProg, writeBackPtrGenProg).
  3. Composite coordinate address and hash helpers (physSlotGenProg, rKeyAtGenProg, fpAtGenProg).

Main definitions #

Main results #

Section 1: quotArr and valArr Accessors #

@[irreducible]

Read fs.quotArr p (p < n_max, d = ((cp, base), p)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readQuotGenProg_spec {c U V w n_max base p : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hp : p < n_max) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := readQuotGenProg ((mkWhpCoreParams c U V w n_max, base), p); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = fs.quotArr p ∧ WordRAM.Realization.memoryCost prog s = 2 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]

Write fs.quotArr p := q_val (p < n_max, d = (((cp, base), p), q_val)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeQuotGenProg_fastStep {c U V w n_max base p q_val : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hp : p < n_max) (hq_lt : q_val < 2 ^ SuccinctWhp.quotBitsWhp U 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 := writeQuotGenProg (((mkWhpCoreParams c U V w n_max, base), p), q_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 θ { quotArr := Function.update fs.quotArr p q_val, 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, dirtyBuckets := fs.dirtyBuckets, dirtyIdx := fs.dirtyIdx, rebCandSalt := fs.rebCandSalt, rebScanCursor := fs.rebScanCursor, rebInsCount := fs.rebInsCount, rebCollision := fs.rebCollision } s s'
@[irreducible]

Read fs.valArr p (p < n_max, d = ((cp, base), p)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readValGenProg_spec {c U V w n_max base p : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hp : p < n_max) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := readValGenProg ((mkWhpCoreParams c U V w n_max, base), p); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = fs.valArr p ∧ WordRAM.Realization.memoryCost prog s = 2 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]

Write fs.valArr p := v_val (p < n_max, d = (((cp, base), p), v_val)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeValGenProg_fastStep {c U V w n_max base p v_val : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hp : p < n_max) (hv_lt : v_val < 2 ^ FeistelQuotient.valBits V) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := writeValGenProg (((mkWhpCoreParams c U V w n_max, base), p), v_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 θ { quotArr := fs.quotArr, valArr := Function.update fs.valArr p v_val, 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, dirtyBuckets := fs.dirtyBuckets, dirtyIdx := fs.dirtyIdx, rebCandSalt := fs.rebCandSalt, rebScanCursor := fs.rebScanCursor, rebInsCount := fs.rebInsCount, rebCollision := fs.rebCollision } s s'

Section 2: backPtr Accessors #

@[irreducible]

Read fs.backPtr b k (b < M, k < capBackWhp n_max, d = (((cp, base), b), k)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readBackPtrGenProg_spec {c U V w n_max base b k : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hk : k < SuccinctWhp.capBackWhp n_max) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := readBackPtrGenProg (((mkWhpCoreParams c U V w n_max, base), b), k); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = fs.backPtr b k ∧ WordRAM.Realization.memoryCost prog s = 2 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]

Write fs.backPtr b k := pSlot (d = ((((cp, base), b), k), pSlot)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeBackPtrGenProg_fastStep {c U V w n_max base b k pSlot : ℕ} {θ : 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) (hk : k < SuccinctWhp.capBackWhp n_max) (hp_le : pSlot ≤ 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 := writeBackPtrGenProg ((((mkWhpCoreParams c U V w n_max, base), b), k), pSlot); 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 θ { 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 := Function.update fs.backPtr b (Function.update (fs.backPtr b) k pSlot), 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, dirtyBuckets := fs.dirtyBuckets, dirtyIdx := fs.dirtyIdx, rebCandSalt := fs.rebCandSalt, rebScanCursor := fs.rebScanCursor, rebInsCount := fs.rebInsCount, rebCollision := fs.rebCollision } s s'

Section 3: Composite Coordinate Helpers (physSlot, rKeyAt, fpAt) #

@[irreducible]

Compute fs.physSlot n_max b loc (d = (((cp, base), b), loc)).

Precondition for physSlotGenProg: (b, loc) in bounds and backyard pointer < poolSize.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.physSlotGenProg_spec {c U V w n_max base b loc : ℕ} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hloc : loc < SuccinctWhp.totalLocalCoordsWhp n_max) (hbp_lt : SuccinctWhp.capFrontWhp n_max ≤ loc → fs.backPtr b (loc - SuccinctWhp.capFrontWhp n_max) < SuccinctWhp.poolSizeWhp n_max) (hrep : FastMemRep base c U V w n_max fs s.mem) :
@[irreducible]

Compute fs.rKeyAt c U n_max θ b loc (d = (((wp, base), b), loc)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.rKeyAtGenProg_spec {c U V w n_max base b loc : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hloc : loc < SuccinctWhp.totalLocalCoordsWhp n_max) (hbp : SuccinctWhp.capFrontWhp n_max ≤ loc → fs.backPtr b (loc - SuccinctWhp.capFrontWhp n_max) < SuccinctWhp.poolSizeWhp n_max) :
have prog := rKeyAtGenProg (((mkWhpParams c U V w n_max, base), b), loc); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = SuccinctWhp.FastState.rKeyAt c U n_max θ fs b loc ∧ WordRAM.Realization.memoryCost prog s ≤ hashEvalCostWhp c + 5 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]

Compute fs.fpAt c U n_max θ salt b loc (d = ((((wp, base), salt), b), loc)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fpAtGenProg_spec {c U V w n_max base salt b loc : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hloc : loc < SuccinctWhp.totalLocalCoordsWhp n_max) (hbp : SuccinctWhp.capFrontWhp n_max ≤ loc → fs.backPtr b (loc - SuccinctWhp.capFrontWhp n_max) < SuccinctWhp.poolSizeWhp n_max) :
have prog := fpAtGenProg ((((mkWhpParams c U V w n_max, base), salt), b), loc); (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = SuccinctWhp.FastState.fpAt c U n_max θ fs salt b loc ∧ WordRAM.Realization.memoryCost prog s ≤ 2 * hashEvalCostWhp c + 4 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog