Growth class analysis of small Turing Machines

2026-11-28

Contents:

For background on what’s happening, see this post.

# Introduction

I finished talking about the data in my last post, and from now on, we’ll start running Basin on the span vs t data for these machines. I won’t go into the internals of how Basin works, because that’s really for another day. But, what we should note is that it computes two thing for us:

  1. An expression for span(t)
  2. An error

The error is a relative MSE. Relative to what you may ask? In our case, Basin will split the 41 rows we have into 5 groups at random for each machine. It will then fit on any 4 of the groups and predict the 5th one. The error is the difference in actual vs. prediction for the 5th one. We do this for all the 5, leaving one out each time and then average it to get the relative MSE.

Now we have 5 formulas, so Basin will return the simplest formula (note: the definition for simplest is not of concern here, the word itself is good enough for us) whose error is WITHIN one std. dev. from the lowest error formula. (We do this because the lowest error formula might be an overfit, with complex equations which we don’t want).

I am talking about this because this is a very important quantitiy. We call it roughness. A smooth machine, as we observed had a roughness of about $10^{-6}$ or below (yes, its incredibly low!) while a rough machine (which by definition means a machine that Basin COULDN’T fit very well) had an error of about $10^{-3}$ or more. You can see that there is a CLEAR difference!

Basin has no log functionality (I know I made it, but log with classical AI search is kinda hard) so I also computed log(t) separately and used that as an independent variable to find span(log(t)) too. You never know, span might be an exponential! To differentiate between the two different “fits”, let’s call them:

  1. “t-fit”: span(t)
  2. “u-fit”: span(log(t))

So for each machine, we run both the t-fit and the u-fit and to decide between the two, we again need to use some heuristics. There are two rules:

  1. A u-fit is allowed only if the raw slope from $2^20$ to $2^22$ is at most $0.4$. If the data grows faster than $t^0.4$, the u-fit is thrown out and the t-fit wins.

We picked 0.4 because its just less than sqrt(t).

  1. If the above doesn’t happen and raw slope is less than $0.4$, then we need to compare the two errors we get for those formulas:
  • If they are within a factor 2 of each other (the bigger is at most twice the smaller) AND the fits have different numbers of coefficients, take the fit with fewer coefficients, even if its error is a bit higher.

  • Otherwise, take the fit with lower error.

The “number of coefficients” is counted as the number of decimal numbers written in the law string. For example $1.4146*\sqrt{t} - 2.8657$ has 2 coefficients.

This rule was kinda emperical. If we didn’t have this, then a bunch of sqrt(t) machines would have been labelled log (based on just the first rule).

# Growth classes and rate

Alright, with that out of the way, we’re ready to see growth classes. Let me first give you the pipeline. For each machine, with 41 datapoints and 2 sets (span vs t and span vs log(t)) we do the following:

  1. Check if the machine is bounded. If the span is identical (exactly) for ALL of the 41 checkpoints, then we classify the machine as bounded.

  2. If the machine is not bounded, run Basin on the two sets of data, and pick a formula in accordance to the rules above.

  3. If u-fit comes out, the growth class is defined to be log for that machine.

  4. If t-fit comes out, we compute the formula’s local-exponent at $t = 2^22$.

The local-exponent is the slope of the log-log plot for the formula at the end of the window. Its like taking the log of both sides of the equation and then trying to compute the slope because the slope is the exponent and hence the growth class. So,

$$ \alpha = \frac{d(\log f)}{d(\log t)} $$

We’ll have to numerically approximate this, but then we round $\alpha$ to the nearest of 0, 1/3, 1/2, 2/3, 1 if its within 0.04 of that value. So, if alpha was say 1.03, then we’d round to 1. One of these become the class for that formula. Why these numbers specifically? Because we observed that numbers closer to these were frequently achieved by Basin!

If $\alpha$ doesn’t fit any of these within 0.04, then the class is others.

Clearly:

$\alpha = 0$: Bounded growth -> The span doesn’t change $\alpha = 1$: Linear growth $\alpha = \frac{1}{2}$: $\text{span} \approx \sqrt{t}$ $\alpha = \frac{1}{3}$: $\text{span} \approx t^{\frac{1}{3}}$

So, we have 5 growth classes. 4 of these and 1 log from the u-fit.

