Keywords

1 Introduction

A deterministic two-player board game is played by two players on a finite board. The players take turns in choosing a move out of finitely many moves. Such a game has a unique starting board and end boards can be classified as a win for either player or a draw. Examples of deterministic two-player board games are Tic Tac Toe [1] and its many variants (e.g., Qubic [2]), chess, and checkers. Let an epoch be the set of all boards reachable from the starting board after a given number of moves. A deterministic two-player game is primitive recursive if there exists a primitive recursive (p.r.) function G(p, i, j), where p is a player and i and j are epoch numbers such that i < j, that returns for p an optimal sequence of moves from a given board in epoch i to a board in epoch j if it is p’s turn to play at epoch i.

In a previous paper [3], we showed Tic Tac Toe to be p.r. In this paper, a proof is presented to show that chess is a deterministic p.r. game. In Sect. 2, several operators on Gödel numbers are defined. Section 3 presents a proof that chess is p.r. Conclusions are presented in Sect. 4.

2 Gödel Number Operators

All variables such as x, y, z, a, b, i, j, k, and t refer to natural numbers (i.e., elements of \(\mathbb {N}\)). The Greek letters α, γ, and ω with appropriate subscripts refer to auxiliary functions. All functions map \(\mathbb {N}\) to \(\mathbb {N}\). Let 〈x, y〉 = z, where , , and y = ((z + 1)∕2x − 1)∕2. The pairing functions l(z) and r(z) are defined in (1) and shown to be p.r. in [4], where min is the minimalization function that returns the smallest natural number for which the predicate being minimalized is true.

(1)

Let (a 1, …, a n) be a sequence of numbers. The Gödel number of this sequence is defined in (2).

$$\displaystyle \begin{aligned}{}[a_1, \ldots, a_n] = \prod_{i=1}^{n}p_{i}^{a_i} \end{aligned} $$
(2)

The function [a 1, …, a n] is p.r., because x ⋅ y, x y, and p i are p.r., as shown in [4]. The Gödel number of () is 1. Let x = [a 1, …, a n]. Then the function (x)i = a i, 1 ≤ i ≤ n defined in (3) is shown to be p.r. in [4].

(3)

The length of x is the position of the last non-zero prime power in the Gödel representation of x defined by the p.r. function Lt(x) in (4).

(4)

Let the p.r. function ⌊xy⌋ return the integer part of the quotient xy [4]. Let γ 1(i, b) ≡ i > Lt(b) ∨ i < 1 ∨ b < 1. The p.r. function set in (5) sets the i-th element of b to x.

$$\displaystyle \begin{aligned} {\mathtt{set}}(b, i, x)= \begin{cases} 0 & \mbox{if } \gamma_1(i, b), \\ \lfloor{\frac{b}{p_{i}^{(b)_{i}}}}\rfloor \cdot p_{i}^{x} & \mbox{otherwise}. \end{cases} \end{aligned} $$
(5)

Let

$$\displaystyle \begin{aligned} \begin{array}{lll} {\mathtt{cntx}}(x, y, 0) & = & 0,\\ {\mathtt{cntx}}(x, y, t+1) & = & \gamma_2(x, y, t, {\mathtt{cntx}}(x, y, t)), \end{array} \end{aligned}$$

where s(x) = x + 1 and

$$\displaystyle \begin{aligned} \gamma_2(x, y, t, c) = \begin{cases} 1+c & \mbox{if } (y)_{s(t)} = x,\\ c & \mbox{otherwise}. \end{cases} \end{aligned}$$

The p.r. function count in (6) returns the count of occurrences of x in y. Let in(x, y) ≡count(x, y) ≠ 0. In the remainder of the paper, in(x, y) and x ∈ y are used interchangeably.

$$\displaystyle \begin{aligned} {\mathtt{count}}(x, y) = {\mathtt{cntx}}(x, y, Lt(y)) \end{aligned} $$
(6)

The p.r. function rap in (7) appends its first argument x to the right of the second argument y.

$$\displaystyle \begin{aligned} {\mathtt{rap}}(x, y)= \begin{cases} [x] & \mbox{if } y = 0 \vee y = 1,\\ y \cdot p_{Lt(y)+1}^{x} & \mbox{otherwise}. \end{cases} \end{aligned} $$
(7)

Let

$$\displaystyle \begin{aligned} \begin{array}{lll} {\mathtt{lcx}}(x_1, x_2, 0) & = & x_2,\\ {\mathtt{lcx}}(x_1, x_2, t+1) & = & \gamma_3(x_1, t, {\mathtt{lcx}}(x, y, t)), \end{array} \end{aligned}$$

