Stateful ordered-set realization by recursive van Emde Boas trees #
This module realizes the shared Cslib.DataStructure.OrderedSet.spec (Fin (universeSize d))
interface (contains, insert, delete, minimum, successor) using recursive minimum-excluded
van Emde Boas trees Tree d over the bounded universe Fin (universeSize d) of size
universeSize d = 2 ^ (2 ^ d), and supplies an active-recursive-call depth certificate
callDepthBound of d + 1 per operation ([Dem15], pp. 4–5; [CLRS09],
Section 20.3).
Alongside Cslib.DataStructure.SearchTree (linear worst-case bound s.card), this provides a
bounded-universe realization of Cslib.DataStructure.OrderedSet.spec with doubly-logarithmic
recursion depth d + 1 on bounded integer keys.
Cost model and limitations #
Native operation traces count active recursive van Emde Boas calls (1 at the root plus the
active calls of the single recursive subcall, if any, at each internal level; at most d + 1 per
operation). In particular:
- Empty-node insertion (
bounds = none) and singleton-node deletion (bounds = some (m, m)) terminate in1active call without recursing into children. - Non-recursive
O(1)child-header reads and updates (bounds,minimum,maximum,withBounds,eraseTarget,clusterMax), immutableFunction.updatecluster-array updates, initial tree allocation (Tree.empty d, whose span isO(universeSize d)), division/modulo coordinate arithmetic,Finbounds wrapping, and pure client continuations are not charged here. SeeCslibFrontier.DataStructure.VanEmdeBoas.WordRAM.Model(and its companion initialization, membership, insertion, and successor modules; Word-RAM deletion and predecessor remain separate) for explicit Word-RAM memory and instruction accounting.
Main definitions #
Tree.memberVisits,Tree.insertVisits,Tree.eraseVisits,Tree.minimumVisits,Tree.successorVisits,Tree.predecessorVisits: active recursive-call counts forTree doperations.Tree.finElements,Tree.finMinimum,Tree.finSuccessor,Tree.finPredecessor: typedFin (universeSize d)observations and queries.step,Exec,run: concreteOrderedSet.Op (Fin (universeSize d))step, native execution relation, and executable client interpreter, built withCslib.DataStructure.Execution.ofStep.Rep,impl,callDepthBound: representation relation, semantic realization ofOrderedSet.spec (Fin (universeSize d)), and uniformd + 1per-operation resource bound.
Main results #
Tree.memberVisits_le,Tree.insertVisits_le,Tree.eraseVisits_le,Tree.minimumVisits_le,Tree.successorVisits_le,Tree.predecessorVisits_le: each operation makes at mostd + 1active recursive calls.Tree.insertVisits_of_bounds_none,Tree.eraseVisits_of_bounds_eq:O(1)single-call base cases on empty insertion and singleton deletion.Rep.valid,Rep.finElements_eq,rep_empty,impl_rep: representation projections and empty-set initialization.callDepthBound,realized_client,run_correct: adaptiveOrderedSetclients execute with finite-set correctness and total active-call cost at mosthistory.length * (d + 1).
References #
Every van Emde Boas universe size is nonzero, enabling OfNat (Fin (universeSize d)) numerals
for bounded-key clients.
Active recursive calls performed by Tree.minimum (1 root header read).
minimum performs 1 ≤ d + 1 active calls.
member performs at most d + 1 active recursive calls.
Inserting into an empty node performs only 1 active call at any depth.
insert performs at most d + 1 active recursive calls.
erase performs at most d + 1 active recursive calls.
successor performs at most d + 1 active recursive calls.
predecessor performs at most d + 1 active recursive calls.
Mathematical finite-set observation in Fin (universeSize d).
Membership in finElements agrees with Tree.Contains on valid trees.
Membership in finElements agrees with Tree.elements on x.val.
The empty tree represents the empty finite set of bounded keys.
Bounded insertion commutes with finElements.
Deletion commutes with finElements.
Typed Fin (universeSize d) minimum read from the cached root bounds.
Typed Fin (universeSize d) strict successor query.
Typed Fin (universeSize d) strict predecessor query.
finMinimum satisfies the optional-minimum contract for t.finElements.
finSuccessor satisfies the optional-minimum contract for keys strictly above x.
A successful finPredecessor returns the greatest element of t.finElements strictly below
x.
finPredecessor returns none iff every element of t.finElements is at least x.
Execute a single OrderedSet.Op (Fin (universeSize d)) on t : Tree d, returning the updated
tree, result, and active recursive-call count.
Native execution relation for OrderedSet.spec (Fin (universeSize d)) over Tree d.
Representation relation coupling a finite set s : Finset (Fin (universeSize d)) with a valid
van Emde Boas tree t : Tree d.
Extract Tree.Valid from Rep.
Extract the finElements equality from Rep.
Tree.empty d represents the empty Finset (Fin (universeSize d)).
Semantic realization of OrderedSet.spec (Fin (universeSize d)) by Tree d.
Every native OrderedSet operation on Tree d performs at most d + 1 active recursive
calls.
Uniform d + 1 active-call depth bound (O(log log U) since universeSize d = 2 ^ (2 ^ d))
for VanEmdeBoas.impl d.
Every adaptive OrderedSet client over Fin (universeSize d) executes on Tree d with
finite-set correctness and total active recursive calls at most history.length * (d + 1).
Execute an OrderedSet client concretely on Tree d, recording active recursive-call counts
per operation.
Running the concrete vEB interpreter agrees with abstract Finset (Fin (universeSize d))
semantics, preserves Rep, and satisfies the history.length * (d + 1) active-call bound.