Documentation

Examples.Language.Splay.CorrectnessBasic

Mathematical postconditions for the actual splay access #

AccessResult packages successful execution of the sole source declaration, its represented output tree and the exact cell-local frame. The mathematical rotation certificate uses the depth of ordinary search in the original tree; it is not a separate runtime evaluator or a resource premise for termination.

The elementary cases below stop at the current root or lift its matching child. Recursive cases compose the same postcondition at smaller mathematical trees.

def Complexity.Language.Examples.Splay.AccessResult (key : ℕ → ℕ) (keys left right : Buffer CellTy.nat) (query : ℕ) (tree : Tree ℕ) (heap : Heap) :

Successful source execution, mathematical splay certificate and actual heap frame. No word-width, capacity or time-budget premise occurs here.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.Language.Examples.Splay.AccessResult.of_unchanged {key : ℕ → ℕ} {keys left right : Buffer CellTy.nat} {query : ℕ} {heap : Heap} {tree : Tree ℕ} (represented : BufferTree.Rep key keys left right heap tree) (executed : Implementation.splay keys left right (BufferTree.root tree) query heap = Part.some (Except.ok (BufferTree.root tree), heap)) (focus : searchFocus key query tree = tree) (depth : searchDepth key query tree = 0) :
    AccessResult key keys left right query tree heap

    A terminal access keeps both its mathematical tree and its actual heap.

    theorem Complexity.Language.Examples.Splay.AccessResult.nil {key : ℕ → ℕ} {keys left right : Buffer CellTy.nat} {query : ℕ} {heap : Heap} :
    AccessResult key keys left right query Tree.nil heap

    The empty input terminates without reading any buffer.

    theorem Complexity.Language.Examples.Splay.AccessResult.of_eq {key : ℕ → ℕ} {keys left right : Buffer CellTy.nat} {query : ℕ} {heap : Heap} {id : ℕ} {a b : Tree ℕ} (represented : BufferTree.Rep key keys left right heap (Tree.node id a b)) (same : key id = query) :
    AccessResult key keys left right query (Tree.node id a b) heap

    A matching root needs no rotation.

    theorem Complexity.Language.Examples.Splay.AccessResult.left_nil {key : ℕ → ℕ} {keys left right : Buffer CellTy.nat} {query : ℕ} {heap : Heap} {id : ℕ} {b : Tree ℕ} (represented : BufferTree.Rep key keys left right heap (Tree.node id Tree.nil b)) (direction : query < key id) :
    AccessResult key keys left right query (Tree.node id Tree.nil b) heap

    A missing left child makes the current root the last visited node.

    theorem Complexity.Language.Examples.Splay.AccessResult.right_nil {key : ℕ → ℕ} {keys left right : Buffer CellTy.nat} {query : ℕ} {heap : Heap} {id : ℕ} {a : Tree ℕ} (represented : BufferTree.Rep key keys left right heap (Tree.node id a Tree.nil)) (direction : key id < query) :
    AccessResult key keys left right query (Tree.node id a Tree.nil) heap

    The symmetric missing-child branch also retains the current root.

    theorem Complexity.Language.Examples.Splay.AccessResult.left_eq {key : ℕ → ℕ} {keys left right : Buffer CellTy.nat} {query : ℕ} {heap : Heap} {x y : ℕ} {a b c : Tree ℕ} (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) (direction : query < key y) (same : key x = query) :
    AccessResult key keys left right query (Tree.node y (Tree.node x a b) c) heap

    A matching left child becomes the root through the actual right rotation.

    theorem Complexity.Language.Examples.Splay.AccessResult.right_eq {key : ℕ → ℕ} {keys left right : Buffer CellTy.nat} {query : ℕ} {heap : Heap} {x y : ℕ} {a b c : Tree ℕ} (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) (direction : key x < query) (same : key y = query) :
    AccessResult key keys left right query (Tree.node x a (Tree.node y b c)) heap

    The symmetric immediate-child case uses the actual left rotation.