Documentation

CslibFrontier.DataStructure.SplayTree.WilberFirst

Wilber's First Lower Bound (Interleave Bound) and Bit-Reversal Separation #

This module formalizes Wilber's first lower bound (the Interleave Bound, [Wil89]) on the cost of any binary search tree execution serving an access sequence xs, together with an explicit bit-reversal sequence family witnessing an Ω(m log n) lower bound across all BST algorithms.

Proof overview #

Fix any static Ordered reference BST P storing the same key set as the dynamic BSTs. For each key y ∈ elements P, partition subtreeAt y P into its strict left subtree leftRegion P y and rightRegion P y = {y} ∪ rightSubtree(y). Both regions and their union are order-convex in elements P. Restricting xs to keys in subtreeAt y P and labeling left-region accesses by false and right-region accesses by true, interleave P y xs counts adjacent left/right alternations, and wilberFirst P xs = ∑ y ∈ elements P, interleave P y xs.

For every node y with nonempty leftRegion P y and every dynamic BST T on elements P, let v = topNode (elements (subtreeAt y P)) T be the highest node of y's reference subtree in T. The transition point transitionPoint? P y T is the highest node in T of the opposite region from v (topNode (rightRegion P y) T if v ∈ leftRegion P y, and topNode (leftRegion P y) T otherwise). Three structural lemmas drive the lower bound:

  1. Injectivity (transitionPoint?_inj): Distinct nodes y₁ ≠ y₂ of P have distinct transition points in T.
  2. Stability (transitionPoint?_stable): As long as transitionPoint? P y T is untouched during a TouchedStep, both the transition point and its side remain unchanged.
  3. Forced touch (mem_touched_of_mem_side): Any access landing on the transition point's side must touch the transition point itself.

A 1-bit credit induction along any TouchedExecution yields interleave P y xs ≤ 2 * touchCount y without any additive loss; summing over y ∈ elements P and applying injectivity at each time step gives wilberFirst P xs ≤ 2 * e.cost, hence wilberFirst P xs ≤ 2 * e.touchedCost and wilberFirst P xs ≤ 2 * e.stepCost for every atomic BSTExecution.

Bit-reversal witness #

Instantiating P = completeBST 0 (d + 1) (with 2^(d + 1) - 1 keys {1, …, 2^(d + 1) - 1}) and the r-fold repeated bit-reversal permutation bitRevLeaves 0 d of its 2^d odd leaves yields the exact interleave sum wilberFirst = d * r * 2^d - (2^d - 1), forcing d * m - (2^d - 1) ≤ 2 * e.stepCost (Ω(m log n)) for every BST execution on m = r * 2^d accesses.

Main definitions #

Main results #

References #

Boolean Alternation Counts #

Number of adjacent flips (a ≠ b) in a list of booleans.

@[simp]

Reference-Tree Regions and Interleave Bound #

Strict left-subtree region L(y) of key y in reference tree P.

Right region R(y) = {y} ∪ rightSubtree(y) of key y in reference tree P.

def Cslib.DataStructure.SplayTree.regionSides {α : Type u_1} [LinearOrder α] (P : BinaryTree α) (y : α) :
List α → List Bool

Project an access sequence xs onto the left (false) and right (true) regions of y in reference tree P, ignoring accesses outside subtreeAt y P.

def Cslib.DataStructure.SplayTree.interleave {α : Type u_1} [LinearOrder α] (P : BinaryTree α) (y : α) (xs : List α) :

Number of left/right preferred-child interleaves of xs at reference node y in P ([Wil89]).

Wilber's First Lower Bound (Interleave Bound) ([Wil89]): sum of interleave P y xs over all nodes y of a static reference BST P.

Transition Points and Their Three Structural Lemmas #

Wilber's transition point tp(y, T) together with its region side (false for leftRegion, true for rightRegion). Let v = topNode (elements (subtreeAt y P)) T; the transition point is the highest node in T of the region opposite to v.

theorem Cslib.DataStructure.SplayTree.transitionPoint?_inj {α : Type u_1} [LinearOrder α] {P T : BinaryTree α} (hP : SearchTree.Ordered P) (hT : SearchTree.Ordered T) (helem : SearchTree.elements T = SearchTree.elements P) {y₁ y₂ w : α} {s₁ s₂ : Bool} (hy₁ : y₁ ∈ SearchTree.elements P) (hy₂ : y₂ ∈ SearchTree.elements P) (hL₁ : (leftRegion P y₁).Nonempty) (hL₂ : (leftRegion P y₂).Nonempty) (h₁ : transitionPoint? P y₁ T = some (w, s₁)) (h₂ : transitionPoint? P y₂ T = some (w, s₂)) :
y₁ = y₂

Injectivity of transition points: Distinct reference nodes y₁ ≠ y₂ cannot share the same transition point in any ordered BST T on elements P.

1-Bit Credit Induction and Wilber's First Lower Bound #

Wilber's First Lower Bound (Interleave Bound) ([Wil89]) for any touched-subtree execution: for every static ordered reference BST P on the same key set as T₀, wilberFirst P xs ≤ 2 * e.cost.

Wilber's First Lower Bound (Interleave Bound) ([Wil89]) for touched-node cost of any pointer-and-rotation BSTExecution.

Wilber's First Lower Bound (Interleave Bound) ([Wil89]) for atomic step cost of any pointer-and-rotation BSTExecution.

Bit-Reversal Ω(m log n) Lower-Bound Witness #

Complete binary search tree of height d on keys {lo + 1, …, lo + 2 ^ d - 1}.

Interleave two lists element by element ([a₀, b₀, a₁, b₁, …]).

d-bit reversal of i (low d bits reversed into MSB-first order).

The 2 ^ d leaves of completeBST lo (d + 1) in bit-reversal order.

bitRevLeaves 0 d lists the 2 ^ d odd leaves 2 * bitRev d i + 1 for i = 0, …, 2^d - 1.

Exact evaluation of Wilber's first lower bound on the r-fold repeated bit-reversal access sequence (List.replicate r (bitRevLeaves lo d)).flatten with reference tree completeBST lo (d + 1) (r ≥ 1): wilberFirst = d * r * 2 ^ d - (2 ^ d - 1).

theorem Cslib.DataStructure.SplayTree.bitRev_stepCost_lower_bound {d r : ℕ} (hr : 1 ≤ r) {T₀ : BinaryTree ℕ} (hT₀ : SearchTree.Ordered T₀) (helem : SearchTree.elements T₀ = SearchTree.elements (completeBST 0 (d + 1))) (e : BSTExecution T₀ (List.replicate r (bitRevLeaves 0 d)).flatten) :
d * (r * 2 ^ d) - (2 ^ d - 1) ≤ 2 * e.stepCost

Ω(m log n) BST lower bound via bit-reversal accesses ([Wil89]): for any d ≥ 1, r ≥ 1, any ordered initial BST T₀ on {1, …, 2^(d + 1) - 1} (n = 2^(d + 1) - 1 keys), and any pointer-and-rotation execution e serving the m = r * 2^d bit-reversal accesses (List.replicate r (bitRevLeaves 0 d)).flatten, d * m - (2^d - 1) ≤ 2 * e.stepCost.