A $q$-Queens Problem. I. General Theory

By means of the Ehrhart theory of inside-out polytopes we establish a general counting theory for nonattacking placements of chess pieces with unbounded straight-line moves, such as the queen, on a polygonal convex board. The number of ways to place $q$ identical nonattacking pieces on a board of variable size $n$ but fixed shape is given by a quasipolynomial function of $n$, of degree $2q$, whose coefficients are polynomials in $q$. The number of combinatorially distinct types of nonattacking configuration is the evaluation of our quasipolynomial at $n=-1$. The quasipolynomial has an exact formula that depends on a matroid of weighted graphs, which is in turn determined by incidence properties of lines in the real affine plane. We study the highest-degree coefficients and also the period of the quasipolynomial, which is needed if the quasipolynomial is to be interpolated from data, and which is bounded by some function, not well understood, of the board and the piece's move directions. In subsequent parts we specialize to the square board and then to subsets of the queen's moves, and we prove exact formulas (most but not all already known empirically) for small numbers of queens, bishops, and nightriders. Each part concludes with open questions, both specialized and broad.


Introduction and Preview
The famous n-Queens Problem is to place n nonattacking queens-the largest conceivable number-on an n × n chessboard, or more broadly, to count the number of placements. (See, for instance, [3] on the former and [11] on the latter.) The counting problem has no known solution except by individual computation for relatively small values of n.
This article is Part I of a series [5] that presents a natural generalization we call the q-Queens Problem, wherein we arbitrarily fix the number of queens, q, and vary n, the size of the board; also, the "queen" may be any of a large class of traditional and fairy chess pieces called "riders". We show (Theorem 4.1) that for each separate problem the number of solutions is, aside from a denominator of q!, a quasipolynomial function of n, which means it is given by a cyclically repeating sequence of polynomials. This form of solution could be inferred from empirical formulas for small q found over the decades (see [9]) though it was never proved; our approach makes it obvious. Remarkably, the coefficients of this quasipolynomial in n are themselves (up to a normalization) polynomial functions of q (Theorem 4.2); this, too, can be inferred from empirical results, though it seems never to have been considered that making q a variable might give a single comprehensive expression.
Our results apply to any pieces with unbounded straight-line moves, such as the queen, rook, bishop, and the nightrider of fairy chess, which moves arbitrary distances in the directions of a knight's move-in fact, the requirements of our method are the definition of a fairy-chess rider; thus, our proof of quasipolynomiality and coefficient polynomiality applies to all riders, and only to riders. Our work generalizes in other ways too, as both properties extend to boards of arbitrary rational convex polygonal shape and quasipolynomiality inn extends to mixtures of pieces with different moves. Here, in Part I, we develop the theory under the generality of arbitrary rational convex polygonal shapes; however, we restrain the complexity and strengthen the results by assuming all pieces have the same moves. In Parts II-V we further narrow the focus successively to square boards (Part II), to partial queens, whose moves are subsets of the queen's moves, on square boards (Part III), and then to three special pieces: the bishop, the queen, and the nightrider (Parts IV and V). Part III may be considered the capstone of our series; it is where the theory of the prior parts is applied, many times, to obtain exact results for a narrow but important family of pieces, results which in Part IV are applied to obtain detailed results about three real (or as one might say of the nightrider, surreal) chess pieces. Part V is devoted to one theorem: the exact period for any number of bishops-the only nontrivial period known for all numbers of a single piece.
Setting q = n for queens on the square board gives the first known formula for the n-Queens Problem (in Part II). It is complex and hard to evaluate except when q is very small, but it is precise and complete.
Our work has two main elements: a method of computation, and a common structural framework for all counting functions for riders. The method is that of inside-out polytopes [2], which is an extension of Ehrhart's theory of counting lattice points in convex polytopes (cf. [13,Chapter 4]). The extension adds to a convex polytope an arrangement (a finite set) of forbidden hyperplanes. The polytope is derived from the board and the hyperplane arrangement expresses the moves. The lattice of intersection subspaces of the arrangement plays the crucial role in the construction of the counting function. The proof of quasipolynomiality in n is a simple application of inside-out polytopes. The proof of bivariate quasipolynomiality is by a more subtle analysis. The structural framework, besides proving quasipolynomiality, includes explicit formulas in terms of q for the coefficients of the highest-order powers of n on any board, with stronger results for the square board in Part II and even stronger ones for partial queens in Part III, all obtained by careful study of subspaces of low codimension in the hyperplane intersection lattice. Then Part IV proves explicit formulas, some new, some known but never rigorously established, for small numbers of the three special pieces mentioned above. These proofs either apply the general results of Parts II and III or directly employ inside-out polytope geometry. Part V establishes the period for bishops; its technique is exceptional as it employs signed graph theory to assist the inside-out geometry. Now we state the problem more precisely. It has three ingredients: a piece, a board, and a number. The piece P has moves that are all integral multiples of vectors in a nonempty set M of non-zero, non-parallel integral vectors m r ∈ R 2 . A move is the difference between a new position and the original position; that is, if a piece is in position z ∈ Z 2 , it may move to any location z + κm r for κ ∈ Z and m r ∈ M. We call the m r 's the basic moves. Each one must be in lowest terms; that is, its two coordinates need to be relatively prime; and no basic move may be a scalar multiple of any other. (Indeed, the slope of m r contains all necessary information and can be specified instead of m r itself.) The board consists of the integral points in the interior (n + 1)B • of a positive integral multiple tB of a rational convex polygon B ⊂ R 2 (that is, the vertices of B have rational coordinates). The number is q, the number of pieces that are to occupy places on the board. The rule that no two pieces may attack each other, said mathematically, is that if there are pieces at positions z i and z j , then z j − z i is not a multiple of any m r .
We took advantage of Kotěšovec's formulas for bishops and queens to guide some of our investigations. For instance, he found that the quasipolynomial counting formulas tend to have high-degree coefficients that do not vary periodically. His formulas also suggested that q appears polynomially in each coefficient, aside from a denominator of q!. Those observations led us to more closely examine the polytopal geometry, leading us to a proof of polynomiality with respect to q as well as other results.
Our results provide a basis for understanding the periodicity properties of the coefficients in Kotěšovec's formulas. The general Ehrhart theory of inside-out polytopes implies a period that divides the least common multiple of the denominators of the coordinates of certain points. This least common multiple is called the denominator of the inside-out polytope (see Section 2). In Section 6 we take an approach involving subdeterminants of matrices I. GENERAL THEORY February 21, 2014 5 to understanding this denominator, but it appears to provide an inefficient bound on the period.
We finally summarize Part I. It begins in Section 2 by reviewing inside-out Ehrhart theory. Section 3 defines the hyperplane arrangement that corresponds to a piece and describes simple aspects of the structure of its intersection subspaces-which are the essential ingredient in our approach. In Section 4 we prove our main result, a universal structural formula for the counting quasipolynomial, and initiate the theory of its coefficients and their individual periods.
Then we change focus from the number of nonattacking configurations to their combinatorial structure. The combinatorial types appear in the geometry of the hyperplane arrangement. Their number is consequently the evaluation of the main counting function at a board of size n = −1 (!).
Section 6 tackles the fundamental problem of bounding the quasipolynomial period, or rather its natural upper bound the denominator. We explain a fairly simple approach from [6] involving subdeterminants of matrices. Examples suggest it provides an inefficient bound; still, some bound is better than none at all.
In the final section we propose new research directions, among which are pieces of different kinds on the same board, pieces on higher-dimensional boards, and even a wild generalization where the attacking moves depend on which piece is attacked as well as which does the attacking. Indeed, throughout the series we list open directions and conjectures. Two problems seem to be of highest importance. One that is fundamental to our approach but very complex is that of determining all the subspaces needed to apply our general formulas in examples; this question (see Section 7.2) lies in the overlap of matroid theory and real incidence geometry. Then in Section II.7.2 we discuss the great dissimilarity between the period of the counting function and the length of a recurrence for its values according to the (largely unproved but highly suggestive) work of Kotěšovec. An understanding of this phenomenon should permit a vast reduction in the computing power required to get provable formulas.
We end each part with a dictionary of notation for the benefit of the authors and readers.

Hyperplanes, Subspaces, and Ehrhart Quasipolynomials
The essential tools for our study are hyperplane arrangements and the Ehrhart theory of inside-out polytopes.
In a vector space R d , an arrangement of hyperplanes, A , is a finite set of hyperplanes, i.e., linear subspaces of codimension 1. A region of a hyperplane arrangement is a connected component of the complement of the union of all the hyperplanes. The intersection lattice of A is the set partially ordered by reverse inclusion. Thus, it is a partially ordered set, it has bottom element0 = R d and top element1 = A ; in fact, it is a geometric lattice. An inside-out polytope (P, A ) (see [2], which is the source of the following exposition) is a convex polytope P ⊆ R d , which we assume is closed and full-dimensional, together with a hyperplane arrangement A in R d . A region R of (P, A ) is a nonempty set that is the intersection of P • , the interior of P, with a region of the arrangement A . A vertex of (P, A ) is any point of P that is the intersection of hyperplanes in A and boundary hyperplanes of P; each vertex is the intersection of k linearly independent hyperplanes of A with a kdimensional face of P. (That includes vertices of P, for which k = 0, and any points of intersection of forbidden hyperplanes that lie in the interior of P, for which k = d.) When A is empty we have just a convex polytope; the vertices are just the vertices of P. The intersection semilattice of (P, A ) is the set ordered by reverse inclusion. The two sets L (A ) and L (P • , A ) are equal for the inside-out polytopes we employ, but in general they can differ.
(In this paper, P is B q , a 2q-dimensional polytope that contains all configurations of q pieces in the board, and the hyperplane arrangement is A P , consisting of hyperplanes that contain all the 2q-dimensional points representing configurations of q chess pieces P in which some pieces attack each other; see the complete definition in Section 3.1.) A quasipolynomial is a function f (t) of positive integers that can be written in the form e d (t)t d + e d−1 (t)t d−1 + · · · + e 0 (t) where each coefficient e j (t) is a periodic function of t. The least common multiple p of the periods of all the coefficients is the period of f . Another way to describe f is as a function that is given by p polynomials, f k (t) for k = 0, 1, . . . , p − 1, under the rule f (t) = f k (t) if 0 < t ≡ k mod p. We call the individual polynomials f k (t) the constituents of f . We say f has degree d if that is the highest degree of a constituent. (In our quasipolynomials every constituent has the same degree.) For a positive integer t and a polytope P, the number of integer points in tP, or equivalently the number of (1/t)-fractional points in P, is denoted by E P (t). The number in P • is denoted by E • P (t) = E P • (t). We assume the vertices of P are rational and we define D(P), the denominator of P, to be the least common denominator of all their coordinates. Then E • P is a quasipolynomial function of t, the open Ehrhart quasipolynomial of P. Furthermore, the leading term of every constituent polynomial is vol(P)t d , where the coefficient is the volume of P, and the period of this quasipolynomial is a divisor of D(P); in particular, if P has integral vertices, E • P is a polynomial. (These results are due to Ehrhart; see, e.g., [1].) An inside-out polytope (P, A ) that has rational vertices has similar properties. Its open Ehrhart quasipolynomial is the function E • P,A (t) of positive integers t whose value is the number of integer points in the t-fold dilate tP • , or equivalently the number of (1/t)-fractional points in P, that do not lie in any of the hyperplanes of A . (The equivalence of the two definitions is due to the fact that homogeneous hyperplanes are invariant under dilation.) The denominator D(P, A ) is the least common denominator of the coordinates of all vertices. Given U ∈ L (A ), the volume vol(U ∩ P) when dim U < d is a relative volume defined in terms of the integral lattice U ∩ Z d ; it is the proportion that the measure of U ∩ P bears to that of a fundamental domain of U ∩ Z d . In the case of P itself, it is the usual volume, since U = R d .
where the coefficient e d is the volume of P (a constant) and the coefficients e j (t) for j < d are periodic functions of t with period that divides the denominator D(P, A ).
The period p of E • P,A equals the least common multiple of the periods of the coefficients. Thus, p|D(P, A ). We write the constituents as E • P,A ,i for i = 0, 1, . . . , p − 1. A fundamental formula in the Ehrhart theory of inside-out polytopes [2,Equation (4.4)] is where µ denotes the Möbius function of L (P • , A ). This has the following important consequence.
Lemma 2.2. Suppose U∩P has integral vertices for every U ∈ L (P • , A ) whose codimension is < k. Then the coefficients e d−i (t) are constant for all i ≤ k.
Proof. Each Ehrhart quasipolynomial on the right-hand side of Equation (2.1) has the form where each e j (U; t) is a periodic function of t and e dim U (U; t) is the (dim U)-dimensional volume of U ∩ P. If U has integral vertices the denominator of U is 1 so each e j (U; t) is e j (U), a constant independent of t. Now, Thus, If codim U = i, then e d−i (U; t) = vol(P • ∩ U), a constant independent of t. If also U ∩ P • has integral vertices for all U with codim U < i, then all coefficients e d−i (U; t) = e d−i (U), independent of t, so e d−i is a constant. This is true for all i ≤ k; thus, all terms t j with j ≥ d − k have constant coefficients e j (U).
Taking k = 1 gives a special case of most importance for chess placements.
Lemma 2.3. If P has integral vertices, then e d−1 (t) is constant.

Configurations
From now on, the polytope is P = B q , the open polytope is P • = B •q , and the (open) inside-out polytope is (P • , A P ), where A P is the "move arrangement" to be defined shortly. (We assume that q > 0.) 3.1. Nonattacking configurations and the move arrangement.
The secret of the solution is to restate each rule of attack as an equation of a forbidden hyperplane in R 2q . A labelled configuration describes the locations of q labelled pieces; it is a point z = (z 1 , . . . , z q ) ∈ R 2q with each z i = (x i , y i ) ∈ Z 2 . The labelled configuration is nonattacking or attacking depending on whether or not it violates every attack equation. An attack equation is a linear constraint on z expressing the fact that labelled pieces P i and P j attack each other; in mathematical terms, that z j − z i is a multiple of a move m r .
To express an attack in the configuration space R 2q , observe that z j − z i ∈ m r can be rewritten as ( is the equation of a hyperplane in the configuration space (the move hyperplane H mr ij associated to the move m r ) whose points are attacking labelled configurations. (We also use slope notation: H d/c ij when m r = (c, d), with slope d/c.) These move hyperplanes in the configuration space form an arrangement of hyperplanes, A P , which we call the move arrangement of P. There are q 2 |M| of these hyperplanes.
For specificity, for each basic move vector m r = (c r , d r ), we define m ⊥ r := (d r , −c r ), which is m r rotated 90 • counterclockwise; thus, m ⊥ r points to the left side of the move line. The fact that the inflated polytope tB •q can engulf arbitrarily large integral points makes our polytopal approach awkward. Therefore, we often reduce the integral configuration z ∈ tB q to a fractional configuration z ′ = t −1 z ∈ B q . The denominators of the components of z ′ tell us which dilates tB q contain a corresponding integral point tz ′ , since tz ′ is integral precisely when t is a multiple of the least common denominator of the components of z ′ . We refer to either z ∈ tB q ∩ Z 2q or z ∈ B q ∩ Q 2q as a configuration, assuming that the context will make clear whether we mean an integral or fractional configuration.
Every move hyperplane contains the diagonal {(z, z, . . . , z) ∈ R 2q : z ∈ R 2 }; hence each move hyperplane intersects the interior P • = (B q ) • = B •q so it is definitely a member of the intersection semilattice. That is, for every board and piece.

Subspaces in the move arrangement.
In a configuration a piece P i has coordinates z i = (x i , y i ). Each subspace U is specified by equations that involve certain of the q labelled pieces, for instance P 1 , . . . , P κ , and no others; then U has the form U × R 2(q−κ) where U is a subspace of R 2κ whose equations in R 2κ use at least one coordinate corresponding to each of P 1 , . . . , P κ . We say that U has equations that involve the pieces P 1 , . . . , P κ (for short, U involves those pieces); and we call U the essential part of U. Let U ν κ denote any subspace with codimension ν involving precisely κ pieces. Similarly, U κ denotes a subspace of any codimension that involves κ pieces.
For counting points in P ∩ U we want special notation. We define α(U κ ; n) to be the number of configurations of κ pieces in a board of scale factor n + 1 that satisfy all the attack equations that define U κ ; that is, the number of integral points in B κ ∩ U. (We prefer n = t − 1 as parameter because it is natural for the square board and because we are interested in the coefficients of powers of n.) because U 1 and U 2 involve different coordinates. These reduction formulas are very useful, especially in the treatment of partial queens in Part III.
Certain subspaces in L (A P ) merit closer examination. Define .. = 2(number of subscripts − 1), and, for instance, for any two distinct slopes d/c and d ′ /c ′ .
Lemma 3.1. For any board and any move set M with |M| ≥ 2, we have Möbius functions ik . This Möbius function is well known (see, e.g., [13]).
The computation of µ(0, The slope graph Σ(U) is a labelled graph associated with an intersection subspace U. The subspace involves certain pieces; the nodes of Σ(U) correspond to those pieces and the edges correspond to all the hyperplanes that contain U. The edge corresponding to a hyperplane H d/c ij is labelled by the slope; thus we call the edge e d/c ij . An isomorphism of slope graphs is defined as a graph isomorphism that preserves slope labels. It is clear that subspaces are isomorphic if and only if their slope graphs are isomorphic. (That is why we call subspace isomorphism "combinatorial".) Note that to specify U it is not necessary to state all edges; only codim U edges are necessary.
The slope graph of a subspace is a subgraph of the slope graph of the arrangement A q P . (The superscript in A q P is a reminder that we are in R 2q .) Let Σ q (P) be the graph with nodes corresponding to q pieces labelled 1, 2, . . . , q and edges corresponding to the hyperplanes of A q P . Let Σ(P) be the union of all these; its node set is {v i : i = 1, 2, 3, . . .}. We use Σ q (B), the bishop slope graph, to prove in Part V that the period of a bishops counting function is at most 2, and we hope it can be used to get general results about periods. (Because the slope graph Σ(P) corresponds to hyperplane arrangements there is a related finitary matroid closure on the edge set whose closed sets are the edge sets of subspace graphs Σ(U), but it is complicated and we do not need it here. See the problem statement in Section 7.2.)

Isomorphic subspaces.
We now analyze the combinatorial structure of the subspaces U ∈ L (A q P ). Given U = U κ that involves pieces P 1 , . . . , P κ , let Aut(U) be the group of permutations of those pieces-that is, permutations of indices of the coordinates z i -that leave U invariant. We call such a permutation an automorphism of U. Then there are κ!/| Aut(U)| subspaces that are similar to U, meaning that they have the same equations except for a permutation of the subscripts 1, . . . , κ in the coordinates. For instance, let X be determined by P P P P P P P P P P P P P P P P P P P P r r r r r r r r r r r r r r r All have the form U 3 3 but X and Y are similar while Z is dissimilar to the others.
We say two subspaces U, U ′ ∈ L (A P ) are isomorphic or have the same type if there is a bijection from the pieces involved in U to those involved in U ′ which transforms the equations of U to those of U ′ . (Defined precisely by way of the slope graph Σ(U) in Section 3.3.) We write [U] for the isomorphism class, or type, of U. The subspaces need not live in the same dimension; i.e., if U ⊆ R 2q and U ′ ⊆ R 2q ′ , q and q ′ need not be equal (unless we are restricting ourselves to L (A q P )). Isomorphism is concerned only with the pieces that are involved in the subspaces. Isomorphic subspaces have the same codimension ν (because codim U in R 2κ equals codim U in R 2q ) though not necessarily the same dimension, and the same Möbius function µ(0, U), counting function α(U; n) (since it is the Ehrhart quasipolynomial of U), and automorphism group. The number of subspaces in L (A q P ) that are isomorphic to U κ is Isomorphism is a combinatorial relation. That can be made precise through the slope graph Σ(U) since it is clear that U and U ′ are isomorphic if and only if there is an isomorphism of their slope graphs that preserves edge labels. It is then obvious that U and U are isomorphic, and that U and U ′ are isomorphic if and only U and U ′ are isomorphic. Taking account of isomorphism and the fact that Equation (2.1) can be rewritten as where the inner sum ranges over all subspace types [U κ ], since the limit q on κ is equivalent to saying there is a representative U κ ∈ L (A q P ). Letting κ range up to ∞ does not change the value of the expression because (q) κ = 0 when κ > q.

Counting Configurations
An unlabelled configuration is a multiset of planar points z 1 , . . . , z q ; it corresponds to having unlabelled pieces. Unlabelled configurations are what we really want to count. Since a point with any z j = z i is attacking, the same number q! of nonattacking unlabelled configurations corresponds to each nonattacking labelled configuration.

The number of configurations.
Let u P (q; n) be the number of nonattacking unlabelled configurations and o P (q; n) the number of nonattacking labelled configurations with q pieces in the interior of the dilated board tB, where t = n + 1 is a positive integer; thus u P (q; n) = o P (q; n)/q!.
Let vol B denote the area of B. Proof. We prove the theorem by showing that o P (q; n) is a quasipolynomial with suitable properties. We already know that o P (q; n) is the number of integral lattice points in the interior of tB q that are not in any of the move hyperplanes. Since the hyperplanes are homogeneous, the integral lattice points in tB q can be scaled to t −1 -fractional points in B q . Technically, insideout theory applies to the count of these fractional points in B q . The theory also requires that the move hyperplanes have rational equations, which they do. According to the theory, o P (q; n) is a quasipolynomial function of t whose degree is dim B q , which is 2q, and whose leading coefficient is the volume of B q , which is vol(B) q .
Its leading coefficient is a constant, γ 0 (n) = vol(B) q /q! (since u P (q; n) is a disguised Ehrhart quasipolynomial) and its period is a divisor of the denominator D(B q , A P ).

The general form of coefficients.
We demonstrate that the coefficients in the labelled counting quasipolynomial o P (q; n) = q!u P (q; n) are themselves polynomials in q. The key to the proof is a new variable, the number of lattice points in the interior of the dilated board; that is, it is the number of locations a single piece can be placed on the dilated board. This variable is a quadratic quasipolynomial function of n (and its leading term is (vol B)n 2 ), so in terms of N we can expand each subspace Ehrhart quasipolynomial as whereΓ j = nΓ j1 +Γ j0 , a linear quasipolynomial in n; thus the Ehrhart quasipolynomial of U ν κ becomes Write C k (f (n)) for the coefficient of n k in a quasipolynomial f (n) (this coefficient may vary periodically with n).
Theorem 4.2 (Coefficient Theorem). The coefficient q!γ i of n 2q−i in each constituent of o P (q; n) is a polynomial in q of degree 2i. A formula for the coefficient is In particular, γ 0 = (vol B) q /q!, a constant, and γ 1 is constant if the vertices of B are integral points.
Proof. The constancy of γ 1 when B is integral is from Lemma 2.3.

We rewrite Equation (3.2) via Equation (4.2) as
where the third summation ranges over all subspace types [U ν κ ] for κ ≤ q. In this sum only the factors (q) κ and N q involve q.
Since no subspace can involve only one piece, there are two kinds of subspace: U 0 2q = R 2q , which gives the term N q , and U ν κ with ν > 0 and κ ≥ 2. If we defineΓ j := 0 when j < 0 and note that only the subspace R 2q contributes an N q term, then we may write Substituting for N and theΓ j in terms of n, the last expression becomes a quasipolynomial function of n. We conclude that q!γ i is the coefficient of n 2q−i in that quasipolynomial. This coefficient is independent of q except for the factor (q) κ . It is also a finite sum. First, ν ≤ i since a subspace of codimension greater than i will not contribute to the coefficient of n 2q−i . Also, ν ≥ κ/2 because every piece must participate in an equation of U ν κ , each of which involves two pieces. It follows from κ/2 ≤ ν ≤ i that κ ≤ 2i. In addition, k ≤ κ ≤ 2i. Since q appears only in the factors (q) κ and κ is bounded by 2i, we conclude that q!γ i is a polynomial function of q of degree at most 2i if n is held constant.
The bound ν ≤ 2κ − 2 follows from the fact that the smallest subspace that involves κ pieces is W = [κ] , which has codimension 2κ − 2.
Moreover, κ ≥ i/2. For U = U ν κ , the dimension of U is 2κ − ν so the leading term of α(U; n) has degree 2κ − nu and the last term has degree 0 in terms of n. For E B •q ∩U (n + 1) = α(U; n)N q−κ has, in terms of n, leading and final degrees 2q − ν and 2q − 2κ. That is, if i > 2κ, U cannot contribute to γ i ; that is why we may assume the restriction κ ≥ i/2. Now we consider the effect of the variability of n. Let P be the smallest common period (with respect to n) of all α(U; n) for all types [U] that appear in the sum (4.3). EveryΓ i−ν (U) is periodic with a period that divides P , and so is N. Therefore the coefficient of (q) κ in (4.3) is periodic with a period that divides P . We conclude that q!γ i is a polynomial function of q whose precise polynomial may vary periodically with n and whose period divides P .
The last step is to determine the degree. We showed that the largest conceivable degree of q is κ = 2i. A term with (q) 2i arises only from a subspace involving κ = 2i pieces; then ν must equal i. The degree is indeed 2i because a coefficient of (q) 2i arises only from a subspace of the form U i 2i . That coefficient isΓ 0 (U i 2i ), which is the leading coefficient of α(U i 2i ; n), hence a volume and not zero. In sum, the coefficient of (q) 2i in q!γ i is nonzero so q!γ i has degree exactly 2i.

Configuration types
For each basic move m r ∈ M from a fixed location, the line m r is naturally directed, so it has a left and right side. Given a nonattacking configuration of q pieces, record, for each piece P i at location z i and each move line z i + m r through P i , oriented in the direction of m r , the indices of the points P j that lie on the left side of the line. The set of these lists, for every pair, is the combinatorial type of the labelled configuration, briefly the labelled configuration type. (Our configuration types are always nonattacking; we are not interested in attacking types.) Another way to describe a labelled configuration type is by building a nonattacking configuration, one piece at a time. Place the first piece, labelled P 1 , at z 1 ∈ tB • ∩ Z 2 . This creates |M| lines through z 1 that may not be occupied by any other piece, and 2|M| regions that may be occupied. The second piece, P 2 at z 2 , will be in one of these regions. Now we have |M| forbidden lines through z 2 ; these lines in combination create permitted regions that will be occupied by the other pieces. Placing the third piece further subdivides these into a larger number of regions, and similarly with each placement up to the last piece. The sequence of choices of region is equivalent to the labelled configuration type.
By forgetting the order of the pieces we have an unlabelled combinatorial type of configuration, for short an unlabelled configuration type. We want to know how many unlabelled configuration types there are.
Lemma 5.1. There are q! labelled nonattacking configuration types for each unlabelled type.
Proof. In the left-to-right direction −m ⊥ r perpendicular to a move line m r , the q labelled pieces appear in a definite order, (P 1 , P 2 , . . . , P q ). This is indicated by the left-side list of the ith piece with respect to m r , which is {1, . . . , i − 1}. Renumbering the pieces changes the order, hence the left-side list of at least one piece, and therefore the labelled configuration type.
Lemma 5.2. The labelled nonattacking configuration types are in one-to-one correspondence with the regions of (B q , A P ).
Proof. We need to be more formal about labelled configuration types. A configuration on the t-fold board tB, in terms of coordinates, is z = (z 1 , z 2 , . . . , z q ) ∈ (tB • ) q ∩ Z 2q . We normalize this to a fractional configuration t −1 z ∈ (B • ) q . The normalized configurations are just as good as the integral ones as far as describing configuration types, because the inequalities that describe types are homogeneous.
The type of a configuration z is a list of lists of lists. The ith point has lists L ir = {j : P j is on the left side of the rth move line through P i }, one for each basic move m r . That is, . This inequality is precisely what defines the positive halfspace of a hyperplane in A P ; the collection of all such inequalities derived from the configuration z determines a subset of the interior of B q , which is nonvoid because it contains the fractional configuration t −1 z. Consequently, a configuration determines a region of (B q , A P ).
Conversely, any region contains a fractional point t −1 z ∈ t −1 Z 2q for a sufficiently large integer t. Therefore, it corresponds to one or more configuration types. However, it cannot correspond to more than one configuration type, because the inequalities that define the region determine which indices j are in which list L ir for each i and r.
Proof. By [2,Theorem 4.1], the number of regions of (B q , A P ) is Still another way to look at the type of a configuration is through isotopy. Two labelled configurations z and z ′ are isotopic if one can be deformed into the other by a continuous movement in the configuration space R 2q without at any time crossing a move hyperplane. It is clear from the correspondence between lists and regions in the proof of Lemma 5.2, and the convexity of regions, that this is possible if and only if z and z ′ have the same left-side lists, and then the isotopism can be performed along a line segment in the interior of tB q .
On the other hand, one might ask about discrete isotopy, where we move one piece at a time on the board. A discrete isotopism is a sequence of steps, z = z 0 → z 1 → · · · → z k = z ′ where z j−1 and z j differ only by making a legitimate move of a single piece that does not change the combinatorial type of the configuration. One should allow any amount of inflation, i.e., one should be allowed to multiply all the coordinates by a very large positive integer before performing the isotopism (which one can think of as replacing the (1/t)-lattice by a finer (1/kt)-lattice). One would naively expect this to be equivalent to continuous isotopy, and indeed it is, once we overcome two difficutlies.
First, if there is only one basic move m, the only configurations that can be reached from a nonattacking configuration z by allowed moves are those in the line through z in the direction of m (in some z i plane). Therefore, there must be more than one move in M.
Second, even if there are two basic moves, there can be configurations that are unreachable from each other in a board tB if t is fixed; for instance, in a configuration of bishops no moves can change the numbers of bishops on squares of each color. That problem is solvable by inflation.
The proof begins with a planar lemma. Note that any two basic moves are nonparallel.
Lemma 5.5. Given two basic moves, m 1 and m 2 , there is a sequence of moves that takes a piece from z = (x, y) Proof. There exists such a sequence if and only if there is an integral solution to κm 1 +λm 2 = (x ′ − x, y ′ − y). Let C = m 1 m 2 . The equation to be solved is Inverting, where C * is the cofactor matrix, which is an integral matrix. By the assumptions on moves, the greatest common divisor of the entries in either column of C is 1; thus, an integral solution exists if and only if x ′ − x and y ′ − y are multiples of det C.
Proof of Theorem 5.4. Choose two basic moves m 1 , m 2 ∈ M. Let z = (z 1 , . . . , z q ), z ′ = (z ′ 1 , . . . , z ′ q ) ∈ Z 2q be nonattacking configurations of the same combinatorial type on the dilated board tB • , where t > 0. No restriction hyperplane separates them; that is, they lie in the same open region R of A P . We want a discrete isotopism from z to z ′ , that is, is a sequence of moves of individual pieces that gives a sequence of (fractional) configurations lying in R ∩ B • ∩ τ −1 Z 2q for some τ ∈ Z >0 .
A sequence of individual moves is expressed (disregarding its order) by solving the Diophantine equation This is a set of q independent equations: . . , q. We know from Lemma 5.5 when they are solvable: if and only if det C divides every component of z ′ − z. If we multiply the entire board by k, replacing z ′ − z by k(z ′ − z), this condition is satisfied; thus, using kt as the board dilation factor, we get a walk kI := (kz = z 0 , z 1 , . . . , z l = kz ′ ), from kz to kz ′ in (ktB • ) q ∩ Z 2q consisting of integral multiples of moves m 1 and m 2 . We normalize kI to lie in (tB • ) q ∩ k −1 Z 2q through division by k; this gives a walk Define I 0 := (0, k −1 z 1 − z, k −1 z 2 − z, . . . , z ′ − z), the walk I translated to the origin; thus we may write I = z + I 0 .
We squeeze I into R by shrinking and replicating it. The line segment [z, z ′ ] lies in R ∩ (tB • ) q by the convexity of regions and of the polytope (tB • ) q . For some δ ∈ R >0 the segment has a δ-neighborhood U contained in R∩(tB • ) q . By taking a sufficiently large divisor τ ∈ Z >0 we can ensure that In particular, that is true for every z ′′ = z + (j − 1)τ −1 (z ′ − z) such that j ∈ {1, . . . , τ }. Consequently, the concatenated sequence is a walk from z to z ′ in (tB • ) q ∩ (kτ ) −1 Z 2q by (1/kτ )-fractions of legal moves, is contained in R, and is therefore a discrete isotopism from z to z ′ .
Proposition 5.6. The number of nonattacking configuration types for q = 1 is 1. For q = 2 it is |M|, the number of basic moves.
Proof. Adding one piece at a time as described in the opening of this section, it is clear that two labelled pieces have 2|M| configuration types and two unlabelled ones have |M|.
Thus, for any piece P, the formula for u P (q; n), upon setting n = −1, must yield 1 when q = 1 and |M| when q = 2. This provides a means for checking formulas. Based on the (apparent) facts about queens and nightriders (see below), we propose: Conjecture 5.7. The number of nonattacking configuration types of 3 pieces depends only on |M|.
We think the number depends on the actual moves for large q, though we are not sure where that dependence begins; we suspect q = 4 or q = 5.
On the other hand, if there are hardly any basic moves, the number of configuration types is always independent of the actual moves.
Theorem 5.8. The number of unlabelled combinatorial types of nonattacking configuration of q pieces is 1 for a piece with only one move and q! for any piece with exactly two moves.
Proof. The case |M| = 1 is obvious. Assume M = {m 1 , m 2 } and label the pieces. Take the basic moves as coordinate vectors in a new coordinate system, in which m 1 is the horizontal move to the right and m 2 is the vertical move up.
A configuration type is formalized by the list of lists just described. Since no two pieces are on the same horizontal line, the lists L i1 are determined by the permutation of the piece labels in order of height. Similarly, the lists L i2 are determined by the order of piece labels from left to right. There are q! permutations of each kind, and the horizontal and vertical permutations are independent. Hence the number of labelled combinatorial types is (q!) 2 . Upon dividing by q! we have q! combinatorial types for unlabelled pieces.
In particular, Theorem 5.8 applies to the rook R and the bishop B to give q! unlabelled combinatorial configurations for q pieces. For the queen Q and the nightrider N, we can apply Theorem 5.3 to generate data. For example, the methods from Part II give the previously known formula for two queens, Subtracting the number of attacking pairs of squares in all knight-like diagonals from the total number of pairs gives the formula for two nightriders: For both of these equations, the number of combinatorial types of configuration of two (unlabelled) pieces is u Q (2; −1) = u N (2; −1) = 4, in accord with Proposition 5.6. Using derived and known formulas for queens, we have the data in Table 5.1. The number of combinatorial configuration types of nonattacking placements of 3 nightriders in an n×n square board is 36, based on Kotěšovec's enormous formula for three nightriders (undoubtedly correct, though unproved) [9]. The fact that this agrees with the number for three queens gave rise to Conjecture 5.7. Corollary III.4.3 on three partial queens supports the conjecture.  Table 5.1. The number of combinatorial configuration types of q (unlabelled) queens in an n × n square board.

Bounds on the period
Theorem 4.1 says nothing about the period of u P (q; n). We want to bound the period by deriving the denominator from the plane geometry of B (which gives the boundary inequalities) and from M (which gives the attack constraints).
Let the boundary inequalities (with integral coefficients) of the polygon B be a j x+b j y ≤ β j for 1 ≤ j ≤ ω. The pieces have coordinate (column) vectors z 1 , z 2 , . . . , z q , which must satisfy a j x i + b j y i ≤ β j for all 1 ≤ i ≤ q and 1 ≤ j ≤ ω. Then the system Az = b in Equation (6.1) contains all the equations that determine any one vertex of the inside-out polytope (B q , A P ).
where M and B are the matrices containing the row vectors m ⊥ r , and where β is the column vector of constant terms β 1 , . . . , β ω . We define A ′ to be the top half of A.
A fundamental fact from linear algebra is the following lemma.
Lemma 6.1. The configuration z ∈ R 2q is a vertex of the inside-out polytope (P, A ) if and only if it is in the closed polytope P and there are k attack equations and 2q − k boundary equations that uniquely determine z.
A vertex corresponds to a set of violated boundary and attack constraints that determines uniquely (up to translation) a particular placement of q labelled pieces on the lattice points contained in some integer dilate tB of the closed board.

Cramer's rule and rectangular boards.
Alternatively, we might investigate the system in Equation (6.1) directly as a matrix. It follows by Cramer's Rule and Lemma 6.1 that every denominator of an inside-out vertex divides a 2q × 2q subdeterminant of A. The period of the counting quasipolynomial of (B q , A P ) is a divisor of the least common multiple of all 2q × 2q subdeterminants of A. This quantity is not so easy to determine, but for rectangular boards there is a way to estimate it, if there are not too many moves. In general lcmd(A ′ ) is difficult to compute. Two of us studied it and found a computable formula that applies as long as the moves matrix M has up to two rows [6]. Observe that A ′ is the Kronecker product H T q ⊗ M where H T q (H is 'Eta') is the matrix consisting of one row for each pair of different pieces, say i and j, in which all columns are zero except for a 1 in the column of piece i and a −1 in that of piece j. Thus, H q is the oriented incidence matrix of the complete graph K q , which is well known to be totally unimodular with rank q − 1. In this situation we can calculate lcmd(A ′ ) when M has two rows by means of [6,Corollary 2], which in terms of M = d 1 −c 1 d 2 −c 2 and H T q states that, for a piece with two moves, , where LCM p denotes the least common multiple of all the terms for p in the indicated range. We conclude that, for a piece with one or two moves on a rectangular board with sides parallel to the axes, the period of o P (q; n) is a divisor of the right-hand side of Equation (6.2). This applies, for example, to the bishop, where the right-hand side equals 2 q (see [6]). Unfortunately, this bound on the period is far from sharp (see Section 6.2) and, worse, the theory of [6] does not apply to a matrix M with more than two rows, which means a piece with more than two move directions. For such matrices, e.g., for the queen and nightrider, we have to calculate the determinantal upper bound lcmd(A ′ ) on the period separately for each value of q. One hopes that Equation (6.2) can be generalized to m × 2 matrices, though probably it is excessively complex when there are more than two moves.
In summary, the disadvantage of the lcmd bound is that it is weak; the advantage is that it is explicit if P has one or two moves.
For the bishop, the move matrix has lcmd(M B ) = 2. It follows that the period of u B (q; n) divides 2 q−1 . In Part V we prove that an upper bound on the period of u B (q; n) is 2, which rigorously establishes the period and consequently the correctness of Kotěšovec's quasipolynomial formulas. The proof relies on signed graph theory applied to the bishops hyperplane arrangement A B . Table 6.1 shows descriptive data for nonattacking placements of few bishops.
Unlike in the case of bishops, the period of the counting quasipolynomial u Q (q; n) for q queens is not simple and we have no general formula. The denominator of the inside-out polytope and the value of lcmd(M) can only be computed for very small values of q. Again we see that lcmd(M) is a weak bound.

Questions, Extensions
Work on nonattacking chess placements raises many questions, several of which have general interest. We propose the following questions and directions, with others to come in subsequent parts of this series.

Combinatorial configuration types.
We noticed that three queens and three nightriders have the same number of combinatorial types of nonattacking configuration. The queen and nightrider also have the same number of moves. The slope matroid SM q (P) of order q of a piece P with basic move set (or for this purpose, slope set) M is the matroid of the move arrangement A q P that consists of all move hyperplanes in R 2q . It should be viewed as a matroid on the edge set of the slope graph Σ q (P). The problem is to describe the rank function and closed sets of the slope matroid.
We propose that the rules for closed sets are the same as the geometrical incidence theorems about rational points and slopes. We cannot say exactly what that means, but here is an example. Suppose we have slopes 1/0, 0/1, 1/1, −1/1. Consider the hyperplanes The ultimate goal is to automate the listing of closed subgraphs of SM q (M). Since the automorphism groups and Möbius function can be computed automatically without too much difficulty, that would enable automatic generation of formulas for u P (q; n) for arbitrary sets of moves and large values of q. Since that goal requires knowing all rational incidence theorems it is unlikely to be attainable except for relatively small q and M, but M indeed is small for real pieces, and any understanding of small incidences would enlarge the range of accessible values of q.

Riders versus non-riders.
Kotěšovec's many formulas are quasipolynomials only for riders. For all others he gets an eventual polynomial, as in our analysis of pieces on a k × n board where k is fixed [4]. It seems clear that the reason he does not get a quasipolynomial is that, with nonriders, not all moves have unbounded distance, so Ehrhart theory does not apply. The reason he gets an eventual polynomial is less apparent. We believe it is, in essence, that the count is the number of ways to place a finite number of "tight" nonattacking configurations involving a total of q pieces so that no two tight configurations overlap, each tight configuration that can fit on the board contributes a polynomial to the total count, and for large n the board is big enough that every possible tight configuration can fit. How to make this intuitive statement precise is not precisely clear.

Varied moves.
Our counting method extends to a much more general situation. For convenience we assume distinguishable pieces, P 1 , . . . , P q . Think of the moves as attacks, and suppose the basic attacks m ij,r may depend on both the attacking piece P i and the attacked piece P j . This may seem unrealistically general but it permits us to combine more than one interesting type of situation. We form a move matrix M ij from the basic attacks of P i on P j . Theorem 4.1 and the ensuing discussion of the period remains valid if we take A ′ (the upper half of the system in Equation (6.1)) to be the matrix in Equation (7.1).
The most realistic case is that where, as in chess, the moves (or attacks) do not depend on the piece being attacked. In that case, M ij = M i , independent of j, and the matrix A ′ becomes more similar to that of Equation (6.1).

Higher dimensions.
It is tempting to apply the inside-out polytope method to boards of higher dimension such as hypercubical boards B = (0, 1) d . However, pieces with multidimensional moves would surely be much more difficult to treat. For two-dimensional moves m r , the orthogonal vector m ⊥ r defines the move line so the attacking configurations in R dq are determined by a hyperplane; but when d > 2 a move line requires more than one equation to define it, so the attacking configurations are determined by a subspace of codimension d − 1.

A generalization of total dual integrality?
The least common multiple of subdeterminants of the coefficient matrix of the attack hyperplanes (that is, lcmd) turned out to be a very inefficient bound on the period, because it is much larger than the least common denominator of all vertices. This reminds us of the fact that there are totally dual integral matrices which are not totally unimodular; indeed the (7.1) analogy is close, since total unimodularity means the lcmd = 1. We suggest that a worthy general question about an integral r × s matrix M is the relationship between lcmd M and the least common denominator D of all lattice vertices of M, defined as points z ∈ R s determined by restrictions Az ∈ Z s where A is any nonsingular matrix consisting of s rows of M. Though D may usually be much less than lcmd M, the cases of equality, being analogs of totally unimodular matrices, might be quite interesting.