Sleator–Tarjan's Access Lemma, Static Optimality, and Update Bounds #
This module formalizes the potential-method amortized analysis of self-adjusting splay trees due to Sleator and Tarjan ([ST85b], Sections 2–3, pp. 656–665).
Given any positive weight assignment w : α → ℝ (∀ x, 0 < w x — a purely analytical parameter
not stored in the tree), each subtree t has size subtreeWeight w t, binary-logarithm rank
nodeRank w t = Real.logb 2 (subtreeWeight w t) ([ST85b], Section 2, p. 658,
Footnote 1), and tree potential potential w t summing nodeRank w over all internal subtrees of
t. Following Sleator and Tarjan's rotation-count BST access model ([ST85b],
Section 2, p. 658), the rotation-plus-one access cost splayCost res = max res.rotations 1 charges
one unit when no rotations occur (for the root access) and the exact edge-rotation count otherwise;
this is a structural BST rotation cost, not a Word-RAM or Turing-machine running time.
Main definitions #
subtreeWeight,nodeRank,potential: parameterized subtree weight, base-2 logarithmic node rank, and rank-sum potential ([ST85b], Section 2, p. 658).splayCost,splaySeq,splaySeqCost,splaySeqRotations: single-splay and multi-access sequence rotation-cost measures.unitWeight,unitPotential: unit-weight specialization (w = fun _ => 1) used for the Balance Theorem and dynamic dictionary updates ([ST85b], Section 2, Theorem 1, p. 659; Section 3, Lemma 2 and Theorem 6, pp. 663–665).
Main results #
splayUp_amortized_le,splayUp_splayCost_amortized_le,splay_splayCost_amortized_le,exists_mem_splay_splayCost_amortized_le,splay_splayCost_amortized_le_of_mem: Sleator and Tarjan's Access Lemma ([ST85b], Section 2, Lemma 1, p. 658) in rotation-count and rotation-plus-one (splayCost) forms.potential_sub_potential_le_sum_logb: fixed-weight net potential drop boundΦ(t₁) - Φ(t₂) ≤ ∑_{y ∈ t₁} log₂(W / w(y))([ST85b], Section 2, p. 659), with the potential boundssum_logb_weight_le_potentialandpotential_le_sum_logb_of_le.splaySeqCost_le_fixed_weights: the general fixed-weight access-sequence rotation-cost bound∑ⱼ (3 log₂(W / w(xⱼ)) + 1) + ∑_{y ∈ t} log₂(W / w(y))for accesses to present items ([ST85b], Section 2, p. 659), from which the static finger bound follows.potential_le_potential_of_le,potential_reweight_root_le: potential change under weight reassignment; decreasing weights, or moving weight onto the root key without changing the total, does not increase the potential ([ST85b], Section 2, proof of Theorem 4, p. 660; Section 3, Lemma 2, pp. 663–664).splaySeqCost_le_balance: Balance Theorem ([ST85b], Section 2, Theorem 1, p. 659), bounding the rotation-plus-one access cost of any sequence ofmaccesses (present or absent) on ann-element splay tree by(3m + n) log₂ n + m.splaySeqCost_le_static_optimality: Static Optimality Theorem ([ST85b], Section 2, Theorem 2, p. 659), bounding the rotation-plus-one access cost ofmaccesses to present items (each accessed at least once) bym + 4 ∑_{y ∈ t} q(y) log₂(m / q(y)).contains_unitPotential_amortized_le,split_unitPotential_amortized_le,join_unitPotential_amortized_le,insert_unitPotential_amortized_le,erase_unitPotential_amortized_le: unit-weight (w = 1) specialization of Sleator and Tarjan's Update Lemma ([ST85b], Section 3, Lemma 2, pp. 663–664, wherelog₂ 1 = 0eliminates Lemma 2's external-item potential term), extended to total set-idempotentinsertanderase.minimum_unitPotential_amortized_le,successor_unitPotential_amortized_le: companion unit-weight rotation bounds derived from the Access Lemma ([ST85b], Section 2, Lemma 1, p. 658) forCslib.DataStructure.OrderedSet.spec(minimumandsuccessorare not part of Lemma 2).
References #
- [ST85b] Daniel Dominic Sleator and Robert Endre Tarjan, Self-Adjusting Binary Search Trees, Journal of the ACM 32(3), Sections 2–3, pp. 656–665, 1985.
Subtree Weights, Node Ranks, and Rank-Sum Potential #
Sum of item weights w over all internal nodes of a BinaryTree α
(s(x) in [ST85b], Section 2, p. 658).
Base-2 logarithmic rank r(x) = log₂ s(x) of a subtree ([ST85b], Section 2,
p. 658, Footnote 1).
Sleator–Tarjan potential Φ(t) = ∑_x r(x) summing nodeRank w over all internal subtrees of
t ([ST85b], Section 2, p. 658).
Local restructurings that preserve subtreeWeight leave the ranks of all proper ancestors in
ctx unchanged, so the global potential difference equals the local potential difference.
Sleator–Tarjan rotation-plus-one access cost for a single splay ([ST85b],
Section 2, p. 658): the number of edge rotations performed, or 1 when zero rotations are
performed. Counts BST rotations (plus 1 at 0), not machine instructions.
Elementary AM-GM Binary-Logarithm Inequality and Bottom-Up Access Lemma #
Bottom-Up Access Lemma ([ST85b], Section 2, Lemma 1, p. 658):
for any positive weights w, bottom-up splaying of (x, l, r) through ctx has amortized
rotation cost at most 3 (r(root) - r(u)) when ctx = [] and at most 3 (r(root) - r(u)) + 1
when ctx ≠ [].
Sleator–Tarjan rotation-plus-one (splayCost) Access Lemma on splayUp ([ST85b],
Section 2, Lemma 1, p. 658).
Unit weight w(x) = 1 ([ST85b], Section 2, Theorem 1, p. 659; Section 3,
Theorem 6, p. 665).
Rank-sum potential under unit weights (unitWeight).
Access Lemma on Search Trees, Balance Theorem, and Static Optimality #
On an Ordered search tree, subtreeWeight w t equals the Finset sum of w over
elements t.
Access Lemma (focused-subtree form) ([ST85b], Section 2, Lemma 1, p. 658):
if focusSearch x t [] = some f, splaying t at x has amortized rotation-plus-one cost
(splayCost) at most 3 (r(t) - r(f.sub)) + 1.
Access Lemma (general key-weight form) ([ST85b], Section 2, Lemma 1, p. 658;
Section 3, p. 664): on any non-empty Ordered tree t and any query x (present or absent),
there exists a key u ∈ elements t (equal to x if x ∈ elements t, and otherwise unspecified)
such that the amortized rotation-plus-one cost (splayCost) of splay x t is at most
3 log₂(W / w(u)) + 1.
Access Lemma for present keys ([ST85b], Section 2, Lemma 1, p. 658):
when x ∈ elements t in an Ordered tree t, splaying t at x has amortized rotation-plus-one
cost (splayCost) at most 3 log₂(W / w(x)) + 1.
Rotation-count corollary of splay_splayCost_amortized_le_of_mem.
Amortized rotation bound for splayMin on a non-empty tree.
Amortized rotation bound for splayMax on a non-empty tree.
Fixed-Weight Potential Drop, Balance Theorem, and Static Optimality #
Lower potential bound: each node's rank is at least the logarithm of its own key's weight, so
∑ y ∈ t, log₂ w(y) ≤ Φ(t) ([ST85b], Section 2, p. 659).
Upper potential bound: if the total weight is at most W, every rank is at most log₂ W, so
Φ(t) ≤ ∑ y ∈ t, log₂ W ([ST85b], Section 2, p. 659).
Fixed-Weight Potential Drop Bound ([ST85b], Section 2, p. 659):
between any two Ordered trees t₁ and t₂ representing the same set of keys, if
0 < W and subtreeWeight w t₁ ≤ W, the net potential decrease satisfies
potential w t₁ - potential w t₂ ≤ ∑ y ∈ elements t₁, log₂(W / w(y)).
Execute a sequence of splay operations xs starting from t, returning the final tree
and the list of per-operation SplayResults.
Total Sleator–Tarjan rotation-plus-one access cost (∑ max rotations 1) across an access
sequence xs ([ST85b], Section 2, p. 658).
Total edge rotations across an access sequence xs.
Balance Theorem ([ST85b], Section 2, Theorem 1, p. 659):
for any non-empty Ordered tree t of n = (elements t).card elements and any sequence xs
of m = xs.length accesses (whether successful or unsuccessful), the total rotation-plus-one
access cost satisfies splaySeqCost xs t ≤ (3m + n) log₂ n + m.
Static Optimality Theorem ([ST85b], Section 2, Theorem 2, p. 659):
for any Ordered splay tree t and any access sequence xs of present keys (∀ x ∈ xs, x ∈ t)
in which every key in t is accessed at least once (∀ y ∈ elements t, 1 ≤ xs.count y),
the total rotation-plus-one access cost is bounded by the empirical Shannon access-frequency sum:
splaySeqCost xs t ≤ m + 4 ∑ y ∈ elements t, q(y) log₂(m / q(y)), where m = xs.length and
q(y) = xs.count y.
Fixed-weight access-sequence bound ([ST85b], Section 2, p. 659; the common
argument behind Theorems 1–3): for any positive weights w with total tree weight at most W,
a sequence xs of accesses to present keys has rotation-plus-one access cost at most the summed
Access Lemma bounds plus the net potential drop,
splaySeqCost xs t ≤ ∑ⱼ (3 log₂(W / w(xⱼ)) + 1) + ∑ y ∈ t, log₂(W / w(y)).
Weight Changes #
The weights in the Access Lemma are analysis parameters, so a proof may change them between
operations at the cost of the resulting potential change ([ST85b], Section 3,
Lemma 2, pp. 663–664: decreasing the weight of an item does not increase the potential). The
Working Set Theorem ([ST85b], Section 2, Theorem 4, pp. 659–660) reassigns weights
after each access while the accessed item is at the root; potential_reweight_root_le bounds
that potential change.
Pointwise smaller weights on the keys of t give a smaller total weight.
Decreasing weights never increases the potential ([ST85b], Section 3, Lemma 2,
pp. 663–664): if 0 < w' y ≤ w y for every key y of t, then Φ_{w'}(t) ≤ Φ_w(t).
Root weight reassignment ([ST85b], Section 2, proof of Theorem 4, p. 660):
if the key x is at the root of an Ordered tree t, and new positive weights w' keep the total
weight of t unchanged while not increasing the weight of any other key of t, then the
potential does not increase. The root's size is unchanged, and every other node's subtree avoids
x, so its size can only decrease.
Unit-Weight Update Lemma Specialization and OrderedSet Companion Bounds #
Sleator and Tarjan's Update Lemma ([ST85b], Section 3, Lemma 2, pp. 663–664) states
general positive-weight bounds for access, join, split, insert (assuming x ∉ t), and
delete (assuming x ∈ t) under a multi-tree potential incorporating ∑_{i ∉ trees} log₂ w(i).
At unit weights (unitWeight, where log₂ 1 = 0), that external-item potential term vanishes.
Below we prove this unit-weight specialization for contains, split, join, and total
set-idempotent insert and erase, together with companion unit-weight bounds for minimum and
successor derived directly from the Access Lemma (Lemma 1, p. 658).
Unit-weight (w = 1) specialization of the access bound in [ST85b], Section 3,
Lemma 2, pp. 663–664, for contains.
Companion unit-weight amortized rotation bound for minimum, derived from the Access Lemma
([ST85b], Section 2, Lemma 1, p. 658) via splayMin_rotations_amortized_le (minimum
is not part of Section 3, Lemma 2).
Unit-weight (w = 1) specialization of the split bound in [ST85b], Section 3,
Lemma 2, pp. 663–664.
Unit-weight (w = 1) specialization of the join bound in [ST85b], Section 3,
Lemma 2, pp. 663–664.
Unit-weight (w = 1) specialization of the insert bound in [ST85b], Section 3,
Lemma 2, pp. 663–664, extended from x ∉ elements t to total set-idempotent insert.
Unit-weight (w = 1) specialization of the delete bound in [ST85b], Section 3,
Lemma 2, pp. 663–664, extended from x ∈ elements t to total set-idempotent erase.
Companion unit-weight amortized rotation bound for successor (splaying x, followed by
splayMin on the right subtree when root ≤ x), derived from the Access Lemma
([ST85b], Section 2, Lemma 1, p. 658; successor is not part of Section 3,
Lemma 2).