Ancestors of a linked subtree #
These ghost frames describe ancestors and siblings, not an additional machine stack.
They adapt the ancestor contexts and labelled cursors of Stefan Langerman's earlier
lean-bst development to Frontier's BinaryTree.
represents_plug_iff decomposes a whole-tree heap representation into the focused subtree
and its surrounding context, and conversely reconstructs it. Parent pointers implement
the corresponding machine navigation.
One ghost ancestor, retaining its label and the sibling outside the focus.
- left {M : PointerMachine.Model} {extra : ℕ} (label : Label M extra) (right : BinaryTree (Label M extra)) : Frame M extra
The focus is the left child.
- right {M : PointerMachine.Model} {extra : ℕ} (left : BinaryTree (Label M extra)) (label : Label M extra) : Frame M extra
The focus is the right child.
Reconstruct the tree, with the immediate parent first in the context.
The immediate parent's address, or null at the overall root.
A plugged tree consists of the focus addresses and the addresses in its context.
Heap representation of the ancestors and siblings around a supplied focus link. The list and labels are proof data; no unbounded register or stack is added to the machine.
A whole-tree representation is exactly the focused subtree plus its ancestor/sibling context. This permits local mutation proofs to reconstruct the complete tree.
A complete tree is separated exactly when its focus and context are individually separated and their address footprints are disjoint.
A focused subtree inherits distinct addresses from its complete tree.
Replacing a focus by a separated tree with the same address footprint preserves separation from every ancestor and sibling.
Equal focus roots give equal complete-tree roots, independently of interior shape.
The focused addresses are among the complete tree's addresses.
A focus's height plus its ancestor count is bounded by the complete tree's height.
A local replacement with the same root reconstructs the whole tree when the heap outside the original focus is unchanged. Separation is derived from the original tree.
Following a represented nonempty focus's parent takes one load and halt. The heap, scalars and every other pointer register survive; at the root the resulting cursor is null.