where γ 3(x, t, y) = rap((x)s(t), y). The p.r. function ⊗l in (8) places all elements of x 2, in order, to the left of the first element of x 1. Let \( \otimes _{l}|{ }^{k}_{i=1} x_i = x_1 \otimes _{l} x_2 \otimes _{l} \ldots \otimes _{l} x_{k} = ( \ldots ((x_1 \otimes _{l} x_2) \otimes _{l} \ldots \otimes _{l} x_{k}) \ldots ) = ( \ldots (x_1 \otimes _{l} (x_2 \otimes _{l} (\ldots \otimes _{l} (x_{k-1} \otimes _{l} x_{k}) \ldots ))) \ldots )\).

$$\displaystyle \begin{aligned} x_1 \otimes_{l} x_2 = {\mathtt{lc}}(x_1, x_2) = {\mathtt{lcx}}(x_1, x_2, Lt(x_1)) \end{aligned} $$
(8)

The p.r. function ⊗r in (9) places all elements of x 2, in order, to the right of the last element in x 1. Let \( \otimes _{r}|{ }^{k}_{i=1} x_i = x_1 \otimes _{r} x_2 \otimes _{r} \ldots \otimes _{r} x_{k} = ( \ldots ((x_1 \otimes _{r} x_2) \otimes _{r} \ldots \otimes _{r} x_{k}) \ldots ) = ( \ldots (x_1 \otimes _{r} (x_2 \otimes _{r} (\ldots \otimes _{r} (x_{k-1} \otimes _{r} x_{k}) \ldots ))) \ldots ).\)Note that 0 ⊗l x = 1 ⊗l x = 0 ⊗r x = 1 ⊗r x = x.

$$\displaystyle \begin{aligned} x_1 \otimes_{r} x_2 = {\mathtt{lc}}(x_2, x_1) \end{aligned} $$
(9)

Let rmx(x, y, 0) = [ ] and rmx(x, y, t + 1) = γ 4(x, y, rmx(x, y, t), s(t)), where

$$\displaystyle \begin{aligned} \gamma_4(x, y, z, i) = \begin{cases} z & \mbox{if } (y)_i = x,\\ {} [(y)_i] \otimes_{l} z & \mbox{otherwise}. \end{cases} \end{aligned}$$

The p.r. function rm(x, y) = rmx(x, y, Lt(y)) removes all occurrences of x from y.

Let f(x) be a p.r. predicate and let mapx f(y, 0) = [ ] and mapx f(y, t + 1) = γ 5(y, mapx f(y, t), s(t)), where

$$\displaystyle \begin{aligned} \gamma_5(y, z, i) = \begin{cases} z & \mbox{if } f((x)_i) = 0,\\ {} [(y)_i] \otimes_{l} z & \mbox{if } f((x)_i) = 1. \end{cases} \end{aligned}$$

The p.r. function map f(y) = mapx f(y, Lt(y)) returns the list of occurrences of those elements x in y for which f(x) = 1.

Let pssx(x, y, 0) = [ ] and pssx(x, y, t + 1) = γ 6(x, y, pssx(x, y, t), s(t)), where

$$\displaystyle \begin{aligned} \gamma_6(x, y, z, i) = \begin{cases} [i] \otimes_{l} z & \mbox{if } (y)_i = x,\\ z & \mbox{otherwise}. \end{cases} \end{aligned}$$

The p.r. function pstn(x, y) = pssx(x, y, Lt(y)) returns all positions of x in y.

3 Chess

We can encode a chess board as a Gödel number B with 64 elements (see Fig. 1). An empty cell is encoded as 1. A white pawn is encoded as 2 ≤ n ≤ 9, the two white rooks are 10 and 17, the two white knights are 11 and 16, the two white bishops are 12 and 15, the white queen is 13, and the white king is 14. A black pawn is 18 ≤ n ≤ 25, the two black rooks are 26 and 33, the two black knights are 27 and 32, the two black bishops are 28 and 31, the black queen is 29, and the black king is 30. Let b 0 be the starting board. Then (b 0)j, 1 ≤ j ≤ 16, encode the black pieces, (b 0)j, 49 ≤ j ≤ 64, encode the white pieces, and (b 0)j, 17 ≤ j ≤ 48, encode the four empty rows in the middle of the board.

Fig. 1
figure 1

Chess board after 2 moves (above) and its Gödel number represented as a 2D matrix (below)

Let b be a board. The p.r. predicate γ 7(b) ≡count(14, b) = count(30, b) = 1 ensures that b has exactly one white king (i = 14) and exactly one black king (i = 30). The predicate γ 8(b) ≡ (∀i)≤64{{i ≤ 1 ∨ i = 14 ∨ i = 30}∨{count(i, b) ≤ 1}} ensures that, unless i encodes an empty square (i = 1), the white king (i = 14), or the black king (i = 30), its count on b is 0 or 1. The predicate γ 9(b) ≡ (∀i)≤64{{i ≠ 1}∨{32 ≤count(i, b) ≤ 62}} ensures that the count of the empty spaces on b is between 32 (in the starting chess board) and 62 (when only the two kings remain on the board). The predicate valid(b) in (10) is true if b is a valid chess board.

