// Independent re-count of the TNF tree sizes in arXiv:2509.12337v2, Table "TNF metrics", for n = 2, 3, 4. // Rules (sections/TNF.tex): root = no transitions; a machine that reaches an undefined transition is HALT and its // children define that transition (symbol 0/1, move L/R, state A..next-unseen); at the root only right moves; // a machine that never halts is a NONHALT leaf; machines with every transition defined are not enumerated. // Halting is decided by running S(n) steps: a partial machine that survives S(n) steps never reaches an undefined // transition, else completing it with a halt would beat S(n). This uses the known S(n), so it checks the counts, // not S(n) itself. const S = { 2: 6, 3: 21, 4: 107 }; function count(n) { const T = new Int16Array(2 * n).fill(-1); // encoded transition: w*1000 + (d>0?1:0)*100 + state, -1 = undefined let halt = 0, nonhalt = 0, maxSteps = 0, defined = 0; function visit() { // run on blank tape const tape = new Map(); let pos = 0, q = 0, steps = 0, hit = -1; while (steps <= S[n]) { const a = tape.get(pos) || 0, t = T[2 * q + a]; steps++; if (t < 0) { hit = 2 * q + a; break; } tape.set(pos, (t / 1000) | 0); pos += ((t / 100) | 0) % 10 ? 1 : -1; q = t % 100; } if (hit < 0) { nonhalt++; return; } halt++; if (steps > maxSteps) maxSteps = steps; if (defined === 2 * n - 1) return; // children would be fully defined: not enumerated let seen = 0; for (let i = 0; i < 2 * n; i++) if (T[i] >= 0) seen = Math.max(seen, T[i] % 100); const maxState = Math.min(n - 1, seen + 1); const dirs = defined === 0 ? [1] : [0, 1]; for (const w of [0, 1]) for (const d of dirs) for (let s = 0; s <= maxState; s++) { T[hit] = w * 1000 + d * 100 + s; defined++; visit(); T[hit] = -1; defined--; } } visit(); return { n, nonhalt, halt, total: halt + nonhalt, maxSteps }; } const expect = { 2: [42, 19, 61], 3: [3645, 1772, 5417], 4: [609216, 249693, 858909] }; let ok = true; for (const n of [2, 3, 4]) { const r = count(n), e = expect[n]; const pass = r.nonhalt === e[0] && r.halt === e[1] && r.total === e[2] && r.maxSteps === S[n]; ok = ok && pass; console.log((pass ? "PASS " : "FAIL ") + JSON.stringify(r) + " paper: nonhalt=" + e[0] + " halt=" + e[1] + " total=" + e[2]); } console.log(ok ? "ALL PASS" : "SOME FAIL");