Clock infrastructure for the time-bounded universal machine #
Everything lives in namespace TM (the machines here are generic
TM-building blocks in the style of Subroutines.lean / DecReg.lean,
not bodyTM phase states, so they sit beside liftTM rather than in
TM.UTMBody). Two pieces:
HoareTimelifting throughliftTM: a Hoare-style spec fortm : TM ntransfers totm.liftTM mwith the same time bound, with themextra work tapes exactly preserved.liftTM_hoareTime_frameis the ghost-pinned frame version: the extras hold arbitrary parked content (head ≥ 1, reading a non-▷symbol) — needed to run lifted 6-tape UTM phases while tape 6 holds the clock.liftTM_hoareTimeis the special case where the extras hold the canonical parked blank tape(Tape.init []).move Dir3.right(the tapeliftCfgpins them to).
The key observation:
liftTM's extra-tape action isreadBackWrite/idleDir— exactlytransitionTape, which is the identity on any tape reading a non-▷symbol (transitionTape_eq_self). So the extras are preserved exactly at every step, for any parked content, not just the blank tape hard-wired intoliftCfg. SinceLift.lean's step commutation is specialized to blank extras (and its internals are private), we redo the small step lemma here against the generalized embeddingliftCfgWith.The clock machines, both
TM 7, acting on work tape 6 (clkT), which holds a unary counter (1s on cells1..v, head parked at 1 — i.e.HoldsExact (List.replicate v Γw.one)with head 1):decClockTM— scan right to the last mark, blank it, rewind to cell 1; a zero counter is left unchanged. Spec:decClockTM_hoareTime(ghost style:2*v + 6steps, every other tape exactly unchanged).zeroTestTM— read clock cell 1 and write the verdict to the real output cell 1 (1iff the counter is zero), leaving the output head at cell 1 and every work tape exactly unchanged. Spec:zeroTestTM_hoareTime(4 steps).
Cross-arity generalization of reachesIn_map: the simulating
machine may have a different number of work tapes. If wrap commutes
with step, then reachesIn lifts through the embedding.
Embed a configuration of tm : TM n into one of tm.liftTM m with the
extra work tapes pinned to the fixed tapes extras. Generalizes
liftCfg, which is the special case
extras = fun _ => (Tape.init []).move Dir3.right.
Equations
- One or more equations did not get rendered due to their size.
Instances For
liftCfgWith leaves the state unchanged.
liftCfgWith leaves the input tape unchanged.
liftCfgWith leaves the output tape unchanged.
Frame rule for liftTM Hoare specs (ghost-pinned extras). If
tm : TM n satisfies {pre} tm {post} [≤ b], then tm.liftTM m
satisfies the same triple on its first n work tapes while the m
extra tapes — holding arbitrary parked content extras (head ≥ 1,
reading a non-▷ symbol) — are preserved exactly, with the same
time bound. This is what lets lifted 6-tape UTM phases run while tape
6 holds the clock.
liftTM preserves Hoare specs (blank extras). Special case of
liftTM_hoareTime_frame: the extra tapes start and end as the
canonical parked blank tape (Tape.init []).move Dir3.right.
The clock tape: work tape 6 of the 7-tape layout (6 UTM body tapes plus the clock).
Equations
Instances For
Control states of decClockTM.
- scan : ClockPhase
- erase : ClockPhase
- back : ClockPhase
- park : ClockPhase
- done : ClockPhase
Instances For
Equations
- One or more equations did not get rendered due to their size.
Decrement the clock: scan right over the marks on tape clkT,
erase the last one, rewind to cell 1. From v marks to v - 1 marks
in at most 2v + 6 steps; every other tape idles throughout (and is
exactly preserved while parked). The zero clock is left unchanged.
Equations
- One or more equations did not get rendered due to their size.
Instances For
decClockTM specification (ghost-initial-tapes style). Starting
from qstart with the clock tape (clkT = work tape 6) holding v
unary marks with its head at cell 1, and every other tape parked on a
non-▷ symbol, decClockTM halts within 2v + 6 steps having
decremented the clock to v - 1 marks (head back at cell 1); the
input tape, the output tape, and every other work tape are preserved
exactly. The zero clock is left unchanged (0 - 1 = 0).
Clock zero test: read clock cell 1 (head parked at 1) and write
the verdict to the real output cell 1 — 1 if it is blank (the
counter is zero), else 0 — leaving the output head at cell 1;
then halt. Every work tape and the input tape idle.
Equations
- One or more equations did not get rendered due to their size.
Instances For
zeroTestTM specification (ghost-initial-tapes style). Starting
from qstart with the clock tape (clkT = work tape 6) holding v
unary marks with its head at cell 1, the output head resting at cell 1
on a non-▷ symbol, and every other tape parked on a non-▷ symbol,
zeroTestTM halts within 4 steps having
- written the verdict at output cell 1:
Γ.oneiffv = 0, elseΓ.zero(all other output cells unchanged, head back at cell 1); - left the input tape and every work tape exactly unchanged.