The tidy normal form #
Every computation can be made tidy (Turing.MultiTapeTM.ComputesTidilyInTimeAndSpace) at a
linear cost in time and space: tidy m₀ m₁ tm runs tm with every work tape shadowed
(Turing.MultiTapeTM.shadow), then clears each work tape along its shadow
(Turing.MultiTapeTM.clearShadowed), and finally rewinds the input head
(Turing.MultiTapeTM.rewindInput); the symbols m₀ ≠ m₁ mark the shadows. A computation of tm
within t steps and s cells becomes a tidy computation of tidy m₀ m₁ tm within
2 t + 3 s + 2 k + 4 steps (ComputesInTimeAndSpace.computesTidily_tidy). So tidiness, which
makes machines composable, is no restriction on what is computable within given resources up to
constant factors (ComputableInTimeAndSpace.exists_computableTidilyInTimeAndSpace).
The shadow tapes are needed because a work tape may hold blanks among the cells tm has written:
sweeping until the first blank would not find them all.
Main definitions #
Turing.MultiTapeTM.clearList: clear a list of work tapes along their shadows.Turing.MultiTapeTM.tidy: the tidy normal form of a machine.
Main results #
Turing.MultiTapeTM.exists_runPath_tidy: the run path oftidy m₀ m₁ tmwhentmhalts.Turing.MultiTapeTM.ComputesInTimeAndSpace.computesTidily_tidy:tidy m₀ m₁ tmcomputes tidily whattmcomputes.Turing.MultiTapeTM.ComputableInTimeAndSpace.exists_computableTidilyInTimeAndSpace: computable functions are tidily computable.
Clearing a work tape and its shadow #
Work tape i of C and its shadow k + i are ready to be cleared: the heads of both are on
cell c - a, the shadow marks cells V that together with c - a form the interval [-a, b],
and the work tape is blank outside it.
The head of the work tape is on cell
c - a.The head of the shadow is on cell
c - a.The marked cells and the cell under the heads form the interval
[-a, b].The shadow marks the cells
V.- blank (y : ℤ) : y ∉ Finset.Icc (-↑a) ↑b → C.workTapes (Fin.castAdd k i) y = none
The work tape is blank outside
[-a, b].
Instances For
Clearing tapes l preserves PairReady on any tape i ∉ l.
Clearing one work tape and its shadow inside a machine with k + k work tapes.
The control states of clearList for a list of length n.
Instances For
Clear the work tapes in l along their shadows, one after the other.
Instances For
Clearing a list of work tapes with their shadows, each ready to be cleared: a run path of
clearList m₀ m₁ l to the configuration with these tapes cleared.
The tidy normal form #
The tidy normal form of tm: run tm with shadowed work tapes, clear every work tape along
its shadow, and rewind the input head. The symbols m₀ and m₁ mark the shadows.
Instances For
The run of the tidy normal form. If tm first halts at step u, having used S cells,
then tidy m₀ m₁ tm has a run path to the halted configuration with blank work tapes, every head on
its start cell and the output of tm, taking at most 2 u + 3 S + 2 k + 4 steps and visiting at
most 2 S + 2 k (3 S + 2 k + 3) cells.
The tidy normal form. What tm computes within t steps and s cells,
tidy m₀ m₁ tm computes tidily within 2 t + 3 s + 2 k + 4 steps and 2 s + 2 k (3 s + 2 k + 3)
cells, for any two distinct marks m₀ and m₁.
Computable functions are tidily computable, at a linear cost: a function computable within
time t and space s is computable tidily within time 2 t + 3 s + c and space c (s + 1), for a
constant c that depends on the number of work tapes of the machine.