Root Initialization and Proactive Root Split (ensureAndSplitRootGenProg) #
Implements and certifies phase 1 of btreeInsertGenProg: initializing an empty slice (alloc = 0)
to a single empty leaf or proactively splitting a full (2t - 1)-key root before descent.
Precondition for ensureAndSplitRootGenProg (d = ((cp, base), sIdx)).
Parameter-free splitRootIfFull ∘ ensureRootSlice (d = ((cp, base), sIdx)), returning
(alloc1, root1).
theorem Cslib.DataStructure.Dictionary.WordRAM.SuccinctWhp.ensureAndSplitRootGenProg_spec {c U V w n_max base sIdx insCount : ℕ} {sl : SuccinctWhp.BTreeSlice} {mapFn : ℕ → Option ℕ} {s : Memory.State} (henv : WhpLargeEnv c U V w n_max w base) (hsIdx : sIdx < 3 * SuccinctWhp.numBucketsWhp n_max) (hins : insCount ≤ 8 * FeistelQuotient.slabScale n_max ^ 12) (hrep : BTreeSliceMemRep base c U V w n_max sIdx sl s.mem) (hv : SuccinctWhp.ValidWhpSlice n_max insCount sl mapFn) :
have prog := ensureAndSplitRootGenProg ((mkWhpCoreParams c U V w n_max, base), sIdx);
have sl1 :=
SuccinctWhp.splitRootIfFull (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max)
(SuccinctWhp.tMinWhp n_max) (SuccinctWhp.ensureRootSlice sl);
have s' := (Memory.spec 0).clientState s prog;
s'.frontier = s.frontier ∧ (Memory.spec 0).clientResult s prog = (sl1.alloc, sl1.root) ∧ WordRAM.Realization.memoryCost prog s ≤ 50 ∧ Succinct.ValidProg w (base + SuccinctWhp.largeSpaceWhp c U V w n_max) s prog ∧ BTreeSliceMemRep base c U V w n_max sIdx sl1 s'.mem ∧ sl1.alloc + SuccinctWhp.hMaxBTree < SuccinctWhp.nSliceWhp n_max ∧ (∃ (T1 : SuccinctWhp.BTreeTree),
T1.rootIdx = sl1.root ∧ T1.height ≤ SuccinctWhp.hMaxBTree ∧ SuccinctWhp.metaCount (sl1.nodes sl1.root).metaWord < 2 * SuccinctWhp.tMinWhp n_max - 1 ∧ SuccinctWhp.ValidSubtree true (SuccinctWhp.fpBitsWhp n_max) (SuccinctWhp.valLaneBitsWhp n_max)
(SuccinctWhp.tMinWhp n_max) sl1.alloc sl1.nodes 0 (2 ^ SuccinctWhp.fpBitsWhp n_max - 1) mapFn
T1) ∧ (∀ 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 ∧ a < base + offBtMeta c U V w n_max ∨ base + offTrieChild0 c U V w n_max ≤ a →
s'.mem a = s.mem a