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

Chapter 26 · Tango trees · Section 26.3Tango with linear startup

The Tango bound of Section 26.2 has two terms: a factor O(log⁡log⁡n)O(\log\log n) on the cost of the best offline execution, and an additive startup term (14L+6) n(14L + 6)\,n, where L=log⁡2(⌊log⁡2n⌋+1)L = \log_2(\lfloor\log_2 n\rfloor + 1). The startup term pays for the first time each reference node receives a preference, so it is Θ(nlog⁡log⁡n)\Theta(n \log\log n). That is harmless for competitiveness, but not when Tango is used as one ingredient of a larger bound. Theorem 4.3 of Iacono and Langerman combines GreedyASS with Tango and claims a total cost of

O(n+min⁡(WF∗(X), OPT(X)log⁡log⁡n)),O\Bigl(n + \min\bigl(\mathrm{WF}^*(X),\ \mathrm{OPT}(X)\log\log n\bigr)\Bigr),

with an additive O(n)O(n), not O(nlog⁡log⁡n)O(n\log\log n). When the optimum is small, an nlog⁡log⁡nn\log\log n startup on the Tango side would dominate. So the combination needs a Tango whose startup is linear.

This section proves that bound. The algorithm is the Tango of Section 26.2 with one change: within each request, the preference updates are applied from the bottom of the search path upward instead of from the top down. With that order, almost every first setting is paid by a credit local to the node’s reference subtree, and the credits of a balanced reference tree sum to at most 42n42n.

Key result · Demaine et al. 2007
Tango with a linear startup term

For every nn there is a Tango policy for the balanced reference tree on nn keys, fixed before any request is known, whose step applies each request’s preference updates bottom-up, with the following property. Let XX be any sequence of mm requests, and take any offline execution that serves XX with RR rotations from any tree on nn keys. Then the policy, run from its reference tree, serves XX with total cost (rotations plus one per request) at most

42 n  +  (70 L+20) (R+m),L=log⁡2(⌊log⁡2n⌋+1).42\,n \;+\; \bigl(70\,L + 20\bigr)\,(R + m), \qquad L = \log_2(\lfloor\log_2 n\rfloor + 1).

Compared with Section 26.2, the startup term (14L+4) n(14L+4)\,n of the policy becomes 42n42n, and the factor 56L+1656L+16 becomes 70L+2070L+20.

A policy starts from its own reference tree. The second theorem turns any policy into an online algorithm in the sense of Chapter 5 that performs exactly the policy’s rotations when it starts from the reference tree. From any other tree of the same size it costs at most mm, plus the policy’s rotations, plus 2n2n. Combining the two gives an online BST, chosen before the initial tree and the requests, of total cost at most 44n+(70L+20)(R+m)44n + (70L+20)(R+m) from every initial tree on nn keys, against every offline execution from that tree. The library states this combination as one theorem, exists_competitive_linear.

In Lean, the policy is a Tango.Policy whose step is BottomUp.serve, its cost is that of Policy.run, the comparator is any Execution, and the online algorithm is an Algorithm with cost Algorithm.totalCost.

The Lean statements
theoremTango.BottomUp.Results.balanced_policypropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:163
theorem balanced_policy (n : Nat) :    ∃ p : Policy (balanced n),      (∀ past s x, p.step past s x = serve s (balanced n) past x) ∧      ∀ (start finish : Tree) (xs : List Nat) (offline : Nat), start.size = n →        RotationBST.Execution start xs finish offline →          ((p.run xs).2 : ℝ) + xs.length ≤ 42 * n +            (70 * Real.logb 2 (Nat.log2 n + 1) + 20) * (offline + xs.length : Nat) := …  RotationBST.Tango.BottomUp.balanced_policy n
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.Algorithm.Rotation.Results.rotation_algorithmpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Rotation/Abstract.lean:9
/-- A causal rotation algorithm follows the marked policy exactly from itsreference tree. Any other same-size initial tree pays at most one 2n reset.Reconstructing private marks from history has uncharged abstract planning cost. -/theorem rotation_algorithm {reference : Tree} (p : Policy reference) :    ∃ a : RotationBST.Algorithm,      (∀ xs, (∀ x ∈ xs, x < reference.size) →        a.runFrom [] reference xs = ((p.run xs).1.tree, (p.run xs).2)) ∧      ∀ saved : Tree, saved.size = reference.size → ∀ xs, (∀ x ∈ xs, x < reference.size) →        a.totalCost saved xs ≤ xs.length + (p.run xs).2 + 2 * saved.size := …  p.rotation_algorithm
theoremTango.Algorithm.Results.exists_competitive_linearpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Abstract.lean:63
/-- **Tango with linear startup.** The same statement with startup `44n`instead of `O(n log log n)`, at a larger coefficient. The algorithm runs thebottom-up policy (`Tango.BottomUp`), which pays for first preference settingsfrom local credit, at most `42n` on the balanced reference; reaching thereference from another initial tree costs at most `2n` more. -/theorem exists_competitive_linear (n : Nat) :    ∃ A : Algorithm, ∀ {start finish : Tree} {xs : List Nat} {offline : Nat},      start.size = n → Execution start xs finish offline →        (A.totalCost start xs : ℝ) ≤          (70 * Real.logb 2 (Nat.log2 n + 1) + 20) * (offline + xs.length : Nat) + 44 * n := …  Tango.exists_online_linear_bound n
90 definitions in 13 chapters, 35 more in internal modules · reading list
Main result
First preference settings cost linear total

Let PP be any reference tree of height hh, and serve a sequence XX of mm keys of PP with bottom-up preference updates, starting from the all-singleton marking. Each preference update gets an amortized charge from its actual position in the evolving auxiliary trees. The charges of all first settings together are at most

∑v∈P(8log⁡2h(v)+2)  +  m (14log⁡2h+4),\sum_{v \in P} \bigl(8\log_2 h(v) + 2\bigr) \;+\; m\,\bigl(14\log_2 h + 4\bigr),

where h(v)h(v) is the height of vv’s subtree in PP. The first term is a one-time credit per node; the second is one ancestor-attachment charge per request. For the balanced reference tree on nn keys, the credit sum is at most 42n42n.

In Lean, the first-setting charge is Initialization.firstLogCharge of the bottom-up log BottomUp.log, and the credit sum is Initialization.localAllowance.

