Right-going recursive cases of the actual splay program #
The recursive call's represented subtree and precise cell frame are reattached by the shared parent-link rules. The actual ensuing rotations produce the mathematical splay trace and preserve every cell outside the original tree. Empty recursive results take the implementation's single-rotation path.
theorem
Complexity.Language.Examples.Splay.AccessResult.zig_zig_right
{query : ℕ}
(key : ℕ → ℕ)
(keys left right : Buffer CellTy.nat)
(z y : ℕ)
(a b inner : Tree ℕ)
{heap : Heap}
(represented : BufferTree.Rep key keys left right heap (Tree.node z a (Tree.node y b inner)))
(unique : (Tree.node z a (Tree.node y b inner)).inorder.Nodup)
(keysLeft : keys.Disjoint left)
(keysRight : keys.Disjoint right)
(leftRight : left.Disjoint right)
(rootLt : key z < query)
(childLt : key y < query)
(recursive : AccessResult key keys left right query inner heap)
:
AccessResult key keys left right query (Tree.node z a (Tree.node y b inner)) heap
Right-right descent composes the recursive call, its real parent-link write and one or two left rotations at their actual intermediate heaps.
theorem
Complexity.Language.Examples.Splay.AccessResult.zig_zag_right
{query : ℕ}
(key : ℕ → ℕ)
(keys left right : Buffer CellTy.nat)
(z y : ℕ)
(a inner d : Tree ℕ)
{heap : Heap}
(represented : BufferTree.Rep key keys left right heap (Tree.node z a (Tree.node y inner d)))
(unique : (Tree.node z a (Tree.node y inner d)).inorder.Nodup)
(keysLeft : keys.Disjoint left)
(keysRight : keys.Disjoint right)
(leftRight : left.Disjoint right)
(rootLt : key z < query)
(queryLtChild : query < key y)
(recursive : AccessResult key keys left right query inner heap)
:
AccessResult key keys left right query (Tree.node z a (Tree.node y inner d)) heap
Right-left descent reattaches the actual recursive result, rotates the child only when nonempty, updates the root link and performs the final rotation.