Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpFastOpProg.InsAllocWrite

Fast Insertion Slot Allocation & Write Primitives #

Low-level mutating primitives for fresh fast insertions: backyard slot pop/binding, (q, v) slot writes, and collision vs. direct insertion commit steps.

Main definitions #

Main results #

@[irreducible]

Allocate backyard slot at (b, X) when capFrontWhp ≤ X (d = (((cp, base), b), X)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.fastInsertAllocGenProg_fastStep {c U V w n_max base b X : ℕ} {θ : 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) (hX_tl : X < SuccinctWhp.totalLocalCoordsWhp n_max) (hcf_fn : SuccinctWhp.capFrontWhp n_max ≤ X → 0 < fs.poolFreeTop ∧ fs.poolFreeTop ≤ SuccinctWhp.poolSizeWhp n_max ∧ fs.poolFreeStack (fs.poolFreeTop - 1) < SuccinctWhp.poolSizeWhp 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 := fastInsertAllocGenProg (((mkWhpCoreParams c U V w n_max, base), b), X); have s' := (Memory.spec 0).clientState s prog; WordRAM.Realization.memoryCost prog s ≤ 12 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ FastStateStep base c U V w n_max θ (SuccinctWhp.fastInsertAlloc n_max b X fs) s s'
@[irreducible]

Write (q_val, v_val) at physSlot b X (d = ((((cp, base), b), X), (q_val, v_val))).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insWriteQVAtGenProg_fastStep {c U V w n_max base b X q_val v_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) (hX_tl : X < SuccinctWhp.totalLocalCoordsWhp n_max) (hbp : SuccinctWhp.capFrontWhp n_max ≤ X → fs.backPtr b (X - SuccinctWhp.capFrontWhp n_max) < SuccinctWhp.poolSizeWhp n_max) (hq_lt : q_val < 2 ^ SuccinctWhp.quotBitsWhp U 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 := insWriteQVAtGenProg ((((mkWhpCoreParams c U V w n_max, base), b), X), q_val, v_val); have s' := (Memory.spec 0).clientState s prog; have p_new := SuccinctWhp.FastState.physSlot n_max fs b X; WordRAM.Realization.memoryCost prog s ≤ 10 ∧ 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_new q_val, valArr := Function.update fs.valArr p_new 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'
@[irreducible]

Finish collision insertion (hasFpCollision = true): write bktCount, locState := 2 + curEp, and insert (b, X) into buf curEp (d = ((((cp, base), b), X), rKey)).

@[irreducible]

Finish direct insertion (hasFpCollision = false): write bktCount, locState := 1, insert (fp, X) into slices lIdx, and increment liveInsCount b.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insFinishCollisionGenProg_fastStep {c U V w n_max base b X rKey : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {curMap : ℕ → Option (ℕ × ℕ)} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hce : fs.curEp = 0 ∨ fs.curEp = 1) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hX_tl : X < SuccinctWhp.totalLocalCoordsWhp n_max) (hna_cap : (fs.buf fs.curEp).nodeAlloc + SuccinctWhp.cTabWhp c ≤ SuccinctWhp.maxTrieNodesWhp c n_max) (hia_cap : (fs.buf fs.curEp).itemAlloc < SuccinctWhp.qEpochWhp n_max) (hv_cur : SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.curEp) curMap) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := insFinishCollisionGenProg ((((mkWhpCoreParams c U V w n_max, base), b), X), rKey); have s' := (Memory.spec 0).clientState s prog; have ep := fs.curEp; have tr' := SuccinctWhp.bufInsert (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf ep) rKey b X; WordRAM.Realization.memoryCost prog s ≤ 20 * SuccinctWhp.cTabWhp c + 33 ∧ 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 := Function.update fs.locState b (Function.update (fs.locState b) X (2 + ep)), bktCount := Function.update fs.bktCount b (X + 1), 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 := Function.update fs.buf ep tr', 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'
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insFinishDirectGenProg_fastStep {c U V w n_max base b X fp lIdx : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {lm : ℕ → Option ℕ} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hb : b < SuccinctWhp.numBucketsWhp n_max) (hX_tl : X < SuccinctWhp.totalLocalCoordsWhp n_max) (hlIdx_eq : lIdx = fs.liveSliceIdx b) (hlIdx : lIdx < 3 * SuccinctWhp.numBucketsWhp n_max) (hfp_lt : fp < 2 ^ SuccinctWhp.fpBitsWhp n_max) (hlic : fs.liveInsCount b ≤ 8 * FeistelQuotient.slabScale n_max ^ 12) (hv_l : SuccinctWhp.ValidWhpSlice n_max (fs.liveInsCount b) (fs.slices lIdx) lm) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := insFinishDirectGenProg ((((mkWhpCoreParams c U V w n_max, base), b), X), fp, lIdx); have s' := (Memory.spec 0).clientState s prog; have sl' := SuccinctWhp.btreeInsert (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max) (SuccinctWhp.tMinWhp n_max) (fs.slices lIdx) fp X; WordRAM.Realization.memoryCost prog s ≤ 2440 ∧ 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 := Function.update fs.locState b (Function.update (fs.locState b) X 1), bktCount := Function.update fs.bktCount b (X + 1), bktSalt := fs.bktSalt, liveRole := fs.liveRole, liveInsCount := Function.update fs.liveInsCount b (fs.liveInsCount b + 1), 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 := Function.update fs.slices lIdx sl', 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'