Static multiway predecessor trees #
This is an outer multiway tree for fusion-tree search, independently of node search. Keys occur in leaves; each internal node caches the first key in its subtree. A node search may scan its children linearly. No word-RAM running-time bound is asserted here. Singleton branches are collapsed, so leaves need not all have the same depth.
Main definitions #
Tree: singleton leaves and internal nodes with cached subtree minima.Tree.build: executable construction from a list, with branching parameterB.Tree.predecessor: inclusive predecessor, using an explicit linear scan of child minima.
Main results #
Tree.keys_build,Tree.valid_build: construction preserves all keys and supplies occupancy.Tree.height_build_le: height is at mostNat.clog B n, uniformly forB ≥ 2.Tree.height_build_le_log_add_one: height is at mostNat.log B n + 1forB ≥ 2.Tree.slots_build_le: keys, links, cached minima and headers occupy at most14n + 2slots.Tree.predecessor_build_eq_some_iff,Tree.predecessor_build_eq_none_iff: exact search semantics.
References #
See [FW93] for fusion trees and their multiway outer search tree.
A multiway tree representation. Well-formed leaves contain at most one key. The empty tree is represented by an empty leaf. Internal nodes store one cached minimum and their child pointers.
Instances For
Stored leaf keys in left-to-right order, without the cached internal minima.
Instances For
Cached subtree minimum, with zero used for an empty leaf.
Instances For
Height counts edges, so a leaf has height zero.
Instances For
Structural storage in scalar slots, including the list representation: a leaf has a tag and
a list reference; an internal node has a tag, minimum and child-list reference. Each list cell
has a tag, an entry and a next link. A key is counted as one scalar, not by its bit length.
There is no allocation of B slots at every node.
Instances For
Occupancy and cached-minimum invariants. Every non-root child is nonempty.
Instances For
Form a node, collapsing groups of zero or one child.
Instances For
Split into at most B consecutive nonempty blocks of at most k elements, using Mathlib's
List.splitLengths. The caller must ensure that B * k covers the input.
Instances For
Construct a static tree. For 2 ≤ B, no input keys are lost, and the height is at most
Nat.clog B xs.length. Sorting and distinctness are requirements for ordered search, not for
construction or its shape bounds.
Instances For
Total keys, child pointers, cached minima, node headers and list links use at most 14n+2
scalar slots. The numerical constant is independent of B. This is a structural bound,
not a word-RAM heap encoding or a bit-space bound for unbounded natural numbers.
Cached-minimum routing agrees with rightmost list search on every valid ordered tree.
The list search returns exactly the greatest stored key not exceeding the query.
Inclusive predecessor correctness for every sorted distinct input and every natural query.
Empty output is equivalent to having no stored key at or below the query.