$$\displaystyle \begin{aligned} {\mathtt{valid}}(b) \equiv {\mathtt{Lt}}(b) = 64 \wedge \gamma_{7}(b) \wedge \gamma_{8}(b) \wedge \gamma_{9}(b) \end{aligned} $$
(10)

For each piece x in a specific position, there is a set of positions reachable for x from that position. Let z = [1, 2, …, 64] be the Gödel number encoding the board positions, where 1 encodes the top-left corner of the board and 64 encodes the bottom-right corner of the board, and let \(L_{j}^{k}\) be the Gödel number whose elements are the board positions where chess piece j can move from position k. For example, \(L_{15}^{1}\) is the list of positions reachable by the light-colored bishop 15 from position 1. The lists of positions reachable by bishop 15 from the positions along the main diagonal are

$$\displaystyle \begin{aligned} \begin{array}{lll} L_{15}^{1} = [10, 19, 28, 37, 46, 55, 64];\\ L_{15}^{10} = [1, 3, 17, 19, 28, 37, 46, 55, 64];\\ L_{15}^{19} = [1, 10, 5, 12, 26, 33, 28, 37, 46, 55, 64];\\ L_{15}^{28} = [1, 10, 19, 7, 14, 21, 35, 42, 49, 37, 46, 55, 64];\\ L_{15}^{37} = [1, 10, 19, 28, 16, 23, 30, 44, 51, 58, 46, 55, 64];\\ L_{15}^{46} = [1, 10, 19, 28, 37, 32, 39, 53, 60, 55, 64];\\ L_{15}^{55} = [1, 10, 19, 28, 37, 46, 48, 62, 64];\\ L_{15}^{64} = [1, 10, 19, 28, 37, 46, 55]. \end{array} \end{aligned}$$

Let W be the Gödel number whose elements are the white-colored cells on the chess board. Then L 15 in (11) defines the Gödel number whose elements are all possible board positions for bishop 15.

$$\displaystyle \begin{aligned} L_{15} = \otimes_{r}|{}_{i \in W} L_{15}^{i}. \end{aligned} $$
(11)

Such lists (i.e., Gödel numbers) can be computed in a p.r. fashion for all pieces and all positions on the board. Let be the list of pairs i, L i, where i denotes a chess piece and L i is the list of all possible positions where i can move. The p.r. function in (12) returns, for each piece x at position i on b, all potentially reachable positions where x can move from i.

$$\displaystyle \begin{aligned} {\mathtt{prp}}(x, i , b) = \begin{cases} r( ( L_{x} )_{\gamma_{10}(i, L_{x})} ) & \mbox{if } {\mathtt{valid}}(b)\\ 0 & \mbox{otherwise}, \end{cases} \end{aligned} $$
(12)

where and \(L_{x} = r((L)_{\gamma _{10}(x, L)}))\).

The p.r. predicate wp(x) ≡ 2 ≤ x ≤ 17 is true if x is a white piece and the p.r. predicate bp(x) ≡ 18 ≤ x ≤ 33 is true if x is a black piece. Let the predicate arp(x, i, b) be true if and only if position i on b is actually reachable for piece x (i.e., prp(x, i, b) = 1 and i is not blocked by another piece). Since arp(x, i, b) can be defined in this manner by cases, each of which is defined in terms of p.r. predicates such as bp, wp, valid, Lt, rap, etc., and combinations of compositions and primitive recursions thereof, arp is p.r.

Let z = [1, 2, …, 64] be the Gödel number encoding the board positions and b a chess board. Let f(x) ≡arp(x, j, b), where j ∈ z and wp(x) = 1 or bp(x) = 1. Then the p.r. function alst(x, b) = map f(x, z) returns the Gödel number of actually reachable positions for x on b.

Let bkp(b) = (pstn(30, b))1 be a p.r. function that returns the position of the black king on b. The black king is checked when there is a white piece (other than the white king encoded as 14) for which the current position of the black king is actually reachable. Formally, bchk(b) ≡ (∃x)<34{wp(x) ∧ x ≠ 14 ∧ γ 11(x, b)}, where γ 11(x, b) ≡ (∃j)<65{j > 0 ∧ α(x, j, b)} and α(x, j, b) ≡ (pstn(x, b))1 = j ∧in(bkp(b), alst(x, b)). The black king is mated if, when checked, it cannot move to any cell that is not actually reachable by a white piece. The p.r. predicate bmtd in (13) defines this logic.

$$\displaystyle \begin{aligned} {\mathtt{bmtd}}(b) \equiv {\mathtt{bchk}}(b) \land \gamma_{12}(b), \end{aligned} $$
(13)

