Proactive Full-Root Split Subprogram (splitRootCode) #
Internal Word-RAM subroutine used privately by Insert (never re-exported publicly by
CslibFrontier.DataStructure.BTree.WordRAM): splits a full (2 * t - 1)-key root oldRoot into
oldRoot and newly allocated sibling cnt, and writes a new 1-key internal root at cnt + 1
(memSplitRoot).
Split full root rChild = oldRoot into oldRoot and cnt, creating a new 1-key root at
cnt + 1 (memSplitRoot).
theorem Cslib.DataStructure.BTree.WordRAM.splitRootCode_spec {w base capNodes t oldRoot cnt : ℕ} {x : WordRAM.Data 20} (ht : 2 ≤ t) (hr_lt : oldRoot < cnt) (hcap : cnt + 2 ≤ capNodes) (hbdd : WordRAM.Data.Bounded w x) (hfit : WordRAM.Fits w (base + arenaWords t capNodes)) (hz0 : x.regs rZero = 0) (ho : x.regs rOne = 1) (hbase : x.regs Reg.rBase = base) (hdeg : x.regs Reg.rDeg = t) (hstride : x.regs rStride = 6 * t) (hchild : x.regs rChild = oldRoot) (hcnt : x.regs rCnt = cnt) :
∃ (y : WordRAM.Data 20),
WordRAM.ExecWithin w splitRootCode x y (21 * t + 88) ∧ WordRAM.Data.Bounded w y ∧ y.mem = memSplitRoot base t oldRoot cnt x.mem ∧ WordRAM.Modifies { base := base, length := arenaWords t capNodes }.footprint x.mem y.mem ∧ y.regs rZero = 0 ∧ y.regs rOne = 1 ∧ y.regs Reg.rBase = base ∧ y.regs Reg.rDeg = t ∧ y.regs rStride = 6 * t ∧ y.regs Reg.rKey = x.regs Reg.rKey ∧ y.regs Reg.rVal = x.regs Reg.rVal ∧ y.regs rCur = cnt + 1 ∧ y.regs rCnt = cnt + 2
Specification of splitRootCode, realizing memSplitRoot base t oldRoot cnt in 21 * t + 88
instructions.