One step of System 5

Wolfram Institute • 2026
Every step decrements the bag and increments the rules. When an element reaches 0 it is removed and the first rule is merged into the bag with parity: an integer already present is removed rather than added.
The functions come from the paclet WolframInstitute/TuringMachine.

A program

Smith's System 5 program of p. 33: a bag
{2}
and four rules:
In[1]:=
program=System5[{2},{{1,4},{1,6},{},{}}]
Out[1]=
System5


Its run, step by step

Every configuration of the run:
In[2]:=
System5Evolution[program,20]
Out[2]=
{Bag{2},Rules{{1,4},{1,6},{},{}},Bag{1},Rules{{2,5},{2,7},{},{}},Bag{6,3},Rules{{3,8},{},{}},Bag{5,2},Rules{{4,9},{},{}},Bag{4,1},Rules{{5,10},{},{}},Bag{11,6,3},Rules{{},{}},Bag{10,5,2},Rules{{},{}},Bag{9,4,1},Rules{{},{}},Bag{8,3},Rules{{}},Bag{7,2},Rules{{}},Bag{6,1},Rules{{}},Bag{5},Rules{}}
Step 1 decrements the bag to
{1}
and increments the rules to
{2,5},{2,7},{1},{1}
. At step 2 the element reaches 0: it is removed and the first rule, now
{3,6}
, becomes the bag. Two more steps count it down to
{1,4}
; at step 5 the 1 reaches 0 and the next rule, now
{6,11}
, joins what is left: the bag becomes
{3,6,11}
. The run halts when the rules are used up.

The run drawn

The bag at every step, red right after a pop. Every element drifts left by one per step; each pop brings in a new rule:
In[3]:=
System5EvolutionPlot[program,20,ImageSize->420]
Out[3]=
bag
after a pop
The length of the run:
In[4]:=
System5Evolution[program,Infinity,"Length"]
Out[4]=
11