Blog

The game behind TREE(3)

The tree sequence playground, showing an illegal move with the embedded earlier tree ringed

Here is a game for one player. You have crayons in nn colours, and you are going to draw a sequence of rooted trees. Two rules:

  1. The kk-th tree you draw may have at most kk vertices. So the first has one vertex, the second at most two, and so on.
  2. No tree may fit inside any tree drawn after it.

That is all. The game ends when you cannot draw anything legal. The longest you could possibly last, playing perfectly with nn colours, is called TREE(n)\mathrm{TREE}(n).

With one colour you last one move. With two, three moves. With three colours the answer is finite — that part is a theorem — but it is so large that no notation you have met is going to help, and it makes Graham’s number look like a rounding error.

Sequence0 trees

Nothing played yet. Tree #1 may have exactly one vertex, so your only choice is which colour to spend.

Tree #1at most one vertex

New vertices
1

Legal. This would become tree #1.

Saved sequences

Nothing saved yet. Saves live in this browser only.

The checker is doing the referee’s job: after every edit it tells you whether the tree in the editor is legal, and if it is not, which earlier tree fits inside it and exactly where. You can save a sequence under a name and come back to it later.

What “fits inside” means

Everything depends on rule 2, and the natural reading of it is wrong.

The relation is the one from Kruskal’s tree theorem. Tree SS fits inside tree TT when you can find a copy of SS among the vertices of TT such that

That third condition is the one people drop, and it is what makes the game playable. Write a tree as a colour followed by its children in brackets, so 1(2,3) is a vertex of colour 1 with two children coloured 2 and 3. Then:

So sibling-ness is rigid. Two children of a vertex need two genuinely separate subtrees to live in, and no amount of stretching will merge them. That rigidity is the only reason you get to make more than a couple of moves.

One colour, then two

With one colour, the first tree must be the single vertex, and after that you are finished: every tree contains a vertex, that vertex has the only colour there is, and so your first tree fits inside everything. TREE(1)=1\mathrm{TREE}(1) = 1.

Two colours gets more interesting, and the trick is worth internalising because it is the whole idea of the game in miniature. Play:

  1. A single vertex of colour 2.
  2. 1(1), a colour-1 vertex with a colour-1 child.
  3. A single vertex of colour 1.

Check it. Tree 1 cannot fit into anything later, because nothing later uses colour 2 at all. Tree 2 has two vertices and tree 3 has one, so it cannot fit into it. And now you are stuck: a fourth tree would have to avoid colour 2 (or tree 1 fits) and avoid colour 1 (or tree 3 fits), which leaves nothing to draw. TREE(2)=3\mathrm{TREE}(2) = 3, and the playground will confirm the dead end for you — that is what the “any legal move left?” button is checking.

Notice what tree 1 was for. Spending a whole move on a single dot looks wasteful, but it buys a ban: from then on, that colour is forbidden everywhere. The art of this game is deciding when to cash a colour in, because you may only do it once per colour, and afterwards the board shrinks.

Which also explains why greedy play is terrible. If you always play the smallest legal tree you will play nn single dots and stop, so greedy scores exactly nn. Try it with three colours: three moves. Then try the seven-move run in the examples, which uses nothing more exotic than two-vertex trees, and note that it is still nowhere near optimal.

Three colours, and why nobody can tell you the answer

The moment you have a third colour, the two-colour game becomes a resource rather than the whole story. You can spend colour 3 to buy yourself a ban, then play out a two-colour game with a more generous vertex budget, and the budget keeps growing while you do it. Each colour you cash in leaves you playing the smaller game from a better starting position, and the recursion nests.

The result grows faster than essentially any function you can name. TREE(3)\mathrm{TREE}(3) is not merely bigger than Graham’s number; the gap is not one you can close with more arrows or more layers of recursion.

The reason the game must end at all is Kruskal’s tree theorem: in any infinite sequence of finite trees with colours from a fixed finite set, some earlier tree fits inside some later one. A sequence that breaks rule 2 forever is therefore impossible, so every game is finite, so TREE(n)\mathrm{TREE}(n) exists.

And here is the part I find genuinely strange. Harvey Friedman showed that Kruskal’s theorem cannot be proved in ATR0\mathrm{ATR}_0, one of the standard subsystems of second-order arithmetic — a system strong enough for a great deal of ordinary mathematics. The finite game inherits that strength. Any proof that your game must terminate is, in a precise sense, using more mathematical power than a large chunk of analysis needs. The unimaginable size of TREE(3)\mathrm{TREE}(3) is the arithmetic shadow of that logical strength: a system can only prove a function total if it can, in effect, out-grow it.

Things worth trying

How the referee works

Deciding “does SS fit inside TT” is a small recursion with a subtlety. Either the root of SS lands on the root of TT, in which case the colours must agree and each child subtree of SS must be placed in a different child subtree of TT — that is a bipartite matching, and running it is what enforces the meet condition on siblings. Or the root of SS lands somewhere deeper, in which case all of SS fits inside one of the child subtrees of TT, and you recurse. Memoising on pairs of subtrees keeps it quick at these sizes.

That is a neat argument, and neat arguments are exactly the ones that are subtly wrong, so the checker is tested against the definition rather than against my reasoning. A second, deliberately naive program enumerates every injection from SS into TT and verifies the colour and meet conditions directly from their statement; the two programs are compared on every pair of trees up to three and four vertices over two colours, and on hundreds of random pairs over up to three colours. Every witness the fast checker produces is separately re-verified against the definition. The search that proves you are stuck also reports honestly: when it can only rule out the trees it had time to enumerate, it says so instead of claiming you are finished. And the whole thing agrees that TREE(1)=1\mathrm{TREE}(1) = 1 and TREE(2)=3\mathrm{TREE}(2) = 3 by brute-force search over all legal sequences, which is the only part of this problem where brute force will ever be enough.

If you enjoy trees that stay small and well behaved, four ways to keep a tree balanced is about the other end of the spectrum entirely.

Comments