1. Introduction
A deterministic two-player board game (D2PBG) is played by two players on a finite board. The board is finite in the sense that it contains finitely many positions where each player can make a move. The players take turns making moves on the board with exactly one move per player per turn. The order of turns is pre-determined and cannot be changed at any point during the game. At each turn, a move is chosen by a player out of finitely many possible moves and uniquely determines the next board.
A D2PBG is a sequence of boards with a unique starting board. The last board (or the end board) of any such sequence is reached from the starting board after finitely many valid (i.e., allowed by the rules of the game) moves, and can be classified as a win for either player, a draw, or an unfinished board in the sense that the game can continue from its end board for a positive number of moves into the future. Examples of D2PBGs are Tic Tac Toe [
1] and numerous variants thereof (e.g., Qubic [
2]), chess, and checkers.
We follow Kleene’s classification of computational methods into
decision procedures and
calculation procedures (Chapter 6 in [
3]). A decision procedure is a mechanical method expressed in a symbolic formalism (e.g.,
-calculus [
4] or the language L [
5]) that returns, in finitely many steps, a positive (e.g., 1) or negative (e.g., 0) answer to a class of problems. We refer to such classes of problems as
characteristics. Thus, the characteristic of
relative primality of two positive integers in number theory is decidable by a decision procedure that uses Euclid’s algorithm to find their greatest common divisor, checks whether it is equal to 1 and returns 1 (i.e., true) if it is, and 0 (i.e., false) if it is not. The characteristic of
winnability in the game of Tic Tac Toe is decidable by a decision procedure that for the end board
b of any unfinished Tic Tac Toe game returns 1 if it is winnable by either player (i.e.,
X or
O) whose turn it is to play on
b within
M moves where
M is a positive integer [
6] and returns 0 if it is not winnable. As shown in this investigation, the characteristic of
stalemate for a chess game is decidable by a decision procedure that determines if the end board of the game is a stalemate for the player whose turn it is to play on it. We refer to a feature of a D2PBG as a
decision characteristic if there exists a decision procedure to decide it.
A calculation procedure requires an effective (i.e., mechanical and deterministic) construction, in finitely many steps, of a mathematical object (e.g., a sequence of instructions in -calculus, a plot, a matrix, etc.) that satisfies specific properties. Euclid’s algorithm is a calculation procedure for the characteristic of relatively primality, because it constructs in finitely many steps the required object – the greatest common divisor of two numbers. Similarly, a calculation procedure for the game of Tic Tac Toe takes any unfinished game and, if the latter is winnable within M moves by the player whose turn it is to play on its last board, constructs a sequence of at most M moves that result in a win board for the player. We call a feature of a D2PBG a calculation characteristic if there exists a calculation procedure to produce required mathematical objects (e.g., boards or games) with specific properties. The existence of a calculation procedure for a characteristic implies the existence of a decision procedure for it that returns 1 if a required object is constructed and 0 otherwise.
We may require that a decision or calculation procedure itself satisfy certain properties. In general, those properties can be either structural (e.g., a procedure must be primitive recursive, computable, or partially computable) or algorithmic (e.g., the number of steps the procedure takes to return a decision or construct an object must be the function of the size of the input n such as and must be known ahead of the calculation).
In this article, we focus on the structural (and, more specifically, primitive recursive) characteristics of chess. In that, we follow a fundamental tenet of classical computability theory, which, as formulated by Rogers [
4], states that
‘‘[w]e thus require that a computation
terminate after some finite number
of steps; we do not insist on an a
priori ability to estimate this number.’’
We thus study the arithmetization of chess (and, by implication, of other D2PBGs) to analyze the game’s characteristics with methods of number theory and classical computability. If a decision characteristic of chess can be computed with a primitive recursive predicate, we call the characteristic primitive recursively decidable or pr-decidable; if a calculation characteristic of chess can be computed with a primitive recursive function, we refer to it as primitive recursively computable or pr-computable.
Unfortunately, the theory of recursive functions appears to lack a uniform, commonly accepted formalism. The treatment of primitive recursive functions in this article is based on the formalism by Davis et al. in [
5], which, in turn, is based on Kleene’s formalism in (Chapter 9 in [
3]). Alternative treatments are given in [
7], where primitive recursive functions are formalized as loop programs consisting of assignment and iteration statements similar to DO statements in FORTRAN, or in [
4], where primitive recursive functions are described with
-calculus.
The words number or numbers in this article refer to a natural number or natural numbers, respectively, where the set of natural number is defined as . All small letters (e.g., x, y, z, a, b, c, i, j, k, t, l, m, n, u, z, , etc.) with appropriate numeric or symbolic subscripts (when the latter are required by the context) are variables that denote numbers. We sometimes use capital letters (e.g., M, Z) with suitable subscripts or no subscripts to refer to numbers that we believe are significant for the current exposition.
In this article, all functions map to (i.e., ), where j and k are positive numbers. We use the symbol ≡ to define predicates (e.g., ). We use the capital letter P with prime superscripts (e.g., ) or numeric subscripts to define predicates and use the capital letter F with numeric subscripts to define functions. Number 0 when referencing the value of a predicate means that the predicate is false; number 1 when referencing the value of a predicate means that the predicate is true.
When the argument variables of a function or predicate are clear from the context, we use the notation or for brevity. For example, instead of and instead of .
When a variable occurs free in the definition of a predicate or a function it refers to a number referenced in the immediate context. For example, let and let . In this definition of , z refers to number 10.
In defining some predicates, we occasionally abbreviate Boolean combinations of numerical predicates. For example, is abbreviated as ; as ; as , etc.
The remainder of the article is organized as follows. In
Section 2, several functions are defined that are shown to be primitive recursive in [
5]. In
Section 3, we use the primitive recursive functions in
Section 2 to define several primitive recursive functions to manipulate Gödel numbers (G-numbers). We call these functions
G-number operators and use them in
Section 4 to show several characteristics of chess and to be pr-decidable and pr-computable. In
Section 6 and
Section 7, we discuss and summarize our findings.
2. Preliminaries
Let
be a function and
be functions, where each
,
, is a function of
n arguments. Then
is obtained by composition from
if
Let
and
be total. Let
and
be total. If
h is obtained from
by the recurrences in (
2) or from
f and
g by the recurrences in (
3), then
h is obtained from
or from
f and
g by
primitive recursion or, simply, by
recursion.
Let
be the three
initial functions. A function is
primitive recursive if it can be obtained from the initial functions by a finite number of applications of composition or recursion as defined in (
1)–(
3) [
5].
A total function is a predicate if for any n numbers or , where 1 designates true and 0 false. The expression is a bounded existential quantifier so that if is a predicate, , if , for at least one t such that . The expression is called the bounded existential quantification of .
The expression is a bounded universal quantifier so that, if is a predicate, then , if , for every t such that . The expression is called the bounded universal quantification of .
If
is a predicate and
z is a number, then
is called the
bounded minimalization of
and defines the smallest number
for which the predicate
is true or 0 if there is no such number. If
and
, then 0 returned by the bounded minimalization of
is the smallest number
for which
holds. If
, then 0 returned by the minimalization of
means that there is no number
, for which
holds. If this additional check on 0 must be avoided in a given context,
t in the minimalized predicate
must be required to be greater than 0 (e.g.,
), in which case, 0 returned by the minimalization of
means that there is no
for which
holds. The operator
min is similar to Kleene’s operator
[
3]. If
is a
n-ary predicate, we occasionally write
to abbreviate
and write
to abbreviate
.
It is shown in [
5] that 1) the predicates
,
,
,
,
,
, and
(
x divides
y or
x is a divisor of
y) are primitive recursive; 2) any Boolean combination of primitive recursive predicates is primitive recursive; and 3) if a predicate
is primitive recursive, then so are its negation and its bounded minimalization and bounded universal and existential quantifications. We will use the notation
to denote
(i.e.,
x does not divide
y or
x is not a divisor of
y).
Let
y =
x −
y x ≥ 0, and
x ∸
y = 0
x <
y. Thefunction
x ∸
y is shown to be primitive recursive in [
5]. Let the pairing of numbers
x and
y be defined as
where
The minimalization of the primitive recursive predicate
above makes
x the largest number such that
. As shown in [
5], for any number
z, there are unique
x and
y such that
and the pairing function
is primitive recursive. For example, if
, then
Let the functions
and
in (
6) return the left and right components of any number
z. Since the predicate
is primitive recursive, both
are primitive recursive, because they are bounded minimalizations of the bounded existential quanitifcations of primitive recursive predicates. Thus, if
, then
,
, and, in general,
for any number
z.
Let
be the
n-th prime so that
,
,
, etc. Let
, by default. In [
5],
is shown to be computed by a primitive recursive function, which we define as
Thus, , , , , , , etc.
Let
be a sequence of numbers. The function in (
8) computes the Gödel number (G-number) of this sequence.
The function
is shown to be primitive recursive in [
5], because
,
,
are primitive recursive, and a finite product of primitive recursive functions is, by induction, primitive recursive. The G-number of the empty number sequence
is 1. Thus, the G-number of
is
Let
. The accessor function
in (
9), which returns the
i-th element of
x, is shown to be primitive recursive in [
5].
The function
allows us to treat G-numbers as arrays (i.e., sequences of numbers). Thus, if
, then
Since G-numbers are sequences, they have lengths. Thus, if
, the length of
x is the position of the last non-zero prime power in
x and is computed by the primitive recursive function
in (
10). We note that
if and only if
, and if
, then
.
The function
that returns the integer part of the quotient
is shown to be primitive recursive in [
5]. Thus,
;
;
, and
for any number
x.
4. Chess
4.1. Boards
Figure 1 shows the starting board of any chess game. It consists of 64 cells where each of the two players (the white and the black), has 16 pieces. We encode this board as G-number
b of 64 numbers, each of which encodes the contents of the corresponding cell. This number
b can, when convenient for visualization, be construed as a matrix shown below the board picture in
Figure 1.
An empty cell is encoded as 1. A white piece on the starting board is encoded as a number from 2 up to 17. Thus, west to east, the white pawns are encoded as 2, 3, 4, 5, 6, 7, 8, 9, the white rooks as 10 (west) and 17 (east), the white knights as 11 (west) and 16 (east), the white bishops as 12 (west or dark-colored) and 15 (east or light-colored), the white queen as 13, and the white king as 14.
A black piece on the starting board is encoded as a number from 18 up to 33. Thus, west to east, the black pawns are encoded as 18, 19, 20, 21, 22, 23, 24, 25, the black rooks as 26 (west) and 33 (east), the black knights as 27 (west) and 32 (east), the black bishops as 28 (west or light-colored) and 31 (east or dark-colored), the black queen as 29, and the black king as 30.
Each cell on board
b has a unique position shown in
Figure 2. Let
denote the G-number of all positions from 1 to 64. A position
k is a
valid position if
. Thus, if
b is the board in
Figure 1, then
and
Since there are exactly 32 empty cells, we have
The position of the black and white kings on any valid board
b (valid boards are defined below) are
Figure 3 shows board
that is the result of two moves made by each player on
b in
Figure 1. Thus, the following predicates are true:
4.2. Pawn Metamorphosis
If a pawn reaches the first row on the opposite side of the board, it transforms into a queen, a rook, a bishop, or a king of the same color. We call these positions
metamorphic positions and give them in
Table 1.
Let be a white pawn and let k be one of its metamorphic positions. If j becomes a queen, the new white queen is encoded as ; if j becomes a rook, the new white rook is encoded as ; if j becomes a bishop, the new white bishop is encoded as ; if j becomes a knight, the new white knight is encoded as .
Let be a black pawn and let k be one of its metamorphic positions. If j becomes a queen, the new black queen is encoded as ; if j becomes a rook, the new black rook is encoded as ; if j becomes a bishop, the new black bishop is encoded as ; if j becomes a knight, the new black knight is encoded as .
Thus, if white pawn 2 becomes a queen at position 7, the new white queen is ; if 2 becomes a rook at position 7, the new white rook is ; if 2 becomes a bishop at position 7, the new white bishop is ; if 2 becomes a knight, the new white knight is .
Similarly, if black pawn 19 becomes a queen at position 59, the new black queen is ; if 19 becomes a rook at position 59, the new black rook is ; if 19 becomes a bishop at position 59, the new black bishop is ; if 19 becomes a knight at position 59, the new black knight is .
Since for any
z,
, where
x and
y are unique (See Equation (
5)), this encoding scheme for pawn metamorphosis ensures that every new piece is encoded as a unique number. Each player can obtain at most eight new pieces through pawn metamorphosis. The
supplementary materials contain the encoding tables for all pieces that can be obtained through pawn metamorphosis.
We call the pieces into which the pawns transform at the metamorphic positions metamorphic pieces and refer to the pieces on the original board as regular pieces. Formally, j is a regular white piece if , is a regular black piece if , and is a regular piece if j is a regular white or black piece.
Tables S1 and S2 in the Supplementary Materials contain all unique numbers of the white and black pieces under this encoding scheme that can be obtained through pawn metamorphosis with the primitive recursive pairing function. Let
be the G-numbers of the white, black, and all metamorphic pieces.
4.3. Valid Pieces and Boards
Let the primitive recursive predicates
hold when
j is a valid white or black piece, respectively. A chess piece
j is
valid if and only if the primitive recursive predicate
holds (i.e.,
). Let
denote the G-numbers of the white pieces (
), the black pieces (
), and all chess pieces (
).
Let us consider if the
valid chess board characteristic is pr-decidable. If
b is a valid chess board, it must contain exactly one white king (14) and exactly one black king (30). The primitive recursive predicate
holds when
b has this characteristic.
Board
b is valid if the number of occurrences of each regular or metamorphic piece on
b, with the exception of the two kings, is 0 (if the piece is captured) or exactly 1 (if the piece is not captured). The primitive recursive predicate
ensures that the number of occurrences for each piece on
b, regular or metamorphic, so long as that piece is not a king, is 0 or 1.
If
b is valid, then the count of the empty cells on it is at least 32 (i.e.,
b is the starting board) and at most 62 (i.e., when only the kings are present). The primitive recursive predicate
holds when the count of the empty cells on
b is between 32 and 62.
If board
b is valid, then the regular and metamorphic black and white bishops, when present on
b, must be in the appropriate light-colored and dark-colored positions.
Tables S3–S6 in the Supplementary Materials contain the encoding tables for all metamorphic light-colored and dark-colored bishops.
Let
denote the G-number of the numbers of the metamorphic light-colored white bishops in
Table S3,
—the G-number of the numbers of the metamorphic dark-colored white bishops in
Table S4,
—the G-number of the numbers of the metamorphic light-colored black bishops in
Table S5,
—the G-number of the numbers of the metamorphic dark-colored black bishops in
Table S6. Let
be the G-numbers of the light-colored and dark-colored metamorphic bishops.
The primitive recursive predicates
hold if
j is a metamorphic white or black knight, respectively. The primitive recursive predicates
hold if
j is a metamorphic white or black light-colored bishop, respectively. The primitive recursive predicates
hold if
j is a metamorphic white or black dark-colored knight, respectively. The primitive recursive predicates
hold if
j is a metamorphic knight or bishop, respectively.
If board
b is valid, then the regular light-colored bishops 15 and 28 and any metamorphic light-colored bishops, when present, must be located on the light-colored positions and the regular dark-color bishops 12 and 31 and any metamorphic dark-colored bishops, when present, must be located on the dark-colored positions. Let
be the G-number of all light-colored positions on
b (See
Figure 4) and let
be the G-number of all dark-colored positions on
b (See
Figure 5). The primitive recursive predicate
holds of
b when all bishops, if present, are in the positions of the appropriate color.
If
b is valid, then the regular white pawns 2–9 or the regular black pawns 18–25 cannot be in the metamorphic positions 1–8 and 57–64 (See
Figure 1 and
Figure 2). Let
be the G-number of positions 1–8 and 57–64. The primitive recursive predicate
holds of
b when the regular white and black pawns do not occupy the positions they cannot occupy either because they cannot move backward to reach those positions or because they undergo metamorphosis on those positions. In summary, the primitive recursive predicate
holds if
b is a valid 64-cell chess board. Thus, if
and
are the boards in
Figure 1 and
Figure 3, respectively, then
.
4.4. Diagonals, Rows, Columns
A position
on valid
b is a member of at most two diagonals. Let
and
be the diagonals (if
) or the diagonal that include
k. For example,
is a member of two diagonals:
and
(See
Figure 2); and
is a member of the diagonal
(i.e., the first main diagonal).
Let
be the G-number that pairs each position
k with the diagonals that contain it.
Since each position is a member of exactly one row and exactly one column, we define G-numbers R and C to pack all rows and columns. For example, 7 is in the row and the column .
Since
is primitive recursive by definition,
is primitive recursive by the DCT. Thus,
We place all row numbers on valid
b into G-number
R to pair each row number with the G-number of all positions in that row:
For each
, we define eight primitive recursive functions (one for each column)
and let
We place all column numbers into the G-number
C that pairs each column number with the G-number of all positions in the column:
The primitive recursive functions in (
44)–(
46) return the G-number of the diagonals, rows, and columns, respectively, for a valid position
k on
b.
Given positions
and
, let
and
The primitive recursive function
returns diagonal
d that contains both
and
if
d exists.
Let
] and
The primitive recursive function
returns row
r that contains both
and
if
r exists.
Let
] and
The primitive recursive function
returns column
c that contains both
and
if
c exists.
4.5. Potentially Reachable Positions
The primitive recursive predicate
holds for valid pieces
x and
y of the opposite colors.
Let j, k, and b denote a valid piece, a valid position, and a valid board, respectively. Position on b is potentially reachable for j from k if j can move from k to on b. Position can be empty or occupied by a different piece.
Let be the G-number of the positions potentially reachable by j from k on b. For example, is the G-number of the positions potentially reachable by bishop 15 from position 1. The G-numbers , , denote the positions potentially reachable by 15 from the other positions of the first main diagonal. We note that is defined regardless of any b in the sense that whether is potentially reachable for j from k depends only on the move rules for j and not on the positions of the other pieces on b.
Thus, for bishop 15 positioned anywhere on the first main diagonal, we have
We recall that
in (
41) is the G-number of the light-colored positions on
b. Since 15 is light-colored, the G-number
contains all positions potentially reachable by 15. We observe that if
j is another real or metamorphic light-colored black bishop (e.g.,
), then
For the dark-colored real bishops 12 and 31 (or any dark-colored metamorphic bishop
j), we can analogously define
using
in (
42) (i.e., the G-number of the dark-colored positions on valid
b).
In general, for each valid piece
j we define the G-number of all potentially reachable positions on
b and place all such G-numbers into
L in (
51) of the pairs
, where
is the G-number of all reachable positions for
j on
b.
The function
returns the G-number of all potentially reachable positions for
j from
k on
b. The function
is primitive recursive by the DCT.
4.6. Actual Reachability for Bishop 15
If , it may be occupied by of the same color. For example, although , , i.e., it is occupied by pawn 5 of the same color as knight 16 and, consequently, 16 cannot move from 46 to 52 on . To put it differently, 52 is not actually reachable for 16 from 46 on .
The characteristics of potential reachability and actual reachability, while conceptually related by the rules of chess, are different in that the potential reachability of for j from k holds on any valid b whereas the actual reachability of for j from k depends not only on whether but also on .
As an extended example, let us consider the characteristic of actual reachability for bishop 15 to determine if this characteristic is pr-computable. For any valid position k of 15 on b, the positions in the G-number of actually reachable positions for 15 from k depend on the light-colored bishop move rules and require us to take into account the positions of the other pieces of the same color on b.
Let the primitive recursive function
return the current position of valid piece
j on valid board
b so that if
, then
Let
. We seek to compute the G-number of actually reachable positions for 15 from
on
b. Let
be a valid position. Then
in (49) returns diagonal
d that contains both
and
k. If
d does not exist (i.e.,
), then
k is not actually reachable for 15 from
on
b. If
d exists, we need to ensure that either
k is empty on
b (i.e.,
) or is occupied by a piece of the opposite color
and 15 can capture
. Furthermore, if
d exists, we need to ensure that there is no piece either of the same or opposite color between
and
k on
d. The primitive recursive predicate
holds on
b if
k is potentially reachable for 15 from
and is on the same diagonal with
and every position
between
k and
on the diagonal is empty and
k itself is either empty or occupied by a black piece. The primitive recursive predicate
holds when
k is actually reachable for 15 from
on valid
b.
Let
be the board in
Figure 3. Then
because
, but pawn 8 in position 55 is of the same color with 15, which makes
false. On the other hand,
for any
. Let
b be a board and let
Then for any
on
b,
computes in a primitive recursive fashion the G-number of all positions actually reachable for 15 from
on
b (See Equation (
41) for
), which furnishes us the following lemma.
Lemma 1. Actual reachability for bishop 15 is pr-decidable and pr-computable.
4.7. Actual Reachability
Let
j be a valid piece on valid
b. Let
, where
is the pr-computable position of
j on
b. Thus,
is the position of the black king on
b and
is the position of the white king on
b.
Let
. By the rules of chess,
j can actually reach finitely many positions from
. Consequently, whether
k is actually reachable for
j from
on
b can be decided in a primitive recursive fashion with the functions and predicates in
Section 2 and
Section 3 and
,
,
,
,
,
,
through appropriate Boolean combinations of primitive recursive predicates and applications of the DCT in the way similar to the one constructed for bishop 15 in the previous section. Hence, we have the following lemma.
Lemma 2. Let and . Then is primitive recursive.
Since there are finitely many regular and metamorphic pieces, there are finitely many predicates
. Let
. The function
where
returns the G-number of all positions in
z that are actually reachable for
j from
on
b. The function
is primitive recursive by Lemma 1 and the DCT, which makes
also primitive recursive.
The function
in (
55) returns the G-number of actually reachable positions for
j from
on
b. This function is primitive recursive, because it is composed from primitive recursive functions.
We have the following lemma.
Lemma 3. Actual reachability for valid piece j on valid board b is pr-decidable and pr-computable.
4.8. Checks, Mates, and Stalemates
Black king 30 on valid
b is checked when there is a white piece
(i.e., different from white king 14), for which
(See Equation (
54)) is actually reachable. The primitive recursive predicate
holds of
b when king 30 is checked on it (See Equation (
35) for
). King 30 is mated if, when checked, it cannot move to any position that is not actually reachable by some white piece
j from the latter’s current position. The primitive recursive predicate
holds of
b when king 30 is mated on it (See Equation (
32) for
). The primitive recursive predicate
holds of
b when white king 14 is checked on it (See Equation (
35) for
); and the primitive recursive predicate
holds of
b when 14 is mated on it.
A stalemate occurs when the player whose turn it is to make a move on
b is not in check, yet has no legal move to make. In other words, all the player’s pieces have no actually reachable positions. The primitive recursive predicate
holds if
b is the black stalemate; and the primitive recursive predicate
holds if
b is the white stalemate.
4.9. Dead Position
The dead position rule (DPR) holds for valid b when neither player can checkmate the opponent by any series of moves. The DPR can be broken into four cases: (1) b contains only 14 (white king) and 30 (black king); (2) b contains only 14, 30 and a bishop; (3) b contains only 14, 30 and a knight; (4) b contains only 14, 30, one white bishop, and one black bishop such that one bishop is light-colored and the other one-dark-colored.
The primitive recursive predicate
holds for case 1.
We break case 2 into five sub-cases: (2a) b contains only 14, 30, 12; (2b) b contains only 14, 30, 15; (2c) b contains only 14, 30, 28; (2d) b contains only 14, 30, 31; (2e) b contains only 14, 30, and exactly one metamorphic bishop.
The primitive recursive predicate
holds when
b contains 14, 30, and exactly one other piece
j. The primitive recursive predicate
holds for case 2 (See Equation (
40) for
).
We break case 3 of the DPR into five sub-cases: (3) b contains only 14, 30, 11; (3b) b contains only 14, 30, 16; (3c) b contains only 14, 30, 27; (3d) b contains only 14, 30, 32. (3e) b contains only 14, 30, and exactly one metamorphic knight.
The primitive recursive predicate
holds for case 3.
We break case 4 of the DPR into three sub-cases: (
4a)
b contains 14, 30, 15, 31; (
4b)
b contains 14, 30, 12, 28; (
4c)
b contains 14, 30, and two metamorphic bishops one of which is light-colored and the other dark-colored. Let the primitive recursive predicate
hold of two different pieces
and
on valid
b that are the only two pieces on
b different from 14 and 30. The primitive recursive predicate
holds for case 4. The primitive recursive predicate
holds if
b is a valid dead position board.
There are two more types of draw in chess: repetition and the 50-move rule. 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. We will consider these types of draw after we formalize the concept of game history.
4.10. Moves
Let the primitive recursive predicate
hold when position
k is actually reachable for piece
j on valid
b from
(as defined in (
54)) and
b is not a mate, a stalemate, or a draw. Let
The above equation defines a primitive recursive function that calculates the board obtained from
b after
j is placed in position
k and position
is set to 1. Thus, if
is the starting board in
Figure 1, then
is the board after the white player moves pawn 6 from position 53 to position 37.
Let the primitive recursive predicate
hold if the move of
j into
k from
does not result a board where the king of the same color with
j is checked, because such moves are not allowed by the rules of chess.
The function defined in (
70) is primitive recursive by the DCT. Thus, if
is the board in
Figure 1, then the board in
Figure 3 is
The right-hand side of the above equality denotes the board obtained from with four moves: (1) white pawn 6 to position 37; (2) black pawn 22 to position 29; (3) white knight 16 to position 46; and (4) black knight 32 to position 22; or (1) e4 e5; (2) Kf3 Kf6 in standard chess notation.
We will denote the white player by 1 and the black player by 2. If
x is a player, then
denotes the player’s opponent. Thus, if
, then
; if
, then
. Let
denote the move of piece
j by player
x from
to
k on
b that results in
. Thus,
is the move of pawn 6 from 53 to 37 by player 1 on
that results in
The primitive recursive function
in (
72) constructs the required move number for valid
b,
x,
j,
k.
Let
be a move constructed from valid
b,
x,
j, and
k. Then the primitive recursive functions
,
,
, and
in (
73) return the predecessor board, the successor board, the player, the piece and the piece’s positions of move
z, respectively.
Thus, if
be the board in
Figure 1, the G-number
contains a sequence of moves from
in
Figure 1 to the board
in
Figure 3.
Let
be the G-number of all possible moves that player
x can do on
b if it is
x’s turn to play. Equations (
74) and show us how
and
are pr-computable.
Let the primitive recursive predicate
hold when
b is not a mate, a stalemate, or a dead position. The function
in (
75), which is primitive recursive by the DCT, maps board
b to the G-number of all possible moves obtained from it by exactly one move of player
x.
4.11. History
An epoch of a D2PBG is the G-number of all possible valid boards that can be obtained from each board in the previous epoch with exactly one move by the player whose turn it is to play on the boards of the previous epoch. The history of a D2PBG is the G-number of finitely many epochs.
Let
be the initial board in
Figure 1. Let the history of chess start at epoch
where
We observe that
and
denotes player 1 whose turn it is to play on
.
Epoch
,
, is
where
is pr-computable from
as
Thus, epoch
, is pr-computable from
as
where
Epoch
is pr-computable from
as
where
To generalize, we let
and define epoch
as a primitive recursive function in (
79).
Given an epoch number
t, the history of chess,
, is pr-computable as
4.12. Games
We define the primitive recursive predicate
to hold when
b is a successor of some move in
,
. We will refer to
b as an epoch
t board. Let the primitive recursive predicate
hold between boards
b and
if for some move
such that
b is the move’s predecessor and
is its successor. In other words, epoch
t board
can be obtained from epoch
board
b in exactly one move by the player whose turn it is to play on
b.
Let
,
, be a sequence of boards and let
be the starting board. The primitive recursive predicate
holds of
z when it has at least two boards, its first board is
, and the predicate
in (
82) holds of every two consecutive boards in
z. If
for some sequence of boards
z, we refer to
z as
chess game or simply as
game .
Then, since
,
,
, and
are games.
Let
z be a G-number of boards. The primitive recursive function
computes the last board of
z. If
is a game, we will refer to the last board of
(i.e.,
) as the
tail board or the
tail of
.
The primitive recursive function
computes the G-number of all games up to epoch
.
where
where
where
where
The primitive recursive function
in (
89) takes a game
, a G-number
of moves such that
, a G-number
Z of games and a number
t. This function computes the continuation
of
and appends it at the right of the games
Z computed thus far.
The primitive recursive function
in (
88) takes a game
, a G-number
M of moves such that
and returns the G-number of games each of which is a continuation of
with each successor board of the moves
.
The primitive recursive function
in (
87) takes a game
and the G-number
of moves of epoch
and computes the G-number of all games that extend
with the appropriate successor boards in
(i.e., with the successor board of each move
such that
).
The primitive recursive function
in (
86) takes a G-number of games
Z and
and computes the G-number of games by extending every game in
Z with all appropriate successor boards in
. If
, then
is the G-number of all games up to epoch
t. All games in
are
historical in the sense that they are based on the moves in each epoch
of
in (
80). All games in
are
legal, because they are obtained by legal moves from the initial board
. We have the following lemma.
Lemma 4. Let , , and . Then and if t is even, then player 1 is to play on b; if t is odd, player 2 is to play on b.
Let
be a primitive recursive predicate that holds of
z if
is a chess game and let
be the set of numbers for which
holds. Since every primitive recursive function is computable (See Chapter 3 in [
5]), we have the following lemma.
Lemma 5. The set of chess games Γ is recursive.
Lemma 5 shows that the characteristic of chess game historicity or, equivalently, chess game legality is pr-decidable.
Let
be a game and let
be a sequence of boards such that
. We say that
is a
subgame of
if the primitive recursive predicate
in (
93) holds of
and
.
In other words,
must have at least 2 boards but no more boards than
z and be a sub-sequence of
z that starts at some position
i between 1 and
1. Consider
Figure 10. If
then
We define the primitive recursive predicate
to hold when
starts at a specific board
i in
.
4.13. Repetition and 50-Move Rule
We now return to the remaining two types of draw: draw by repetition and the 50-move rule, which we promised to consider at the end of
Section 4.9. We recall that a draw by repetition is achieved when the same board position occurs three times in a row with the same player to move. Consider the sequence of boards in
Figure 12. Board
occurs three times in this sequence (i.e.,
) with player 1 to move.
Let
be a subgame with player
x to play on
. The same board occurs in a row at
since
x and
must make one move each and then reverse that move. Player
x then plays on
and the same board occurs in a row at
, since
x and
make one move each again and reverse it. Thus,
is a draw by repetition if it has 9 boards such that
. In other words, if
Let
,
, then
is a draw by repetition if
The 50-move rule states that a game is a draw when the last 50 moves contain no capture or pawn move. If a game is a draw by the 50-move rule, then , . Let be a subgame of that has 50 boards (i.e., ). Then is a 50-move rule draw if for all boards in the pawn positions are same and the counts of all white and black pieces remain constant.
We define several auxiliary primitive recursive predicates to compose them into a primitive recursive predicate that holds of
if the latter is a draw by the 50-move rule. Let
be the G-numbers of the white and black pawns, respectively. The primitive recursive predicates
and
below hold if every white and black pawn is present or abscent on both boards (i.e.,
and
) and, if any white or black pawn is present on both boards, its position is the same on both.
We recall that
in (
41) defines the G-number of all the white and black pieces. The primitive recursive predicate
holds if the counts of all pieces on the boards
and
are equal.
Let
z be a sequence of boards. The primitive recursive predicate
holds if the predicates
and
hold for every pair of consecutive boards in
z. The primitive recursive predicate
holds if the counts of all pieces on all boards in
z are equal. The primitive recursive predicate
holds if the boards in
z have no pawn moves or piece captures.
The game
is a draw by the 50-move rule if there is a position
i in
z that starts a subgame of length 50 for which
holds. The primitive recursive predicate
holds if
is a draw by the 50-move rule.
4.14. Classification of Games
We define the primitive recursive predicate
to hold when
is a draw game by repetition, the 50-move rule, stalemate, or dead position. The primitive recursive predicate
holds when
ends in a mate for
. The primitive recursive predicate
holds when
is unfinished for
x (i.e., it is neither a draw nor a win for
x).
By Lemma 4, player 1 can win only those games in
if
t is odd and player 2 can win only games in
if
t is even. Let
,
, and let
x be the player to play at
t. If
is not a win for
, then
x can win in 1, 3, 5, …,
moves. Let
n be an odd number of moves into the future. We inquire if it is possible to find games
that are continuations of
and are wins for
x in a primitive recursive fashion. The primitive recursive predicate
determines if
is a continuation of
. For any
, we let the primitive recursive predicate
hold when
is a continuation of
that is a win for
x. Let
and
. If
,
, then the primitive recursive function
returns the G-number of all continuations of
in
that are wins for
x whose turn it is to play on the tail of
. The primitive recursive predicate
holds when
is a continuation of
that is a draw. If
,
, then the primitive recursive function
returns the G-number of all continuations of
in
that are draws for
x whose turn it is to play on the last board of
. The primitive recursive predicate
holds when
is a continuation of
that is unfinished for
x. Let
and
. If
,
, then the primitive recursive function
returns the G-number of all continuations of
in
that are unfinished for
x whose turn it is to play on the tail of
.
Let , , and let x be the player whose turn it is to play on the tail of . We will further assume that is unfinished (i.e., ) for x. We call winnable for x in n moves if , drawable for x in n moves if , and unfinishable for x in n moves if . We will call unfinishable games hangs. If a player makes a move that results in a hang, we will say that the player hangs the game or that the game is hung. We have the following lemma.
Lemma 6. Let , , be a hang and x be the player whose turn it is to play on . If n is an odd positive integer, then it is pr-decidable whether is is winnable for x within n moves, is drawable for x within n moves, or is a hang for x within n moves.
Of course, if a game is winnable, drawable, or unfinishable for x, x may still lose it within n moves, because there may be a sequence of at most n moves from the tail of that allows to win.
We pose the question if it is pr-decidable to whether is absolutely winnable for x within n moves when x is to play on the tail of . is absolutely winnable for x if any continuation of of less than or equal to n boards results in a win for x and is not winnable or drawable for .
Let us assume that
,
, and
x is the player whose turn it is to play on the tail of
and
is unfinished (i.e.,
). Let
be the G-numbers of game epochs strictly between
t and
, where
, and
, where
and
are the largest numbers less than
obtained in even increments from
and
, respectively. G-number
contains the numbers of epochs, where
plays and
x can win, draw, or hang, and
contains the numbers of epochs where
x plays and
can win, draw, or hang.
The primitive recursive predicate
holds if
x wins every continuation
of
within
n moves and the primitive recursive predicate
holds if every continuation
of
within
n moves is a hang for
.
The primitive recursive predicate
holds if
is absolutely winnable for
x within
n moves.
Is it pr-decidable if x can win or draw from its tail within the next n moves while cannot win under any sequence of moves less than or equal to n? If is such a game, we call it favorable for x.
We define the primitive recursive predicate
to hold if
x wins or draws in every continuation
of
within
n moves and define the primitive recursive predicate
to hold if every continuation
of
within
n moves is a hang for
.
The primitive recursive predicate
holds if
is favorable for
x within
n moves in that in any continuation
of
within the next
n moves
x wins or draws whereas
hangs.
Is it pr-decidable whether neither x nor can win or draw within the next n moves from the tail of ? In other words, is any continuation of within the next n moves from its tail is a hang? If that it the case, let us refer to as an absolute hang or absolutely unfinishable.
The primitive recursive predicate
holds if
x hangs in every continuation
of
within
n moves, and the primitive recursive predicate
holds if every continuation
of
within
n moves is a hang for
.
The primitive recursive predicate
holds if
is unfinishable for
x and
within
n moves.
We summarize the above arguments in the following lemma.
Lemma 7. Let , , be a hang and x be the player whose turn it is to play on . If n be an odd positive integer, then it is pr-decidable whether is absolutely winnable for x within n moves, is favorable for x within n moves, or is an absolute hang for x (and ) within n moves.
Before we leave this section, we summarize our findings in the following lemma.
Lemma 8. The following characteristics of chess are pr-decidable: board validity, checkmate, stalemate, draw, potential and actual reachability, game winnability, drawability, and unfinishability within the next n moves, absolute game winnability and unfinishability within the next n moves and game favorability within the next n moves, where n is a positive odd integer.
5. Procedures
Suppose
,
, and the player
x is to play on the tail of
. Is an optimal continuation of
for
x within
n moves pr-computable for some positive odd
n? An optimal continuation may be the continuation of 0 moves (i.e., resignation), which is the only rational decision in the absence of any wins or draws. Lemma 8 suggests a host of primitive recursive procedures for
x to find an optimal continuation including the resignation. If
is true, then let
be the pr-computable G-number of winnable games for
x within
n moves, which, since
is absolutely winnable, includes all continuations of
within
n moves. The next move from
can be arbitrarily chosen for
x to play (e.g.,
. Alternatively, the minimalization can be used to find the index of
such that
Since the above predicate is primitive recursive, so is its minimalization. If
is the shortest absolutely winnable game found through the minimalization of the above primitive recursive predicate, the next move is chosen as
If
but
, then let
Since
is favorable, all continuations of
within the next
n moves will be in
or
. If
,
x uses the minimalization to find the shortest continuation in
as outlined above and selects the next move from that continuation. If
, then all continuations of
are draws for
x within the next
n moves, and
x can choose the next move from the shortest continuation in
. If
but
, then
x chooses the next move from the shortest
z in
What if
? In this case,
is
absolutely losable or an
absolute loss for
x within
n moves. The primitive recursive predicate
holds when
is absolutely losable for
x within the next
n moves. In this case, the concept of lookahead (i.e.,
moves ahead for some positive even number
m) can be applied and the above primitive recursive steps of computing
,
, and
repeated so long as
, where
K is some arbibrary large positive odd integer. Taking
should suffice in light of the fact that the longest game so far in the history of chess took 269 moves to complete and lasted 20 h and 15 min [
8]. If
remains absolutely losable for
x within the next
K moves,
x resigns.
What if (i.e., there are absolute hangs)? We can use the same incremental lookahead method to determine if any is absolutely winnable or favorable for x within the next K moves. If there is an absolutely winnable game, x plays the first move of that game. If there is a favorable game, x plays the first move of that game.
If there are no absolutely winnable or favorable games within the next K moves for any game in , it must be decided for x which unfinishable game in to choose. One possible pr-computable procedure is to choose a continuation of in for which the counts of the pieces for each board of are equal. If there is such a game, x plays its first move.
Another, more flexible, pr-computable procedure is to assign an arbitrary value (a positive integer) to each piece: 2 to a pawn, 3 to a knight and a bishop, 5 to a rook, 7 to a queen and compute the value of each board for player x as the sum of x’s pieces on the board. Then a continuation of is chosen where each board from the tail of to the tail of has the same value for x and or the difference in the values does not exceed an arbitrarily chosen number. In general, any decision procedure or a utility function that is built from primitive recursive functions and predicates that compute properties of G-numbers will be primitive recursive.
The above discussion furnishes us with the following theorem and a corollary.
Theorem 1. Let , , be a hang and x be the player whose turn it is to play on and let K be a large positive odd integer. Then there exist pr-computable procedures to compute optimal continuations of for x and to decide if is absolutely losable for x within the next M moves.
Corollary 1. Absolute losability of a chess game is a pr-decidable characteristic.
6. Discussion
In the AI game playing literature (e.g., [
9,
10]), game engines are functions computed by programs that can play specific games by generating legal moves against humans or other programs with varying degrees of success. These programs almost never compute total functions, because they are based on search control heuristics (e.g., A*, minimax, alpha-beta pruning, etc.). Thus, even when their inputs and outputs can be represented as natural numbers with a rigorous Gödel numbering scheme, they can be construed only as partially computable functions. Furthermore, programs that play games with difficult combinatorics (chess, checkers, Go, etc.) break the fundamental tenet of classical computability in Rogers’ quote from [
4] in
Section 1, because, to be efficient, they must estimate, ahead of computation, how long the decision making process takes and heuristically prune continuations.
In the classification of Barr and Feigenbaum [
9], D2PBGs are games that can be represented with AND/OR trees. Specifically, Barr and Feigenbaum write that
‘‘[a]t each turn, the rules define both what moves are legal
and the effect that each possible move will have; there is
no element of chance. In contrast to card games in which the
players’ hands are hidden, each player has complete information
about his opponent’s position, including the choices open to
him and the moves he has made. The game begins from a specified
state, often a configuration of men on a board. It ends in a
win for one player and a loss for the other, or possibly in
a draw.’’
Russell and Norvig [
10] characterize chess as “a game of perfect information”, because “the agent can perceive everything there is to know about the environment”. In our opinion, Russell and Norvig’s definition is less precise than Barr and Feigenbaum’s, because it appears to separate computation and perception. If perception is not computation, then AI D2PBG engines fall outside of the scope of classical computability. If perception is computation, many such engines are partially computable functions, because they are not total due to heuristic pruning.
AND/OR game trees can be searched with minimax [
9]. If in a chess engine both players use minimax on the complete AND/OR game tree, which is feasible only in theory, and if the board evaluation function applied to each tree node by each player is primitive recursive, then the engine is a primitive recursive function by Lemma 8 and the
Section 5 theorem. However, if the board evaluation function in minimax is
not primitive recursive (e.g., if it is computable but not primitive recursive or partially computable), then the engine is not primitive recursive.
What if we put aside heuristic search control (e.g., minimax) and consider a chess game engine that uses an artificial or convolutional neural network (ANN or ConvNet) (e.g., [
11])? In this case, the chess engine computes a primitive recursive function if and only if the synapse weights are natural numbers, which is never the case in the state-of-the-art ANNs or ConvNets that play such games as chess and Go. They are deep multi-layer networks where each weight is a real number (typically, but not always, between 0 and 1). But, since there are uncountably many reals between 0 and 1 or in any interval defined by two distinct real numbers, it is impossible to generate network states with primitive recursion. Consequently, if the chess engine is a ANN/ConvNet, then the engine may be computable, but not primitive recursive. Of course, even the computability of the engine depends on whether, in addition to representing inputs and outputs as natural numbers, we are able to show that the engine computes a total function.
Any characteristic of a D2PBG game with a finite history (e.g., Tic Tac Toe) is pr-decidable and pr-computable in the sense that the entire game history is a G-number and an optimal sequence of moves for either player can be found using number-theoretic methods from an arbitrary board within that number.
A D2PBG all of whose boards can be calculated in a primitive recursive fashion within the next K moves for some arbitrarily large number K (with the magnitude of K dependent on the rules of the game) is pr-decidable for K in the sense that for either player it is possible to decide in a primitive recursive fashion whether an unfinished game is absolutely winnable, favorable, or absolutely losable within K moves. If a game is absolutely unfinishable within the next K moves, then there exist primitive recursive calculation procedures to choose the next move and in that sense (and that sense only) chess is pr-computable.
As we showed in this article, some characteristics of chess are pr-computable. Any characteristic of the chess board (and, in general, a board in a D2PBG) represented as a G-number that can be decided by a primitive recursive predicate through primitive recursive number-theoretic methods is pr-decidable. Since sequences of boards can be combined into G-numbers as games, any characteristic of the G-number of a game that can be calculated through primitive recursive number-theoretic methods is pr-computable and pr-decidable.
The following questions remain open with respect to chess as a D2PBG:
Is chess a D2PBG with a finite history? In other words, is there
such that
? (See Equation (
79)).
Are there computable decision procedures for player x that are not primitive recursive and that guarantee for x to win or draw an unfinished game if uses only primitive recursive decision procedures?
Are there games that x cannot lose when x uses only primitive recursive decision procedures while uses computable decision procedures that are not primitive recursive?