Chapter 14Adaptive bounds
Dynamic optimality is a comparison with an unknown optimum. The classical results about splay trees instead compare an algorithm with explicit functions of the request sequence. Each function measures one kind of locality: recency (working set), frequency (static optimality) and spatial proximity to a fixed key (static finger). This chapter defines these functions and the corresponding properties of an Algorithm. It also proves the implications between them, which hold for every algorithm. Whether splaying has these properties is the subject of Section 24.2.
The chapter has two main results. The first is that the working-set bound is the strongest of the three: an algorithm that has it also has the other two, and therefore competes with every fixed BST. The second is the classical entropy lower bound for fixed trees, which makes “static optimality” mean what its name says. The introduction to Part II maps these benchmarks together with those of the later chapters, the relations between them, and the algorithms that meet them.
Let be any online BST algorithm. Suppose there are constants such that, from every initial tree on keys and for every sequence of valid requests, performs at most rotations, where the working-set number is one plus the number of distinct keys requested since the previous request for , or if has not been requested before (the working-set bound). Then, for new constants , the total cost of (rotations plus ) is at most
- , where is the number of requests for (static optimality);
- , for every finger at once (static finger);
- , where is the cost of serving in any fixed BST on the same keys, one unit per request plus the depth of the requested key.
In Lean, the three bounds are the properties HasWorkingSetBound, HasStaticOptimalityBound and HasStaticFingerBound of an Algorithm, and the fixed-tree cost is StaticTree.cost. Nothing about any specific algorithm is involved.
The Lean statements
theorem workingSet_implies_staticOptimality (a : Algorithm) (h : HasWorkingSetBound a) : HasStaticOptimalityBound a := … h.staticOptimality aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmictheorem staticOptimality_implies_staticFinger (a : Algorithm) (h : HasStaticOptimalityBound a) : HasStaticFingerBound a := … h.staticFinger aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmictheorem workingSet_implies_staticFinger (a : Algorithm) (h : HasWorkingSetBound a) : HasStaticFingerBound a := … h.staticFinger aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmic/-- Every algorithm with a working-set bound competes with every fixed BST onthe same ordered key universe, up to uniform constants and initialization. -/theorem workingSet_competes (a : Algorithm) (workingSet : HasWorkingSetBound a) : ∃ C D : Nat, ∀ t u xs, t.size = u.size → (∀ x ∈ xs, x < t.size) → (a.totalCost t xs : ℝ) ≤ (C : ℝ) * StaticTree.cost u xs + (D : ℝ) * t.size * (1 + (t.size.log2 : ℝ)) := … (workingSet.staticOptimality a).fixedTree aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.StaticTree.Definitions, Models.Pointer.MachineFor every binary search tree on keys and every sequence of requests to its keys, let be the number of requests for . Serving in without restructuring, at one unit per request plus the depth of the requested key, costs at least a third of the entropy bound:
In Lean, the left side is Bounds.staticCost and the right side is StaticTree.cost.
The Lean statement
theorem entropy_lower_bound (t : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < t.size) : Bounds.staticCost t.size xs ≤ 3 * (StaticTree.cost t xs : ℝ) := … entropy_le_cost t xs validModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.StaticTree.Definitions, Models.Pointer.Machine14.1 Conventions
All logarithms are base 2. The sequence functions use Nat.log2 (the floor of , with Nat.log2 0 = 0) where the original definitions are natural-number valued, and Real.logb 2 (with ) where they are real-valued. Every property has the same shape:
where = t.size. The second term is a startup allowance: it pays for an arbitrary initial tree, and it plays the role of the term in Sleator and Tarjan’s theorems.
14.2 The working-set bound
The working-set number of a request measures how recently its key was last requested, counted in distinct keys:
/-- First access has working-set number `n`; otherwise count distinct keyssince its last access, plus one. -/def workingSetNumber (n : Nat) (past : List Nat) (x : Nat) : Nat := if x ∈ past then 1 + (past.reverse.takeWhile (· != x)).eraseDups.length else nFor a request x with history past (oldest first):
- If
xhas not been requested before, its number isn, the number of keys in the tree. - Otherwise,
past.reverse.takeWhile (· != x)is the list of requests made since the most recent request forx, most recent first.eraseDupsremoves repetitions, so its length is the number of distinct keys requested since then. The working-set number is one more than that.
An immediately repeated request therefore has number , and in general the number is at most .
!=is the Boolean inequality given byBEq Nat, which agrees with≠on natural numbers.takeWhilestops at the most recent occurrence ofxand does not include it.- The counts
xitself. With it the number equals Sleator and Tarjan’s , where is the number of distinct keys accessed since the last access of . Iacono’s convention, the size of the working set including , is the same quantity. - First accesses. Sleator and Tarjan let be the number of distinct keys accessed before when is new; the library uses instead. This charges at most for each of at most first accesses, a total that the startup allowance already absorbs. The two conventions give the same property.
def workingSetSum (n : Nat) (past : List Nat) : List Nat → Nat | [] => 0 | x :: xs => 1 + (workingSetNumber n past x).log2 + workingSetSum n (past ++ [x]) xsThe working-set sum charges each request , where is its working-set number. The is needed: an immediate repeat has but still costs a comparison. The floor is harmless, since and are within a factor of of each other for . Like runFrom, the recursion appends each request to the history after charging it.
The property:
/-- Total working-set bound, with an initial-tree allowance. -/def HasWorkingSetBound (a : Algorithm) : Prop := ∃ C D : Nat, ∀ t xs, (∀ x ∈ xs, x < t.size) → a.cost t xs ≤ C * workingSetSum t.size [] xs + D * t.size * (1 + t.size.log2)Read: there are natural constants such that for every initial tree and every valid sequence, the rotation count of the algorithm is at most workingSetSum plus the startup allowance. This is Theorem 4 of Sleator and Tarjan (1985), the working-set theorem, as a property of an arbitrary algorithm, with the constants left existential.
- The cost is
a.cost(rotations), nota.totalCost. Since every request contributes at least toworkingSetSum, the two versions are equivalent; see the next theorem. - The constants are uniform over all initial trees, sizes and sequences. The working-set sum is computed with the size of the initial tree,
t.size, which never changes. - Validity
∀ x ∈ xs, x < t.sizeis a hypothesis, so the property says nothing about invalid requests.
Adding the request count does not change which algorithms have the property.
Theorem (rotations or total cost). An algorithm has the working-set bound if and only if there are constants such that its total cost, rotations plus one per request, is at most for every initial tree and every valid sequence.
/-- Charging one unit per request does not change which algorithms satisfy ourworking-set bound. Constants are uniform over initial trees and valid sequences. -/theorem workingSet_totalCost_iff (a : Algorithm) : HasWorkingSetBound a ↔ ∃ C D : Nat, ∀ t xs, (∀ x ∈ xs, x < t.size) → a.totalCost t xs ≤ C * workingSetSum t.size [] xs + D * t.size * (1 + t.size.log2) := BoundsBridge.normalized_workingSet_iff aBounds/Normalization/Abstract.lean and its importsThe proof uses xs.length ≤ workingSetSum n past xs, which holds because every term of the sum is at least . Going from rotations to total cost changes to ; the other direction keeps the constants. In contrast with dynamic optimality, the normalization is harmless here because the benchmark already charges every request.
14.3 Static optimality
Let be the number of times key occurs in a sequence of length . A static tree in which has depth about serves the sequence in time proportional to plus the empirical entropy of the access frequencies. The library defines this benchmark directly:
/-- Frequency entropy, with one unit per request. Zero-frequency terms vanish. -/noncomputable def Bounds.staticCost (n : Nat) (xs : List Nat) : ℝ := (xs.length : ℝ) + ∑ x ∈ Finset.range n, (xs.count x : ℝ) * Real.logb 2 ((xs.length : ℝ) / xs.count x)Zero frequencies. For a key that never occurs, xs.count x = 0, so the term is 0 * Real.logb 2 (m / 0). In Lean, m / 0 = 0 and Real.logb 2 0 = 0, and the term is either way. This matches the usual convention , as the docstring says. The sum ranges over all keys, but only keys that occur contribute.
/-- Static optimality in the frequency-entropy formulation, with the same`n(1 + floor(log₂ n))` initialization allowance as the working-set property. -/def HasStaticOptimalityBound (a : Algorithm) : Prop := ∃ C D : Nat, ∀ t xs, (∀ x ∈ xs, x < t.size) → (a.totalCost t xs : ℝ) ≤ (C : ℝ) * Bounds.staticCost t.size xs + (D : ℝ) * t.size * (1 + (t.size.log2 : ℝ))The property bounds the total cost , with the same startup allowance as the working-set property. The statement is in ; the natural-number constants and t.size.log2 are cast.
Sleator and Tarjan’s Theorem 2 assumes that every key is accessed at least once, and has no startup term: . The property above allows unused keys, and pays for them, and for the initial tree, with the startup allowance. For splay, Section 24.2 proves both this property and the paper’s form without startup, the latter under the explicit hypothesis that every key occurs.
14.4 Static finger
Fix a key , the finger. Requests close to in rank should be cheap:
/-- Static finger cost for the fixed inorder rank `f`, including one unit per request. -/noncomputable def Bounds.fingerCost (f : Nat) (xs : List Nat) : ℝ := (xs.map fun x : Nat => 1 + Real.logb 2 (Nat.dist x f + 1 : Nat)).sum/-- The constant factors are uniform over the initial tree, request sequence,and choice of fixed finger. -/def HasStaticFingerBound (a : Algorithm) : Prop := ∃ C D : Nat, ∀ t xs f, f < t.size → (∀ x ∈ xs, x < t.size) → (a.totalCost t xs : ℝ) ≤ (C : ℝ) * Bounds.fingerCost f xs + (D : ℝ) * t.size * (1 + (t.size.log2 : ℝ))Each request costs , where Nat.dist x f is on natural numbers. Distance is rank distance, the number of keys between and , not a difference of key values. With the implicit-key model this is the only meaningful choice, and it is the distance used in Sleator and Tarjan’s Theorem 3, where items are numbered in symmetric order.
The quantifier order matters. The constants come first, and then the bound holds for every finger f < t.size. A single algorithm with fixed constants competes with every finger simultaneously, as in the paper. The algorithm itself never learns f.
14.5 Dynamic finger
The dynamic finger bound replaces the fixed finger by the previous request: a request is cheap when it is close in rank to the one before it. The library defines the benchmark as a sequence function:
/-- Dynamic-finger charges for consecutive requests, including a unit perrequest. The predecessor of the first request is supplied explicitly. -/noncomputable def dynamicFingerCostFrom : Nat → List Nat → ℝ | _, [] => 0 | p, x :: xs => 1 + Real.logb 2 (Nat.dist p x + 1 : Nat) + dynamicFingerCostFrom x xsdynamicFingerCostFrom p xs charges each request the amount , with a real base-two logarithm, where is an explicitly supplied predecessor of the first request. The unit makes an immediately repeated request cost , as in every other benchmark of this chapter. The bound was proved for splay trees by Cole and coauthors (Cole et al. 2000; Cole 2000); that proof is not in the library. The library proves it instead for GreedyASS (Section 25.3), and for the optimal lazy-finger tree (Chapter 16), where it is the unit-weight case of the weighted dynamic finger bound of Chapter 15.
The property has the same shape as the others, with the start key quantified like the finger:
/-- The dynamic-finger property. The bound holds for every start key `p`; thechoice of `p` changes the sum by at most `1 + log₂ n`, which the startup termabsorbs, so fixing `p` instead would give an equivalent property. -/def HasDynamicFingerBound (a : Algorithm) : Prop := ∃ C D : Nat, ∀ t xs p, p < t.size → (∀ x ∈ xs, x < t.size) → (a.totalCost t xs : ℝ) ≤ (C : ℝ) * Bounds.dynamicFingerCostFrom p xs + (D : ℝ) * t.size * (1 + (t.size.log2 : ℝ))The bound must hold for every start key p < t.size. Changing p changes the sum by at most , which the startup term absorbs, so fixing p would give an equivalent property. No algorithm in the library is proved to have this property as stated: the GreedyASS theorem of Section 25.3 gives one algorithm for each number of keys , while the property asks for one algorithm for all .
Dynamic finger is stronger than static finger. A step from to is at most the step from to and back from to , because . Summing, each request’s finger term is counted at most twice:
Theorem (dynamic finger and static finger). For every finger , start key and sequence, the dynamic finger sum is at most twice the static finger sum plus . Starting at the finger, the extra term vanishes.
/-- For every finger `f`, start key `p` and sequence, the dynamic-finger sum isat most twice the static-finger sum, plus the start key's own finger term. -/theorem dynamicFinger_le_fingerCost (f p : Nat) (xs : List Nat) : dynamicFingerCostFrom p xs ≤ 2 * fingerCost f xs + Real.logb 2 (Nat.dist p f + 1 : Nat) := dynamicFingerCostFrom_le_fingerCost f p xsModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions/-- Starting at the finger, the start term vanishes. -/theorem dynamicFinger_le_fingerCost_self (f : Nat) (xs : List Nat) : dynamicFingerCostFrom f xs ≤ 2 * fingerCost f xs := dynamicFingerCostFrom_finger_le f xsModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions14.6 The logarithmic baseline
Every bound above is at most what a balanced tree pays, about per request whatever the sequence. The library names this baseline, and the corresponding property:
/-- One unit plus `log₂ n` per request. -/noncomputable def Bounds.logCost (n : Nat) (xs : List Nat) : ℝ := (xs.length : ℝ) * (1 + Real.logb 2 n)/-- Logarithmic amortized cost per request, with the usual startup allowance. -/def HasLogarithmicBound (a : Algorithm) : Prop := ∃ C D : Nat, ∀ t xs, (∀ x ∈ xs, x < t.size) → (a.totalCost t xs : ℝ) ≤ (C : ℝ) * Bounds.logCost t.size xs + (D : ℝ) * t.size * (1 + (t.size.log2 : ℝ))logCost n xs is . An algorithm has the logarithmic bound when it pays amortized per request, after the usual startup allowance. The balanced static tree of Chapter 19 meets the baseline on every sequence, and every static tree pays it on some sequence. The dynamic trees of Part III have logarithmic height under updates; a search-cost statement for them against logCost is not formalized.
14.7 The unified charge
Sleator and Tarjan’s Theorem 5 combines the three localities: each access is charged the smallest of its three logarithmic costs. The library defines this benchmark in Bounds/Unified/Abstract.lean, next to the others, so that the bound is a property of a sequence and not of splaying:
/-- One request's best frequency, static-finger, or working-set logarithm. -/noncomputable def unifiedCharge (n f : Nat) (original past : List Nat) (x : Nat) : ℝ := 1 + min (Real.logb 2 (workingSetNumber n past x)) (min (Real.logb 2 ((original.length : ℝ) / original.count x)) (Real.logb 2 (Nat.dist x f + 1 : Nat)))/-- Frequencies use the entire sequence, while recency uses only the prefix. -/noncomputable def unifiedSum (n f : Nat) (original : List Nat) : List Nat → List Nat → ℝ | _, [] => 0 | past, x :: xs => unifiedCharge n f original past x + unifiedSum n f original (past ++ [x]) xsFor a request with history past, unifiedCharge is
$$
Frequencies come from the whole sequence original, so is its length and the number of occurrences of in it. Recency comes from the prefix past, which unifiedSum extends one request at a time while keeping original fixed. This mixes offline information (frequencies) with online information (recency), as the paper’s bound does. An algorithm measured against it still sees only the past; the frequencies are used by the analysis alone.
- These logarithms are real:
Real.logb 2 (workingSetNumber …)is not the floor used inworkingSetSum. - If did not occur in
original, then ,m / 0 = 0in Lean, andlogb 2 0 = 0, so the minimum could collapse to . Theorems apply it asunifiedSum n f xs [] xs, sooriginalis the very sequence being summed over, and every occurs in it. - Since the minimum is taken per access,
unifiedSumis at most each of the three earlier sums up to constants, and can be much smaller than all of them: a sequence that alternates between a hot spot near and a small working set far away is cheap for one charge on one half and for another on the other half.
Splaying satisfies this bound (Results.unified, Section 24.2). The library defines no Has…Bound property for it, because no implication involving it is proved.
14.8 Comparison with a fixed tree
Static optimality is usually explained as “as good as the best fixed BST for the access frequencies”. The library makes the comparison literal. First, a fixed tree’s search cost:
/-- Search a fixed tree from its root each time, charging one per request andone per downward pointer move (the rank's `Tree.depth`). No rotations orreturn-to-root moves occur. -/def cost (t : Tree) (xs : List Nat) : Nat := (xs.map fun x => t.depth x + 1).sumcost charges each request one unit plus its depth, the number of edges from the root to the requested rank (Tree.depth, defined in Chapter 1).
This benchmark is exactly the cost of an actual pointer-machine execution that never restructures.
Theorem (a fixed tree is a pointer execution). For every tree t and every valid sequence xs, there is a pointer-machine execution that serves xs from t, ends in t, and costs exactly StaticTree.cost t xs.
/-- This benchmark is exactly realized by searches that never rotate the tree. -/theorem pointer_execution (t : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < t.size) : Pointer.Execution t xs t (StaticTree.cost t xs) := execution t xs validModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.StaticTree.Definitions, Models.Pointer.MachineEach request is served by walking down depth t x edges, visiting x, and stopping. That is Pointer.Serves t t x (depth t x + 1) in the pointer model, with the unit request charge. The next search starts again at the root, and returning there is free in that model. The final tree is t itself.
Entropy is a lower bound on the cost of every fixed tree, up to a factor of .
Theorem (entropy lower bound). For every tree t and every valid sequence xs, , where is the size of t.
theorem entropy_lower_bound (t : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < t.size) : Bounds.staticCost t.size xs ≤ 3 * (StaticTree.cost t xs : ℝ) := entropy_le_cost t xs validModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.StaticTree.Definitions, Models.Pointer.MachineThe proof is the prefix-code argument. Give key the weight , two bits for each comparison step, including the final one. These weights sum to at most in every shape. Gibbs’ inequality bounds the entropy by , so .
The bound is tight up to that factor: some fixed tree achieves the entropy bound itself.
Theorem (entropy upper bound). For every and every sequence xs of requests less than , there is a tree t on keys with .
/-- Conversely, some fixed tree achieves normalized frequency entropy withconstant one. Unobserved keys are retained and empty sequences are included. -/theorem entropy_upper_bound (n : Nat) (xs : List Nat) (valid : ∀ x ∈ xs, x < n) : ∃ t : Tree, t.size = n ∧ (StaticTree.cost t xs : ℝ) ≤ Bounds.staticCost n xs := entropy_tree n xs validModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.StaticTree.Definitions, Models.Pointer.MachineThe constant is one, and there is no additive term. The tree has all keys, including those never requested, and the statement includes and the empty sequence, where both sides are . Combined with the lower bound, the best fixed tree for xs costs between and , which is the classical statement that optimal static trees cost . The optimal static tree itself, and this two-sided bound for it, are in Chapter 19 (Results.optCost_entropy).
Consequently, a working-set algorithm competes with every fixed BST.
Theorem (working set beats every fixed tree). If an algorithm has the working-set bound, then there are constants such that, for every initial tree t, every tree u of the same size and every valid sequence xs, the algorithm’s total cost from t is at most .
/-- Every algorithm with a working-set bound competes with every fixed BST onthe same ordered key universe, up to uniform constants and initialization. -/theorem workingSet_competes (a : Algorithm) (workingSet : HasWorkingSetBound a) : ∃ C D : Nat, ∀ t u xs, t.size = u.size → (∀ x ∈ xs, x < t.size) → (a.totalCost t xs : ℝ) ≤ (C : ℝ) * StaticTree.cost u xs + (D : ℝ) * t.size * (1 + (t.size.log2 : ℝ)) := (workingSet.staticOptimality a).fixedTree aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.StaticTree.Definitions, Models.Pointer.MachineHere t is the algorithm’s initial tree and u is any comparison tree of the same size; they need not be equal. The constants are uniform over t, u and xs. The proof goes through static optimality (below) and entropy_lower_bound, which turns into .
14.9 Implications between the bounds
The following implications hold for every algorithm and use nothing about splaying. They are inequalities between sequence functions, lifted to properties.
Theorem (implications). For every algorithm, the working-set bound implies static optimality, and static optimality implies the static finger bound. Hence the working-set bound implies the static finger bound. The dynamic finger bound also implies the static finger bound, and the static finger bound implies the logarithmic bound.
theorem workingSet_implies_staticOptimality (a : Algorithm) (h : HasWorkingSetBound a) : HasStaticOptimalityBound a := h.staticOptimality aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmictheorem staticOptimality_implies_staticFinger (a : Algorithm) (h : HasStaticOptimalityBound a) : HasStaticFingerBound a := h.staticFinger aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmictheorem workingSet_implies_staticFinger (a : Algorithm) (h : HasWorkingSetBound a) : HasStaticFingerBound a := h.staticFinger aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmictheorem dynamicFinger_implies_staticFinger (a : Algorithm) (h : HasDynamicFingerBound a) : HasStaticFingerBound a := h.staticFinger aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmic/-- Every distance between two of `n` keys is less than `n`, so thestatic-finger sum is at most the logarithmic baseline. -/theorem fingerCost_le_log (n f : Nat) (xs : List Nat) (hf : f < n) (valid : ∀ x ∈ xs, x < n) : fingerCost f xs ≤ logCost n xs := fingerCost_le_logCost n f xs hf validModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmictheorem staticFinger_implies_logarithmic (a : Algorithm) (h : HasStaticFingerBound a) : HasLogarithmicBound a := h.logarithmic aModels.Rotation, Models.Online, Bounds.WorkingSet, Bounds, Bounds.DynamicFinger.Definitions, Bounds.Logarithmic- Working set ⇒ static optimality. The key inequality is $$ The proof groups the charges by key. Between consecutive accesses to , the working-set number is at most the time elapsed (the gap). The gaps of key sum to at most , and a finite Jensen inequality bounds by . First accesses are charged to the startup term. The constants become .
- Static optimality ⇒ static finger. Apply the weighted entropy inequality with weights , which sum to at most on both sides of together. This gives for every , and the constants become .
- Working set ⇒ static finger is the composition.
- Dynamic finger ⇒ static finger follows from the inequality of the previous section, taking the start key equal to the finger. The constants become .
- Static finger ⇒ logarithmic. Two keys among are less than apart, so each static-finger term is at most , and the constants do not change.
In Sleator and Tarjan’s paper, Theorems 2 and 3 are proved directly from the access lemma, with suitably chosen weights. The library instead proves the working-set theorem for splay once and derives static optimality and static finger through these algorithm-independent implications. The splay-specific sharper forms, without startup when every key occurs, are proved separately in Section 24.2.
14.10 Transfer to the pointer machine
Working-set guarantees proved in the rotation model also hold for the causal pointer simulation of Section 7.6.
Theorem (working set on the pointer machine). If an algorithm has the working-set bound in the rotation model, then there are constants such that its online pointer-machine implementation costs at most , for every initial tree and every valid sequence.
/-- Working-set guarantees proved on shapes transfer to the chosen causalpointer implementation, with uniform constants. -/theorem workingSet (a : RotationBST.Algorithm) (bound : HasWorkingSetBound a) : ∃ C D : Nat, ∀ t xs, (∀ x ∈ xs, x < t.size) → (run a [] (initial t) xs).2 ≤ C * workingSetSum t.size [] xs + D * t.size * (1 + t.size.log2) := workingSet_transfer a boundThe left-hand side is the cost of the online pointer implementation of a, including requests and every pointer instruction. Postponed rotations are not executed at the end, and they need not be: the pointer execution serves every request without them. The proof combines simulation () with the hypothesis on and with , giving constants . The constants hold for every algorithm, independently of . For splaying specifically, Section 24.1 gives a more direct pointer implementation with better constants.
14.11 What is not formalized
Two well-known results are absent. The dynamic finger theorem for splay trees (Cole et al. 2000; Cole 2000) is not in the library: its proof is long. The benchmark itself is defined above, and other structures are proved to meet it. The unified bound (Iacono 2001; Bădoiu et al. 2007) replaces the fixed finger by the distance to recently accessed keys; it is open whether splay trees satisfy it. Both are mentioned here only to place the formalized bounds. One further result appears as a dashed arrow in the map of the bounds and is listed in the library’s roadmap: the theorem of Chmel et al. (2026), a 2026 preprint, that splay trees are -competitive. The lower-bound side of Part II is Chapter 17.