where γ 12(b) ≡ (∀j)<65in(j, alst(30, b)) ∨ γ 13(j, b)} and γ 13(j, b) ≡ (∃x)<34{wp(x) ∧in(j, alst(x, b))}. The same logic can be used to define a p.r. predicate wmtd(b) to return 1 when the white king is mated and 0, otherwise.

A draw by stalemate occurs when the player whose turn it is to move is not in check but has no legal move. The p.r. black stalemate predicate bstlmt(b) ≡¬bchk(b) ∧ γ 14(b), where γ 14(b) ≡ (∀j)<65bp(j) ∨Lt(alst(j, b)) = 0], checks if the black king is not checked and no black piece has actually reachable positions. A white stalemate can be defined in the same fashion. All cases of the dead position rule can be defined as p.r. predicates with count, valid, in, =, and boolean combinations thereof.

A draw by repetition is achieved when the same position occurs three times in a row with the same player to move. The 50-move rule states that a game is a draw when the last 50 moves contain no capture or pawn move. The dead position rule applies when neither player can checkmate the opponent by any series of moves. The dead position rule applies to situations when there are only two kings left on the board, when one side has the king and a bishop and the other side has the king, when one side has the king and a knight and the other side has the king, when both sides have the king and a bishop and the bishops are both light-colored or dark-colored. The rules for the draw by repetition and the 50-move rule will be outlined below after we formalize the notion of the board history. Consider the p.r. function in (14).

$$\displaystyle \begin{aligned} \big( b \big)^{x}_{j} = \begin{cases} {\mathtt{set}}(b, j, x) & \mbox{if } \gamma_{15}(x, b)\\ 0 & \mbox{otherwise}, \end{cases} \end{aligned} $$
(14)

where γ 15(x, b) ≡valid(b) ∧{wp(x) ∨bp(x)}∧in(j, alst(x, b)). For example, the chess board in Fig. 1 is

$$\displaystyle \begin{aligned} \big( \big( \big( \big( b_{0} \big)^{6}_{37} \big)^{22}_{29} \big)^{16}_{46} \big)^{32}_{22}. \end{aligned}$$

Let b 1 be the list of all possible boards obtained from b by exactly one move of the white player, assuming that it is the white’s turn to move.

$$\displaystyle \begin{aligned} b^{1} = \otimes_{r}|{}^{17}_{x=2} \otimes_{r}|{}^{64}_{j=1} [(b)^{x}_{j}]. \end{aligned}$$

Let b 2 be the list of all possible moves obtained from b by exactly one move of the black player, assuming that it is the black’s turn to move.

$$\displaystyle \begin{aligned} b^{2} = \otimes_{r}|{}^{33}_{x=18} \otimes_{r}|{}^{64}_{j=1} [(b)^{x}_{j}]. \end{aligned}$$

Since both b 1 and b 2 are p.r., we can combine b 1 and b 2 into a single p.r. function pm(x, p) that maps the current board to the list of all possible boards obtained from it by exactly one move of either player.

$$\displaystyle \begin{aligned} {\mathtt{pm}}(b, p) = \begin{cases} b^{1} & \mbox{if } p = 1 \wedge {\mathtt{valid}}(b)\\ b^{2} & \mbox{if } p = 2 \wedge {\mathtt{valid}}(b)\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned} $$
(15)

Let \({\mathtt {Z}} = [b_{i_{0}}, b_{i_{1}}, \ldots , b_{i_{k}}]\) such that \({\mathtt {valid}}(b_{i_{j}}) = 1\), 0 ≤ j ≤ k. Let p ∈{1, 2}. The p.r. function scr(Z, p) in (16) takes a Gödel number that consists of valid boards and a player’s number and returns another Gödel number that consists of successor boards such that each successor board is obtained from one of the boards in Z by exactly one move of p, assuming that it is p’s turn to move.

$$\displaystyle \begin{aligned} {\mathtt{scr}}({\mathtt{Z}}, p) = {\mathtt{rm}}(0, \otimes_{r}|{}^{{\mathtt{Lt}}(Z)}_{i=1} {\mathtt{pm}}(({\mathtt{Z}})_{i}, p)) \end{aligned} $$
(16)

Let b 1 and b 2 be two boards and let p ∈{1, 2} be a player whose turn it is to play on b 1. The p.r. predicate prn(p, b 1, b 2) ≡valid(b 2) ∧in(b 2, pm(p, b 1)) is true when b 2 is in the Gödel number of the boards obtained from b 1 by exactly one move of p on it. In other words, b 1 is the parent of b 2. Let the p.r. function B(t), defined in (17), return the Gödel number that includes all boards, actually reachable from b 0 after t moves. We will refer to each B(t) as epoch t. Let B(0) = [〈[b 0], 1〉].

