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 a positive weight , and charge a move from to 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 . 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, is the number of keys, is a sequence of keys in , and is the number of points that GreedyASS adds on , starting from an empty history: its geometric cost, one unit per point, which includes one point per request.
This is Theorem 4.1 of the paper. Let be the least lazy-finger cost of over all BSTs on 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
As a BST: there is a single online BST algorithm, depending only on , such that for every initial tree on keys and every , its total cost (rotations plus one per request) is at most
In Lean, is Geometric.rowCost greedySweep 0 ∅ X for the sweep Geometric.greedySweep, 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
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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.Definitionstheorem 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 nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsThis is Theorem 4.2 of the paper. For positive weights and keys , let , both endpoints included, and
where the start key is arbitrary. Then for every such and ,
and the same holds with replaced by its infimum over all positive weightings. As a BST: there is a single online BST algorithm, depending only on , such that for every initial tree on keys, every , every positive weighting and every , its total cost is at most
The weights appear only in the bound: neither GreedyASS nor the BST algorithm knows them. In Lean, is WeightedFinger.costFrom w p X and the infimum is WeightedFinger.optimalCostFrom, which need not be attained.
The Lean statements
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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.Definitionstheorem 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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.Definitionstheorem 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 nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsThis is Corollary 1 of the paper, the case of unit weights. For every start key , with ,
As a BST: there is a single online BST algorithm, depending only on , whose total cost from every initial tree on keys, for every and every , is at most times the same sum, plus .
In Lean, the sum is Bounds.dynamicFingerCostFrom p X.
The Lean statements
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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.Definitionstheorem 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 nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsThe 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.rowCostgreedySweep 0 ∅ xs, the number of points that the sweep adds when run from an empty history at time . It bounds an explicit, executable function of the request sequence, and says nothing about trees, rotations or initial trees. These are the theoremslazy_tree,lazy_from,lazy_optimal,lazy_optimal_from,weighted,weighted_optimalanddynamic. - The realizations are about binary search trees.
bst,bst_weightedandbst_dynamicassert that there is an online algorithm in the rotation model of Chapter 5, and bound its total cost from every initial tree.pointerandpointer_weightedassert 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 points into a BST execution of cost at most (Results.normalized_simulation), or into a pointer execution of cost at most (Results.pointer_simulation). Their constants are the geometric constants multiplied through by these. They are not meant to be sharp.
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
The algorithm is chosen knowing only : before the initial tree, before the start key and the weights 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 .
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 .
- A unit per request. Every benchmark charges at least one per request:
LazyFinger.costFromcharges plus the edge distance, the weighted chargeWeightedFinger.chargeis , and the dynamic finger charge is . The paper’s weighted formula is a sum of logarithms alone, which is 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 . - The first request. The paper’s sums start from an unspecified . The library fixes it in each benchmark.
LazyFinger.coststarts the finger at the root of the tree.LazyFinger.costFrom,WeightedFinger.costFromandBounds.dynamicFingerCostFromtake an explicit start key , and the theorems hold for every valid . Choosing makes the first charge exactly (Results.repeated_key), which recovers the paper’s sums from , plus the unit per request. - Minimum and infimum.
LazyFinger.optimalCostandLazyFinger.optimalCostFromare infima of natural numbers over the trees on keys. They are attained (Results.optimal_attained), so they are minima, as in the paper.WeightedFinger.optimalCostFromis 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 howweightedfollows fromweighted_optimal. - Startup. The additive term is explicit and linear: 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 , must be less than . The weights need only be positive on ; 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 be a BST on keys, , and a sequence of keys of . Then , where is the lazy-finger cost of in with the finger starting at .
theorem lazy_from (t : Tree) (p : Nat) (xs : List Nat) (hp : p < t.size) (valid : ∀ x ∈ xs, x < t.size) : rowCost greedySweep 0 ∅ xs ≤ 120 * LazyFinger.costFrom t p xs + 15 * t.size := Performance.lazy_from t p xs hp validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsNeither nor 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 on keys and every sequence of its keys, , where the finger starts at the root.
theorem lazy_tree (t : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < t.size) : rowCost greedySweep 0 ∅ xs ≤ 120 * LazyFinger.cost t xs + 15 * t.size := Performance.lazy_tree t xs validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsFor the empty tree there are no valid requests, and both sides are .
Theorem (Theorem 4.1). For every and every sequence of keys less than , , where is the least root-start lazy-finger cost of over all BSTs on keys.
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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsTheorem (Theorem 4.1, any start). For every , , where is the least lazy-finger cost over all BSTs on keys with the finger starting at .
theorem lazy_optimal_from (n p : Nat) (xs : List Nat) (hp : p < n) (valid : ∀ x ∈ xs, x < n) : rowCost greedySweep 0 ∅ xs ≤ 120 * LazyFinger.optimalCostFrom n p xs + 15 * n := Performance.lazy_optimal_from n p xs hp validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsTheorem 4.2 is the weighted dynamic finger bound, first against the best weighting and then against each one.
Theorem (Theorem 4.2). For every and every sequence of keys less than , , where is the infimum of over all weightings that are positive on the keys.
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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsTheorem (Theorem 4.2, each weighting). For every weighting positive on the keys, every and every , .
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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsWith unit weights, and the minimum weight is , so the weighted charge becomes the dynamic finger charge (Results.unit_weights).
Theorem (Corollary 1). For every and every sequence of keys less than , , with .
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 validModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsThe 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 by a constant times the cost of the optimal static tree, plus . 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 there is an online BST algorithm such that, for every initial tree on keys and every sequence of keys less than , its total cost is at most , and also at most for every .
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 nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsThe constants are those of the geometric theorems pushed through the simulation :
Theorem (Theorem 4.2 for a BST, each weighting). For every there is an online BST algorithm such that, for every initial tree on keys, every , every weighting positive on the keys and every , its total cost is at most .
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 nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsTheorem (Corollary 1 for a BST). For every there is an online BST algorithm such that, for every initial tree on keys, every and every , its total cost is at most , with .
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 nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.Definitions- Total cost.
Algorithm.totalCostis rotations plus one per request, the conventional cost of Chapter 5. Each step is certified to perform a legalAccessof the request. - Every initial tree. The bound holds from every tree of size , 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 (Section 25.2).
Theorem (Theorems 4.1 and 4.2 on the pointer machine). For every there is a BST algorithm whose pointer-machine run, from every initial tree on keys and on every sequence of keys less than , is a legal pointer execution serving , with at most pointer instructions, and at most for every .
theorem pointer (n : Nat) : ∃ algorithm : Algorithm, ∀ initial : Tree, initial.size = n → ∀ xs : List Nat, (∀ x ∈ xs, x < n) → Pointer.Execution initial xs (Pointer.Lazy.Online.run algorithm [] (Pointer.Lazy.Online.initial initial) xs).1.current (Pointer.Lazy.Online.run algorithm [] (Pointer.Lazy.Online.initial initial) xs).2 ∧ (Pointer.Lazy.Online.run algorithm [] (Pointer.Lazy.Online.initial initial) xs).2 ≤ 23111160 * LazyFinger.optimalCost n xs + 3081471 * n ∧ ∀ p, p < n → ((Pointer.Lazy.Online.run algorithm [] (Pointer.Lazy.Online.initial initial) xs).2 : ℝ) ≤ 92444640 * WeightedFinger.optimalCostFrom n p xs + 3081471 * n := Performance.pointer nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsTheorem (Theorem 4.2 on the pointer machine, each weighting). The same, with for every and every weighting positive on the keys.
theorem pointer_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) → Pointer.Execution initial xs (Pointer.Lazy.Online.run algorithm [] (Pointer.Lazy.Online.initial initial) xs).1.current (Pointer.Lazy.Online.run algorithm [] (Pointer.Lazy.Online.initial initial) xs).2 ∧ ((Pointer.Lazy.Online.run algorithm [] (Pointer.Lazy.Online.initial initial) xs).2 : ℝ) ≤ 92444640 * WeightedFinger.costFrom w p xs + 3081471 * n := Performance.pointer_weighted nModels.Rotation, Models.Online, Models.Pointer.Machine, Models.Pointer.Lazy.Online.Definitions, Models.Pointer.Lazy.Online.Algorithm, Models.Geometric.Definitions, Models.Geometric.Online, Algorithms.GreedyASS.Algorithm, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Bounds.WeightedFinger.Definitions, Bounds.DynamicFinger.DefinitionsThe first conjunct says that the instructions form a Pointer.Execution that serves from the initial tree. The constants are , and . 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):
for every leaf-oriented tree whose leaves include the requests (Results.cost, Section 25.6). The benchmark Amortized.referenceCost 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.
- From ordinary trees to leaf-oriented ones. An ordinary BST on keys converts into a leaf-oriented tree with exactly 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 comparisonResults.cost_fromgives for every valid . Theorem 3.1 then giveslazy_fromwith constant , and . The paper’s Lemma 4.1 plays this role. - From one tree to the best tree.
lazy_treetakes to be the root. Since the minimum over trees is attained (Results.optimal_attainedandResults.optimal_from_attained), applying the one-tree bound to a minimizing tree giveslazy_optimalandlazy_optimal_from. - 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: . Combined withlazy_optimal_from, this isweighted_optimal, with constant . The infimum is below every weighting’s cost (Results.optimal_le), which givesweighted. Unit weights givedynamic. - 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 . GreedyASS knows nothing about : the tree exists only in the analysis.
The reference forest (Section 25.4). After the search for , delete from the path from the root to the leaf . The remaining subtrees form the forest . Between consecutive searches, becomes by merges up to the lowest common ancestor of and , and then splits down to : 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 . 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 to while the points stay fixed. Each merge may raise the item potential by at most , and each new root brings at most of virgin credit, so the events of the transition cost at most 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 per reference edge between consecutive searches, plus , plus 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 per leaf. Every column is accessed for the first time at most once, which costs at most per leaf. Together these give the startup term per leaf, and the per edge and per request give .
- 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 -competitiveness and 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.