Deterministic Multi-Tape Turing Machines #
Defines deterministic Turing machines with a read-only input tape, k work tapes and one write-only
output tape.
The tapes contain symbols from Option Symbol for a finite alphabet Symbol (where none is the
blank symbol).
Design #
The multi-tape Turing machine uses a read-only input tape, k work tapes and a write-only output
tape.
The input head can move freely on the input, but any move attempt beyond one cell outside the input
results in no movement.
The transition function can optionally output one symbol, which models the write-only output tape.
Because of these restrictions, we ignore the input and output tapes for space usage of the machine.
The space usage is defined as the total number of cells the work tape heads visited during
execution.
Restricting the movement of the input head is not essential, but useful because it allows us to easily bound the number of possible configurations of a space-bounded machine. Most textbooks have this restriction.
Instead of considering the cells visited by the work tape heads, some textbooks
(including [AB09]) only consider the number of cells that contain
a non-blank symbol at some point in the execution or the number of cells written to. This allows
work tape heads to freely move at no cost as long as they do not write. It is
important to note that this causes DSPACE(1) to include DSPACE(log log n), a class that
contains e.g. the non-regular language {0^n 1^n | n ∈ ℕ} (it is accepted by a TM that writes a
single marker on the work tape and then counts the number of symbols by work tape head movement
without writing).
Defining space usage via "cells visited" thus yields the more fine-grained "complexity world" in
which DSPACE(1) is exactly the class of regular languages.
This definition is adapted from the one in [Pap94], chapter 2.3 including the sub-linear space modifications from chapter 2.5 with the following changes:
- We allow Turing machines to choose to not write on a tape. This is equivalent to writing the read symbol again but makes it easier to reason about the semantics.
- Our tapes are infinite in both directions instead of just to the right. This definition is equivalent (see [AB09], Claim 1.4). It saves us from having to add a "start marker" to the alphabet.
- We only have a single halting state. The different ways to halt (accepting, rejecting, etc) can be distinguished based on the output.
- The way to prevent the input head to move outside the input is enforced by the interpretation and not by a restriction on the transition function. The two definitions are equivalent, but not restricting the transition function makes it easier to define a universal machine.
Important Declarations #
We define a number of structures and concepts related to multi-tape Turing machine computation:
MultiTapeTM: the TM itselfCfg: the configuration of a TM: the internal state, the work tape contents and head positionsspaceUsed: the number of work tape cells touched by the heads until a certain stepTransitionRelation: the transition relation from one configuration to the nextspaceUsed: the number of tape cells touched by work tape heads, our main space measureComputesInTimeAndSpace: a proof that a specific TM computes an output from an input in a certain number of steps and using a certain number of tape cellsComputableInTimeAndSpace: a proof that there is a multi-tape TM that computes a function (on strings) respecting a time and space bound in the input length.DecidableInTimeAndSpace: a proof that a TM decides a language within a certain time and space bound.
There are two ways to talk about the behaviour of a multi-tape Turing machine, and they are proven to be equivalent.
MultiTapeTM.configs: a sequence of configurations by execution stepRelatesInSteps tm.TransitionRelation cfg cfg' t: a proof thattmtransforms the configurationcfgintocfg'in exactlytsteps
References #
A multi-tape Turing machine with k work tapes over the alphabet of Option Symbol (where none
is the blank BiTape symbol). Note that it is not required that Symbol or State are finite
to keep the definition more general. The restriction will be introduced once we start talking about
computability by Turing machines in general.
- q₀ : State
initial state
- tr (q : State) (input : Option Symbol) (work : Fin k → Option Symbol) : TransitionOut k Symbol State
transition function, mapping a state, the current input symbol and a tuple of work head symbols to a movement for the input head, actions on the work tape, optionally a symbol to output and the successor state
Instances For
Configurations of a Turing Machine #
This section defines the configurations of a Turing machine, the step function that lets the machine transition from one configuration to the next, the resulting sequence of configurations and the initial configuration.
The configurations of a Turing machine is relative to the input of the machine and consist of:
- an
Optional state (or none for the halting state), - the position of the input head (shifted by one),
- the contents of the work tape,
- the positions of the work tape heads.
- state : Option State
the state of the TM (or none for the halting state)
the position of the input head, shifted by one
the work tapes
the positions of the heads on the work tapes
Instances For
Equations
Attempt to move the input tape head. The machine can only read one empty cell outside of the input, any attempted movement beyond that results in no movement.
The addition is performed in ℤ before clamping. Performing it in Fin (n + 2) would wrap an
outward boundary move to the opposite end of the input.
Equations
Instances For
A left move away from the left input boundary decrements the native input position.
The symbol read by work tape i.
Equations
- cfg.workTapeSymbols i = cfg.workTapes i (cfg.workTapePos i)
Instances For
The step function corresponding to a MultiTapeTM.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The symbol (optionally) output when executing one step starting from configuration cfg.
Equations
- Turing.MultiTapeTM.outputSymbol cfg = match cfg.state with | none => none | some q => (tm.tr q cfg.inputSymbol cfg.workTapeSymbols).outS
Instances For
The initial configuration corresponding to an input string.
Equations
Instances For
The sequence of configurations of the Turing machine starting from cfg.
If the Turing machine halts, it will stay at the halting configuration.
Equations
Instances For
Any number of steps run from a halting configuration results in the same configuration.
The work-tape head moves by at most one cell in a single step.
Now we define space usage and add some helper lemmas.
The number of work tape cells touched by the head of tape i in the computation starting from
configuration cfg up to step t.
Equations
- Turing.MultiTapeTM.spaceUsedByTape cfg t i = (List.map (fun (t' : ℕ) => (Turing.MultiTapeTM.configs cfg t').workTapePos i) (List.range (t + 1))).toFinset.card
Instances For
The number of work tape cells touched by a computation starting from configuration
cfg up to step t.
Equations
- Turing.MultiTapeTM.spaceUsed cfg t = ∑ i : Fin k, Turing.MultiTapeTM.spaceUsedByTape cfg t i
Instances For
The number of cells touched by a single work tape grows by at most one each step.
The TransitionRelation corresponding to a MultiTapeTM k Symbol
is defined by the step function,
which maps a configuration to its next configuration.
Equations
- Turing.MultiTapeTM.TransitionRelation c₁ c₂ = (Turing.MultiTapeTM.step c₁ = c₂)
Instances For
The string output by the Turing machine tm starting in configuration cfg₀, executing for
t steps. It is the concatenation of the symbols (optionally) emitted at each of the first t
steps.
Equations
- tm.outputString cfg₀ t = List.flatMap (fun (t' : ℕ) => (Turing.MultiTapeTM.outputSymbol (Turing.MultiTapeTM.configs cfg₀ t')).toList) (List.range t)
Instances For
The output produced in t + 1 steps is the output produced in t steps followed by the symbol
(optionally) emitted at step t.
A proof that the Turing machine tm on input input outputs output in at most t steps
and uses exactly s space.
Note that this does not require the alphabet or state set to be finite.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A proof that the Turing machine tm computes the function f such that on all inputs of
length n it uses at most t n steps and s n space. It assumes an embedding function
from the input/output alphabet into the machine alphabet.
Note that this does not require the alphabet or state set to be finite.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The main definition of complexity of multi-tape Turing machines:
A proof that the function f is computable by some multi-tape Turing machine tm (with finite
work alphabet and finite state set) via an alphabet embedding function toMachineSymbol,
such that on all inputs of length n, tm uses at most t n steps and at most s n space.
Equations
- One or more equations did not get rendered due to their size.
Instances For
This lemma translates between the relational notion and the iterated step notion. The latter can be more convenient especially for deterministic machines as we have here.
The Turing machine tm halts after exactly t steps on input input
if its state is none at step t and non-none at step t - 1.
Note that every Turing machine hast to perform at least one step to halt.
Equations
- One or more equations did not get rendered due to their size.
Instances For
If a Turing machine halts, the time step is uniquely determined.