Chapter 38 · Heavy paths · Section 38.4Finger histories and simulation
Section 3 of Bose, Collette, Fagerberg and Langerman (2012a) shows that any BST algorithm can be run inside another BST that stays balanced at all times. The original algorithm, the source, keeps a persistent finger. Each of its instructions moves the finger to a child or to the parent, or rotates the finger over its parent. The simulating BST, the physical tree, keeps its own cursor at the root between instructions, and the source finger’s node sits at that root. The path from the root to the source finger is stored upside down as two weighted pop-tarts (Section 37.1, Section 37.2), and the subtrees hanging off that path are stored recursively as heavy-path representations (Section 38.1, Section 38.2). Every source instruction becomes a constant number of pop-tart operations. Every node of weight stays at physical depth , where is the total weight. This is the paper’s Theorem 5.
This section formalizes that simulation, as needed by the deamortization of Chapter 30. The representation of a source finger is a finger history: a state whose pop-tarts and payload layouts are whatever earlier instructions left behind, not a canonical rebuild of the current source tree. The section proves that each of the six source instructions maps one valid history to another at constant amortized cost and worst-case cost. It then packages the steps into one online policy, runs it on instruction streams and on request sequences, and bounds the depth of every key at every intermediate physical configuration, including those in the middle of the response to one source instruction.
Fix a weight for every label . There is a policy with the following properties. To answer one source instruction, sees only the current source cursor, the current physical representation and that instruction.
Let the source finger point at a node of a labelled tree with nodes and positive weights. Let be the total weight, and let be the weight of the -th label of in inorder. Then the physical tree, starting as itself with its cursor at the root, can be reshaped into a starting representation by a pointer-machine trace of cost . The trace satisfies , where is the starting potential. Take any stream of source instructions that is legal from the source finger. Running instruction by instruction then succeeds and ends in a valid representation of the final source cursor, with the following guarantees:
- the startup and the responses together form one pointer-machine trace from , of cost with , where is the final potential;
- each source instruction is answered by at most physical instructions, which start and end with the physical cursor at the root;
- in every valid representation, between instructions, the physical root holds the source finger’s node, and the node of rank is at depth at most ;
- at every instruction boundary of the emitted physical program, even in the middle of a response, the node of rank is at depth at most
In Lean, the per-instruction bound is part of Simulation.PolicyBounded, and Simulation.PolicyWithin extends it. Depths count edges (Tree.depth), and a rank is an inorder position. The policy is obtained by choice from the existence of a response for each step, so the theorem asserts that a function with these properties exists, not that it is computable. It depends on the weights, because the physical layout does.
The Lean statements
theorem policy_within_exists {α : Type} (weight : α → ℝ) : ∃ p : Policy α, PolicyWithin weight p := … RotationBST.HeavyPath.Finger.History.Simulation.policy_within_exists weightModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem initialized_run {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {cs : List (Frame α)} {left right : LabelledTree α} {key : α} (positive : Positive weight (plug cs (.node left key right))) : ∃ (start : State α) (startupCost : Nat), ConfigValid weight ⟨.node left key right, cs⟩ start ∧ Pointer.Trace ⟨(plug cs (.node left key right)).erase, []⟩ ⟨start.pair.tree, []⟩ startupCost ∧ startupCost + start.potential ≤ 39 * (plug cs (.node left key right)).erase.size ∧ ∀ (ops : List Multifinger.Opcode) (final : Config α), sourceRun ⟨.node left key right, cs⟩ ops = some final → ∃ out, run p ⟨.node left key right, cs⟩ start ops = some out ∧ out.source = final ∧ ConfigValid weight out.source out.state ∧ Pointer.Trace ⟨(plug cs (.node left key right)).erase, []⟩ ⟨out.state.pair.tree, []⟩ (startupCost + out.cost) ∧ startupCost + out.cost + out.state.potential ≤ 39 * (plug cs (.node left key right)).erase.size + 62 * ops.length := … RotationBST.HeavyPath.Finger.History.Simulation.initialized_run policyValid positiveModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem run_weighted_prefix {α : Type} {weight : α → ℝ} {p : Policy α} (certified : PolicyWithin weight p) {c : Config α} {s : State α} (valid : ConfigValid weight c s) {ops : List Multifinger.Opcode} {out : Output α} (completed : run p c s ops = some out) (cut : Nat) : ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ rank : Fin c.tree.inorder.length, (Tree.depth middle.tree rank.val : ℝ) ≤ 336 + 240 * Real.logb 2 (HeavyPath.mass weight c.tree / weight (c.tree.inorder[rank.val]'rank.isLt)) := … RotationBST.HeavyPath.Finger.History.Simulation.Interruption.run_weighted_prefix certified valid completed cutModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitionstheorem root_key {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) : (Pointer.Config.mk s.pair.tree []).key? = c.erase.key? := … RotationBST.HeavyPath.Finger.History.Simulation.root_key validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem depth {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) (rank : Fin c.tree.inorder.length) : (Tree.depth s.pair.tree rank.val : ℝ) ≤ 15 + 15 * Real.logb 2 (HeavyPath.mass weight c.tree / weight (c.tree.inorder[rank.val]'rank.isLt)) := … RotationBST.HeavyPath.Finger.History.Simulation.depth valid rankModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.DefinitionsOnly if you want to see how the deamortization works inside. The theorems that other chapters quote are Results.simulation and the scheduler results of Chapter 30, and the replay of source algorithms inside ComboBST workers (Section 29.1 and the sections after it) and in the combined finger BST (Chapter 31). Those statements mention the policy, the state and the request runs defined here. To check those results, you only need Section 38.4.6 and Section 38.4.10: what a policy promises, and how a source algorithm is described. The rest is the simulation itself: the invariant, the six instruction lemmas, and the depth analysis.
38.4.1 Overview
Three objects are involved.
- The source cursor is a
LabelledCursor.Config(a zipper): a focused labelled subtreenode left key righttogether with its context framescs, innermost first. The source finger is the nodekey. The source instructions are the sixMultifinger.Opcodes, with the labelled semanticsLabelledCursor.perform: move to the left or right child, move to the parent, or rotate the finger over its parent. A rotation keeps the finger on the same node. Labels travel with their nodes, and is a function of the labels. - The finger history is a
History.State. It records one entry per source ancestor of the finger, a pair of Chocolate pop-tarts (Finger.Pair, Section 38.3), and the physical layouts of the finger’s two children. - The physical tree is
s.pair.tree, an unlabelledTreewith the same number of nodes, operated on by the single-cursor pointer machine of Chapter 7.
The physical tree has this shape. It is Figure 5 of the paper with the lower side mirrored:
key ← physical root = source finger
╱ ╲
lower pop-tart, mirrored upper pop-tart
leaves, left to right: leaves, left to right:
payload of a₁ right subtree of key
payload of a₂ payload of b_j
… …
left subtree of key payload of b₁
a₁ … a_i : ancestors smaller than key (the cursor went right at them), root first
b₁ … b_j : ancestors larger than key (the cursor went left at them), root first
The internal nodes of each pop-tart are the ancestor keys of its side. The leaves are the payloads: the off-path subtree of each ancestor, and, innermost, the corresponding child subtree of the finger. Each payload is itself stored as a recursive heavy-path layout (History.Layout, Section 38.2). The stack top of each pop-tart is at the finger end. So the ancestors nearest the finger, and the finger’s children, are near the physical root. A source instruction changes only that end:
- Down. The finger moves into one of its children. The old finger becomes an ancestor and is pushed onto one stack, its other child becomes that ancestor’s payload, and the new finger’s two children are exposed from the old child’s layout.
- Up. The inverse: the innermost ancestor is popped and becomes the finger again.
- Rotation. The finger and its parent exchange roles. The parent leaves its stack, and the two payloads it separated are joined with it into one.
Each instruction is a constant number of pushes, pops and top replacements on Chocolate pop-tarts, plus local surgery on the recursive layouts. A pop-tart operation has amortized and worst-case cost (Lemma 4 of the paper), so a source instruction costs at most physical instructions amortized against the state potential, and at most in the worst case.
The depth bound is the paper’s telescoping argument. A pop-tart stores a leaf of weight at depth . A payload’s weight is its whole subtree mass, and inside the payload the recursive heavy-path layout again stores a node of weight at depth . The logarithms telescope to .
Why “history”. After a few instructions the pop-tarts and payload layouts are no longer the canonical ones that Finger.build would produce from the current source tree. A payload that was split and later rejoined may have a different shape, and the potential records its imbalance. The invariant therefore accepts any layout that a valid sequence of stack operations can produce, as History.Layout does for heavy paths. Two equal source subtrees may be laid out differently at different places.
Why intermediate depths. Theorem 5 of the paper says that depths are “always” , and its proof bounds them in the representation, that is, between simulated source instructions. Theorem 6 interrupts the simulated program every physical operations to serve the next request. Such an interruption can fall in the middle of the instructions that answer one source instruction. The formalization therefore also bounds the depth of every key at every physical instruction boundary (Section 38.4.9).
The section proceeds as follows. Section 38.4.2 defines the state and its invariant. Section 38.4.3 lists what a valid state guarantees. Section 38.4.4 builds the first state. Section 38.4.5 gives the six instruction lemmas. Section 38.4.6 packages them as a policy and Section 38.4.7 runs it. Section 38.4.8 shows that starting from the cheapest representation removes the potential from the cost bound. Section 38.4.9 bounds depths inside responses, and Section 38.4.10 lifts everything to request sequences.
38.4.2 The representation
The definitions are in Structures/HeavyPath/Finger/History/Definitions/Abstract.lean.
38.4.2.1 Slots charged toward the finger
The leaves of a weighted pop-tart carry weights. The ancestor keys are internal nodes, which the pop-tarts of Section 37.1 do not weigh. So the weight of each ancestor key is moved onto the next leaf toward the finger:
/-- Shift each ancestor's weight to the next payload toward the finger.Payload shapes belong to occurrences, independently of their source labels. -/def sideSlots {α : Type} (weight : α → ℝ) (boundary : LabelledTree α) (shape : Tree) : ℝ → List (Entry α) → List (Tree × ℝ) | carry, [] => [(shape, carry + HeavyPath.mass weight boundary)] | carry, e :: es => (e.shape, carry + HeavyPath.mass weight (framePayload e.source)) :: sideSlots weight boundary shape (weight (frameKey e.source)) essideSlots weight boundary shape carry es lists the leaves of one side, outermost first. Each ancestor entry e contributes its payload’s physical shape e.shape, with weight carry plus the payload’s mass. Then the ancestor’s own key weight becomes the carry of the next leaf. The last leaf is the finger’s child boundary, physically laid out as shape. It receives the key weight of the innermost ancestor on that side. The slot weights of both sides therefore add up to the total mass minus the finger’s own weight (Results.state_mass). This is the history version of Finger.sideSlots (Section 38.3). That function computes each payload’s shape with the canonical rebuild, while this one takes the recorded shape of each History.Entry.
38.4.2.2 States and potential
/-- All physical payload occurrences of an inverted source cursor. -/structure State (α : Type) where ancestors : List (Entry α) leftShape : Tree rightShape : Tree leftCredit : Nat rightCredit : Nat pair : Pairdef State.potential {α : Type} (s : State α) : Nat := s.pair.potential + s.leftCredit + s.rightCredit + (s.ancestors.map Entry.credit).sumA state has five components:
ancestors: oneHistory.Entryper source ancestor, innermost first. An entry is the source frame (ancestor key, side, off-path subtree), the physical shape of that subtree, and its credit.leftShape,rightShape: the physical layouts of the finger’s two children.leftCredit,rightCredit: their credits.pair: the two pop-tarts, aFinger.Pair. Its physical tree is the finger node with the mirrored lower pop-tart on the left and the upper pop-tart on the right. The leaves of the pop-tarts are the payload shapes.
The potential is the pop-tart potential of the pair (Pair.potential) plus the credits of the two children and of every ancestor payload. A credit is itself the potential of a recursive layout, so the potential counts every pop-tart nested anywhere in the physical tree. It is a natural number. The cost bounds below are amortized against it.
38.4.2.3 The invariant
/-- The whole inverted-cursor invariant. Depth is a consequence, not a field.Every ancestor payload and both finger children retain their recursive layouts. -/structure Valid {α : Type} (weight : α → ℝ) (cs : List (Frame α)) (left : LabelledTree α) (key : α) (right : LabelledTree α) (s : State α) : Prop where positive : Positive weight (plug cs (.node left key right)) context : s.ancestors.map Entry.source = cs pair : s.pair.Valid leftLayout : Recursive.History.Layout weight left s.leftShape s.leftCredit rightLayout : Recursive.History.Layout weight right s.rightShape s.rightCredit children : ∀ e ∈ s.ancestors, Recursive.History.Layout weight (framePayload e.source) e.shape e.credit lower : s.pair.lower.decode.mirror.fringe = sideSlots weight left s.leftShape 0 (Recursive.History.lower s.ancestors) upper : s.pair.upper.decode.fringe = (sideSlots weight right s.rightShape 0 (Recursive.History.upper s.ancestors).reverse).reverseValid weight cs left key right s says that s represents the source cursor with focus node left key right and context cs. Its eight fields are the whole invariant:
positiveStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importscontextStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importspairStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importsleftLayoutStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importsrightLayoutStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importschildrenStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importslowerStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importsupperStructures/HeavyPath/Finger/History/Definitions/Abstract.lean and its importspositive: every weight in the whole source tree is positive (HeavyPath.Positive). The depth bounds divide by weights.context: the sources of the ancestor entries are exactly the context frames. So the state records the actual source path from the root to the finger.pair: both Chocolate pop-tarts are valid (at level ).leftLayout,rightLayout: the finger’s children are laid out as recursive heavy-path histories with the recorded shapes and credits.children: so is every ancestor’s off-path payload.lower,upper: the leaves of the two pop-tarts, read in inorder, are exactly the slots of the two sides.History.lowerselects the ancestors smaller than the finger, root first, andHistory.upperthose larger, innermost first. The latter list is reversed so thatsideSlotsagain runs from the root toward the finger.
The path from the root to the finger is not required to be a heavy path. The whole path is held by one pair of pop-tarts, whatever its edges, and only the payloads use the heavy-path decomposition. Depth is not a field either: it is a consequence of the invariant (Results.state_depth), so the instruction lemmas never need to re-establish it.
38.4.3 What a valid state guarantees
These theorems are in Structures/HeavyPath/Finger/History/Abstract.lean. Each assumes Valid weight cs left key right s, and writes = plug cs (node left key right) for the whole source tree.
Theorem (same keys, finger at the root). The physical tree has as many nodes as . The physical root has the inorder rank of the source finger. If the labels are ordered by a preorder and is a search tree, there is exactly one labelling of the physical tree that has ’s inorder and is a search tree. The finger’s weight plus the slot masses of the pair is the total mass of . Each side has the size of its blocks: the ancestors on that side with their payloads, plus the finger’s child on that side.
theorem state_size {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) : s.pair.tree.size = (plug cs (.node left key right)).erase.size := RotationBST.HeavyPath.Finger.History.state_size validModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_root_key {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) : (Pointer.Config.mk s.pair.tree []).key? = (Config.mk (.node left key right) cs).erase.key? := RotationBST.HeavyPath.Finger.History.state_root_key validModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_labels {α : Type} [Preorder α] {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) (ordered : (plug cs (.node left key right)).Ordered) : ∃! u : LabelledTree α, u.erase = s.pair.tree ∧ u.inorder = (plug cs (.node left key right)).inorder ∧ u.Ordered := RotationBST.HeavyPath.Finger.History.state_labels valid orderedModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_mass {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) : weight key + s.pair.mass = HeavyPath.mass weight (plug cs (.node left key right)) := RotationBST.HeavyPath.Finger.History.state_mass validModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_side_sizes {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) : s.pair.lower.decode.tree.mirror.size = ((Recursive.History.lower s.ancestors).flatMap Entry.lowerBlock).length + left.erase.size ∧ s.pair.upper.decode.tree.size = right.erase.size + ((Recursive.History.upper s.ancestors).flatMap Entry.upperBlock).length := RotationBST.HeavyPath.Finger.History.state_side_sizes validModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionsstate_root_key compares Config.key? at the physical root with the rank of the source cursor (Config.erase). So the pointer machine, whose searches start at the root, finds the source finger there at no cost. state_labels says that the physical tree is a BST on the same keys. The physical tree is unlabelled, and state_labels says how its nodes inherit the source labels.
Theorem (depth). The node of inorder rank in , with weight , has physical depth at most , where is the total weight. Consequently, the pointer machine can walk from the root to that node and back, with the same cost each way, such that .
theorem state_depth {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) {before after : List α} {target : α} (occurrence : (plug cs (.node left key right)).inorder = before ++ target :: after) : (Tree.depth s.pair.tree before.length : ℝ) ≤ 15 + 15 * Real.logb 2 (HeavyPath.mass weight (plug cs (.node left key right)) / weight target) := RotationBST.HeavyPath.Finger.History.state_depth valid occurrenceModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_depth_at {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) (rank : Fin (plug cs (.node left key right)).inorder.length) : (Tree.depth s.pair.tree rank.val : ℝ) ≤ 15 + 15 * Real.logb 2 (HeavyPath.mass weight (plug cs (.node left key right)) / weight ((plug cs (.node left key right)).inorder[rank.val]'rank.isLt)) := RotationBST.HeavyPath.Finger.History.state_depth_at valid rankModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_search_walk {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) (rank : Fin (plug cs (.node left key right)).inorder.length) : ∃ (visited : Pointer.Config) (cost : Nat), visited.tree = s.pair.tree ∧ visited.key? = some rank.val ∧ Pointer.Trace ⟨s.pair.tree, []⟩ visited cost ∧ Pointer.Trace visited ⟨s.pair.tree, []⟩ cost ∧ (1 + 2 * cost : ℝ) ≤ 31 + 30 * Real.logb 2 (HeavyPath.mass weight (plug cs (.node left key right)) / weight ((plug cs (.node left key right)).inorder[rank.val]'rank.isLt)) := RotationBST.HeavyPath.Finger.History.state_search_walk valid rankModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionsstate_depth names the node by an occurrence in the inorder list (before ++ target :: after, of rank before.length), and state_depth_at by a rank in Fin. The walk in state_search_walk is navigation only: it never rotates, and it returns to the same tree with the cursor at the root. The is the unit charge of the request.
Theorem (potential). The potential of a valid state is at most , where is the size of .
theorem potential_bound {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} {s : State α} (valid : Valid weight cs left key right s) : s.potential + 20 ≤ 20 * (plug cs (.node left key right)).erase.size := RotationBST.HeavyPath.Finger.History.potential_bound validModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.DefinitionsThe bound holds for every valid history, not only for freshly built ones. Section 38.4.10 uses it to bound the work on any window of requests without assumptions about the starting potential.
38.4.4 The starting state
A valid state always exists, and the canonical one is reachable cheaply. Given positive weights, there is a valid state whose pair is the canonical Finger.build of Section 38.3. Its potential is at most . Starting from the source tree itself, read as an unlabelled tree with the cursor at the root, the pointer machine reaches the physical tree of some valid state in at most instructions, and that state can be chosen with potential at most , so that startup cost plus potential is at most .
theorem build_state {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} (positive : Positive weight (plug cs (.node left key right))) : ∃ s : State α, Valid weight cs left key right s ∧ s.pair = build weight cs left right := RotationBST.HeavyPath.Finger.History.build_state positiveModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem build_state_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} (positive : Positive weight (plug cs (.node left key right))) : ∃ s : State α, Valid weight cs left key right s ∧ s.pair = build weight cs left right ∧ s.potential ≤ 23 * (plug cs (.node left key right)).erase.size := RotationBST.HeavyPath.Finger.History.build_state_bounded positiveModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_initialization {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} (positive : Positive weight (plug cs (.node left key right))) : ∃ (s : State α) (cost : Nat), Valid weight cs left key right s ∧ Pointer.Trace ⟨(plug cs (.node left key right)).erase, []⟩ ⟨s.pair.tree, []⟩ cost ∧ cost ≤ 16 * (plug cs (.node left key right)).erase.size := RotationBST.HeavyPath.Finger.History.state_initialization positiveModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem state_initialization_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {left right : LabelledTree α} {key : α} (positive : Positive weight (plug cs (.node left key right))) : ∃ (s : State α) (cost : Nat), Valid weight cs left key right s ∧ Pointer.Trace ⟨(plug cs (.node left key right)).erase, []⟩ ⟨s.pair.tree, []⟩ cost ∧ cost ≤ 16 * (plug cs (.node left key right)).erase.size ∧ s.potential ≤ 23 * (plug cs (.node left key right)).erase.size ∧ cost + s.potential ≤ 39 * (plug cs (.node left key right)).erase.size := RotationBST.HeavyPath.Finger.History.state_initialization_bounded positiveModels.Rotation, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.DefinitionsThe source finger may be anywhere in . The startup trace begins from ’s own shape, which is how the physical machine starts: before the simulation begins, the physical and source trees coincide. The constant is the one the initialization proof produces, and Results.potential_bound improves it to after the fact. The is what enters every startup-inclusive bound below.
38.4.5 The six instructions
Each source instruction has a lemma in three strengths. The plain version gives a valid successor state, reached by a Pointer.Trace from the physical root to the physical root, and an amortized bound . The _bounded version adds a worst-case bound , where is the physical size. The _within version replaces the trace by a Pointer.TraceWithin (Chapter 36). That trace keeps the size and satisfies, at every one of its instruction boundaries, for every rank , where is the depth in the starting physical tree. Each lemma also says exactly how the list of ancestor entries changes.
| instruction | amortized | worst case | intermediate depth |
|---|---|---|---|
| move down | |||
| move up | |||
| rotate |
The policy below uses the worst row of each column: , and .
38.4.5.1 Moving down
Theorem (move down). Suppose the finger key has a nonempty left child node l x r and right subtree sibling. Then there is a valid state for the finger x, whose new innermost ancestor is key with payload sibling. That payload keeps the old physical shape and credit of the right child. The cost satisfies the bounds of the table. The right move is the mirror image.
theorem downLeft {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key x : α} {s : State α} (valid : Valid weight cs (.node l x r) key sibling s) : ∃ (next : State α) (cost : Nat), Valid weight (.left key sibling :: cs) l x r next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 54 + s.potential ∧ next.ancestors = ⟨.left key sibling, s.rightShape, s.rightCredit⟩ :: s.ancestors := RotationBST.HeavyPath.Finger.History.Down.downLeft validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem downRight {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key x : α} {s : State α} (valid : Valid weight cs sibling key (.node l x r) s) : ∃ (next : State α) (cost : Nat), Valid weight (.right sibling key :: cs) l x r next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 54 + s.potential ∧ next.ancestors = ⟨.right sibling key, s.leftShape, s.leftCredit⟩ :: s.ancestors := RotationBST.HeavyPath.Finger.History.Down.downRight validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem downLeft_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key x : α} {s : State α} (valid : Valid weight cs (.node l x r) key sibling s) : ∃ (next : State α) (cost : Nat), Valid weight (.left key sibling :: cs) l x r next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 54 + s.potential ∧ next.ancestors = ⟨.left key sibling, s.rightShape, s.rightCredit⟩ :: s.ancestors ∧ (cost : ℝ) ≤ 26 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Down.downLeft_bounded validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem downRight_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key x : α} {s : State α} (valid : Valid weight cs sibling key (.node l x r) s) : ∃ (next : State α) (cost : Nat), Valid weight (.right sibling key :: cs) l x r next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 54 + s.potential ∧ next.ancestors = ⟨.right sibling key, s.leftShape, s.leftCredit⟩ :: s.ancestors ∧ (cost : ℝ) ≤ 26 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Down.downRight_bounded validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem downLeft_within {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key x : α} {s : State α} (valid : Valid weight cs (.node l x r) key sibling s) : ∃ (next : State α) (cost : Nat), Valid weight (.left key sibling :: cs) l x r next ∧ Pointer.TraceWithin (fun t => t.size = s.pair.tree.size ∧ ∀ x, Tree.depth t x ≤ 16 * Tree.depth s.pair.tree x + 64) ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 54 + s.potential ∧ next.ancestors = ⟨.left key sibling, s.rightShape, s.rightCredit⟩ :: s.ancestors ∧ (cost : ℝ) ≤ 26 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Down.downLeft_within validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem downRight_within {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key x : α} {s : State α} (valid : Valid weight cs sibling key (.node l x r) s) : ∃ (next : State α) (cost : Nat), Valid weight (.right sibling key :: cs) l x r next ∧ Pointer.TraceWithin (fun t => t.size = s.pair.tree.size ∧ ∀ x, Tree.depth t x ≤ 16 * Tree.depth s.pair.tree x + 64) ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 54 + s.potential ∧ next.ancestors = ⟨.right sibling key, s.leftShape, s.leftCredit⟩ :: s.ancestors ∧ (cost : ℝ) ≤ 26 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Down.downRight_within validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.DefinitionsThe equation for next.ancestors shows the history at work. The old right child is not rebuilt. Its layout is reused as the payload of a new entry, so equal source subtrees can end up with different layouts. Physically, the top leaf of the lower pop-tart, the layout of the old left child, is opened at x. Its place is taken by x’s left child l. The old finger becomes an internal node of the upper pop-tart, its old right child stays there as a leaf, and x’s right child r is pushed as the new top leaf. On the pair this is the transfer Pair.downLeft of Section 38.3.
38.4.5.2 Moving up
Theorem (move up). Suppose the finger key, with children l and r, is the left child of parent, whose right subtree is sibling. Then there is a valid state for the finger parent, with left child node l key r and right child sibling. Its ancestors are the old ones without the innermost entry, and the cost satisfies the bounds of the table. The case of a right child is symmetric.
theorem upLeft {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.left parent sibling :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs (.node l key r) parent sibling next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 62 + s.potential ∧ next.ancestors = s.ancestors.tail := RotationBST.HeavyPath.Finger.History.Up.upLeft validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem upRight {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.right sibling parent :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs sibling parent (.node l key r) next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 62 + s.potential ∧ next.ancestors = s.ancestors.tail := RotationBST.HeavyPath.Finger.History.Up.upRight validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem upLeft_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.left parent sibling :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs (.node l key r) parent sibling next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 62 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Up.upLeft_bounded validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem upRight_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.right sibling parent :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs sibling parent (.node l key r) next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 62 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Up.upRight_bounded validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem upLeft_within {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.left parent sibling :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs (.node l key r) parent sibling next ∧ Pointer.TraceWithin (fun t => t.size = s.pair.tree.size ∧ ∀ x, Tree.depth t x ≤ 16 * Tree.depth s.pair.tree x + 96) ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 62 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Up.upLeft_within validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem upRight_within {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.right sibling parent :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs sibling parent (.node l key r) next ∧ Pointer.TraceWithin (fun t => t.size = s.pair.tree.size ∧ ∀ x, Tree.depth t x ≤ 16 * Tree.depth s.pair.tree x + 96) ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 62 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Up.upRight_within validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.DefinitionsMoving up is the most expensive instruction. The parent is popped from its stack, and the old finger with both its children must be merged back into one payload with a valid recursive layout.
38.4.5.3 Rotating at the finger
Theorem (rotation). Suppose the finger key, with children l and r, is the left child of parent, whose right subtree is sibling. Then there is a valid state for the rotated cursor: the finger is still key, now in the parent’s position, with left child l and right child node r parent sibling. Its ancestors are the old ones without the innermost entry, and the cost satisfies the bounds of the table. The case of a right child is symmetric.
theorem rotateLeftChild {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.left parent sibling :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs l key (.node r parent sibling) next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 50 + s.potential ∧ next.ancestors = s.ancestors.tail := RotationBST.HeavyPath.Finger.History.Rotation.rotateLeftChild validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem rotateRightChild {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.right sibling parent :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs (.node sibling parent l) key r next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 50 + s.potential ∧ next.ancestors = s.ancestors.tail := RotationBST.HeavyPath.Finger.History.Rotation.rotateRightChild validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem rotateLeftChild_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.left parent sibling :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs l key (.node r parent sibling) next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 50 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 22 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Rotation.rotateLeftChild_bounded validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem rotateRightChild_bounded {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.right sibling parent :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs (.node sibling parent l) key r next ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 50 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 22 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Rotation.rotateRightChild_bounded validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem rotateLeftChild_within {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.left parent sibling :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs l key (.node r parent sibling) next ∧ Pointer.TraceWithin (fun t => t.size = s.pair.tree.size ∧ ∀ x, Tree.depth t x ≤ 16 * Tree.depth s.pair.tree x + 56) ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 50 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 22 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Rotation.rotateLeftChild_within validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.Definitionstheorem rotateRightChild_within {α : Type} {weight : α → ℝ} {cs : List (Frame α)} {l r sibling : LabelledTree α} {key parent : α} {s : State α} (valid : Valid weight (.right sibling parent :: cs) l key r s) : ∃ (next : State α) (cost : Nat), Valid weight cs (.node sibling parent l) key r next ∧ Pointer.TraceWithin (fun t => t.size = s.pair.tree.size ∧ ∀ x, Tree.depth t x ≤ 16 * Tree.depth s.pair.tree x + 56) ⟨s.pair.tree, []⟩ ⟨next.pair.tree, []⟩ cost ∧ cost + next.potential ≤ 50 + s.potential ∧ next.ancestors = s.ancestors.tail ∧ (cost : ℝ) ≤ 22 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Rotation.rotateRightChild_within validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Bounds.StaticTree.DefinitionsTogether with the moves, these are the six cases of LabelledCursor.perform. The physical tree is not rotated like the source. The physical root stays the finger, the parent leaves its stack, and the two payloads it separated, the finger’s old right child r and the parent’s payload sibling, are joined with it into the single payload node r parent sibling.
38.4.6 Policies
The definitions are in Structures/HeavyPath/Finger/History/Simulation/Definitions/Abstract.lean. A policy turns the instruction lemmas into a program: for each source instruction, it emits a concrete list of physical instructions.
/-- The complete history invariant at a source cursor. Empty focuses are notsource fingers and cannot execute any of the six labelled instructions. -/def ConfigValid {α : Type} (weight : α → ℝ) (c : Config α) (s : State α) : Prop := match c.focus with | .nil => False | .node l key r => Valid weight c.context l key r s/-- One physical response, including its source cursor and exact trace cost. -/structure Output (α : Type) where source : Config α state : State α instructions : List Multifinger.Opcodedef Output.cost {α : Type} (out : Output α) : Nat := out.instructions.length/-- A policy sees only the current source cursor, representation, and opcode. -/abbrev Policy (α : Type) := Config α → State α → Multifinger.Opcode → Option (Output α)ConfigValid weight c s is History.Valid at a source cursor c. When the focus is empty it is False: an empty focus is not a finger, and no instruction can be performed at it. An Output is a response: the new source cursor, the new state, and the emitted physical instructions. Its cost is their number, one per pointer instruction. A Policy is a function of the current source cursor, the current state and the next opcode only. It cannot see later instructions or requests, so a run of a policy is online by construction. It may return none.
/-- Every legal instruction preserves the whole state; illegal instructionsare rejected. The potential includes all nested payload occurrences. -/def PolicyValid {α : Type} (weight : α → ℝ) (policy : Policy α) : Prop := ∀ c s op, ConfigValid weight c s → match perform op c with | none => policy c s op = none | some next => ∃ out, policy c s op = some out ∧ out.source = next ∧ ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ out.cost + out.state.potential ≤ 62 + s.potential/-- The same causal policy retains a logarithmic worst-case response boundin addition to its global potential inequality. -/def PolicyBounded {α : Type} (weight : α → ℝ) (policy : Policy α) : Prop := PolicyValid weight policy ∧ ∀ c s op out, ConfigValid weight c s → policy c s op = some out → (out.cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size/-- A bounded causal policy whose actual emitted program retains a structuralkey-depth certificate at every physical interruption. -/def PolicyWithin {α : Type} (weight : α → ℝ) (policy : Policy α) : Prop := PolicyBounded weight policy ∧ ∀ c s op out, ConfigValid weight c s → policy c s op = some out → ∀ cut, ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ x, Tree.depth middle.tree x ≤ 16 * Tree.depth s.pair.tree x + 96These are three levels of contract:
PolicyValid weight p: from any valid pair(c, s), an illegal instruction is rejected (none). A legal one is answered by an output whose source cursor is the true successorperform op c, whose state is valid for it, whose instructions replay (Multifinger.replay) from the physical root to the new physical root, and whose cost satisfies .PolicyBounded: in addition, every response costs at most .PolicyWithin: in addition, for every cut point of a response there is an intermediate pointer configurationmiddle, possibly with the cursor away from the root. The firstcutinstructions lead tomiddle, the remaining ones lead frommiddleto the final configuration, and every rank has depth at most inmiddle. This is a certificate about the emitted program itself, not just about some trace with the same endpoints.
38.4.6.1 One step
Theorem (one step). From a valid pair and a legal source instruction, there is a valid state for the successor cursor, reached from the physical root by a trace back to the physical root, of amortized cost at most and worst-case cost at most . Along the trace the size is constant, and every depth stays at most times its old value plus . Recording such a trace gives a response with all three properties. Hence policies of all three strengths exist.
theorem step {α : Type} {weight : α → ℝ} {c next : Config α} {s : State α} {op : Multifinger.Opcode} (valid : ConfigValid weight c s) (legal : perform op c = some next) : ∃ (after : State α) (cost : Nat), ConfigValid weight next after ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨after.pair.tree, []⟩ cost ∧ cost + after.potential ≤ 62 + s.potential := RotationBST.HeavyPath.Finger.History.Simulation.step valid legalModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem step_bounded {α : Type} {weight : α → ℝ} {c next : Config α} {s : State α} {op : Multifinger.Opcode} (valid : ConfigValid weight c s) (legal : perform op c = some next) : ∃ (after : State α) (cost : Nat), ConfigValid weight next after ∧ Pointer.Trace ⟨s.pair.tree, []⟩ ⟨after.pair.tree, []⟩ cost ∧ cost + after.potential ≤ 62 + s.potential ∧ (cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Simulation.step_bounded valid legalModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem step_within {α : Type} {weight : α → ℝ} {c next : Config α} {s : State α} {op : Multifinger.Opcode} (valid : ConfigValid weight c s) (legal : perform op c = some next) : ∃ (after : State α) (cost : Nat), ConfigValid weight next after ∧ Pointer.TraceWithin (fun t => t.size = s.pair.tree.size ∧ ∀ x, Tree.depth t x ≤ 16 * Tree.depth s.pair.tree x + 96) ⟨s.pair.tree, []⟩ ⟨after.pair.tree, []⟩ cost ∧ cost + after.potential ≤ 62 + s.potential ∧ (cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Simulation.step_within valid legalModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem response_exists_within {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} {op : Multifinger.Opcode} (valid : ConfigValid weight c s) (legal : (perform op c).isSome = true) : ∃ out : Output α, perform op c = some out.source ∧ ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ out.cost + out.state.potential ≤ 62 + s.potential ∧ (out.cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size ∧ ∀ cut, ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ x, Tree.depth middle.tree x ≤ 16 * Tree.depth s.pair.tree x + 96 := RotationBST.HeavyPath.Finger.History.Simulation.response_exists_within valid legalModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem policy_exists {α : Type} (weight : α → ℝ) : ∃ p : Policy α, PolicyValid weight p := RotationBST.HeavyPath.Finger.History.Simulation.policy_exists weightModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem policy_bounded_exists {α : Type} (weight : α → ℝ) : ∃ p : Policy α, PolicyBounded weight p := RotationBST.HeavyPath.Finger.History.Simulation.policy_bounded_exists weightModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem policy_within_exists {α : Type} (weight : α → ℝ) : ∃ p : Policy α, PolicyWithin weight p := RotationBST.HeavyPath.Finger.History.Simulation.policy_within_exists weightModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.DefinitionsThe step lemmas are a case analysis on the opcode, using the six lemmas of Section 38.4.5. response_exists_within turns the trace into an explicit instruction list with the prefix certificate. The policy behind policy_within_exists picks, by choice, one such response at each valid configuration and legal opcode, and returns none otherwise. Since PolicyWithin contains PolicyBounded, which contains PolicyValid, a single policy has all three properties. As elsewhere in the abstract online model, the policy’s internal computation is not charged. Only emitted pointer instructions count.
38.4.7 Running a policy
/-- Execute a finite source instruction stream, rejecting the first illegalinstruction. This is the reference semantics, independent of a policy. -/def sourceRun {α : Type} (c : Config α) : List Multifinger.Opcode → Option (Config α) | [] => some c | op :: ops => (perform op c).bind (fun next => sourceRun next ops)/-- Execute the same fixed policy at every instruction. Only accumulatedphysical trace cost is added; the final state carries its remaining credit. -/def run {α : Type} (p : Policy α) (c : Config α) (s : State α) : List Multifinger.Opcode → Option (Output α) | [] => some ⟨c, s, []⟩ | op :: ops => (p c s op).bind fun first => (run p first.source first.state ops).map fun last => ⟨last.source, last.state, first.instructions ++ last.instructions⟩sourceRun c ops is the reference semantics of a source instruction stream: it applies LabelledCursor.perform in turn and fails at the first illegal instruction. run p c s ops answers the same stream with the policy, one instruction at a time. It concatenates the emitted programs, and it fails as soon as the policy does. The final state carries the remaining potential, and the output’s cost is only the emitted instructions.
Theorem (runs are online). Running on xs ++ ys is running on xs and then continuing from the output on ys. If the run on xs ++ ys succeeds, then so does the run on xs, and its program is a prefix of the whole program.
theorem run_append {α : Type} (p : Policy α) (c : Config α) (s : State α) (xs ys : List Multifinger.Opcode) : run p c s (xs ++ ys) = (run p c s xs).bind fun first => (run p first.source first.state ys).map fun last => ⟨last.source, last.state, first.instructions ++ last.instructions⟩ := RotationBST.HeavyPath.Finger.History.Simulation.run_append p c s xs ysModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem run_prefix {α : Type} (p : Policy α) (c : Config α) (s : State α) (xs ys : List Multifinger.Opcode) {out : Output α} (completed : run p c s (xs ++ ys) = some out) : ∃ first, run p c s xs = some first ∧ first.instructions <+: out.instructions := RotationBST.HeavyPath.Finger.History.Simulation.run_prefix p c s xs ys completedModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.DefinitionsThese two facts need no validity assumption. They hold for any policy, because a policy never sees the future.
Theorem (correct simulation). Let satisfy PolicyValid, and let be valid. If a stream of source instructions is legal from and ends at , then the run succeeds and ends at in a valid state. Its program replays from the physical root to the final physical root, and . The run fails exactly when the source stream is illegal.
theorem run_spec {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {c final : Config α} {s : State α} {ops : List Multifinger.Opcode} (valid : ConfigValid weight c s) (legal : sourceRun c ops = some final) : ∃ out, run p c s ops = some out ∧ out.source = final ∧ ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ out.cost + out.state.potential ≤ 62 * ops.length + s.potential := RotationBST.HeavyPath.Finger.History.Simulation.run_spec policyValid valid legalModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem run_none_iff {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {c : Config α} {s : State α} (valid : ConfigValid weight c s) (ops : List Multifinger.Opcode) : run p c s ops = none ↔ sourceRun c ops = none := RotationBST.HeavyPath.Finger.History.Simulation.run_none_iff policyValid valid opsModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.DefinitionsTheorem (initialized run). For a valid policy and a source finger in a positively weighted tree with nodes, there is a starting state, reached from by a startup trace of cost with . For every legal stream of instructions, the run from it ends at the right source cursor in a valid state. The startup and the run form a single pointer trace from of cost , and .
theorem initialized_run {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {cs : List (Frame α)} {left right : LabelledTree α} {key : α} (positive : Positive weight (plug cs (.node left key right))) : ∃ (start : State α) (startupCost : Nat), ConfigValid weight ⟨.node left key right, cs⟩ start ∧ Pointer.Trace ⟨(plug cs (.node left key right)).erase, []⟩ ⟨start.pair.tree, []⟩ startupCost ∧ startupCost + start.potential ≤ 39 * (plug cs (.node left key right)).erase.size ∧ ∀ (ops : List Multifinger.Opcode) (final : Config α), sourceRun ⟨.node left key right, cs⟩ ops = some final → ∃ out, run p ⟨.node left key right, cs⟩ start ops = some out ∧ out.source = final ∧ ConfigValid weight out.source out.state ∧ Pointer.Trace ⟨(plug cs (.node left key right)).erase, []⟩ ⟨out.state.pair.tree, []⟩ (startupCost + out.cost) ∧ startupCost + out.cost + out.state.potential ≤ 39 * (plug cs (.node left key right)).erase.size + 62 * ops.length := RotationBST.HeavyPath.Finger.History.Simulation.initialized_run policyValid positiveModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.DefinitionsThe starting state is chosen before the instruction stream, in the same ∃ … ∀ order as the statement. So one physical start serves every future stream.
Theorem (between instructions). In any valid configuration, the physical root holds the source finger’s rank. The node of rank is at depth at most , and a round trip to it from the root costs .
theorem root_key {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) : (Pointer.Config.mk s.pair.tree []).key? = c.erase.key? := RotationBST.HeavyPath.Finger.History.Simulation.root_key validModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem depth {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) (rank : Fin c.tree.inorder.length) : (Tree.depth s.pair.tree rank.val : ℝ) ≤ 15 + 15 * Real.logb 2 (HeavyPath.mass weight c.tree / weight (c.tree.inorder[rank.val]'rank.isLt)) := RotationBST.HeavyPath.Finger.History.Simulation.depth valid rankModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitionstheorem search_walk {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) (rank : Fin c.tree.inorder.length) : ∃ (visited : Pointer.Config) (cost : Nat), visited.tree = s.pair.tree ∧ visited.key? = some rank.val ∧ Pointer.Trace ⟨s.pair.tree, []⟩ visited cost ∧ Pointer.Trace visited ⟨s.pair.tree, []⟩ cost ∧ (1 + 2 * cost : ℝ) ≤ 31 + 30 * Real.logb 2 (HeavyPath.mass weight c.tree / weight (c.tree.inorder[rank.val]'rank.isLt)) := RotationBST.HeavyPath.Finger.History.Simulation.search_walk valid rankModels.Rotation, Models.Pointer.Invariant.Definitions, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.DefinitionsThese restate Section 38.4.3 for a cursor c, with c.tree the whole source tree.
38.4.8 Cheapest representations
The bound charges the starting potential to the simulation. Results.simulation instead bounds the cost by a multiple of alone, with no additive potential term. The tool is the cheapest representation of each source cursor. The definitions are in Simulation/Minimum/Definitions/Abstract.lean.
/-- The least total potential among representations of the same labelledsource cursor. This depends on the fixed analysis weights, not on future input.For an unrepresentable cursor, the natural-number infimum is zero. -/noncomputable def potential {α : Type} (weight : α → ℝ) (c : LabelledCursor.Config α) : Nat := sInf {n | ∃ s : State α, ConfigValid weight c s ∧ s.potential = n}/-- Credit above the minimum for this source cursor. Minimum representationsstart with zero excess even when every representation has positive raw credit. -/noncomputable def excess {α : Type} (weight : α → ℝ) (c : LabelledCursor.Config α) (s : State α) : Nat := s.potential - potential weight cpotential weight c is the least potential of any valid state for the source cursor c. It is an infimum over natural numbers, which is attained whenever some valid state exists. When none exists, for instance when the focus is empty, the infimum is : a totalized value that the theorems never use. It depends on c and the weights only, not on the history that led to c. excess weight c s is the credit of s above that minimum.
Theorem (minimum). For a valid pair : the minimum is at most , it is attained by some valid state, and is the excess plus the minimum.
theorem potential_le {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) : potential weight c ≤ s.potential := RotationBST.HeavyPath.Finger.History.Simulation.Minimum.potential_le validModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Minimum.Definitionstheorem attained {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) : ∃ best, ConfigValid weight c best ∧ best.potential = potential weight c := RotationBST.HeavyPath.Finger.History.Simulation.Minimum.attained validModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Minimum.Definitionstheorem excess_add {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) : excess weight c s + potential weight c = s.potential := RotationBST.HeavyPath.Finger.History.Simulation.Minimum.excess_add validModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Minimum.DefinitionsTheorem (the minimum moves slowly). Suppose a stream of source instructions leads from to and has a valid state. Then the minimum potential at is at most plus the minimum at . Consequently, a run of a valid policy satisfies
theorem potential_drop {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {c final : Config α} {s : State α} {ops : List Multifinger.Opcode} (finalValid : ConfigValid weight final s) (legal : sourceRun c ops = some final) : potential weight c ≤ 186 * ops.length + potential weight final := RotationBST.HeavyPath.Finger.History.Simulation.Minimum.potential_drop policyValid finalValid legalModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Minimum.Definitionstheorem run_excess {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {c final : Config α} {s : State α} {ops : List Multifinger.Opcode} {out : Output α} (valid : ConfigValid weight c s) (legal : sourceRun c ops = some final) (completed : run p c s ops = some out) : out.cost + excess weight out.source out.state ≤ 248 * ops.length + excess weight c s := RotationBST.HeavyPath.Finger.History.Simulation.Minimum.run_excess policyValid valid legal completedModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Minimum.DefinitionsThe first bound runs the simulation backwards. Every source instruction can be undone by at most three source instructions (Opcode.inverse), each of amortized cost , and . Adding this to the forward bound of gives . Starting from an attained minimum, the excess is , so the run costs at most . This is the constant in Results.simulation.
38.4.9 Interrupting a response
The theorems of this section, in Simulation/Interruption/Abstract.lean, bound the physical tree at an arbitrary cut point of the emitted program, as Theorem 6 requires. A cut point is a natural number cut: the configuration middle is reached by the first cut instructions, and the remaining instructions lead from middle to the end. Cuts beyond the end give the final configuration.
Theorem (interrupted response, worst-case route). For a bounded policy and a valid pair , every cut of one response reaches a configuration in which the node of rank has depth at most
With unit weights this is , at every cut of a single response and of a whole run.
theorem response {α : Type} {weight : α → ℝ} {p : Policy α} (bounded : PolicyBounded weight p) {c : Config α} {s : State α} (valid : ConfigValid weight c s) {op : Multifinger.Opcode} {out : Output α} (responded : p c s op = some out) : ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ out.cost + out.state.potential ≤ 62 + s.potential ∧ (out.cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size ∧ ∀ cut, ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ rank : Fin c.tree.inorder.length, (Tree.depth middle.tree rank.val : ℝ) ≤ 49 + 15 * Real.logb 2 (HeavyPath.mass weight c.tree / weight (c.tree.inorder[rank.val]'rank.isLt)) + 24 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Simulation.Interruption.response bounded valid respondedModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitionstheorem response_uniform {α : Type} {p : Policy α} (bounded : PolicyBounded (fun _ => 1) p) {c : Config α} {s : State α} (valid : ConfigValid (fun _ => 1) c s) {op : Multifinger.Opcode} {out : Output α} (responded : p c s op = some out) (cut : Nat) : ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ x < s.pair.tree.size, (Tree.depth middle.tree x : ℝ) ≤ 49 + 39 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Simulation.Interruption.response_uniform bounded valid responded cutModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitionstheorem run_uniform_prefix {α : Type} {p : Policy α} (bounded : PolicyBounded (fun _ => 1) p) {c : Config α} {s : State α} (valid : ConfigValid (fun _ => 1) c s) {ops : List Multifinger.Opcode} {out : Output α} (completed : run p c s ops = some out) (cut : Nat) : ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ x < s.pair.tree.size, (Tree.depth middle.tree x : ℝ) ≤ 49 + 39 * Real.logb 2 s.pair.tree.size := RotationBST.HeavyPath.Finger.History.Simulation.Interruption.run_uniform_prefix bounded valid completed cutModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.DefinitionsThe argument is elementary. One pointer instruction changes any depth by at most one, a response has at most instructions, and the response starts from a valid state, where depths are at most . For a whole run, the cut falls inside one response, and that response starts from the valid state left by the previous ones. The bound is in terms of the starting tree c.tree: rotations change neither the total weight nor the inorder, so rank names the same label throughout. The deamortization with unit weights uses run_uniform_prefix (via Deamortization.Finger, Chapter 30).
Theorem (interrupted response, weighted). For a policy with the PolicyWithin certificate, every cut of a response, and every cut of a whole run, reaches a configuration in which the node of rank has depth at most
theorem response_weighted {α : Type} {weight : α → ℝ} {p : Policy α} (certified : PolicyWithin weight p) {c : Config α} {s : State α} (valid : ConfigValid weight c s) {op : Multifinger.Opcode} {out : Output α} (responded : p c s op = some out) : ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ out.cost + out.state.potential ≤ 62 + s.potential ∧ (out.cost : ℝ) ≤ 34 + 24 * Real.logb 2 s.pair.tree.size ∧ ∀ cut, ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ rank : Fin c.tree.inorder.length, (Tree.depth middle.tree rank.val : ℝ) ≤ 336 + 240 * Real.logb 2 (HeavyPath.mass weight c.tree / weight (c.tree.inorder[rank.val]'rank.isLt)) := RotationBST.HeavyPath.Finger.History.Simulation.Interruption.response_weighted certified valid respondedModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitionstheorem run_weighted_prefix {α : Type} {weight : α → ℝ} {p : Policy α} (certified : PolicyWithin weight p) {c : Config α} {s : State α} (valid : ConfigValid weight c s) {ops : List Multifinger.Opcode} {out : Output α} (completed : run p c s ops = some out) (cut : Nat) : ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ ∀ rank : Fin c.tree.inorder.length, (Tree.depth middle.tree rank.val : ℝ) ≤ 336 + 240 * Real.logb 2 (HeavyPath.mass weight c.tree / weight (c.tree.inorder[rank.val]'rank.isLt)) := RotationBST.HeavyPath.Finger.History.Simulation.Interruption.run_weighted_prefix certified valid completed cutModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.DefinitionsHere and . The certificate’s multiplicative form avoids the term, which a weighted bound cannot afford: a heavy key must stay shallow even while a response deep in the tree is executed. This is the depth clause of Results.simulation.
Theorem (detours). With unit weights, at any cut of a run and for every key , there is a navigation-only detour from the interrupted configuration to and back, of total length (plus one for the request) at most . The detour is empty if the cursor is already on . Inserting it at the cut leaves the program legal with the same final tree, and the tree does not change during the detour.
theorem run_detour {α : Type} {p : Policy α} (bounded : PolicyBounded (fun _ => 1) p) {c : Config α} {s : State α} (valid : ConfigValid (fun _ => 1) c s) {ops : List Multifinger.Opcode} {out : Output α} (completed : run p c s ops = some out) (cut : Nat) : ∃ middle, Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop cut) middle = some ⟨out.state.pair.tree, []⟩ ∧ middle.focus ≠ .nil ∧ ∀ x < s.pair.tree.size, ∃ (visited : Pointer.Config) (before after : List Multifinger.Opcode), Multifinger.replay before middle = some visited ∧ visited.key? = some x ∧ Multifinger.replay after visited = some middle ∧ (1 + before.length + after.length : ℝ) ≤ 197 + 156 * Real.logb 2 s.pair.tree.size ∧ (middle.key? = some x → before = [] ∧ after = []) ∧ Multifinger.replay (out.instructions.take cut ++ before ++ after ++ out.instructions.drop cut) ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ (∀ pause, ∃ cursor, Multifinger.replay (before.take pause) middle = some cursor ∧ cursor.tree = middle.tree) ∧ (∀ pause, ∃ cursor, Multifinger.replay (after.take pause) visited = some cursor ∧ cursor.tree = middle.tree) := RotationBST.HeavyPath.Finger.History.Simulation.Interruption.run_detour bounded valid completed cutModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.DefinitionsThis is the paper’s “access this element by moving the finger to it and back”: go up to the root and down to , then return, each leg bounded by the interrupted depth . The interrupted cursor may be anywhere in the tree. The conclusion middle.focus ≠ .nil says that it is on a node, not on an empty subtree, so a detour can start there.
Theorem (a search window). Use unit weights. Suppose a source stream serves a request for rank target (in the sense of Requests.Serves below), and let budget be at least . Then the run of the stream succeeds with the usual amortized bound, and the physical machine has a window for the request: a number consumed budget of the run’s instructions, and a walk from the physical root that visits target and ends exactly where those consumed instructions end. The walk has length at most consumed, so at most budget. Either the whole budget is consumed, or the cursor is on target after the consumed instructions.
theorem search_window {α : Type} {p : Policy α} (bounded : PolicyBounded (fun _ => 1) p) {c final : Config α} {s : State α} (valid : ConfigValid (fun _ => 1) c s) {ops : List Multifinger.Opcode} {target budget : Nat} (targetValid : target < s.pair.tree.size) (search : Requests.Serves c ops target final) (budgetBound : 49 + 39 * Real.logb 2 s.pair.tree.size ≤ budget) : ∃ (out : Output α) (consumed : Nat) (middle visited : Pointer.Config) (before after : List Multifinger.Opcode), run p c s ops = some out ∧ out.source = final ∧ out.cost + out.state.potential ≤ 62 * ops.length + s.potential ∧ consumed ≤ budget ∧ consumed ≤ out.instructions.length ∧ Multifinger.replay (out.instructions.take consumed) ⟨s.pair.tree, []⟩ = some middle ∧ Multifinger.replay (out.instructions.drop consumed) middle = some ⟨out.state.pair.tree, []⟩ ∧ Multifinger.replay before ⟨s.pair.tree, []⟩ = some visited ∧ visited.key? = some target ∧ Multifinger.replay after visited = some middle ∧ before.length + after.length ≤ 5 * consumed ∧ 1 + before.length + after.length ≤ 1 + 5 * budget ∧ (consumed = budget ∨ middle.key? = some target) := RotationBST.HeavyPath.Finger.History.Simulation.Interruption.search_window bounded valid targetValid search budgetBoundModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Bounds.StaticTree.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.DefinitionsThis is Results.serve (Chapter 30) specialized to this simulation, whose interruption depths satisfy that theorem’s height hypothesis. A scheduler can answer every request within budget physical instructions while making progress on the pending simulated work.
38.4.10 Serving requests
So far the source has been a stream of instructions. A source BST algorithm turns requests into such streams. The definitions are in Simulation/Requests/Definitions/Abstract.lean.
/-- A source search visits the requested rank at an instruction boundary.The cursor persists between searches; a visit may occur before any movement. -/def Serves {α : Type} (c : Config α) (ops : List Multifinger.Opcode) (key : Nat) (final : Config α) : Prop := ∃ before after visited, ops = before ++ after ∧ sourceRun c before = some visited ∧ visited.erase.key? = some key ∧ sourceRun visited after = some finalServes c ops key final says that the source stream ops from cursor c visits the node of rank key at some instruction boundary and ends at final. The stream splits as before ++ after, the cursor after before is on key, and after is arbitrary further work. The source finger persists between requests: a search starts wherever the previous one ended, as in the paper’s BST model, and before may be empty if the finger already is on the key.
/-- A source BST algorithm sees past requests, its current cursor and the nextrank. Correctness requires a legal search but permits arbitrary later work. -/structure Algorithm (α : Type) where step : List Nat → Config α → Nat → List Multifinger.Opcode × Config α correct : ∀ past c key, c.focus ≠ .nil → key < c.tree.erase.size → Serves c (step past c key).1 key (step past c key).2correctStructures/HeavyPath/Finger/History/Simulation/Requests/Definitions/Abstract.lean and its importsdef Algorithm.runFrom {α : Type} (a : Algorithm α) (past : List Nat) (c : Config α) : List Nat → List Multifinger.Opcode × Config α | [] => ([], c) | key :: keys => let first := a.step past c key let last := a.runFrom (past ++ [key]) first.2 keys (first.1 ++ last.1, last.2)An Algorithm has a step that sees the past requests, the current source cursor and the next requested rank. It returns a source instruction stream and the resulting cursor. Its correct field requires, for a nonempty focus and an in-range rank, that the stream serve the request and end at the returned cursor. Correctness constrains legality and the visit, not the cost, and an algorithm may do arbitrary work after the visit. runFrom past c keys concatenates the streams over a request list and returns the final cursor. The source cost of a request sequence is the length of this concatenated stream. This is a persistent-finger counterpart of the online algorithms of Chapter 5. Chapter 30 connects the two.
/-- Lift the fixed physical instruction policy request by request. Emittedinstructions and source state are carried forward without seeing future keys. -/def run {α : Type} (p : Policy α) (a : Algorithm α) (past : List Nat) (c : Config α) (s : State α) : List Nat → Option (Output α) | [] => some ⟨c, s, []⟩ | key :: keys => (Simulation.run p c s (a.step past c key).1).bind fun first => (run p a (past ++ [key]) first.source first.state keys).map fun last => ⟨last.source, last.state, first.instructions ++ last.instructions⟩Requests.run p a past c s keys lifts the policy request by request. For each key it runs the policy on the algorithm’s stream for that key. No step sees a future key.
Basic facts. Erasing labels commutes with running: a labelled source stream is a legal pointer program on the unlabelled tree with the same result, so source costs are pointer-model costs. Algorithms exist, so the correct obligation is satisfiable. Both the source algorithm and the lifted run are compositional and prefix-preserving. A request-by-request run equals the instruction-by-instruction run on the concatenated stream, which is legal. Every valid state has potential at most .
theorem source_erase {α : Type} (c : Config α) (ops : List Multifinger.Opcode) : (sourceRun c ops).map Config.erase = Multifinger.replay ops c.erase := RotationBST.HeavyPath.Finger.History.Simulation.Requests.source_erase c opsModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem algorithm_exists (α : Type) : Nonempty (Algorithm α) := RotationBST.HeavyPath.Finger.History.Simulation.Requests.algorithm_exists αModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem source_requests_append {α : Type} (a : Algorithm α) (past : List Nat) (c : Config α) (xs ys : List Nat) : a.runFrom past c (xs ++ ys) = let first := a.runFrom past c xs let last := a.runFrom (past ++ xs) first.2 ys (first.1 ++ last.1, last.2) := RotationBST.HeavyPath.Finger.History.Simulation.Requests.source_requests_append a past c xs ysModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem run_append {α : Type} (p : Policy α) (a : Algorithm α) (past : List Nat) (c : Config α) (s : State α) (xs ys : List Nat) : run p a past c s (xs ++ ys) = (run p a past c s xs).bind fun first => (run p a (past ++ xs) first.source first.state ys).map fun last => ⟨last.source, last.state, first.instructions ++ last.instructions⟩ := RotationBST.HeavyPath.Finger.History.Simulation.Requests.run_append p a past c s xs ysModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem run_prefix {α : Type} (p : Policy α) (a : Algorithm α) (past : List Nat) (c : Config α) (s : State α) (xs ys : List Nat) {out : Output α} (completed : run p a past c s (xs ++ ys) = some out) : ∃ first, run p a past c s xs = some first ∧ first.instructions <+: out.instructions := RotationBST.HeavyPath.Finger.History.Simulation.Requests.run_prefix p a past c s xs ys completedModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem flatten {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) (a : Algorithm α) (past : List Nat) {c : Config α} {s : State α} (valid : ConfigValid weight c s) (keys : List Nat) (validKeys : ∀ x ∈ keys, x < c.tree.erase.size) {out : Output α} (completed : run p a past c s keys = some out) : Simulation.run p c s (a.runFrom past c keys).1 = some out ∧ sourceRun c (a.runFrom past c keys).1 = some (a.runFrom past c keys).2 := RotationBST.HeavyPath.Finger.History.Simulation.Requests.flatten policyValid a past valid keys validKeys completedModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem config_potential_bound {α : Type} {weight : α → ℝ} {c : Config α} {s : State α} (valid : ConfigValid weight c s) : s.potential + 20 ≤ 20 * c.tree.erase.size := RotationBST.HeavyPath.Finger.History.Simulation.Requests.config_potential_bound validModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionsflatten is what lets the results for instruction runs apply to request runs: Results.run_excess and Results.run_weighted_prefix are both applied to the flattened run in the proof of Results.simulation.
Theorem (one request). For a valid policy and a valid pair , if a source stream serves rank key, then the simulated run serves it on the pointer machine. In the sense of Pointer.Serves, the physical program starts at the physical root, visits key, and ends in the final physical tree, at cost , where is the number of emitted instructions. The amortized bound holds, and the visit happens at a recorded cut of the emitted program.
theorem serves {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {c final : Config α} {s : State α} {ops : List Multifinger.Opcode} {key : Nat} (valid : ConfigValid weight c s) (search : Serves c ops key final) : ∃ out, Simulation.run p c s ops = some out ∧ out.source = final ∧ ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ out.cost + out.state.potential ≤ 62 * ops.length + s.potential ∧ Pointer.Serves s.pair.tree out.state.pair.tree key (1 + out.cost) := RotationBST.HeavyPath.Finger.History.Simulation.Requests.serves policyValid valid searchModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem serves_recorded {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) {c final : Config α} {s : State α} {ops : List Multifinger.Opcode} {key : Nat} (valid : ConfigValid weight c s) (search : Serves c ops key final) : ∃ out, Simulation.run p c s ops = some out ∧ out.source = final ∧ ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ out.cost + out.state.potential ≤ 62 * ops.length + s.potential ∧ Pointer.Serves s.pair.tree out.state.pair.tree key (1 + out.cost) ∧ ∃ cut visited, cut ≤ out.instructions.length ∧ Multifinger.replay (out.instructions.take cut) ⟨s.pair.tree, []⟩ = some visited ∧ visited.key? = some key := RotationBST.HeavyPath.Finger.History.Simulation.Requests.serves_recorded policyValid valid searchModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.DefinitionsThe physical visit happens between two responses. When the source finger is on key, the physical root is the node of rank key (Results.root_key), so the visit needs no extra instructions. The recorded cut in serves_recorded is the visit hypothesis of Results.serve.
Theorem (request sequences). For a valid policy, any source algorithm, a valid pair and in-range requests, the lifted run succeeds and ends at the algorithm’s final cursor in a valid state. It is a Pointer.Execution of the request list from the physical tree, of cost (one unit per request plus the emitted instructions), and , where is the algorithm’s total source cost. Without any assumption on , the work on any window of requests is at most .
theorem run_spec {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) (a : Algorithm α) (past : List Nat) {c : Config α} {s : State α} (valid : ConfigValid weight c s) (keys : List Nat) (validKeys : ∀ x ∈ keys, x < c.tree.erase.size) : ∃ out, run p a past c s keys = some out ∧ out.source = (a.runFrom past c keys).2 ∧ ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ Pointer.Execution s.pair.tree keys out.state.pair.tree (keys.length + out.cost) ∧ out.cost + out.state.potential ≤ 62 * (a.runFrom past c keys).1.length + s.potential := RotationBST.HeavyPath.Finger.History.Simulation.Requests.run_spec policyValid a past valid keys validKeysModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionstheorem interval_work {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) (a : Algorithm α) (past : List Nat) {c : Config α} {s : State α} (valid : ConfigValid weight c s) (keys : List Nat) (validKeys : ∀ x ∈ keys, x < c.tree.erase.size) : ∃ out, run p a past c s keys = some out ∧ out.source = (a.runFrom past c keys).2 ∧ ConfigValid weight out.source out.state ∧ Multifinger.replay out.instructions ⟨s.pair.tree, []⟩ = some ⟨out.state.pair.tree, []⟩ ∧ Pointer.Execution s.pair.tree keys out.state.pair.tree (keys.length + out.cost) ∧ keys.length + out.cost ≤ 62 * (keys.length + (a.runFrom past c keys).1.length) + 20 * c.tree.erase.size := RotationBST.HeavyPath.Finger.History.Simulation.Requests.interval_work policyValid a past valid keys validKeysModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.Definitionsinterval_work combines run_spec with Results.config_potential_bound. It applies to any segment of a longer run, starting from whatever history the earlier requests left.
Theorem (initialized request sequences). For a valid policy and any source algorithm, starting from a source finger in a positively weighted tree with nodes, there is a starting state, reached from by a startup trace of cost with , such that for every request history past and every list of in-range requests:
- the lifted run succeeds and ends at the algorithm’s final cursor in a valid state;
- it is a pointer-machine execution of the requests from the starting physical tree at cost , and, for a nonempty request list, an execution from itself at cost ;
- , where is the algorithm’s source cost.
theorem initialized_run {α : Type} {weight : α → ℝ} {p : Policy α} (policyValid : PolicyValid weight p) (a : Algorithm α) {cs : List (Frame α)} {left right : LabelledTree α} {key : α} (positive : Positive weight (plug cs (.node left key right))) : ∃ (start : State α) (startupCost : Nat), ConfigValid weight ⟨.node left key right, cs⟩ start ∧ Pointer.Trace ⟨(plug cs (.node left key right)).erase, []⟩ ⟨start.pair.tree, []⟩ startupCost ∧ startupCost + start.potential ≤ 39 * (plug cs (.node left key right)).erase.size ∧ ∀ (past keys : List Nat), (∀ x ∈ keys, x < (plug cs (.node left key right)).erase.size) → ∃ out, run p a past ⟨.node left key right, cs⟩ start keys = some out ∧ out.source = (a.runFrom past ⟨.node left key right, cs⟩ keys).2 ∧ ConfigValid weight out.source out.state ∧ Pointer.Execution start.pair.tree keys out.state.pair.tree (keys.length + out.cost) ∧ (keys ≠ [] → Pointer.Execution (plug cs (.node left key right)).erase keys out.state.pair.tree (startupCost + (keys.length + out.cost))) ∧ startupCost + keys.length + out.cost + out.state.potential ≤ 39 * (plug cs (.node left key right)).erase.size + 62 * (keys.length + (a.runFrom past ⟨.node left key right, cs⟩ keys).1.length) := RotationBST.HeavyPath.Finger.History.Simulation.Requests.initialized_run policyValid a positiveModels.Rotation, Models.Multifinger.Program.Definitions, Models.Multifinger.Program.Replay.Definitions, Models.Pointer.Machine, Models.Pointer.Mirror.Definitions, Models.Pointer.Lazy.Skeleton, Models.Labelled.Cursor.Definitions, Models.Labelled.Ordering.Definitions, Structures.PopTart.Definitions, Structures.PopTart.Mirror.Definitions, Structures.PopTart.Chocolate.Definitions, Structures.PopTart.Located.Definitions, Structures.HeavyPath.Definitions, Structures.HeavyPath.Paired.Definitions, Structures.HeavyPath.Paired.Substitution.Definitions, Structures.HeavyPath.Recursive.Definitions, Structures.HeavyPath.Finger.Definitions, Structures.PopTart.Chocolate.Top.Definitions, Structures.HeavyPath.Paired.Exposure.Definitions, Structures.HeavyPath.Recursive.History.Definitions, Structures.HeavyPath.Finger.Transfer.Definitions, Structures.HeavyPath.Finger.History.Definitions, Structures.HeavyPath.Finger.History.Simulation.Definitions, Structures.HeavyPath.Finger.History.Simulation.Requests.Definitions, Bounds.StaticTree.DefinitionsThe empty request list is excluded from the second execution because a Pointer.Execution of no requests has cost and cannot absorb a nonzero startup. Up to constants, this is Theorem 5’s for every online source algorithm, with the startup made explicit. Results.simulation replaces the start by a cheapest representation, as in Section 38.4.8, to get the purely multiplicative bound .