# Tic-tac-toe And A Non-Constructive Proof Usually the game tic-tac-toe is played on an infinite board (i.e. 30 times 40 or something). The two players draw X:s and 0:s to the squares of a notepad paper. Player 1 (beginner) is the X-drawer and the Player 2 is the 0-drawer. The first player who manages to draw five of his symbols in a row, column or a diagonal wins (and no two symbols can be drawn in the same square). There are plenty variations and the most simple of them is played on a 3×3 grid and the player who gets 3 in a row/column/diagonal wins. According to these rules Player 1 won the game in the above cartoon. A combinatorial line however is a sequence of n-tuples (elements of A^n for a finite A={0,…,k-1}) which do not have both: increasing and decreasing co-ordinates. For instance ((1,0),(1,1),(1,2)) is a combinatorial line, but ((0,2),(1,1),(2,0)) is not. When mathematicians turned their attention to tic-tac-toe they noticed that it is more convenient to work with combinatorial lines rather than the traditional, discrete lines.

Let us return to the ordinary tic-tac-toe on the 3×3-board. There is a simple no-losing strategy for both players. More on this in Wikipedia. However if one extends the board to three dimensional $$3\times 3 \times 3$$ or four dimensional $$3\times 3 \times 3\times 3$$, or n-dimensional $$3^n$$, the X-player has a winning strategy. These games can be in fact played on a paper. For $$3\times 3 \times 3$$ one draws 3 grids of size 3×3 and imagines that they correspond to the first, second and the third layers in the $$3\times 3 \times 3$$ cube. For $$3\times 3 \times 3\times 3$$ draw a grid like in sudoku. More generally we call $$k^n$$-tic-tac-toe the game played on an n-dimensional board with sides of length k. In this case a line of length k must be produced. What is a winning line, a discrete line, is formally defined below.

The $$3^3$$-tic-tac-toe can be actually played in Finland in Heureka. There is an apparatus with a physical grid of $$27=3\times 3 \times 3$$ lamps hanging on the roof and people can switch them on and off in two different colours using special joysticks. There is a link to an advertisement of it from here. I found also another version of the game: the player who by the end of the game has more lines of his or her symbols than the opponent, wins.

Let us consider the $$3\times 3 \times 3$$ board. The game is played on the set
$$A^3=A\times A\times A$$, where $$A=\{0,1,2\}$$.
On the first move Player 1 picks one of the triples in $$A^3$$ and gives it the colour X (we prefer to talk about colouring the board, but still use X and 0 to denote the colours). Then Player 2 picks another triple and gives it the colour 0. They continue in this manner and the first player who obtains a discrete line (see below) coloured all in his colour (a monochromatic line), wins. If there is no monochromatic discrete line even after all the elements of $$A^3$$ are coloured, then the game is a draw. The definitions are the same for $$A=\{0,\dots,k-1\}$$ and the n-dimensional board $$A^n$$: players colour elements from the set $$A^n$$ of sequences of length n and the colour of the first monochromatic discrete line defines the winner.

Let us now define a discrete line or a d-line we referred to above. Suppose $$A=\{0,\dots,k-1\}$$. Elements of $$A^n$$ are sequences of length n. A typical element of $$A^4$$ for k=3 is (1,1,2,0). A sequence with variables is a sequence in which some elements are replaced by one of the two variables x and y: for example (x,2,x,0) or (y,y,x,0) are sequences with variables. Formally a sequence with variables $$s(x,y)$$ is an element of the set $$(A\cup\{x,y\})^n$$. For any sequence with variables $$s(x,y)$$, let us denote by $$s(v,u)$$ this sequence but with x replaced by v and y replaced by u everywhere. Now given a sequence with variables $$s(x,y)$$ the corresponding d-line will be the set

$$\{s(u,k-1-u)\mid u\in A\}=\{s(0,k-1),s(1,k-2),\dots,s(k-1,0)\}$$.

Examples of d-lines in $$A^4$$ for k=3 are thus

$$\{(0,2,1,2),(1,2,1,2),(2,2,1,2)\}, s(x,y)=(x,2,1,2)$$
$$\{(2,0,0,0),(2,1,1,1),(2,2,2,2)\}, s(x,y)=(2,x,x,x)$$ and
$$\{(2,1,0,0),(1,1,1,0),(0,1,2,0)\}, s(x,y)=(y,1,x,0)$$ etc..

So there are increasing, decreasing and constant co-ordinates corresponding respectively to x, y and constants. Now, combinatorial lines are those discrete line which arise from sequences with variables not containing both x and y. Thus the first and the second of above examples are combinatorial but the last is not.

I will now give a proof that Player 1 can always win in the $$3^3$$-tic-tac-toe and then I will give a sufficient condition for a winning strategy in $$k^n$$-tic-tac-toe.

Theorem 1 There is a winning strategy for Player 1 in the $$3^3=3\times 3\times 3$$-tic-tac-toe.

Proof. So now $$A=\{0,1,2\}$$ and the game board is $$A^3$$. On the first move Player 1 picks the element in the middle (the element $$(1,1,1)$$). Suppose the opponent answers by an element $$(0,v,u)$$. After that Player 1 just picks a line from the opposite $$3\times 3$$-subgrid, $$\{(2,x,y)\mid x,y\in A\}$$. This is possible because the opponent has to prevent the formation of a line of the form $$\{(2,x,y),(1,1,1),(0,x’,y’)\}$$ and has to play only on the subgrid $$\{(0,x,y)\mid x,y\in A\}.\,\,\,\,\,\, \square$$

