Turing Machine
A tape of cells, a head that reads and writes one cell at a time, and a table of rules. That is the whole machine, and anything that can be computed at all can be computed by one of these.
Program
One rule per line. _ is the blank symbol, moves are L, R or N (stay), ; starts a comment. The machine starts in the state of the first rule, or the one named by start: name. It halts when no rule matches. Editing resets the machine.
State diagram
Arrows are labelled read→write,move. The current state and the rule about to fire are highlighted. Double circles are halting states.
Transition table
How it works
Each step the machine does the same four things:
- Read the symbol in the cell under the head.
- Look up the rule for the pair (current state, symbol read).
- Write the rule's symbol into the cell and move the head one cell left or right.
- Switch to the rule's next state.
If there is no rule for the pair, the machine halts. The tape has no end in either direction; cells that were never written hold the blank symbol.
The machine loaded above, written out as the formal definition:
Alan Turing described this machine in 1936 to pin down what "computable" means. The first example in his paper is in the list above: it prints 0 and 1 on alternate cells and never stops. He also showed that no machine can decide, for every machine and input, whether that machine will ever halt.
The busy beaver examples show how hard that question gets. Among all machines with n states and two symbols that do halt when started on a blank tape, the busy beaver is the one that runs longest. With 2, 3 and 4 states the records are 6, 21 and 107 steps. With 5 states the record is 47,176,870 steps, and it took until 2024 to prove that no 5-state machine does better. Set the speed to max to run it to the end.