Iterative control for fan-in-d Cook–Mertz #
The controller unravels Ary.procWith into calls and returns over one shared register bank.
A frame retains a round number, child index, forward/undo phase, coefficient and target register;
it stores neither a tree nor a saved register bank. Reading a node is parameterized by the
existing Tree.Node lookup at a path. The path is recovered from the stack's child indices.
A forward phase scales a child's register and calls that child with coefficient one. After the
last forward call, it performs the supplied gate update. Undo phases call each child with
coefficient minus one and undo its scaling upon return. Children in both phases are processed
in increasing order, exactly as in Ary.gateRoundWith.
Main definitions #
Cslib.TreeEval.Ary.Iter.Frame,Mode,Cfg: frames, call/return modes and global state.Cslib.TreeEval.Ary.Iter.path: recover the current node path without storing it per frame.Cslib.TreeEval.Ary.Iter.step,runFrom: the controller and its clocked iteration.
References #
- O. Goldreich, On the Cook–Mertz Tree Evaluation procedure, Algorithm 1, with signed calls.
- R. Williams, Simulating Time With Square-Root Space, Appendix A.
This is pure control semantics for positive fan-in. Node lookup and the supplied gate extension are parameters; their native implementation and space costs are separate obligations.
A suspended call, retaining control data only.
Calling a node with a coefficient and target, or returning from one.
Update at a gate, leaving the registers unchanged if the requested path is invalid.
Iterate control steps from any supplied configuration.
A successor clock performs one more control step.
Consecutive runs compose without resetting registers or continuation frames.
A leaf call uses one control step and leaves its continuation stack intact.
A gate starts the first round when the unit enumeration is nonempty.
With no unit rounds a gate call immediately returns unchanged registers.
Reading a valid gate performs exactly the supplied algebraic gate update.
After a forward child returns, scale and call the next child if one remains.
The last forward return performs the gate update and calls the first undo child.
An undo return first cancels the scaling, then calls the next child without scaling it.
The last undo return begins the next round if one remains.
The final undo return pops exactly the current call's frame.