Universal Turing Machine

Universal Turing Machines (UTM) were first described by Alan Turing in 1936. One definition, taken from the Wikipedia, states:

“... a Turing machine consists of:

  • A tape which is divided into cells, one next to the other. Each cell contains a symbol from some finite alphabet. The alphabet contains a special blank symbol (here written as '0') and one or more other symbols. The tape is assumed to be arbitrarily extendible to the left and to the right, i.e., the Turing machine is always supplied with as much tape as it needs for its computation. Cells that have not been written to before are assumed to be filled with the blank symbol.
  • A head that can read and write symbols on the tape and move left and right one (and only one) step at a time.
  • A state register that stores the state of the Turing machine. The number of different states is always finite and there is one special start state with which the state register is initialized.
  • An action table (or transition function) that tells the machine what symbol to write, how to move the head ('L' for one step left, and 'R' for one step right) and what its new state will be, given the symbol it has just read on the tape and the state it is currently in. If there is no entry in the table for the current combination of symbol and state then the machine will halt.“

The UTM implemented in the example can also be found on that wikipedia page and is reprinted here:

“The following Turing machine has an alphabet {‘0‘, ‘1‘}, with 0 being the blank symbol. It expects a series of 1s on the tape, with the head initially on the leftmost 1, and doubles the 1s with a 0 in between, i.e., “111“ becomes “1110111“. The set of states is {s1, s2, s3, s4, s5} and the start state is s1. The action table is as follows.

Old Read Write New
State Symbol Symbol Move State
s11->0Rs2
s21->1Rs2
s20->0Rs3
s30->1Ls4
s31->1Rs3
s41->1Ls4
s40->0Ls5
s51->1Ls5
s50->1Rs1

A computation of this Turing machine might for example be: (the position of the head is indicated by displaying the cell in bold face)

Step State Tape
1s111
2s201
3s2010
4s30100
5s40101
6s50101
7s50101
8s11101
9s21001
10s31001
11s310010
12s410011
13s410011
14s510011
15s111011
--halt--