Array-Allocated Word-RAM B-Tree (O(t log_t n) Lookup and Insertion) #
Re-export facade for the concrete in-memory Word-RAM implementation of classic minimum-degree-t
B-trees (t ≥ 2) over Cslib.WordRAM.Basis.standard (20 registers), backed by the flat arena
representation of CslibFrontier.DataStructure.BTree.WordRAM.Arena and following [CLRS09],
Section 18.2:
- Representation & Initialization (
WordRAM.Rep): caller-visible registersReg.rBase..rFound, coupling invariantRep, allocated-node counterallocCount, andO(1)initializerinitCode(initCode_spec). - Lookup (
WordRAM.Lookup): walks a single root-to-leaf path without modifying memory, returning(found, val)matchingBTree.lookup k trin at most(16 * t + 21) * tr.height + 16(O(t log_t n)) Word-RAM instructions (lookupCode,lookupProgram,lookupCode_spec,lookupCode_log_spec,lookupProgram_spec). - Proactive top-down insertion (
WordRAM.Insert): splits a full(2 * t - 1)-key root and descends through non-full nodes, proactively splitting any full child before descending, realizingCslib.SortedAssoc.insert k v tr.toListinO(t log_t n)Word-RAM instructions while preservingBTree.IsWF tand outside memory (insertCode,insertProgram,insertCode_spec,insertCode_log_spec,insertProgram_spec).
Main definitions #
Cslib.DataStructure.BTree.WordRAM.Reg.rBase,Cslib.DataStructure.BTree.WordRAM.Reg.rDeg,Cslib.DataStructure.BTree.WordRAM.Reg.rKey,Cslib.DataStructure.BTree.WordRAM.Reg.rVal,Cslib.DataStructure.BTree.WordRAM.Reg.rFound: caller-visible Word-RAM interface registers.Cslib.DataStructure.BTree.WordRAM.RepandCslib.DataStructure.BTree.WordRAM.allocCount: coupling invariant and allocated-node count (x.mem (base + 1)) for a20-register Word-RAM statex : Data 20representing a well-formedBTree ℕ ℕin[base, base + arenaWords t capNodes).Cslib.DataStructure.BTree.WordRAM.initCode:O(1)empty-arena initializer overBasis.standard.Cslib.DataStructure.BTree.WordRAM.lookupCode,Cslib.DataStructure.BTree.WordRAM.lookupProgram:O(t log_t n)B-tree lookup code and compiled flat program overBasis.standard.Cslib.DataStructure.BTree.WordRAM.insertCode,Cslib.DataStructure.BTree.WordRAM.insertProgram:O(t log_t n)proactive top-down B-tree insertion code and compiled flat program overBasis.standard.
Main results #
Cslib.DataStructure.BTree.WordRAM.Rep.isWF,Cslib.DataStructure.BTree.WordRAM.Rep.height_le_log,Cslib.DataStructure.BTree.WordRAM.Rep.setKey, andCslib.DataStructure.BTree.WordRAM.Rep.setKeyVal: well-formedness, logarithmic height bound, and argument-register framing forRep.Cslib.DataStructure.BTree.WordRAM.initCode_spec:O(1)Word-RAM initialization of.leaf.Cslib.DataStructure.BTree.WordRAM.lookupCode_spec,Cslib.DataStructure.BTree.WordRAM.lookupCode_log_spec, andCslib.DataStructure.BTree.WordRAM.lookupProgram_spec:O(t * tr.height)andO(t log_t n)Word-RAM instruction bounds forlookupCodeand halting flatlookupProgram.Cslib.DataStructure.BTree.WordRAM.insertCode_spec,Cslib.DataStructure.BTree.WordRAM.insertCode_log_spec, andCslib.DataStructure.BTree.WordRAM.insertProgram_spec:O(t * (tr.height + 1))andO(t log_t n)Word-RAM instruction bounds,Reppreservation,SortedAssoc.insertcorrectness, node-allocation bound, and memory framing forinsertCodeand halting flatinsertProgram.