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
Complexity.Algorithms.WordRAM.VanEmdeBoas.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 #
State after dfsSetup.
Instances For
Constant registers and lookup-table invariant preserved throughout the Phase 3 DFS loop.
Instances For
Extract the lookup-table invariant from DfsConst.
Transfer DfsConst across a state update that preserves the twelve constant registers and
establishes the lookup-table invariant on the new memory.
Active DFS state at pointer ptr, subtree depth k, and phase kindVal (0 = enter,
1 = exit).
Instances For
State after dfsBody at a leaf (kind = 0, x = 0).
Instances For
State after dfsBody entering an internal node (kind = 0, x = k + 1).
Instances For
State after dfsBody advancing from one child to the next cluster (kind = 1, x = k,
mem (low + k + 1) = cnt + 1).
Instances For
State after dfsBody finishing all clusters of a depth-k + 1 node (kind = 1, x = k,
mem (low + k + 1) = 0).
Instances For
State after dfsBody exiting the root (kind = 1, x = d).
Instances For
Cluster-iteration helper for dfs_subtree_spec at depth k + 1: given the induction
hypothesis ih at depth k, initializes the remaining cnt clusters starting at index m
(where m + cnt = universeSize k) in cnt * (8 * span k) loop instructions.
Subtree initialization theorem: from DfsState base d ptr k 0 s with k ≤ d and
ptr + span k ≤ base + span d, the DFS loop initializes Rep (Tree.empty k) ptr s'.mem
and reaches DfsState base d (ptr + span k) k 1 s' in at most 8 * span k - 15 instructions,
modifying only [ptr, ptr + span k) and counters [low + 1, low + k].
Complete Phase 3 DFS loop specification: from DfsState base d base d 0 s, dfsLoop
terminates in at most 8 * span d - 6 instructions, establishing Rep (Tree.empty d) base z.mem,
preserving root, payload, and stackBase, and modifying only [base, base + span d) and
[base + span d + 2 * (d + 1) + 1, base + span d + 3 * d + 2].
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.
The combined tree and scratch region of span d + 4 * (d + 1) words is bounded by
10 * universeSize d + 4 * (d + 1).