How a Turing machine becomes a tag system
How a Turing machine becomes a tag system
Wolfram Institute • 2026
A 2-tag system reads the first symbol of its word, deletes two symbols and appends a production. Cocke and Minsky write a Turing machine configuration as such a word, with the two halves of the tape spelled in unary, and turn every machine step into three or five rounds of tag steps.
Tag systems
Tag systems
A 2-tag system has a word and a production for each symbol. A step reads the first symbol, deletes the first two symbols and appends the production of the one it read; the system halts when fewer than two symbols are left.
A tag system over the symbols , , with the productions , , , started on the word :
0
1
2
0->12
1->0
2->000
100
In[1]:=
tag3=TagSystem[{{1,2},{0},{0,0,0}},{1,0,0}]
Out[1]=
TagSystem
Its run, each word drawn at its place in the queue: two symbols leave on the left, the production arrives on the right:
In[2]:=
TagSystemEvolutionPlot[tag3,10]
Out[2]=
0 | 1 | 0 | 0 | ||||
1 | 0 | 0 | |||||
2 | 1 | 2 | |||||
3 | 0 |
The machine
The machine
A binary Turing machine with states 1 and 2 (state 0 halts). Each rule reads the state and the bit under the head, writes a bit, moves right () or left () and changes state:
1
-1
In[3]:=
machine={{1,0}->{2,1,1},{1,1}->{1,0,-1},{2,0}->{1,1,-1},{2,1}->{2,1,1}}
Out[3]=
{{1,0}{2,1,1},{1,1}{1,0,-1},{2,0}{1,1,-1},{2,1}{2,1,1}}
Its rule icons, as for any : the state and the cell read above, the cell written and the move below:
In[4]:=
RulePlot[TuringMachine[machine]]
Out[4]=
The configuration: state 1, nothing on the left, the head on a 0, and to its right:
11
In[5]:=
config={1,{},0,{1,1}}
Out[5]=
{1,{},0,{1,1}}
Its first four steps; the head cell is colored by the state:
In[6]:=
TuringMachineEvolutionPlot[machine,config,4,ImageSize->220]
Out[6]=
0 | 0 | 1 | 1 | 0 |
1 | 1 | 1 | 1 | 0 |
2 | 1 | 1 | 1 | 0 |
3 | 1 | 1 | 1 | 0 |
4 | 1 | 1 | 1 | 1 |
A configuration as a word
A configuration as a word
The tag system does not keep a tape. It keeps two numbers: , the left half of the tape read as a binary number with the nearest cell least significant, and , the head cell plus twice the right half read the same way. For the configuration above:
m
N
In[7]:=
{FromDigits[Reverse[config[[2]]],2],config[[3]]+2FromDigits[Reverse[config[[4]]],2]}
Out[7]=
{0,6}
The word of a configuration in state is , then pairs , then , then pairs , every symbol carrying the state as a subscript; the numbers are written in unary. The tag system of the machine, with the tag times of its first four steps, drawn as the productions of the symbols its word reaches and the word itself:
q
Ax
m
alx
Bx
N
bex
q
In[8]:=
tag=TuringMachineToTagSystem[machine,config,4]
Out[8]=
TagSystem
The word, symbol by symbol ( is the pad, subscripts are states):
x
In[9]:=
tag["SymbolNames"][[tag["Word"]+1]]
Out[9]=
{A₁,x,B₁,x,be₁,x,be₁,x,be₁,x,be₁,x,be₁,x,be₁,x}
There is a symbol for each of 21 kinds, each state below and up to two bits, and the pad, in all:
s
1+84s
In[10]:=
Length[tag["Productions"]]
Out[10]=
253
One machine step, round by round
One machine step, round by round
The first machine step writes 1, moves right and goes to state 2. The tag system carries it out in 18 steps, in three rounds; every symbol is labeled with its name:
In[11]:=
TagSystemEvolutionPlot[tag,18]
Out[11]=
0 | A₁ | x | B₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | ||||||||||||||||||||||||||||||||
1 | B₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | P1₁ | P0₁ | ||||||||||||||||||||||||||||||||
2 | be₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | P1₁ | P0₁ | Q₁ | |||||||||||||||||||||||||||||||||
3 | be₁ | x | be₁ | x | be₁ | x | be₁ | x | be₁ | x | P1₁ | P0₁ | Q₁ | r₁ | ||||||||||||||||||||||||||||||||||
4 | be₁ | x | be₁ | x | be₁ | x | be₁ | x | P1₁ | P0₁ | Q₁ | r₁ | r₁ | |||||||||||||||||||||||||||||||||||
5 | be₁ | x | be₁ | x | be₁ | x | P1₁ | P0₁ | Q₁ | r₁ | r₁ | r₁ | ||||||||||||||||||||||||||||||||||||
6 | be₁ | x | be₁ | x | P1₁ | P0₁ | Q₁ | r₁ | r₁ | r₁ | r₁ | |||||||||||||||||||||||||||||||||||||
7 | be₁ | x | P1₁ | P0₁ | Q₁ | r₁ | r₁ | r₁ | r₁ | r₁ | ||||||||||||||||||||||||||||||||||||||
8 | P1₁ | P0₁ | Q₁ | r₁ | r₁ | r₁ | r₁ | r₁ | r₁ | |||||||||||||||||||||||||||||||||||||||
9 | Q₁ | r₁ | r₁ | r₁ | r₁ | r₁ | r₁ | E₁¹ | E₁⁰ | |||||||||||||||||||||||||||||||||||||||
10 | r₁ | r₁ | r₁ | r₁ | r₁ | E₁¹ | E₁⁰ | F₁¹ | F₁⁰ | |||||||||||||||||||||||||||||||||||||||
11 | r₁ | r₁ | r₁ | E₁¹ | E₁⁰ | F₁¹ | F₁⁰ | f₁¹ | f₁⁰ | |||||||||||||||||||||||||||||||||||||||
12 | r₁ | E₁¹ | E₁⁰ | F₁¹ | F₁⁰ | f₁¹ | f₁⁰ | f₁¹ | f₁⁰ | |||||||||||||||||||||||||||||||||||||||
13 | E₁⁰ | F₁¹ | F₁⁰ | f₁¹ | f₁⁰ | f₁¹ | f₁⁰ | f₁¹ | f₁⁰ | |||||||||||||||||||||||||||||||||||||||
14 | F₁⁰ | f₁¹ | f₁⁰ | f₁¹ | f₁⁰ | f₁¹ | f₁⁰ | x | A₂ | x | al₂ | x | ||||||||||||||||||||||||||||||||||||
15 | f₁⁰ | f₁¹ | f₁⁰ | f₁¹ | f₁⁰ | x | A₂ | x | al₂ | x | B₂ | x | ||||||||||||||||||||||||||||||||||||
16 | f₁⁰ | f₁¹ | f₁⁰ | x | A₂ | x | al₂ | x | B₂ | x | be₂ | x | ||||||||||||||||||||||||||||||||||||
17 | f₁⁰ | x | A₂ | x | al₂ | x | B₂ | x | be₂ | x | be₂ | x | ||||||||||||||||||||||||||||||||||||
18 | A₂ | x | al₂ | x | B₂ | x | be₂ | x | be₂ | x | be₂ | x |
In the first round (steps 0 to 8) every pair of the word is read once: becomes , each becomes one , and becomes . The unary count is copied, but at half the spacing. In the second round (steps 8 to 13) the symbols are read in pairs, so the round sees modulo 2, the bit under the head, and halves ; the bit is recorded in the superscript of the and symbols. In the third round (steps 13 to 18) the productions of those symbols apply the machine's rule for state 1 reading 0: they write the new state 2, the new left number (the written bit pushed onto the left half) and the new right number, halved and rounded down.
A₁x
P1₁P0₁
be₁x
r₁
B₁x
Q₁
r
N
N
E
F
2m+1
N
At step 18 the word is the word of the next configuration:
In[12]:=
TagSystemToTuringMachine[TagSystemEvolution[tag,18][[-1]],3]
Out[12]=
{2,{1},1,{1}}
The whole run of four machine steps; the tag times are where the words of the configurations appear:
In[13]:=
TagSystemEvolutionPlot[tag,85,"Labels"->False]
Out[13]=
In[14]:=
tag["TagTimes"]
Out[14]=
{0,18,32,48,85}