Enumerating partial Latin rectangles

This paper deals with distinct computational methods to enumerate the set $\mathrm{PLR}(r,s,n;m)$ of $r \times s$ partial Latin rectangles on $n$ symbols with $m$ non-empty cells. For fixed $r$, $s$, and $n$, we prove that the size of this set is a symmetric polynomial of degree $3m$, and we determine the leading terms (the monomials of degree $3m$ through $3m-9$) using inclusion-exclusion. For $m \leq 13$, exact formulas for these symmetric polynomials are determined using a chromatic polynomial method. Adapting Sade's method for enumerating Latin squares, we compute the exact size of $\mathrm{PLR}(r,s,n;m)$, for all $r \leq s \leq n \leq 7$, and all $r \leq s \leq 6$ when $n=8$. Using an algebraic geometry method together with Burnside's Lemma, we enumerate isomorphism, isotopism, and main classes when $r \leq s \leq n \leq 6$. Numerical results have been cross-checked where possible.


Introduction
Let [n] := {1, 2, . . . , n}. An r × s partial Latin rectangle L = (l ij ) on the symbol set [n] ∪ {·} is an r × s matrix such that each row and each column has at most one copy of any symbol in [n]. Here, r, s, and n are arbitrary positive integers, and we admit the possibility that n < min{r, s}. If r = s = n, then this constitutes a partial Latin square of order n. The cells containing the symbol · are considered empty, and we say that l ij is undefined. An entry of L is any triple (i, j, l ij ) ∈ [r] × [s] × [n]. The set of all entries of L is called its entry set, which is denoted E(L). The weight of L is its number of non-empty cells, that is, the size of its entry set. Let PLR(r, s, n; m) denote the set of r × s partial Latin rectangles on the symbol set [n] ∪ {·} of weight m and let PLR(r, s, n) = ∪ 0≤m≤rs PLR(r, s, n; m). Let PLS(n; m) = PLR(n, n, n; m) be the set of partial Latin squares of weight m. For m = n 2 , this is the set of Latin squares of order n.
For each positive integer t ∈ Z + , let S t denote the symmetric group on the set [t].
The remainder of the paper is organized as follows. The three following sections deal with distinct combinatorial methods that enable us to determine the size of the set PLR(r, s, n; m): (a) Section 2: an inclusion-exclusion method that demonstrates #PLR(r, s, n; m) for fixed m is a symmetric polynomial of degree 3m; (b) Section 3: a chromatic polynomial method that gives exact formulas for this symmetric polynomial, which we compute for m ≤ 13; and (c) Section 4: an adaptation of Sade's method (which efficiently enumerates Latin squares) to partial Latin rectangles, which enables us to determine explicitly the number #PLR(r, s, n; m) for all r ≤ s ≤ n ≤ 7, and all r ≤ s ≤ 6 when n = 8. Section 5 describes an algebraic method for computing #PLR((Θ, π); m) and also the number of isotopisms between two given partial Latin rectangles. In Section 6 we use the Orbit-Stabilizer Theorem and Burnside's Lemma to compute the size of isomorphisms, isotopism and main classes. Section 7 describes the computational results and the implementations of the various methods. In Section 8 we comment how these computational results have been crosschecked in order to ensure their accuracy. A glossary of the most common symbols that are used throughout the paper is shown in Appendix A. To improve the readability of the paper, tables are in Appendix B.

Inclusion-exclusion method
For fixed m ≥ 1, we find formulas for the size of PLR(r, s, n; m) by modifying the method for enumerating partial orthomorphisms of finite cyclic groups given in [63]. At first, this is a surprising claim, as partial Latin rectangles and partial orthomorphisms are largely unrelated (unless we impose some symmetry, which we don't in the context of this section). The similarity between these two types of objects is that both partial Latin rectangles of weight m and partial orthomorphisms with domain size m are equivalent to non-clashing m-sets of ordered triples (the difference is what constitutes a "clash").

Generalized ordered partial Latin rectangles
Let S m = S(r, s, n; m) be the set of sequences e = (e i ) m i=1 , where each e i = (e i [1], e i [2], e i [3]) is a 3-tuple in [r] × [s] × [n]. From any e ∈ S m , we construct an r × s matrix M = M (e) as follows: • We begin with each cell in M containing the empty multiset ∅.
• For i ∈ [m], we add symbol e i [3] in the multiset in cell (e i [1], e i [2]). If it turns out that every non-empty multiset in M has cardinality 1 and there are no repeated elements in any row or column of M , then M is essentially a partial Latin rectangle (formally, we need to map ∅ → · and {i} → i). For example, if r = s = n = m = 3 and e = (1, 1, 1), (1,2,3), (2,2,2) , then Thus, sequences in S m are generalized partial Latin rectangles consisting of m ordered entries.
Let A m be the subset of S m that gives rise to partial Latin rectangles. Hence, because we can order the entries in a partial Latin rectangle in m! ways. For fixed m, we define To find a formula for f m (r, s, n) by using inclusion-exclusion on the number of "clashes", let which we use to index the possible clashes in e ∈ S m as follows: Any e ∈ S m therefore has a corresponding set of clashes C e ⊆ C m . For any U ⊆ C m , define i.e., the sequences in S m that have the clashes in U (and possibly more clashes), and i.e., the sequences in S m that have precisely those clashes in U (and no more clashes). By definition, Hence, by inclusion-exclusion, When U = ∅, we have |D U | = |A m | and consequently the following lemma.

Graph colorings
Our next goal is to find an equation for |B V | in terms of the number of vertex colorings of an edgecolored graph, satisfying some additional constraints (neither vertex colorings nor edge colorings are required to be proper in the ordinary sense). Given V ⊆ C m , we define a graph G = G(V ) with an edge coloring δ = δ(V ) by the following process. We start with the null graph on the vertex set [m], and for each [i, j, k] ∈ V : I: If k = 1, then add a red edge between i and j.
II: If k = 2, then add a blue edge between i and j.
III: If k = 3, then add a green edge between i and j.
IV: Replace any parallel edges resulting from I-III with a single black edge.
We denote the graph together with its edge coloring generated from V by (G, δ) V . An example of an edge-colored graph generated in this way is given in Figure 1.  Sequences e ∈ B V are equivalent to a special type of vertex coloring φ of (G, δ) V , for which we assign to vertex i ∈ [m] the color This coloring satisfies the properties: • If there is a red edge between vertices i and j, then φ 2 (i) = φ 2 (j) and φ 3 (i) = φ 3 (j).
• If there is a black edge between vertices i and j, then φ 1 (i) = φ 1 (j), φ 2 (i) = φ 2 (j) and We call such a vertex coloring of (G, δ) V suitable. Conversely, any suitable vertex coloring of (G, δ) V with the vertex color set [r] × [s] × [n] that satisfies the above four properties is a member of B V , thus giving the following lemma.
Lemma 2.2. For all V ⊆ C m , the set B V is the set of suitable vertex colorings of (G, δ) V , hence |B V | is the number of suitable proper vertex colorings of (G, δ) V .
We can find a simple formula (Lemma 2.3) for the number of suitable colorings of (G, δ) V since each of the three coordinates can be accounted for separately. Let H 1 , H 2 , and H 3 respectively be the graphs formed by deleting the red, blue, and green edges from (G, δ) V , then ignoring the edge colors. For any graph H, let c(H) denote the number of connected components in H. Lemma 2.3. The number of proper suitable colorings of (G, δ) V is Proof. In order to be a suitable vertex coloring, the vertices in each component of H 1 must be assigned colors in G that agree at the first coordinate. We can thus assign the first coordinates of a suitable vertex coloring in r c(H 1 ) ways. Similar claims hold for H 2 and H 3 .
We are now ready to make the following fundamental observation about the polynomials f m .
This ensures that f m (r, s, n) is a polynomial in variables r, s, n and has integer coefficients. The leading term is (rsn) m , which arises when V = ∅; for all other V ⊆ C m , we see |B V | has degree less than 3m. Finally, to verify that f m (r, s, n) is a symmetric polynomial, we observe that we can permute the colors red, blue, and green (or equivalently, permute the third coordinate of the elements in C m ). Each equivalence class under this action contributes to the sum in Lemma 2.1, which is symmetric. We conclude that f m (r, s, n) is the sum of symmetric polynomials, and is also symmetric.

A simplified equation
For a 4-edge-colored graph (G, δ), with possible edge colors red, blue, green, and black, let |G| be the number of vertices in G, let |E(G)| be the number of edges in G, and let b(δ) be the number of black edges in δ. There are 4 |b(δ)| sets V ⊆ C m for which (G, δ) = (G, δ) V , since a black edge can be formed in 4 possible ways: (a) when exactly two of properties I, II and III hold, or (b) when all three of properties I, II and III hold. From Lemmas 2.1 and 2.3, we have From here, we use the following identity from [63]: For any (G, δ), we have using the Binomial Theorem. The local variable x counts the number of black edges where I, II and III all hold. This yields the following theorem: Theorem 2.5. For all r, s, n, m ≥ 1, we have The advantage of Theorem 2.5 is that it eliminates the need for accounting for clashes (via the variable V ). Instead, we are now working solely with graphs. For computational purposes, it is easier to work with isomorphism classes of graphs (rather than labeled graphs).
We will also account for isolated vertices mathematically. For v ≥ 0 and e ≥ 0, let Γ e,v denote the set of unlabeled e-edge v-vertex graphs without isolated vertices (the set Γ 0,0 contains the empty graph, whereas Γ e,1 = ∅). We can split Theorem 2.5 according to e, v, and Γ e,v to give the following theorem.
We obtain the theorem by rearranging this equation.
The following corollary follows straightforwardly from Theorem 2.6.
Corollary 2.7. For fixed m ≥ 1, the polynomial f m (r, s, n) is divisible by rsn.
Furthermore, we use the next result to reduce the required computation.
Lemma 2.8. Let G 1 and G 2 be two graphs. Then, 1. if both graphs are disjoint, then, P (G 1 ∪ G 2 ) = rsn P (G 1 )P (G 2 ); and 2. if both graphs meet at a single vertex, then P ( Finally, the following lemma is useful for finding which graphs have to be included when computing the leading terms in f m (r, s, n). Lemma 2.9. For any graph G on v vertices, the degree of (rsn) m−v+1 P (G) in Theorem 2.6 is at most 3m − 2v + 2c(G).
Proof. From Theorem 2.6, the degree of (rsn ). Let us show, by induction on the number of edges, that for any 4-edge-coloring δ (with equality when all the edges are red, say). If G has no edges, then we have equality in (2.1). Next, assume (

Chromatic polynomial method
Let R r,s be the r × s rook's graph, i.e., the Cartesian product of K r and K s . The graph R 3,4 is drawn in Figure 2. Any partial Latin rectangle in PLR(r, s, n; m) can be interpreted as a proper n-coloring of an m-vertex induced subgraph of R r,s . An example of this correspondence is also given in Figure 2. We can naturally think of (labeled) induced subgraphs of R r,s as (0, 1)-matrices, with a 1 in cell (i, j) whenever vertex (i, j) is present. Under this equivalence, we talk of the rows and columns We act on the set of r × s (0, 1)-matrices by permuting rows and columns. Under this action, we choose representatives from each orbit and call them canonical. After that, we define a function of canonical blocks such that (a) the number of 1's in the blocks sum to m; (b) the number of rows in the blocks sum to ≤ r; and (c) the number of columns in the blocks sum to ≤ s. Given any K ∈ K r,s,m,k , we can arrange the blocks as follows: where ∅ denotes an all-0 submatrix, so that there are r rows and c columns. Call this matrix M (K). If we permute the rows and columns of this matrix, we generate every r × s (0, 1)-matrix M that has {C(M i )} k i=1 = K some number of times, Γ say, by the Orbit-Stabilizer Theorem. It follows from (3.1) that since each K i corresponds to a disjoint component in the induced subgraph of R r,s . Let e row and e col denote the number of non-empty rows and columns in the matrix M (K), respectively. If there are ℓ distinct matrices in the multiset K, let k i , for i ∈ [ℓ], be the number of copies of the i-th distinct matrix. The elements in the stabilizer of M (K) are those which permute the all-0 rows and columns, permute the identical blocks amongst themselves, and stabilize each K i individually. Thus since every K i ∈ K is canonical, To compute #PLR(r, s, n; m) for small m, we thus: • Generate a list of possible blocks K with up to m ones, inequivalent under row and column permutations, and compute, for each block, the size of Aut(G K ), and the chromatic polynomial of K. Table 1 lists the results of this computation for m ≤ 5.
• Iterate through each K ∈ ∪ k≥0 K r,s,m,k , computing its contribution to (3.2) from the table generated in the first step.
To further reduce the computation, we only store blocks with no more rows than columns. This requires the modification of (3.3) to account for transposing the blocks. By ordering the set of all blocks, a multiset to keep track of which K i we transpose, with 1 meaning "transpose" and 0 meaning "don't transpose". We define ( We choose not to transpose square matrices at this stage, as it adds the task of identifying when the transpose of a matrix can be formed by permuting its rows and columns, hence we have condition (a). Condition (b) prevents overcounting in cases such as 1 0 0 1 0 0 0 1 1 and Thus, (3.2) can be rephrased to give the following theorem.

Sade's method
Sade's method [55] outstrips all other methods for finding the number of Latin squares [58]. Subsequent authors [9,50,49,70] who found the number of Latin squares of orders n ∈ {8, 9, 10, 11} implemented optimized computerized versions of Sade's method. We generalize Sade's method to partial Latin rectangles: L is isotopic to M , then they can be extended in the same number of ways to (r + 1) × s partial Latin rectangles of a given weight m by adding an (r + 1)-th row.
Proof. In the first case, the possible (r + 1)-th rows for L and M are the same. In the second case, if M = L Θ , then the possible (r + 1)-th rows of L Θ are precisely the possible (r + 1)-th rows of L after applying Θ.
Let L, M ∈ PLR(r, s, n). We say that L and M are Sade equivalent if L is isotopic to a partial Latin rectangle L ′ such that the columns of L ′ and M have the same sets of symbols. Particularly, L and M must have the same weight. Thus, for instance, the following four partial Latin rectangles in PLR(2, 3, 3; 4) are Sade equivalent.
Practically, we need a fast method for checking whether a large number of partial Latin rectangles are Sade equivalent. To this end, for each partial Latin rectangle L ∈ PLR(r, s, n), we perform the following steps, which we illustrate for this example PLR(3, 4, 3; 6): In our running example (4.1), we obtain: 2. Canonically label the graph in a way that preserves the vertex colors (to this end we use nauty [46], for which such a labeling is an internal procedure). In our running example, we obtain: Binary search for sn L ext among the Sade numbers in P LRs[i] 8: if sn L ext is found then  Other practical improvements can be made: • In enumerating up to 8 × 8 partial Latin rectangles, the Sade number will be less than 2 64 , which can thus be stored as 64-bit unsigned integers.
• When processing the last few rows, we can forgo Sade's method and instead use a simple backtracking algorithm to count the number of extensions up to completions of each partial Latin rectangle.
• Although #PLR(r, s, n; m) = #PLR(r, n, s; m), it is significantly faster to compute the value of #PLR(r, s, n; m) when s ≤ n.

Algebraic geometry method
In this section, we review how sets of partial Latin rectangles are identified with the algebraic sets of certain ideals. This follows the idea of Bayer [10] and Adams and Loustaunau [2] to solve the problem of n-coloring a graph by means of algebraic geometry, since every Latin square of order n is equivalent to an n-colored bipartite graph K n,n [44]. Much more recently, this algebraic method has been adapted to solve sudokus [6,34,56], enumerate quasigroup rings derived from partial Latin squares [20], enumerate partial Latin rectangles that admit a given autotopism [25,26,27,28] or autoparatopism [32], and also the number of isotopisms between two given partial Latin rectangles [30], thereby enabling us to compute in Section 6 the numbers of equivalence classes by means of the Orbit-Stabilizer Theorem and Burnside's Lemma. See [15,43] for more details on algebraic geometry.
, for all i ≤ m} . The algebraic set of I is the set of points V(I) := {(a 1 , . . . , a n ) ∈ k n : p(a 1 , . . . , a n ) = 0, for all p ∈ I}.
There is a bijection between partial Latin rectangles L = (l ij ) ∈ PLR(r, s, n; m) and elements of the algebraic set of I r,s,n;m : we have l ij = k whenever x ijk = 1, and l ij is undefined otherwise. More specifically: • Having x 2 ijk − x ijk = 0 implies that the algebraic set is contained in {0, 1} rsn . • Having x ijk x i ′ jk = 0 implies that the symbol k does not appear twice in the column j.
• Having x ijk x ij ′ k = 0 implies that the symbol k does not to appear twice in the row i.
• Having x ijk x ijk ′ = 0 implies that there is at most one symbol in the cell (i, j).

• Having i∈[r] j∈[s] k∈[n]
x ijk = m implies that the weight of the partial Latin rectangle L is m.
Since the algebraic set V(I r,s,n;m ) is finite and the ideal I r,s,n;m ∩ Q[x ijk ] is generated by the polynomial This fact has recently been used in [27] to compute #PLR(r, s, n; m), for all r, s, n ≤ 6 and m ≤ rs.
This algebraic geometry enumeration method can be generalized to include cases in which a certain autoparatopism is imposed as follows.
A similar approach enables us to determine the set of isotopisms between two partial Latin rectangles as follows. 11 , . . . , x rr , y 11 , . . . , y ss , z 11 , . . . , z nn ] be a polynomial ring in r 2 + s 2 + n 2 variables. The set I(P, Q) of isotopisms between two partial Latin rectangles P = (p ij ) and Q = (q ij ) in PLR(r, s, n) has a natural bijection with the algebraic set of the ideal z ij : j ∈ [n] + x ik y jl (z p ij q kl − 1) : i, k ∈ [r], j, l ∈ [s], such that p ij , q kl ∈ [n] + x ik y jl : i, k ∈ [r], j, l ∈ [s], p ij and/or q kl is undefined .
Consequently, the number of isotopisms from P to Q is given by Proof. The first three subideals of I P,Q imply V(I P,Q ) ⊆ {0, 1} r 2 +s 2 +n 2 . Every isotopism Θ = (α, β, γ) ∈ I r,s,n uniquely corresponds to a zero (x Θ 11 , . . . , x Θ rr , y Θ 11 , . . . , y Θ ss , z Θ 11 , . . . , z Θ nn ) in V(I P,Q ), where x Θ ij = 1, (resp., y Θ ij = 1 and z Θ ij = 1) if α(i) = j (resp., β(i) = j and γ(i) = j) and 0, otherwise. Specifically, the fourth and fifth subideals of I P,Q (in the statement of Theorem 5.2) imply α is a permutation of S r (the fourth one ensures the injectivity, while the fifth one ensures surjectivity). Similarly, the next two pairs of subideals imply β and γ are permutations of S s and S n , respectively, and hence, Θ is an isotopism of PLR(r, s, n). The last two subideals imply Θ is a bijection between the entry sets E(P ) and E(Q). Further, since ijk − x ijk ⊆ I P,Q , Seidenberg's Lemma and Theorem 3.7.19 in [43] imply the theorem statement.
6 Counting equivalence classes of partial Latin rectangles Theorem 5.2 can be used to determine not only the size of the autotopism group I(P, P ) of a partial Latin rectangle P , but also that of its autoparatopism group P(P, P ), because #P(P, P ) = π∈S 3 #I(P, P π ).
The following result shows how the computation of both values enables us to determine the size of the isotopism and main classes containing P by means of the Orbit-Stabilizer Theorem.
Theorem 6.1. Let P ∈ PLR(r, s, n). Then, 1. the number of partial Latin rectangles that are isotopic to P , i.e., the size of the isotopism class containing P , is r! s! n! #I(P, P ) ; 2. the number of partial Latin rectangles that are paratopic to P , i.e., the size of the main class containing P , is #S r,s,n r! s! n! #P(P, P ) ; and 3. the number of isotopism classes in the main class of P is #S r,s,n #I(P, P ) #P(P, P ) .
Proof. The first two claims follow from the Orbit-Stabilizer Theorem. For the third claim, we observe that paratopic partial Latin rectangles have autotopism groups of the same size, because Θ is an autotopism of P if and only if Λ −1 ΘΛ is an autotopism of P Λ for any paratopism Λ. They thus also have isotopism classes of the same size, which partition the main class, so the first two claims imply the third.
From here on, let Isom(n; m), Isot(r, s, n; m) and MC(r, s, n; m) respectively denote the set of isomorphism classes of PLS(n; m) and the sets of isotopism and main classes of PLR(r, s, n; m). The following result follows straightforwardly from Burnside's Lemma and the fact of acting the isomorphism, isotopism, and paratopism groups on the set of partial Latin rectangles of a given order. #MC(r, s, n; m) = 1 r! s! n! #S r,s,n (Θ,π)∈Pr,s,n #PLR((Θ, π); m).
The following result is shown using similar reasoning to that used by Mendis and Wanless in the proof of Theorem 2.2 in [52] for paratopisms of Latin squares. Theorem 6.4. Two paratopisms ((α 1 , α 2 , α 3 ), π 1 ) and ((β 1 , β 2 , β 3 ), π 2 ) in P r,s,n are conjugate if and only if there is a length preserving bijection η from the cycles of π 1 to those of π 2 such that, if η maps a cycle (a 1 , . . . , a k ) to a cycle (b 1 , . . . , b k ), both of them in the symmetric group S 3 , then α a 1 · · · α a k ∼ β b 1 · · · β b k .
Proof. If r = s = n, or if π 1 = π 2 , the proof of Theorem 2.2 in [52] suffices the prove the theorem. Otherwise, up to equivalence, we have π 1 = (12) and π 2 = Id and r = s = n. Clearly, η does not exist. The two paratopisms are not conjugate since conjugation in P r,s,n preserves the conjugacy class of the parastrophe permutation.
And we similarly prove the other equalities. Theorem 6.4 implies the conjugacy claims.
Conjugacy in symmetric groups constitutes an equivalence relation in which each conjugacy class is characterized by the common cycle structure of their elements. Recall that the cycle structure of a permutation π ∈ S m is the expression z π := m d π m · · · 1 d π 1 , where d π i denotes the number of cycles of length i in the unique cycle decomposition of the permutation π. Thus, for instance, the cycle structure of the permutation (12)(345)(78)(9) is 3 1 2 2 1 1 . From here on, we denote the set of cycle structures of the symmetric group S m as CS m . The number of permutations in S m with cycle structure m dm · · · 1 d 1 ∈ CS m m!
Given a cycle structure z ∈ CS m , define d z i := d π i for any permutation π ∈ S m with cycle structure z. The next theorem follows straightforwardly from Theorem 6.2, Lemma 6.3 and (6.1).
Theorem 6.6. Let r, s, n ≥ 1 and m ≤ rs. Then, 1. the number of isomorphism classes in PLS(n; m) is , and 2. the number of isotopism classes in PLR(r, s, n; m) is #Isot(r, s, n; m) = In practice, it is not necessary perform computations for all possible triples (z 1 , z 2 , z 3 ) ∈ CS r × CS s × CS n to determine the number of isotopism classes in statement 2 of Theorem 6.6. The following lemma gives necessary and sufficient conditions for PLR((Θ, Id)) to contain a non-empty partial Latin rectangle. This generalizes in a natural way a pair of similar results referred to Latin squares [61,Lemma 3.6] and partial Latin squares [25, Lemma 2.2]. Lemma 6.7. Let Θ ∈ I r,s,n be an isotopism of cycle structure (z 1 , z 2 , z 3 ) ∈ CS r × CS s × CS n . The set PLR((Θ, Id)) contains at least one non-empty partial Latin rectangle if and only if there exists a triple (i, j, k) ∈ [r] × [s] × [n] such that the following two conditions are satisfied: 1. lcm(i, j) = lcm(i, k) = lcm(j, k) = lcm(i, j, k), and 2. z 1 has an i-cycle, z 2 has a j-cycle, and z 3 has a k-cycle.
Parastrophisms preserve the number of isotopism and main classes of partial Latin rectangles of a given order. Thus, in practice, it is enough to focus on the case r ≤ s ≤ n to determine the number of isotopism classes in PLR(r, s, n; m), whereas the number of main classes splits into three cases: (a) r < s < n; (b) r = s < n; and (c) r = s = n. In (a), the parastrophism group S r,s,n is only formed by the trivial permutation Id ∈ S 3 and hence, the number of main classes coincides with that of isotopism classes. In order to deal with (b) and (c), and keeping in mind Theorem 6.5, let us define the following two sets for each pair of permutations β, γ ∈ S r C 1 (β, γ) := {(α, β ′ , γ ′ ) ∈ I r,r,n : αβ ′ ∼ β and γ ′ ∼ γ}. C 2 (γ) := {(α, β, γ ′ ) ∈ I r,r,r : αβγ ′ ∼ γ}.
The next result holds straightforwardly from Theorem 6.2, Lemma 6.3, and (6.1). Theorem 6.8. Let r, n ≥ 1 and m ≤ r 2 . The following statements hold.

Computational results
Inclusion-exclusion method For small graphs G, Tables 2 and 3 list the polynomial P (G) = P (G; r, s, n) in Theorem 2.6. These polynomials were computed using a C++ program, using geng (packaged with nauty [45,46,48]) to generate a list of isolated-vertex-free non-isomorphic graphs (e.g. "geng -d1 3" generates 3-vertex isomorphism class representatives with minimum degree 1) and bliss [40] to compute their automorphism group size. The notation abc is shorthand for the sum of the monic monomials with variables r, s, and n and exponents a, b, and c. For example, 210 = r 2 s + r 2 n + s 2 r + s 2 n + n 2 r + n 2 s and 2 100 = 2(r + s + n).
By Lemma 2.9, substituting the data in Tables 2 and 3 into the formula in Theorem 2.6 gives a formula for f m (r, s, n) containing all terms of degree ≥ 3m−9; unlisted graphs G have v −c(G) ≥ 5, and thus contribute to terms in the polynomial with degree at most 3m − 10. In this regard, the following result generalizes Theorem 4.7 in [27], which only deals with the case m ≤ 6.  Tables 2 and 3 contain all graphs with no isolated vertices with up to 5 vertices, and when v ≥ 6, graphs make a zero contribution to Theorem 2.6 since the binomial m v = 0.
Chromatic polynomial method We use Theorem 3.1 to compute exact formulas for f m (r, s, n) for all m ≤ 13 which are available from [31]. They corroborate in particular the formulas shown in [27] for m ≤ 6. The authors acknowledge the use of GAP [35], the GAP package GRAPE [57] (which uses nauty), and the Tutte polynomial software tutte bhkk [11] (available from github.com/thorehusfeldt/tutte_bh for these computations. Sade's method We implement Algorithm 1 in C++ using nauty for graph isomorphism and GMP [37] for arbitrary precision arithmetic, which we use to compute #PLR(r, s, n; m) for all r, s, n ≤ 7, and for r, s ≤ 6 when n = 8 (for all 0 ≤ m ≤ rs). Our computations for r, s, n ≤ 6 corroborate Tables 2 through 5 in [27]. The remaining cases are listed here in Tables 4 through 8.
Algebraic geometry method We implement Theorem 5.1 in Singular [17] and Minion [36] to determine the values ∆(z 1 , z 2 , z 3 ), for all (z 1 , z 2 , z 3 ) ∈ CS r × CS s × CS n satisfying the conditions of Lemma 6.7, when r, s, n ≤ 6. Theorem 6.6 has then be applied to obtain the corresponding numbers of isomorphism and isotopism classes of partial Latin rectangles, as listed in Tables 9 through 12. The number of main classes of partial Latin rectangles in PLR(r, s, n) according to their weights is given in Tables 13 and 14 when 2 ≤ r ≤ s ≤ n ≤ 6. We include only the cases in which r, s, and n are not pairwise distinct; otherwise, the number of main classes and isotopism classes coincide.
Constructive enumeration It is also possible to enumerate constructively the number of isotopism and main classes in PLR(r, s, n; m). We simply extend all representative weight-(m − 1) partial Latin rectangles by one entry in all possible ways, and throw away those that belong to the same class as an already discovered partial Latin rectangle. To compare isotopism and main class equivalence, it is enough, for instance, to generate a graph similar to those proposed in [47].
For fixed m ≥ 1, provided r ≥ m, s ≥ m, and n ≥ m, the number of isotopism classes and main classes in the set PLR(r, s, n; m) do not vary with r, s and n, which amounts to adding empty rows, empty columns, or unused symbols. To compute these numbers, we use the above constructive method, but allow the possibility of introducing new rows, columns, and/or symbols when extending weight-(m − 1) partial Latin rectangles. We perform this enumeration for m ≤ 11, and the results are given in Table 15. The results for main classes is consistent with those independently obtained in [18,69], and moreover, [18] also computes the number of main classes for m = 12.
Direct constructive enumeration of isomorphism classes is infeasible, since the numbers grow too quickly. Moreover, isotopic partial Latin rectangles may have different-sized isomorphism classes 1 , so we cannot easily derive the number of isomorphism classes within a isotopism class, which thwarts modifying the approach we use for enumerating isotopism classes to enumerating isomorphism classes. Instead, using an algebraic geometry method like in Section 5, we enumerate isomorphism classes for m ≤ 6 in [30, Table 2].

Verification
The authors have made efforts to ensure the numbers and formulas presented here are as bug-free as possible; we document these efforts in this section. First, the various source codes used and their output are available from [31]. Next, where feasible, computations have been independently performed, using different techniques and different software. Where possible, we have also crosschecked the results of the enumeration methods.
• The number of isotopism classes and main classes has been computed using both the algebraic geometry method (for r, s, n ≤ 6) and constructive enumeration (for r, s, n ≤ 5).
• For m ≤ 13, the results of the computation of #PLR(r, s, n; m) have been cross-checked against the computed polynomials f m (r, s, n). Thus for 854 quadruples (r, s, n; m) the computations agreed exactly.
In addition to cross-checking computational results, we check the divisibility of the numbers computed using the following theorem. More specifically, we check the exact formulas for f m (r, s, n), for m ≤ 13, satisfy Theorem 8.1 whenever k ∈ {1, . . . , 10} and r, s, n ∈ {k + 1, . . . , k + 10}.