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 #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckCapPoolGenProgCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckRKeyGuardsGenProgCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insReadFpLiveGenProgCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckFpCapOptGenProg
Main results #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckCapPoolGenProg_specCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckRKeyGuardsGenProg_specCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insReadFpLiveGenProg_specCslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.insCheckFpCapOptGenProg_spec
@[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.realizes_insCheckCapPoolGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact insCheckCapPoolGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (WhpCoreParams × ℕ) × ℕ) (x_1 : Memory.State) =>
match x with
| ((cp, base), b) => WhpLargeEnvGen w cp base ∧ b < wpM cp)
fun (x : (WhpCoreParams × ℕ) × ℕ) (x_1 : Memory.State) => 0
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.realizes_insCheckRKeyGuardsGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact insCheckRKeyGuardsGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (WhpCoreParams × ℕ) × ℕ) (s : Memory.State) =>
match x with
| ((cp, base), snd) =>
∃ (c : ℕ) (U : ℕ) (V : ℕ) (w₀ : ℕ) (n_max : ℕ) (fs : SuccinctWhp.FastState) (curMap : ℕ → Option (ℕ × ℕ)),
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 ∧ (fs.curEp = 0 ∨ fs.curEp = 1) ∧ SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.curEp) curMap ∧ (fs.rebStage ≤ 3 →
∃ (oldMap : ℕ → Option (ℕ × ℕ)),
SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.oldEp)
oldMap))
fun (x : (WhpCoreParams × ℕ) × ℕ) (x_1 : Memory.State) => 0
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) :
have prog := insCheckRKeyGuardsGenProg ((mkWhpCoreParams c U V w n_max, base), rKey);
let bad :=
(SuccinctWhp.bufLookup (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.curEp) rKey).isSome = true ∨ fs.rebStage ≤ 3 ∧ (SuccinctWhp.bufLookup (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.oldEp) rKey).isSome = true;
(Memory.spec 0).clientState s prog = s ∧ ((Memory.spec 0).clientResult s prog = if bad then 0 else 1) ∧ WordRAM.Realization.memoryCost prog s ≤ 4 * SuccinctWhp.cTabWhp c + 19 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_insReadFpLiveGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact insReadFpLiveGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (WhpParams × ℕ) × ℕ × ℕ) (s : Memory.State) =>
match x with
| ((wp, base), b, snd) =>
∃ (c : ℕ) (U : ℕ) (V : ℕ) (w₀ : ℕ) (n_max : ℕ) (θ : SuccinctWhp.SeedWhp c U n_max) (fs : SuccinctWhp.FastState)
(lm : ℕ → Option ℕ),
WhpLargeEnv c U V w₀ n_max w base ∧ wp = mkWhpParams 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 ∧ fs.liveRole b < 3 ∧ fs.liveInsCount b ≤ 8 * FeistelQuotient.slabScale n_max ^ 12 ∧ SuccinctWhp.ValidWhpSlice n_max (fs.liveInsCount b) (fs.slices (fs.liveSliceIdx b)) lm)
fun (x : (WhpParams × ℕ) × ℕ × ℕ) (x_1 : Memory.State) => 0
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.realizes_insCheckFpCapOptGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact insCheckFpCapOptGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (s : Memory.State) =>
match x with
| (((cp, base), snd), snd_1) =>
∃ (c : ℕ) (U : ℕ) (V : ℕ) (w₀ : ℕ) (n_max : ℕ) (fs : SuccinctWhp.FastState) (curMap : ℕ → Option (ℕ × ℕ)),
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 ∧ (fs.curEp = 0 ∨ fs.curEp = 1) ∧ SuccinctWhp.ValidBufTrie (SuccinctWhp.cTabWhp c) (SuccinctWhp.bCharWhp n_max) (fs.buf fs.curEp) curMap)
fun (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ) (x_1 : Memory.State) => 0
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