$$\displaystyle \begin{aligned} {\mathtt{B}}(t+1) = [\langle {\mathtt{scr}}(l(({\mathtt{B}}(t))_{1}), \gamma_{16}(s(t))) \rangle ], \end{aligned} $$
(17)

where γ 16(x) = 1 if ¬(2|x) and 2 if 2|x. Let G 0 = [b 0] and G i, for i > 0, be the Gödel number encoding all boards actually reachable from the boards in G i−1 in 1 move by the appropriate player. Let b ∈ G i, G i−1 = l((B(i − 1))1), and p = r((B(i − 1))1). The p.r. function ipb in (18) returns the index of the parent of b in G i−1 for i > 0.

(18)

The p.r. function prb in (19) returns the parent of b.

$$\displaystyle \begin{aligned} {\mathtt{prb}}(b, i) = (l(({\mathtt{B}}(i-1))_{1}))_{{\mathtt{ipb}}(b, i)} \end{aligned} $$
(19)

The p.r. function prbs in (20) computes the Gödel number whose last element is b and whose previous elements are its predecessors. In other words, element 8 is the parent board of element 9, element 7 is the parent board of element 8, etc.

(20)

Let X = prbs(b, i) such that i > 7 and valid(b) = 1. The p.r. predicate drw3r(b, i) ≡ γ 17(X), where γ 17(X) ≡{(X)1 = (X)5 = (X)9}∧{(X)2 = (X)6}∧{(X)3 = (X)7}∧{(X)4 = (X)8} is true if b is a threefold repetition board. To put it differently, in the list of b’s predecessors, elements 1 and 5 must be the same as b (i.e., element 9), element 2 must be the same as element 6, element 3 is the same as element 7, and element 4 is the same as element 8.

It is straightforward to extend the definition of prbs(b, i) to a p.r. predicate drw50(b, i) that computes 49 predecessors of a valid board b in epoch B(i) and checks if each board in the Gödel number of the predecessors and b itself contains no capture, which can be done by comparing the number of pieces on a given board and its immediate predecessor (i.e., its parent), or a pawn move, which can be done by comparing the pawn positions of all the predecessor boards of b and b itself. All these functions are p.r., because they manipulate Gödel numbers.

We can similarly express, in a p.r. fashion, each case of the dead position rule. For example, checking if a given board b contains only two kings or whether the white has the king and a knight and the black has only the king is p.r., because it requires checking p.r. properties of a given Gödel number. Consequently, we may assume that there is a p.r. predicate drw(b, i) that returns 1 if a valid board b in epoch i > 0 is a draw and 0 otherwise.

Let \(t \in \mathbb {N}\). We define the chess game history in (21) as the Gödel number encoding the boards at each epoch and the player whose turn it is to play at the next epoch.

$$\displaystyle \begin{aligned} {\mathtt{H}}(t) = \otimes_{r}|{}^{t}_{i=0} {\mathtt{B}}(i) \end{aligned} $$
(21)

For example H(3) = [B(0), B(1), B(2), B(3)] = [〈G 0, 1〉, 〈G 1, 2〉, 〈G 2, 1〉, 〈G 3, 2〉]. Let \(t, i, j \in \mathbb {N}\). Let \(G^{t}_{i} = l(({\mathtt {H}}(t))_i)\), \(b^{t}_{i,j} = (G^{t}_{i})_j\), L t = Lt(H(t)), and \(L^{t}_{i} = {\mathtt {Lt}}(G^{t}_{i})\). The p.r. predicate ww(t), t ≥ 0, in (22) returns true if there is a board in epoch i, 0 ≤ i ≤ t, where the white checkmates its opponent.

$$\displaystyle \begin{aligned} {\mathtt{ww}}(t) \equiv (\exists i)_{\leq L_t} \{ (\exists j)_{\leq L^{t}_{i}} \{ {\mathtt{bmtd}}(b^{t}_{i,j}) \} \} \end{aligned} $$
(22)

The p.r. predicate bw(t) in (23) is true if there is a board in epoch i, 0 ≤ i ≤ t, where the black checkmates its opponent.

$$\displaystyle \begin{aligned} {\mathtt{bw}}(t) \equiv (\exists i)_{\leq L_t} \{ (\exists j)_{\leq L^{t}_{i}} \{ {\mathtt{wmtd}}(b^{t}_{i,j}) \} \} \end{aligned} $$
(23)

If H(t) is the history of the game, then the white can win only in the even-numbered epochs and the black can win only in the odd-numbered epochs. We can define two predicates W w(m) and W b(m) that are true if the white or black, respectively, wins within t moves. Specifically, W w(m) ≡ (∃t)m{ww(t)} and W b(m) ≡ (∃t)m{bw(t)}. The p.r. predicate in (24) combines both predicates into one.

