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.validWhpProg_laneGetGenProg {w F : ℕ} {s : Memory.State} (d : (ℕ × ℕ) × ℕ) :
Succinct.ValidProg w F s (laneGetGenProg d)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.validWhpProg_wordInsertAtGenProg {w F : ℕ} {s : Memory.State} (d : ((ℕ × ℕ) × ℕ) × ℕ) :
Succinct.ValidProg w F s (wordInsertAtGenProg d)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.validWhpProg_wordDeleteAtGenProg {w F : ℕ} {s : Memory.State} (d : (ℕ × ℕ) × ℕ) :
Succinct.ValidProg w F s (wordDeleteAtGenProg d)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.validWhpProg_wordUpdateAtGenProg {w F : ℕ} {s : Memory.State} (d : ((ℕ × ℕ) × ℕ) × ℕ) :
Succinct.ValidProg w F s (wordUpdateAtGenProg d)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.validWhpProg_swarRankGenProg {w F : ℕ} {s : Memory.State} (d : WhpCoreParams × (ℕ × ℕ) × ℕ) :
Succinct.ValidProg w F s (swarRankGenProg d)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.btree_slice_param_bounds {c n_max : ℕ} (hth : SuccinctWhp.whpThreshold c ≤ n_max) :
(3 ≤ SuccinctWhp.tMinWhp n_max ∧ 4 * SuccinctWhp.tMinWhp n_max ≤ 2 ^ SuccinctWhp.nodeMetaBitsWhp n_max ∧ 2 * SuccinctWhp.tMinWhp n_max < 2 ^ SuccinctWhp.keyLaneBitsWhp n_max ∧ SuccinctWhp.nSliceWhp n_max < 2 ^ SuccinctWhp.valLaneBitsWhp n_max) ∧ 8 ≤ SuccinctWhp.tMinWhp n_max
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.validWhpProg_splitFullNodeGenProg {w F : ℕ} {s : Memory.State} (d : WhpCoreParams × ℕ × ℕ × ℕ) :
Succinct.ValidProg w F s (splitFullNodeGenProg d)
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)
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.validSubtree_root_bounds {isRoot : Bool} {c n_max alloc lo hi : ℕ} {nodes : ℕ → SuccinctWhp.BTreeNode} {mapFn : ℕ → Option ℕ} {T : SuccinctWhp.BTreeTree} (hth : SuccinctWhp.whpThreshold c ≤ n_max) (hhi : hi < 2 ^ SuccinctWhp.fpBitsWhp n_max) (hv :
SuccinctWhp.ValidSubtree isRoot (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max)
(SuccinctWhp.tMinWhp n_max) alloc nodes lo hi mapFn T) :
have nd := nodes T.rootIdx;
have cnt := SuccinctWhp.metaCount nd.metaWord;
T.rootIdx < alloc ∧ cnt ≤ 2 * SuccinctWhp.tMinWhp n_max - 1 ∧ nd.metaWord < 2 ^ SuccinctWhp.nodeMetaBitsWhp n_max ∧ nd.keysWord < 2 ^ (cnt * SuccinctWhp.keyLaneBitsWhp n_max) ∧ nd.keysWord < 2 ^ SuccinctWhp.keysWordBitsWhp n_max ∧ nd.valsWord < 2 ^ SuccinctWhp.valsWordBitsWhp n_max ∧ ∀ j < cnt, laneGet (SuccinctWhp.keyLaneBitsWhp n_max) nd.keysWord j < 2 ^ SuccinctWhp.fpBitsWhp n_max
Packed bit-width and SWAR preconditions at the root of any ValidSubtree in the large
regime.
Write (alloc, root) = (newA, newR) for slice sIdx.
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.realizes_writeSliceHeaderGen :
WordRAM.Realization.Realizes WordRAM.Basis.exact writeSliceHeaderGenProg WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ × ℕ) (x_1 : Memory.State) =>
match x with
| (((cp, base), sIdx), snd) => WhpLargeEnvGen w cp base ∧ sIdx < 3 * wpM cp)
fun (x : ((WhpCoreParams × ℕ) × ℕ) × ℕ × ℕ) (x_1 : Memory.State) => 0
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.