RealityModels

A census of Turing machines

Interactive census of all the small Turing machines: every machine starts on a blank tape, and the outputs of the ones that halt are counted. The frequencies approximate algorithmic probability, the universal distribution of Solomonoff and Levin. It has no dependencies and works offline.

Open it by double-clicking simulations/foundations/turing-census/index.html (or from any static server); nothing to install. Theory and references: algorithmic-probability-theory.en.md; Italian version: algorithmic-probability-simulation-guide.it.md.

Idea

Take every Turing machine with n states and 2 symbols, run each one on a tape of zeros, and record the string of cells it visited when it halts. No string is privileged at the start: every machine is counted exactly once. Yet the result is strongly ordered. Short strings come out of far more machines than long ones, and at equal length the regular strings beat the irregular ones. The share of machines that produce a string x approximates its algorithmic probability m(x), and βˆ’logβ‚‚(share) approximates its Kolmogorov complexity in bits. The simulation shows this hierarchy being built live, by counting alone.

The machines

States nMachinesModeStep cap S(n)
220,736full enumeration6
316,777,216full enumeration21
425,600,000,000seeded random sample107

The census runs in small slices, so the page stays responsive: 2 states finish instantly, 3 states take a few seconds, and with 4 states the sample size sets the duration. The Run button pauses and resumes it.

Parameters and query string

ParameterQueryRangeDefault
States nn2–42
Random seed (4 states only)seed0–999991
Sampled machines (4 states only)samples100000–100000001000000
Scalescalelin, loglin
Languagelangit, enbrowser

Example: index.html?n=3&scale=log.

Language and theme (System, Light, Dark) are set with the gear button at the top right. They are saved in the browser and apply to the other simulations too.

Readings

Graph legend

Reference results

Numbers from js/model.js, the same code the page runs.

2 states, full census

20,736 machines, 9,784 halting (47.18%), 17 distinct strings, longest run 6 = S(2). The complete census:

OutputMachinesShare
03,45635.32%
13,45635.32%
007287.44%
017047.20%
107047.20%
116806.95%
011, 110, 1118 each0.08% each
001, 010, 100, 1014 each0.04% each
1001, 1011, 1101, 11114 each0.04% each

Notable: 000 never occurs, and every length-4 output starts and ends with 1. Six steps are too few to scan four cells and leave the far ends blank.

3 states, full census

16,777,216 machines, 7,571,840 halting (45.13%), 95 distinct strings, longest run 21 = S(3). Top of the ranking:

OutputMachinesShare
02,097,15227.70%
12,097,15227.70%
00722,7529.55%
01704,9129.31%
10704,9129.31%
11687,0729.07%
11166,8400.88%
00064,2000.85%
01163,9200.84%
11063,9200.84%
00162,3920.82%
10062,3920.82%
01058,9920.78%
10158,5760.77%

Share by output length:

LengthMachinesShare
14,194,30455.39%
22,819,64837.24%
3501,2326.62%
450,0640.66%
56,2240.08%
63360.004%
7320.0004%

Beyond two cells, each extra cell costs about an order of magnitude. Mirror pairs match exactly (01 = 10, 011 = 110, 001 = 100), while the 0↔1 complement does not (010 β‰  101, 000 < 111): the blank tape is made of zeros and breaks that symmetry. The theory document explains both facts.

4 states, sample

Seed 1, 200,000 machines: 87,161 halting (43.58%), 88 distinct strings, longest run 24. Top of the ranking:

OutputMachinesShare
119,95622.90%
019,86122.79%
018,82110.12%
008,75510.04%
108,6469.92%
118,4229.66%
0001,4111.62%
1111,4091.62%

In a sample the exact ties survive only up to noise: 0 and 1 differ by sampling error, not by structure. The page defaults to 1,000,000 samples; this table uses 200,000 so that it matches the third verification command below.

Simplifications

Structure

simulations/foundations/turing-census/
β”œβ”€β”€ index.html      page and control panel
β”œβ”€β”€ css/style.css   theme tokens (light, dark, system) and responsive layout
β”œβ”€β”€ js/i18n.js      it/en dictionaries and translation functions
β”œβ”€β”€ js/model.js     census engine: enumeration, sampling, tallies (also usable from Node)
β”œβ”€β”€ js/graph.js     Canvas renderer: ranked bars, length strip, tooltip
└── js/app.js       controls, query string, animation

The settings button (language and theme) is shared by all simulations and lives in simulations/shared/ (js/settings.js, css/settings.css).

Verification

cd simulations/foundations/turing-census && node -e 'const M=require("./js/model.js"); const I=require("./js/i18n.js").I18n; const c=M.create({states:2}); M.run(c,c.total); const s=M.summary(c); console.log(c.halting, s.entries.length, c.maxUsed, I.check().length)'

Expected: 9784 17 6 0 (9,784 halting machines out of 20,736, 17 distinct strings, longest run 6 = S(2), no missing dictionary keys).

cd simulations/foundations/turing-census && node -e 'const M=require("./js/model.js"); const c=M.create({states:3}); M.run(c,c.total); const s=M.summary(c); console.log(c.halting, s.entries.length, c.maxUsed)'

Expected: 7571840 95 21 (takes a few seconds; longest run 21 = S(3)).

cd simulations/foundations/turing-census && node -e 'const M=require("./js/model.js"); const c=M.create({states:4,seed:1,samples:200000}); M.run(c,c.target); const s=M.summary(c); console.log(c.halting, s.entries.length, c.maxUsed)'

Expected: 87161 88 24 (the sample is seeded, so the numbers reproduce exactly).