Recursive van Emde Boas sets #
The universe at depth d is [0, 2 ^ (2 ^ d)). Each internal node stores its minimum
outside its clusters, caches its maximum, and records nonempty clusters in a recursive summary.
This is the recursive variant presented in Demaine's lecture notes,
not the stratified-tree implementation of van Emde Boas, Kaas and
Zijlstra.
The lecture notes credit Michael Bender for a 2001 personal communication.
The functions here are Lean algorithms. Immutable function updates, pattern matching and recursive calls have no certified machine cost. The separate word-RAM realization must charge instructions, initialization and memory before any machine running-time claim is made.
Main definitions #
Tree: a fully allocated recursive shape, with a two-key base universe.Tree.empty,Tree.insert,Tree.member,Tree.successor: set operations.Tree.Contains: mathematical interpretation of the stored keys.Tree.Valid: the recursive extrema, cluster and summary invariant.
References #
The extrema use one shared presence bit. A present pair stores minimum and maximum.
- leaf (bounds : Option (ℕ × ℕ)) : Tree 0
A node for the universe
{0, 1}. - node {d : ℕ} (bounds : Option (ℕ × ℕ)) (summary : Tree d) (cluster : Fin (universeSize d) → Tree d) : Tree (d + 1)
A node with a recursive summary and a direct-indexed array of clusters.
Instances For
The fully allocated empty tree. Allocation cost is not measured in this Lean definition.
Instances For
The local extrema correctly describe a bounded set of keys.
Instances For
Recursive invariant: bounded extrema, valid children and summary, exact summary occupancy, and strict exclusion of the local minimum from every cluster.
Instances For
The representation invariant has a concrete instance at every depth.