$$\displaystyle \begin{aligned} {\mathtt{W}}(p, m) = \begin{cases} {\mathtt{W}}_{w}(m) & \mbox{if } p = 1\\ {\mathtt{W}}_{b}(m) & \mbox{if } p = 2\\ 0 & \mbox{otherwise}.\\ \end{cases} \end{aligned} $$
(24)

In a similar fashion, we can define the p.r. predicate in (25) that is true if a draw is achieved for player p within m moves.

$$\displaystyle \begin{aligned} {\mathtt{D}}(p, m) \equiv (\exists i)_{\leq L_t} \{ (\exists j)_{\leq L^{t}_{i}} \{ {\mathtt{dwr}}(b^{t}_{i,j}, i) \}. \end{aligned} $$
(25)

Let \(p \in \{1,2\}, t \in \mathbb {N}\). The p.r. functions W (p, t) in (26) and D (p, t) in (27) return the lists of all win and draw boards for p, respectively, within t moves.

$$\displaystyle \begin{aligned} {\mathtt{W}}_{\leq}(p, t) = \otimes_{r}|{}^{t}_{i=1} {\mathtt{W}}(p, i) \end{aligned} $$
(26)
$$\displaystyle \begin{aligned} {\mathtt{D}}_{\leq}(p, t) = \otimes_{r}|{}^{t}_{i=1} {\mathtt{D}}(p, i) \end{aligned} $$
(27)

Let b x ∈ l((B(i))1) and b y ∈ l((B(j))1), where i < j. Let

$$\displaystyle \begin{aligned} \begin{array}{rcl} {\mathtt{ptx}}(b_x, b_y, 0) & = &\displaystyle \gamma_{18}(b_x, b_y),\\ {\mathtt{ptx}}(b_x, b_y, t+1) & = &\displaystyle [b_y] \otimes_{l} {\mathtt{ptx}}(b_x, {\mathtt{prb}}(b_y, s(t)), t), \end{array} \end{aligned} $$

where

$$\displaystyle \begin{aligned} \gamma_{18}(x, y) = \begin{cases} [x] & \mbox{if } x = y,\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned}$$

The p.r. function path in (28) gives the list of boards, possibly empty, from the board b x ∈B(i) to the board b y ∈B(j).

$$\displaystyle \begin{aligned} {\mathtt{path}}(b_x, b_y, i, j) = {\mathtt{ptx}}(b_x, b_y, j-i) \end{aligned} $$
(28)

If path(b x, b y, i, j) ≠ 0, b y ∈B(j) is reachable from b x ∈B(i). If path(b x, b y, 1, 3) = 0, then b y is unreachable from b x. Let b ∈ l((B(i))1), k ≥ 0, i < j, and let \(Z \in \mathbb {N}\) be a list of boards. Let

$$\displaystyle \begin{aligned} \begin{array}{rcl} {\mathtt{ppx}}(b, Z, i, j, 0) & = &\displaystyle [\hspace{0.02in} ],\\ {\mathtt{ppx}}(b, Z, i, j, t+1) & = &\displaystyle \gamma_{19}(b, Z, t, i, j) \otimes_{l} \\ & &\displaystyle {\mathtt{ppx}}(b, Z, i, j, t), \end{array} \end{aligned} $$

where γ 19(b, Z, t, i, j) = [path(b, (Z)s(t), i, j)]. The p.r. function ppx returns a list of paths from a given board b to each board in Z. Let ppxx(b, Z, i, j) = ppx(b, Z, i, j, Lt(Z)). The p.r. function in (29) returns the list of all paths, possibly empty, from b ∈ l((B(i))1) to a win board b ∈ l((B(j))1).

$$\displaystyle \begin{aligned} {\mathtt{wpss}}(b, i, j) = \otimes_{r}|{}^{j}_{k=i+1} \gamma_{20}(b, k, i, j), \end{aligned} $$
(29)

where γ 22(b, k, i, j) = ppxx(b, W(p, k), i, j), where p = 1 if 2|i and p = 2, otherwise. The p.r. function in (30) removes all empty paths from the list returned by wpss.

$$\displaystyle \begin{aligned} {\mathtt{wps}}(b, i, j) = {\mathtt{rm}}(0, {\mathtt{wpss}}(b, i, j)) \end{aligned} $$
(30)

The p.r. function in (31) returns the list of all paths, possibly empty, that start at b ∈ l((B(i))1) and end with a draw board b ∈ l((B(j))1).

$$\displaystyle \begin{aligned} {\mathtt{dpss}}(b, i, j) = \otimes_{r}|{}^{j}_{k=i+1} \gamma_{21}(b, k, i, j), \end{aligned} $$
(31)

where γ 21(b, k, i, j) = ppxx(b, D(p, k), i, j), where p = 1 if 2|i and p = 2, otherwise. The p.r. function in (32) removes all empty paths from the list returned by dpss.

