Strict van Emde Boas predecessor #
This module defines and verifies strict predecessor lookup on recursive minimum-excluded
van Emde Boas trees ([CLRS09], Section 20.3, p. 552). [Dem15] gives only
Successor (p. 4), which this mirrors. The algorithm returns the greatest represented key
strictly less than its query, or none when every represented key is at least the query.
Queries need not lie inside [0, universeSize d).
Because each internal node stores its minimum m outside its clusters, predecessor is slightly
asymmetric with successor: when m < x ≤ M and neither x's cluster nor any earlier nonempty
cluster recorded in summary contains a key below x, predecessor falls back to returning
some m in O(1). These are mathematical correctness statements, without a machine cost claim.
Main definitions #
Tree.predecessor: strict predecessor query onTree d.
Main results #
Tree.predecessor_empty: predecessor lookup onempty dreturnsnone.Tree.predecessor_spec: the successful and unsuccessful result specifications.Tree.predecessor_eq_some_iff: success is equivalent to being the greatest smaller stored key.Tree.predecessor_eq_none_iff: failure is equivalent to having no smaller stored key.Tree.predecessor_isSome_of_gt_min: a query strictly above the cached minimum always has a strict predecessor in[0, universeSize d).
References #
The greatest stored key strictly less than the query, or none if it does not exist.
The cached cluster minimum chooses between one cluster recursion and one summary recursion;
when no cluster entry precedes x > m, the excluded node minimum m is returned
([CLRS09], Section 20.3, p. 552; it mirrors Successor in [Dem15], p. 4).
Predecessor lookup on the empty tree at depth d always returns none.
A returned key is the greatest represented key strictly below the query; failure certifies that every represented key is at least the query. No bound on the query is required.
A successful result is exactly the greatest represented key strictly less than the query.