The Lean statements
theoremTango.BottomUp.Results.startup_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:127
theorem startup_bound (reference : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    firstLogCharge (initial reference) (log reference [] xs) ≤      localAllowance reference + xs.length * (14 * Real.logb 2 (height reference) + 4) := …  RotationBST.Tango.BottomUp.startup_bound reference xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.Initialization.Local.Results.balanced_localAllowancepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:21
theorem balanced_localAllowance (n : Nat) : localAllowance (balanced n) ≤ 42 * n := …  RotationBST.Tango.Initialization.balanced_localAllowance n
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions
34 definitions in 8 chapters, 12 more in internal modules · reading list

If you only want to confirm the result, the first box is enough. Its statements use the rotation model, the online algorithms of Part I, and the Policy interface and marked trees of Section 26.2, and the checking page lists those definitions. The rest of the section explains where the nlog⁡log⁡nn\log\log n came from and how the bottom-up order removes it. Section 26.3.1 is an overview with a small example. Section 26.3.2 and Section 26.3.3 set up the accounting: a credit per reference node, and an exact charge per preference update, which also refines the top-down analysis of Section 26.2. Section 26.3.4 defines the bottom-up policy and Section 26.3.5 proves the linear startup. Section 26.3.6 packages a policy as an online algorithm and points to the combination of Chapter 31, which uses this section.

The definitions are in Algorithms/Tango/Preferences/Initialization/, Algorithms/Tango/Algorithm/Initialization/ and Algorithms/Tango/Algorithm/BottomUp/, each with a Definitions/Abstract.lean; the online packaging is in Algorithms/Tango/Algorithm/Rotation/Abstract.lean.

26.3.1 Overview

26.3.1.1 Where the startup term comes from

Recall the accounting of Section 26.2. A request for xx produces an update log: one entry for each node on the reference search path to xx whose preference changes (Tango.preferenceUpdates). An entry is either a switch, where a node’s preferred child changes sides, or a first setting, where a node that has never been observed receives a preference. The policy contract charges every entry 14log⁡2h+414\log_2 h + 4, and every request 3log⁡2h+13\log_2 h + 1 for the final splay. Switches total Wilber’s interleave quantity, which is O(OPT+m)O(\mathrm{OPT} + m). First settings number at most nn, once per node, so they cost (14log⁡2h+4) n(14\log_2 h + 4)\,n. That is the startup term.

The flat charge for a first setting is pessimistic. A first setting at vv only joins: it merges the auxiliary tree of vv’s newly preferred child into the auxiliary tree that contains vv. In the library’s analysis a join costs at most 8log⁡2s+28\log_2 s + 2 amortized, where ss is the size of the merged auxiliary tree. The question is how large ss is.

In the original top-down order, the updates of a request run from the reference root toward xx. When the update reaches vv, every ancestor of vv on the search path already prefers the side toward xx, so vv already lies in the root’s auxiliary tree. The merged tree contains all of vv’s ancestors, so s≥depth(v)s \ge \mathrm{depth}(v). Most nodes of a balanced tree are deep, so most first settings really cost Θ(log⁡h)=Θ(log⁡log⁡n)\Theta(\log h) = \Theta(\log\log n).

26.3.1.2 Bottom-up order

Apply the same updates in reverse, from xx up to the reference root. When the update reaches a node vv that is set for the first time, consider its parent uu on the path.

  • uu is new as well. Then uu’s update comes later, and uu has no preference yet, so the edge from uu to vv still leaves the auxiliary tree. The tree containing vv is a downward path that starts at vv, so the merged tree lies inside vv’s reference subtree: s≤h(v)s \le h(v), the height of that subtree. The join costs at most 8log⁡2h(v)+28\log_2 h(v) + 2, a credit that depends only on vv.
  • uu was observed before. Nothing on the search path below uu was ever requested, since vv is unobserved. So vv is the topmost new node of this request, and there is at most one such node per request. If uu prefers some other child, vv is again at the top of its auxiliary tree and the local bound applies. If uu already prefers vv, then vv hangs in an existing auxiliary tree of ancestors. That happens only when vv is the left child of uu and the last request in uu’s subtree was uu itself. This join is the ancestor attachment, charged the flat 14log⁡2h+414\log_2 h + 4.

Switches are unchanged: each still costs 14log⁡2h+414\log_2 h + 4 and is counted by the interleave quantity. Over a run, each node’s local credit is spent at most once, and there is at most one attachment per request:

first-setting charges  ≤  ∑v(8log⁡2h(v)+2)  +  m (14log⁡2h+4).\text{first-setting charges} \;\le\; \sum_v \bigl(8\log_2 h(v) + 2\bigr) \;+\; m\,(14\log_2 h + 4).

The credit sum is linear for a balanced tree, because log⁡2h(v)≤h(v)+1\log_2 h(v) \le h(v) + 1 and the subtree heights of a balanced tree sum to at most 4n4n:

∑v(8log⁡2h(v)+2)  ≤  8⋅4n+10n  =  42 n.\sum_v \bigl(8\log_2 h(v) + 2\bigr) \;\le\; 8\cdot 4n + 10n \;=\; 42\,n .

The attachment charge goes into the per-request term, which is why the factor grows from 56L+1656L + 16 to (56L+16)+(14L+4)=70L+20(56L+16) + (14L+4) = 70L + 20.

Two facts make the reordering safe. The updates of one request concern distinct nodes, and setting the preference of one node does not affect another, so the reversed log produces exactly the same final marking (Results.preferenceUpdates_reverse_canonical). And every intermediate marking is still a valid path marking, which is all that the edits of Section 26.2 need.

26.3.1.3 An example

Take the reference tree balanced 7 (root 33, children 11 and 55, leaves 0,2,4,60, 2, 4, 6) and the first request 00. All three nodes 3,1,03, 1, 0 on the path are set for the first time, each toward its left child. The library’s regression tests compute the size of the merged auxiliary tree at node 11:

order updates merged tree at 11 charge at 11 local credit of 11
top-down 3,1,03, 1, 0 {3,1,0}\{3, 1, 0\}, size 33 8log⁡23+2≈14.78\log_2 3 + 2 \approx 14.7 8log⁡22+2=108\log_2 2 + 2 = 10
bottom-up 0,1,30, 1, 3 {1,0}\{1, 0\}, size 22 8log⁡22+2=108\log_2 2 + 2 = 10 1010

Top-down, node 11 joins after its ancestor 33, and its charge exceeds its credit. Bottom-up, it joins before, and the charge fits. Node 00 is a leaf, and its first setting points toward an empty child. There is nothing to join, and the implementation now performs no rotation at all (see the section on exact charges).

The attachment case is real. In the tree below, with past requests 44 and then 33, both prefer their left child. Node 11 has never been observed, but it already hangs in the auxiliary tree {4,3,1}\{4, 3, 1\}.

        4            past requests: 4, 3
       /             auxiliary tree {4, 3, 1}
      3
     /
    1                request 0: 1 is set for the first time,
   / \               and joins 0 into {4, 3, 1}
  0   2

The request 00 sets 00 and then 11 for the first time. The join at 11 produces a tree of size 44 and is charged 8log⁡24+2=188\log_2 4 + 2 = 18, while the local credits of 00 and 11 are only 2+10=122 + 10 = 12. The regression module checks both numbers. This is why a per-request attachment allowance is needed: local credit alone does not suffice.

Compared with the papers
  • Demaine, Harmon, Iacono and Pătraşcu (2007) bound Tango’s running time by O((OPT(X)+n)(1+log⁡log⁡n))O((\mathrm{OPT}(X) + n)(1 + \log\log n)), with the nlog⁡log⁡nn\log\log n coming from first settings, as in Section 26.2. The bottom-up order and the local-credit argument are the library’s. They change neither the data structure nor the order of magnitude of the competitive ratio.
  • The combination paper (Demaine et al. 2013) treats O(log⁡log⁡n)O(\log\log n)-competitiveness as a well-behaved bound with overhead O(nlog⁡log⁡n)O(n\log\log n), in its Corollary 4. The additive O(n)O(n) of Iacono and Langerman’s Theorem 4.3 needs the Tango side to have overhead O(n)O(n); the paper does not spell this step out. This section supplies it, and Chapter 31 uses it.

26.3.2 Credit on the reference side

The first layer of accounting lives entirely in the reference tree, like Section 26.1: a weight per reference node, spent when the node is observed for the first time.

defTango.Initialization.allowancepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Definitions/Abstract.lean:19
/-- Total available initialization credit, one weight per reference node. -/def allowance : Tree → Nat → (Nat → ℝ) → ℝ  | .nil, _, _ => 0  | .node l r, lo, w => w (lo + l.size) + allowance l lo w + allowance r (lo + l.size + 1) w
defTango.Initialization.observedChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Definitions/Abstract.lean:10
/-- The accumulated charge of reference nodes observed by the history. Theweight belongs to the reference key, independently of when it is first seen. -/def observedCharge : Tree → Nat → List Nat → (Nat → ℝ) → ℝ  | .nil, _, _, _ => 0  | .node l r, lo, past, w =>      (if regions l.size (l.size + 1 + r.size) past = [] then 0 else w (lo + l.size)) +      observedCharge l lo (leftRequests l.size past) w +      observedCharge r (lo + l.size + 1) (rightRequests l.size past) w
defTango.Initialization.firstChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Definitions/Abstract.lean:24
/-- Charge only actual first-setting events in the executable update log. -/def firstCharge (updates : List PreferenceUpdate) (w : Nat → ℝ) : ℝ :=  ((updates.filter fun e => e.previous.isNone).map fun e => w e.key).sum

For a weight function ww on absolute ranks:

  • allowance t lo w is the total weight of the nodes of t, a subtree at offset lo.
  • observedCharge t lo past w is the total weight of the nodes that past has observed, meaning the nodes whose subtree contains at least one past request. It has the recursive shape of Tango.initializations, which counts the same nodes.
  • firstCharge updates w sums the weights of the first-setting entries of an update log, the entries whose previous is none.

The weight belongs to the node, whenever it happens to be observed. The following theorems say that first settings are exactly the newly observed nodes, so every node pays its weight at most once.

theoremTango.Initialization.Results.allowance_eq_sumpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:10
theorem allowance_eq_sum (t : Tree) (lo : Nat) (w : Nat → ℝ) :    allowance t lo w = ((List.range' lo t.size).map w).sum :=  RotationBST.Tango.Initialization.allowance_eq_sum t lo w
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.observed_steppropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:14
theorem observed_step (t : Tree) (lo : Nat) (past : List Nat) (x : Nat) (w : Nat → ℝ)    (valid : x < t.size) :    observedCharge t lo (past ++ [x]) w = observedCharge t lo past w +      firstCharge (preferenceUpdates t lo past x) w :=  RotationBST.Tango.Initialization.observed_step t lo past x w valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.observed_logpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:20
theorem observed_log (t : Tree) (past xs : List Nat) (w : Nat → ℝ)    (valid : ∀ x ∈ xs, x < t.size) :    observedCharge t 0 (past ++ xs) w = observedCharge t 0 past w +      firstCharge (preferenceLog t past xs) w :=  RotationBST.Tango.Initialization.observed_log t past xs w valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions

allowance_eq_sum writes the allowance as a plain sum over the ranks lo, …, lo + size - 1. observed_step says that serving a valid request xx increases the observed charge by exactly the first-setting charge of xx’s update log, and observed_log sums this over a sequence served online, with the log Tango.preferenceLog of Section 26.1.

Theorem (one payment per node). For nonnegative weights and any valid sequence XX following a history past, the first settings of XX cost at most the weight not yet observed: firstCharge≤allowance−observedCharge(past)\mathrm{firstCharge} \le \mathrm{allowance} - \mathrm{observedCharge}(\mathit{past}). In particular, from the empty history, they cost at most the whole allowance.

theoremTango.Initialization.Results.remaining_budgetpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:26
theorem remaining_budget (t : Tree) (past xs : List Nat) (w : Nat → ℝ)    (valid : ∀ x ∈ xs, x < t.size) (nonneg : ∀ key < t.size, 0 ≤ w key) :    firstCharge (preferenceLog t past xs) w ≤ allowance t 0 w - observedCharge t 0 past w :=  RotationBST.Tango.Initialization.remaining_budget t past xs w valid nonneg
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.first_budgetpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:31
theorem first_budget (t : Tree) (xs : List Nat) (w : Nat → ℝ)    (valid : ∀ x ∈ xs, x < t.size) (nonneg : ∀ key < t.size, 0 ≤ w key) :    firstCharge (preferenceLog t [] xs) w ≤ allowance t 0 w :=  RotationBST.Tango.Initialization.first_budget t xs w valid nonneg
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions

The two counting identities behind Results.preference_settings also hold exactly for a continued history:

theoremTango.Initialization.Results.first_countpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:36
theorem first_count (t : Tree) (past xs : List Nat) (valid : ∀ x ∈ xs, x < t.size) :    (preferenceLog t past xs |>.filter fun e => e.previous.isNone).length + initializations t past =      initializations t (past ++ xs) :=  RotationBST.Tango.Initialization.first_count t past xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.switch_countpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:41
theorem switch_count (t : Tree) (past xs : List Nat) (valid : ∀ x ∈ xs, x < t.size) :    (preferenceLog t past xs |>.filter fun e => e.previous.isSome).length + interleave t past =      interleave t (past ++ xs) :=  RotationBST.Tango.Initialization.switch_count t past xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions

first_count says that the first-setting entries of the log of XX, added to the nodes observed by past, give the nodes observed by past ++ X. switch_count says the same for switches and Wilber’s Wilber.interleave. Together they say that the log of XX consists of exactly IB(past+ ⁣ ⁣+X)−IB(past)\mathrm{IB}(\mathit{past} \mathbin{+\!\!+} X) - \mathrm{IB}(\mathit{past}) switches and as many first settings as newly observed nodes.

26.3.2.1 Local credit

The weight used for the linear startup is the local join bound: 8log⁡2h(v)+28\log_2 h(v) + 2 for each node vv, where h(v)h(v) is the height of vv’s subtree.

defTango.Initialization.heightAtno axiomsAlgorithms/Tango/Preferences/Initialization/Local/Definitions/Abstract.lean:10
/-- Height of the reference subtree rooted at an inorder key; zero off-tree. -/def heightAt : Tree → Nat → Nat  | .nil, _ => 0  | .node l r, key =>      if key < l.size then heightAt l key      else if key = l.size then height (.node l r)      else heightAt r (key - l.size - 1)
defTango.Initialization.heightSumno axiomsAlgorithms/Tango/Preferences/Initialization/Local/Definitions/Abstract.lean:18
/-- Sum of subtree heights, used only to bound available initialization credit. -/def heightSum : Tree → Nat  | .nil => 0  | .node l r => height (.node l r) + heightSum l + heightSum r
defTango.Initialization.localCreditpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Definitions/Abstract.lean:23
/-- Local reference-height credit. This is not the evolving component charge. -/noncomputable def localCredit (t : Tree) (key : Nat) : ℝ :=  8 * Real.logb 2 (heightAt t key) + 2
defTango.Initialization.localAllowancepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Definitions/Abstract.lean:27
/-- One local logarithmic allowance at each node of the reference tree. -/noncomputable def localAllowance : Tree → ℝ  | .nil => 0  | .node l r => 8 * Real.logb 2 (height (.node l r)) + 2 + localAllowance l + localAllowance r

heightAt t key is the height, in nodes as in Tree.height, of the subtree of t rooted at the node of inorder rank key, and 00 for ranks outside t. heightSum t is the sum of all subtree heights. localCredit t key is 8log⁡2(heightAt t key)+28\log_2(\mathtt{heightAt}\ t\ \mathit{key}) + 2, a function of the fixed reference tree only. Its docstring stresses that it is not the charge of the evolving components; the bounds below relate the two. localAllowance t sums the credits structurally, and allowance_localCredit identifies it with the allowance of the weight localCredit.

Theorem (the credit of a balanced tree is linear). The subtree heights of balanced n sum to at most 4n4n, and its local credits sum to at most 42n42n.

theoremTango.Initialization.Local.Results.heightSum_cappropext · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:10
theorem heightSum_cap (t : Tree) (h : Nat) (cap : height t ≤ h) :    heightSum t + h + 2 ≤ 2 ^ (h + 1) :=  RotationBST.Tango.Initialization.heightSum_cap t h cap
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions
theoremTango.Initialization.Local.Results.balanced_heightSumpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:14
theorem balanced_heightSum (n : Nat) : heightSum (balanced n) ≤ 4 * n :=  RotationBST.Tango.Initialization.balanced_heightSum n
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions
theoremTango.Initialization.Local.Results.allowance_localCreditpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:17
theorem allowance_localCredit (t : Tree) (lo : Nat) :    allowance t lo (fun key => localCredit t (key - lo)) = localAllowance t :=  RotationBST.Tango.Initialization.allowance_localCredit t lo
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions
theoremTango.Initialization.Local.Results.balanced_localAllowancepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:21
theorem balanced_localAllowance (n : Nat) : localAllowance (balanced n) ≤ 42 * n :=  RotationBST.Tango.Initialization.balanced_localAllowance n
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions

heightSum_cap is the general fact behind it. A tree of height at most hh has no more total subtree height than the complete tree of height hh, whose height sum is 2h+1−h−22^{h+1} - h - 2. Since balanced n has height ⌊log⁡2n⌋+1\lfloor\log_2 n\rfloor + 1 and 2⌊log⁡2n⌋≤n2^{\lfloor\log_2 n\rfloor} \le n, this gives heightSum≤4n\mathrm{heightSum} \le 4n, including incomplete last levels and n=0n = 0. The proof of balanced_localAllowance then uses log⁡2h≤h+1\log_2 h \le h + 1 to get localAllowance t≤8 heightSum t+10 ∣t∣\mathrm{localAllowance}\ t \le 8\,\mathrm{heightSum}\ t + 10\,|t|, hence 42n42n. The constant is not optimized.

theoremTango.Initialization.Local.Results.balanced_firstChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:24
theorem balanced_firstCharge (n : Nat) (xs : List Nat) (valid : ∀ key ∈ xs, key < n) :    firstCharge (preferenceLog (balanced n) [] xs) (localCredit (balanced n)) ≤ 42 * n :=  RotationBST.Tango.Initialization.balanced_firstCharge n xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions
theoremTango.Initialization.Local.Results.balanced_remainingChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:28
theorem balanced_remainingCharge (n : Nat) (past xs : List Nat)    (valid : ∀ key ∈ xs, key < n) :    firstCharge (preferenceLog (balanced n) past xs) (localCredit (balanced n)) ≤      42 * n - observedCharge (balanced n) 0 past (localCredit (balanced n)) :=  RotationBST.Tango.Initialization.balanced_remainingCharge n past xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions

Specialized to the local credit of balanced n, the budget theorems read: the first settings of any valid sequence from the empty history are charged at most 42n42n, and after a history past, at most 42n42n minus the credit that past has already spent. The second form applies to a run resumed after an arbitrary valid history.

26.3.3 Exact charges for preference updates

The second layer charges each update for what it really costs in the BST. Section 26.2 used the flat bound 14log⁡2h+414\log_2 h + 4 for every update. The library now has a refined charge that distinguishes first settings and records the actual size of the merged auxiliary tree.

defTango.Initialization.componentChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:11
/-- First joins retain their actual target component size; empty childrenrequire no rotations and make no potential change. -/noncomputable def componentCharge (fs : List Frame) (l r : MarkedTree) (next : Bool) : ℝ :=  if (if next then l else r) = .nil then 0  else 8 * Real.logb 2 (plug fs (.node l r (!next) next)).region.size + 2
defTango.Initialization.updateChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:17
/-- Charge the compiled reference update according to its current marks.This inspects the reference state, not a potentially inconsistent log label. -/noncomputable def updateCharge (reference : MarkedTree) (key : Nat) (next : Bool) : ℝ :=  match reference.locateKey key with  | some (.node l r cl cr, fs) =>      if cl && cr then componentCharge (componentAddress fs).2 l r next      else 14 * Real.logb 2 (height reference.tree) + 4  | _ => 0
defTango.Initialization.logChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:26
/-- Advance the actual reference marks between charged updates. -/noncomputable def logCharge : MarkedTree → List PreferenceUpdate → ℝ  | _, [] => 0  | reference, u :: us => updateCharge reference u.key u.next +      logCharge (reference.setPreference u.key u.next) us

The charges are computed on the reference marking, the marked reference tree whose unmarked edges are the current preferred edges, like MarkedTree.canonical. The actual BST is a different marked tree with the same component nesting.

  • updateCharge reference key next locates the reference node of rank key (with the internal locateKey, which returns the node and the list of frames on the path to it). If both child edges of the node are marked, the node has no preference yet and this is a first setting, charged by componentCharge. Otherwise it is a switch, charged 14log⁡2h+414\log_2 h + 4 with hh the reference height. An out-of-range key is charged 00; such keys do not occur in generated logs.
  • componentCharge fs l r next is the join bound 8log⁡2s+28\log_2 s + 2, where ss is the size of the auxiliary tree that contains the node after the update. That tree is computed by plugging the node, with its new marks, into the unmarked frames above it (componentAddress), so it includes every ancestor already in the node’s component. If the newly preferred child is empty, the charge is 00.
  • logCharge reference updates adds the charges of a log, and advances the reference marking after each entry with the internal setPreference. Each entry is therefore classified and measured on the marking it actually meets, not by the previous label recorded in the log. This matters once logs are reordered.

The zero for empty children reflects a change of the implementation, the redundant-splay skip. When a first setting points toward an empty child, there is no auxiliary tree to join, and the auxiliary trees do not change. Only the mark changes. The executable edit (the internal unmarkKnownInPath, used by both the top-down and the bottom-up policy) now returns the tree unchanged with cost 00 in that case, instead of performing the merge at the component boundary. For instance, the first time a leaf is requested, its first setting points toward its empty left child. The following theorems state the effect of a first-setting edit, with or without an empty target:

theoremTango.Initialization.Results.empty_componentpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:69
theorem empty_component (s : MarkedTree) (fs : List Frame)    (l r : MarkedTree) (next : Bool) (empty : (if next then l else r) = .nil) :    s.setMarksInPath fs l r true true next = (s, 0) :=  RotationBST.Tango.MarkedTree.setMarksInPath_initial_empty s fs l r next empty
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.empty_update_costpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:86
theorem empty_update_cost (s reference : MarkedTree) (key : Nat) (next : Bool)    (l r : MarkedTree) (fs : List Frame)    (located : reference.locateKey key = some (.node l r true true, fs))    (empty : (if next then l else r) = .nil) :    (s.updatePreference reference key next).2 = 0 :=  RotationBST.Tango.MarkedTree.updatePreference_initial_empty_cost s reference key next l r fs located empty
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.component_chargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:74
theorem component_charge (s : MarkedTree) (fs : List Frame)    (unmarked : ∀ f ∈ fs, f.marked = false) (l r : MarkedTree) (next : Bool)    (same : s.nesting = (plug fs (.node l r true true)).nesting) :    (s.setMarksInPath fs l r true true next).1.nesting = (plug fs (.node l r (!next) next)).nesting ∧      Rotations s.tree (s.setMarksInPath fs l r true true next).1.tree        (s.setMarksInPath fs l r true true next).2 ∧      ((s.setMarksInPath fs l r true true next).2 : ℝ) +        (s.setMarksInPath fs l r true true next).1.potential - s.potential ≤          if (if next then l else r) = .nil then 0          else 8 * Real.logb 2 (plug fs (.node l r (!next) next)).region.size + 2 :=  RotationBST.Tango.MarkedTree.setMarksInPath_initial_charge s fs unmarked l r next same
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.initial_componentpropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:46
theorem initial_component (s : MarkedTree) (fs : List Frame)    (unmarked : ∀ f ∈ fs, f.marked = false) (l r : MarkedTree) (next : Bool)    (same : s.nesting = (plug fs (.node l r true true)).nesting) :    (s.setMarksInPath fs l r true true next).1.nesting = (plug fs (.node l r (!next) next)).nesting ∧      Rotations s.tree (s.setMarksInPath fs l r true true next).1.tree        (s.setMarksInPath fs l r true true next).2 ∧      ((s.setMarksInPath fs l r true true next).2 : ℝ) +        (s.setMarksInPath fs l r true true next).1.potential - s.potential ≤          8 * Real.logb 2 (plug fs (.node l r (!next) next)).region.size + 2 :=  RotationBST.Tango.MarkedTree.setMarksInPath_initial_spec s fs unmarked l r next same
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions
theoremTango.Initialization.Results.initial_updatepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Abstract.lean:57
theorem initial_update (s reference : MarkedTree) (key : Nat) (next : Bool)    (same : s.nesting = reference.nesting) (paths : reference.PathMarked) (valid : key < reference.tree.size)    (first : ∃ l r fs, reference.locateKey key = some (.node l r true true, fs)) :    ∃ size : Nat,      size ≤ height reference.tree ∧      (s.updatePreference reference key next).1.nesting = (reference.setPreference key next).nesting ∧      Rotations s.tree (s.updatePreference reference key next).1.tree        (s.updatePreference reference key next).2 ∧      ((s.updatePreference reference key next).2 : ℝ) +        (s.updatePreference reference key next).1.potential - s.potential ≤ 8 * Real.logb 2 size + 2 :=  RotationBST.Tango.MarkedTree.updatePreference_initial_spec s reference key next same paths valid first
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions

These are statements about the internal edit setMarksInPath, which changes the marks of one node inside the auxiliary tree described by the frames fs, and about updatePreference, which locates the node from the reference marking and calls it.

  • empty_component and empty_update_cost: a first setting toward an empty child returns the same tree and 00 rotations, even when the node’s component is nested below other components.
  • component_charge: for a first setting, the edit produces the nesting of the updated marking, is a legal sequence of Rotations, and has amortized cost (rotations plus the change of MarkedTree.potential) at most componentCharge: 00 toward an empty child, 8log⁡2s+28\log_2 s + 2 otherwise.
  • initial_component is the same bound without the empty case, 8log⁡2s+28\log_2 s + 2.
  • initial_update is the version through updatePreference, with ss bounded by the reference height. Summed over nn first settings, this is the old nlog⁡log⁡nn\log\log n bound.
theoremTango.Initialization.Local.Results.root_component_chargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Preferences/Initialization/Local/Abstract.lean:34
theorem root_component_charge (s l r : MarkedTree) (next : Bool)    (paths : (MarkedTree.node l r true true).PathMarked)    (same : s.nesting = (MarkedTree.node l r true true).nesting) :    (s.setMarksInPath [] l r true true next).1.nesting =      (MarkedTree.node l r (!next) next).nesting ∧      Rotations s.tree (s.setMarksInPath [] l r true true next).1.tree        (s.setMarksInPath [] l r true true next).2 ∧      ((s.setMarksInPath [] l r true true next).2 : ℝ) +        (s.setMarksInPath [] l r true true next).1.potential - s.potential ≤          localCredit (.node l.tree r.tree) l.tree.size :=  RotationBST.Tango.Initialization.root_component_charge s l r next paths same
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions

root_component_charge is the local case in its simplest form. When the node is the root of the reference marking, with no frames above it, the amortized cost of its first setting is at most its own local credit. The bottom-up proof applies this at every component boundary, a node whose parent edge is marked.

26.3.3.1 The charge of a single update and of a log

With the charges defined, the per-update contract reads as follows.

Theorem (one update). Let ss be a marked BST with the same component nesting as the reference marking, and let the reference marking give each node at most one preferred child (the internal predicate PathMarked). Updating the preference of a valid node produces the nesting of the updated marking, by legal rotations, at amortized cost at most updateCharge. The same holds for a whole log, with logCharge.

theoremTango.Algorithm.Initialization.Results.update_specpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:10
theorem update_spec (s reference : MarkedTree) (key : Nat) (next : Bool)    (same : s.nesting = reference.nesting) (paths : reference.PathMarked)    (valid : key < reference.tree.size) :    (s.updatePreference reference key next).1.nesting = (reference.setPreference key next).nesting ∧      Rotations s.tree (s.updatePreference reference key next).1.tree        (s.updatePreference reference key next).2 ∧      ((s.updatePreference reference key next).2 : ℝ) +        (s.updatePreference reference key next).1.potential - s.potential ≤ updateCharge reference key next :=  RotationBST.Tango.Initialization.update_spec s reference key next same paths valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.log_specpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:20
theorem log_spec (s reference : MarkedTree) (updates : List PreferenceUpdate)    (same : s.nesting = reference.nesting) (paths : reference.PathMarked)    (valid : ∀ update ∈ updates, update.key < reference.tree.size) :    (s.updatePreferences reference updates).1.nesting = (reference.applyPreferences updates).nesting ∧      Rotations s.tree (s.updatePreferences reference updates).1.tree (s.updatePreferences reference updates).2 ∧      ((s.updatePreferences reference updates).2 : ℝ) +        (s.updatePreferences reference updates).1.potential - s.potential ≤ logCharge reference updates :=  RotationBST.Tango.Initialization.log_spec s reference updates same paths valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.logCharge_appendpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:29
theorem logCharge_append (reference : MarkedTree) (xs ys : List PreferenceUpdate) :    logCharge reference (xs ++ ys) = logCharge reference xs + logCharge (reference.applyPreferences xs) ys :=  RotationBST.Tango.Initialization.logCharge_append reference xs ys
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions

The hypothesis is only that ss and the reference marking agree on the nesting, not that the marking is canonical for some history. This is what allows applying the updates in any order: every intermediate marking of a reordered log still satisfies PathMarked. logCharge_append splits the charge of a concatenated log at the intermediate marking.

The refined charge is never worse than the flat one of Section 26.2:

theoremTango.Algorithm.Initialization.Results.updateCharge_lepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:65
theorem updateCharge_le (reference : MarkedTree) (key : Nat) (next : Bool)    (paths : reference.PathMarked) (valid : key < reference.tree.size) :    updateCharge reference key next ≤ 14 * Real.logb 2 (height reference.tree) + 4 :=  RotationBST.Tango.Initialization.updateCharge_le reference key next paths valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.logCharge_lepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:70
theorem logCharge_le (reference : MarkedTree) (updates : List PreferenceUpdate)    (paths : reference.PathMarked) (valid : ∀ u ∈ updates, u.key < reference.tree.size) :    logCharge reference updates ≤ updates.length * (14 * Real.logb 2 (height reference.tree) + 4) :=  RotationBST.Tango.Initialization.logCharge_le reference updates paths valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions

26.3.3.2 First settings and switches, from the marks

To separate the two kinds of updates, the library classifies each entry by the marks it meets.

defTango.Initialization.virginCountno axiomsAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:41
/-- Reference nodes with no preference set yet, including empty-child marks. -/def virginCount : MarkedTree → Nat  | .nil => 0  | .node l r cl cr => (if cl && cr then 1 else 0) + virginCount l + virginCount r
defTango.Initialization.firstAtpropextAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:46
def firstAt (reference : MarkedTree) (key : Nat) : Bool :=  match reference.locateKey key with  | some (.node _ _ cl cr, _) => cl && cr  | _ => false
defTango.Initialization.firstCountpropextAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:51
def firstCount : MarkedTree → List PreferenceUpdate → Nat  | _, [] => 0  | reference, u :: us => (if firstAt reference u.key then 1 else 0) +      firstCount (reference.setPreference u.key u.next) us
defTango.Initialization.laterCountpropextAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:56
def laterCount : MarkedTree → List PreferenceUpdate → Nat  | _, [] => 0  | reference, u :: us => (if firstAt reference u.key then 0 else 1) +      laterCount (reference.setPreference u.key u.next) us
defTango.Initialization.firstLogChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:61
/-- Keep only initialization charges, classified from the evolving marks. -/noncomputable def firstLogCharge : MarkedTree → List PreferenceUpdate → ℝ  | _, [] => 0  | reference, u :: us => (if firstAt reference u.key then updateCharge reference u.key u.next else 0) +      firstLogCharge (reference.setPreference u.key u.next) us

virginCount counts the nodes with both child edges marked, the nodes without a preference. Its docstring says it includes “empty-child marks”: a leaf counts until it is first set, even though its preferred child is empty. firstAt reference key says that the node of rank key has no preference yet. Along a log, with the marking advanced after each entry, firstCount counts the entries that meet an unset node, laterCount the others, and firstLogCharge keeps only the charges of the first ones.

theoremTango.Algorithm.Initialization.Results.virgin_steppropext · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:83
theorem virgin_step (reference : MarkedTree) (key : Nat) (next : Bool)    (valid : key < reference.tree.size) :    virginCount (reference.setPreference key next) + (if firstAt reference key then 1 else 0) =      virginCount reference :=  RotationBST.Tango.Initialization.virgin_step reference key next valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.virgin_logpropext · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:89
theorem virgin_log (reference : MarkedTree) (updates : List PreferenceUpdate)    (valid : ∀ u ∈ updates, u.key < reference.tree.size) :    firstCount reference updates + virginCount (reference.applyPreferences updates) = virginCount reference :=  RotationBST.Tango.Initialization.virgin_log reference updates valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.virgin_canonicalpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:94
theorem virgin_canonical (t : Tree) (past : List Nat) (history : ∀ x ∈ past, x < t.size) :    virginCount (canonical t 0 past) + initializations t past = t.size :=  RotationBST.Tango.Initialization.virgin_canonical t past history
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions

Each first setting removes exactly one unset node (virgin_step, virgin_log), and the canonical marking of a history has exactly n−initializationsn - \mathrm{initializations} unset nodes (virgin_canonical). So the classification by marks agrees with the reference-side counts:

theoremTango.Algorithm.Initialization.Results.firstCount_generatedpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:98
theorem firstCount_generated (t : Tree) (past xs : List Nat)    (history : ∀ x ∈ past, x < t.size) (valid : ∀ x ∈ xs, x < t.size) :    firstCount (canonical t 0 past) (preferenceLog t past xs) + initializations t past =      initializations t (past ++ xs) :=  RotationBST.Tango.Initialization.firstCount_generated t past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.laterCount_generatedpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:104
theorem laterCount_generated (t : Tree) (past xs : List Nat)    (history : ∀ x ∈ past, x < t.size) (valid : ∀ x ∈ xs, x < t.size) :    laterCount (canonical t 0 past) (preferenceLog t past xs) + interleave t past =      interleave t (past ++ xs) :=  RotationBST.Tango.Initialization.laterCount_generated t past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.logCharge_splitpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:110
theorem logCharge_split (reference : MarkedTree) (updates : List PreferenceUpdate)    (valid : ∀ u ∈ updates, u.key < reference.tree.size) :    logCharge reference updates = firstLogCharge reference updates +      laterCount reference updates * (14 * Real.logb 2 (height reference.tree) + 4) :=  RotationBST.Tango.Initialization.logCharge_split reference updates valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.firstLogCharge_lepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:116
theorem firstLogCharge_le (reference : MarkedTree) (updates : List PreferenceUpdate)    (paths : reference.PathMarked) (valid : ∀ u ∈ updates, u.key < reference.tree.size) :    firstLogCharge reference updates ≤ firstCount reference updates *      (14 * Real.logb 2 (height reference.tree) + 4) :=  RotationBST.Tango.Initialization.firstLogCharge_le reference updates paths valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.generated_splitpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:122
theorem generated_split (reference : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    logCharge (initial reference) (preferenceLog reference [] xs) =      firstLogCharge (initial reference) (preferenceLog reference [] xs) +        interleave reference xs * (14 * Real.logb 2 (height reference) + 4) :=  RotationBST.Tango.Initialization.generated_split reference xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions

On the top-down log of a continued history, firstCount is the number of newly observed nodes and laterCount is the increase of the interleave quantity. logCharge_split splits any log’s charge into its first-setting part and 14log⁡2h+414\log_2 h + 4 per later entry. firstLogCharge_le bounds the first part by 14log⁡2h+414\log_2 h + 4 per first setting, which is the old bound again. generated_split combines them for a run from the initial marking: the total charge is the first-setting charge plus IB(X) (14log⁡2h+4)\mathrm{IB}(X)\,(14\log_2 h + 4).

26.3.3.3 The top-down policy with exact charges

These charges sharpen the analysis of the existing top-down step MarkedTree.serve of Section 26.2. The request charge is the refined log charge of the request’s update log, plus 3log⁡2h+13\log_2 h + 1 for the final splay.

defTango.Initialization.requestChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:32
/-- Preference maintenance followed by the final root-component access. -/noncomputable def requestCharge (reference : Tree) (past : List Nat) (x : Nat) : ℝ :=  logCharge (canonical reference 0 past) (preferenceUpdates reference 0 past x) +    (3 * Real.logb 2 (height reference) + 1)
defTango.Initialization.sequenceChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Definitions/Abstract.lean:37
noncomputable def sequenceCharge (reference : Tree) : List Nat → List Nat → ℝ  | _, [] => 0  | past, x :: xs => requestCharge reference past x + sequenceCharge reference (past ++ [x]) xs

Theorem (top-down Tango with exact charges). Under the invariant MarkedTree.Maintains of Section 26.2, the top-down step is a legal access, preserves the invariant, and has amortized cost at most the refined request charge. Over a run from the reference tree, the rotations are at most the first-setting charge plus IB(X)(14log⁡2h+4)+m(3log⁡2h+1)\mathrm{IB}(X)(14\log_2 h + 4) + m(3\log_2 h + 1), and the total cost is at most the first-setting charge plus (56log⁡2h+16)(R+m)(56\log_2 h + 16)(R + m) against any offline execution.

theoremTango.Algorithm.Initialization.Results.request_specpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:33
theorem request_spec (s : MarkedTree) (reference : Tree) (past : List Nat) (x : Nat)    (maintained : Maintains s reference past) (history : ∀ y ∈ past, y < reference.size)    (valid : x < reference.size) :    Access s.tree (s.serve reference past x).1.tree x (s.serve reference past x).2 ∧      Maintains (s.serve reference past x).1 reference (past ++ [x]) ∧      ((s.serve reference past x).2 : ℝ) + (s.serve reference past x).1.potential - s.potential ≤        requestCharge reference past x :=  RotationBST.Tango.Initialization.request_spec s reference past x maintained history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.sequenceCharge_eqpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:42
theorem sequenceCharge_eq (reference : Tree) (past xs : List Nat)    (history : ∀ y ∈ past, y < reference.size) (valid : ∀ x ∈ xs, x < reference.size) :    sequenceCharge reference past xs = logCharge (canonical reference 0 past) (preferenceLog reference past xs) +      xs.length * (3 * Real.logb 2 (height reference) + 1) :=  RotationBST.Tango.Initialization.sequenceCharge_eq reference past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.runFrom_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:48
theorem runFrom_bound {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = s.serve reference past x)    (s : MarkedTree) (past xs : List Nat)    (maintained : Maintains s reference past) (history : ∀ y ∈ past, y < reference.size)    (valid : ∀ x ∈ xs, x < reference.size) :    ((p.runFrom past s xs).2 : ℝ) +      (p.runFrom past s xs).1.potential - s.potential ≤ sequenceCharge reference past xs :=  RotationBST.Tango.Initialization.runFrom_bound p steps s past xs maintained history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.run_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:57
theorem run_bound {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = s.serve reference past x)    (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    ((p.run xs).2 : ℝ) ≤      logCharge (initial reference) (preferenceLog reference [] xs) +        xs.length * (3 * Real.logb 2 (height reference) + 1) :=  RotationBST.Tango.Initialization.run_bound p steps xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.policy_existspropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:75
theorem policy_exists (reference : Tree) :    ∃ p : Policy reference,      (∀ past s x, p.step past s x = s.serve reference past x) ∧      ∀ xs, (∀ x ∈ xs, x < reference.size) →        ((p.run xs).2 : ℝ) ≤ logCharge (initial reference) (preferenceLog reference [] xs) +          xs.length * (3 * Real.logb 2 (height reference) + 1) :=  RotationBST.Tango.Initialization.policy_exists reference
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.separated_run_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:128
theorem separated_run_bound {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = s.serve reference past x)    (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    ((p.run xs).2 : ℝ) ≤ firstLogCharge (initial reference) (preferenceLog reference [] xs) +      interleave reference xs * (14 * Real.logb 2 (height reference) + 4) +      xs.length * (3 * Real.logb 2 (height reference) + 1) :=  RotationBST.Tango.Initialization.separated_run_bound p steps xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions
theoremTango.Algorithm.Initialization.Results.separated_competitivepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Initialization/Abstract.lean:136
theorem separated_competitive {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = s.serve reference past x)    {start finish : Tree} {xs : List Nat} {offline : Nat}    (size : reference.size = start.size) (execution : RotationBST.Execution start xs finish offline) :    ((p.run xs).2 : ℝ) + xs.length ≤ firstLogCharge (initial reference) (preferenceLog reference [] xs) +      (56 * Real.logb 2 (height reference) + 16) * (offline + xs.length : Nat) :=  RotationBST.Tango.Initialization.separated_competitive p steps size execution
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions

runFrom_bound and run_bound hold for every policy p whose step is MarkedTree.serve (the hypothesis steps), and policy_exists provides one. separated_competitive separates the startup from the competitive part. In the top-down order, the only bound available for the first-setting charge is firstLogCharge_le, (14log⁡2h+4)(14\log_2 h + 4) per node. So this is where the top-down analysis stops: with an unresolved nlog⁡log⁡nn\log\log n.

26.3.4 The bottom-up policy

The new step differs from MarkedTree.serve in a single word: it applies the reversed update log.

defTango.BottomUp.servepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Definitions/Abstract.lean:10
/-- Compile one request's distinct reference changes from the deepest nodeupward, then access the key in the resulting root component. -/def serve (s : MarkedTree) (reference : Tree) (past : List Nat) (x : Nat) : MarkedTree × Nat :=  let updated := s.updatePreferences (canonical reference 0 past) (preferenceUpdates reference 0 past x).reverse  let accessed := updated.1.splayRoot (Region.index updated.1.region 0 x)  (accessed.1, updated.2 + accessed.2)
defTango.BottomUp.logno axiomsAlgorithms/Tango/Algorithm/BottomUp/Definitions/Abstract.lean:17
/-- Reverse within each request only; the request sequence remains causal. -/def log (reference : Tree) : List Nat → List Nat → List PreferenceUpdate  | _, [] => []  | past, x :: xs => (preferenceUpdates reference 0 past x).reverse ++ log reference (past ++ [x]) xs

serve s reference past x computes the update log of xx from the history, reverses it, and replays it on the actual marked BST s with the internal updatePreferences, advancing the canonical reference marking canonical reference 0 past after each entry. Then it splays xx to the root within the root component, exactly as before. The cost is the sum of the two rotation counts. log reference past xs is the log that a run actually replays: the update log of each request, reversed, concatenated in request order. Only the updates within a request are reordered, so the run remains online.

26.3.4.1 Reordering is harmless

theoremTango.BottomUp.Results.setPreference_commutepropext · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:10
theorem setPreference_commute (s : MarkedTree) (x y : Nat) (a b : Bool)    (different : x ≠ y) :    (s.setPreference x a).setPreference y b = (s.setPreference y b).setPreference x a :=  RotationBST.Tango.MarkedTree.setPreference_commute s x y a b different
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.applyPreferences_reversepropext · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:15
theorem applyPreferences_reverse (s : MarkedTree) (updates : List PreferenceUpdate)    (distinct : updates.Pairwise (fun u v => u.key ≠ v.key)) :    s.applyPreferences updates.reverse = s.applyPreferences updates :=  RotationBST.Tango.MarkedTree.applyPreferences_reverse s updates distinct
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.preferenceUpdates_reverse_canonicalpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:20
theorem preferenceUpdates_reverse_canonical (t : Tree) (past : List Nat) (x : Nat)    (history : ∀ y ∈ past, y < t.size) (valid : x < t.size) :    (canonical t 0 past).applyPreferences (preferenceUpdates t 0 past x).reverse =      canonical t 0 (past ++ [x]) :=  RotationBST.Tango.MarkedTree.preferenceUpdates_reverse_canonical t past x history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.log_canonicalpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:66
theorem log_canonical (reference : Tree) (past xs : List Nat)    (history : ∀ y ∈ past, y < reference.size) (valid : ∀ x ∈ xs, x < reference.size) :    (canonical reference 0 past).applyPreferences (log reference past xs) =      canonical reference 0 (past ++ xs) :=  RotationBST.Tango.BottomUp.log_canonical reference past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.log_appendpropextAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:108
theorem log_append (reference : Tree) (past xs ys : List Nat) :    log reference past (xs ++ ys) = log reference past xs ++ log reference (past ++ xs) ys :=  RotationBST.Tango.BottomUp.log_append reference past xs ys
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

Setting the preferences of two different nodes commutes (setPreference_commute), so a log with pairwise distinct keys gives the same marking in either order (applyPreferences_reverse). The update log of one request has distinct keys, one per node on the search path. Hence the reversed log turns the canonical marking of past into the canonical marking of past ++ [x] (preferenceUpdates_reverse_canonical), and the whole bottom-up log does the same for a sequence (log_canonical). log_append splits the log of a concatenated sequence.

26.3.4.2 The contract

The bottom-up request charge is the refined log charge of the reversed log, measured on the marking each entry actually meets, plus the final splay:

defTango.BottomUp.requestChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Definitions/Abstract.lean:22
/-- The refined charge uses the actual intermediate reference components inbottom-up order, not the components of the top-down execution. -/noncomputable def requestCharge (reference : Tree) (past : List Nat) (x : Nat) : ℝ :=  Initialization.logCharge (canonical reference 0 past) (preferenceUpdates reference 0 past x).reverse +    (3 * Real.logb 2 (height reference) + 1)
defTango.BottomUp.sequenceChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Definitions/Abstract.lean:28
noncomputable def sequenceCharge (reference : Tree) : List Nat → List Nat → ℝ  | _, [] => 0  | past, x :: xs => requestCharge reference past x + sequenceCharge reference (past ++ [x]) xs

Its docstring makes the point explicit: the charge uses the intermediate reference markings in bottom-up order, not those of the top-down execution.

Theorem (serving a request bottom-up). Under the invariant of Section 26.2, the bottom-up step performs a legal access of xx, preserves the invariant for past ++ [x], and has amortized cost at most the bottom-up request charge.

theoremTango.BottomUp.Results.request_specpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:26
theorem request_spec (s : MarkedTree) (reference : Tree) (past : List Nat) (x : Nat)    (maintained : Maintains s reference past) (history : ∀ y ∈ past, y < reference.size)    (valid : x < reference.size) :    Access s.tree (serve s reference past x).1.tree x (serve s reference past x).2 ∧      Maintains (serve s reference past x).1 reference (past ++ [x]) ∧      ((serve s reference past x).2 : ℝ) + (serve s reference past x).1.potential - s.potential ≤        requestCharge reference past x :=  RotationBST.Tango.BottomUp.request_spec s reference past x maintained history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

This is the analogue of the internal contract of Section 26.2, stated here with the refined charge. Since the refined charge is at most the flat one, the step also satisfies the Policy contract, so it is a Tango.Policy (the internal BottomUp.policy).

theoremTango.BottomUp.Results.sequenceCharge_eqpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:35
theorem sequenceCharge_eq (reference : Tree) (past xs : List Nat)    (history : ∀ y ∈ past, y < reference.size) (valid : ∀ x ∈ xs, x < reference.size) :    sequenceCharge reference past xs = logCharge (canonical reference 0 past) (log reference past xs) +      xs.length * (3 * Real.logb 2 (height reference) + 1) :=  RotationBST.Tango.BottomUp.sequenceCharge_eq reference past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.runFrom_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:41
theorem runFrom_bound {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = serve s reference past x)    (s : MarkedTree) (past xs : List Nat)    (maintained : Maintains s reference past) (history : ∀ y ∈ past, y < reference.size)    (valid : ∀ x ∈ xs, x < reference.size) :    ((p.runFrom past s xs).2 : ℝ) +      (p.runFrom past s xs).1.potential - s.potential ≤ sequenceCharge reference past xs :=  RotationBST.Tango.BottomUp.runFrom_bound p steps s past xs maintained history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.run_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:50
theorem run_bound {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = serve s reference past x)    (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    ((p.run xs).2 : ℝ) ≤      logCharge (initial reference) (log reference [] xs) +        xs.length * (3 * Real.logb 2 (height reference) + 1) :=  RotationBST.Tango.BottomUp.run_bound p steps xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.policy_existspropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:58
theorem policy_exists (reference : Tree) :    ∃ p : Policy reference,      (∀ past s x, p.step past s x = serve s reference past x) ∧      ∀ xs, (∀ x ∈ xs, x < reference.size) →        ((p.run xs).2 : ℝ) ≤ logCharge (initial reference) (log reference [] xs) +          xs.length * (3 * Real.logb 2 (height reference) + 1) :=  RotationBST.Tango.BottomUp.policy_exists reference
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.runFrom_appendpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:112
theorem runFrom_append {reference : Tree} (p : Policy reference)    (past : List Nat) (s : MarkedTree) (xs ys : List Nat) :    p.runFrom past s (xs ++ ys) =      let first := p.runFrom past s xs      let rest := p.runFrom (past ++ xs) first.1 ys      (rest.1, first.2 + rest.2) :=  RotationBST.Tango.Policy.runFrom_append p past s xs ys
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

These are the run-level forms. sequenceCharge_eq rewrites the summed request charges as one log charge of log reference past xs plus m(3log⁡2h+1)m(3\log_2 h + 1). runFrom_bound and run_bound telescope the potential, for every policy whose step is BottomUp.serve. policy_exists provides such a policy, with the run bound. runFrom_append is a general fact about policies: running on xs ++ ys is running on xs and then resuming on ys from the returned marked tree, with the counts added. A worker that is paused and resumed relies on it.

26.3.4.3 The same counts in a different order

Reordering must not change how many first settings and switches there are. The bottom-up log is a permutation of the top-down log within each request, and the classification by marks still agrees with the reference-side counts:

theoremTango.BottomUp.Results.firstCharge_logpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:72
theorem firstCharge_log (reference : Tree) (past xs : List Nat) (w : Nat → ℝ) :    firstCharge (log reference past xs) w = firstCharge (preferenceLog reference past xs) w :=  RotationBST.Tango.BottomUp.firstCharge_log reference past xs w
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.firstCount_generatedpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:82
theorem firstCount_generated (t : Tree) (past xs : List Nat)    (history : ∀ x ∈ past, x < t.size) (valid : ∀ x ∈ xs, x < t.size) :    firstCount (canonical t 0 past) (log t past xs) + initializations t past =      initializations t (past ++ xs) :=  RotationBST.Tango.BottomUp.firstCount_generated t past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.laterCount_generatedpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:88
theorem laterCount_generated (t : Tree) (past xs : List Nat)    (history : ∀ x ∈ past, x < t.size) (valid : ∀ x ∈ xs, x < t.size) :    laterCount (canonical t 0 past) (log t past xs) + interleave t past =      interleave t (past ++ xs) :=  RotationBST.Tango.BottomUp.laterCount_generated t past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.generated_splitpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:94
theorem generated_split (reference : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    logCharge (initial reference) (log reference [] xs) =      firstLogCharge (initial reference) (log reference [] xs) +        interleave reference xs * (14 * Real.logb 2 (height reference) + 4) :=  RotationBST.Tango.BottomUp.generated_split reference xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.separated_competitivepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:100
theorem separated_competitive {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = serve s reference past x)    {start finish : Tree} {xs : List Nat} {offline : Nat}    (size : reference.size = start.size) (execution : RotationBST.Execution start xs finish offline) :    ((p.run xs).2 : ℝ) + xs.length ≤ firstLogCharge (initial reference) (log reference [] xs) +      (56 * Real.logb 2 (height reference) + 16) * (offline + xs.length : Nat) :=  RotationBST.Tango.BottomUp.separated_competitive p steps size execution
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

firstCharge_log says that the bottom-up and the top-down log have the same first-setting charge for every weight function. firstCount_generated and laterCount_generated say that, measured on the marks, the bottom-up log of a continued history still has one first setting per newly observed node and one later entry per new unit of interleave. A regression test checks that reversing does not turn switches into first settings. generated_split and separated_competitive are the bottom-up versions of the top-down statements above: the run’s total cost is at most the first-setting charge plus (56log⁡2h+16)(R+m)(56\log_2 h + 16)(R + m).

26.3.5 The linear startup

All that remains is the bound on the first-setting charge in bottom-up order.

Theorem (local credit plus one attachment per request). For any reference tree of height hh and any valid history and continuation XX of mm requests, the first-setting charge of the bottom-up log of XX, measured on the evolving marking, is at most the local credit of the first-set nodes plus m(14log⁡2h+4)m(14\log_2 h + 4). From the empty history, it is at most localAllowance plus m(14log⁡2h+4)m(14\log_2 h + 4).

theoremTango.BottomUp.Results.first_log_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:120
theorem first_log_bound (reference : Tree) (past xs : List Nat)    (history : ∀ y ∈ past, y < reference.size) (valid : ∀ x ∈ xs, x < reference.size) :    firstLogCharge (canonical reference 0 past) (log reference past xs) ≤      firstCharge (log reference past xs) (localCredit reference) +        xs.length * (14 * Real.logb 2 (height reference) + 4) :=  RotationBST.Tango.BottomUp.first_log_bound reference past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.startup_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:127
theorem startup_bound (reference : Tree) (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    firstLogCharge (initial reference) (log reference [] xs) ≤      localAllowance reference + xs.length * (14 * Real.logb 2 (height reference) + 4) :=  RotationBST.Tango.BottomUp.startup_bound reference xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

The proof is the argument of the overview, by induction on the reference tree for one request. Inside a newly observed subtree, every first setting meets a component boundary, so root_component_charge, in an internal form plugged into the surrounding frames, bounds it by the node’s local credit. Only the topmost first setting of the request may join an existing ancestor component, and that one is bounded by updateCharge_le. startup_bound then sums the local credits with first_budget: each node’s credit is spent once.

theoremTango.BottomUp.Results.balanced_remainingChargepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:76
theorem balanced_remainingCharge (n : Nat) (past xs : List Nat)    (valid : ∀ key ∈ xs, key < n) :    firstCharge (log (balanced n) past xs) (localCredit (balanced n)) ≤      42 * n - observedCharge (balanced n) 0 past (localCredit (balanced n)) :=  RotationBST.Tango.BottomUp.balanced_remainingCharge n past xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.balanced_startup_remainingpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:132
theorem balanced_startup_remaining (n : Nat) (past xs : List Nat)    (history : ∀ y ∈ past, y < n) (valid : ∀ x ∈ xs, x < n) :    firstLogCharge (canonical (balanced n) 0 past) (log (balanced n) past xs) ≤      42 * n - observedCharge (balanced n) 0 past (localCredit (balanced n)) +        xs.length * (14 * Real.logb 2 (height (balanced n)) + 4) :=  RotationBST.Tango.BottomUp.balanced_startup_remaining n past xs history valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

For balanced n, the credit is at most 42n42n, and a resumed run only has the credit not yet spent by its history: 42n−observedCharge42n - \mathrm{observedCharge}, plus the attachment term.

Theorem (linear-startup Tango). For a policy whose step is the bottom-up step, the rotations of a run on mm valid requests are at most

localAllowance+IB(X) (14log⁡2h+4)+m (17log⁡2h+5),\mathrm{localAllowance} + \mathrm{IB}(X)\,(14\log_2 h + 4) + m\,(17\log_2 h + 5),

and against any offline execution with RR rotations, from any tree of the same size, the total cost is at most localAllowance+(70log⁡2h+20)(R+m)\mathrm{localAllowance} + (70\log_2 h + 20)(R + m).

theoremTango.BottomUp.Results.linear_run_boundpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:139
theorem linear_run_bound {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = serve s reference past x)    (xs : List Nat) (valid : ∀ x ∈ xs, x < reference.size) :    ((p.run xs).2 : ℝ) ≤ localAllowance reference +      interleave reference xs * (14 * Real.logb 2 (height reference) + 4) +        xs.length * (17 * Real.logb 2 (height reference) + 5) :=  RotationBST.Tango.BottomUp.linear_run_bound p steps xs valid
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.linear_competitivepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:147
theorem linear_competitive {reference : Tree} (p : Policy reference)    (steps : ∀ past s x, p.step past s x = serve s reference past x)    {start finish : Tree} {xs : List Nat} {offline : Nat}    (size : reference.size = start.size) (execution : RotationBST.Execution start xs finish offline) :    ((p.run xs).2 : ℝ) + xs.length ≤ localAllowance reference +      (70 * Real.logb 2 (height reference) + 20) * (offline + xs.length : Nat) :=  RotationBST.Tango.BottomUp.linear_competitive p steps size execution
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

The factor 17log⁡2h+517\log_2 h + 5 is the attachment charge 14log⁡2h+414\log_2 h + 4 plus the final splay 3log⁡2h+13\log_2 h + 1. In linear_competitive, Wilber’s bound IB≤4R+2m\mathrm{IB} \le 4R + 2m (Results.rotation_lower_bound) turns the interleave term into (56log⁡2h+16)(R+m)(56\log_2 h + 16)(R + m), and the attachment term is absorbed as (14log⁡2h+4)(R+m)(14\log_2 h + 4)(R + m). Validity of the requests follows from the comparator.

Theorem (balanced reference). With the balanced reference tree on nn keys, the bound is 42n+(70L+20)(R+m)42n + (70L + 20)(R + m) with L=log⁡2(⌊log⁡2n⌋+1)L = \log_2(\lfloor\log_2 n\rfloor + 1), and a policy with this bound exists.

theoremTango.BottomUp.Results.balanced_competitivepropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:155
theorem balanced_competitive (n : Nat) (p : Policy (balanced n))    (steps : ∀ past s x, p.step past s x = serve s (balanced n) past x)    {start finish : Tree} {xs : List Nat} {offline : Nat}    (size : start.size = n) (execution : RotationBST.Execution start xs finish offline) :    ((p.run xs).2 : ℝ) + xs.length ≤ 42 * n +      (70 * Real.logb 2 (Nat.log2 n + 1) + 20) * (offline + xs.length : Nat) :=  RotationBST.Tango.BottomUp.balanced_competitive n p steps size execution
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions
theoremTango.BottomUp.Results.balanced_policypropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/BottomUp/Abstract.lean:163
theorem balanced_policy (n : Nat) :    ∃ p : Policy (balanced n),      (∀ past s x, p.step past s x = serve s (balanced n) past x) ∧      ∀ (start finish : Tree) (xs : List Nat) (offline : Nat), start.size = n →        RotationBST.Execution start xs finish offline →          ((p.run xs).2 : ℝ) + xs.length ≤ 42 * n +            (70 * Real.logb 2 (Nat.log2 n + 1) + 20) * (offline + xs.length : Nat) :=  RotationBST.Tango.BottomUp.balanced_policy n
Statement reads only Models.Rotation, Algorithms.Tango.Algorithm.Definitions, Algorithms.Tango.Algorithm.Request, Algorithms.Tango.State.Defs, Algorithms.Tango.State.Nesting.Defs, Algorithms.Tango.State, Algorithms.Tango.Preferences.Updates, Bounds.Interleave.Definitions, Algorithms.Tango.Definitions, Algorithms.Tango.Paths, Bounds.Interleave.Wilber, Bounds.Interleave.Transition.Defs, Algorithms.Tango.State.Preferences.Defs, Algorithms.Tango.State.Preferences.Lookup.Defs, Algorithms.Tango.State.Preferences.Algorithm.Defs, Algorithms.Tango.State.ComponentPath.Defs, Algorithms.Tango.State.ComponentPath.Address.Defs, Algorithms.Tango.State.Context.Defs, Algorithms.Tango.State.Context.Lookup.Defs, Algorithms.Tango.State.Context.Fringe.Defs, Algorithms.Tango.State.Nesting.Edits.Path.Algorithm.Defs, Algorithms.Tango.State.Nesting.Edits.Algorithm.Defs, Algorithms.Tango.State.Rebuild.Defs, Algorithms.Tango.State.Splay.Defs, Algorithms.Tango.State.Cut.Defs, Algorithms.Tango.State.Join.Defs, Models.Region, Algorithms.Tango.Auxiliary.Definitions, Models.Pointer.Lazy.Skeleton, Models.Pointer.Traces, Models.Pointer.Machine, Algorithms.Splay.Algorithm, Algorithms.Splay.Potential, Algorithms.Tango.Preferences, Algorithms.Tango.Preferences.Initialization.Definitions, Algorithms.Tango.Algorithm.Initialization.Definitions, Algorithms.Tango.Reference, Algorithms.Tango.Preferences.Initialization.Local.Definitions, Algorithms.Tango.Algorithm.BottomUp.Definitions

balanced_competitive applies to every policy whose step is BottomUp.serve, and uses height(balanced n)≤⌊log⁡2n⌋+1\mathrm{height}(\mathtt{balanced}\ n) \le \lfloor\log_2 n\rfloor + 1. balanced_policy is the headline: one policy, chosen before the requests and the comparator, satisfying the bound for all of them. Its proof is ⟨policy (balanced n), …⟩, the executable bottom-up policy.

Reading the Lean
  • Start tree. As in Section 26.2, the policy’s run starts from its reference tree, MarkedTree.initial (balanced n), while the comparator starts from any tree of size nn. The next section removes this asymmetry at the price of 2n2n rotations.
  • No hidden inputs. The hypothesis steps is discharged by the witness, and none of the bounds assumes anything about the request sequence beyond what the comparator implies.
  • Constants. 4242, 7070 and 2020 are explicit, unoptimized witnesses. The attachment term costs a larger multiplicative constant than Section 26.2; only the startup became smaller, from (14L+4) n(14L+4)\,n to 42n42n.

26.3.6 From a policy to an algorithm

A policy becomes an ordinary online algorithm by the construction of Section 26.2: recompute the marks by replaying the policy on the past requests, which is free planning in the rotation model, and reset any other initial tree to the reference tree on the first request, with at most 2n2n rotations (Geometry.reset). The library states this once, for every policy.

Theorem (a policy as an online algorithm). For every policy pp with reference tree PP, there is an online algorithm that, run from PP on valid requests, produces exactly the policy’s final tree and rotation count, and whose total cost from any tree of the same size is at most m+rotations(p)+2nm + \mathrm{rotations}(p) + 2n.

theoremTango.Algorithm.Rotation.Results.rotation_algorithmpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Rotation/Abstract.lean:9
/-- A causal rotation algorithm follows the marked policy exactly from itsreference tree. Any other same-size initial tree pays at most one 2n reset.Reconstructing private marks from history has uncharged abstract planning cost. -/theorem rotation_algorithm {reference : Tree} (p : Policy reference) :    ∃ a : RotationBST.Algorithm,      (∀ xs, (∀ x ∈ xs, x < reference.size) →        a.runFrom [] reference xs = ((p.run xs).1.tree, (p.run xs).2)) ∧      ∀ saved : Tree, saved.size = reference.size → ∀ xs, (∀ x ∈ xs, x < reference.size) →        a.totalCost saved xs ≤ xs.length + (p.run xs).2 + 2 * saved.size :=  p.rotation_algorithm

The first conjunct compares Algorithm.runFrom from the reference tree with the plain tree of the policy’s run. The second bounds Algorithm.totalCost from any saved tree. With balanced_policy, it gives the online algorithm of the headline:

Theorem (Tango with linear startup, as one online algorithm). For every nn there is an online BST algorithm whose total cost, from every initial tree on nn keys, is at most (70L+20)(R+m)+44n(70L + 20)(R + m) + 44n against every offline execution from the same initial tree that serves the same mm requests with RR rotations.

theoremTango.Algorithm.Results.exists_competitive_linearpropext · Classical.choice · Quot.soundAlgorithms/Tango/Algorithm/Abstract.lean:63
/-- **Tango with linear startup.** The same statement with startup `44n`instead of `O(n log log n)`, at a larger coefficient. The algorithm runs thebottom-up policy (`Tango.BottomUp`), which pays for first preference settingsfrom local credit, at most `42n` on the balanced reference; reaching thereference from another initial tree costs at most `2n` more. -/theorem exists_competitive_linear (n : Nat) :    ∃ A : Algorithm, ∀ {start finish : Tree} {xs : List Nat} {offline : Nat},      start.size = n → Execution start xs finish offline →        (A.totalCost start xs : ℝ) ≤          (70 * Real.logb 2 (Nat.log2 n + 1) + 20) * (offline + xs.length : Nat) + 44 * n :=  Tango.exists_online_linear_bound n

It has the same shape as Results.exists_competitive of Section 26.2, which uses the top-down policy, with a larger factor and a linear additive term.

The real consumer is the combination of Chapter 31. There the bottom-up policy, packaged by rotation_algorithm, becomes an interruptible Tango worker for the ComboBST machinery of Section 29.1, with startup 2816n2816n (Results.linear_balanced_worker). Its linear startup is what lets the combined bound of Theorem 4.3, Results.combined, keep an additive O(n)O(n).