Per-Bucket SWAR B+-Tree Slice Reconstruction for csrToFastGenProg #
This internal module implements Phase E2 of csrToFastGenProg:
readHealSlotQuotProg: reads the Feistel quotient of local coordinate(b, loc)from either front-yardoffQuotWhp[b * cf + loc]or backyardoffQuotWhp[M * cf + offBackPtr[b * cb + k]].buildBktSliceLoopProg: insertscntfingerprinted coordinates(fp, loc)into live slice3 * busing candidate saltoffBktMeta[16 * b + 1].buildAllBucketsOuterLoopProg: reconstructs live slices3 * bacross allb < Mwhile leaving auxiliary slices3 * b + 1, 3 * b + 2atzeroBTreeSlice.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.readHealSlotQuotProg,buildBktSliceLoopProg,buildAllBucketsOuterLoopProg.
Main results #
Slot Quotient Reader (readHealSlotQuotProg) #
Per-Bucket & All-Bucket Slice Rebuild (buildBktSliceLoopProg) #
@[irreducible]
Single coordinate insertion step of buildBktSliceLoopProg.
Precondition for buildBktSliceStepProg.
@[irreducible]
Single bucket step of buildAllBucketsOuterLoopProg.
Precondition for buildAllBucketsOuterStepProg.
@[irreducible]
Outer bucket loop rebuilding all M live SWAR B+-tree slices 3 * b.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_buildAllBucketsOuterLoop :
WordRAM.Realization.Realizes WordRAM.Basis.exact buildAllBucketsOuterLoopProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : (((WhpCoreParams × ℕ) × HealRt × HashRt) × ℕ) × ℕ) (s : Memory.State) =>
match x with
| ((cfg, b₀), rem) =>
WordRAM.Realization.iterationSafe buildAllBucketsOuterStepProg BuildAllBucketsOuterPre w cfg rem b₀ s)
fun (x : (((WhpCoreParams × ℕ) × HealRt × HashRt) × ℕ) × ℕ) (x_1 : Memory.State) => 0
Realizes .exact certificate for buildAllBucketsOuterLoopProg.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.buildAllBucketsOuterLoop_safe {c U V w n_max base : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} (henv : WhpLargeEnv c U V w n_max w base) :
have cp := mkWhpCoreParams c U V w n_max;
have rt := mkHealRt c U V w n_max base;
have hrt := mkHashRt c U w n_max base;
∀ (rem b₀ : ℕ) (s : Memory.State),
b₀ + rem ≤ SuccinctWhp.numBucketsWhp n_max →
SeedWhpMemRep base c U w n_max θ s.mem →
(∀ sIdx < 3 * SuccinctWhp.numBucketsWhp n_max,
b₀ ≤ sIdx / 3 → BTreeSliceMemRep base c U V w n_max sIdx SuccinctWhp.zeroBTreeSlice s.mem) →
WordRAM.Realization.iterationSafe buildAllBucketsOuterStepProg BuildAllBucketsOuterPre w ((cp, base), rt, hrt)
rem b₀ s
Loop-safety invariant for buildAllBucketsOuterLoopProg.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.buildAllBucketsOuterLoop_spec {c U V w n_max base : ℕ} {θ : SuccinctWhp.SeedWhp c U n_max} {fbStart qArr : ℕ → ℕ} {backPtr : ℕ → ℕ → ℕ} {salts : ℕ → ℕ} {s₀ : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hfb_adj : ∀ b < SuccinctWhp.numBucketsWhp n_max, fbStart b ≤ fbStart (b + 1)) (hbnd :
∀ b < SuccinctWhp.numBucketsWhp n_max,
fbStart (b + 1) - fbStart b - SuccinctWhp.capFrontWhp n_max < SuccinctWhp.capBackWhp n_max ∧ fbStart (b + 1) - fbStart b ≤ SuccinctWhp.totalLocalCoordsWhp n_max) (hbp_ps :
∀ b < SuccinctWhp.numBucketsWhp n_max,
∀ k < fbStart (b + 1) - fbStart b - SuccinctWhp.capFrontWhp n_max, backPtr b k < SuccinctWhp.poolSizeWhp n_max) (hseed₀ : SeedWhpMemRep base c U w n_max θ s₀.mem) (hfb₀ :
∀ x ≤ SuccinctWhp.numBucketsWhp n_max,
BitPackedArray.readPacked (base + offFbStart c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s₀.mem x = fbStart x) (hq₀ :
∀ i < n_max,
BitPackedArray.readPacked (base + offQuotWhp c w n_max) (SuccinctWhp.quotBitsWhp U n_max) w s₀.mem i = qArr i) (hbp₀ :
∀ b < SuccinctWhp.numBucketsWhp n_max,
∀ k < SuccinctWhp.capBackWhp n_max,
BitPackedArray.readPacked (base + offBackPtr c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s₀.mem
(b * SuccinctWhp.capBackWhp n_max + k) = backPtr b k) :
have cp := mkWhpCoreParams c U V w n_max;
have rt := mkHealRt c U V w n_max base;
have hrt := mkHashRt c U w n_max base;
have M := SuccinctWhp.numBucketsWhp n_max;
have targetSlice := fun (sIdx : ℕ) =>
have b := sIdx / 3;
have role := sIdx % 3;
if b < M ∧ role = 0 then
SuccinctWhp.buildBucketSlice c U n_max θ qArr backPtr b (salts b) (fbStart (b + 1) - fbStart b)
else SuccinctWhp.zeroBTreeSlice;
∀ (rem b₀ : ℕ) (s : Memory.State),
b₀ + rem ≤ M →
(∀ sIdx < 3 * M,
BTreeSliceMemRep base c U V w n_max sIdx
(if sIdx / 3 < b₀ then targetSlice sIdx else SuccinctWhp.zeroBTreeSlice) s.mem) →
(∀ b < M,
BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s.mem
(16 * b + 1) = salts b) →
(∀ (a : ℕ),
a < base + offBktMeta c U V w n_max ∨ base + offFbStart c U V w n_max ≤ a ∧ a < base + offBtMeta c U V w n_max ∨ base + offTrieChild0 c U V w n_max ≤ a →
s.mem a = s₀.mem a) →
have prog := buildAllBucketsOuterLoopProg ((((cp, base), rt, hrt), b₀), rem);
have s' := (Memory.spec 0).clientState s prog;
s'.frontier = s.frontier ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ (∀ sIdx < 3 * M,
BTreeSliceMemRep base c U V w n_max sIdx
(if sIdx / 3 < b₀ + rem then targetSlice sIdx else SuccinctWhp.zeroBTreeSlice) s'.mem) ∧ (∀ b < M,
BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w
s'.mem (16 * b + 1) = salts b) ∧ ∀ (a : ℕ),
a < base + offBktMeta c U V w n_max ∨ base + offFbStart c U V w n_max ≤ a ∧ a < base + offBtMeta c U V w n_max ∨ base + offTrieChild0 c U V w n_max ≤ a →
s'.mem a = s₀.mem a
Exact memory specification of buildAllBucketsOuterLoopProg.