The five rules of System 4
The five rules of System 4
Wolfram Institute • 2026
System 4 is a tape of sets of integers and stars with a head in state A, B or C. In A the head walks left; at the left end it turns and sweeps right in B and C, decrementing every set it passes; stars are deleted as it goes, and a 0 in a set switches between B and C.
The rules
The rules
The head sits on one element of the tape.
◼
In state A on a set the head moves left; at the left end it turns into state B instead.
◼
In state A on a star the star is deleted and the state becomes B.
◼
In state B or C on a set, every integer of the set is decremented and the head moves right; if the set contained 0, the 0 is removed and the state switches between B and C.
◼
In state B on a star the star is deleted and the head moves left into state A.
◼
In state C on a star the head moves onto the set to its right and toggles 1 in it (adds it if absent, removes it if present).
A tiny tape
A tiny tape
The tape , the head on the first set in state A:
{0,2}*{}
In[1]:=
tape=System4[{{0,2},"*",{}}]
Out[1]=
System4
Its run, every element labeled with its contents; the active element is red in state A, blue in B and orange in C:
In[2]:=
System4EvolutionPlot[tape,10]
Out[2]=
0 | {0,2} | ★ | {} |
1 | {0,2} | ★ | {} |
2 | {1} | ★ | {} |
3 | {1} | ★ | {1} |
4 | {1} | ★ | {0} |
At the left end the head turns into B. It decrements : the 0 is removed, which switches the state to C, and the set becomes . In state C the star is not deleted: the head steps onto the empty set and toggles 1 into it. The head then decrements to and runs off the right end in state C, where System 4 halts.
{0,2}
{1}
{1}
{0}
A longer tape
A longer tape
The System 4 tape of a small System 5 program (see the companion notebook on the encoder):
In[3]:=
tape2=System5ToSystem4[System5[{1,3},{{1},{}}],1]
Out[3]=
System4
The first 25 steps, labeled. The head turns at the left end, sweeps right in state C past the stars, switches back to B at a set holding 0, deletes the next star and walks back left:
In[4]:=
System4EvolutionPlot[tape2,25]
Out[4]=
0 | {4,0} | ★ | {} | ★ | {6,0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
1 | {4,0} | ★ | {} | ★ | {6,0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
2 | {3} | ★ | {} | ★ | {6,0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
3 | {3} | ★ | {1} | ★ | {6,0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
4 | {3} | ★ | {0} | ★ | {6,0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
5 | {3} | ★ | {0} | ★ | {6,0,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
6 | {3} | ★ | {0} | ★ | {5,1,2} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
7 | {3} | ★ | {0} | ★ | {5,1,2} | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |
8 | {3} | ★ | {0} | ★ | {5,1,2} | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |
9 | {3} | ★ | {0} | {5,1,2} | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||
10 | {3} | ★ | {0} | {4,0,1} | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||
11 | {3} | ★ | {0} | {4,0,1} | {} | ★ | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||
12 | {3} | ★ | {0} | {4,0,1} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||
13 | {3} | ★ | {0} | {4,0,1} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||
14 | {3} | ★ | {0} | {4,0,1} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||
15 | {3} | ★ | {0} | {4,0,1} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||
16 | {3} | {0} | {4,0,1} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||||
17 | {3} | {} | {4,0,1} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||||
18 | {3} | {} | {3,0} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||||
19 | {3} | {} | {3,0} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||||
20 | {3} | {} | {3,0} | {} | {} | ★ | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | ||||
21 | {3} | {} | {3,0} | {} | {} | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||||
22 | {3} | {} | {3,0} | {} | {} | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||||
23 | {3} | {} | {3,0} | {} | {} | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||||
24 | {3} | {} | {3,0} | {} | {} | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} | |||||
25 | {3} | {} | {3,0} | {} | {} | {0,1,2,3} | ★ | {0,1,2,3} | ★ | {} | ★ | {} | ★ | {0,1,2,3} |
The whole run of 100 steps: the head (colored) zigzags while the stars are used up, nine at the start and none at the end:
In[5]:=
System4EvolutionPlot[tape2,200,ImageSize->420]
Out[5]=