$$\displaystyle \begin{aligned} {\mathtt{dps}}(b, i, j) = {\mathtt{rm}}(0, {\mathtt{dpss}}(b, i, j)) \end{aligned} $$
(32)

Let 0 ≤ k < t, k < j ≤ t, p ∈{1, 2}, and b ∈ l((B(k))1). If p = 1 (i.e., p plays white), then p is the max player whose objective is to maximize the utility score of b. Let the highest utility score that can be assigned to b be 3 if there is at least one win board b B(j) reachable from b. If there are no reachable win boards, let the utility of b be 2 so long as there is at least one draw board b B(j) reachable from b. Let b have the lowest utility score of 1 when there is no win or draw board b B(j) reachable from b. Let the utility score of 0 be assigned to invalid boards. The p.r. function in (33) returns the utility score of b for p = 1, where γ 22(b, k, t) ≡ Lt(dps(b, k, t)) = Lt(wps(b, k, t)) = 0.

$$\displaystyle \begin{aligned} {\mathtt{U}}_{max}(b, k, t) = \begin{cases} 3 & \mbox{if } Lt({\mathtt{wps}}(b, k, t)) > 0,\\ 2 & \mbox{if } Lt({\mathtt{dps}}(b, k, t)) > 0,\\ 1 & \mbox{if } \gamma_{22}(b, k, t),\\ 0 & \mbox{if } \neg {\mathtt{valid}}(b). \end{cases} \end{aligned} $$
(33)

If p = 2 (i.e., p plays black), then p is the min player whose objective is to minimize the utility score of b. Let the utility score of b be 1 if there is at least one win board b B(j) reachable from b. If there are no win boards in B(j) reachable from b, let the utility score of b be 2 so long as there is at least one draw board in b B(j) reachable from b. Let the highest utility score of 3 indicate that there is no win or draw board b B(j) reachable from b. Again, let the utility score of 0 be assigned to invalid boards. The p.r. function in (34) returns the utility score for b for player 0.

$$\displaystyle \begin{aligned} {\mathtt{U}}_{min}(b, k, t) = \begin{cases} 1 & \mbox{if } Lt({\mathtt{wps}}(b, k, t)) > 0,\\ 2 & \mbox{if } Lt({\mathtt{dps}}(b, k, t)) > 0,\\ 3 & \mbox{if } \gamma_{22}(b, k, t),\\ 0 & \mbox{if } \neg {\mathtt{valid}}(b). \end{cases} \end{aligned} $$
(34)

Let b ∈ l((B(i))1), 0 ≤ i < j, The p.r. function U in (35) returns the utility score of b ∈B(i) for player p ∈{1, 2} when the game continues from epoch B(i) to epoch B(j).

$$\displaystyle \begin{aligned} {\mathtt{U}}(b, p, i, j) = \begin{cases} {\mathtt{U}}_{max}(b, i, j) & \mbox{if } 2|i,\\ {\mathtt{U}}_{min}(b, i, j) & \mbox{if } \neg{(2|i)},\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned} $$
(35)

Let 0 ≤ i < j. The p.r. function fb in (36) returns a list of boards with a given utility score x ∈{1, 2, 3} for player p from epoch i to epoch j.

$$\displaystyle \begin{aligned} {\mathtt{fb}}(p, i, j, x) = {\mathtt{fbx}}(p, i, j, Z, L, x), \end{aligned} $$
(36)

where Z = l((B(i))1), L = Lt(l((B(j))1)), fbx(p, i, j, Z, 0, x) = [ ], fbx(p, i, j, Z, t + 1, x) = γ 23(p, i, j, (Z)s(t), fbx(p, i, j, Z, t, x), x), and

$$\displaystyle \begin{aligned} \gamma_{23}(p, i, j, b, Z, x) = \begin{cases} [b] \otimes_{l} Z & \mbox{if } {\mathtt{U}}(b, p, i, j) = x,\\ b & \mbox{if } {\mathtt{U}}(b, p, i, j) \neq x. \end{cases} \end{aligned}$$

Let 0 ≤ i < j and α 3(p, i, j) ≡fb(p, i, j, 3) ≠ 0, α 2(p, i, j) ≡fb(p, i, j, 2) ≠ 0 ∧fb(p, i, j, 3) = 0, and α 1(p, i, j) ≡fb(p, i, j, 1) ≠ 0 ∧fb(p, i, j, 3) = fb(p, i, j, 2) = 0, The p.r. function fb max returns a list of boards for player p = 1 from epoch i to epoch j.

$$\displaystyle \begin{aligned} {\mathtt{fb}}_{max}(p, i, j) = \begin{cases} {\mathtt{fb}}(p, i, j, 3) & \mbox{if } \alpha_{3}(p, i, j),\\ {\mathtt{fb}}(p, i, j, 2) & \mbox{if } \alpha_{2}(p, i, j),\\ {\mathtt{fb}}(p, i, j, 1) & \mbox{if } \alpha_{1}(p, i, j),\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned} $$

