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

Chapter 29 · Combining search trees · Section 29.4One online execution

Section 29.2 and Section 29.3 built the logical side of Combo-BST. A worker packages the two source algorithms A0A_0 and A1A_1 as interruptible step functions, and the controller runs them in alternating bounded rounds, restoring the initial tree whenever it switches. All costs there are counted in worker units: one unit per worker step, plus an explicit restore charge per switch. Nothing there is yet a binary search tree.

This section turns the controller into one physical online BST algorithm, and proves its bounds. It is the last step of Theorem 3 of Demaine, Iacono, Langerman and Özkan (2013). There are three ingredients.

  1. Refinement onto shared nodes. Each worker step becomes a bounded number of instructions on a tree buffer with two persistent fingers: finger 0 is the worker’s cursor, finger 1 keeps the scan position of the saved snapshot. Restoring the initial tree is a streaming load of that snapshot. This is the paper’s Combo-MFBST, a multi-finger BST in the sense of Chapter 10.
  2. One finger. The finger hand of Section 35.2 simulates the two fingers with the single root-restarting cursor of the pointer machine (Chapter 7). This is the paper’s OneFinger-BST (its Theorem 5), applied to Combo-MFBST.
  3. One fixed policy. All choices, the snapshot, the hand, and the instructions of every request, are fixed once, before any request is known. Preparation is paid on the first request. The result is one online algorithm, and its actual run is analysed on every prefix and on every contiguous window.

The window theorem, window_policy, is the formal Theorem 3. Its headline box is in Section 29.1. This section’s own headline is the whole-prefix version, which has a slightly sharper formula.

Main result · Demaine et al. 2013
One fixed online pointer algorithm is within the better of two bounds on every prefix

Let TT be a nonempty tree on nn keys, and let a worker present two source algorithms A0A_0 and A1A_1 on TT, with a causal pointer interpretation in which every access visits its key. Suppose both have well-behaved nonnegative amortized charges τ0,τ1\tau_0, \tau_1 with constants C0,C1C_0, C_1 and overhead F≥nF \ge n. Then there is one prepared online policy pp, fixed before any request is known, such that for every sequence XX of keys in {0,…,n−1}\{0,\dots,n-1\}, pp serves XX as a legal pointer-machine execution from TT, and its total cost, pointer instructions plus one unit per request, is at most

524⋅1088 n  +  8384 (C1+58)(2C0min⁡(∑i<∣X∣τ0(X,i), ∑i<∣X∣τ1(X,i))+3F).524 \cdot 1088\, n \;+\; 8384\,(C_1 + 58)\Bigl(2C_0 \min\Bigl(\sum_{i<|X|} \tau_0(X,i),\ \sum_{i<|X|} \tau_1(X,i)\Bigr) + 3F\Bigr).

In Lean, the worker is a Controller.Worker with a Refinement.WorkerModel satisfying Visits.Correct, the charges satisfy Analysis.WellBehaved, and the policy is a Online.Prepared run by Online.execute from the optional state none. The execution is a Pointer.Execution from T, in which every request starts at the root. The policy is chosen before the sequence (∃ p, ∀ xs), and the smaller of the two sums is chosen only in the proof.

