Charged uniform Word-RAM initialization of van Emde Boas trees #
This module certifies a single fixed 32-register Word-RAM program (initProgram) that initializes
an empty recursive van Emde Boas tree of arbitrary depth d at base address base, together with
the scratch stack pointer at base + span d, without depth-dependent code generation, square-root
oracle instructions, or uncharged zero-memory assumptions.
The initializer executes in three phases:
- Compute
(universeSize d, span d)byditerations of the layout recurrences. - Set
tableBase = stackBase = base + span dand populate a(splitSize k, childSpan k)lookup table of2 * (d + 1)words at[tableBase, tableBase + 2 * (d + 1)). - Traverse the recursive layout in depth-first order using
dwords of per-depth cluster counters at[tableBase + 2 * (d + 1) + 1, tableBase + 3 * d + 2], writing0,splitSize k, andchildSpan kinto every depth-kheader while leaving empty minimum/maximum cells untouched.
The program initProgram and its first two phases are developed in
CslibFrontier.DataStructure.VanEmdeBoas.WordRAM.Init.Table and re-exported here.
Main definitions #
Main results #
init_dispatch_spec: structured execution in at most8 * span d + 20 * d + 24instructions, establishingRep (Tree.empty d) base z.mem,z.regs root = base, andz.regs stackBase = base + span d, while preserving all memory outside[base, base + span d + 4 * (d + 1)).init_call,init_executes,init_executes_generic: bounded-state, flat, and generic RAM initialization certificates.init_space_le: the total tree-plus-scratch footprint is at most10 * universeSize d + 4 * (d + 1)words.
References #
Phase 3: depth-first empty-header initialization #
Constant registers and lookup-table invariant preserved throughout the Phase 3 DFS loop.
Active DFS state at pointer ptr, subtree depth k, and phase kindVal (0 = enter,
1 = exit).
Complete initializer specifications #
Complete structured execution of initProgram (excluding only the final flat halt):
from any state with s.regs root = base and s.regs depth = d, initProgram executes in at
most 8 * span d + 20 * d + 24 instructions, establishes Rep (Tree.empty d) base z.mem,
preserves z.regs root = base, sets z.regs stackBase = base + span d and
z.regs out = base + span d, and modifies no memory outside [base, base + span d + 4 * (d + 1)).
Bounded-caller initialization certificate: from any bounded state with s.regs root = base
and s.regs depth = d, initProgram executes in at most 8 * span d + 20 * d + 25 instructions
(including the final halt), preserves boundedness, establishes Rep (Tree.empty d) base z.mem,
and sets z.regs root = base and z.regs stackBase = base + span d.
Flat bounded-word execution of initProgram.program out, including the final halt, in at
most 8 * span d + 20 * d + 25 instructions.
Exact transfer of the flat initializer execution into the shared generic RAM model.
The flat initializer instruction bound written directly in terms of universeSize d.