Let β 1(p, i, j) ≡fb(p, i, j, 1) ≠ 0, β 2(p, i, j) ≡fb(p, i, j, 2) ≠ 0 ∧fb(p, i, j, 1) = 0, and β 3(p, i, j) ≡fb(p, i, j, 3) ≠ 0 ∧fb(p, i, j, 1) = fb(p, i, j, 2) = 0. The p.r. function fb min returns a list of boards for player p = 2 from epoch i to epoch j.

$$\displaystyle \begin{aligned} {\mathtt{fb}}_{min}(p, i, j) = \begin{cases} {\mathtt{fb}}(p, i, j, 1) & \mbox{if } \beta_1(p, i, j),\\ {\mathtt{fb}}(p, i, j, 2) & \mbox{if } \beta_2(p, i, j),\\ {\mathtt{fb}}(p, i, j, 3) & \mbox{if } \beta_3(p, i, j),\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned} $$

The p.r. function fb mnx in (37) returns the list of optimal boards for player p ∈{1, 2} from epoch i to epoch j.

$$\displaystyle \begin{aligned} {\mathtt{fb}}_{mnx}(p, i, j) = \begin{cases} {\mathtt{fb}}_{max}(p, i, j) & \mbox{if } p = 1,\\ {\mathtt{fb}}_{min}(p, i, j) & \mbox{if } p = 2,\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned} $$
(37)

The p.r. function et(k) in (38) determines whose turn it is to play at epoch B(k).

$$\displaystyle \begin{aligned} {\mathtt{et}}(k) = \begin{cases} 1 & \mbox{if } 2|k,\\ 2 & \mbox{if } \neg (2|k).\\ \end{cases} \end{aligned} $$
(38)

Let 0 ≤ k < t. Let

$$\displaystyle \begin{aligned} \omega_1(k, t) = \otimes_{r}|{}^{t-1}_{j=k} [({\mathtt{fb}}_{mnx}({\mathtt{et}}(j), j, t))_{1}]. \end{aligned} $$

The p.r. ω 1 function chooses the first board returned from the function fb mnx. Other p.r. functions can also be defined to inspect the first n boards returned by fb mnx. The p.r. function bseq in (39) returns a sequence of optimal boards for player p whose turn it is to play at k.

$$\displaystyle \begin{aligned} {\mathtt{bseq}}(p, k, t) = \begin{cases} \omega(k, t) & \mbox{if } {\mathtt{et}}(k) = p,\\ {} [\hspace{0.02in}] & \mbox{otherwise}. \end{cases} \end{aligned} $$
(39)

Let 0 ≤ k < t and let b 1 and b 2 be two boards such that ϕ(b 1, b 2, k) ≡in(b 1, l((B(k))1)) ∧in(b 2, l((B(k + 1))1)) and prb(b 2, k + 1) = b 1. Let

The p.r. function ω 3(b 1, b 2) extracts a move 〈p, j〉, where 1 ≤ j ≤ 64, that changes b 1 to b 2.

$$\displaystyle \begin{aligned} \omega_3(b_{1}, b_{2}, k) = \begin{cases} \langle {\mathtt{et}}(k), \omega_2(b_1, b_2) \rangle & \mbox{if } \phi(b_1, b_2, k),\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned} $$
(40)

Let Z = bseq(p, k, t) = [b 1, …, b tk+1] and let

$$\displaystyle \begin{aligned} {\mathtt{mseq}}(p, k, t) = \otimes_{r}|{}^{Lt(Z)-1}_{i=1} [\omega_3((Z)_{i}, (Z)_{i+1}, k-1+i)] \end{aligned} $$

Let γ 24(p, i) ≡{2|i ∧ p = 1}∨{¬(2|i) ∧ p = 2}. The p.r. function in (41) defines a game of chess for player p and epoch i by returning a sequence of optimal moves for p beginning at epoch B(i) and ending at epoch B(j).

$$\displaystyle \begin{aligned} G(p, i, j) = \begin{cases} {\mathtt{mseq}}(p, i, j) & \mbox{if } \gamma_{24}(p, i),\\ 0 & \mbox{otherwise}. \end{cases} \end{aligned} $$
(41)

Since G(i, j) is p.r., we have the following theorem.

Theorem

Chess is a deterministic two-player p.r. game.

4 Conclusion

A proof is presented to show that chess is a deterministic two-player primitive recursive game. To the extent that the proof holds, chess can be characterized in terms of primitive recursive functions. If this is the case, some deterministic two-player games and processes that can be formalized as such are likely to have algorithmic solutions that outperform human players. The techniques developed in this paper may lead to proofs that other deterministic two-player board games are primitive recursive and contribute to the theory of primitive recursive functions [5].