Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.SuccinctWhpBTreeProg.Helpers

Internal SWAR B+-Tree Slice Parameter Bounds and Header Write Frame Laws #

Internal ValidProg wrappers, bit-width bounds (btree_slice_param_bounds, validSubtree_root_bounds, descendToLeaf_leaf), and BTreeSliceMemRep frame lemmas for slice header updates (writeSliceHeaderGenProg, writeSliceAllocGenProg_sliceRep).

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.descendToLeaf_leaf {isRoot : Bool} {fpBits W_val tMin alloc lo hi q fuel : ℕ} {nodes : ℕ → SuccinctWhp.BTreeNode} {mapFn : ℕ → Option ℕ} {T : SuccinctWhp.BTreeTree} (ht2 : 2 ≤ tMin) (hcap : 2 * tMin < 2 ^ (fpBits + 2)) (hv : SuccinctWhp.ValidSubtree isRoot fpBits W_val tMin alloc nodes lo hi mapFn T) (hhi : hi < 2 ^ fpBits) (hqlo : lo ≤ q) (hqhi : q ≤ hi) (hfuel : T.height ≤ fuel) :
∃ (cnt : ℕ) (loL : ℕ), ∃ hiL ≤ hi, SuccinctWhp.ValidSubtree false fpBits W_val tMin alloc nodes loL hiL mapFn (SuccinctWhp.BTreeTree.leaf (SuccinctWhp.descendToLeaf fpBits W_val tMin nodes fuel T.rootIdx q) cnt)

Packed bit-width and SWAR preconditions at the root of any ValidSubtree in the large regime.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeSliceHeaderGenProg_sliceRep {c U V w n_max base sIdx newA newR : ℕ} {nodes : ℕ → SuccinctWhp.BTreeNode} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hsIdx : sIdx < 3 * SuccinctWhp.numBucketsWhp n_max) (hnewA : newA ≤ SuccinctWhp.nSliceWhp n_max) (hnewR : newR ≤ SuccinctWhp.nSliceWhp n_max) (hnodes : ∀ u < newA, have idx := sIdx * SuccinctWhp.nSliceWhp n_max + u; BitPackedArray.readPacked (base + offBtMeta c U V w n_max) (SuccinctWhp.nodeMetaBitsWhp n_max) w s.mem idx = (nodes u).metaWord ∧ BitPackedArray.readPacked (base + offBtKeys c U V w n_max) (SuccinctWhp.keysWordBitsWhp n_max) w s.mem idx = (nodes u).keysWord ∧ BitPackedArray.readPacked (base + offBtVals c U V w n_max) (SuccinctWhp.valsWordBitsWhp n_max) w s.mem idx = (nodes u).valsWord) :
have prog := writeSliceHeaderGenProg (((mkWhpCoreParams c U V w n_max, base), sIdx), newA, newR); have s' := (Memory.spec 0).clientState s prog; s'.frontier = s.frontier ∧ WordRAM.Realization.memoryCost prog s = 8 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ BTreeSliceMemRep base c U V w n_max sIdx { alloc := newA, root := newR, nodes := nodes } s'.mem ∧ (∀ sIdx' < 3 * SuccinctWhp.numBucketsWhp n_max, sIdx' ≠ sIdx → ∀ (sl' : SuccinctWhp.BTreeSlice), BTreeSliceMemRep base c U V w n_max sIdx' sl' s.mem → BTreeSliceMemRep base c U V w n_max sIdx' sl' s'.mem) ∧ (∀ idx < 16 * SuccinctWhp.numBucketsWhp n_max, idx ≠ 16 * (sIdx / 3) + 10 + 2 * (sIdx % 3) → idx ≠ 16 * (sIdx / 3) + 11 + 2 * (sIdx % 3) → BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s'.mem idx = BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s.mem idx) ∧ ∀ (a : ℕ), a < base + offBktMeta c U V w n_max ∨ base + offFbStart c U V w n_max ≤ a → s'.mem a = s.mem a

Updating (alloc, root) via writeSliceHeaderGenProg establishes BTreeSliceMemRep at the new (newA, newR) while framing all other slices, other bktMeta fields, and non-bktMeta words.

theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.writeSliceAllocGenProg_sliceRep {c U V w n_max base sIdx newA root0 : ℕ} {nodes : ℕ → SuccinctWhp.BTreeNode} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hsIdx : sIdx < 3 * SuccinctWhp.numBucketsWhp n_max) (hnewA : newA ≤ SuccinctWhp.nSliceWhp n_max) (hroot : BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s.mem (16 * (sIdx / 3) + 11 + 2 * (sIdx % 3)) = root0) (hnodes : ∀ u < newA, have idx := sIdx * SuccinctWhp.nSliceWhp n_max + u; BitPackedArray.readPacked (base + offBtMeta c U V w n_max) (SuccinctWhp.nodeMetaBitsWhp n_max) w s.mem idx = (nodes u).metaWord ∧ BitPackedArray.readPacked (base + offBtKeys c U V w n_max) (SuccinctWhp.keysWordBitsWhp n_max) w s.mem idx = (nodes u).keysWord ∧ BitPackedArray.readPacked (base + offBtVals c U V w n_max) (SuccinctWhp.valsWordBitsWhp n_max) w s.mem idx = (nodes u).valsWord) :
have prog := writeSliceAllocGenProg (((mkWhpCoreParams c U V w n_max, base), sIdx), newA); have s' := (Memory.spec 0).clientState s prog; s'.frontier = s.frontier ∧ WordRAM.Realization.memoryCost prog s = 4 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ BTreeSliceMemRep base c U V w n_max sIdx { alloc := newA, root := root0, nodes := nodes } s'.mem ∧ (∀ sIdx' < 3 * SuccinctWhp.numBucketsWhp n_max, sIdx' ≠ sIdx → ∀ (sl' : SuccinctWhp.BTreeSlice), BTreeSliceMemRep base c U V w n_max sIdx' sl' s.mem → BTreeSliceMemRep base c U V w n_max sIdx' sl' s'.mem) ∧ (∀ idx < 16 * SuccinctWhp.numBucketsWhp n_max, idx ≠ 16 * (sIdx / 3) + 10 + 2 * (sIdx % 3) → BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s'.mem idx = BitPackedArray.readPacked (base + offBktMeta c U V w n_max) (SuccinctBucket.globalPtrBits n_max) w s.mem idx) ∧ ∀ (a : ℕ), a < base + offBktMeta c U V w n_max ∨ base + offFbStart c U V w n_max ≤ a → s'.mem a = s.mem a

Updating alloc alone via writeSliceAllocGenProg establishes BTreeSliceMemRep at newA while framing all other slices, other bktMeta fields, and non-bktMeta words.