Universal machine: the simulate/halt-test loop #
The headline correctness theorem for the UTM's main loop
loopTM bodyTM haltTestTM: if the interpreted machine
(decodeDesc α).toTM halts on x in T steps at the configuration
mcF, then from any tapes realizing the standing invariant SimInv at
the interpreted machine's initial configuration (output tape cleared,
head parked at cell 1), the loop halts within (T + 1) * utmStepTime α
steps with SimInv re-established at mcF and the halt verdict Γ.one
at output cell 1.
Proof structure #
One loop iteration = one interpreted step:
bodyIterationruns one body pass (SimInvatmc↦SimInvat(decodeDesc α).toTM.step mc, or an exact no-op when halted);- the body→test / test→rewind combinator transitions apply
transitionInput/transitionTapeto every tape — literal identities here, since everySimInvtape is parked (head ≥ 1, read ≠▷); haltTestTM_hoareTimecompares the state tape against the description's qhalt field, writing the verdict at output cell 1;simInv_verdictidentifies the comparison with the interpreted halt test;- the rewind/check bookkeeping (3 steps, output head 1 → 0 → 1) either
halts the loop (verdict
Γ.one) or returns to the loop start with the invariant re-established (loopTM_rewind_checkbelow).
The outer induction (loop_sim_aux) is a strong induction on the
remaining fuel T - t' rather than an instance of loopTM_hoareTime:
the loop variant would have to be a function of the tapes, while here
it is determined only through the existentially quantified prefix run of
the interpreted machine. Determinism of reachesIn plus the
halted-configurations-don't-step principle (TM.reachesIn_le_halt)
identify the loop's exit configuration with mcF.
Per-α time cost of one iteration of the UTM's simulate/halt-test
loop: one body pass, the two combinator transitions, the halt test,
and the loop's rewind/check bookkeeping.
Equations
Instances For
The UTM loop simulates the interpreted machine. Suppose
(decodeDesc α).toTM halts on x in T steps at mcF. Then from
any tapes realizing SimInv at the interpreted machine's initial
configuration — with the output tape ▷-clean and parked at cell 1 —
the loop loopTM bodyTM haltTestTM halts within
(T + 1) * utmStepTime α steps, with SimInv re-established at mcF
(so the virtual output tape shadows the simulated output) and the halt
verdict Γ.one at output cell 1.
Hoare-style packaging of utm_loop_simulates, ready for seqTM
composition with the init and extract phases.
Loop + extraction: after the simulate/halt-test loop, extractTM
copies the virtual output tape onto the real output tape. The combined
machine turns the loop's precondition into the final output guarantee:
the real output tape agrees with the simulated machine's final output
tape (cells 1, …, m + 1) through the latter's first blank.
The universal machine's end-to-end specification. On the standard
initial tapes for input pair α x, if the interpreted machine
(decodeDesc α).toTM halts on x at mcF within T steps, then
utmTM halts within
4·|pair α x| + 4·|groupPairs α| + 26 + (T + 1)·utmStepTime α + 2T + 9
steps with its real output tape agreeing with the simulated machine's
final output tape through the latter's first blank — i.e. the UTM
computes exactly the simulated machine's output.