Running a machine from a work tape onto a work tape #
A loop body cannot compute into the real output tape — it is one-way, so it
cannot serve as scratch across iterations. TM.retargetInputStarted reads a
machine's input off a work tape and TM.retargetOutput writes its output onto a
fresh one; composing them gives TM.applyTM, a work-to-work evaluator, and
composing their Hoare rules gives its contract.
Main results #
TM.applyTM— the work-to-work evaluator for a source machineTM.applyTM_hoareTime/TM.applyTM_hoareTime_frame— its time contract
Work-tape-to-work-tape evaluation. applyTM M : TM (k + 2) reads the
source machine's input off work tape k, runs M on it, and leaves the result
on work tape k + 1; the real input and output tapes are untouched.
Work tapes 0, …, k-1 are M's own scratch, so a caller that runs applyTM M
more than once has to restore them between calls — that is what the
precondition below demands.
Equations
Instances For
The tapes applyTM M expects at entry: M's scratch blank, the virtual
input holding y, the result tape blank.
Equations
- M.applyPre y realInput = Fin.snoc (M.retargetInputStartedCfg y realInput).work Complexity.TM.parkedBlank
Instances For
The contract of the work-to-work evaluator. Given M's own time bound,
applyTM M halts within that bound with f y on its result tape — provided
M's scratch tapes were blank, work tape k held y, and the result tape was
blank.
The work-to-work evaluator reads its input from a work tape, so it idles the real input head.
The work-to-work evaluator, with its disturbance framed. Beyond
computing f y onto the result tape, this records the two facts a caller needs
in order to reset the machine for a second call: every tape's head is still
within H, and every cell beyond H is still blank. Both follow from the run
being T |y|-bounded and every entry tape being parked and blank past |y|.