Simulating multi-tape machines on numbers #
The universal machine simulates a multi-tape Turing machine over the states and symbols ℕ from a
description (Turing.MultiTapeTM.Universal.Desc): the number of work tapes, the initial state and
a transition table. A transition maps a key (Turing.MultiTapeTM.Universal.Key) — the state and
the symbols under the heads, as the arguments of Turing.MultiTapeTM.tr — to an action
(Turing.MultiTapeTM.Universal.Act), which mirrors Turing.Action with the work tapes in a list.
A missing transition halts the machine.
The configurations (Turing.MultiTapeTM.Universal.SCfg) mirror Turing.Cfg without the output:
a step returns the symbol it emits, if any, and it is up to the caller to collect, use or discard
it. A work tape (Turing.MultiTapeTM.Universal.Tape) is a zipper: the position of its head, the
cells left of the head, nearest first, and the cells from the head on. It holds no more cells than
the head has visited, so a configuration takes space linear in the space of the simulated machine.
The input head is a number, encoded in binary by the universal machine.
Main definitions #
Turing.MultiTapeTM.Universal.Desc: descriptions of machines.Turing.MultiTapeTM.Universal.SCfg: configurations of the simulation.Turing.MultiTapeTM.Universal.step: one step of the simulation, and the symbol it emits.Turing.MultiTapeTM.Universal.simulate: the output after a number of steps, and whether the machine has halted.
Instances For
An action, as Turing.Action with the work tapes in a list.
- inputTape : SignType
The move of the input head.
What to write on each work tape, if anything, and how to move its head.
The symbol to emit, if any.
The next state, or
noneto halt.
Instances For
A configuration of the simulation, as Turing.Cfg with the work tapes in a list and without
the output.
The state, or
noneonce halted.- inputPos : ℕ
The position of the input head.
The work tapes.
Instances For
The symbol under the head.
Instances For
Moves the head by m.
Instances For
The effect of an action on a configuration on the input x, as Turing.Action.apply, without
the output.
Instances For
The initial configuration: the initial state, the input head on the first symbol and blank work tapes.