Fast Deletion Move-Last Info Reader, Buffer Relocation & Slot Copy #
Sub-helpers for Substep 2 (fastDeleteMoveLast): reading loc_last metadata, updating
epoch-buffer back-pointers, and copying (quotArr, valArr, locState) into loc_del.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delMoveBufGenProgCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delCopySlotGenProgCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delMoveReadInfoGenProg
Main results #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_delMoveBufGenCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delMoveBufGenProg_fastStepCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_delCopySlotGenCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delCopySlotGenProg_fastStepCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delMoveReadInfoGenProg_specCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_delMoveReadInfoGen
@[irreducible]
Sub-helper 6.2a: relocate (b, loc_last) → (b, loc_del) in buf 0 or buf 1.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_delMoveBufGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact delMoveBufGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (((WhpCoreParams × ℕ) × ℕ) × ℕ) × ℕ × ℕ) (s : Memory.State) =>
match x with
| ((((cp, base), b), loc_del), st_last, snd) =>
∃ (c : ℕ) (U : ℕ) (V : ℕ) (w₀ : ℕ) (n_max : ℕ) (fs : SuccinctWhp.FastState),
WhpLargeEnv c U V w₀ n_max w base ∧ cp = mkWhpCoreParams c U V w₀ n_max ∧ FastMemRep base c U V w₀ n_max fs s.mem ∧ b < SuccinctWhp.numBucketsWhp n_max ∧ loc_del < SuccinctWhp.totalLocalCoordsWhp n_max ∧ (st_last = 2 →
(fs.buf 0).nodeAlloc + SuccinctWhp.cTabWhp c ≤ SuccinctWhp.maxTrieNodesWhp c n_max ∧ (fs.buf 0).itemAlloc < SuccinctWhp.qEpochWhp n_max ∧ ∃ (m0 : ℕ → Option (ℕ × ℕ)),
SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf 0)
m0) ∧ (st_last = 3 →
(fs.buf 1).nodeAlloc + SuccinctWhp.cTabWhp c ≤ SuccinctWhp.maxTrieNodesWhp c n_max ∧ (fs.buf 1).itemAlloc < SuccinctWhp.qEpochWhp n_max ∧ ∃ (m1 : ℕ → Option (ℕ × ℕ)),
SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf 1)
m1))
fun (x : (((WhpCoreParams × ℕ) × ℕ) × ℕ) × ℕ × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delMoveBufGenProg_fastStep {c U V w n_max base b loc_del st_last rKey_last : ℕ} {θ : 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) (hld : loc_del < SuccinctWhp.totalLocalCoordsWhp n_max) (h2 :
st_last = 2 →
(fs.buf 0).nodeAlloc + SuccinctWhp.cTabWhp c ≤ SuccinctWhp.maxTrieNodesWhp c n_max ∧ (fs.buf 0).itemAlloc < SuccinctWhp.qEpochWhp n_max ∧ ∃ (m0 : ℕ → Option (ℕ × ℕ)),
SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf 0) m0) (h3 :
st_last = 3 →
(fs.buf 1).nodeAlloc + SuccinctWhp.cTabWhp c ≤ SuccinctWhp.maxTrieNodesWhp c n_max ∧ (fs.buf 1).itemAlloc < SuccinctWhp.qEpochWhp n_max ∧ ∃ (m1 : ℕ → Option (ℕ × ℕ)),
SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf 1) m1) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := delMoveBufGenProg ((((mkWhpCoreParams c U V w n_max, base), b), loc_del), st_last, rKey_last);
have s' := (Memory.spec 0).clientState s prog;
have buf2 :=
if st_last = 2 then
Function.update fs.buf 0
(SuccinctWhp.bufInsert (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf 0) rKey_last b loc_del)
else if st_last = 3 then
Function.update fs.buf 1
(SuccinctWhp.bufInsert (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf 1) rKey_last b loc_del)
else fs.buf;
WordRAM.Realization.memoryCost prog s ≤ 20 * SuccinctWhp.cTabWhp c + 24 ∧ 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 := buf2, 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]
Sub-helper 6.2d: copy (quotArr[p_last], valArr[p_last], st_last) into (p_del, loc_del)
(d = ((((cp, base), b), (loc_del, loc_last)), st_last)).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_delCopySlotGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact delCopySlotGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (((WhpCoreParams × ℕ) × ℕ) × ℕ × ℕ) × ℕ) (s : Memory.State) =>
match x with
| ((((cp, base), b), loc_del, loc_last), snd) =>
∃ (c : ℕ) (U : ℕ) (V : ℕ) (w₀ : ℕ) (n_max : ℕ) (θ : SuccinctWhp.SeedWhp c U n_max) (fs : SuccinctWhp.FastState),
WhpLargeEnv c U V w₀ n_max w base ∧ cp = mkWhpCoreParams c U V w₀ n_max ∧ SeedWhpMemRep base c U w₀ n_max θ s.mem ∧ FastMemRep base c U V w₀ n_max fs s.mem ∧ b < SuccinctWhp.numBucketsWhp n_max ∧ loc_del < loc_last ∧ loc_last < SuccinctWhp.totalLocalCoordsWhp n_max ∧ (∀ k < loc_last + 1 - SuccinctWhp.capFrontWhp n_max,
fs.backPtr b k < SuccinctWhp.poolSizeWhp n_max) ∧ fs.quotArr (SuccinctWhp.FastState.physSlot n_max fs b loc_last) < 2 ^ SuccinctWhp.quotBitsWhp U n_max ∧ fs.valArr (SuccinctWhp.FastState.physSlot n_max fs b loc_last) < 2 ^ FeistelQuotient.valBits V)
fun (x : (((WhpCoreParams × ℕ) × ℕ) × ℕ × ℕ) × ℕ) (x_1 : Memory.State) => 0
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delCopySlotGenProg_fastStep {c U V w n_max base b loc_del loc_last st_last : ℕ} {θ : 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) (hlt : loc_del < loc_last) (hll : loc_last < SuccinctWhp.totalLocalCoordsWhp n_max) (hbp : ∀ k < loc_last + 1 - SuccinctWhp.capFrontWhp n_max, fs.backPtr b k < SuccinctWhp.poolSizeWhp n_max) (hq_lt : fs.quotArr (SuccinctWhp.FastState.physSlot n_max fs b loc_last) < 2 ^ SuccinctWhp.quotBitsWhp U n_max) (hv_lt : fs.valArr (SuccinctWhp.FastState.physSlot n_max fs b loc_last) < 2 ^ FeistelQuotient.valBits V) (hst_lt : st_last < 4) (hseed : SeedWhpMemRep base c U w n_max θ s.mem) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have prog := delCopySlotGenProg ((((mkWhpCoreParams c U V w n_max, base), b), loc_del, loc_last), st_last);
have s' := (Memory.spec 0).clientState s prog;
have p_last := SuccinctWhp.FastState.physSlot n_max fs b loc_last;
have p_del := SuccinctWhp.FastState.physSlot n_max fs b loc_del;
WordRAM.Realization.memoryCost prog s ≤ 20 ∧ 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_del (fs.quotArr p_last),
valArr := Function.update fs.valArr p_del (fs.valArr p_last),
locState := Function.update fs.locState b (Function.update (fs.locState b) loc_del st_last),
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'
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.delMoveReadInfoGenProg_spec {c U V w n_max base b loc_last : ℕ} {θ : 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) (hll : loc_last < SuccinctWhp.totalLocalCoordsWhp n_max) (hbp_ll :
SuccinctWhp.capFrontWhp n_max ≤ loc_last →
fs.backPtr b (loc_last - SuccinctWhp.capFrontWhp n_max) < SuccinctWhp.poolSizeWhp n_max) :
have prog := delMoveReadInfoGenProg (((mkWhpParams c U V w n_max, base), b), loc_last);
(Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = (fs.locState b loc_last, SuccinctWhp.FastState.rKeyAt c U n_max θ fs b loc_last, SuccinctWhp.FastState.fpAt c U n_max θ fs (fs.bktSalt b) b loc_last, SuccinctWhp.FastState.fpAt c U n_max θ fs fs.rebCandSalt b loc_last) ∧ WordRAM.Realization.memoryCost prog s ≤ 5 * hashEvalCostWhp c + 18 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog