Next Article in Journal
Rational Degree of Belief Ceases to Be Additive When the Dutch Book Argument Is Transported to a New Environment
Previous Article in Journal
Estimation of the Generalized Logarithmic Transformation Exponential Distribution under Progressively Type-II Censored Data with Application to the COVID-19 Mortality Rates
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

On Primitive Recursive Characteristics of Chess

by
Vladimir Kulyukin
Department of Computer Science, Utah State University, Logan, UT 84322, USA
Mathematics 2022, 10(7), 1016; https://doi.org/10.3390/math10071016
Submission received: 12 February 2022 / Revised: 15 March 2022 / Accepted: 15 March 2022 / Published: 22 March 2022

Abstract

:
Several characteristics of chess are investigated with methods of computability and number theories. It is shown that for an unfinished game it is primitive recursively decidable whether the game is winnable, drawable, or absolutely losable within a specified number of future moves for the player whose turn it is to play on the last board of the game. It is also shown that there exist primitive recursive procedures to compute optimal continuations of unfinished games within specified numbers of future moves and that the set of chess games is recursive.

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 O ( n 3 ) 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 N = { 0 , 1 , 2 , } . 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 N j to N k (i.e., N j N k ), where j and k are positive numbers. We use the symbol ≡ to define predicates (e.g., P ( x 1 , x 2 ) x 1 < x 2 ). We use the capital letter P with prime superscripts (e.g., P ) 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 P ( · ) or F ( · ) for brevity. For example, P ( · ) instead of P ( x 1 , x 2 ) and F ( · ) instead of F ( x 1 , x 2 , x 3 ) .
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 z = 10 and let P ( d ) 2 d | ( z + 1 ) . In this definition of P ( · ) , z refers to number 10.
In defining some predicates, we occasionally abbreviate Boolean combinations of numerical predicates. For example, i j j k is abbreviated as i j k ; i j j k as i j k ; i = j j = k as i = j = k , 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 f ( x 1 , , x k ) be a function and g 1 , , g k be functions, where each g i , 1 i k , is a function of n arguments. Then h ( x 1 , , x n ) is obtained by composition from f , g 1 , , g k if
h ( x 1 , , x n ) = f ( g 1 ( x 1 , , x n ) , , g k ( x 1 , , x n ) ) .
Let k N and ϕ ( x , y ) : N 2 N be total. Let f ( x 1 , , x n ) : N n N and g ( x 1 , , x n + 2 ) : N n + 2 N 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.
h ( 0 ) = k , h ( t + 1 ) = ϕ ( t , h ( t ) )
h ( x 1 , , x n , 0 ) = f ( x 1 , , x n ) , h ( x 1 , , x n , t + 1 ) = g ( t , h ( x 1 , , x n , t ) , x 1 , , x n )
Let
s ( x ) = x + 1 ; n ( x ) = 0 ; u i n ( x 1 , · · · , x n ) = x i , 1 i n ,
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 P ( x 1 , , x n ) is a predicate if for any n numbers y 1 , , y n   P ( y 1 , , y n ) = 1 or P ( y 1 , , y n ) = 0 , where 1 designates true and 0 false. The expression ( t ) z is a bounded existential quantifier so that if P ( t , x 1 , , x n ) is a predicate, ( t ) z P ( t , x 1 , , x n ) = 1 , if P ( t , x 1 , , x n ) = 1 , for at least one t such that 0 t z . The expression ( t ) z P ( t , x 1 , , x n ) is called the bounded existential quantification of P ( · ) .
The expression ( t ) z is a bounded universal quantifier so that, if P ( t , x 1 , , x n ) is a predicate, then ( t ) z P ( t , x 1 , , x n ) = 1 , if P ( t , x 1 , , x n ) = 1 , for every t such that 0 t z . The expression ( t ) z P ( t , x 1 , , x n ) is called the bounded universal quantification of P ( · ) .
If P ( t , x 1 , , x n ) is a predicate and z is a number, then
y = min t z P ( t , x 1 , , x n )
is called the bounded minimalization of P ( · ) and defines the smallest number 0 t z for which the predicate P ( · ) is true or 0 if there is no such number. If
min t z P ( t , x 1 , , x n ) = 0
and P ( 0 , x 1 , , x n ) = 1 , then 0 returned by the bounded minimalization of P ( · ) is the smallest number z for which P ( · ) holds. If P ( 0 , x 1 , , x n ) = 0 , then 0 returned by the minimalization of P ( · ) means that there is no number 0 t z , for which P ( t , x 1 , , x n ) holds. If this additional check on 0 must be avoided in a given context, t in the minimalized predicate P ( · ) must be required to be greater than 0 (e.g., P ( t , x 1 , x 2 ) t x 1 · x 2 t > 0 ), in which case, 0 returned by the minimalization of P ( · ) means that there is no 0 t z for which P ( · ) holds. The operator min is similar to Kleene’s operator μ [3]. If P ( x 1 , , x n ) is a n-ary predicate, we occasionally write P ( x 1 , , x n ) to abbreviate P ( x 1 , , x n ) = 1 and write ¬ P ( x 1 , , x n ) to abbreviate P ( x 1 , , x n ) = 0 .
It is shown in [5] that 1) the predicates x = y , x y , x < y , x > y , x y , x y , and x | y (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 P ( · ) is primitive recursive, then so are its negation and its bounded minimalization and bounded universal and existential quantifications. We will use the notation x y to denote ¬ { x | y } (i.e., x does not divide y or x is not a divisor of y).
Let x y = xy , i f x ≥ 0, and xy = 0 , if x < y. Thefunction xy is shown to be primitive recursive in [5]. Let the pairing of numbers x and y be defined as
x , y = z ,
where
z = 2 x ( 2 y + 1 ) 1 γ ( d ) { 2 d | ( z + 1 ) ( c ) ( z + 1 ) { 2 c ( z + 1 ) c d } } ; x = min d z + 1 γ ( d ) ; y = 1 2 ( z + 1 2 x 1 ) .
The minimalization of the primitive recursive predicate γ ( · ) above makes x the largest number such that 2 x | ( z + 1 ) . As shown in [5], for any number z, there are unique x and y such that x , y = z and the pairing function x , y is primitive recursive. For example, if z = 27 , then
x = min d 28 γ ( d ) = 2 ; y = 1 2 ( 28 2 2 1 ) = 3 ; 2 , 3 = 2 2 ( 2 · 3 + 1 ) 1 = 27 .
Let the functions l ( z ) and r ( z ) in (6) return the left and right components of any number z. Since the predicate z = x , y is primitive recursive, both
l ( z ) = min x z { ( y ) z { z = x , y } } r ( z ) = min y z { ( x ) z { z = x , y } }
are primitive recursive, because they are bounded minimalizations of the bounded existential quanitifcations of primitive recursive predicates. Thus, if z = 27 = 2 , 3 , then l ( z ) = 2 , r ( z ) = 3 , and, in general, l ( z ) , r ( z ) = z for any number z.
Let p n be the n-th prime so that p 1 = 2 , p 2 = 3 , p 3 = 5 , etc. Let p 0 = 0 , by default. In [5], p n is shown to be computed by a primitive recursive function, which we define as
π ( i ) = p i .
Thus, π ( 0 ) = 0 , π ( 1 ) = 2 , π ( 2 ) = 3 , π ( 3 ) = 5 , π ( 4 ) = 7 , π ( 5 ) = 11 , etc.
Let ( a 1 , , a n ) be a sequence of numbers. The function in (8) computes the Gödel number (G-number) of this sequence.
[ a 1 , , a n ] = i = 1 n π ( i ) a i
The function [ a 1 , , a n ] is shown to be primitive recursive in [5], because x · y , x y , π ( i ) 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 ( 3 , 101 , 7891 , 1 , 43 ) is
[ 3 , 101 , 7891 , 1 , 43 ] = 2 3 · 3 101 · 5 7891 · 7 1 · 11 43 .
Let x = [ a 1 , , a n ] . The accessor function ( x ) i = a i in (9), which returns the i-th element of x, is shown to be primitive recursive in [5].
( x ) i = min t x { π ( i ) t + 1 x }
The function ( x ) i allows us to treat G-numbers as arrays (i.e., sequences of numbers). Thus, if x = [ 1 , 7 , 13 ] , then
( x ) 1 = 1 ; ( x ) 2 = 7 ; ( x ) 3 = 13 ; ( x ) j = 0 , if j > 3 .
Since G-numbers are sequences, they have lengths. Thus, if x = [ a 1 , a 2 , , a n ] , the length of x is the position of the last non-zero prime power in x and is computed by the primitive recursive function L t ( · ) in (10). We note that L t ( [ a 1 , , a n ] ) = n if and only if a n 0 , and if L t ( x ) = n , then [ ( x ) 1 , , ( x ) n ] = x .
L t ( x ) = min i x { ( x ) i 0 ( j ) x { j i ( x ) j = 0 } }
Thus,
L t ( 540 ) = L t ( [ 2 , 3 , 1 ] ) = 3 .
The function x / y that returns the integer part of the quotient x / y is shown to be primitive recursive in [5]. Thus, 7 / 2 = 3 ; 2 / 5 = 0 ; 8 / 5 = 1 , and x / 0 = 0 for any number x.

3. G-Number Operators

In this section, we define several primitive recursive functions on G-numbers. We call these functions G-number operators and use them in Section 4 to show that several characteristics of chess and are pr-decidable and pr-computable.

3.1. Assignment

Let
P 0 ( i , b ) 1 i L t ( b ) b 1 .
The function
s e t ( b , i , v ) = b π ( i ) ( b ) i · π ( i ) v if P 0 ( i , b ) , 0 otherwise
assigns the value of the i-th element of b to v. By Theorem 5.4 (the Definition by Cases Theorem) of Chapter 3 in [5] (which we henceforth abbreviate as the DCT), s e t ( · ) in (11) is primitive recursive, because P 0 ( · ) is primitive recursive. Thus, if b = [ 1 , 2 ] = 2 1 3 2 = 18 , i = 1 , and v = 3 , then
s e t ( [ 1 , 2 ] , 1 , 3 ) = b π ( 1 ) ( b ) 1 · π ( 1 ) 3 =
[ 1 , 2 ] 2 ( [ 1 , 2 ] ) 1 · 2 3 = 2 1 · 3 2 2 1 · 2 3 = [ 3 , 2 ] = 72
or, more succinctly,
s e t ( 18 , 1 , 3 ) = 72 .
If b = 72 , i = 2 , and v = 4 , then
s e t ( 72 , 2 , 4 ) = 648 ,
because
s e t ( s e t ( 18 , 1 , 3 ) , 2 , 4 ) = s e t ( 72 , 2 , 4 ) =
72 3 2 · 3 4 = [ 3 , 4 ] = 648 .
If b = [ 2 , 3 , 5 , 8 , 13 ] i = 5 , v = 21 , then
s e t ( b , 5 , 21 ) = b 11 13 11 21 = [ 2 , 3 , 5 , 8 , 21 ] = 14398076794131917643247179978712500
or, more succinctly,
s e t ( 67168090852890380796712500 , 5 , 21 ) = 14398076794131917643247179978712500 .

3.2. Count

Let
c n t x ( x , y , 0 ) = 0 , c n t x ( x , y , t + 1 ) = F 0 ( x , y , t , c n t x ( x , y , t ) ) ,
where
F 0 ( x , y , t , c ) = 1 + c if ( y ) s ( t ) = x , c otherwise .
The function F 0 ( · ) is primitive recursive by the DCT. Therefore, the function c n t x ( · ) is primitive recursive, because it is obtained from s ( x ) and F 0 ( · ) by composition and recursion. The function c n t ( · ) in (12) to compute the count of occurrences of x in y is also primitive, because it is obtained by composition from c n t x ( · ) and L t ( x ) .
c n t ( x , y ) = c n t x ( x , y , L t ( y ) )
Let y = 30,870 = [1, 2, 1, 3]. Then
c n t ( 1 , y ) = c n t x ( 1 , y , 4 ) = F 0 ( 1 , y , 3 , c n t x ( 1 , y , 3 ) ) ; c n t x ( 1 , y , 3 ) = F 0 ( 1 , y , 2 , c n t x ( 1 , y , 2 ) ) ; c n t x ( 1 , y , 2 ) = F 0 ( 1 , y , 1 , c n t x ( 1 , y , 1 ) ) ; c n t x ( 1 , y , 1 ) = F 0 ( 1 , y , 0 , c n t x ( 1 , y , 0 ) ) ; c n t x ( 1 , y , 0 ) = 0 ; F 0 ( 1 , y , 0 , 0 ) = 1 , since ( y ) s ( 0 ) = 1 ; c n t x ( 1 , y , 1 ) = F 0 ( 1 , y , 0 , 0 ) = 1 ; F 0 ( 1 , y , 1 , 1 ) = 1 , since ( y ) s ( 1 ) 1 ; c n t x ( 1 , y , 2 ) = F 0 ( 1 , y , 1 , 1 ) = 1 ; F 0 ( 1 , y , 2 , 1 ) = 2 , since ( y ) s ( 2 ) = 1 ; c n t x ( 1 , y , 3 ) = F 0 ( 1 , y , 2 , 1 ) = 2 ; F 0 ( 1 , y , 3 , 2 ) = 2 , since ( y ) s ( 3 ) 1 ; c n t x ( 1 , y , 4 ) = F 0 ( 1 , y , 3 , 2 ) = 2 ; c o u n t ( 1 , y ) = 2 .
Analogously,
c n t ( 2 , y ) = c n t ( 3 , y ) = 1 ; c n t ( 10 , y ) = 0 .
Let
i n ( x , y ) c n t ( x , y ) 0 x y .
Thus,
1 30870 ; 2 30870 ; 3 30870 ; 10 30870 .
Let k y and let P ( x 1 , , x n ) , n 1 , be an n-ary predicate. We will adopt the following notational conventions for bounded quantifiers:
( k y ) P ( k , , x n ) ( t ) L t ( y ) { t < 1 P ( ( y ) t , , x n ) } ; ( k y ) P ( k , , x n ) ( t ) L t ( y ) { t > 0 P ( ( y ) t , , x n ) } .
Thus, if y = [ 1 , 2 , 3 , 4 ] and P ( x 1 , x 2 ) x 1 < x 2 , then
( k y ) { P ( k , 5 ) } = ( k y ) { P ( k , 2 ) } = 1 ,
whereas
( k y ) { P ( k , 3 ) } = ( k y ) { P ( k , 1 ) } = 0 .

3.3. Append

The function
r a p ( x , y ) = [ x ] if L t ( y ) = 0 , y · π ( L t ( y ) + 1 ) x otherwise
appends x to the right of the rightmost element of y. By the DCT, the function r a p ( · ) in (15) is primitive recursive, because x · y , L t ( y ) , x y , π ( x ) , and x y are. Thus,
r a p ( 1 , 0 ) = r a p ( 1 , 1 ) = π ( 1 ) = [ 1 ] ; r a p ( 1 , [ 1 ] ) = r a p ( 1 , 2 ) = 2 · π ( L t ( 2 ) + 1 ) 1 = 2 · π ( 2 ) 1 = 2 · 3 1 = 6 = [ 1 , 1 ] ; r a p ( 8 , [ 2 , 3 , 5 ] ) = [ 2 , 3 , 5 ] · π ( 4 ) 8 = [ 2 , 3 , 5 , 8 ] ; r a p ( 5 , s e t ( [ 0 , 3 ] , 1 , 2 ) ) = [ 2 , 3 , 5 ] .
More succinctly,
r a p ( 1 , 0 ) = r a p ( 1 , 1 ) = 2 ; r a p ( 1 , 2 ) = 6 ; r a p ( 8 , 337500 ) = 1945620337500 ; r a p ( 5 , s e t ( 27 , 1 , 2 ) ) = r a p ( 5 , 108 ) = 337500 .

3.4. Concatenation

Let
l c ( x 1 , x 2 , 0 ) = x 2 , l c ( x 1 , x 2 , t + 1 ) = F 1 ( x 1 , t , l c ( x 1 , x 2 , t ) ) ,
where
F 1 ( x , t , y ) = r a p ( ( x ) s ( t ) , y ) .
The function l c ( · ) is primitive recursive by definition. The function
x 1 l x 2 = l c ( x 1 , x 2 , L t ( x 1 ) ) ,
which is also primitive recursive by definition, places all numbers in x 2 , in order, to the left of the first number, if there is one, in x 1 . We refer to the binary function in (16) as left concatenation. Thus,
0 l x = 1 l x = x .
If x 1 = 2 = [ 1 ] and x 2 = 4 = [ 2 ] , then
2 l 4 = [ 1 ] l [ 2 ] = [ 2 , 1 ] = 12 ,
because
[ 1 ] l [ 2 ] = l c ( [ 1 ] , [ 2 ] , L t ( [ 1 ] ) ) = l c ( [ 1 ] , [ 2 ] , 1 ) = F 1 ( [ 1 ] , 0 , l c ( [ 1 ] , [ 2 ] , 0 ) ) = F 1 ( [ 1 ] , 0 , [ 2 ] ) ) = r a p ( ( [ 1 ] ) s ( 0 ) , [ 2 ] ) = r a p ( ( [ 1 ] ) 1 , [ 2 ] ) = r a p ( 1 , [ 2 ] ) = [ 2 , 1 ] .
We also have
[ 2 , 3 ] l [ 1 ] = [ 1 , 2 , 3 ] .
To compute [ 3 , 4 , 5 ] l [ 1 , 2 ] , we compute
l c ( [ 3 , 4 , 5 ] , [ 1 , 2 ] , 1 ) = F 1 ( [ 3 , 4 , 5 ] , 0 , l c ( [ 3 , 4 , 5 ] , [ 1 , 2 ] , 0 ) = F 1 ( [ 3 , 4 , 5 ] , 0 , [ 1 , 2 ] ) = r a p ( ( [ 3 , 4 , 5 ] ) s ( 0 ) , [ 1 , 2 ] ) = [ 1 , 2 , 3 ]
and, hence,
l c ( [ 3 , 4 , 5 ] , [ 1 , 2 ] , 2 ) = F 1 ( [ 3 , 4 , 5 ] , 1 , l c ( [ 3 , 4 , 5 ] , [ 1 , 2 ] , 1 ) = F 1 ( [ 3 , 4 , 5 ] , 1 , [ 1 , 2 , 3 ] ) = r a p ( ( [ 3 , 4 , 5 ] ) s ( 1 ) , [ 1 , 2 , 3 ] ) = [ 1 , 2 , 3 , 4 ] ,
which gives us
[ 3 , 4 , 5 ] l [ 1 , 2 ] = l c ( [ 3 , 4 , 5 ] , [ 1 , 2 ] , L t ( [ 3 , 4 , 5 ] ) ) = l c ( [ 3 , 4 , 5 ] , [ 1 , 2 ] , 3 ) = F 1 ( [ 3 , 4 , 5 ] , 2 , l c ( [ 3 , 4 , 5 ] , [ 1 , 2 ] , 2 ) ) = F 1 ( [ 3 , 4 , 5 ] , 2 , [ 1 , 2 , 3 , 4 ] ) = r a p ( ( [ 3 , 4 , 5 ] ) s ( 2 ) , [ 1 , 2 , 3 , 4 ] ) = [ 1 , 2 , 3 , 4 , 5 ]
or, more succinctly,
2025000 l 18 = 870037764750 .
Let
F 2 ( x ) = 0 if L t ( x ) = 0 , [ ( x ) 1 ] if L t ( x ) = 1 , F 3 ( x , L t ( x ) 2 ) if L t ( x ) > 1 ,
where
F 3 ( x , 0 ) = ( x ) L t ( x ) 1 l ( x ) L t ( x )
F3(x, t + 1) = (x)s(t)l F3(x, t).
Since F 3 ( · ) is primitive recursive by definition and F 2 ( · ) is primitive recursive by the DCT, the left concatenation of x 1 , , x k , k 1 , in (17) is primitive recursive.
l | i = 1 k x i = F 2 ( [ x 1 , , x k ] )
Thus, if x 1 = [ 3 , 4 , 5 ] , x 2 = [ 1 , 2 ] , x 3 = [ 10 , 11 ] , then
l | i = 1 3 x i = F 2 ( [ x 1 , x 2 , x 3 ] ) = F 3 ( [ x 1 , x 2 , x 3 ] , 1 ) = x 1 l F 3 ( [ x 1 , x 2 , x 3 ] , 0 ) = x 1 l ( x 2 l x 3 ) = x 1 l [ 10 , 11 , 1 , 2 ] = [ 10 , 11 , 1 , 2 , 3 , 4 , 5 ] = 2398810352874712857400320 .
In general,
l | i = 1 k x i = x 1 l x 2 l l x k = ( ( ( x 1 l x 2 ) l l x k ) ) = ( ( x 1 l ( x 2 l ( l ( x k 1 l x k ) ) ) ) ) .
The primitive recursive function to do the right concatenation of x 1 and x 2 (i.e., the operation of placing all numbers of x 2 , in order, to the right of the rightmost number in x 1 ) is defined in (19).
x 1 r x 2 = x 2 l x 1
Thus,
[ 1 ] r [ 2 ] = [ 2 ] l [ 1 ] = [ 1 , 2 ] ; [ 2 , 3 ] r [ 1 ] = [ 1 ] l [ 2 , 3 ] = [ 2 , 3 , 1 ] ; [ 3 , 4 , 5 ] r [ 1 , 2 ] = [ 1 , 2 ] l [ 3 , 4 , 5 ] = [ 3 , 4 , 5 , 1 , 2 ] .
The right concatenation of any numbers x 1 , , x k in (20) is primitive recursive, because it is a composition of two primitive recursive functions.
r | i = 1 k x i = F 2 ( [ x k , , x 1 ] )
Let x 1 = [ 3 , 4 , 5 ] , x 2 = [ 1 , 2 ] , x 3 = [ 10 , 11 ] . Then
r | i = 1 3 x i = F 2 ( [ x 3 , x 2 , x 1 ] ) = F 3 ( [ x 3 , x 2 , x 1 ] , 1 ) = x 3 l F 3 ( [ x 3 , x 2 , x 1 ] , 0 ) = x 3 l ( x 2 l x 1 ) = x 3 l [ 3 , 4 , 5 , 1 , 2 ] = [ 3 , 4 , 5 , 1 , 2 , 10 , 11 ] .
In general,
r | i = 1 k x i = x 1 r x 2 r r x k = ( ( ( x 1 r x 2 ) r r x k ) ) = ( ( x 1 r ( x 2 r ( r ( x k 1 r x k ) ) ) ) ) .
We will use the notation r | i g , for G-number g, to denote the right concatenation of the elements indexed from ( g ) 1 to ( g ) L t ( g ) in increments of 1. Thus, if g = [ 1 , 2 , 3 ] and x 1 = [ 3 , 4 , 5 ] , x 2 = [ 1 , 2 ] , x 3 = [ 10 , 11 ] , then
l | i g x i = l | i = 1 3 x i = [ 10 , 11 , 1 , 2 , 3 , 4 , 5 ] ; r | i g x i = r | i = 1 3 x i = [ 3 , 4 , 5 , 1 , 2 , 10 , 11 ] .

3.5. G-Number Generator

Let
g n x ( l , u , k , 0 ) = [ l ] , g n x ( l , u , k , t + 1 ) = g n n x ( l , u , k , g n x ( l , u , k , t ) , t ) ,
where
g n n x ( l , u , k , z , t ) = z r [ l + s ( t ) k ] if l + s ( t ) k u , z otherwise .
Since g n n x ( · ) is primitive recursive by the DCT, so is g n x ( · ) . Let
g g n ( l , u , k ) = g n x ( l , u , k , s ( u l ) ) if k > 0 l u , 0 otherwise .
The function g g n ( · ) is primitive recursive by the DCT. Thus, if we want to generate the G-number whose elements are in the range from 5 to 7 and the range is iterated through in increments of 1, we have
g g n ( 5 , 7 , 1 ) = g n x ( 5 , 7 , 1 , 3 ) = g n n x ( 5 , 7 , 1 , g n x ( 5 , 7 , 1 , 2 ) , 2 ) ; g n x ( 5 , 7 , 1 , 2 ) = g n n x ( 5 , 7 , 1 , g n x ( 5 , 7 , 1 , 1 ) , 1 ) ; g n x ( 5 , 7 , 1 , 1 ) = g n n x ( 5 , 7 , 1 , g n x ( 5 , 7 , 1 , 0 ) , 0 ) ; g n x ( 5 , 7 , 1 , 0 ) = [ 5 ] ; g n n x ( 5 , 7 , 1 , g n x ( 5 , 7 , 1 , 0 ) , 0 ) = g n n x ( 5 , 7 , 1 , [ 5 ] , 0 ) = [ 5 ] r [ 5 + 1 · 1 ] = [ 5 ] r [ 6 ] = [ 5 , 6 ] ; g n x ( 5 , 7 , 1 , 1 ) = [ 5 , 6 ] ; g n x ( 5 , 7 , 1 , 2 ) = g n n x ( 5 , 7 , 1 , [ 5 , 6 ] , 1 ) = [ 5 , 6 ] r [ 5 + 2 · 1 ] = [ 5 , 6 ] r [ 7 ] = [ 5 , 6 , 7 ] ; g n n x ( 5 , 7 , 1 , [ 5 , 6 , 7 ] , 2 ) = [ 5 , 6 , 7 ] ; g n x ( 5 , 7 , 1 , 3 ) = [ 5 , 6 , 7 ] ; g g n ( 5 , 7 , 1 ) = [ 5 , 6 , 7 ] .
If we want to generate the G-number whose elements are in the range from 5 to 7 iterated through in increments of 2, we have
g g n ( 5 , 7 , 2 ) = g n x ( 5 , 7 , 2 , 3 ) = g n n x ( 5 , 7 , 2 , g n x ( 5 , 7 , 2 , 2 ) , 2 ) ; g n x ( 5 , 7 , 2 , 2 ) = g n n x ( 5 , 7 , 2 , g n x ( 5 , 7 , 2 , 1 ) , 1 ) ; g n x ( 5 , 7 , 2 , 1 ) = g n n x ( 5 , 7 , 2 , g n x ( 5 , 7 , 2 , 0 ) , 0 ) ; g n x ( 5 , 7 , 2 , 0 ) = [ 5 ] ; g n n x ( 5 , 7 , 2 , g n x ( 5 , 7 , 2 , 0 ) , 0 ) = g n n x ( 5 , 7 , 2 , [ 5 ] , 0 ) = [ 5 ] r [ 5 + 1 · 2 ] = [ 5 ] r [ 7 ] = [ 5 , 7 ] ; g n x ( 5 , 7 , 2 , 1 ) = [ 5 , 7 ] ; g n x ( 5 , 7 , 2 , 2 ) = g n n x ( 5 , 7 , 2 , [ 5 , 7 ] , 1 ) = [ 5 , 7 ] ; g n n x ( 5 , 7 , 2 , [ 5 , 7 ] , 2 ) = [ 5 , 7 ] ; g n x ( 5 , 7 , 2 , 3 ) = [ 5 , 7 ] ; g g n ( 5 , 7 , 2 ) = [ 5 , 7 ] .
We observe that g g n ( 5 , 7 , k ) = 0 for any k > 2 . If u = l and k > 0 , then g g n ( l , u , k ) = [ l ] .

3.6. Subsequence

The function s s q ( · ) in (23) returns the subsequence of G-number z specified by its start and end positions i and j in z.
s s q ( z , i , j ) = k = i j π ( k ) ( z ) k if 0 < i j L t ( z ) , 0 otherwise .
Thus, if z = [ 1 , 2 , 3 , 4 , 5 ] , then
s s q ( z , 1 , 3 ) = k = 1 3 π ( k ) ( z ) k = [ 1 , 2 , 3 ]
and
s s q ( z , 4 , 5 ) = k = 4 5 π ( k ) ( z ) k = [ 4 , 5 ] .

3.7. Removal

Let
r m x ( x , y , 0 ) = [ ] , r m x ( x , y , t + 1 ) = F 4 ( x , y , r m x ( x , y , t ) , s ( t ) ) ,
where
F 4 ( x , y , z , i ) = z if ( y ) i = x , i ] l z otherwise .
Since F 4 ( · ) is primitive by the DCT, r m x ( · ) is also primitive recursive. The primitive recursive function r m ( x , y ) in (24) removes all occurrences of x from y.
r m ( x , y ) = r m x ( x , y , L t ( y ) )
Let y = [ 2 , 3 , 1 ] . Then
r m ( 1 , y ) = r m x ( 1 , y , 3 ) = F 4 ( 1 , y , r m x ( 1 , y , 2 ) , 3 ) = F 4 ( 1 , y , F 4 ( 1 , y , r m x ( 1 , y , 1 ) , 2 ) , 3 ) = F 4 ( 1 , y , F 4 ( 1 , y , F 4 ( 1 , y , r m x ( 1 , y , 0 ) , 1 ) , 2 ) , 3 ) = F 4 ( 1 , y , F 4 ( 1 , y , F 4 ( 1 , y , [ ] , 1 ) , 2 ) , 3 ) = F 4 ( 1 , y , F 4 ( 1 , y , [ 2 ] , 2 ) , 3 ) = F 4 ( 1 , y , [ 2 , 3 ] , 3 ) = [ 2 , 3 ] .
Let y = [ 5 , 1 , 2 , 3 , 2 ] . Then r m ( 2 , y ) = [ 5 , 1 , 3 ] .
Sometimes it is required to remove all duplicate elements from a G-number. Let
r m d x ( y , 0 ) = [ ] , r m d x ( y , t + 1 ) = F 5 ( y , r m d x ( y , t ) , s ( t ) ) ,
where
F 5 ( y , z , i ) = z r [ ( y ) i ] if ( y ) i z , z otherwise .
Since F 5 ( · ) is primitive recursive by the DCT, so is r m d x ( · ) . The primitive recursive function r m d ( x , y ) in (25) removes all duplicates from y.
r m d ( y ) = r m d x ( y , L t ( y ) )
Let y = [ 5 , 3 , 5 ] . Then
r m d ( y ) = r m d x ( y , 3 ) = F 5 ( y , r m d x ( y , 2 ) , 3 ) = F 5 ( y , F 5 ( y , r m d x ( y , 1 ) , 2 ) , 3 ) = F 5 ( y , F 5 ( y , F 5 ( y , r m d x ( y , 0 ) , 1 ) , 2 ) , 3 ) = F 5 ( y , F 5 ( y , F 5 ( y , [ ] , 1 ) , 2 ) , 3 ) = F 5 ( y , F 5 ( y , [ 5 ] , 2 ) , 3 ) = F 5 ( y , [ 5 , 3 ] , 3 ) = [ 5 , 3 ] .

3.8. Predicate Mapping

We define a function that takes a unary primitive recursive predicate P ( x ) and G-number y and returns another G-number y such that the elements of y are the elements of y that satisfy the predicate. Let P ( x ) be a primitive recursive predicate and let
m a p x P ( y , 0 ) = [ ] , m a p x P ( y , t + 1 ) = F 6 ( y , m a p x P ( y , t ) , s ( t ) ) ,
where
F 6 ( y , z , i ) = z if ¬ P ( ( y ) i ) , [ ( y ) i ] l z if P ( ( y ) i ) ,
and let
m a p P ( y ) = m a p x P ( y , L t ( y ) ) .
Since P ( x ) is primitive recursive, F 6 ( · ) is primitive recursive by the DCT. Thus, m a p P ( · ) is primitive recursive by definition for any unary primitive recursive predicate P ( x ) .
Let
p r i m e ( x ) x > 1 ( t ) x { t = 1 t = x t x } ,
which is shown to be primitive recursive in [5]. Let P ( x ) p r i m e ( x ) and y = [ 5 , 6 , 7 ] . Then
m a p P ( y ) = m a p x P ( y , L t ( y ) ) = m a p x P ( y , 3 ) = F 6 ( y , m a p x P ( y , 2 ) , 3 ) = F 6 ( y , F 6 ( y , m a p x P ( y , 1 ) , 2 ) , 3 ) = F 6 ( y , F 6 ( y , F 6 ( y , m a p x P ( y , 0 ) , 1 ) , 2 ) , 3 ) = F 6 ( y , F 6 ( y , F 6 ( y , [ ] , 1 ) , 2 ) , 3 ) = F 6 ( y , F 6 ( y , [ 5 ] , 2 ) , 3 ) = F 6 ( y , [ 5 ] , 3 ) = [ 5 , 7 ] .
As a notational shortcut, we will occasionally write the actual predicate in the subscript to m a p ( · ) (e.g., m a p p r i m e ( x ) ( y ) ). Thus, we can summarize the above example as
m a p P ( y ) = m a p p r i m e ( x ) ( y ) = [ 5 , 7 ] .
Similarly,
m a p x > 5 ( y ) = [ 6 , 7 ] .
If P ( x ) is a primitive recursive predicate, then so is ¬ P ( x ) . Consequently, m a p ¬ P ( y ) is the G-number that consists of all numbers x of y for which ¬ P ( x ) is true. Then the primitive recursive function
r m p P ( y ) = m a p ¬ P ( y )
removes from G-number y all elements x y for which P ( x ) holds. Thus, if P ( x ) p r i m e ( x ) and y = [ 3 , 5 , 6 , 7 ] , then
r m p P ( y ) = m a p ¬ p r i m e ( y ) = [ 6 ]
and
r m p x 5 ( y ) = m a p x < 5 ( y ) = [ 3 ] .

3.9. Position

Let
p s x ( x , y , 0 ) = [ ] , p s x ( x , y , t + 1 ) = F 7 ( x , y , p s x ( x , y , t ) , s ( t ) ) ,
where
F 7 ( x , y , z , i ) = [ i ] l z if ( y ) i = x , z otherwise .
Since ( y ) i is primitive recursive, F 7 ( · ) is primitive recursive by the DCT. Thus, p s x ( · ) is primitive recursive by definition. The primitive recursive function
p s n ( x , y ) = p s x ( x , y , L t ( y ) )
computes the G-number of all positions of x in y. Let x = 1 , y = [ 1 , 3 , 1 ] . Then
p s n ( 1 , y ) = p s x ( 1 , y , L t ( y ) ) = p s x ( 1 , y , 3 ) = F 7 ( 1 , y , p s x ( 1 , y , 2 ) , 3 ) = F 7 ( 1 , y , F 7 ( 1 , y , p s x ( 1 , y , 1 ) , 2 ) , 3 ) = F 7 ( 1 , y , F 7 ( 1 , y , F 7 ( 1 , y , p s x ( 1 , y , 0 ) , 1 ) , 2 ) , 3 ) = F 7 ( 1 , y , F 7 ( 1 , y , F 7 ( 1 , y , [ ] , 1 ) , 2 ) , 3 ) = F 7 ( 1 , y , F 7 ( 1 , y , [ 1 ] , 2 ) , 3 ) = F 7 ( 1 , y , [ 1 ] , 3 ) = [ 1 , 3 ] .
In general,
( t p s n ( x , y ) ) { ( y ) t = x } .

3.10. Association

Let the primitive recursive function
a s x ( x , y ) = min t L t ( y ) { t > 0 x = l ( ( y ) t ) }
return the smallest index t of i , j y such that x = i . Thus, if
y = [ 10 , 100 , 20 , 200 , 30 , 300 ] ,
then
a s x ( 10 , y ) = 1 ; a s x ( 20 , y ) = 2 ; a s x ( 30 , y ) = 3 .
We define the primitive recursive function
a s c ( x , y ) = ( y ) a s x ( x , y )
to return the pair from y at the index t returned by a s x ( · ) . Thus, if
y = [ 10 , 100 , 20 , 200 , 30 , 300 ] ,
then
a s c ( 10 , y ) = ( y ) a s x ( 10 , y ) = ( y ) 1 = 10 , 100 ; a s c ( 20 , y ) = ( y ) a s x ( 20 , y ) = ( y ) 2 = 20 , 200 ; a s c ( 30 , y ) = ( y ) a s x ( 30 , y ) = ( y ) 3 = 30 , 200 ; a s c ( 13 , y ) = ( y ) a s x ( 13 , y ) = ( y ) 0 = 0 .

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
ζ p s = g g n ( 1 , 64 , 1 )
denote the G-number of all positions from 1 to 64. A position k is a valid position if k ζ p s . Thus, if b is the board in Figure 1, then
( b ) 1 = 26 ; ( b ) 2 = 27 ; ( b ) 63 = 16 ; ( b ) 64 = 17 ; ( b ) i = 0 , i < 1   or   i > 64 ;
and
( i g g n ( 17 , 48 ) ) { ( b ) i = 1 } .
Since there are exactly 32 empty cells, we have
c n t ( 1 , b ) = 32 .
The position of the black and white kings on any valid board b (valid boards are defined below) are
( p s n ( 14 , b ) ) 1 ; ( p s n ( 30 , b ) ) 1 .
Thus, for b in Figure 1, we have
( p s n ( 14 , b ) ) 1 = 61 ; ( p s n ( 30 , b ) ) 1 = 5 .
Figure 3 shows board b that is the result of two moves made by each player on b in Figure 1. Thus, the following predicates are true:
( b ) 53 = 6 ( b ) 37 = 1 ( b ) 53 = 1 ( b ) 37 = 6 ; ( b ) 63 = 16 ( b ) 46 = 1 ( b ) 63 = 1 ( b ) 46 = 16 ; ( b ) 13 = 22 ( b ) 29 = 1 ( b ) 13 = 1 ( b ) 29 = 22 ; ( b ) 7 = 32 ( b ) 22 = 1 ( b ) 7 = 1 ( b ) 22 = 32 .

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 2 j 8 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 j , k , 37 ; if j becomes a rook, the new white rook is encoded as j , k , 41 ; if j becomes a bishop, the new white bishop is encoded as j , k , 43 ; if j becomes a knight, the new white knight is encoded as j , k , 47 .
Let 18 j 25 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 j , k , 53 ; if j becomes a rook, the new black rook is encoded as j , k , 59 ; if j becomes a bishop, the new black bishop is encoded as j , k , 61 ; if j becomes a knight, the new black knight is encoded as j , k , 67 .
Thus, if white pawn 2 becomes a queen at position 7, the new white queen is 2 , 7 , 37 ; if 2 becomes a rook at position 7, the new white rook is 2 , 7 , 41 ; if 2 becomes a bishop at position 7, the new white bishop is 2 , 7 , 43 ; if 2 becomes a knight, the new white knight is 2 , 7 , 47 .
Similarly, if black pawn 19 becomes a queen at position 59, the new black queen is 19 , 59 , 53 ; if 19 becomes a rook at position 59, the new black rook is 19 , 59 , 59 ; if 19 becomes a bishop at position 59, the new black bishop is 19 , 59 , 61 ; if 19 becomes a knight at position 59, the new black knight is 19 , 59 , 67 .
Since for any z, z = x , y , 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 j g g n ( 2 , 17 , 1 ) , is a regular black piece if j g g n ( 18 , 33 , 1 ) , 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
ζ μ w = [ 2 , 1 , 37 , , 9 , 8 , 47 ] ; ζ μ b = [ 18 , 57 , 53 , , 25 , 64 , 67 ]
be the G-numbers of the white, black, and all metamorphic pieces.

4.3. Valid Pieces and Boards

Let the primitive recursive predicates
w p ( j ) { 2 j 17 } { j ζ μ w } ; b p ( j ) { 18 j 33 } { j ζ μ b }
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
v l p ( j ) w p ( j ) b p ( j ) .
holds (i.e., v l p ( j ) = 1 ). Let
ζ w p = g g n ( 2 , 17 , 1 ) r ζ μ w ; ζ b p = g g n ( 18 , 33 , 1 ) r ζ μ b ; ζ c p = ζ w p r ζ b p
denote the G-numbers of the white pieces ( ζ w p ), the black pieces ( ζ b p ), and all chess pieces ( ζ c p ).
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
P 1 ( b ) c n t ( 14 , b ) = c n t ( 30 , b ) = 1
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
P 2 ( b ) ( i ζ c p ) { { i = 14 i = 30 } c n t ( i , b ) 1 }
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
P 3 ( b ) 32 c n t ( 1 , b ) 62
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 ζ μ l c , w b denote the G-number of the numbers of the metamorphic light-colored white bishops in Table S3, ζ μ d c , w b —the G-number of the numbers of the metamorphic dark-colored white bishops in Table S4, ζ μ l c , b b —the G-number of the numbers of the metamorphic light-colored black bishops in Table S5, ζ μ d c , b b —the G-number of the numbers of the metamorphic dark-colored black bishops in Table S6. Let
ζ μ l c b = ζ μ l c , w b r ζ μ l c , b b ; ζ μ d c b = ζ μ d c , w b r ζ μ d c , b b
be the G-numbers of the light-colored and dark-colored metamorphic bishops.
The primitive recursive predicates
w k μ ( j ) j ζ μ w r ( j ) = 47 ; b k μ ( j ) j ζ μ b r ( j ) = 67
hold if j is a metamorphic white or black knight, respectively. The primitive recursive predicates
w l b μ ( j ) j ζ μ l c b r ( j ) = 43 ; b l b μ ( j ) j ζ μ l c b r ( j ) = 61
hold if j is a metamorphic white or black light-colored bishop, respectively. The primitive recursive predicates
w d b μ ( j ) j ζ μ d c b r ( j ) = 43 ; b d b μ ( j ) j ζ μ d c b r ( j ) = 61 ;
hold if j is a metamorphic white or black dark-colored knight, respectively. The primitive recursive predicates
k n μ ( j ) w k μ ( j ) b k μ ( j ) ; b h μ ( j ) w d b μ ( j ) b d b μ ( j )
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
ζ l p s = [ 1 , 3 , 5 , 7 , 10 , 12 , 14 , 16 , 17 , 19 , 21 , 23 , 26 , 28 , 30 , 32 , 33 , 35 , 37 , 39 , 42 , 44 , 46 , 48 , 49 , 51 , 53 , 55 , 58 , 60 , 62 , 64 ]
be the G-number of all light-colored positions on b (See Figure 4) and let
ζ d p s = [ 2 , 4 , 6 , 8 , 9 , 11 , 13 , 15 , 18 , 20 , 22 , 24 , 25 , 27 , 29 , 31 , 34 , 36 , 38 , 40 , 41 , 43 , 45 , 47 , 50 , 52 , 54 , 56 , 57 , 59 , 61 , 63 ]
be the G-number of all dark-colored positions on b (See Figure 5). The primitive recursive predicate
P 4 ( b ) { ( j [ 15 , 28 ] r ζ μ l c b ) { j b ( p s n ( j , b ) ) 1 ζ l p s } { ( j [ 12 , 31 ] r ζ μ d c b ) { j b ( p s n ( j , b ) ) 1 ζ d p s }
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
ρ μ = g g n ( 1 , 8 , 1 ) r g g n ( 57 , 64 , 1 )
be the G-number of positions 1–8 and 57–64. The primitive recursive predicate
P 5 ( b ) { ( j g g n ( 2 , 9 , 1 ) ) { j b ( p s n ( j , b ) ) 1 ρ μ } { ( j g g n ( 18 , 25 , 1 ) ) { j b ( p s n ( j , b ) ) 1 ρ μ } }
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
v l d ( b ) L t ( b ) = 64 P 1 ( b ) P 2 ( b ) P 3 ( b ) P 4 ( b ) P 5 ( b )
holds if b is a valid 64-cell chess board. Thus, if b 1 and b 2 are the boards in Figure 1 and Figure 3, respectively, then v l d ( b 1 ) = v l d ( b 2 ) = 1 .

4.4. Diagonals, Rows, Columns

A position 1 k 64 on valid b is a member of at most two diagonals. Let k { 1 , 2 } and d k , k be the diagonals (if k = 2 ) or the diagonal that include k. For example, k = 62 is a member of two diagonals: d 62 , 1 = [ 48 , 55 , 62 ] and d 62 , 2 = [ 17 , 26 , 35 , 44 , 53 , 62 ] (See Figure 2); and k = 1 is a member of the diagonal d 1 , 1 = [ 1 , 10 , 19 , 28 , 37 , 46 , 55 , 64 ] (i.e., the first main diagonal).
Let
D = [ 1 , [ d 1 , 1 ] , 2 , [ d 2 , 1 , d 2 , 2 ] , 3 , [ d 3 , 1 , d 3 , 2 ] , , , 64 , [ d 64 , 1 ] ]
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 [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] and the column [ 7 , 15 , 23 , 31 , 39 , 47 , 55 , 63 ] .
Let
F 8 ( 0 ) = 1 F 8 ( t + 1 ) = F 8 ( t ) + 8
and
F 9 ( r ) = g g n ( F 8 ( r 1 ) , F 8 ( r 1 ) + 7 , 1 ) if   1 r 8 , 0 otherwise .
Since F 8 ( · ) is primitive recursive by definition, F 9 ( · ) is primitive recursive by the DCT. Thus,
F 9 ( 1 ) = g g n ( F 8 ( 0 ) , F 8 ( 0 ) + 7 , 1 ) = j = 1 8 π ( j ) j ; F 9 ( 2 ) = g g n ( F 8 ( 1 ) , F 8 ( 1 ) + 7 , 1 ) = j = 9 16 π ( j ) j ; F 9 ( 8 ) = g g n ( F 8 ( 7 ) , F 8 ( 7 ) + 7 , 1 ) = j = 57 64 π ( j ) j .
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:
R = r = 1 8 r , F 9 ( r ) .
For each 1 i 8 , we define eight primitive recursive functions (one for each column)
κ i ( 0 ) = i , κ i ( t + 1 ) = κ i ( t ) + 8
and let
c i = j = κ i ( 0 ) κ i ( 7 ) π ( j ) j .
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:
C = i = 1 8 i , c i .
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.
d g s ( k ) = r ( ( D ) a s c ( k , D ) )
r w s ( k ) = r ( ( R ) a s c ( k , R ) )
c l s ( k ) = r ( ( C ) a s c ( k , C ) )
Thus,
d g s ( 62 ) = [ d 62 , 1 , d 62 , 2 ] = [ [ 48 , 55 , 62 ] , [ 17 , 26 , 35 , 44 , 53 , 62 ] ] ; ( d g s ( 62 ) ) 1 = d 62 , 1 ; ( d g s ( 62 ) ) 2 = d 62 , 2 ; r w s ( 62 ) = [ 57 , 58 , 59 , 60 , 61 , 62 , 63 , 64 ] ; c l s ( 62 ) = [ 6 , 14 , 22 , 30 , 38 , 46 , 54 , 62 ] .
Given positions k 1 and k 2 , let
z d = d g s ( k 1 ) r d g s ( k 2 )
and
F 10 ( k 1 , k 2 ) = min t L t ( z d ) { k 1 ( z d ) t k 2 ( z d ) t } .
  The primitive recursive function d g ( k 1 , k 2 ) returns diagonal d that contains both k 1 and k 2 if d exists.
d g ( k 1 , k 2 ) = ( z d ) F 10 ( k 1 , k 2 )
Let z r = [ r w s ( k 1 ) ] r [ r w s ( k 2 ) ] and
F 11 ( k 1 , k 2 ) = min t L t ( z r ) { k 1 ( z r ) t k 2 ( z r ) t } .
  The primitive recursive function r w ( k 1 , k 2 ) returns row r that contains both k 1 and k 2 if r exists.
r w ( k 1 , k 2 ) = ( z r ) F 11 ( k 1 , k 2 )
Let z c = [ c l s ( k 1 ) ] r [ c l s ( k 2 ) ] and
F 12 ( k 1 , k 2 ) = min t L t ( z c ) { k 1 ( z c ) t k 2 ( z c ) t } .
  The primitive recursive function c l ( k 1 , k 2 ) returns column c that contains both k 1 and k 2 if c exists.
c l ( k 1 , k 2 ) = ( z c ) F 12 ( k 1 , k 2 )

4.5. Potentially Reachable Positions

The primitive recursive predicate
o c ( x , y ) { w p ( x ) b p ( y ) } { w p ( y ) b p ( x ) }
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 k k on b is potentially reachable for j from k if j can move from k to k on b. Position k can be empty or occupied by a different piece.
Let L j k be the G-number of the positions potentially reachable by j from k on b. For example, L 15 1 is the G-number of the positions potentially reachable by bishop 15 from position 1. The G-numbers L 15 k , k [ 10 , 19 , 28 , 37 , 46 , 55 , 64 ] , denote the positions potentially reachable by 15 from the other positions of the first main diagonal. We note that L j k is defined regardless of any b in the sense that whether k 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
L 15 1 = 1 , [ 10 , 19 , 28 , 37 , 46 , 55 , 64 ] ; L 15 10 = 10 , [ 1 , 3 , 17 , 19 , 28 , 37 , 46 , 55 , 64 ] ; L 15 19 = 19 , [ 1 , 10 , 5 , 12 , 26 , 33 , 28 , 37 , 46 , 55 , 64 ] ; L 15 28 = 28 , [ 1 , 10 , 19 , 7 , 14 , 21 , 35 , 42 , 49 , 37 , 46 , 55 , 64 ] ; L 15 37 = 37 , [ 1 , 10 , 19 , 28 , 16 , 23 , 30 , 44 , 51 , 58 , 46 , 55 , 64 ] ; L 15 46 = 46 , [ 1 , 10 , 19 , 28 , 37 , 32 , 39 , 53 , 60 , 55 , 64 ] ; L 15 55 = 55 , [ 1 , 10 , 19 , 28 , 37 , 46 , 48 , 62 , 64 ] ; L 15 64 = 64 , [ 1 , 10 , 19 , 28 , 37 , 46 , 55 ] .
We recall that ζ l p s in (41) is the G-number of the light-colored positions on b. Since 15 is light-colored, the G-number
L 15 = r | k ζ l p s L 15 k
contains all positions potentially reachable by 15. We observe that if j is another real or metamorphic light-colored black bishop (e.g., j = 28 ), then
L j = L 15 .
For the dark-colored real bishops 12 and 31 (or any dark-colored metamorphic bishop j), we can analogously define L 12 = L 31 = L j using ζ d 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 j , L j , where L j is the G-number of all reachable positions for j on b.
L = r | j = 2 33 [ j , L j ] r r | j ζ μ w r ζ μ b [ j , L j ]
The function
r p ( j , k , b ) = r ( a s c ( k , r ( a s c ( j , L ) ) ) ) if v l p ( j ) v l d ( b ) 0 otherwise
returns the G-number of all potentially reachable positions for j from k on b. The function r p ( · ) is primitive recursive by the DCT.
Thus, if b and b are boards in Figure 1 and Figure 3, respectively, then (See Figure 6 and Figure 7)
r p ( 16 , 63 , b ) = [ 53 , 46 , 48 ] ; r p ( 16 , 46 , b ) = [ 61 , 52 , 36 , 29 , 31 , 40 , 56 , 63 ] .

4.6. Actual Reachability for Bishop 15

If k r p ( j , k , b ) , it may be occupied by j j of the same color. For example, although 52 r p ( 16 , 46 , b ) , ( b ) 52 = 5 1 , 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 b . To put it differently, 52 is not actually reachable for 16 from 46 on b .
The characteristics of potential reachability and actual reachability, while conceptually related by the rules of chess, are different in that the potential reachability of k for j from k holds on any valid b whereas the actual reachability of k for j from k depends not only on whether k r p ( j , k , b ) but also on ( b ) k .
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
c p s n ( j , b ) = ( p s n ( j , b ) ) 1 if v l p ( j ) v l d ( b ) , 0 otherwise
return the current position of valid piece j on valid board b so that if j b , then
( b ) c p s n ( j , b ) = j .
Let c p s n ( 15 , b ) = k 15 . We seek to compute the G-number of actually reachable positions for 15 from k 15 on b. Let k k 15 be a valid position. Then d g ( k 15 , k ) in (49) returns diagonal d that contains both k 15 and k. If d does not exist (i.e., d = 0 ), then k is not actually reachable for 15 from k 15 on b. If d exists, we need to ensure that either k is empty on b (i.e., ( b ) k = 1 ) or is occupied by a piece of the opposite color o c ( ( b ) k , 15 ) = 1 and 15 can capture ( b ) k . Furthermore, if d exists, we need to ensure that there is no piece either of the same or opposite color between k 15 and k on d. The primitive recursive predicate
P 6 ( k , k 15 , b ) v l d ( b ) k k 15 k r p ( 15 , k 15 , b ) d g ( k 15 , k ) 0 ( k d g ( k 15 , k ) ) { { k = k k = k 15 } ( b ) k = 1 } { ( b ) k = 1 o c ( 15 , ( b ) k ) }
holds on b if k is potentially reachable for 15 from k 15 and is on the same diagonal with k 15 and every position k between k and k 15 on the diagonal is empty and k itself is either empty or occupied by a black piece. The primitive recursive predicate
a r p 15 ( k , k 15 , b ) P 6 ( k , k 15 , b )
holds when k is actually reachable for 15 from k 15 on valid b.
Let b be the board in Figure 3. Then
a r p 15 ( 48 , 62 , b ) = 0 ,
because d g ( 62 , 48 ) = d 62 , 1 = [ 48 , 55 , 62 ] , but pawn 8 in position 55 is of the same color with 15, which makes P 6 ( 48 , 62 , b ) false. On the other hand,
a r p 15 ( k , 62 , b ) = 1 ,
for any k { 17 , 26 , 35 , 44 , 53 } . Let b be a board and let
a r p 15 ( k ) a r p 15 ( k , k 15 , b ) .
Then for any k 15 on b,
m a p a r p 15 ( k ) ( ζ l p s )
computes in a primitive recursive fashion the G-number of all positions actually reachable for 15 from k 15 on b (See Equation (41) for ζ l p s ), 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 j = ( b ) k j , where
k j = c p s n ( j , b )
is the pr-computable position of j on b. Thus, k 30 is the position of the black king on b and k 14 is the position of the white king on b.
Let k r p ( j , k j , b ) . By the rules of chess, j can actually reach finitely many positions from k j . Consequently, whether k is actually reachable for j from k j on b can be decided in a primitive recursive fashion with the functions and predicates in Section 2 and Section 3 and o c ( · ) , v l d ( · ) , d g ( · ) , r w ( · ) , c l ( · ) , p s n ( · ) , r p ( ) ˙ 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 v l p ( j ) = v l d ( b ) = 1 and k r p ( j , k j , b ) . Then a r p j ( k , k j , b ) is primitive recursive.
Since there are finitely many regular and metamorphic pieces, there are finitely many predicates a r p j ( · ) . Let z = r p ( j , k j , b ) . The function
a r x ( z , j , k j , b , 0 ) = [ ] , a r x ( z , j , k j , b , t + 1 ) = F 13 ( z , j , k j , b , a r x ( z , j , k j , b , t ) , s ( t ) ) ,
where
F 13 ( z , j , k j , b , y , i ) = y if ( z ) i a r p j ( j , k j , b ) , [ ( z ) i ] l y if ( z ) i a r p j ( j , k j , b )
returns the G-number of all positions in z that are actually reachable for j from k j on b. The function F 13 ( · ) is primitive recursive by Lemma 1 and the DCT, which makes a r x ( · ) also primitive recursive.
The function a r p s ( · ) in (55) returns the G-number of actually reachable positions for j from k j on b. This function is primitive recursive, because it is composed from primitive recursive functions.
a r p s ( j , k j , b ) = a r x ( r p ( j , k j , b ) , j , k j , b , L t ( r p ( j , k j , b ) ) )
Thus, if b and b are the boards in Figure 1 and Figure 3, respectively, then
a r p s ( 15 , 62 , b ) = [ ] ; a r p s ( 16 , 63 , b ) = [ 46 , 48 ] ; a r p s ( 15 , 62 , b ) = [ 17 , 26 , 35 , 44 , 53 ] ; a r p s ( 16 , 46 , b ) = [ 29 , 31 , 36 , 40 , 63 ] .
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 j 14 (i.e., different from white king 14), for which k 30 (See Equation  (54)) is actually reachable. The primitive recursive predicate
b k c ( b ) ( j ζ w p ) { j 14 k 30 a r p s ( j , k j , b ) }
holds of b when king 30 is checked on it (See Equation (35) for ζ w p ). 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
b k m ( b ) b k c ( b ) ( k ζ p s ) { k a r p s ( 30 , k , b ) ( j ζ w p ) { k a r p s ( j , k j , b ) } }
holds of b when king 30 is mated on it (See Equation (32) for ζ p s ). The primitive recursive predicate
w k c ( b ) ( j ζ b p ) { j 30 k 14 a r p s ( j , k j , b ) }
holds of b when white king 14 is checked on it (See Equation (35) for ζ w p ); and the primitive recursive predicate
w k m ( b ) w k c ( b ) ( k ζ p s ) { k a r p s ( 14 , k , b ) ( j ζ b p ) { k a r p s ( j , k j , b ) } }
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
b s m ( b ) ¬ b c k ( b ) ( j ζ b p ) { L t ( a r p s ( j , k j , b ) ) = 0 }
holds if b is the black stalemate; and the primitive recursive predicate
w s m ( b ) ¬ w c k ( b ) ( j ζ w p ) { L t ( a r p s ( j , k j , b ) ) = 0 }
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
d p 1 ( b ) v l d ( b ) ( j ζ c p ) { j = 14 j = 30 j b }
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
d p x ( b , j ) { v l d ( b ) j b j 14 j 30 } ( i ζ c p ) { i = 14 i = 30 i = j i b } }
holds when b contains 14, 30, and exactly one other piece j. The primitive recursive predicate
d p 2 ( b ) d p x ( b , 12 ) d p x ( b , 15 ) d p x ( b , 28 ) d p x ( b , 31 ) ( j ζ c p ) { b h μ ( j ) d p x ( b , j ) }
holds for case 2 (See Equation (40) for b h μ ( · ) ).
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
d p 3 ( b ) d p x ( b , 11 ) d p x ( b , 16 ) d p x ( b , 27 ) d p x ( b , 32 ) ( j ζ c p ) { k n μ ( j ) d p x ( b , j ) }
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
d p x x ( b , j , j ) { v l d ( b ) j b j b j j j 14 j 30 j 14 j 30 ( i ζ c p ) { { i = 14 i = 30 i = j i = j } i b } }
hold of two different pieces j and j on valid b that are the only two pieces on b different from 14 and 30. The primitive recursive predicate
d p 4 ( b ) d p x x ( b , 15 , 31 ) d p x x ( b , 12 , 28 ) ( j ζ μ l c b ) ( j ζ μ d c b ) { d p x x ( b , j , j ) }
holds for case 4. The primitive recursive predicate
d p ( b ) = d p 1 ( b ) d p 2 ( b ) d p 3 ( b ) d p 4 ( b )
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
P 7 ( j , k , b ) v l d ( b ) j b k a r p s ( j , k j , b ) ¬ w k m ( b ) ¬ b k m ( b ) ¬ w s m ( b ) ¬ b s m ( b ) ¬ d p ( b )
hold when position k is actually reachable for piece j on valid b from k j (as defined in (54)) and b is not a mate, a stalemate, or a draw. Let
b k j = s e t ( s e t ( b , k , j ) , k j , 1 ) .
The above equation defines a primitive recursive function that calculates the board obtained from b after j is placed in position k and position k j is set to 1. Thus, if b 0 is the starting board in Figure 1, then
b 37 6 = s e t ( s e t ( b 0 , 37 , 6 ) , 53 , 1 )
is the board after the white player moves pawn 6 from position 53 to position 37.
Let the primitive recursive predicate
P 7 ( j , k , b ) ¬ j ζ w p w k c b k j ¬ j ζ b p b k c b k j
hold if the move of j into k from k j 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.
Let
P 7 ( j , k , b ) P 7 ( j , k , b ) P 7 ( j , k , b )
and
b k j = b k j if P 7 ( j , k , b ) 0 otherwise .
The function defined in (70) is primitive recursive by the DCT. Thus, if b 0 is the board in Figure 1, then the board in Figure 3 is
b 0 37 6 29 22 46 16 22 32 = b 0 37 6 29 22 46 16 22 32 .
The right-hand side of the above equality denotes the board obtained from b 0 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 x ¯ denotes the player’s opponent. Thus, if x = 1 , then x ¯ = 2 ; if x = 2 , then x ¯ = 1 . Let
b , b k j , x , j , k j , k
denote the move of piece j by player x from k j to k on b that results in { b } k j . Thus,
b 0 , b 0 37 6 , 1 , 6 , 53 , 37
is the move of pawn 6 from 53 to 37 by player 1 on b 0 that results in
b 0 37 6 = b 0 37 6 .
The primitive recursive function m v p ( · ) in (72) constructs the required move number for valid b, x, j, k.
m v p ( b , x , j , k ) = b , b k j , x , j , k j , k
Let
z = m v p ( b , x , j , k )
be a move constructed from valid b, x, j, and k. Then the primitive recursive functions p c b ( · ) , s c b ( · ) , p l r ( · ) , and m v i ( · ) in (73) return the predecessor board, the successor board, the player, the piece and the piece’s positions of move z, respectively.
p c b ( z ) = l ( l ( l ( z ) ) ) s c b ( z ) = r ( l ( l ( z ) ) ) p l r ( z ) = r ( l ( z ) ) m v i ( z ) = r ( z )
Thus, if b 0 be the board in Figure 1, the G-number
[ m v p ( b 0 , 1 , 6 , 37 ) , m v p ( s c b ( m v p ( b 0 , 1 , 6 , 37 ) ) , 2 , 22 , 29 ) , m v p ( s c b ( m v p ( s c b ( m v p ( b 0 , 1 , 6 , 37 ) ) , 2 , 22 , 29 ) ) , 1 , 16 , 46 ) , m v p ( s c b ( m v p ( s c b ( m v p ( s c b ( m v p ( b 0 , 1 , 6 , 37 ) ) , 2 , 22 , 29 ) ) , 1 , 16 , 46 ) ) , 2 , 32 , 22 ) ]
contains a sequence of moves from b 0 in Figure 1 to the board
b 0 37 6 29 22 46 16 22 32
in Figure 3.
Let M b x 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 M b 1 and M b 2 are pr-computable.
M b 1 = r | j ζ w p r | k a r p s ( j , k j , b ) [ m v p ( b , 1 , j , k ) ] M b 2 = r | j ζ b p r | k a r p s ( j , k j , b ) [ m v p ( b , 2 , j , k ) ]
Let the primitive recursive predicate
P 8 ( b ) v l d ( b ) ¬ w k m ( b ) ¬ b k m ( b ) ¬ w s m ( b ) ¬ b s m ( b ) ¬ d p ( b )
hold when b is not a mate, a stalemate, or a dead position. The function m v s ( · ) 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.
m v s ( x , b ) = r m ( 0 , M b 1 ) if x = 1 P 8 ( b ) , r m ( 0 , M b 2 ) if x = 2 P 8 ( b ) , 0 otherwise .

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 b 0 be the initial board in Figure 1. Let the history of chess start at epoch
E 0 = E M 0 , 1 ,
where
E M 0 = [ 0 , b 0 , 0 , 0 , 0 , 0 ] .
We observe that
s c b ( ( l ( E 0 ) ) 1 ) = s c b ( ( E M 0 ) 1 ) = b 0
and r ( E 0 ) = 1 denotes player 1 whose turn it is to play on s c b ( ( l ( E 0 ) ) 1 ) .
Epoch E t , t > 0 , is
E t = E M t , x ,
where E M t is pr-computable from E t 1 as
E M t = r | m l ( E t 1 ) m v s ( r ( E t 1 ) , s c b ( m ) ) .
Thus, epoch E 1 , is pr-computable from E 0 as
E 1 = E M 1 , 2 ,
where
E M 1 = r | m l ( E 0 ) m v s ( 1 , s c b ( m ) ) .
Epoch E 2 is pr-computable from E 1 as
E 2 = E M 2 , 1 ,
where
E M 2 = r | m l ( E 1 ) m v s ( 2 , s c b ( m ) ) .
To generalize, we let
F 14 ( E t , t ) = E M s ( t ) , 1 if 2 | s ( t ) , E M s ( t ) , 2 if 2 s ( t ) ,
and define epoch E t as a primitive recursive function in (79).
E 0 = E M 0 , 1 , E t + 1 = F 14 ( E t , t ) .
Thus,
E 0 = E M 0 , 1 ; E 1 = F 14 ( E 0 , 0 ) = E M 1 , 2 ; E 2 = F 14 ( E 1 , 1 ) = E M 2 , 1 ; E 3 = F 14 ( E 2 , 2 ) = E M 3 , 2 ; E 4 = F 14 ( E 3 , 3 ) = E M 4 , 1 ; E 5 = F 14 ( E 4 , 4 ) = E M 5 , 2 ;
Given an epoch number t, the history of chess, H t , is pr-computable as
H t = r | k = 0 t [ E i ] = [ E 0 , E 1 , , E t 1 , E t ] .
Thus, for t > 2 .
H 0 = [ E 0 ] ; H 1 = [ E 0 , E 1 ] ; H 2 = [ E 0 , E 1 , E 2 ] ; H t = [ E 0 , E 1 , E 2 , , E t ] .

4.12. Games

We define the primitive recursive predicate
e b ( b , t ) ( m M t ) { s c b ( m ) = b }
to hold when b is a successor of some move in M t , t 0 . We will refer to b as an epoch t board. Let the primitive recursive predicate
s c r ( b , b , t ) { t > 0 e b ( b , t 1 ) e b ( b , t ) ( m M t ) { p c b ( m ) = b s c b ( m ) = b } }
hold between boards b and b if for some move m M t such that b is the move’s predecessor and b is its successor. In other words, epoch t board b can be obtained from epoch t 1 board b in exactly one move by the player whose turn it is to play on b.
Let z = [ b i 1 , , b i k ] , k 2 , be a sequence of boards and let b 0 be the starting board. The primitive recursive predicate
h g m ( z ) L t ( z ) 2 ( z ) 1 = b 0 ( t g g n ( 2 , L t ( z ) , 1 ) ) { s c r ( ( z ) t 1 , ( z ) t , t ) }
holds of z when it has at least two boards, its first board is b 0 , and the predicate s c r ( · ) in (82) holds of every two consecutive boards in z. If h g m ( z ) = 1 for some sequence of boards z, we refer to z as chess game G z or simply as game  G z .
Consider the board sequences in Figure 8, Figure 9, Figure 10 and Figure 11 and let
z 1 = [ b 0 ] r z 1 = [ b 0 , b 1 1 , b 2 1 , b 3 1 , b 4 1 ] ; z 2 = [ b 0 ] r z 2 = [ b 0 , b 1 2 , b 2 2 , b 3 2 , b 4 2 ] ; z 3 = [ b 0 ] r z 3 = [ b 0 , b 1 3 , b 2 3 , b 3 3 , b 4 3 ] ; z 3 = [ b 0 ] r z 4 = [ b 0 , b 1 4 , b 2 4 , b 3 4 , b 4 4 ] .
Then, since
h g m ( z 1 ) = h g m ( z 2 ) = h g m ( z 3 ) = h g m ( z 4 ) = 1 ,
G z 1 , G z 2 , G z 3 , and G z 4 are games.
Let z be a G-number of boards. The primitive recursive function
t l b ( z ) = ( z ) L t ( z )
computes the last board of z. If G z is a game, we will refer to the last board of G z (i.e., t l b ( G z ) ) as the tail board or the tail of G z .
The primitive recursive function J ( · ) computes the G-number of all games up to epoch t > 0 .
J ( 0 ) = [ [ b 0 ] ] , J ( t + 1 ) = F 15 ( J ( t ) , t ) ,
where
F 15 ( Z , t ) = r | z Z F 16 ( z , E M t + 1 ) ,
where
F 16 ( z , E M ) = F 17 ( z , m a p p c b ( m ) = t l b ( z ) ( E M ) , L t ( m a p p c b ( m ) = t l b ( z ) ( E M ) ) ) ,
where
F 17 ( z , E M , 0 ) = [ ] , F 17 ( z , E M , t + 1 ) = F 18 ( z , E M , F 17 ( z , E M , t ) , t ) ,
where
F 18 ( z , E M , Z , t ) = Z r [ z r [ s c b ( ( E M ) s ( t ) ) ] ] .
The primitive recursive function F 18 ( · ) in (89) takes a game G z , a G-number E M of moves such that ( m E M ) { p c b ( m ) = t l b ( z ) } , a G-number Z of games and a number t. This function computes the continuation [ z r [ s c b ( ( E M ) s ( t ) ) ] of G z and appends it at the right of the games Z computed thus far.
The primitive recursive function F 17 ( · ) in (88) takes a game G z , a G-number M of moves such that ( m E M ) { p c b ( m ) = t l b ( z ) } and returns the G-number of games each of which is a continuation of G z with each successor board of the moves E M .
The primitive recursive function F 16 ( · ) in (87) takes a game G z and the G-number E M of moves of epoch t > 0 and computes the G-number of all games that extend G z with the appropriate successor boards in E M (i.e., with the successor board of each move m E M such that p c b ( m ) = t l b ( z ) ).
The primitive recursive function F 15 ( · ) in (86) takes a G-number of games Z and t 1 and computes the G-number of games by extending every game in Z with all appropriate successor boards in E M t + 1 . If t > 0 , then
G t = r | i = 1 t [ J ( i ) ]
is the G-number of all games up to epoch t. All games in G t are historical in the sense that they are based on the moves in each epoch E t of H t in (80). All games in G t are legal, because they are obtained by legal moves from the initial board b 0 . We have the following lemma.
Lemma 4.
Let G z G t , t > 0 , and b = t l b ( G z ) . Then L t ( z ) = t + 1 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
P Γ ( z ) h g m ( z ) G z G L t ( z ) 1
be a primitive recursive predicate that holds of z if G z is a chess game and let
Γ = { z N | P Γ ( z ) }
be the set of numbers for which P Γ ( · ) 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 G z be a game and let z be a sequence of boards such that L t ( z ) > 1 . We say that z is a subgame of G z if the primitive recursive predicate s b g ( · ) in (93) holds of G z and z .
s b g ( z , G z ) { 1 < L t ( z ) L t ( z ) ( i g g n ( 1 , L t ( z ) 1 , 1 ) ) { ( k g g n ( 1 , L t ( z ) , 1 ) ) { ( z ) k = ( z ) i + k 1 } } }
In other words, z 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 L t ( z ) 1. Consider Figure 10. If
z 3 = [ b 0 , b 1 3 , b 2 3 , b 3 3 , b 4 3 ] ,
then
s b g ( [ b 0 , b 1 3 ] , G z 3 ) = 1 ; s b g ( [ b 1 3 , b 2 3 , b 3 3 ] , G z 3 ) = 1 ; s b g ( [ b 1 3 , b 3 3 , b 4 3 ] , G z 3 ) = 0 ; s b g ( [ b 2 3 , b 4 3 ] , G z 3 ) = 0 .
We define the primitive recursive predicate s b g 2 ( · ) to hold when z starts at a specific board i in G z .
s b g 2 ( z , G z , i ) { 1 < L t ( z ) L t ( z ) { 0 < i ( k g g n ( 1 , L t ( z ) , 1 ) ) { ( z ) k = ( z ) i + k 1 } } }
Thus,
s b g 2 ( [ b 0 , b 1 3 ] , G z 3 , 1 ) = s b g 2 ( [ b 2 3 , b 3 3 , b 4 3 ] , G z 3 , 3 ) = 1 .

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 b 0 occurs three times in this sequence (i.e., b 0 = b 4 = b 8 ) with player 1 to move.
Let z be a subgame with player x to play on ( z ) 1 . The same board occurs in a row at ( z ) 5 since x and x ¯ must make one move each and then reverse that move. Player x then plays on ( z ) 5 and the same board occurs in a row at ( z ) 9 , since x and x ¯ make one move each again and reverse it. Thus, z is a draw by repetition if it has 9 boards such that ( z ) 1 = ( z ) 5 = ( z ) 9 . In other words, if
L t ( z ) = 9 ( z ) 1 = ( z ) 5 = ( z ) 9 .
Let G z G t , t > 0 , then G z is a draw by repetition if
d r p ( G z ) { L t ( z ) 9 t l b ( z ) = ( z ) L t ( z ) 8 = ( z ) L t ( z ) 4 }
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 G z is a draw by the 50-move rule, then G z G t , t 49 . Let z be a subgame of G z that has 50 boards (i.e., L t ( z ) = 50 ). Then G z is a 50-move rule draw if for all boards in z 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 G z if the latter is a draw by the 50-move rule. Let
ζ w p n = g g n ( 2 , 9 , 1 ) ; ζ b p n = g g n ( 18 , 25 , 1 )
be the G-numbers of the white and black pawns, respectively. The primitive recursive predicates w p x 50 ( · ) and b p x 50 ( · ) below hold if every white and black pawn is present or abscent on both boards (i.e., b 1 and b 2 ) and, if any white or black pawn is present on both boards, its position is the same on both.
w p x 50 ( b 1 , b 2 ) { ( i ζ w p n ) { { i b 1 i b 2 } { i b 1 i b 2 } } } { ( i ζ w p n ) { { i b 1 i b 2 } c p s n ( i , b 1 ) = c p s n ( i , b 2 ) } }
b p x 50 ( b 1 , b 2 ) { ( i ζ b p n ) { { i b 1 i b 2 } { i b 1 i b 2 } } } { ( i ζ b p n ) { { i b 1 i b 2 } c p s n ( i , b 1 ) = c p s n ( i , b 2 ) } }
We recall that ζ c p in (41) defines the G-number of all the white and black pieces. The primitive recursive predicate
c n t x 50 ( b 1 , b 2 ) ( j ζ c p ) { c n t ( j , b 1 ) = c n t ( j , b 2 ) }
holds if the counts of all pieces on the boards b 1 and b 2 are equal.
Let z be a sequence of boards. The primitive recursive predicate
w b p 50 ( z ) ( t g g n ( 1 , L t ( z ) 1 , 1 ) ) { w p x 50 ( ( z ) t , ( z ) t + 1 ) b p x 50 ( ( z ) t , ( z ) t + 1 ) }
holds if the predicates w p x 50 ( · ) and b p x 50 ( · ) hold for every pair of consecutive boards in z. The primitive recursive predicate
c n t 50 ( z ) ( t g g n ( 1 , L t ( z ) 1 , 1 ) ) { c n t x 50 ( ( z ) t , ( z ) t + 1 ) }
holds if the counts of all pieces on all boards in z are equal. The primitive recursive predicate
d r x 50 ( z ) w b p 50 ( z ) c n t 50 ( z )
holds if the boards in z have no pawn moves or piece captures.
The game G z 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 d r x 50 ( · ) holds. The primitive recursive predicate
d r 50 ( G z ) L t ( z ) 50 ( t g g n ( 1 , L t ( z ) 49 , 1 ) ) { d r x 50 ( s s q ( z , t , t + 49 ) }
holds if G z is a draw by the 50-move rule.

4.14. Classification of Games

We define the primitive recursive predicate
d r g ( G z ) d r p ( G z ) d r 50 ( G z ) b s m t l b ( G z ) w s m t l b ( G z ) d p t l b ( G z )
to hold when G z is a draw game by repetition, the 50-move rule, stalemate, or dead position. The primitive recursive predicate
w n g ( G z , x ) b k m t l b ( G z ) if x = 1 , w k m t l b ( G z ) if x = 2 , 0 otherwise
holds when G z ends in a mate for x ¯ . The primitive recursive predicate
u f g ( G z , x ) ¬ d r g ( G z ) ¬ w n g ( G z , x )
holds when G z 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 G t if t is odd and player 2 can win only games in G t if t is even. Let G z G t , t > 0 , and let x be the player to play at t. If G z is not a win for x ¯ , then x can win in 1, 3, 5, …, 2 k + 1 moves. Let n be an odd number of moves into the future. We inquire if it is possible to find games G y G t + n that are continuations of G z and are wins for x in a primitive recursive fashion. The primitive recursive predicate
c n g ( y , z ) z = s s q ( y , 1 , L t ( z ) ) P Γ ( y )
determines if G y is a continuation of G z . For any G z , we let the primitive recursive predicate
w c n g ( y , x ) c n g ( y , z ) w n g ( G y , x )
hold when G y is a continuation of G z that is a win for x. Let w n x ( y ) w c n g ( y , 1 ) and b n x ( y ) w c n g ( y , 2 ) . If G z G t , t > 0 , then the primitive recursive function
w n g s ( G z , x , t , n ) = m a p w n x ( G t + n ) if 2 n x = 1 , m a p b n x ( G t + n ) if 2 n x = 2 , 0 otherwise
returns the G-number of all continuations of G z in G t + n that are wins for x whose turn it is to play on the tail of G z . The primitive recursive predicate
d c n g ( y ) c n g ( y , z ) d r g ( G y )
holds when G y is a continuation of G z that is a draw. If G z G t , t > 0 , then the primitive recursive function
d r g s ( G z , t , n ) = m a p d c n g ( G t + n ) if 2 n , 0 otherwise
returns the G-number of all continuations of G z in G t + n that are draws for x whose turn it is to play on the last board of G z . The primitive recursive predicate
u c n g ( y , x ) c n g ( y , z ) u f g ( G y , x )
holds when G y is a continuation of G z that is unfinished for x. Let w u x ( y ) u c n g ( y , 1 ) and b u x ( y ) u c n g ( y , 2 ) . If G z G t , t > 0 , then the primitive recursive function
u f g s ( G z , x , t , n ) = m a p w u x ( G t + n ) if 2 n x = 1 , m a p b u x ( G t + n ) if 2 n x = 2 , 0 otherwise
returns the G-number of all continuations of G z in G t + n that are unfinished for x whose turn it is to play on the tail of G z .
Let G z G t , t > 0 , and let x be the player whose turn it is to play on the tail of G z . We will further assume that G z is unfinished (i.e., u f g ( G z , x ) = 1 ) for x. We call G z winnable for x in n moves if w n g s ( G z , x , t , n ) 0 , drawable for x in n moves if d r g s ( G z , t , n ) 0 , and unfinishable for x in n moves if u f g s ( G z , x , t , n ) 0 . 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 G z G t , t > 0 , be a hang and x be the player whose turn it is to play on b = t l b ( z ) . If n is an odd positive integer, then it is pr-decidable whether G z 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 G z that allows x ¯ to win.
We pose the question if it is pr-decidable to whether G z is absolutely winnable for x within n moves when x is to play on the tail of G z . G z is absolutely winnable for x if any continuation of G z of less than or equal to n boards results in a win for x and is not winnable or drawable for x ¯ .
Let us assume that G z G t , t > 0 , and x is the player whose turn it is to play on the tail of G z and G z is unfinished (i.e., u f g ( G z , x ) = 0 ). Let
g 1 = g g n ( t + 1 , t + n , 2 ) g 2 = g g n ( t + 2 , t + n , 2 )
be the G-numbers of game epochs strictly between t and t + n , where g 1 = [ ( t + 1 ) , ( t + 1 ) + 2 , , ( t + 1 ) + 2 j ] , and g 2 = [ t + 2 , t + 2 · 2 , , t + 2 k ] , where ( t + 1 ) + 2 j and t + 2 k are the largest numbers less than t + n obtained in even increments from ( t + 1 ) and ( t + 2 ) , respectively. G-number g 1 contains the numbers of epochs, where x ¯ plays and x can win, draw, or hang, and g 2 contains the numbers of epochs where x plays and x ¯ can win, draw, or hang.
The primitive recursive predicate
a w g 1 ( G z , x , n ) ( t g 1 ) ( y G t ) { ¬ c n g ( y , z ) w c n g ( y , x ) }
holds if x wins every continuation G y of G z within n moves and the primitive recursive predicate
a w g 2 ( G z , x , n ) ( t g 2 ) ( y G t ) { ¬ c n g ( y , z ) u c n g ( y , x ¯ ) }
holds if every continuation G y of G z within n moves is a hang for x ¯ .
The primitive recursive predicate
a w g ( G z , x , n ) a w g 1 ( G z , x , n ) a w g 2 ( G z , x , n )
holds if G z is absolutely winnable for x within n moves.
Is it pr-decidable if x can win or draw G z from its tail within the next n moves while x ¯ cannot win under any sequence of moves less than or equal to n? If G z is such a game, we call it favorable for x.
We define the primitive recursive predicate
f v g 1 ( G z , x , n ) ( t g 1 ) ( y G t ) { ¬ c n g ( y , z ) { d c n g ( y ) w c n g ( y , x ) } }
to hold if x wins or draws in every continuation G y of G z within n moves and define the primitive recursive predicate
f v g 2 ( G z , x , n ) ( t g 2 ) ( y G t ) { ¬ c n g ( y , z ) u c n g ( y , x ¯ ) }
to hold if every continuation G y of G z within n moves is a hang for x ¯ .
The primitive recursive predicate
f v g ( G z , x , n ) f v g 1 ( G z , x , n ) f v g 2 ( G z , x , n )
holds if G z is favorable for x within n moves in that in any continuation G y of G z within the next n moves x wins or draws whereas x ¯ hangs.
Is it pr-decidable whether neither x nor x ¯ can win or draw G z within the next n moves from the tail of G z ? In other words, is any continuation of G z within the next n moves from its tail is a hang? If that it the case, let us refer to G z as an absolute hang or absolutely unfinishable.
The primitive recursive predicate
a h g 1 ( G z , x , n ) ( t g 1 ) ( y G t ) { ¬ c n g ( y , z ) u c n g ( y , x ) }
holds if x hangs in every continuation G y of G z within n moves, and the primitive recursive predicate
a h g 2 ( G z , x , n ) ( t g 2 ) ( y G t ) { ¬ c n g ( y , z ) u c n g ( y , x ¯ ) }
holds if every continuation G y of G z within n moves is a hang for x ¯ .
The primitive recursive predicate
a h g ( G z , x , n ) a h g 1 ( G z , x , n ) a h g 2 ( G z , x , n )
holds if G z is unfinishable for x and x ¯ within n moves.
We summarize the above arguments in the following lemma.
Lemma 7.
Let G z G t , t > 0 , be a hang and x be the player whose turn it is to play on b = t l b ( z ) . If n be an odd positive integer, then it is pr-decidable whether G z is absolutely winnable for x within n moves, is favorable for x within n moves, or is an absolute hang for x (and x ¯ ) 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 G z G t , t > 0 , and the player x is to play on the tail of G z . Is an optimal continuation of G z 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 a w g ( G z , x , n ) is true, then let
Z a = w n g s ( G z , x , t , n )
be the pr-computable G-number of winnable games for x within n moves, which, since G z is absolutely winnable, includes all continuations of G z within n moves. The next move from ( Z a ) 1 can be arbitrarily chosen for x to play (e.g., ( ( Z a ) 1 ) L t ( z ) + 1 ) . Alternatively, the minimalization can be used to find the index of z Z a such that
( z Z a ) { z = z L t ( z ) L t ( z ) } .
Since the above predicate is primitive recursive, so is its minimalization. If G z is the shortest absolutely winnable game found through the minimalization of the above primitive recursive predicate, the next move is chosen as
( z ) L t ( z ) + 1 .
If a w g ( G z , x , n ) = 0 but f v g ( G z , x , n ) = 1 , then let
Z w = w n g s ( G z , x , t , n ) ; Z d = d r g s ( G z , x , t , n ) .
Since G z is favorable, all continuations of G z within the next n moves will be in Z w or Z d . If Z w 0 , x uses the minimalization to find the shortest continuation in Z w as outlined above and selects the next move from that continuation. If Z w = 0 , then all continuations of G z are draws for x within the next n moves, and x can choose the next move from the shortest continuation in Z d . If a w g ( G z , x , n ) = f v g ( G z , x , n ) = 0 but a h g ( G z , x , n ) = 1 , then x chooses the next move from the shortest z in
Z h = u f g s ( G z , x , t , n ) .
What if Z w = Z d = Z h = 0 ? In this case, G z is absolutely losable or an absolute loss for x within n moves. The primitive recursive predicate
a l g ( G z , x , n ) w n g s ( G z , x , L t ( z ) + 1 , n ) = d r g s ( G z , x , L t ( z ) + 1 , n ) = u f g s ( G z , x , L t ( z ) + 1 , n ) = 0
holds when G z is absolutely losable for x within the next n moves. In this case, the concept of lookahead (i.e., n + m moves ahead for some positive even number m) can be applied and the above primitive recursive steps of computing Z w , Z d , and Z h repeated so long as n + m K , where K is some arbibrary large positive odd integer. Taking M = 399 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 G z remains absolutely losable for x within the next K moves, x resigns.
What if Z h 0 (i.e., there are absolute hangs)? We can use the same incremental lookahead method to determine if any G z Z h 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 Z h , it must be decided for x which unfinishable game in Z h to choose. One possible pr-computable procedure is to choose a continuation G z of G z in Z h for which the counts of the pieces for each board of G z 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 G z Z h of G z is chosen where each board from the tail of G z to the tail of G z has the same value for x and x ¯ 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 G z G t , t > 0 , be a hang and x be the player whose turn it is to play on b = t l b ( z ) and let K be a large positive odd integer. Then there exist pr-computable procedures to compute optimal continuations of G z for x and to decide if G z 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 t > 0 such that ( t ) { t t E t = 0 } ? (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 x ¯ uses only primitive recursive decision procedures?
  • Are there games that x cannot lose when x uses only primitive recursive decision procedures while x ¯ uses computable decision procedures that are not primitive recursive?

7. Summary

We investigated several characteristics of chess with methods of computability and number theories. We showed that chess boards can be represented as Gödel numbers (G-numbers). The following characteristics were shown to be pr-decidable: board validity, position reachability, potential and actual position reachability, check, mate, stalemate, and draw.
We showed that it is pr-decidable whether an unfinished game is absolutely winnable, favorable (i.e., winnable or drawable), or absolutely losable within a specified number of moves for the player whose turn it is to play on the last board. We also showed that that there exist primitive recursive procedures to compute optimal continuations of an unfinished game and that the set of all chess games is recursive.

Supplementary Materials

The following supporting information can be downloaded at: https://www.mdpi.com/article/10.3390/math10071016/s1.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Conflicts of Interest

The author declares no conflict of interest.

References

  1. Bolon, T. How to Never Lose at Tic Tac Toe; Book Country: New York, NY, USA, 2013. [Google Scholar]
  2. Daly, W., Jr. Computer Strategies for the Game of Qubic. Master’s Thesis, Department of Electrical Engineering, Massachusetts Institute of Technology, Cambridge, MA, USA, 1961. [Google Scholar]
  3. Kleene, S.C. Introduction to Metamathematics; D. Van Nostrand: New York, NY, USA, 1952. [Google Scholar]
  4. Rogers, H., Jr. Theory of Recursive Functions and Effective Computability; The MIT Press: Cambridge, MA, USA, 1988. [Google Scholar]
  5. Davis, M.; Sigal, R.; Weyuker, E. Computability, Complexity, and Languages: Fundamentals of Theoretical Computer Science, 2nd ed.; Harcourt, Brace & Company: Boston, MA, USA, 1994. [Google Scholar]
  6. Kulyukin, V. On Primitive Recursiveness of Tic Tac Toe. In Proceedings of the International Conference on Foundations of Computer Science (FCS’19), Las Vegas, NV, USA, 29 July–1 August 2019; pp. 9–15. [Google Scholar]
  7. Meyer, M.; Ritchie, D. The Complexity of Loop Programs. In Proceedings of the ACM National Meeting, Washington, DC, USA; 1967; p. 465. Available online: https://people.csail.mit.edu/meyer/meyer-ritchie.pdf (accessed on 11 February 2022).
  8. The Longest Tournament Chess Game. Available online: https://www.chess.com/blog/ThummimS/the-longest-tournament-chess-game (accessed on 21 January 2022).
  9. Barr, A.; Feigenbaum, E. The Handbook of Artificial Intelligence; Addison-Wesley: Reading, MA, USA, 1982; Volume 1. [Google Scholar]
  10. Russell, S.; Norvig, P. Artificial Intelligence: A Modern Approach; Pearson: Hoboken, NJ, USA, 1995. [Google Scholar]
  11. Krizhevsky, A.; Sutskever, I.; Hinton, G.E. ImageNet classification with deep convolutional neural networks. In Proceedings of the 25th International Conference on Neural Information Processing Systems, Lake Tahoe, NV, USA, 3–6 December 2012; pp. 1097–1105. [Google Scholar]
Figure 1. Starting chess board (above) encoded as G-number b (below).
Figure 1. Starting chess board (above) encoded as G-number b (below).
Mathematics 10 01016 g001
Figure 2. Positions in chess board b.
Figure 2. Positions in chess board b.
Mathematics 10 01016 g002
Figure 3. Board b after two moves (i.e., (1) e4 e5 and (2) Kf3 Kf6) by each player on b in Figure 1.
Figure 3. Board b after two moves (i.e., (1) e4 e5 and (2) Kf3 Kf6) by each player on b in Figure 1.
Mathematics 10 01016 g003
Figure 4. Light-colored positions (bolded) on valid board b (See Figure 2 for all board position numbers).
Figure 4. Light-colored positions (bolded) on valid board b (See Figure 2 for all board position numbers).
Mathematics 10 01016 g004
Figure 5. Dark-colored positions (bolded) on valid board b (See Figure 2 for all board position numbers).
Figure 5. Dark-colored positions (bolded) on valid board b (See Figure 2 for all board position numbers).
Mathematics 10 01016 g005
Figure 6. r p ( 16 , 63 , b ) = [ 53 , 46 , 48 ] , where b is the board in Figure 1.
Figure 6. r p ( 16 , 63 , b ) = [ 53 , 46 , 48 ] , where b is the board in Figure 1.
Mathematics 10 01016 g006
Figure 7. r p ( 16 , 46 , b ) = [ 61 , 52 , 36 , 29 , 31 , 40 , 56 , 63 ] ; b is in Figure 3.
Figure 7. r p ( 16 , 46 , b ) = [ 61 , 52 , 36 , 29 , 31 , 40 , 56 , 63 ] ; b is in Figure 3.
Mathematics 10 01016 g007
Figure 8. Board sequence z 1 corresponding to the moves (1) e4 e5; (2) Kf3 Kf6.
Figure 8. Board sequence z 1 corresponding to the moves (1) e4 e5; (2) Kf3 Kf6.
Mathematics 10 01016 g008
Figure 9. Board sequence z 2 corresponding to the moves (1) e4 Kf6; (2) Kf3 e5.
Figure 9. Board sequence z 2 corresponding to the moves (1) e4 Kf6; (2) Kf3 e5.
Mathematics 10 01016 g009aMathematics 10 01016 g009b
Figure 10. Board sequence z 3 corresponding to the moves (1) Kf3 e5; (2) e4 Kf6.
Figure 10. Board sequence z 3 corresponding to the moves (1) Kf3 e5; (2) e4 Kf6.
Mathematics 10 01016 g010
Figure 11. Board sequence z 4 corresponding to the moves (1) Kf3 e5; (2) e4 Kf6.
Figure 11. Board sequence z 4 corresponding to the moves (1) Kf3 e5; (2) e4 Kf6.
Mathematics 10 01016 g011
Figure 12. Draw by threefold repetition.
Figure 12. Draw by threefold repetition.
Mathematics 10 01016 g012
Table 1. Metamorphic positions for the white and black pawns encoded as G-numbers and the symbols that denote the G-numbers.
Table 1. Metamorphic positions for the white and black pawns encoded as G-numbers and the symbols that denote the G-numbers.
PawnMetamorphic Positions
2[1, 2, 3, 4, 5, 6, 7]
3[1, 2, 3, 4, 5, 6, 7, 8]
4[1, 2, 3, 4, 5, 6, 7, 8]
5[1, 2, 3, 4, 5, 6, 7, 8]
6[1, 2, 3, 4, 5, 6, 7, 8]
7[1, 2, 3, 4, 5, 6, 7, 8]
8[1, 2, 3, 4, 5, 6, 7, 8]
9[2, 3, 4, 5, 6, 7, 8]
18[57, 58, 59, 60, 61, 62, 63]
19[57, 58, 59, 60, 61, 62, 63, 64]
20[57, 58, 59, 60, 61, 62, 63, 64]
21[57, 58, 59, 60, 61, 62, 63, 64]
22[57, 58, 59, 60, 61, 62, 63, 64]
23[57, 58, 59, 60, 61, 62, 63, 64]
24[57, 58, 59, 60, 61, 62, 63, 64]
25[58, 59, 60, 61, 62, 63, 64]
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Kulyukin, V. On Primitive Recursive Characteristics of Chess. Mathematics 2022, 10, 1016. https://doi.org/10.3390/math10071016

AMA Style

Kulyukin V. On Primitive Recursive Characteristics of Chess. Mathematics. 2022; 10(7):1016. https://doi.org/10.3390/math10071016

Chicago/Turabian Style

Kulyukin, Vladimir. 2022. "On Primitive Recursive Characteristics of Chess" Mathematics 10, no. 7: 1016. https://doi.org/10.3390/math10071016

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop