Declarative certificates for splay rotations #
SplayTrace records the shape changes made by bottom-up splaying and their
number of rotations. It is a proposition, not a second executable splay
function. A source-program proof must construct this certificate from its
actual execution; the certificate alone assigns no RAM instruction cost.
The focus is the original subtree rooted at the accessed node. A failed search may instead focus on its last visited node. Empty grandchildren do not introduce double-rotation cases: their source calls can perform work, but the tree transformation is a single zig and that work must be charged separately.
A bottom-up splay certificate, indexed by its original focus and rotation count.
- refl {α : Type u_1} (tree : Tree α) : SplayTrace tree tree tree 0
- zigLeft {α : Type u_1} (x y : α) (a b c : Tree α) : SplayTrace (Tree.node x a b) (Tree.node y (Tree.node x a b) c) (Tree.node x a (Tree.node y b c)) 1
- zigRight {α : Type u_1} (x y : α) (a b c : Tree α) : SplayTrace (Tree.node x b c) (Tree.node y a (Tree.node x b c)) (Tree.node x (Tree.node y a b) c) 1
- zigZigLeft {α : Type u_1} {focus inner : Tree α} {x y z : α} {a b c d : Tree α} {n : ℕ} (rec : SplayTrace focus inner (Tree.node x a b) n) : SplayTrace focus (Tree.node z (Tree.node y inner c) d) (Tree.node x a (Tree.node y b (Tree.node z c d))) (n + 2)
- zigZigRight {α : Type u_1} {focus inner : Tree α} {x y z : α} {a b c d : Tree α} {n : ℕ} (rec : SplayTrace focus inner (Tree.node x c d) n) : SplayTrace focus (Tree.node z a (Tree.node y b inner)) (Tree.node x (Tree.node y (Tree.node z a b) c) d) (n + 2)
- zigZagLeft {α : Type u_1} {focus inner : Tree α} {x y z : α} {a b c d : Tree α} {n : ℕ} (rec : SplayTrace focus inner (Tree.node x b c) n) : SplayTrace focus (Tree.node z (Tree.node y a inner) d) (Tree.node x (Tree.node y a b) (Tree.node z c d)) (n + 2)
- zigZagRight {α : Type u_1} {focus inner : Tree α} {x y z : α} {a b c d : Tree α} {n : ℕ} (rec : SplayTrace focus inner (Tree.node x b c) n) : SplayTrace focus (Tree.node z a (Tree.node y inner d)) (Tree.node x (Tree.node z a b) (Tree.node y c d)) (n + 2)
Instances For
Every label, including duplicates, retains its inorder position.
Splaying neither creates nor removes nodes.
The original focus label is the final root, without choosing a value for nil.
The selected original subtree fits inside the original whole tree.
The access lemma for certified rotations. An execution-cost theorem must separately bound actual program work by these rotations and its constant overhead.
A root-size-only amortized bound, retaining both initial and final credit.