Upper-Half Node Copy Subprogram (copyUpperCode) #
Internal Word-RAM subroutine shared privately by SplitRoot and SplitChild (never re-exported
publicly by CslibFrontier.DataStructure.BTree.WordRAM): moves the upper t - 1 keys/values (and
upper t child pointers when internal) of a full (2 * t - 1)-key node c into a fresh sibling
node z (memCopyUpper).
Copy the upper half of full node rChild into newly allocated sibling rCnt (memCopyUpper).
theorem Cslib.DataStructure.BTree.WordRAM.copyUpperCode_spec {w base capNodes t c z : ℕ} {x : WordRAM.Data 20} (ht : 2 ≤ t) (hc_cap : c < capNodes) (hz_cap : z < capNodes) (hcz : c ≠ z) (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 = c) (hcnt : x.regs rCnt = z) :
∃ (y : WordRAM.Data 20),
WordRAM.ExecWithin w copyUpperCode x y (21 * t + 48) ∧ WordRAM.Data.Bounded w y ∧ y.mem = memCopyUpper base t c z x.mem ∧ WordRAM.Modifies { base := base, length := arenaWords t capNodes }.footprint x.mem y.mem ∧ y.regs rZero = 0 ∧ ∀ reg ∉ [rSrc, rDst, rLim, rIdx, rTmp1, rTmp2, rZero], y.regs reg = x.regs reg
Specification of copyUpperCode, realizing memCopyUpper base t c z in 21 * t + 48
instructions.
theorem Cslib.DataStructure.BTree.WordRAM.memCopyUpper_at_c {base t c cnt : ℕ} (hsep : nodeAddr base t c + 6 * t ≤ nodeAddr base t cnt) (o : ℕ) (ho_lo : 2 ≤ o) (ho_hi : o < 6 * t) (mem : ℕ → ℕ) :
memCopyUpper leaves every key, value, and child cell (2 ≤ o < 6 * t) of c unchanged when
nodeAddr c + 6 * t ≤ nodeAddr cnt.