Step machines #
A step machine reads its input with a two-way head and keeps an arbitrary state. In each step, a
pure function of the state and the symbol under the head gives the next state, a move of the head
by at most one cell and a word to emit. It halts in the states where halt holds.
Step machines describe space-bounded computations without tapes: the space of a computation is the
size of its states, while the position of the head costs nothing, since a Turing machine realizing
the step machine keeps its input head at the same position. A machine whose states take at most
s bits halts on an input of length n within (n + 2) * 3 ^ s steps, if it halts at all, since
it never repeats a state and a head position before halting; in particular, a machine in
logarithmic space halts within polynomially many steps.
Main definitions #
Turing.StepMachine: step machines.Turing.StepMachine.run: the configuration after a number of steps.Turing.StepMachine.HaltsAt: the first step at which a machine has halted.Turing.StepMachine.Simulates: a step machine simulates a system, with a fixed number of its steps per step of the system.
Main results #
Turing.StepMachine.Simulates.exists_haltsAt: a simulating machine halts when the simulated system does, with the same output.Turing.StepMachine.HaltsAt.lt_three_pow: a machine whose states take at mostsbits halts within(n + 2) * 3 ^ ssteps.Turing.StepMachine.HaltsAt.lt_pow_of_log: in spacec * log₂ (n + 2), a machine halts within(n + 2) ^ (2 * c + 1)steps.
A step machine with states σ, input symbols Γ and output symbols Out: from the state q
with a under the head, it moves to (step q a).1, moves its head by (step q a).2.1 and emits
(step q a).2.2, unless halt q. The symbol under the head is none on the blanks before and
after the input, and the head does not move beyond them. Returning to the start of the input needs
no move of its own: move left until the blank before the input, then right.
- init : σ
The initial state.
- halt : σ → Bool
The halting states.
The next state, the move of the head and the emitted word.
Instances For
A configuration on input: the state, the position of the head and the output so far.
- state : σ
The state.
The position of the head, with the blanks at
0andinput.length + 1.- out : List Out
The output so far.
Instances For
The initial configuration: the initial state, the head on the first cell, no output.
Instances For
One step, unless the machine has halted.
Instances For
The configuration after t steps on input.
Instances For
The machine has halted after exactly t steps, and not before.
Instances For
The machine halts on input with the output out.
Instances For
Simulations #
m on input simulates the system next along R, with d steps of m per step of
the system: R is kept by d steps from a state that has not halted, and matches the halting
flags and the outputs.
Instances For
From R at the time t₀, after u steps of the system, m has made u * d more steps
along R.
The rounds of a simulation: within u steps of the system, every time of m is j < d
steps into a round q, which starts along R.
Simulation: from R at the time t₀, when the system halts after u steps, m halts
within u * d more steps, with the same output.
A machine never repeats a core before halting: a core shared by the steps i < j ≤ t would
give the halted state of step t already at step t - j + i < t.
A machine whose states take at most s bits halts within (n + 2) * 3 ^ s steps on an
input of length n: its runs never repeat a state and a head position before halting, and there
are fewer than 3 ^ s words of at most s bits.
Logarithmic space gives polynomial time: a machine whose states take at most
c * log₂ (n + 2) bits halts within (n + 2) ^ (2 * c + 1) steps on an input of length n.