Deterministic Multi-Tape Turing Machines #
A deterministic Turing machine is a nondeterministic machine whose transition relation has exactly
one action for every combination of state and symbols read. From the transition relation it derives
a transition function tr and a function step which maps each configuration to its unique
successor configuration (a halted configuration maps to itself).
The design choices for configurations and actions are documented in
Cslib.Computability.Machines.Turing.MultiTape.Configuration.
Important Declarations #
We define a number of structures and concepts related to multi-tape Turing machine computation:
MultiTapeNTM.IsDeterministic: the transition relation relates every state and tuple of read symbols to exactly one actionMultiTapeTM: the TM itselftr,ofTr: the derived transition function and construction from a functionstep,runFrom: the successor configuration and iteration of this functionMultiTapeNTM.RunPath.ofDeterministic,MultiTapeNTM.ComputationPath.ofDeterministic: paths of a given length from an arbitrary or initial configurationHaltsAt: the run from a configuration halts at exactly a given stepspaceUsed: the number of tape cells visited by work tape heads, our main space measureComputes: the machine halts with the given output on an inputComputesInTimeAndSpace: the machine produces an output within the shared resource boundsComputesFunInTimeAndSpace: function computation with the shared time and space boundsComputableInTimeAndSpace: such a machine exists with binary alphabet and finitely many states.ComputableInTimeAndSpaceOfLength: the specialization to bounds on encoded input length.DecidableInTimeAndSpace: a proof that a TM decides a language within a certain time and space bound.
Every state and tuple of read symbols is related to exactly one action by ntm's transition
relation.
Equations
- ntm.IsDeterministic = ∀ (q : State) (input : Option Symbol) (work : Fin k → Option Symbol), ∃! action : Turing.Action k Symbol State, ntm.Tr q input work action
Instances For
A multi-tape Turing machine with k work tapes over the alphabet of Option Symbol (where none
is the blank tape 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
- deterministic : self.IsDeterministic
Every state and tuple of read symbols is related to exactly one action by the transition relation.
Instances For
Equations
The unique action related to the given state and read symbols by Tr.
Equations
- tm.tr q input work = Exists.choose ⋯
Instances For
Tr relates a state and read symbols to an action exactly when tr returns that action.
Construct a deterministic machine from an initial state and transition function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Extracting the transition of ofTr recovers the supplied function.
Stepping a Turing Machine #
The step function lets the machine transition from one configuration to the next, and runFrom
gives the configuration reached after a number of steps. Configurations themselves are defined in
Cslib.Computability.Machines.Turing.MultiTape.Configuration.
The unique successor configuration related to cfg by the inherited step relation.
Equations
Instances For
A running configuration takes the action selected by the transition function.
The input head after a live step.
A work tape after a live step.
A work tape head after a live step.
The path of the first t steps from cfg.
Equations
- Turing.MultiTapeNTM.RunPath.ofDeterministic tm cfg t = { length := t, toFun := fun (n : Fin (t + 1)) => Turing.MultiTapeTM.step^[↑n] cfg, step := ⋯ }
Instances For
Every deterministic run path is the canonical path from its head for its duration.
The path of the first t steps on input, starting at the initial configuration.
Equations
- Turing.MultiTapeNTM.ComputationPath.ofDeterministic tm input t = { toRunPath := Turing.MultiTapeNTM.RunPath.ofDeterministic tm (tm.initCfg input) t, head_eq := ⋯ }
Instances For
Every deterministic computation path is the canonical path for its duration.
The configuration reached by running the Turing machine for t steps from cfg.
If the Turing machine halts, it will stay at the halting configuration.
Equations
Instances For
Every path of a deterministic machine follows its iterated step function.
A deterministic computation ends at the corresponding iterate.
A deterministic machine halted after t steps satisfies the shared time bound.
The machine tm started in cfg halts at step t: it is halted after t steps and not
halted after any smaller number of steps.
Equations
- tm.HaltsAt cfg t = ((Turing.MultiTapeTM.runFrom cfg t).Halted ∧ ∀ s < t, ¬(Turing.MultiTapeTM.runFrom cfg s).Halted)
Instances For
The halting step is the first step at which the machine is halted.
From the halting step on, the configuration does not change.
A run that is halted after t steps halts at some step u ≤ t.
A run that is halted after some number of steps halts at exactly one step.
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 set of positions visited by the head of work tape i in the computation starting from
configuration cfg up to step t.
Equations
- Turing.MultiTapeTM.visitedByTapeHead cfg t i = Finset.image (fun (n : Fin (t + 1)) => (Turing.MultiTapeTM.runFrom cfg ↑n).workTapePos i) Finset.univ
Instances For
The number of work tape cells visited by the head of tape i in the computation starting from
configuration cfg up to step t.
Equations
- Turing.MultiTapeTM.spaceUsedByTape cfg t i = (Turing.MultiTapeTM.visitedByTapeHead cfg t i).card
Instances For
The number of work tape cells visited 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
Each tape's space usage is bounded by the total space used.
In t steps the input head moves at most t positions to the right.
The machine eventually halts on input with the given output.
Equations
Instances For
The machine computes output from input within the shared time and space bounds.
Equations
- tm.ComputesInTimeAndSpace input output t s = (tm.Computes input output ∧ tm.RunsInTime input t ∧ tm.RunsInSpace input s)
Instances For
The machine computes f relative to given encodings within the given time and space bounds.
Equations
- tm.ComputesFunInTimeAndSpace encIn encOut f t s = ∀ (a : α), tm.ComputesInTimeAndSpace (encIn a) (encOut (f a)) (t a) (s a)
Instances For
Resource bounds can be weakened independently on every input.
Computability by a deterministic machine with a binary tape alphabet and finitely many states, within the supplied input-indexed bounds.
Equations
- One or more equations did not get rendered due to their size.
Instances For
There exists a binary Turing machine with finitely many states that, for every input a,
computes encOut (f a) from encIn a in at most t (encIn a).length steps,
using at most s (encIn a).length work-tape cells.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computability is monotone in the resource bounds.
A set is decidable within the given input-indexed bounds when its Boolean indicator is computable in those bounds.
Equations
- One or more equations did not get rendered due to their size.
Instances For
If a deterministic machine repeats a non-halting configuration, it never halts,
because the sequence between the two configurations will loop forever.
Note that this can be applied to two arbitrary and different time steps t and t + Δ
using Function.iterate_add_apply.