Documentation

CslibFrontier.DataStructure.VanEmdeBoas.WordRAM.Insert

Native van Emde Boas insertion descent #

Insertion updates local extrema in place and recurses at most once per level: either into the summary when the target cluster was empty (after installing the cluster's singleton extrema directly), or into the already-occupied target cluster. Repeated insertion of a local minimum terminates immediately.

Main definitions #

Main results #

References #

The constant and traversal registers at entry to an unfinished insertion.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.insertLoop_spec {d w base key : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : InsertEntry base key s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hkey : key < universeSize d) (ha : WordRAM.Fits w (base + span d)) :
∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w insertLoop s z (39 * (d + 1) + 2) ∧ Rep (tree.insert key) base z.mem ∧ ∀ (a : ℕ), a < base ∨ base + span d ≤ a → z.mem a = s.mem a

The insertion loop is correct for every depth and arbitrary surrounding memory. It executes within 39 * (d + 1) + 2 instructions, establishes Rep (tree.insert key) base z.mem, and leaves all memory outside [base, base + span d) unchanged.