The standard $$3^2$$-tic-tac-toe can end in a draw: all squares of the board are filled but there is no monochromatic discrete line. This situation is impossible in the $$3^3$$-case. After colouring all elements of the $$3^3$$-cube, there will be a monochromatic line (but not necessarily a combinatorial line!). This fact gives another proof of Theorem 1 which follows from the more general Theorem 2:

Theorem 2 Suppose k and n are numbers with the property that whenever the cube $$A^n=\{0,\dots,k-1\}^n$$ is coloured with two colours, there exists a monochromatic d-line. Then Player 1 has a winning strategy in the $$k^n$$-tic-tac-toe.

Proof. The idea is that one of the players must have a winning strategy and if it is Player 2, then Player 1 could use that strategy against her.

So suppose Player 1 does not have a winning strategy. Then independently of what is his first move, it is not a winning move, so Player 2 can reply by a move after which player 1 is still not in a winning position and so forth. This cannot lead to a win by Player 1 and since one of the players wins (by the assumption there cannot be a draw), this is a winning strategy for Player 2. Let us show that this is a contradiction.

If there is a winning strategy for Player 2, then Player 1 can use it! He just ignores his own first move and after the first move by Player 2 he imagines that they switched roles. It has to be checked now that the first extra move doesn’t bother Player 1, but it is an element of his colour, so it certainly cannot help player 2 to win. If he has to play later on the same place as the first extra move occurred, he just picks some random element, since the needed move is already made. $$\,\,\,\,\,\,\square$$

Note that there is a huge difference between the proofs of Theorems 1 and 2. The proof of Theorem 1 is constructive: it provides a strategy. So once it has been understood, one can easily win the $$3^3$$-tic-tac-toe being in the position of Player 1. But the proof of Theorem 2 is not constructive. Hence, even if you know that your playing board satisfies the conditions of Theorem 2 (i.e. there’s never a draw) and you fully understand the proof, there is still no hint of how actually to play in order to win (being Player 1).

But how do we know whether two given numbers k and n satisfy the premise of Theorem 2? It is certainly a hard question, but at least it is known that for each k there exists an n such that the pair k, n meets the requirements. Since a combinatorial line is a special case of a d-line the following result of Ramsey theory applies as well to our case:

Theorem 3 (Hales-Jewett). Let k be a positive integer and $$A=\{0,\dots,k-1\}$$. Then there exists a natural number $$n$$ such that whenever the elements of the cube $$A^n$$ are coloured with two colours, there is a monochromatic combinatorial line, i.e. a combinatorial line with all elements being the same colour. $$\,\,\,\,\,\,\square.$$

The least such number is denoted by $$HJ(k)$$. The general proof of this theorem gives $$HJ(3)\leqslant 8$$. Hindman and Tressler proved that $$HJ(3)=4$$. Their proof is quite detailed though.

But since we are interested in d-lines, not only combinatorial lines, let us define the function $$HJ^*$$ such that $$n=HJ^*(k)$$ is the least natural number such that any two-colouring of $$\{0,\dots,k-1\}^n$$ contains at least one monochromatic d-line. Equivalently $$HJ^*(k)$$ is the least dimension in which $$k^n$$-tic-tac-toe cannot be a draw. Clearly $$HJ^*(k)\leqslant HJ(k)$$. I found that $$HJ^*(3)=3$$. But it is a bit easier to show that $$HJ^*(3)\leqslant 4$$. The following elegant proof is due to Kerkko Luosto. Using the lemma below, the dedicated reader may verify that $$HJ^*(3)=3$$.

Theorem 4 $$HJ^*(3)\leqslant 4.$$

We will talk in terms of draw positions. The claim is that there is no draw position in $$3\times 3 \times 3\times 3$$. The key idea is that if there were a draw position in $$3\times 3 \times 3\times 3$$, then whenever we took a 3-dimensional subcube, the induced colouring would be a draw position on this subcube.

Lemma. Consider a draw position on the $$3^3$$-cube. Then the points $$(1,1,0)$$ and $$(1,1,2)$$ cannot have the same colour.

Proof. So here $$A=\{0,1,2\}$$.
One easily verifies that up to rotation and mirror symmetries and switching colours the following picture gives the unique draw position in a $$3\times 3$$-grid assuming that two horizontally opposite squares in the middle row have the same colour. So assuming that our $$3\times 3\times 3$$-grid has $$(1,1,0)$$ and $$(1,1,2)$$ of the same colour, it implies that the middle subsquare $$\{(1,x,y)\mid x,y\in A\}$$ is coloured as in the picture above. This implies the same for the subsquares $$\{(x,0,y)\mid x,y\in A\}, \{(x,1,y)\mid x,y\in A\}$$ and $$\{(x,2,y)\mid x,y\in A\}$$. There is only one way (up to symmetry) to do this without introducing monochromatic colours on the subsquares $$\{(0,x,y)\mid x,y\in A\}$$ and $$\{(2,x,y)\mid x,y\in A\}$$. But now there is a monochromatic diagonal ((0,0,0),(1,1,1),(2,2,2)). See the picture below. $$\,\,\,\,\,\,\square$$ Suppose now that there is a draw position on 3x3x3x3. By the previous lemma it means that no matter what 3-dimensional subcube we take, it cannot have the same colour at opposite points. Consider the following three subcubes of 3x3x3x3:

$$\{(x,y,z,z)\mid x,y,z\in A\}$$
$$\{(x,y,z,2)\mid x,y,z\in A\}$$
$$\{(x,y,0,z)\mid x,y,z\in A\}$$

Suppose the colour of the point (1,1,0,0) is X. Then using the first subcube we have that (1,1,2,2) must be 0. Using the second subcube this implies that (1,1,0,2) must be X and now using the third subcube this implies that (1,1,0,0) must be 0. A contradiction! $$\,\,\,\,\,\,\square$$ 