Documentation

CslibFrontier.DataStructure.SearchTree.PointerMachine.Encoding

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.

Assign consecutive preorder addresses, retaining all scalar fields.

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) :
(encodeHeap t base parent).length = t.numNodes

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)) :
base ≤ a ∧ a < base + t.numNodes

Every assigned address lies in the consecutive interval reserved for its tree.

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) :
Represents (pre ++ encodeHeap t pre.length parent ++ post) parent (labelTree pre.length t)

The encoded records represent the tree at their actual positions in any ambient heap.