Documentation

CslibFrontier.DataStructure.VanEmdeBoas.WordRAM.Successor

Native van Emde Boas strict-successor certification #

This module certifies the native strict-successor operation (successorDescent followed by successorUnwind) in CslibFrontier.DataStructure.VanEmdeBoas.WordRAM.Program.

During descent, each recursive cluster or summary call pushes a four-word continuation frame (kind, payload, q, t) into the scratch stack [stackBase₀, stackBase₀ + 4 * d). Because Tree.successor checks the cached maximum before recursing, every recursive descent is guaranteed to find a key (found = 1), and successorUnwind pops the pushed frames to reconstruct the universe key in out while restoring sp = stackBase₀.

Main definitions #

Main results #

References #

structure Cslib.DataStructure.VanEmdeBoas.WordRAM.SuccessorEntry (stackBase₀ sp₀ base query : ℕ) (s : WordRAM.Data 32) :

The constant, stack, and traversal registers at entry to successorDescent.

structure Cslib.DataStructure.VanEmdeBoas.WordRAM.UnwindState (stackBase₀ sp₀ ans : ℕ) (mem : ℕ → ℕ) (s : WordRAM.Data 32) :

Register and memory invariant at the start of an unwind stage at stack pointer sp₀.

theorem Cslib.DataStructure.VanEmdeBoas.WordRAM.successor_loop_spec {d w stackBase₀ base query : ℕ} {tree : Tree d} {s : WordRAM.Data 32} (hs : SuccessorEntry stackBase₀ stackBase₀ base query s) (ht : tree.Valid) (hr : Rep tree base s.mem) (hdisj : base + span d ≤ stackBase₀) (hfit : WordRAM.Fits w (stackBase₀ + 4 * d)) :
∃ (z : WordRAM.Data 32), WordRAM.ExecWithin w (successorDescent.seq successorUnwind) s z (65 * (d + 1) + 4) ∧ (if z.regs found = 0 then none else some (z.regs out)) = tree.successor query ∧ z.regs sp = stackBase₀ ∧ Rep tree base z.mem ∧ ∀ (a : ℕ), a < stackBase₀ ∨ stackBase₀ + 4 * d ≤ a → z.mem a = s.mem a

Complete certification of successorDescent; successorUnwind from sp = stackBase₀: executes in at most 65 * (d + 1) + 4 instructions, computes tree.successor query, restores sp = stackBase₀, preserves Rep tree base z.mem, and frames memory outside [stackBase₀, stackBase₀ + 4 * d).