Reconnecting a subtree within its complete tree #
The local mutation supplies a replacement subtree and a frame for the old subtree's exterior. The concrete reconnection program restores the complete heap representation and root register. Separation follows from the original tree's distinct addresses and the preserved footprint.
Whole-tree and register guarantees after reconnecting a changed focus.
The complete tree is again linked correctly.
- distinct : AddressesDistinct (plug cs tree)
Complete-tree addresses remain distinct.
The global root tracks the reconstructed tree.
The cursor remains at the changed focus.
Reconnection preserves scalar registers.
Reconnection allocates nothing.
Only the global root and navigation scratch pointers can change.
- payload (a : ℕ) (f : Fin (extra + 1)) : Option.map (fun (n : PointerMachine.Record M (layout extra regs)) => n.data f) t.heap[a]? = Option.map (fun (n : PointerMachine.Record M (layout extra regs)) => n.data f) s.heap[a]?
All scalar fields of all heap records survive reconnection.
Reattach a nonempty replacement with the original focus's footprint. Every hypothesis about the changed heap is local to the focus; the whole-tree conclusion is proved by the program. The root case takes five instructions and a proper ancestor takes seven.