Complete native van Emde Boas calls and adaptive dynamic realization #
All three operations — insert (tag = 0), member (tag = 1), and strict successor
(tag = 2) — execute on the same fixed 32-register dispatcher program, charging constant
setup, dispatch branches, every loop instruction, and the final halt.
In addition, this module connects program to the shared
DataStructure.StateTransitionSpec / DynamicProgram /
DynamicCertificate interface on finite sets (Finset ℕ) and combines the uniform native
initializer initProgram with arbitrary adaptive client histories (run_initialized).
Native dynamic calls append a checked eight-instruction result conversion. Membership copies its
answer into the shared flag register, and flags are normalized before canonical structural
parsing. Their
uniform halt-inclusive bound is 65 * (d + 1) + 30.
Main definitions #
Operation,Operation.Result,spec,dynamicProgram,SetRep,certificate: the stateful finite-set specification and its fixed-program Word-RAM realization.
Main results #
insert_dispatch_spec,insert_call,insert_executes,insert_executes_generic,insert_executes_log: complete native insertion calls in39 * (d + 1) + 16instructions.member_dispatch_spec,member_call,member_executes,member_executes_generic,member_executes_log: complete native membership calls in28 * (d + 1) + 18instructions.successor_dispatch_spec,successor_call,successor_executes,successor_executes_generic,successor_executes_log: complete native strict-successor calls in65 * (d + 1) + 22instructions.instruction_bound,instruction_bound_log,client_spec,run_initialized: adaptive history execution and combined initialization-plus-client execution certificates.
References #
The single compiled program contains 212 ordinary instructions and a final halt.
Compiling the fixed dispatcher introduces no word-width instruction.
The supported double-exponential universe has exactly d iterated binary logarithms.
Complete native insertion calls #
A complete insertion dispatch (tag = 0), including setup and all control flow but not final
halt, executes in at most 39 * (d + 1) + 15 instructions, updates the represented tree to
tree.insert key, leaves out = 0, and preserves all memory outside [base, base + span d).
A bounded caller invoking insertion (tag = 0) obtains a bounded state representing
tree.insert key, with unchanged persistent root and stackBase registers and all memory
outside [base, base + span d) preserved.
Actual flat bounded-word insertion execution, including its final halt, in
39 * (d + 1) + 16 instructions.
Exact transfer of the flat insertion call into the shared generic RAM model.
The charged native insertion bound written directly in terms of the universe size.
Complete native membership calls #
A complete membership dispatch, including setup and all control flow but not final halt. No query-universe restriction and no zero-filled outside-memory assumption are imposed.
A bounded caller obtains a bounded result, identical represented memory and an unchanged persistent root. Its query fits the machine word because every caller register does.
Actual flat bounded-word execution, including its final halt, in 28 (d+1) + 18
instructions. The selected fixed program has no depth or word-width parameter.
Exact transfer of the actual flat call into the shared generic RAM model; this adds no semantic operation or uncharged oracle instruction.
The charged native membership bound written directly in terms of the universe size.
Complete native strict-successor calls #
A complete strict-successor dispatch (tag = 2), including setup, descent, and stack unwind
but not final halt, executes in at most 65 * (d + 1) + 21 instructions, preserves the
represented tree at base, restores sp = stackBase₀, and modifies no memory outside the
4 * d-word stack region [stackBase₀, stackBase₀ + 4 * d).
A bounded caller invoking strict successor (tag = 2) obtains a bounded state with the
exact optional successor encoded by (found, out), unchanged persistent root and stackBase
registers, preserved tree representation, and unchanged memory outside
[stackBase₀, stackBase₀ + 4 * d).
Actual flat bounded-word strict-successor execution, including its final halt, in
65 * (d + 1) + 22 instructions.
Exact transfer of the flat strict-successor call into the shared generic RAM model.
The charged native strict-successor bound written directly in terms of the universe size.
Finite-set DataStructure.StateTransitionSpec and DynamicCertificate realization #
Dynamic ordered-set operations supported by the van Emde Boas dispatcher.
- insert (key : ℕ) : Operation
Insert a bounded universe key into the set.
- member (query : ℕ) : Operation
Query whether a fitting word belongs to the set.
- successor (query : ℕ) : Operation
Return the least stored key strictly greater than a fitting query, if any.
Instances For
Typed observation returned by each van Emde Boas operation.
Abstract finite-set specification on the universe [0, universeSize d).
Canonical native result formats: unit, exact Boolean, or tag followed by a natural word.
The result format presents each operation's existing observation type by equality.
A fixed bank shared by every operation: presence/Boolean flag, then successor payload.
Native result conversion stages real constants, copies membership's answer to the shared flag register, and normalizes that register to exactly zero or one.
The fixed dispatcher followed by its paid canonical result suffix, with a register-only
calling convention (tag and arg) and one fixed output bank.
Persistent machine representation of an abstract finite set s : Finset ℕ by a valid tree
at base and scratch stack pointer at stackBase₀.
- bounded : WordRAM.Data.Bounded w x
Every encoded argument of a valid van Emde Boas operation fits the machine word width.
Every admitted native call executes the original dispatcher and the paid canonical result suffix, retaining the represented set and all original memory framing guarantees.
Semantic correctness and totality certificate for the fixed bounded-word van Emde Boas implementation.
Separate worst-case per-operation instruction certificate, counting the final halt:
every admissible insert, member, or successor call executes in at most 65 * (d + 1) + 30
instructions.
The per-operation instruction certificate written in terms of the universe size.
Every actual call preserves memory outside the tree region [base, base + span d) and
the scratch stack [stackBase₀, stackBase₀ + 4 * d).
Every admissible adaptive client execution preserves memory outside the tree and stack regions across the entire interaction history.
Every admissible adaptive client has a concrete execution with the specified answers and
final finite set, at most 65 * (d + 1) + 30 instructions per operation, and unchanged memory
outside the tree and stack regions.
Combined native initialization and adaptive client execution: starting from any bounded
machine state s₀ with s₀.regs root = base, s₀.regs depth = d, and
Fits w (base + span d + 4 * (d + 1)) (with arbitrary initial memory), initProgram executes
in at most 8 * span d + 20 * d + 25 instructions to produce an empty represented set x₀,
from which any admissible adaptive client p executes to y with at most 65 * (d + 1) + 30
instructions per operation and no memory modified outside [base, base + span d + 4 * (d + 1)).