Canonical linked-tree input encoding #
Preorder enumeration assigns consecutive ghost addresses to an existing BinaryTree.
The heap contains precisely its records, including parent links, and preserves every scalar
field. This is an input encoding; no machine instruction observes the assigned addresses.
def Cslib.DataStructure.SearchTree.PointerMachine.labelTree {M : PointerMachine.Model} {extra : ℕ} (base : ℕ) :
Assign consecutive preorder addresses, retaining all scalar fields.
def Cslib.DataStructure.SearchTree.PointerMachine.encodeHeap {M : PointerMachine.Model} {extra regs : ℕ} (t : BinaryTree (Fin (extra + 1) → M.Value)) (base : ℕ) (parent : PointerMachine.Pointer) :
The preorder list of records, with the supplied external parent pointer.
@[simp]
theorem Cslib.DataStructure.SearchTree.PointerMachine.length_encodeHeap {M : PointerMachine.Model} {extra regs : ℕ} (t : BinaryTree (Fin (extra + 1) → M.Value)) (base : ℕ) (parent : PointerMachine.Pointer) :
Encoding uses one record per node.
theorem Cslib.DataStructure.SearchTree.PointerMachine.address_labelTree {M : PointerMachine.Model} {extra : ℕ} {t : BinaryTree (Fin (extra + 1) → M.Value)} {base a : ℕ} (mem : a ∈ addresses (labelTree base t)) :
Every assigned address lies in the consecutive interval reserved for its tree.
theorem Cslib.DataStructure.SearchTree.PointerMachine.addressesDistinct_labelTree {M : PointerMachine.Model} {extra : ℕ} (base : ℕ) (t : BinaryTree (Fin (extra + 1) → M.Value)) :
AddressesDistinct (labelTree base t)
Preorder addresses distinguish all nodes.
theorem Cslib.DataStructure.SearchTree.PointerMachine.represents_encodeHeap {M : PointerMachine.Model} {extra regs : ℕ} (t : BinaryTree (Fin (extra + 1) → M.Value)) (pre post : List (PointerMachine.Record M (layout extra regs))) (parent : PointerMachine.Pointer) :
The encoded records represent the tree at their actual positions in any ambient heap.
theorem Cslib.DataStructure.SearchTree.PointerMachine.encodeHeap_links {M : PointerMachine.Model} {extra regs : ℕ} (t : BinaryTree (Fin (extra + 1) → M.Value)) (base : ℕ) (parent : PointerMachine.Pointer) {size : ℕ} (bound : base + t.numNodes ≤ size) (parentBound : ∀ (a : ℕ), parent = some a → a < size) (n : PointerMachine.Record M (layout extra regs)) :
Every heap edge is valid within an ambient heap containing this tree and its parent.