Documentation

Examples.Language.Splay.RotationTree

Splay rotations preserve represented mathematical trees #

The operational two-write contracts are lifted to mathlib's tree rotations. The shared node-update rules supply memory safety and preserve the unchanged subtrees. Uniqueness of the original inorder list supplies the no-cycle facts; no different-object assumption is imposed on the three field arrays.

Each theorem retains the actual source evaluation and the cell-local frame of its original tree. Recursive callers may therefore protect other nodes in the same arrays without reopening the rotation's implementation.

theorem Complexity.Language.Examples.Splay.rotateRight_rep (key : ℕ → ℕ) (keys left right : Buffer CellTy.nat) (x y : ℕ) (a b c : Tree ℕ) {heap : Heap} (represented : BufferTree.Rep key keys left right heap (Tree.node y (Tree.node x a b) c)) (unique : (Tree.node y (Tree.node x a b) c).inorder.Nodup) (keysLeft : keys.Disjoint left) (keysRight : keys.Disjoint right) (leftRight : left.Disjoint right) :
∃ (finish : Heap), Implementation.rotateRight left right y heap = Part.some (Except.ok x, finish) ∧ BufferTree.Rep key keys left right finish (Tree.node y (Tree.node x a b) c).rotateRight ∧ Heap.PreservesOutside (BufferTree.linkCells left right (Tree.node y (Tree.node x a b) c)) heap finish

A real right rotation has the ordinary tree-rotation result and changes only links of the original tree. Read success from the representation supplies every write's index and view-validity condition.

theorem Complexity.Language.Examples.Splay.rotateLeft_rep (key : ℕ → ℕ) (keys left right : Buffer CellTy.nat) (x y : ℕ) (a b c : Tree ℕ) {heap : Heap} (represented : BufferTree.Rep key keys left right heap (Tree.node x a (Tree.node y b c))) (unique : (Tree.node x a (Tree.node y b c)).inorder.Nodup) (keysLeft : keys.Disjoint left) (keysRight : keys.Disjoint right) (leftRight : left.Disjoint right) :
∃ (finish : Heap), Implementation.rotateLeft left right x heap = Part.some (Except.ok y, finish) ∧ BufferTree.Rep key keys left right finish (Tree.node x a (Tree.node y b c)).rotateLeft ∧ Heap.PreservesOutside (BufferTree.linkCells left right (Tree.node x a (Tree.node y b c))) heap finish

The symmetric real left rotation retains its mathematical tree result and the same precise outside-tree frame, including same-object disjoint columns.