Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpFastOpProg.InsGuards

Fast Insertion Read-Only Pre-Check Guards #

Read-only Memory.Prog subroutines evaluating Guard 1 (bucket capacity & pool free stack), Guard 2 (rKey collisions in buf curEp / buf oldEp), live-slice fingerprint collision status, and Guard 3 (buf curEp collision capacity).

Main definitions #

Main results #

@[irreducible]

Guard 1 (insCheckCapPoolGenProg): check totalLocalCoordsWhp ≤ X ∨ (cf ≤ X ∧ poolFreeTop = 0) without mutating memory, returning (0, 0) if rejected or (1, X) if accepted.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckCapPoolGenProg_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) :
have prog := insCheckCapPoolGenProg ((mkWhpCoreParams c U V w n_max, base), b); have X := fs.bktCount b; have cf := SuccinctWhp.capFrontWhp n_max; (Memory.spec 0).clientState s prog = s ∧ ((Memory.spec 0).clientResult s prog = if SuccinctWhp.totalLocalCoordsWhp n_max ≤ X ∨ cf ≤ X ∧ fs.poolFreeTop = 0 then (0, 0) else (1, X)) ∧ WordRAM.Realization.memoryCost prog s ≤ 3 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]

Guard 2 (insCheckRKeyGuardsGenProg): return 0 if rKey collides in buf curEp or active buf oldEp, else 1 (d = ((cp, base), rKey)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckRKeyGuardsGenProg_spec {c U V w n_max base rKey : ℕ} {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) (hv_cur : SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.curEp) curMap) (hbo_fn : fs.rebStage ≤ 3 → ∃ (oldMap : ℕ → Option (ℕ × ℕ)), SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.oldEp) oldMap) (hrep : FastMemRep base c U V w n_max fs s.mem) :
@[irreducible]

Read (hasFpCollision, (fp, liveSliceIdx b)) for key u without mutating memory.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insReadFpLiveGenProg_spec {c U V w n_max base b : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fs : SuccinctWhp.FastState} {lm : ℕ → Option ℕ} {s : Memory.State} (u : Fin U) (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) (hlr : fs.liveRole b < 3) (hins : fs.liveInsCount b ≤ 8 * FeistelQuotient.slabScale n_max ^ 12) (hv_sl : SuccinctWhp.ValidWhpSlice n_max (fs.liveInsCount b) (fs.slices (fs.liveSliceIdx b)) lm) :
have prog := insReadFpLiveGenProg ((mkWhpParams c U V w n_max, base), b, ↑u); have fp := SuccinctWhp.fpOfSalt c U n_max θ.2 (fs.bktSalt b) u; have lIdx := fs.liveSliceIdx b; have hasCol := (SuccinctWhp.btreeLookup (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max) (SuccinctWhp.tMinWhp n_max) (fs.slices lIdx) fp).isSome; (Memory.spec 0).clientState s prog = s ∧ (Memory.spec 0).clientResult s prog = (if hasCol = true then 1 else 0, fp, lIdx) ∧ WordRAM.Realization.memoryCost prog s ≤ hashEvalCostWhp c + 266 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
@[irreducible]

Guard 3 wrapper (d = (((cp, base), hasCol), rKey)).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckFpCapOptGenProg_spec {c U V w n_max base rKey : ℕ} {fs : SuccinctWhp.FastState} {curMap : ℕ → Option (ℕ × ℕ)} {s : Memory.State} (hasFpCollision : Bool) (henv : WhpLargeEnv c U V w n_max w base) (hce : fs.curEp = 0 ∨ fs.curEp = 1) (hv_cur : SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.curEp) curMap) (hrep : FastMemRep base c U V w n_max fs s.mem) :
have hasCol := if hasFpCollision = true then 1 else 0; have prog := insCheckFpCapOptGenProg (((mkWhpCoreParams c U V w n_max, base), hasCol), rKey); let bad3 := hasFpCollision = true ∧ (!SuccinctWhp.bufEverPresent (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.curEp) rKey) = true ∧ 2 * SuccinctWhp.sMaxWhp c n_max ≤ (fs.buf fs.curEp).itemAlloc; (Memory.spec 0).clientState s prog = s ∧ ((Memory.spec 0).clientResult s prog = if bad3 then 0 else 1) ∧ WordRAM.Realization.memoryCost prog s ≤ 2 * SuccinctWhp.cTabWhp c + 5 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog