Binary Search Trees in Lean Check a result Declarations Bibliography Lean source

Chapter 25 · GreedyASS · Section 25.3GreedyASS and the finger bounds

A static BST searched with a lazy finger starts each search where the previous one ended, instead of at the root (Chapter 15). Its cost on a request sequence is the total length of the walks between consecutive requests, and the best static tree for a given sequence is a strong benchmark. It is at least as good as the best root-finger tree, up to a factor two, and it adapts to locality as well. Bose, Douïeb, Iacono and Langerman (2016) showed that it is equivalent, up to constant factors, to a weighted dynamic finger bound: assign each key kk a positive weight wkw_k, and charge a move from xx to yy the logarithm of the total weight between them, divided by the smaller weight of the two endpoints.

Iacono and Langerman (2016) proved that GreedyASS (Section 25.1) meets this benchmark. On every sequence it costs at most a constant times the cost of the best lazy-finger tree for that sequence, plus O(n)O(n). This is a “static optimality” theorem with respect to a much stronger static benchmark, and it implies the dynamic finger bound by taking all weights equal. Since GreedyASS is an online BST algorithm through the simulation of Section 25.2, the bounds hold for an online BST. The library formalizes the paper’s Theorem 3.1, its leaf-oriented core, and the consequences Theorem 4.1, Theorem 4.2 and Corollary 1. This section states those consequences. Theorem 3.1 is the subject of Section 25.6, and Section 25.4 and Section 25.5 prepare it.

In all three results below, nn is the number of keys, X=x1,…,xmX = x_1, \dots, x_m is a sequence of keys in {0,…,n−1}\{0, \dots, n-1\}, and PG(X)P_G(X) is the number of points that GreedyASS adds on XX, starting from an empty history: its geometric cost, one unit per point, which includes one point per request.

Key result · Iacono and Langerman 2016
GreedyASS is competitive with the best lazy-finger tree

This is Theorem 4.1 of the paper. Let LF∗(X)\mathrm{LF}^*(X) be the least lazy-finger cost of XX over all BSTs on nn keys, where the first search starts at the root and each request costs one plus the number of edges walked from the previous request. Then

PG(X)  ≤  120 LF∗(X)+15 n.P_G(X) \;\le\; 120\,\mathrm{LF}^*(X) + 15\,n .

As a BST: there is a single online BST algorithm, depending only on nn, such that for every initial tree on nn keys and every XX, its total cost (rotations plus one per request) is at most

722280 LF∗(X)+96303 n.722280\,\mathrm{LF}^*(X) + 96303\,n .

In Lean, PG(X)P_G(X) is Geometric.rowCost greedySweep 0 ∅ X for the sweep Geometric.greedySweep, LF∗\mathrm{LF}^* is LazyFinger.optimalCost (a minimum, which is attained), and the BST algorithm is an Algorithm with cost Algorithm.totalCost. The second conjunct of bst also gives the weighted bound of the next box.

The Lean statements
theoremGeometric.GreedyASS.Performance.Results.lazy_optimalpropext · Classical.choice · Quot.soundAlgorithms/GreedyASS/Performance/Abstract.lean:24
theorem lazy_optimal (n : Nat) (xs : List Nat) (valid : ∀ x ∈ xs, x < n) :    rowCost greedySweep 0 ∅ xs ≤ 120 * LazyFinger.optimalCost n xs + 15 * n := …  Performance.lazy_optimal n xs valid
theoremGeometric.GreedyASS.Performance.Results.bstpropext · Classical.choice · Quot.soundAlgorithms/GreedyASS/Performance/Abstract.lean:47
theorem bst (n : Nat) :    ∃ algorithm : Algorithm, ∀ initial : Tree, initial.size = n →      ∀ xs : List Nat, (∀ x ∈ xs, x < n) →        algorithm.totalCost initial xs ≤ 722280 * LazyFinger.optimalCost n xs + 96303 * n ∧        ∀ p, p < n → (algorithm.totalCost initial xs : ℝ) ≤          2889120 * WeightedFinger.optimalCostFrom n p xs + 96303 * n := …  Performance.bst n
24 definitions in 7 chapters · reading list
Key result · Iacono and Langerman 2016
GreedyASS has the weighted dynamic finger property

This is Theorem 4.2 of the paper. For positive weights w0,…,wn−1w_0, \dots, w_{n-1} and keys x,yx, y, let W[x,y]=∑min⁡(x,y)≤k≤max⁡(x,y)wkW[x, y] = \sum_{\min(x,y) \le k \le \max(x,y)} w_k, both endpoints included, and

WFw(p,X)  =  ∑j=1m(1+log⁡2W[xj−1,xj]min⁡(wxj−1,wxj)),x0=p,\mathrm{WF}_w(p, X) \;=\; \sum_{j=1}^{m} \Bigl(1 + \log_2 \frac{W[x_{j-1}, x_j]}{\min(w_{x_{j-1}}, w_{x_j})}\Bigr), \qquad x_0 = p,

where the start key p<np < n is arbitrary. Then for every such ww and pp,

PG(X)  ≤  480 WFw(p,X)+15 n,P_G(X) \;\le\; 480\,\mathrm{WF}_w(p, X) + 15\,n,

and the same holds with WFw(p,X)\mathrm{WF}_w(p, X) replaced by its infimum over all positive weightings. As a BST: there is a single online BST algorithm, depending only on nn, such that for every initial tree on nn keys, every p<np < n, every positive weighting ww and every XX, its total cost is at most

2889120 WFw(p,X)+96303 n.2889120\,\mathrm{WF}_w(p, X) + 96303\,n .

The weights appear only in the bound: neither GreedyASS nor the BST algorithm knows them. In Lean, WFw(p,X)\mathrm{WF}_w(p, X) is WeightedFinger.costFrom w p X and the infimum is WeightedFinger.optimalCostFrom, which need not be attained.

The Lean statements
theoremGeometric.GreedyASS.Performance.Results.weighted_optimalpropext · Classical.choice · Quot.soundAlgorithms/GreedyASS/Performance/Abstract.lean:33
theorem weighted_optimal (n p : Nat) (xs : List Nat)    (hp : p < n) (valid : ∀ x ∈ xs, x < n) :    (rowCost greedySweep 0 ∅ xs : ℝ) ≤ 480 * WeightedFinger.optimalCostFrom n p xs + 15 * n := …  Performance.weighted_optimal n p xs hp valid
theoremGeometric.GreedyASS.Performance.Results.weightedpropext · Classical.choice · Quot.soundAlgorithms/GreedyASS/Performance/Abstract.lean:38
theorem weighted (w : Nat → ℝ) (n p : Nat) (xs : List Nat)    (positive : ∀ k < n, 0 < w k) (hp : p < n) (valid : ∀ x ∈ xs, x < n) :    (rowCost greedySweep 0 ∅ xs : ℝ) ≤ 480 * WeightedFinger.costFrom w p xs + 15 * n := …  Performance.weighted w n p xs positive hp valid
theoremGeometric.GreedyASS.Performance.Results.bst_weightedpropext · Classical.choice · Quot.soundAlgorithms/GreedyASS/Performance/Abstract.lean:68
theorem bst_weighted (n : Nat) :    ∃ algorithm : Algorithm, ∀ initial : Tree, initial.size = n →      ∀ p, p < n → ∀ w : Nat → ℝ, (∀ k < n, 0 < w k) →      ∀ xs : List Nat, (∀ x ∈ xs, x < n) →        (algorithm.totalCost initial xs : ℝ) ≤ 2889120 * WeightedFinger.costFrom w p xs + 96303 * n := …  Performance.bst_weighted n
19 definitions in 7 chapters · reading list
Key result · Iacono and Langerman 2016
GreedyASS has the dynamic finger property

This is Corollary 1 of the paper, the case of unit weights. For every start key p<np < n, with x0=px_0 = p,

PG(X)  ≤  480∑j=1m(1+log⁡2(∣xj−xj−1∣+1))+15 n.P_G(X) \;\le\; 480 \sum_{j=1}^{m} \Bigl(1 + \log_2\bigl(|x_j - x_{j-1}| + 1\bigr)\Bigr) + 15\,n .

As a BST: there is a single online BST algorithm, depending only on nn, whose total cost from every initial tree on nn keys, for every p<np < n and every XX, is at most 28891202889120 times the same sum, plus 96303 n96303\,n.

In Lean, the sum is Bounds.dynamicFingerCostFrom p X.

The Lean statements
theoremGeometric.GreedyASS.Performance.Results.dynamicpropext · Classical.choice · Quot.soundAlgorithms/GreedyASS/Performance/Abstract.lean:43
theorem dynamic (n p : Nat) (xs : List Nat) (hp : p < n) (valid : ∀ x ∈ xs, x < n) :    (rowCost greedySweep 0 ∅ xs : ℝ) ≤ 480 * Bounds.dynamicFingerCostFrom p xs + 15 * n := …  Performance.dynamic n p xs hp valid
theoremGeometric.GreedyASS.Performance.Results.bst_dynamicpropext · Classical.choice · Quot.soundAlgorithms/GreedyASS/Performance/Abstract.lean:75
theorem bst_dynamic (n : Nat) :    ∃ algorithm : Algorithm, ∀ initial : Tree, initial.size = n →      ∀ p, p < n → ∀ xs : List Nat, (∀ x ∈ xs, x < n) →        (algorithm.totalCost initial xs : ℝ) ≤ 2889120 * Bounds.dynamicFingerCostFrom p xs + 96303 * n := …  Performance.bst_dynamic n
16 definitions in 7 chapters · reading list

The three boxes are enough to confirm the results: their statements use only the benchmarks of Chapter 15, the GreedyASS sweep of Section 25.1, and the online algorithms of Part I. The rest of this section has three parts. Section 25.3.1 explains the conventions and the two forms of each statement, geometric and BST. Section 25.3.2 to Section 25.3.4 state every theorem of Algorithms/GreedyASS/Performance/Abstract.lean, in English and in Lean. Section 25.3.5 derives them from Theorem 3.1, and Section 25.3.6 gives a map of the proof of Theorem 3.1 across the next three sections.

25.3.1 Reading the statements

25.3.1.1 Geometric bounds and their realizations

Each result comes in two forms.

  • The geometric form is about GreedyASS itself. Its left side is Geometric.rowCost greedySweep 0 ∅ xs, the number of points that the sweep adds when run from an empty history at time 00. It bounds an explicit, executable function of the request sequence, and says nothing about trees, rotations or initial trees. These are the theorems lazy_tree, lazy_from, lazy_optimal, lazy_optimal_from, weighted, weighted_optimal and dynamic.
  • The realizations are about binary search trees. bst, bst_weighted and bst_dynamic assert that there is an online algorithm in the rotation model of Chapter 5, and bound its total cost from every initial tree. pointer and pointer_weighted assert the same for an actual execution on the pointer machine of Chapter 7, where navigation is charged too.

The realizations are proved by feeding Geometric.greedyASS to the simulation theorems of Section 25.2, which turn PP points into a BST execution of cost at most 6019 P+6018 n6019\,P + 6018\,n (Results.normalized_simulation), or into a pointer execution of cost at most 192593 P+192576 n192593\,P + 192576\,n (Results.pointer_simulation). Their constants are the geometric constants multiplied through by these. They are not meant to be sharp.

What the realizations say

The statements of bst, bst_weighted, bst_dynamic, pointer and pointer_weighted begin with ∃ algorithm : Algorithm. They assert that some online BST algorithm has the bound, and do not name it. The algorithm built in the proof is the simulation of GreedyASS, chosen with Classical.choose, but a reader who only checks the statements learns that an online BST achieving the lazy-finger and weighted dynamic finger bounds exists, not that the BST obtained from GreedyASS is that algorithm. The geometric theorems are the ones about GreedyASS by name.

25.3.1.2 One causal policy, chosen first

The order of the quantifiers in the realizations matters. In bst_weighted it is

∃ algorithm  ∀ initial  ∀ p  ∀ w  ∀ X.\exists\, \mathit{algorithm}\ \ \forall\, \mathit{initial}\ \ \forall\, p\ \ \forall\, w\ \ \forall\, X .

The algorithm is chosen knowing only nn: before the initial tree, before the start key pp and the weights ww of the benchmark, and before the requests. It is causal: as an Algorithm, each step sees only the past requests, the current tree and the current request (Chapter 5). So one online algorithm satisfies the bound for all weightings at once, exactly as splaying satisfies the static optimality bound for the frequencies it never sees (Section 24.2). In bst, likewise, the same algorithm satisfies both the lazy-finger bound and the weighted bound for every pp.

These are not dynamic optimality claims. The benchmarks are static: the best fixed tree with a lazy finger, or the best fixed weighting. Whether GreedyASS is within a constant factor of the offline optimum is open, and the library does not claim it (Section 25.1).

25.3.1.3 Conventions

The library makes several normalizations explicit that the paper leaves to the O(⋅)O(\cdot).

  • A unit per request. Every benchmark charges at least one per request: LazyFinger.costFrom charges 11 plus the edge distance, the weighted charge WeightedFinger.charge is 1+log⁡2(⋅)1 + \log_2(\cdot), and the dynamic finger charge is 1+log⁡2(∣xj−xj−1∣+1)1 + \log_2(|x_j - x_{j-1}| + 1). The paper’s weighted formula is a sum of logarithms alone, which is 00 on a sequence that repeats one key, while GreedyASS pays one point per request. The unit makes the inequalities true as stated, with no hidden term in mm.
  • The first request. The paper’s sums start from an unspecified s0s_0. The library fixes it in each benchmark. LazyFinger.cost starts the finger at the root of the tree. LazyFinger.costFrom, WeightedFinger.costFrom and Bounds.dynamicFingerCostFrom take an explicit start key pp, and the theorems hold for every valid pp. Choosing p=x1p = x_1 makes the first charge exactly 11 (Results.repeated_key), which recovers the paper’s sums from j=2j = 2, plus the unit per request.
  • Minimum and infimum. LazyFinger.optimalCost and LazyFinger.optimalCostFrom are infima of natural numbers over the trees on nn keys. They are attained (Results.optimal_attained), so they are minima, as in the paper. WeightedFinger.optimalCostFrom is an infimum of real numbers over positive weightings, and no optimal weighting is assumed to exist. A bound in terms of an infimum is the stronger statement: it implies the bound for each weighting, which is how weighted follows from weighted_optimal.
  • Startup. The additive term is explicit and linear: 15 n15\,n in the geometric form, which pays for the initial credits of the potential and for the first access to each column (Section 25.3.6). In the realizations it also absorbs the simulation’s startup, which rotates an arbitrary initial tree into a fixed shape.
  • Valid keys. All requests, and the start key pp, must be less than nn. The weights need only be positive on {0,…,n−1}\{0, \dots, n-1\}; values outside are never read, because masses are sums over intervals between valid keys.

25.3.2 The geometric bounds

Theorem 4.1 is the lazy-finger bound. It comes in four variants: against one fixed tree or against the best tree, and with the finger starting at the root or at a given key. The basic one is against a fixed tree with a given start key.

Theorem (one tree, any start). Let tt be a BST on nn keys, p<np < n, and XX a sequence of keys of tt. Then PG(X)≤120 LFt(p,X)+15 nP_G(X) \le 120\,\mathrm{LF}_t(p, X) + 15\,n, where LFt(p,X)\mathrm{LF}_t(p, X) is the lazy-finger cost of XX in tt with the finger starting at pp.

Neither tt nor pp is an input of the sweep: the same point count is bounded by the cost of every tree with every start key.

Theorem (one tree, root start). For every BST tt on nn keys and every sequence XX of its keys, PG(X)≤120 LFt(X)+15 nP_G(X) \le 120\,\mathrm{LF}_t(X) + 15\,n, where the finger starts at the root.

For the empty tree there are no valid requests, and both sides are 00.

Theorem (Theorem 4.1). For every nn and every sequence XX of keys less than nn, PG(X)≤120 LF∗(X)+15 nP_G(X) \le 120\,\mathrm{LF}^*(X) + 15\,n, where LF∗(X)\mathrm{LF}^*(X) is the least root-start lazy-finger cost of XX over all BSTs on nn keys.

Theorem (Theorem 4.1, any start). For every p<np < n, PG(X)≤120 LF∗(p,X)+15 nP_G(X) \le 120\,\mathrm{LF}^*(p, X) + 15\,n, where LF∗(p,X)\mathrm{LF}^*(p, X) is the least lazy-finger cost over all BSTs on nn keys with the finger starting at pp.

Theorem 4.2 is the weighted dynamic finger bound, first against the best weighting and then against each one.

Theorem (Theorem 4.2). For every p<np < n and every sequence XX of keys less than nn, PG(X)≤480 WF∗(p,X)+15 nP_G(X) \le 480\,\mathrm{WF}^*(p, X) + 15\,n, where WF∗(p,X)\mathrm{WF}^*(p, X) is the infimum of WFw(p,X)\mathrm{WF}_w(p, X) over all weightings ww that are positive on the keys.

Theorem (Theorem 4.2, each weighting). For every weighting ww positive on the keys, every p<np < n and every XX, PG(X)≤480 WFw(p,X)+15 nP_G(X) \le 480\,\mathrm{WF}_w(p, X) + 15\,n.

With unit weights, W[x,y]=∣x−y∣+1W[x, y] = |x - y| + 1 and the minimum weight is 11, so the weighted charge becomes the dynamic finger charge (Results.unit_weights).

Theorem (Corollary 1). For every p<np < n and every sequence XX of keys less than nn, PG(X)≤480∑j(1+log⁡2(∣xj−xj−1∣+1))+15 nP_G(X) \le 480 \sum_j \bigl(1 + \log_2(|x_j - x_{j-1}| + 1)\bigr) + 15\,n, with x0=px_0 = p.

Further consequences

The best lazy-finger tree is within a factor two of the best root-finger tree (Results.optimal_root_finger, Chapter 15), so lazy_optimal also bounds PG(X)P_G(X) by a constant times the cost of the optimal static tree, plus O(n)O(n). The library does not state this combination as a separate theorem about GreedyASS; it is a one-line consequence of the two statements.

25.3.3 One online BST algorithm

The realizations in the rotation model come in three statements. The first carries both Theorem 4.1 and Theorem 4.2, against the best tree and the best weighting.

Theorem (Theorems 4.1 and 4.2 for a BST). For every nn there is an online BST algorithm such that, for every initial tree on nn keys and every sequence XX of keys less than nn, its total cost is at most 722280 LF∗(X)+96303 n722280\,\mathrm{LF}^*(X) + 96303\,n, and also at most 2889120 WF∗(p,X)+96303 n2889120\,\mathrm{WF}^*(p, X) + 96303\,n for every p<np < n.

The constants are those of the geometric theorems pushed through the simulation T≤6019 P+6018 nT \le 6019\,P + 6018\,n:

6019⋅120=722280,6019⋅480=2889120,6019⋅15+6018=96303.6019 \cdot 120 = 722280, \qquad 6019 \cdot 480 = 2889120, \qquad 6019 \cdot 15 + 6018 = 96303 .

Theorem (Theorem 4.2 for a BST, each weighting). For every nn there is an online BST algorithm such that, for every initial tree on nn keys, every p<np < n, every weighting ww positive on the keys and every XX, its total cost is at most 2889120 WFw(p,X)+96303 n2889120\,\mathrm{WF}_w(p, X) + 96303\,n.

Theorem (Corollary 1 for a BST). For every nn there is an online BST algorithm such that, for every initial tree on nn keys, every p<np < n and every XX, its total cost is at most 2889120∑j(1+log⁡2(∣xj−xj−1∣+1))+96303 n2889120 \sum_j \bigl(1 + \log_2(|x_j - x_{j-1}| + 1)\bigr) + 96303\,n, with x0=px_0 = p.

Reading the Lean
  • Total cost. Algorithm.totalCost is rotations plus one per request, the conventional cost of Chapter 5. Each step is certified to perform a legal Access of the request.
  • Every initial tree. The bound holds from every tree of size nn, not only from a tree chosen by the algorithm.
  • Uncharged planning. As everywhere in the rotation model, the computation that decides which rotations to perform is free. The algorithm built in the proof replays the geometric history, and is not executable.
  • The algorithms may differ. The three theorems are separate existence statements. Their witnesses are built the same way in the proofs, but the statements do not say that they are one algorithm. Within bst, the two bounds are for the same algorithm.

25.3.4 On the pointer machine

The rotation model charges only rotations. The pointer machine of Chapter 7 charges every pointer move as well. The causal transformer Online.run runs a rotation-model algorithm on the pointer machine, starting from Online.initial, and the simulation bounds its cost by 192593 P+192576 n192593\,P + 192576\,n (Section 25.2).

Theorem (Theorems 4.1 and 4.2 on the pointer machine). For every nn there is a BST algorithm whose pointer-machine run, from every initial tree on nn keys and on every sequence XX of keys less than nn, is a legal pointer execution serving XX, with at most 23111160 LF∗(X)+3081471 n23111160\,\mathrm{LF}^*(X) + 3081471\,n pointer instructions, and at most 92444640 WF∗(p,X)+3081471 n92444640\,\mathrm{WF}^*(p, X) + 3081471\,n for every p<np < n.

Theorem (Theorem 4.2 on the pointer machine, each weighting). The same, with 92444640 WFw(p,X)+3081471 n92444640\,\mathrm{WF}_w(p, X) + 3081471\,n for every p<np < n and every weighting ww positive on the keys.

The first conjunct says that the instructions form a Pointer.Execution that serves XX from the initial tree. The constants are 192593⋅120=23111160192593 \cdot 120 = 23111160, 192593⋅480=92444640192593 \cdot 480 = 92444640 and 192593⋅15+192576=3081471192593 \cdot 15 + 192576 = 3081471. The library has no pointer version of Corollary 1, but pointer_weighted with unit weights gives it, by Results.unit_weights.

25.3.5 From Theorem 3.1 to the finger bounds

All the theorems above rest on one inequality, the paper’s Theorem 3.1. It compares GreedyASS with a lazy finger on a leaf-oriented reference tree, whose keys are its leaves (Section 25.4):

PG(X)  ≤  24 RCT(X)+15 leaves(T),P_G(X) \;\le\; 24\,\mathrm{RC}_T(X) + 15\,\mathrm{leaves}(T),

for every leaf-oriented tree TT whose leaves include the requests (Results.cost, Section 25.6). The benchmark Amortized.referenceCost RCT(X)\mathrm{RC}_T(X) charges one unit per request plus the number of reference edges between consecutive requests, and nothing for reaching the first request. The derivation of the finger bounds has four steps.

  1. From ordinary trees to leaf-oriented ones. An ordinary BST tt on nn keys converts into a leaf-oriented tree convert t\mathtt{convert}\ t with exactly nn leaves, one per key, in the same order (Results.population). The conversion at most doubles distances, up to an additive constant (Results.distance), and the benchmark comparison Results.cost_from gives RCconvert t(X)≤5 LFt(p,X)\mathrm{RC}_{\mathtt{convert}\,t}(X) \le 5\,\mathrm{LF}_t(p, X) for every valid pp. Theorem 3.1 then gives lazy_from with constant 24⋅5=12024 \cdot 5 = 120, and 15 leaves=15 n15\,\mathrm{leaves} = 15\,n. The paper’s Lemma 4.1 plays this role.
  2. From one tree to the best tree. lazy_tree takes pp to be the root. Since the minimum over trees is attained (Results.optimal_attained and Results.optimal_from_attained), applying the one-tree bound to a minimizing tree gives lazy_optimal and lazy_optimal_from.
  3. From trees to weights. The characterization theorem of the lazy-finger paper (Results.characterization_from, Chapter 15) says that the best tree and the best weighting agree up to constants: LF∗(p,X)≤4 WF∗(p,X)\mathrm{LF}^*(p, X) \le 4\,\mathrm{WF}^*(p, X). Combined with lazy_optimal_from, this is weighted_optimal, with constant 120⋅4=480120 \cdot 4 = 480. The infimum is below every weighting’s cost (Results.optimal_le), which gives weighted. Unit weights give dynamic.
  4. From points to trees. The simulation theorems of Section 25.2, applied to Geometric.greedyASS, give the realizations.

Only the first step uses anything specific to this paper. The other three are short proofs in Performance/Geometric.lean, Performance/Simulation.lean and Performance/Corollaries.lean, from theorems of other chapters.

25.3.6 A map of the proof of Theorem 3.1

Theorem 3.1 is proved by a potential function, which the next three sections build. Fix a leaf-oriented reference tree TT. GreedyASS knows nothing about TT: the tree exists only in the analysis.

The reference forest (Section 25.4). After the search for xix_i, delete from TT the path from the root to the leaf xix_i. The remaining subtrees form the forest FiF_i. Between consecutive searches, Fi−1F_{i-1} becomes FiF_i by merges up to the lowest common ancestor of xi−1x_{i-1} and xix_i, and then splits down to xix_i: exactly one event per reference edge between the two leaves (Results.transition). This is how the lazy-finger cost enters the argument.

Items, colors and potential (Section 25.5). Every key accessed so far is an item. Its most recent access point is classified by its position in the GreedyASS point set (external, glancing or internal), and it receives a color (red, green, blue or purple) and a value. The values are node counts in the reference tree, from the item’s leaf up to the root of its forest component, or up to the lowest common ancestor of its neighbors in the point set. In addition, every virgin root of the forest, one whose range has not been accessed since it became a root, carries a credit of 1212. The potential is the sum of all item values and all virgin credits.

Paying for each row (Section 25.6). Each request is served in two phases. In Phase I the forest changes from Fi−1F_{i-1} to FiF_i while the points stay fixed. Each merge may raise the item potential by at most 1212, and each new root brings at most 1212 of virgin credit, so the ee events of the transition cost at most 24e24e in total, by the budget identity Results.birth_budget (the paper’s Lemma 3.3). In Phase II GreedyASS adds its row while the forest stays fixed. The new points are paid by a decrease of the potential: the values of the accessed items fall and the touched virgin roots lose their credit. The exceptions are few; for instance, a row touches at most two non-virgin roots (the paper’s Lemma 3.7). The result is the paper’s Lemma 3.19 (Results.step): each row costs, amortized, at most 2424 per reference edge between consecutive searches, plus 2424, plus 33 for each key accessed for the first time.

Summing over the requests (Results.stream), the potential telescopes. It is never negative, and its initial value is at most 1212 per leaf. Every column is accessed for the first time at most once, which costs at most 33 per leaf. Together these give the startup term 12+3=1512 + 3 = 15 per leaf, and the 2424 per edge and per request give 24 RCT(X)24\,\mathrm{RC}_T(X).

Compared with the paper
  • Formalized. Theorem 3.1, Theorem 4.1, Theorem 4.2 and Corollary 1, each with explicit constants, in the geometric model and as BST and pointer-machine executions.
  • Formalized later in the book. Theorem 4.3, which combines the weighted bound with O(log⁡log⁡n)O(\log\log n)-competitiveness and O(log⁡n)O(\log n) worst-case time per search, is the subject of Chapter 31. It needs Tango with a linear startup term (Section 26.3), the ComboBST combination (Chapter 29) and the deamortization (Chapter 30); the result is an abstract BST-operation counterpart, without the paper’s storage clauses.
  • Normalizations. The unit per request, the explicit first finger, the explicit linear startup and the infimum over weightings are described in Section 25.3.1.3. The constants are explicit and not optimized.