Let me show you some examples. You can work some of these out if you want using pen and paper (atleast the bounded and linear ones!) as a fun exercise:

  1. 1RB---_0RC---_0RD0LC_1LC1RE_1LE1RC: span is 5 at all 41 checkpoints $\implies$ bounded.

  2. 1RB---_0RC---_0RD1RE_1LC0LD_1LC1LE: We choose the t-law. That’s $\text{span} = 0.33333\cdot t + 0.94$, $\alpha$ comes out to be exactly 1.00 $\implies$ linear growth.

  3. 1RB---_0RC---_1LD1RC_0LE1RD_0RB0RC: This has a raw slope of about 0.5, so no u-law for this guy. The t-law is $1.4146\cdot \sqrt{t} − 2.87$, and $\alpha \approx 0.50 \implies$ a $\sqrt{t}$ growth.

  4. 1RB---_0RC1RC_1LD1RA_1LE0RD_1RC0LE: This is interesting because the span for this was only 59 at $t = 2^22$!. The raw slope is far below 0.4. So we use the u-law which is $3.0176\cdot \log(t) − 6.96$, and the growth class is log.

# The rate

For a t-fit like $\text{span} = c \cdot t^p$, $\alpha$ is an estimate of p while, the rate is an estimate of c. Computing that for different growth classes is simple, we just have to worry about what the rate means for each of these guys. We compute it at the END of the iterations:

classratemeaning
linear$\frac{f(2^22)}{2^22}$cells per step (speed)
$t^p$ ($\sqrt{t}$, $t^{\frac{1}{3}}$, $t^{\frac{2}{3}}$)$\frac{f(2^22)}{(2^22)^p}$the c in $\text{span} \approx c \cdot t^p$
$\log$$f(\log(t) = 22.5) − f(\log(t) = 21.5)$cells gained per doubling of t
boundedthe span itselfhow many cells it uses

Cells gained per doubling idea for log rate is a natural thing for a counter. A counter gains one cell every time t grows by some fixed factor F. So the cells gained per doubling are $\frac{\log(2)}{\log(F)}$.

I’ll talk more about counters later. But for now, any machine showing a log growth can be thought of as a counter in some F and we can compute the F value using the above idea.

# The results

Alright, now we run. Collect the data and analyse it. I ran it for BB(3), BB(4) and BB(5) machines only. Not BB(6) yet. Here’s what the table looks like:

growth classBB(3) machines (2,678)BB(4) machines (20,000)BB(5) machines total (20,000)BB(5) time limit machines (3,259)BB(5) space limit machines (16,741)
linear (translated cyclers)84.2%83.2%83.1%–99.3%
bounded (cyclers)13.5%13.4%12.8%78.4%–
$\sqrt{t}$ (bouncers)2.0%3.0%3.7%19.6%0.7%
$\log(t)$ (counters)0.4%0.4%0.3%1.9%–
$t^{\frac{1}{3}}$–0.02% (4)0.02% (4)0.1%–
other––1 machine–1 machine

A few surprising facts:

  1. No machine landed on a $t^{\frac{2}{3}}$ growth rate.
  2. The split between the growth classes is roughly the same across BB(3), BB(4) and BB(5) total.

Isn’t that cool! The BB(5) machines will contain the BB(4) machines in them in some degree so maybe that’s an explanation for the stability. But I don’t know why. I don’t know if this continues for other n values too! My laptop was already crying by this point and there was much to do.

If you’re curious as to what that other machine looks like, its this: 1RB---_1LC1RA_0RB0RD_1RC1LE_0LD1RC. You can cook up a simulator and see its span. This will be an important machine a while later.

Note that point 1 is infact not that surprising because we only sampled like 20k out of millions! Maybe if we run this multiple times it’d be more concrete.

Now that you have an idea of the growth class behind all these “names”, let me show you their space-time diagrams, and now you’ll be able to appreciate it.

Space diagrams for different growth classes
Space-time diagrams (time runs down, cells with a 1 in blue, head in orange where every step is drawn). From left: a translated cycler (240 steps), a cycler (240 steps), a bouncer (12,000 steps, every 12th row), and the BB(5) champion (60,000 steps, every 40th row), whose sweeps start over at a larger size after each macro step of its Collatz-like rule.

# Collatz like

I gotta digress from the mainline here a little bit and explain what collatz like machines mean because that part is coming soon!

It all starts with collatz conjecture which is an unsolved problem in math, as of the time of writing (unless OpenAI already proved it internally). It was introduced by Lothar Collatz in 1937. It’s an iterative algorithm which conjectures about the end-state of the system (hence, the link between this and what we’ve been doing so far shouldn’t be too weird).

The conjecture says that,

  1. If you start with a natural number n
  2. Divide it by 2 if its even ($\frac{n}{2}$)
  3. Multiply it by 3 and add 1 if its odd ($3n+1$)
  4. Keep doing this iteratively

then the sequence will eventually hit n = 1 no matter what n you start with. And what’s more, is that it will NEVER terminate and instead keep bouncing between 4 -> 2 -> 1.

Veritasium made a video about this conjecture BTW, you can learn about it from there.

The interesting thing is, the BB(5) champion, the one that halts at 47,176,870 steps is in EFFECT performing a very similar calculation. Now, to see that we’d have to apply a LOT of higher order abstractions to the problem and frankly its a little detailed. Lots of YouTube videos exist on this so you can check it out.

But this is what the BB(5) champion is computing at a higher level of abstraction.

$$ f(x) = \begin{cases} \dfrac{5x+18}{3} & \text{if } x \equiv 0 \pmod{3} \[6pt] \dfrac{5x+22}{3} & \text{if } x \equiv 1 \pmod{3} \[6pt] \text{Halt} & \text{if } x \equiv 2 \pmod{3} \end{cases} $$

Very similar to Collatz case eh? In fact, the BB(6) contender also behaves like a collatz function at a higher level of abstraction.

# Constants

The constants or the rate as we’ve been calling it so far:

  • the speed $\frac{f(t)}{t}$ of each linear machine;
  • the c in $\text{span} \approx c \cdot \sqrt{t}$ of each bouncer (and its square $c^2$);
  • the c in $\text{span} \approx c \cdot t^{\frac{1}{3}}$ (and its cube $c^3$);
  • for counters, the time factor per new cell

Time factor per new cell is a constant that doesn’t come because of Basin. I also haven’t clarified what counters are exactly and all of that is in for the next post.

Right now, let’s talk about the the rate. And remember that this is no less important than the exponent! We analyzed the exponent to get the growth class distribution so clearly we must analyze the rate too!

The hypothesis (which emperically is true atleast) seems to be that all rates are rational numbers. Like clean rational numbers or “exact” values so to speak. I can’t even define the conjecture, but all’s well, I am not a math guy, I am a physics guy.

# Linear machines: Parity of steps vs shift

This relates to an interesting observation for linear machines of the BB(5) family.

Remember that at any position in the tape, the Turing machine will either go right or left (since we’re considering non-halting machines) and its never gonna stay put.

  • In $p$ steps, say $R$ of the moves go right and $L$ go left. Then $R + L = p$.
  • The net shift is $d = R − L$.
  • So $p − d = 2L$, an even number. That means $p$ and $d$ have the same parity (both odd or both even). This implies $p \cong d (mod 2)$.

For a linear machine, recall that the speed is $\frac{f(t)}{t}$, that is, the shift divided by the steps. So, for these linear machines if the speed is $\frac{a}{b}$ in the lowest form, then we’re saying that the true $f(t)$ and $t$ values at the time of speed’s calculation (the end basically) is $m\cdot f(t)$ and $m \cdot t$ for some $m$ (duh) and from above, $m\cdot a \cong m \cdot b (mod 2)$.

Now:

  1. If $a+b$ is even ($a$, $b$ are the same parity), $m = 1$ works so technically, the pattern can be as short as $b$ steps. Example speeds then are: $\frac{1}{3}$ or $\frac{1}{1}$.

Note: $\frac{1}{3}$ can be thought of as moving 1 cell in 3 steps which is possible

  1. If $a+b$ is odd ($a$, $b$ are the opposite parity), $m = 1$ DOESN’T work, and $m$ must be even. This means the pattern needs to be at least $2b$ steps!

For example, $\frac{1}{2}$ but this is impossible as you CANNOT move 1 cell in 2 steps in a turing machine at all. The shortest you can do is 2 cell in 4 steps. You’d notice that in general, the simplest form doesn’t result in a valid turing machine mechanism so the number of steps in general are larger when $a+b$ is odd. So, we expect that BB(5) linear machines, majority will have $a+b$ as even.

And indeed, in the BB(5) sample of the 20k machines we used, 11,465 linear machines have $a + b$ even and 3,362 have $a + b$ odd!

