forRegTM: the register-fueled loop combinator #
forRegTM body r runs body once per mark of register r. The fuel is the
head position on r: the register's cells are never written; the test reads
the cell under the head — a mark means "iterate" (consume = move right, run
the body), the first blank means "exit" (rewind r to cell 1 and halt). The
body must leave r untouched (our ghost-style specs guarantee this for free,
since bodies preserve every non-target tape literally).
This is the only loop mechanism of the reduction emitter
(docs/A5-ReductionEmitter.md): unlike loopTM, its test reads a work
tape, so the output tape remains an append-only accumulator throughout.
The Hoare rule forRegTM_hoareTime threads an iteration-indexed family of
ghost work-tape functions and output words through the loop.
ForPhase is a finite type (it has exactly three constructors).
Equations
- One or more equations did not get rendered due to their size.
forRegTM Hoare rule. Given a fuel register holding v (whose tape the
iteration-indexed ghost family w never changes) and a body spec carrying
w i / ys i to w (i+1) / ys (i+1), the loop carries w 0 / ys 0 to
w v / ys v in at most v·(b_iter + 2) + v + 3 steps.