The Lean statement
theoremCombo.Online.Results.prefix_policypropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:72
theorem prefix_policy (model : Refinement.WorkerModel worker saved) (correct : Refinement.Visits.Correct model)    {overhead C₀ C₁ : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (nonempty : saved ≠ .nil) (size : saved.size ≤ overhead)    (fields : Nat → IntervalMetadata.Bounds) (oldData : Nat → Nat) :    ∃ p : Prepared model (Analysis.budget overhead C₁) (57 * overhead) fields oldData,      ∀ xs, (∀ x ∈ xs, x < saved.size) →        Pointer.Execution saved xs (p.current (execute p none xs).1) (execute p none xs).2 ∧          ((execute p none xs).2 : ℝ) ≤ 524 * (1088 * saved.size : ℝ) + 8384 * (C₁ + 1 + 57 : Nat) *            (2 * C₀ * min (Analysis.total charges false xs) (Analysis.total charges true xs) + 3 * overhead) := …  RotationBST.Combo.Online.prefix_policy model correct well nonempty size fields oldData
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
139 definitions in 12 chapters · reading list

The section has two layers. A reader who wants the statement can stop at the box above, or at Section 29.1 for the window version. The rest explains the construction in the order of its proof. The first section gives the overview and the constants. Then come the refinement of worker steps onto shared nodes, the online state and one request, preparation and the treatment of the first request and of empty input, the whole-prefix bound, the window bound for the actual run, and finally how the combined policy is packaged back into a worker, so that it can itself be combined again. The last section lists what is not claimed.

The definitions are in Algorithms/Combination/Refinement/Definitions/Abstract.lean, Refinement/Visits/Definitions/Abstract.lean, Online/Definitions/Abstract.lean, Online/Startup/Definitions/Abstract.lean, Online/Algorithm/Abstract.lean and Online/Replay/Definitions/Abstract.lean. The theorems are in Refinement/Abstract.lean, Online/Abstract.lean and Online/Replay/Abstract.lean.

29.4.1 Overview

Combo-BST has four levels of description. Each level refines the one above, and each refinement multiplies the cost by a constant.

  controller run        worker units: steps + restore charges      (Sections 29.2–29.3)
        │  ×15 per step, restore ≤ 841 n
        ▼
  shared-node trace     2 fingers on one labelled tree buffer       (Chapter 39)
        │  ×524 per instruction (finger hand, 2 fingers + root anchor)
        ▼
  pointer execution     one cursor, every request from the root    (Chapter 7, Section 35.2)

Throughout, TT is the common initial tree (saved), n=∣T∣n = |T| its size, and requests are inorder ranks less than nn. The overhead FF (overhead) is the one of the well-behaved charges, and the hypothesis n≤Fn \le F is the paper’s f(n)≥nf(n) \ge n. The controller uses round budget B=(C1+1)FB = (C_1 + 1)F (Analysis.budget) and restore charge 57F57F. The constants in the statements come from the following facts.

Constant Meaning
1515 shared-node cost of one worker step: a maintained rotation updates interval metadata and costs 15
841 n841\,n shared-node cost of one streaming restoration of the snapshot
5757 restore factor: 841 n≤15⋅57F841\,n \le 15 \cdot 57 F because n≤Fn \le F and 841≤855841 \le 855
1088 n1088\,n shared-node cost of startup: initializing the node fields and saving the snapshot
524524 finger-hand cost per multi-finger instruction with two fingers, 344+60⋅3344 + 60\cdot 3 (Section 35.2)
83848384 16⋅52416 \cdot 524: pointer cost per worker unit of a request, including its request unit
570112 n570112\,n 524⋅1088 n524 \cdot 1088\, n: the pointer cost of preparation
32 n32\,n upper bound on the potential carried by a maintained hand

The logical analysis, which compares controller work with min⁡(τ0,τ1)\min(\tau_0, \tau_1), is in Section 29.1 and Section 29.3: Results.minimum_bound for prefixes and Results.executed_window for windows. This section multiplies those bounds by the refinement constants, and makes sure that the multiplication is applied to one fixed online execution, not to a family of executions chosen after the input.

29.4.2 Workers on shared nodes

The paper’s Combo-MFBST keeps the initial tree state in a tree state buffer and runs the source algorithm with further fingers in the same tree (Section 39.1, Section 39.2). The library’s refinement says what an abstract worker must provide to be run that way, and what the shared-node trace then costs.

29.4.2.1 A pointer interpretation of the worker

structureCombo.Refinement.WorkerModelpropextAlgorithms/Combination/Refinement/Definitions/Abstract.lean:9
/-- A causal pointer interpretation of an abstract worker. Each charged stepemits one legal pointer opcode or keeps the cursor fixed for local bookkeeping.The invariant also identifies the fixed key set and the common restart tree.This contract does not assert request service or finite-word storage. -/structure WorkerModel {σ : Type} (worker : Controller.Worker σ) (saved : Tree) where  cursor : Bool → σ → Pointer.Config  Ready : Bool → σ → Prop  instruction : Bool → σ → Nat → Option Multifinger.Opcode  restart_ready : ∀ side, Ready side (worker.restart side)  restart_cursor : ∀ side, cursor side (worker.restart side) = ⟨saved, []⟩  size : ∀ side state, Ready side state → (cursor side state).tree.size = saved.size  step_ready : ∀ side state x, Ready side state → x < saved.size → Ready side (worker.step side state x).1  step_cursor : ∀ side state x, Ready side state → x < saved.size →    match instruction side state x with    | none => cursor side (worker.step side state x).1 = cursor side state    | some op => Multifinger.perform op (cursor side state) = some (cursor side (worker.step side state x).1)
theoremCombo.Refinement.WorkerModel.restart_readypropextAlgorithms/Combination/Refinement/Definitions/Abstract.lean:17
restart_ready
Statement reads only Algorithms/Combination/Refinement/Definitions/Abstract.lean and its imports
theoremCombo.Refinement.WorkerModel.restart_cursorpropextAlgorithms/Combination/Refinement/Definitions/Abstract.lean:18
restart_cursor
Statement reads only Algorithms/Combination/Refinement/Definitions/Abstract.lean and its imports
theoremCombo.Refinement.WorkerModel.sizepropextAlgorithms/Combination/Refinement/Definitions/Abstract.lean:19
size
Statement reads only Algorithms/Combination/Refinement/Definitions/Abstract.lean and its imports
theoremCombo.Refinement.WorkerModel.step_readypropextAlgorithms/Combination/Refinement/Definitions/Abstract.lean:20
step_ready
Statement reads only Algorithms/Combination/Refinement/Definitions/Abstract.lean and its imports
theoremCombo.Refinement.WorkerModel.step_cursorpropextAlgorithms/Combination/Refinement/Definitions/Abstract.lean:21
step_cursor
Statement reads only Algorithms/Combination/Refinement/Definitions/Abstract.lean and its imports

A WorkerModel worker saved interprets every worker state, on each side, as a pointer configuration (Pointer.Config): the tree the source algorithm currently has, and where its cursor is. Ready is an invariant of the reachable states. instruction side state x is what the next charged step does physically: either one opcode of Multifinger.Opcode at the cursor, or nothing (none), for a step of pure local bookkeeping. The fields say:

  • restart_ready, restart_cursor: the restart state of each side is ready, and its cursor is the root of saved. Both sources therefore start from the same tree, which is the tree the snapshot holds.
  • size: ready states keep the key set, so the cursor’s tree always has nn nodes.
  • step_ready, step_cursor: on a valid request, a step keeps readiness, and moves the cursor exactly as its instruction says. A some op step is the legal instruction Multifinger.perform op; a none step leaves the cursor where it is.

So a model is causal: each step’s physical effect is determined by the current state and the current request. It does not say that the worker serves requests correctly. That is the next definition.

29.4.2.2 Visiting the requested key

defCombo.Refinement.Visits.Boundaryno axiomsAlgorithms/Combination/Refinement/Visits/Definitions/Abstract.lean:9
/-- A request boundary reached by completed valid requests of one worker.This is a proof certificate, not a stored runtime history. -/def Boundary {σ : Type} (worker : Controller.Worker σ) (n : Nat) (side : Bool) (state : σ) : Prop :=  ∃ earlier spent, Worker.Requests worker side (worker.restart side) earlier state spent ∧ ∀ x ∈ earlier, x < n
defCombo.Refinement.Visits.SeenpropextAlgorithms/Combination/Refinement/Visits/Definitions/Abstract.lean:14
/-- Cursor visits along exactly the consumed worker steps, including theinitial and final cursor. Completion need not occur at the requested key. -/def Seen {σ : Type} {worker : Controller.Worker σ} {saved : Tree} (model : WorkerModel worker saved)    (side : Bool) (x : Nat) : Nat → σ → Prop  | 0, state => (model.cursor side state).key? = some x  | count + 1, state => (model.cursor side state).key? = some x ∨ Seen model side x count (worker.step side state x).1
defCombo.Refinement.Visits.CorrectpropextAlgorithms/Combination/Refinement/Visits/Definitions/Abstract.lean:21
/-- The input algorithm's request-correctness contract is imposed only atreachable request boundaries. It allows cleanup after visiting the key anddoes not assume anything about the controller's eventual physical trace. -/def Correct {σ : Type} {worker : Controller.Worker σ} {saved : Tree} (model : WorkerModel worker saved) : Prop :=  ∀ side state x final work, Boundary worker saved.size side state → x < saved.size →    Worker.Access worker side state x final work → Seen model side x work state

Boundary worker n side state says that state is reached from the restart state of side by completing some valid requests (a Worker.Requests). It is a proof certificate, not data the algorithm stores. Seen model side x count state says that the cursor stands on key xx at some point during the next count steps on request xx, counting the starting and the final cursor. Correct model is the request contract of the source algorithms: from every reachable boundary, every complete access of a valid key (Worker.Access) visits that key with the cursor. The access may continue working after the visit, as Pointer.Serves allows.

The contract is imposed only at reachable boundaries, and only on the source algorithms. It says nothing about the controller, which interrupts accesses at arbitrary points. That an interrupted and restarted run still visits each key is proved, not assumed.

29.4.2.3 The representation invariant

defCombo.Refinement.RepresentspropextAlgorithms/Combination/Refinement/Definitions/Abstract.lean:26
/-- The worker uses finger zero; finger one retains the snapshot scan position.Both fingers denote nodes of the same tree, including during interruptions. -/def Represents {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) (data : Nat → Nat) (actual : TreeBuffer.Shared.State Nat 2)    (side : Bool) (state : σ) : Prop :=  model.Ready side state ∧ actual.Valid data ∧ actual.tree.erase = (model.cursor side state).tree ∧    (model.cursor side state).key? = some (actual.position 0)

Represents model data actual side state ties a worker state to a two-finger Shared.State. The worker state is ready, the shared tree is valid with node payloads data (State.Valid), its plain shape is the cursor’s tree, and finger 0 stands on the cursor’s key. Finger 1 is free: it holds the scan position of the snapshot. Both fingers denote nodes of the same tree, so there is never a second copy of the tree.

29.4.2.4 What a refined run costs

The following theorems lift worker steps, attempts, services and whole controller runs to shared-node traces (Shared.Trace). Each has the same shape: given a representing shared state, there is a trace to a state that represents the next logical state, every cell event of the trace is a correct read of data (Refinement.Reads), and the cost is bounded.

Theorem (one step, one attempt). One worker step on a valid request costs at most 1515 on shared nodes and leaves finger 1 in place. An attempt of ww steps costs at most 15w15w.

theoremCombo.Refinement.Results.worker_steppropext · Classical.choice · Quot.soundAlgorithms/Combination/Refinement/Abstract.lean:11
theorem worker_step {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) (data : Nat → Nat) (actual : Shared.State Nat 2)    (side : Bool) (state : σ) (represented : Represents model data actual side state)    (x : Nat) (valid : x < saved.size) :    ∃ final events cost, Shared.Trace actual final events cost ∧      Represents model data final side (worker.step side state x).1 ∧ Reads data events ∧      final.position 1 = actual.position 1 ∧ cost ≤ 15 :=  RotationBST.Combo.Refinement.worker_step model data actual side state represented x valid
theoremCombo.Refinement.Results.attemptpropext · Classical.choice · Quot.soundAlgorithms/Combination/Refinement/Abstract.lean:20
theorem attempt {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) {side : Bool} {x fuel work : Nat} {state : σ} {result : Controller.Attempt σ}    (run : Controller.AttemptRun worker side x fuel state result work) (valid : x < saved.size)    (data : Nat → Nat) (actual : Shared.State Nat 2) (represented : Represents model data actual side state) :    ∃ final events cost, Shared.Trace actual final events cost ∧ Represents model data final side result.state ∧      Reads data events ∧ final.position 1 = actual.position 1 ∧ cost ≤ 15 * work :=  RotationBST.Combo.Refinement.attempt model run valid data actual represented

Theorem (restart). If the payloads hold the snapshot of saved (CellIO.Stored), the shared tree can be restored to the restart state of either side at cost at most 841n841n, reading only snapshot cells.

theoremCombo.Refinement.Results.restartpropext · Classical.choice · Quot.soundAlgorithms/Combination/Refinement/Abstract.lean:28
theorem restart {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) (data : Nat → Nat) (stored : Snapshot.CellIO.Stored saved data)    (actual : Shared.State Nat 2) (side : Bool) (state : σ) (represented : Represents model data actual side state)    (nextSide : Bool) :    ∃ final events cost, Shared.Trace actual final events cost ∧      Represents model data final nextSide (worker.restart nextSide) ∧ Reads data events ∧ cost ≤ 841 * saved.size :=  RotationBST.Combo.Refinement.restart model data stored actual side state represented nextSide

The restored worker may be on the other side (nextSide): this is the switch of the controller. The cost does not depend on how far the interrupted worker had moved the tree.

Theorem (service and execution). Suppose the restore charge pays for a restoration, 841n≤15⋅restore841n \le 15 \cdot \mathit{restore}. Then one controller service (Controller.Service) with logical work ww, including its restore charge, costs at most 15w15w on shared nodes, and so does a whole controller execution (Controller.Execution) of logical work ww.

theoremCombo.Refinement.Results.servicepropext · Classical.choice · Quot.soundAlgorithms/Combination/Refinement/Abstract.lean:36
theorem service {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) {budget restore : Nat} {s : Controller.State σ} {x : Nat} {result : Controller.Result σ}    (run : Controller.Service worker budget restore s x result) (valid : x < saved.size)    (paid : 841 * saved.size ≤ 15 * restore) (data : Nat → Nat) (stored : Snapshot.CellIO.Stored saved data)    (actual : Shared.State Nat 2) (represented : Represents model data actual s.side s.workerState) :    ∃ final events cost, Shared.Trace actual final events cost ∧      Represents model data final result.state.side result.state.workerState ∧ Reads data events ∧ cost ≤ 15 * result.work :=  RotationBST.Combo.Refinement.service model run valid paid data stored actual represented
theoremCombo.Refinement.Results.executionpropext · Classical.choice · Quot.soundAlgorithms/Combination/Refinement/Abstract.lean:45
theorem execution {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) {budget restore : Nat} {s t : Controller.State σ} {xs : List Nat} {work switches : Nat}    (run : Controller.Execution worker budget restore s xs t work switches) (valid : ∀ x ∈ xs, x < saved.size)    (paid : 841 * saved.size ≤ 15 * restore) (data : Nat → Nat) (stored : Snapshot.CellIO.Stored saved data)    (actual : Shared.State Nat 2) (represented : Represents model data actual s.side s.workerState) :    ∃ final events cost, Shared.Trace actual final events cost ∧      Represents model data final t.side t.workerState ∧ Reads data events ∧ cost ≤ 15 * work :=  RotationBST.Combo.Refinement.execution model run valid paid data stored actual represented

Theorem (refined minimum bound). With well-behaved charges, budget (C1+1)F(C_1 + 1)F and restore charge rFrF, a controller execution from the initial state, refined onto shared nodes, costs at most 15(C1+1+r)(2C0min⁡(∑τ0,∑τ1)+3F)15(C_1 + 1 + r)\bigl(2C_0 \min(\textstyle\sum\tau_0, \sum\tau_1) + 3F\bigr).

theoremCombo.Refinement.Results.execution_boundpropext · Classical.choice · Quot.soundAlgorithms/Combination/Refinement/Abstract.lean:54
theorem execution_bound {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) {overhead C₀ C₁ restoreFactor : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    {t : Controller.State σ} {xs : List Nat} {work switches : Nat}    (run : Controller.Execution worker (Analysis.budget overhead C₁) (restoreFactor * overhead)      (Controller.initial worker (Analysis.budget overhead C₁)) xs t work switches)    (valid : ∀ x ∈ xs, x < saved.size) (paid : 841 * saved.size ≤ 15 * (restoreFactor * overhead))    (data : Nat → Nat) (stored : Snapshot.CellIO.Stored saved data)    (actual : Shared.State Nat 2) (represented : Represents model data actual false (worker.restart false)) :    ∃ final events cost, Shared.Trace actual final events cost ∧ Represents model data final t.side t.workerState ∧      Reads data events ∧ (cost : ℝ) ≤ 15 * (C₁ + 1 + restoreFactor : Nat) *        (2 * C₀ * min (Analysis.total charges false xs) (Analysis.total charges true xs) + 3 * overhead) :=  RotationBST.Combo.Refinement.execution_bound model well run valid paid data stored actual represented

This is Results.minimum_bound multiplied by 1515.

Theorem (refined startup). For a nonempty tree with n≤Fn \le F and any valid sequence XX, there is a startup that initializes the node fields and saves the snapshot (Startup.Execution), after which the controller with restore charge 57F57F runs on XX without failure, and the refined run represents its final state. The startup and the run together cost at most 1088n+15(C1+58)(2C0min⁡(∑τ0,∑τ1)+3F)1088n + 15(C_1 + 58)\bigl(2C_0 \min(\sum\tau_0, \sum\tau_1) + 3F\bigr) on shared nodes.

theoremCombo.Refinement.Results.startuppropext · Classical.choice · Quot.soundAlgorithms/Combination/Refinement/Abstract.lean:68
theorem startup {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : WorkerModel worker saved) {overhead C₀ C₁ : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (nonempty : saved ≠ .nil) (size : saved.size ≤ overhead)    (fields : Nat → IntervalMetadata.Bounds) (data : Nat → Nat) (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) :    ∃ ready snapshotData saveEvents saveCost final events cost endState work switches,      Snapshot.Startup.Execution saved saved.size fields data ready saveEvents saveCost ∧      Snapshot.CellIO.Stored saved snapshotData ∧      Controller.run worker (Analysis.budget overhead C₁) (57 * overhead)        (Controller.initial worker (Analysis.budget overhead C₁)) xs = some (endState, work) ∧      Controller.Execution worker (Analysis.budget overhead C₁) (57 * overhead)        (Controller.initial worker (Analysis.budget overhead C₁)) xs endState work switches ∧      Shared.Trace ready final events cost ∧ Represents model snapshotData final endState.side endState.workerState ∧      Reads snapshotData events ∧ (saveCost + cost : Nat) ≤ (1088 * saved.size : ℝ) + 15 * (C₁ + 1 + 57 : Nat) *        (2 * C₀ * min (Analysis.total charges false xs) (Analysis.total charges true xs) + 3 * overhead) :=  RotationBST.Combo.Refinement.startup model well nonempty size fields data xs valid

This is the shared-node form of the combination, the paper’s Combo-MFBST. Its arguments fields and data are the arbitrary initial contents of the extra node fields. Note the quantifiers: the sequence xs is a parameter, and the trace, the snapshot data and the final state are existential after it. So this is a statement about one sequence at a time, an offline witness. The rest of the section removes that dependence.

29.4.3 The online state and one request

The online policy carries the logical controller state, the shared-node state and a finger hand together, with certificates that they agree.

structureCombo.Online.ContractpropextAlgorithms/Combination/Online/Definitions/Abstract.lean:13
/-- Fixed proof obligations for a causal request rule. No future input appearsin the contract; the snapshot and restore charge remain fixed throughout. -/structure Contract {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : Refinement.WorkerModel worker saved) (data : Nat → Nat) (budget restore : Nat) : Prop where  correct : Refinement.Visits.Correct model  stored : Snapshot.CellIO.Stored saved data  paid : 841 * saved.size ≤ 15 * restore  fresh : Controller.FreshBound worker saved.size budget
theoremCombo.Online.Contract.correctpropextAlgorithms/Combination/Online/Definitions/Abstract.lean:17
correct
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports
theoremCombo.Online.Contract.storedpropextAlgorithms/Combination/Online/Definitions/Abstract.lean:18
stored
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports
theoremCombo.Online.Contract.paidpropextAlgorithms/Combination/Online/Definitions/Abstract.lean:19
paid
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports
theoremCombo.Online.Contract.freshpropextAlgorithms/Combination/Online/Definitions/Abstract.lean:20
fresh
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports

A Contract collects the fixed obligations of one run: the visit contract of the sources, the snapshot stored in the payloads data, the restore charge paying for restoration, and Controller.FreshBound, which says that every valid request completes within one budget from a fresh restart. None of them mentions future requests.

structureCombo.Online.Statepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Definitions/Abstract.lean:22
/-- The controller, annotated virtual tree, and maintained physical hand.The certificates record invariants, not runtime history or future requests.Finite-word storage of this representation is a separate refinement. -/structure State {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : Refinement.WorkerModel worker saved) (data : Nat → Nat) (budget : Nat) where  controller : Controller.State σ  actual : Shared.State Nat 2  hand : FingerHand.Hand  represented : Refinement.Represents model data actual controller.side controller.workerState  boundary : Refinement.Visits.Boundary worker saved.size controller.side controller.workerState  handRep : hand.Represents actual.erase  left_le : controller.left ≤ budget
theoremCombo.Online.State.representedpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Definitions/Abstract.lean:30
represented
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports
theoremCombo.Online.State.boundarypropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Definitions/Abstract.lean:31
boundary
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports
theoremCombo.Online.State.handReppropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Definitions/Abstract.lean:32
handRep
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports
theoremCombo.Online.State.left_lepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Definitions/Abstract.lean:33
left_le
Statement reads only Algorithms/Combination/Online/Definitions/Abstract.lean and its imports

A State has three data fields: the controller state, the actual two-finger shared state, and a FingerHand.Hand. The physical BST is hand.tree. The four certificates say that the shared state represents the current worker state, that the worker state is at a request boundary, that the hand represents the erased shared state (Hand.Represents, Section 35.2), and that the remaining budget is at most BB. The certificates are invariants, not stored history.

defCombo.Online.Transitionpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Definitions/Abstract.lean:35
/-- One request preserves the exact controller transition, a legal physicalvisit, and a potential bound. The shared visit is retained as well, includingthe unchanged snapshot payload read by retries. -/def Transition {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    {model : Refinement.WorkerModel worker saved} {data : Nat → Nat} {budget : Nat}    (restore : Nat) (s : State model data budget) (x : Nat) (result : State model data budget × Nat) : Prop :=  result.1.controller = (Controller.serve worker budget restore s.controller x).state ∧  Pointer.Serves s.hand.tree result.1.hand.tree x result.2 ∧  result.2 + result.1.hand.potential ≤    8384 * (Controller.serve worker budget restore s.controller x).work + s.hand.potential ∧  ∃ events work, Shared.Requests.Visit s.actual result.1.actual x events work ∧    Snapshot.Streaming.Refinement.Reads data events ∧    work ≤ 15 * (Controller.serve worker budget restore s.controller x).work

Transition restore s x result is the specification of one request xx from the state s. The result is a next state and a pointer cost. It requires:

  1. the controller part is exactly Controller.serve on xx, so the logical run is the one of Section 29.3;
  2. the hand trees are related by a legal Pointer.Serves of xx at the reported cost: a search from the root that visits xx, possibly continues working, and pays one unit for the request;
  3. the amortized bound: cost plus the new hand potential is at most 83848384 times the logical work of the service plus the old hand potential;
  4. the shared state performs a Requests.Visit of xx (some finger stands on xx during the trace), reading only correct cells, at shared cost at most 1515 times the logical work.

The logical work includes the failed attempt and the restore charge when the request triggers a switch.

Theorem (every request completes, and has a transition). Under a contract, the controller completes every valid request, and every valid request has a transition.

theoremCombo.Online.Results.completespropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:13
theorem completes (contract : Contract model data budget restore) (s : State model data budget)    (x : Nat) (valid : x < saved.size) : (Controller.serve worker budget restore s.controller x).done = true :=  RotationBST.Combo.Online.completes contract s x valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
theoremCombo.Online.advance_existspropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Algorithm/Abstract.lean:11
theorem advance_exists (contract : Contract model data budget restore) (s : State model data budget)    (x : Nat) (valid : x < saved.size) : ∃ result, Transition restore s x result :=  transition_exists contract s x valid
Statement reads only Algorithms/Combination/Online/Algorithm/Abstract.lean and its imports

Completion uses fresh: if the current round fails, the other side starts fresh with the full budget and completes. The transition is built from the shared-node service, the visit theorem for interrupted runs, and the finger hand’s simulation of one multi-finger request, FingerHand.Hand.simulate_serves.

defCombo.Online.advancepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Algorithm/Abstract.lean:15
/-- A fixed rule chosen from the current state and request alone. Classicalchoice is permitted in the abstract pointer model; planning is uncharged. -/noncomputable def advance (contract : Contract model data budget restore) (s : State model data budget)    (x : Nat) : State model data budget × Nat :=  if valid : x < saved.size then Classical.choose (advance_exists contract s x valid) else (s, 0)
defCombo.Online.runpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Algorithm/Abstract.lean:21
noncomputable def run (contract : Contract model data budget restore) (s : State model data budget) :    List Nat → State model data budget × Nat  | [] => (s, 0)  | x :: xs =>      let next := advance contract s x      let rest := run contract next.1 xs      (rest.1, next.2 + rest.2)

advance contract s x chooses one transition for xx from ss, by classical choice. It sees only the current state and the current request. On an invalid key it returns (s, 0), a totalization that the theorems never use. run threads advance through a list and adds the costs. Classical choice is a legitimate online rule in the abstract BST model, where planning is free, but it is not an executable program.

theoremCombo.Online.Results.advance_specpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:17
theorem advance_spec (contract : Contract model data budget restore) (s : State model data budget)    (x : Nat) (valid : x < saved.size) : Transition restore s x (advance contract s x) :=  RotationBST.Combo.Online.advance_spec contract s x valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
theoremCombo.Online.Results.run_appendpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:21
theorem run_append (contract : Contract model data budget restore) (s : State model data budget) (xs ys : List Nat) :    run contract s (xs ++ ys) =      let first := run contract s xs      let rest := run contract first.1 ys      (rest.1, first.2 + rest.2) :=  RotationBST.Combo.Online.run_append contract s xs ys
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
theoremCombo.Online.Results.run_specpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:28
theorem run_spec (contract : Contract model data budget restore) (s : State model data budget)    (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) :    ∃ work switches,      Controller.Execution worker budget restore s.controller xs (run contract s xs).1.controller work switches ∧      Pointer.Execution s.hand.tree xs (run contract s xs).1.hand.tree (run contract s xs).2 ∧      (run contract s xs).2 + (run contract s xs).1.hand.potential ≤ 8384 * work + s.hand.potential :=  RotationBST.Combo.Online.run_spec contract s xs valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
theoremCombo.Online.Results.stored_potentialpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:84
theorem stored_potential (s : State model data budget) : s.hand.potential ≤ 32 * saved.size :=  RotationBST.Combo.Online.State.potential s
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

advance_spec says that the chosen step satisfies Transition. run_append is exact composition: running X⋅YX \cdot Y is running XX and then YY from where XX left off, with the costs added. Since appending requests cannot change the run on the prefix, run is online. run_spec sums the transitions: the logical part is a controller execution of some work ww, the physical part is a Pointer.Execution between the two hand trees, and the cost plus the final potential is at most 8384w8384w plus the initial potential. stored_potential bounds the potential of any maintained hand by 32n32n, so the potential never costs more than a linear term.

29.4.4 Preparation, the first request, and empty input

Before the first request, the snapshot must be saved and the hand built. The library fixes this preparation once, independently of the requests.

structureCombo.Online.Preparedpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:10
/-- A fixed, charged preparation, chosen before any request is supplied.The snapshot and maintained hand are coupled to the same actual shared state. -/structure Prepared {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : Refinement.WorkerModel worker saved) (budget restore : Nat)    (fields : Nat → IntervalMetadata.Bounds) (oldData : Nat → Nat) where  data : Nat → Nat  contract : Contract model data budget restore  state : State model data budget  controller_initial : state.controller = Controller.initial worker budget  saveEvents : List (Cells.Event Nat)  saveCost : Nat  setup : Snapshot.Startup.Execution saved saved.size fields oldData state.actual saveEvents saveCost  saveBound : saveCost ≤ 1088 * saved.size  cost : Nat  trace : Pointer.Trace ⟨saved, []⟩ ⟨state.hand.tree, []⟩ cost  charged : cost + state.hand.potential ≤ 524 * saveCost
theoremCombo.Online.Prepared.contractpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:16
contract
Statement reads only Algorithms/Combination/Online/Startup/Definitions/Abstract.lean and its imports
theoremCombo.Online.Prepared.controller_initialpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:18
controller_initial
Statement reads only Algorithms/Combination/Online/Startup/Definitions/Abstract.lean and its imports
theoremCombo.Online.Prepared.setuppropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:21
setup
Statement reads only Algorithms/Combination/Online/Startup/Definitions/Abstract.lean and its imports
theoremCombo.Online.Prepared.saveBoundpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:22
saveBound
Statement reads only Algorithms/Combination/Online/Startup/Definitions/Abstract.lean and its imports
theoremCombo.Online.Prepared.tracepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:24
trace
Statement reads only Algorithms/Combination/Online/Startup/Definitions/Abstract.lean and its imports
theoremCombo.Online.Prepared.chargedpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:25
charged
Statement reads only Algorithms/Combination/Online/Startup/Definitions/Abstract.lean and its imports

A Prepared model budget restore fields oldData consists of:

  • the snapshot payloads data and a contract for them;
  • the starting online state, whose controller is Controller.initial (controller_initial), on side A0A_0 with a full budget;
  • the shared-node startup setup from the original fields fields and payloads oldData, with its events and its cost saveCost ≤1088n\le 1088n (saveBound);
  • a pointer trace (Pointer.Trace) of cost cost from the root of saved to the root of the starting hand tree (trace), with cost plus the starting hand potential at most 524⋅524 \cdotsaveCost (charged).

The pointer trace is the physical preparation: the single cursor carries out the simulated startup. It starts and ends at the root, so it can be prepended to a search.

defCombo.Online.Prepared.currentpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:27
/-- `none` is the original tree before the first request triggers preparation. -/def Prepared.current {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    {model : Refinement.WorkerModel worker saved} {budget restore : Nat}    {fields : Nat → IntervalMetadata.Bounds} {oldData : Nat → Nat}    (p : Prepared model budget restore fields oldData) (s : Option (State model p.data budget)) : Tree :=  match s with  | none => saved  | some ready => ready.hand.tree
defCombo.Online.Prepared.controllerpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Startup/Definitions/Abstract.lean:36
/-- The same optional state projected to its logical controller boundary. -/def Prepared.controller {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    {model : Refinement.WorkerModel worker saved} {budget restore : Nat}    {fields : Nat → IntervalMetadata.Bounds} {oldData : Nat → Nat}    (p : Prepared model budget restore fields oldData) (s : Option (State model p.data budget)) : Controller.State σ :=  match s with  | none => Controller.initial worker budget  | some ready => ready.controller

The policy’s state is an Option: none means that nothing has happened yet, and the BST is still saved; some ready means that preparation has run, and the BST is ready.hand.tree. current reads off the physical tree, and controller the logical controller state, which for none is the initial one.

theoremCombo.Online.preparation_existspropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Algorithm/Abstract.lean:29
theorem preparation_exists {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : Refinement.WorkerModel worker saved) (correct : Refinement.Visits.Correct model)    (budget restore : Nat) (fresh : Controller.FreshBound worker saved.size budget)    (paid : 841 * saved.size ≤ 15 * restore) (nonempty : saved ≠ .nil)    (fields : Nat → IntervalMetadata.Bounds) (oldData : Nat → Nat) :    Nonempty (Prepared model budget restore fields oldData) :=  prepared_nonempty model correct budget restore fresh paid nonempty fields oldData
Statement reads only Algorithms/Combination/Online/Algorithm/Abstract.lean and its imports
defCombo.Online.preparepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Algorithm/Abstract.lean:37
/-- Initialization is fixed before any request list is presented. -/noncomputable def prepare (model : Refinement.WorkerModel worker saved) (correct : Refinement.Visits.Correct model)    (budget restore : Nat) (fresh : Controller.FreshBound worker saved.size budget)    (paid : 841 * saved.size ≤ 15 * restore) (nonempty : saved ≠ .nil)    (fields : Nat → IntervalMetadata.Bounds) (oldData : Nat → Nat) :    Prepared model budget restore fields oldData :=  Classical.choice (preparation_exists model correct budget restore fresh paid nonempty fields oldData)

Theorem (preparation exists). For a nonempty tree, a visit-correct model, a budget satisfying the fresh bound and a restore charge paying for restoration, a preparation exists, for any initial node fields.

prepare chooses one. Its arguments contain no request sequence, so the choice is made before any request is presented.

defCombo.Online.accesspropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Algorithm/Abstract.lean:45
/-- Optional state records whether preparation has run. It is charged exactlyonce, on the first request, and never inserted into an empty input. -/noncomputable def access {fields : Nat → IntervalMetadata.Bounds} {oldData : Nat → Nat}    (p : Prepared model budget restore fields oldData) (s : Option (State model p.data budget)) (x : Nat) :    Option (State model p.data budget) × Nat :=  match s with  | none => let next := advance p.contract p.state x; (some next.1, p.cost + next.2)  | some ready => let next := advance p.contract ready x; (some next.1, next.2)
defCombo.Online.executepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Algorithm/Abstract.lean:54
noncomputable def execute {fields : Nat → IntervalMetadata.Bounds} {oldData : Nat → Nat}    (p : Prepared model budget restore fields oldData) (s : Option (State model p.data budget)) :    List Nat → Option (State model p.data budget) × Nat  | [] => (s, 0)  | x :: xs =>      let next := access p s x      let rest := execute p next.1 xs      (rest.1, next.2 + rest.2)

access p s x serves one request. From none, it advances from the prepared state and charges the preparation cost p.cost together with the cost of the request: preparation is paid on the first request. From some ready, it just advances. execute threads access through a list. On the empty list it returns the state unchanged at cost 00, so preparation is never inserted into an empty input, and an empty continuation costs nothing.

Theorem (composition of the online policy). Executing from a prepared state is run; executing from none on a nonempty list is run from the prepared state plus the preparation cost; and executions compose exactly over concatenation.

theoremCombo.Online.Results.execute_readypropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:44
theorem execute_ready (p : Prepared model budget restore fields oldData)    (s : State model p.data budget) (xs : List Nat) :    execute p (some s) xs = (some (run p.contract s xs).1, (run p.contract s xs).2) :=  RotationBST.Combo.Online.execute_ready p s xs
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
theoremCombo.Online.Results.execute_firstpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:49
theorem execute_first (p : Prepared model budget restore fields oldData) (x : Nat) (xs : List Nat) :    execute p none (x :: xs) =      (some (run p.contract p.state (x :: xs)).1, p.cost + (run p.contract p.state (x :: xs)).2) :=  RotationBST.Combo.Online.execute_first p x xs
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
theoremCombo.Online.Results.execute_appendpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:36
theorem execute_append (p : Prepared model budget restore fields oldData)    (s : Option (State model p.data budget)) (xs ys : List Nat) :    execute p s (xs ++ ys) =      let first := execute p s xs      let rest := execute p first.1 ys      (rest.1, first.2 + rest.2) :=  RotationBST.Combo.Online.execute_append p s xs ys
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

execute_append makes the policy online in the precise sense used below: the state and cost after a prefix do not depend on the requests that follow.

Theorem (the policy serves every valid sequence). For every valid sequence XX, the run of a prepared policy from none is a legal pointer execution of XX from saved, refining a controller execution of logical work ww from the initial state, with total cost at most 524⋅saveCost+8384w524 \cdot \mathit{saveCost} + 8384w.

theoremCombo.Online.Results.execute_specpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:54
theorem execute_spec (p : Prepared model budget restore fields oldData)    (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) :    ∃ final work switches,      Controller.Execution worker budget restore (Controller.initial worker budget) xs final work switches ∧      Pointer.Execution saved xs (p.current (execute p none xs).1) (execute p none xs).2 ∧      (execute p none xs).2 ≤ 524 * p.saveCost + 8384 * work :=  RotationBST.Combo.Online.execute_spec p xs valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

For a nonempty sequence, the first request’s search is the preparation trace followed by the simulated search, so the whole run is one Pointer.Execution from saved. For the empty sequence the execution is empty and the bound is trivial.

Theorem (continuing from any state). The remaining budget of any optional state is at most BB. From any optional state, the continuation on a valid sequence is a legal pointer execution between the actual trees, refining a controller execution of logical work ww from that state, at cost at most 570112n+8384w570112n + 8384w.

theoremCombo.Online.Results.remaining_budgetpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:87
theorem remaining_budget (p : Prepared model budget restore fields oldData)    (s : Option (State model p.data budget)) : (p.controller s).left ≤ budget :=  RotationBST.Combo.Online.Prepared.left_le p s
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm
theoremCombo.Online.Results.execute_frompropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:91
theorem execute_from (p : Prepared model budget restore fields oldData)    (s : Option (State model p.data budget)) (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) :    ∃ final work switches,      Controller.Execution worker budget restore (p.controller s) xs final work switches ∧      Pointer.Execution (p.current s) xs (p.current (execute p s xs).1) (execute p s xs).2 ∧      (execute p s xs).2 ≤ 570112 * saved.size + 8384 * work :=  RotationBST.Combo.Online.execute_from p s xs valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

The additive term covers both cases at once. From none, it pays for the preparation, 524⋅1088n524 \cdot 1088n. From a prepared state, it pays for the carried hand potential, at most 32n32n, which a continuation cannot assume to be zero.

29.4.5 Whole prefixes

Theorem (prefix bound for a prepared policy). Let the charges be well-behaved, and let pp be prepared with budget (C1+1)F(C_1 + 1)F and restore charge rFrF. For every valid sequence XX, the run of pp is a legal pointer execution of XX from saved, with cost at most

524⋅1088 n+8384 (C1+1+r)(2C0min⁡(∑iτ0(X,i),∑iτ1(X,i))+3F).524 \cdot 1088\,n + 8384\,(C_1 + 1 + r)\Bigl(2C_0 \min\bigl(\textstyle\sum_i \tau_0(X,i), \sum_i \tau_1(X,i)\bigr) + 3F\Bigr).
theoremCombo.Online.Results.minimum_boundpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:62
theorem minimum_bound {overhead C₀ C₁ restoreFactor : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (p : Prepared model (Analysis.budget overhead C₁) (restoreFactor * overhead) fields oldData)    (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) :    Pointer.Execution saved xs (p.current (execute p none xs).1) (execute p none xs).2 ∧      ((execute p none xs).2 : ℝ) ≤ 524 * (1088 * saved.size : ℝ) +        8384 * (C₁ + 1 + restoreFactor : Nat) *          (2 * C₀ * min (Analysis.total charges false xs) (Analysis.total charges true xs) + 3 * overhead) :=  RotationBST.Combo.Online.minimum_bound well p xs valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

This is execute_spec combined with Results.minimum_bound. The sums are Analysis.total, the charges of the whole sequence.

Theorem (one policy for all prefixes). The headline statement: for a nonempty tree with n≤Fn \le F and a visit-correct model with well-behaved charges, there is one prepared policy with budget (C1+1)F(C_1 + 1)F and restore charge 57F57F that satisfies the bound above, with r=57r = 57, for every valid sequence.

theoremCombo.Online.Results.prefix_policypropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:72
theorem prefix_policy (model : Refinement.WorkerModel worker saved) (correct : Refinement.Visits.Correct model)    {overhead C₀ C₁ : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (nonempty : saved ≠ .nil) (size : saved.size ≤ overhead)    (fields : Nat → IntervalMetadata.Bounds) (oldData : Nat → Nat) :    ∃ p : Prepared model (Analysis.budget overhead C₁) (57 * overhead) fields oldData,      ∀ xs, (∀ x ∈ xs, x < saved.size) →        Pointer.Execution saved xs (p.current (execute p none xs).1) (execute p none xs).2 ∧          ((execute p none xs).2 : ℝ) ≤ 524 * (1088 * saved.size : ℝ) + 8384 * (C₁ + 1 + 57 : Nat) *            (2 * C₀ * min (Analysis.total charges false xs) (Analysis.total charges true xs) + 3 * overhead) :=  RotationBST.Combo.Online.prefix_policy model correct well nonempty size fields oldData
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

The proof takes pp to be prepare with budget (C1+1)F(C_1 + 1)F and restore charge 57F57F. The fresh bound comes from the single-access clause of Analysis.WellBehaved (C1F≤BC_1 F \le B), and the restore condition from n≤Fn \le F. So the policy depends on FF and C1C_1, but not on C0C_0, on the charges, or on the requests. Which of the two sums is smaller is decided only in the proof. The bound holds for every prefix of an infinite online sequence at once, since the run on a prefix is the beginning of the run on the whole.

29.4.6 Windows of the actual run

Theorem 3 of the paper is stronger than a prefix bound. It bounds the cost that Combo-BST spends on any contiguous window X′=(xlo,…,xhi−1)X' = (x_{lo}, \dots, x_{hi-1}) of the input XX, within its run on XX, by the amortized charges that the sources assign to the requests of X′X' as part of XX. The library proves exactly this for the actual run of the fixed policy.

Theorem (the run splits at a window). For every sequence XX and lo≤hilo \le hi, the run of a prepared policy on XX is the run on the prefix X[0,lo)X[0, lo), followed by the run on the window X[lo,hi)X[lo, hi) from the state the prefix left, followed by the run on the suffix X[hi,∣X∣)X[hi, |X|) from the state the window left. The final state is that of the suffix, and the cost is the sum of the three costs.

theoremCombo.Online.Results.execute_window_splitpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:113
theorem execute_window_split (p : Prepared model budget restore fields oldData)    (xs : List Nat) (lo hi : Nat) (ordered : lo ≤ hi) :    let first := execute p none (xs.take lo)    let middle := execute p first.1 (Analysis.segment xs lo hi)    let last := execute p middle.1 (xs.drop hi)    execute p none xs = (last.1, first.2 + middle.2 + last.2) :=  RotationBST.Combo.Online.execute_window_split p xs lo hi ordered
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

The window is Analysis.segment xs lo hi. The three parts are not three runs started afresh: the middle starts from the actual state after the prefix, the suffix from the actual state after the middle. In particular the window is not rerun from the saved tree, and the controller is not reset at lolo.

Theorem (window bound from any state). Let the charges be well-behaved and pp be prepared with budget (C1+1)F(C_1+1)F and restore charge rFrF. From any optional state ss, the run of pp on the window X[lo,hi)X[lo, hi) of a valid sequence XX is a legal pointer execution between the actual trees, with cost at most

570112 n+8384 (C1+1+r)(2C02min⁡(M0,M1)+(2C0C1+5)F),Mj=∑lo≤i<hiτj(X,i).570112\,n + 8384\,(C_1 + 1 + r)\Bigl(2C_0^2 \min\bigl(M_0, M_1\bigr) + (2C_0C_1 + 5)F\Bigr), \qquad M_j = \sum_{lo \le i < hi} \tau_j(X, i).
theoremCombo.Online.Results.window_boundpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:99
theorem window_bound {overhead C₀ C₁ restoreFactor : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (p : Prepared model (Analysis.budget overhead C₁) (restoreFactor * overhead) fields oldData)    (s : Option (State model p.data (Analysis.budget overhead C₁)))    (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) (lo hi : Nat)    (ordered : lo ≤ hi) (inside : hi ≤ xs.length) :    Pointer.Execution (p.current s) (Analysis.segment xs lo hi)        (p.current (execute p s (Analysis.segment xs lo hi)).1) (execute p s (Analysis.segment xs lo hi)).2 ∧      ((execute p s (Analysis.segment xs lo hi)).2 : ℝ) ≤ 570112 * (saved.size : ℝ) +        8384 * (C₁ + 1 + restoreFactor : Nat) *          (2 * C₀ * C₀ * min (Analysis.mass charges false xs lo hi) (Analysis.mass charges true xs lo hi) +            (2 * C₀ * C₁ + 5) * overhead) :=  RotationBST.Combo.Online.window_bound well p s xs valid lo hi ordered inside
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

MjM_j is Analysis.mass charges j xs lo hi. The charges are those of the original sequence XX at the original indices ii: τj(X,i)\tau_j(X, i) may depend on all of XX, in particular on the history before lolo. They are not the charges of the window viewed as a standalone sequence. The proof first compares the controller’s work with the window’s standalone charges, from an arbitrary controller state (Results.state_bound), and then uses the stability clause of Analysis.WellBehaved to convert those into original charges; this second comparison is where C02C_0^2 and the term 2C0C1F2C_0C_1F come from (Results.window_bound). The state ss is arbitrary, not necessarily one reached by the policy.

Theorem (executed window). For a prepared policy pp as above, a valid sequence XX and lo≤hi≤∣X∣lo \le hi \le |X|, write first\mathit{first}, middle\mathit{middle}, last\mathit{last} for the runs on the prefix, window and suffix as in the split. Then the run on XX is their exact composition, the middle is a legal pointer execution of X[lo,hi)X[lo, hi) from the actual tree after the prefix to the actual tree after the window, and the middle cost satisfies the window bound.

theoremCombo.Online.Results.executed_windowpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:121
theorem executed_window {overhead C₀ C₁ restoreFactor : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (p : Prepared model (Analysis.budget overhead C₁) (restoreFactor * overhead) fields oldData)    (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) (lo hi : Nat)    (ordered : lo ≤ hi) (inside : hi ≤ xs.length) :    let first := execute p none (xs.take lo)    let middle := execute p first.1 (Analysis.segment xs lo hi)    let last := execute p middle.1 (xs.drop hi)    execute p none xs = (last.1, first.2 + middle.2 + last.2) ∧      Pointer.Execution (p.current first.1) (Analysis.segment xs lo hi) (p.current middle.1) middle.2 ∧      (middle.2 : ℝ) ≤ 570112 * (saved.size : ℝ) + 8384 * (C₁ + 1 + restoreFactor : Nat) *        (2 * C₀ * C₀ * min (Analysis.mass charges false xs lo hi) (Analysis.mass charges true xs lo hi) +          (2 * C₀ * C₁ + 5) * overhead) :=  RotationBST.Combo.Online.executed_window well p xs valid lo hi ordered inside
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

The physical trees p.current first.1 and p.current middle.1 are the trees of the run on XX at times lolo and hihi. If lo=0lo = 0 the first is saved, and the middle includes the preparation; otherwise the middle starts from a prepared state and carries its hand potential. Both are covered by 570112n570112n. If lo=hilo = hi the middle is empty and costs 00.

Finally, the policy is fixed before both the requests and the window, and the linear term is absorbed into the overhead.

Theorem (Theorem 3, abstract form). Let TT be a nonempty tree on nn keys, and let the worker have a visit-correct pointer interpretation and well-behaved nonnegative charges τ0,τ1\tau_0, \tau_1 with constants C0,C1C_0, C_1 and overhead F≥nF \ge n. Then there is one prepared policy pp with budget (C1+1)F(C_1 + 1)F and restore charge 57F57F such that, for every sequence XX of keys in {0,…,n−1}\{0, \dots, n-1\}:

  1. the run of pp on XX is a legal pointer execution from TT; and
  2. for every lo≤hi≤∣X∣lo \le hi \le |X|, the run on XX splits exactly into prefix, window and suffix as above, the window part is a legal pointer execution between the actual trees at times lolo and hihi, and its cost is at most
8384 (C1+58)(2C02min⁡(∑lo≤i<hiτ0(X,i), ∑lo≤i<hiτ1(X,i))+(2C0C1+73)F).8384\,(C_1 + 58)\Bigl(2C_0^2 \min\Bigl(\sum_{lo \le i < hi} \tau_0(X, i),\ \sum_{lo \le i < hi} \tau_1(X, i)\Bigr) + (2C_0C_1 + 73)F\Bigr).
theoremCombo.Online.Results.window_policypropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Abstract.lean:136
theorem window_policy (model : Refinement.WorkerModel worker saved) (correct : Refinement.Visits.Correct model)    {overhead C₀ C₁ : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (nonempty : saved ≠ .nil) (size : saved.size ≤ overhead)    (fields : Nat → IntervalMetadata.Bounds) (oldData : Nat → Nat) :    ∃ p : Prepared model (Analysis.budget overhead C₁) (57 * overhead) fields oldData,      ∀ xs, (∀ x ∈ xs, x < saved.size) →        Pointer.Execution saved xs (p.current (execute p none xs).1) (execute p none xs).2 ∧        ∀ lo hi, lo ≤ hi → hi ≤ xs.length →          let first := execute p none (xs.take lo)          let middle := execute p first.1 (Analysis.segment xs lo hi)          let last := execute p middle.1 (xs.drop hi)          execute p none xs = (last.1, first.2 + middle.2 + last.2) ∧            Pointer.Execution (p.current first.1) (Analysis.segment xs lo hi) (p.current middle.1) middle.2 ∧            (middle.2 : ℝ) ≤ 8384 * (C₁ + 1 + 57 : Nat) *              (2 * C₀ * C₀ * min (Analysis.mass charges false xs lo hi) (Analysis.mass charges true xs lo hi) +                (2 * C₀ * C₁ + 73) * overhead) :=  RotationBST.Combo.Online.window_policy model correct well nonempty size fields oldData
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm

This is executed_window with r=57r = 57, and 570112n=8384⋅68 n≤8384(C1+58)⋅68F570112n = 8384 \cdot 68\, n \le 8384(C_1 + 58) \cdot 68F, which turns (2C0C1+5)F(2C_0C_1 + 5)F into (2C0C1+73)F(2C_0C_1 + 73)F. In the paper’s notation, the cost of Combo-BST on the window X′X' of XX is O(min⁡(TX′(A0,T,X),TX′(A1,T,X))+f(n))O(\min(T_{X'}(A_0, T, X), T_{X'}(A_1, T, X)) + f(n)), with explicit constants. The smaller source can differ from one window to another; the bound holds for all windows of the same run.

29.4.7 The combined policy as a worker

To combine more than two algorithms, the paper combines them two at a time in a balanced binary tree. That needs the output of one combination to be an input of the next: a Controller.Worker with a pointer interpretation and well-behaved charges. The Replay layer provides this. It is used by the finite families of Section 29.1 and by the combined finger bound of Chapter 31. A reader interested only in two algorithms can skip this section.

structureCombo.Online.Replay.Implementationpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Definitions/Abstract.lean:10
/-- A fixed replay implementation of the already chosen combined policy.Both worker sides run the same policy; inherited bounds may be chosen separately. -/structure Implementation {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    {model : Refinement.WorkerModel worker saved} {budget restore : Nat}    {fields : Nat → IntervalMetadata.Bounds} {oldData : Nat → Nat}    (p : Prepared model budget restore fields oldData) where  planner : Worker.Replay.Planner (Option (Online.State model p.data budget)) saved  initial : planner.initial = fun _ => none  tree : planner.tree = fun _ => p.current  expansion : ∀ side state x, x < saved.size →    (planner.plan side state x).1 = (access p state x).1 ∧    (planner.plan side state x).2.length + 2 ≤ 2 * (access p state x).2
theoremCombo.Online.Replay.Implementation.initialpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Definitions/Abstract.lean:17
initial
Statement reads only Algorithms/Combination/Online/Replay/Definitions/Abstract.lean and its imports
theoremCombo.Online.Replay.Implementation.treepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Definitions/Abstract.lean:18
tree
Statement reads only Algorithms/Combination/Online/Replay/Definitions/Abstract.lean and its imports
theoremCombo.Online.Replay.Implementation.expansionpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Definitions/Abstract.lean:19
expansion
Statement reads only Algorithms/Combination/Online/Replay/Definitions/Abstract.lean and its imports

An Implementation p is a Replay.Planner whose states are the optional states of pp. A planner turns each request into an explicit list of pointer opcodes from the root back to the root, and Replay.worker executes that list one opcode per worker step, with one unit to plan and one to report completion. The fields say that the planner starts at none on both sides, that its tree is p.current, and that each planned request reaches the same state as access p with at most twice its cost, counting the two extra units. Both sides of the replay worker run the same policy pp.

defCombo.Online.Replay.chargeFactorno axiomsAlgorithms/Combination/Online/Replay/Definitions/Abstract.lean:23
def chargeFactor (C₀ C₁ restoreFactor : Nat) : Nat := 16768 * (C₁ + 1 + restoreFactor) * (2 * C₀)
defCombo.Online.Replay.overheadFactorno axiomsAlgorithms/Combination/Online/Replay/Definitions/Abstract.lean:25
def overheadFactor (C₀ C₁ restoreFactor : Nat) : Nat :=  chargeFactor C₀ C₁ restoreFactor +    16768 * (68 + 3 * (C₁ + 1 + restoreFactor) + 2 * (C₁ + 1) + restoreFactor) + 1
defCombo.Online.Replay.scaledChargespropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Definitions/Abstract.lean:29
def scaledCharges (factor : Nat) (charges : Analysis.Charges) : Analysis.Charges :=  fun side xs i => factor * charges side xs i

These are the constants of the inherited bound. chargeFactor multiplies the charges, overheadFactor multiplies FF, and scaledCharges factor charges multiplies every charge by factor. They are explicit, so that a balanced family can compute its constants by recurrence.

Theorem (replay implementations). Every prepared policy has an implementation. Its replay run on any valid sequence ends in the same state as the policy, at most twice the cost; as a worker from its restart state it completes every valid sequence at most at twice the policy’s cost; and a single access from any reachable boundary costs at most 1140224n+16768(2B+restore)1140224n + 16768(2B + \mathit{restore}).

theoremCombo.Online.Replay.Results.implementation_existspropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:13
theorem implementation_exists (p : Prepared model budget restore fields oldData) : Nonempty (Implementation p) :=  RotationBST.Combo.Online.Replay.implementation_exists p
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions
theoremCombo.Online.Replay.Results.run_boundpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:16
theorem run_bound (p : Prepared model budget restore fields oldData) (implementation : Implementation p) (side : Bool)    (s : Option (Online.State model p.data budget)) (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) :    (Worker.Replay.run implementation.planner side s xs).1 = (execute p s xs).1 ∧      (Worker.Replay.run implementation.planner side s xs).2 ≤ 2 * (execute p s xs).2 :=  RotationBST.Combo.Online.Replay.run_bound p implementation side s xs valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions
theoremCombo.Online.Replay.Results.requestspropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:22
theorem requests (p : Prepared model budget restore fields oldData) (implementation : Implementation p) (side : Bool) (xs : List Nat)    (valid : ∀ x ∈ xs, x < saved.size) :    ∃ cost, Worker.Requests (Worker.Replay.worker implementation.planner) side      ((Worker.Replay.worker implementation.planner).restart side) xs      (.boundary (execute p none xs).1) cost ∧ cost ≤ 2 * (execute p none xs).2 :=  RotationBST.Combo.Online.Replay.requests p implementation side xs valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions
theoremCombo.Online.Replay.Results.singlepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:29
theorem single (p : Prepared model budget restore fields oldData) (implementation : Implementation p)    (side : Bool) (state : Worker.Replay.State (Option (Online.State model p.data budget))) (x : Nat)    (boundary : Refinement.Visits.Boundary (Worker.Replay.worker implementation.planner) saved.size side state)    (valid : x < saved.size) :    ∃ final cost, Worker.Access (Worker.Replay.worker implementation.planner) side state x final cost ∧      cost ≤ 1140224 * saved.size + 16768 * (2 * budget + restore) :=  RotationBST.Combo.Online.Replay.single p implementation side state x boundary valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions

The single-access bound is the worst case of one request: at most one failed round, one restoration and one fresh round, plus the preparation if the request is the first one. The factors 16768=2⋅838416768 = 2 \cdot 8384 and 1140224=2⋅5701121140224 = 2 \cdot 570112 are the factor 2 of the replay applied to the policy’s constants.

Theorem (the replay worker inherits the bounds). The replay worker completes every valid sequence from its restart state at cost at most 1140224n+16768(C1+1+r)(2C0min⁡(∑τ0,∑τ1)+3F)1140224n + 16768(C_1 + 1 + r)\bigl(2C_0\min(\sum\tau_0, \sum\tau_1) + 3F\bigr). If n≤Fn \le F, it is well-behaved with overhead overheadFactor ⋅F\cdot F, constants C0C_0 and C1+1C_1 + 1, and charges chargeFactor ⋅ τ\cdot\,\tau, where side jj of the replay worker may inherit the charges of either source, chosen by select.

theoremCombo.Online.Replay.Results.minimum_boundpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:37
theorem minimum_bound {overhead C₀ C₁ restoreFactor : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (p : Prepared model (Analysis.budget overhead C₁) (restoreFactor * overhead) fields oldData)    (implementation : Implementation p) (side : Bool) (xs : List Nat) (valid : ∀ x ∈ xs, x < saved.size) :    ∃ cost, Worker.Requests (Worker.Replay.worker implementation.planner) side      ((Worker.Replay.worker implementation.planner).restart side) xs      (.boundary (execute p none xs).1) cost ∧      (cost : ℝ) ≤ 1140224 * (saved.size : ℝ) +        16768 * (C₁ + 1 + restoreFactor : Nat) *          (2 * C₀ * min (Analysis.total charges false xs) (Analysis.total charges true xs) + 3 * overhead) :=  RotationBST.Combo.Online.Replay.minimum_bound well p implementation side xs valid
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions
theoremCombo.Online.Replay.Results.well_behaved_selectionpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:49
theorem well_behaved_selection {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    {model : Refinement.WorkerModel worker saved} {fields : Nat → IntervalMetadata.Bounds} {oldData : Nat → Nat}    {overhead C₀ C₁ restoreFactor : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (p : Prepared model (Analysis.budget overhead C₁) (restoreFactor * overhead) fields oldData)    (implementation : Implementation p) (size : saved.size ≤ overhead) (select : Bool → Bool) :    Analysis.WellBehaved (Worker.Replay.worker implementation.planner) saved.size      (overheadFactor C₀ C₁ restoreFactor * overhead) C₀ (C₁ + 1)      (scaledCharges (chargeFactor C₀ C₁ restoreFactor) (fun side => charges (select side))) :=  RotationBST.Combo.Online.Replay.well_behaved_selection well p implementation size select
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions
theoremCombo.Online.Replay.Results.well_behavedpropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:60
theorem well_behaved {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    {model : Refinement.WorkerModel worker saved} {fields : Nat → IntervalMetadata.Bounds} {oldData : Nat → Nat}    {overhead C₀ C₁ restoreFactor : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (p : Prepared model (Analysis.budget overhead C₁) (restoreFactor * overhead) fields oldData)    (implementation : Implementation p) (size : saved.size ≤ overhead) :    Analysis.WellBehaved (Worker.Replay.worker implementation.planner) saved.size      (overheadFactor C₀ C₁ restoreFactor * overhead) C₀ (C₁ + 1)      (scaledCharges (chargeFactor C₀ C₁ restoreFactor) charges) :=  RotationBST.Combo.Online.Replay.well_behaved well p implementation size
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions

well_behaved is the case where side jj inherits τj\tau_j. Since both sides run the same policy, either choice is valid: the combined worker is well-behaved with respect to the scaled charges of A0A_0 and also with respect to those of A1A_1. The minimum is not a charge function itself; it reappears when the combined worker is combined again.

Theorem (one combination step). For a nonempty tree with n≤Fn \le F, a visit-correct model and well-behaved charges, there are a prepared policy with restore charge 57F57F and an implementation whose replay worker is again visit-correct and well-behaved, with overhead overheadFactor C₀ C₁ 57 ⋅F\cdot F, constants C0C_0 and C1+1C_1 + 1, and charges chargeFactor C₀ C₁ 57 ⋅ τ\cdot\,\tau.

theoremCombo.Online.Replay.Results.combinepropext · Classical.choice · Quot.soundAlgorithms/Combination/Online/Replay/Abstract.lean:71
theorem combine {σ : Type} {worker : Controller.Worker σ} {saved : Tree}    (model : Refinement.WorkerModel worker saved) (correct : Refinement.Visits.Correct model)    {overhead C₀ C₁ : Nat} {charges : Analysis.Charges}    (well : Analysis.WellBehaved worker saved.size overhead C₀ C₁ charges)    (nonempty : saved ≠ .nil) (size : saved.size ≤ overhead)    (fields : Nat → IntervalMetadata.Bounds) (oldData : Nat → Nat) :    ∃ p : Prepared model (Analysis.budget overhead C₁) (57 * overhead) fields oldData,      ∃ implementation : Implementation p,        Refinement.Visits.Correct (Worker.Replay.model implementation.planner) ∧        Analysis.WellBehaved (Worker.Replay.worker implementation.planner) saved.size          (overheadFactor C₀ C₁ 57 * overhead) C₀ (C₁ + 1)          (scaledCharges (chargeFactor C₀ C₁ 57) charges) :=  RotationBST.Combo.Online.Replay.combine model correct well nonempty size fields oldData
Statement reads only Models.Rotation, Models.Pointer.Machine, Models.Labelled.Cursor.Definitions, Models.Labelled.Cursor.Map.Definitions, Models.Labelled.Metadata.Definitions, Models.Labelled.Intervals.Definitions, Models.Labelled.Intervals.Initialization.Definitions, Structures.TreeBuffer.Nodes.Definitions, Structures.TreeBuffer.Nodes.Initialization.Definitions, Structures.TreeBuffer.Cells.Definitions, Structures.TreeBuffer.Shared.Definitions, Structures.TreeBuffer.Snapshot.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Structures.TreeBuffer.Snapshot.Controller.Definitions, Structures.TreeBuffer.Scan.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Definitions, Structures.TreeBuffer.Snapshot.CellIO.Definitions, Structures.TreeBuffer.Snapshot.Streaming.Refinement.Definitions, Structures.TreeBuffer.Snapshot.Startup.Definitions, Models.Pointer.Walk.Definitions, Models.Pointer.Routing.Definitions, Models.Labelled.Intervals.Access.Definitions, Models.Labelled.Intervals.Maintenance.Definitions, Bounds.StaticTree.Definitions, Bounds.LazyFinger.Definitions, Algorithms.Combination.Controller.Definitions, Algorithms.Combination.Rounds.Definitions, Algorithms.Combination.Worker.Definitions, Algorithms.Combination.Analysis.Definitions, Algorithms.Combination.Refinement.Definitions, Models.Multifinger.Definitions, Structures.TreeBuffer.Shared.Requests.Definitions, Structures.TreeBuffer.Shared.Erasure.Definitions, Algorithms.Combination.Refinement.Visits.Definitions, Models.Pointer.Lazy.Skeleton, Structures.BSTDeque.Definitions, Structures.BSTDeque.Boundary.Definitions, Structures.Tendon.Definitions, Structures.FingerHand.Definitions, Structures.FingerHand.Packed.Definitions, Algorithms.Combination.Online.Definitions, Algorithms.Combination.Online.Startup.Definitions, Algorithms.Combination.Online.Algorithm, Algorithms.Combination.Worker.Replay.Definitions, Algorithms.Combination.Worker.Replay.Model, Algorithms.Combination.Online.Replay.Definitions

This is the induction step of the balanced family: the output worker satisfies the same hypotheses as the inputs, with C1C_1 increased by one and the charges and overhead multiplied by explicit factors. Iterating it compounds those factors from level to level, so the library does not obtain the paper’s O(k)O(k) overhead for kk algorithms.

29.4.8 What is and is not claimed

Hypotheses on the sources

The theorems assume a Refinement.WorkerModel (a causal pointer interpretation of both sources on the common initial tree), Visits.Correct (every access visits its key), and Analysis.WellBehaved charges, including the single-access bound, the complete-run upper bound and the stability of contiguous segments. These are operational hypotheses on the input workers. An arbitrary BST algorithm does not satisfy them automatically: each application must prove them, as Chapter 31 does for GreedyASS and Tango.

Reading the Lean
  • Cost. The cost is that of a Pointer.Execution: pointer instructions, moves and rotations alike, plus one unit per request. Every request starts at the root of the current tree. Snapshot reads, restorations and hand maintenance are all paid in pointer instructions.
  • Online. The policy is one fixed object, chosen before the requests and before the window (∃ p, ∀ xs, ∀ lo hi), and its run on a prefix is the beginning of its run on every extension (execute_append). The individual steps are chosen by classical choice from the current state and request. Planning is free, as everywhere in the abstract BST model, and the policy is noncomputable.
  • Startup. The initial tree is fixed, both sources start from it, and it must be nonempty. Preparation is charged once, on the first request; on an empty input nothing is charged.
  • Charges. Charges are functions τj(X,i)\tau_j(X, i) of the whole sequence and the index, nonnegative and real-valued. Window bounds use the charges of the original sequence at the original indices.
Compared with the paper
  • The paper’s “real-world” clauses of Theorems 3 and 5, that Combo-BST uses only O(log⁡n)O(\log n) bits per node and O(1)O(1) registers when the sources do, are not formalized. The online state contains abstract certificates, and the replay worker keeps its pending opcode list as abstract state. The model in which these clauses would be stated is in Chapter 13.
  • The sharper O(k)O(k) overhead of the paper’s balanced family is not claimed; see the family statements in Section 29.1.
  • The constants are explicit and large. They come from composing generic simulations, not from a tuned implementation.
  • Corollary 4, which combines specific known bounds, is not derived in full. Chapter 31 uses this section’s results for one combination, GreedyASS with Tango.