Also, the four commonest speeds, $\frac{1}{3}$ (2,758), $\frac{1}{1}$ (2,665), $\frac{1}{5}$ (2,064) and $\frac{1}{7}$ (1,266), all have $a + b$ even. The speeds, $\frac{1}{2}$ (856) and $\frac{1}{4}$ (965) are rarer, even though they “look” simpler.

Common speeds of BB(5) machines
The 16 commonest speeds among linear BB(5) machines, coloured by whether the speed’s shortest possible period is b or 2b.

# Bouncers and rational $c^2$

A bouncer sweeps back and forth across a region of the tape. See the space-time diagram for it in figure 1. The span for a bouncer gets a little wider with every sweep.

Now as with linear machines, something interesting goes on with bouncers. But first, into math land:

  1. Say the span gains $a$ cells per round trip (left-to-right-to-left). After $n$ round trips it is about $a\cdot n$ cells wide. So $\text{span} \approx a\cdot n$.
  2. Say the head crosses the span at $h$ cells per step ($h \lte 1$, since the head moves at most one cell per step). Round trip number $k$ crosses about $a\cdot k$ cells twice, so it takes about $\frac{2ak}{h}$ steps.
  3. The total time after $n$ round trips is $t \approx \sum \frac{2ak}{h} \approx \frac{a\cdot n^2}{h}$. So $n \approx \sqrt{\frac{h \cdot t}{a}}$.
  4. Then $\text{span} \approx a\cdot n = \sqrt{aht}$. That is, $\text{span} \approx c \cdot \sqrt{t}$ with $c^2 = a\cdot h$.

Since both $a$ and $h$ are expected to be fractions ($h$ is a simple fraction as it was for the linear machines), their product $c^2$ is also expected to be a simple fraction. Note that, $c$ itself can be irrational.

For example, if $c^2 = 2$, which is the commonest value observed among BB(5) counters, then we can take $a = 2$ (one new cell at each end per round trip) and $h = 1$ (the head runs across at full speed). Then $\text{span} \approx \sqrt{2t}$. The machine 1RB---_0RC0RE_1LD1RC_0RD1LE_1LB1LD has its t-law as: $1.41403\cdot \sqrt{t}$, and $1.41403^2 = 1.99948$.

There were some 749 counters in the 20k sample for BB(5),

  • 60.5% have $c^2$ within 0.2% of a fraction with denominator ≤ 6. The normal distribution value for this chance is 11.5% of machines only! So, this is a significant thing.
  • At the stricter denominator ≤ 4 and within 0.1% of a fraction, we see 28.3% of machines against the normal value of 2.9%.

So, there is a significant pull towards rational fractions as is expected from the theory we developed a few moments ago. The commonest values are 2, 1, 4/3, 4, 3/2, 8/3, 2/3 and 3.

Common c^2 spread for bouncers
Distribution of $c^2$ for the 749 $\sqrt{t}$ machines in the `BB(5)` sample. The mass sits on simple fractions (dashed).

# The $t^{\frac{1}{3}}$ class

There were only 4 machines in a sample of 20k which were of this growth class! These machines grow as $c \cdot t^{\frac{1}{3}}$ and again we want to know if $c^3$ (not $c$ or $c^2$ here) is a clean fraction or not.

In the BB(4) sample, we noticed that 3 machines had $c \approx 1.4424$ which means $c^3 \approx 3.02$. The fourth has $c^3 = 6.11$, close to 6.

In the BB(5) sample:

  • Two machines (1RB1LA_1LA1RC_0RD0LB_0LA1RE_---1RD and 1RB1LA_1LC0RD_0LA1RA_0LE1RD_---0RB) have identical laws, $2.2895t^{\frac{1}{3}} − 0.979$. And $2.2895^3 = 12.00$! Isn’t that fucking sick!

  • One has $2.892t^{\frac{1}{3}} − 2.36$, so $c^3 \approx 23.8$ if we cube the coefficient. That is close to 24, but not exactly.

  • The last one has a law with $c^3 \approx 2.94$, near 3, but not exactly.

These deviations from exact fractions is kinda expected. To get actual values we’d have to sample our checkpoints too and then average, then do multiple runs and average and so on. But for now this is good enough.


And we’re done with growth classes! In the next post I’ll be talking about counters and the whole timing part I hinted at here, and finish with the Pisot number conjecture.


Did you like this blogpost? Then consider catching up via LinkedIn or Github!