1X97-4943/83/020267-26%03.Kl/O Pergamon Press Ltd
Camp. c4 Moths. with Appls. Vol. 9, No. 2. PP. 267-292, 1983 Printed in Great Britain.
ENUMERATION AND CONSTRUCTION OF PANDIAGONAL LATIN SQUARES OF PRIME ORDER? A. 0. L. ATKIN, L. HAYand R. G. LARSON University of Illinois at Chicago, Chicago, IL 60680,U.S.A. (Received
May
1982)
Communicated by R. L. Graham Abstract-A complete enumeration and algebraic description is given of all pandiagonal Latin squares of order 5 13. For n = 5, 7 and 11 there are (up to equivalence) exactly the n-3 cyclic squares. For n = 13 there are 12,386inequivalent squares; of these 10 are cyclic (in all directions) and 1560are semi-cyclic (cyclic in a single direction). Systematic methods are given for constructing semi-cyclic pandiagonal Latin squares of any prime order > 11.
A Latin square which satisfies the additional condition that all wrap-around left and right diagonals be permutations is called pandiagonal. Such squares have been used in the construction of pandiagonal magic squares (see, e.g. Refs. [2, 4, 161);in that context they are often known as “diabolic” or “perfect”. They have also been used in statistical designs to eliminate sources of variation along four dimensions (see, e.g. Refs. [5,8,11]); in that context they are known as “Knut Vik designs”, after Vik[l9]. It is known that pandiagonal Latin squares exist for all orders not divisible by 2 or 3, and only for those orders. This paper is concerned with the systematic construction and classification of pandiagonal Latin squares (PL-squares) of prime order. A brief history of the subject will be given at the end of the paper. A simple example of a pandiagonal Latin square is given in Fig. 0. 0 2 4 1 3
1 3 0 2 4
2 4 1 3 0
3 0 2 4 1
4 1 3 0 2
Fig. 0.
This square may be described as follows: The entry in the ith row, jth column position is given by A(i, j) = j - 3i (modulo 5). (Here we number the rows and columns 0, 1, 2, 3, 4.) A useful notion in working with Latin squares is that of the path of an element k, by which we mean the function which specifies for each row the column whose intersection with that row contains k. That is, the path of k is the function P satisfying: n(i) = j if and only if k is in the (i, j)th position in the square. (Such a function gives a solution to the n-queens problem; see, e.g. Ahrens ([I], p. 255) or Stern[l8].) Note that the paths of all the elements in Fig. 0 are of the following form: in each row, the entry is displaced 3 places to the right (modulo 5) from the corresponding entry in the row above. Such a path, with constant successive displacements, is called an extended Knight’s move path. It can be written r(i) = ci + d (modulo n). A pandiagonal Latin square is determined by the paths of all its elements. In fact, it is determined up to equivalence (under renaming of entries) by the set of its paths, without regard to the elements they correspond to. This reduces the problem of finding all pandiagonal Latin tResearch partly supported by National Science Foundation Grants MPS-75-07478,MPS-71-02790-A05and 76-06638. Computer services used in this research were provided by the Computer Center of the University of Illinois at Chicago Circle. Their assistance is gratefully acknowledged. 261
268
A.0.L.ATKINet al.
squares to the problems of first, finding all possible paths, and second, finding all possible ways of fitting subsets of these paths together to form a pandiagonal Latin square. This method is similar to that used by Parker to investigate orthogonal Latin squares of order 10[12]. It is well known that for prime order p > 3 there are p - 3 extended Knight’s move paths through the origin (i.e. satisfying ~(0) = 0). We wrote a computer program to enumerate all possible paths through the origin (all other paths being obtainable from these by translation) and ran it for all prime orders 5 13. For orders 5,7 and 11, the only paths which resulted were the p - 3 extended Knight’s move paths. For order 13, in addition to the 10 extended Knight’s move paths, there were 338 other paths. Analysis showed that these paths could be classified algebraically as follows: Each path can be obtained by translation from one of the form g(i) = cii where the multipliers ci satisfy certain algebraic conditions. (Recall that ci constant gives an extended Knight’s move path.) These algebraic conditions allow the construction of many paths of any given prime order. Any path can be used to construct a pandiagonal Latin square: for certain directions, the set of all translates of the given path in that direction will form a PL-square. For each path, there are at least four directions that can be used in this way. For each extended Knight’s move path, the PL-squares constructed in this way are all equivalent; they can be characterized by the fact that all of the rows are cyclic permutations of each other, and similarly for the columns, right and left diagonals. Such PL-squares have been called cyclic[16]. For the other paths, the PLsquares constructed by translation in different directions are inequivalent; thus each of these paths yields at least four equivalence classes of PL-squares. Such PL-squares are cyclic in only one direction. They have been called semi-cyclic[l6]. All translates of a cyclic PL-square are equivalent to it, while a semi-cyclic PL-square will have p inequivalent translates. For p = 13, there were found to be 10 equivalence classes of cyclic PL-squares and 1560 equivalence classes of semi-cyclic PL-squares. Unless all of the paths in the PL-square are translates in a fixed direction on some path, the entries will not be cyclic in any direction. Such a PL-square may be called acyclic. The most difficult part of the computation was the determination of which sets of paths form a PL-square. A computer search for all such sets of paths was done for p = 13. This computation was substantially shortened by using the action of the group of transformations of the set of PL-squares to itself to eliminate redundancy. It was found that under the action of this group there are two orbits of acyclic PL-squares. One contains 8112 equivalence classes of PLsquares, the other contains 2704 equivalence classes. Representative PL-squares from these two orbits are given in Figs. 2 and 3. There are thus 12,386inequivalent PL-squares of order 13. The structure of the paper is as follows: Section 1 introduces the basic terminology of the paper and discusses the notions of path and compatibility of paths. Section 2 describes the group of transformations mapping the set of PL-squares onto itself. Section 3 describes the action of this group on the set of paths. Section 4 classifies the paths in terms of subgroups of 2:. Section 5 gives general methods of constructing paths. Section 6 applies the previous theory to the computer-enumerated paths for order n 5 13. Section 7 discusses the generation of PL-squares from translates of a single path. Section 8 describes the result of the computer enumeration of PL-squares of order 13 and applies the previous theory to compute the total number of such squares. Section 9 discusses the reductions used to make the computations manageable. Section 10 discusses some of the technical aspects of the computation. Section 11 surveys the history of the subject.
l.PATHSINAPANDIAGONALLATINSQUARE
In this section we introduce the algebraic description of pandiagonal Latin squares which will be used throughout the remainder of the paper. Let n be a positive integer. Let 2, be the ring Z/nZ, which we take as (0, 1, . . . , n - I} and let Zt be the set of invertible elements of Z,,. We call Z,, X Z,, the n-square. The set {(i,x)(x E Z,} is called the ith row of the n-square. The set {(x, i)lx E Z,,}is called the ith column. The sets {(x, i +x)1x E Z,,} and {(x, i -x)1x E Z,} are called the ith right diagonal and ith left diagonal respectively. A design is any function A(x, y) from the n-square to Z,,. Two designs are equivalent if one can be obtained from the other by renaming the entries in the square.
Enumeration and construction of pandiagonal Latin squares of prime order
269
A design A is a pandiagonal Latin square (PL-square) of order n if, for each i, the following four functions from Z, to Z, are permutations: x-
A(i, x),
(1.1)
x-
A(x, i),
(1.2)
x~A(x,
i+x),
(1.3)
XH A(x, i - x);
(1.4)
i.e. the elements in each row are distinct (or, equivalently, all elements of Z, occur), and similarly for each column, right diagonal and left diagonal. In computations with pandiagonal Latin squares, the notion of the path of an element will play a key role. A function V: Z, + Z, is the path of the element c in the PL-square if c = A(x, rr(x))
for all x E Z, (i.e. in row x, c appears in column a(x).) The fact that (1.1) is a permutation implies that there is a unique y such that c = A(x, y); hence there is a unique path 7~for the element c in the PL-square A. The fact that (1.2) is a permutation implies that if P(x,) = rr(xJ then x, = x2. Hence the function 7~ is a permutation. We claim that the fact that (1.3) is a permutation implies that the function x
is a permutation. For suppose that IT
H
7f(x) - x
- x, = 7~(xJ - x2 = i. Then
a = A(x,, 7~(xJ) = A(x,, i + x1)
and a=
A(x*, IT)
= A(xz, i + x2)
for some a E Z,. Since (1.3) is a permutation, we have that x, = x2. Similarly, the fact that (1.4) is a permutation implies that the function x-
n-(x)+x
is a permutation. DEFINITION1.5.
A virtual path is a function 7~:Z, + Z,, such that X++
P(X),
x I-+ 77(x)-x, x -7T(x)+
x
are all permutations of Z,. The following lemma is an easy consequence of this definition: LEMMA 1.6.
(a) If T is a virtual path, then so is T(X) + k for each k E Z,. (b) If c, c - 1, c + 1 are relatively prime to n then T(X) = cx is a virtual path. If A is a PL-square in which ~riand rj are the paths of i and j respecitvely then evidently i# j implies pi # ~j(X) for each x. This motivates the following definition:
270
A. 0. L. ATKINet al.
DEFINITION 1.7. (a) Two virtual paths r, 7~’are compatible if, for every x, r(x) # r’(x). (b) A collection {rO, . . ., q} of virtual paths is compatible if the paths are pairwise compatible. In this case we also say that the sequence ro, . . ., rk is compatible. PROPOSITION 1.8. Every sequence ro, . . . , T”_~ of n compatible virtual paths determines a unique PL-square of order n in which ri is the path of the element i for each i E 2,. Proof. The assumption of compatibility of ro, . . . , 7~,_~assures that k I+ rk(i) is a permutation for each i; hence for each pair i, j of elements of Z,,, there is a unique k satisfying rk(i) = j. We define A by specifying A(i, j) as the unique k satisfying r,‘(i) = j. It remains to verify that for all i E 2, each of the following functions is one-to-one: (a) x H A(i, x), (b) x I+ A(x, i), (c) x t+ A(x, i +x), (d) x H A(x, i -x). For (a) this follows directly from compatibility. For (b), suppose A(x,, i) = A(xZ,i); i.e., for some k E Z,,,
Since rk is a virtual path, x H gk(x) is a permutation and hence x1 =x2. Similarly, if A(x,, i +x1) = A(x2,i +x2) then for some k E Z,,
hence flk(xl) - xl = gk(x2)- x2. Since rk is a virtual path, x H g,‘(x) - x is a permutation and hence x, = x2. The last case is handled similarly, using the fact that x H nk(x) + x is a permutation for each k. We call A the PL-square constructed from the compatible sequence no, . . . , nnel. We now show that every virtual path is realized as the path of an element in a PL-square. LEMMA 1.9. Let 7~be a virtual path. If Irk is defined by r,‘(x) = P(X) -t k for each k E 2, then ro, . . ., IT-~ is a compatible sequence of virtual paths. Proof. As observed in Lemma 1.6, each ?rk is a virtual path if 7~ is. It is evident that gi(x) = rj(x) if and only if i = j.
PROPOSITION 1.lO. If T is a virtual path there is a PL-square A in which IT is the path of 0. Proof, By Lemma 1.9 there is a sequence ro, . . ., q-I of compatible paths where r. = IT.
Hence by Proposition 1.8, there is a PL-square A in which 7~is the path of the element 0. (This design may be thought of as obtained by putting down O’s along the path 7~and filling in the rows as cyclic permutations of Z,.) Since every virtual path is realized as a path in a PL-square, the distinction between “virtual path” and “path of an element in a square” will be made only when necessary; in general both will be referred to simply as “paths”. COROLLARY 1.11[4]. If n is not divisible by 2 or 3, then there exist at least
equivalence classes of PL-squares, where the product is taken over primes p dividing n. Proof. The number n prII(1 - 3/p) is the number of triples (c - 1, c, c + 1) whose three entries
are relatively prime to n. For each such triple r(x) = cx is a path by Lemma 1.6. By Proposition 1.10 this path is realized as the path of 0 in a PL-square. The PL-squares obtained for different triples by the construction in Proposition 1.10 will be inequivalent since they are built up from different paths of 0.
Enumerationand constructionof pandiagonalLatin squaresof prime order
271
COROLLARY 1.12. If n is a prime > 3 there are at least n - 3 inequivalent PL-squares. DEFINITION1.13.
A path is n called normalized if ~(0) = 0. Note that every PL-square contains a normalized path-the A(O,O)= i.
path of the element i such that
LEMMA1.14. 1,f7~is a path then there is a normalized path P’ such that r(x) = T’(X)+ k for some k E Z,. Proof. Let a’(x) = r(x) - ~(0) and k = r(O). We will refer to the path 7~’as the normalized path corresponding to T. 2. TRANSFORMATIONS OF PL-SQUARES In this section we describe a group which maps the set of PL-squares of order n onto itself. If A is any design and u is any permutation of the n* elements of Z, X Z, then we get a new
design, denoted by uA, as follows: uho a(i, j) = A(i, j). (Here 0 denotes functional composition.) If we think of A as specifying the placement of the symbols 0, 1, . . ., n - 1 in the n* places of Z, x Z,, then UA is the design in which the symbols have been moved to new places according to the permutation u. It is clear that if A is a PL-square and u is a permutation which maps the set of rows, columns, right diagonals, and left diagonals to itself, then UA is also a PL-square. We formalize this remark as follows. DEFINITION2.1. A PLS-transformation
is a permutation of Z, right diagonals and left diagonals to itself.
x 2,
which maps the set of rows, columns,
LEMMA2.2. If u is a PLS-transformation
and A is a PL-square, then UA is a PL-square. The set of PLS-transformations evidently forms a group under composition. We denote this group by 3”. It is easily checked that if n is odd, i,j E Z,, and k E Zz, the following maps are all in %“: T(i,j)(& Y) = 0 + i, Y + ih 4% x(x,
Y) = 6,
- Y),
Y> = 0 + Y, --x + Y),
I&,
Y) = (k
ky).
We prove that if n is odd and n 2 5, then %”is generated by these transformations. Let
9, = {Q,jJ(i,
i) E Zn X .&I
and Yn =
{aE ~“lcl(O,0) = (0, O)}.
Note that 9” is a subgroup, and 9” a normal subgroup, of 3”. LEMMA2.3. Ce,is the semidirect product of 5!?,,and Y,,. Proof. Let /? E 9Jn and suppose p(O,O) = (a, b). Then p’ = T~_,._~)o~ is in _%‘,,,and
P = T(a,h)OP’.
A. 0. L. ATKINet al.
272
Let X,, be the subgroup of 3” generated by v, x and ,..kk,1 I k < n, (k, n) = 1. The following proposition, proved independently by us, appeared in [14]. We include the proof here for completeness. PROPOSITION 2.5.
If n is odd and n 2 5, then 2’,, = X,,. Proof. First note that if L1 and L2 are of the same type (i.e. both rows or columns or right diagonals or left diagonals) then for any PLS-transformation p, p(L,) and p(LJ must also be of the same type, else /3 maps two non-intersecting sets into sets which intersect and hence is not a permutation. Now supppose Q E 9,,. Observe that the transformation x maps rows to right diagonals, right diagonals to columns, columns to left diagonals, and left diagonals to rows. Therefore, by replacing (Yby x-‘o cz for some r, we may assume that (Ymaps the 0th row into the 0th row. It follows that a must map all rows into rows; hence (Y(x, y) = (x’, y’) where x’ = a,(x) for some permutation u, of 2, which satisfies a,(O) = 0 since a E 9”. Now consider the action of a on the set of columns. Case 1. (Ymaps the set of columns to itself. In this case, a(x, y) = (x’, y’) where x’ = uI(x) and y’ = u*(y) for permutations (TV,q of 2,; since LYfixes (0, O), u,(O) = ~(0) = 0. Now a must map the set of left diagonals into either the set of left diagonals or the set of right diagonals. That is, (Ymust map the solutions of x+y=a
into the solutions of ux’ + y’ =
a’
where a’ depends on a, and u = 2 1 is independent of a ; i.e. if x + y = a, then uu,(x) + q(y)
= a’
(2.5)
and hence uu,(x) + u2(a - x) = a’. Setting x = 0 yields a’ = u2(a) and uu,(x) + u2( a - x) = u2( a).
Setting x = a then gives
m(a) = da) and, since a is an arbitrary element of Z,, @2(Y) = U@,(Y).
(2.6)
Substituting in (2.5),
UudX)+ m,(y) = u*(a) = ml(a) and hence, since x + y = a, u*(x) + U,(Y) = 4
+ Y).
It follows that u1 : Z, + Z, is of the form u,(x) = cx with (c, n) = 1; and by (2.6), uz(y) = ucy. Hence in this case,
Enumeration and construction of pandiagonal Latin squares of prime order 44
273
Y) = CC& UCY)
and (Y= IL, or pL,0 v according as u = 1 or u = - 1. This proves that any a E 9n which maps rows to rows and columns to columns in X”. Case 2. (Ymaps the set of columns to one of the sets of diagonals. We now show this case is impossible. Suppose a! maps the set of solutions of y = a to the set of solutions of ux’ + y’ = a’, where a’ depends on a
Y’ = U22(Y) -
uudx).
Also, (Y must transform one of the sets of diagonals to columns, and hence must map the solutions of the equation vx + y = b to the set of solutions of y’ = b’ where b’ depends on b and v = f 1 is independent of b. Hence if y = b - vx, y’ = u2(b - vx) - m,(x) = b’.
Setting x = 0 gives u2(b) = b’ and u2(b - vx) - uuI(x) = u2(b),
(2.7)
Setting x = vb and using v2 = 1, ~~(0)= 0, yields - uul(vb) = u,(b)
(2.8)
or, since b is arbitrary, U2(Y) = - UUl(VY).
Substituting this in (2.7) gives - uudvb -x) - uudx) = - uu,(vb).
Letting b = v(x + y), we get - uu*(y) - uu,(x) = - UUI(X + y)
which implies that u,(x + Y) = Ul(X) + al(Y). Therefore ur(x) = cx for some c with (c, n) = 1 and, by (2.8), u2(y) = - uvcy. Hence a(x, y) = (cx, - uvcy - ucx).
Now let V”p,-IOQ
a,=
t
/_&-I
0 (y
if if
u= 1
u = -
1.’
Then a’ E 9” also, and a’(x, y) = (x, vy + x).
Consider D = {(x, vx)lx E Z,}, which is a right diagonal if v = 1 and a left diagonal if v = - 1.
A.0. L. ATKIN ef al.
274
Now (Y’(x, UX)= (x, l?x + x) = (x, 2x),
hence (Y(D)= {(x, 2x)1x E Z,} which is a row, column or diagonal only if 2 = 0, ? 1 (modulo n). This is impossible since n 2 5. Hence (Y’is not a PLS-transformation. Since this contradicts a’ E 5?“,Case 2 is impossible. It follows from Case 1 and the remarks preceding it that if (YE .J& then for some c and r, (Y= ,y’ 0 pL, or (Y= xr 0 pc 0 ZJand hence (YE x,,. This completes the proof of Proposition 2.5. COROLLARY 2.9. If n is odd and n 2 5, then 9” is the semi-direct product of Y,, by 3,,, is generated by the transformations r(i,j), pk, v, and x, and is of order 8p(n)n*, where $ is the Euler totient function. Proof. The subgroup generated by {kk} is easily seen to have order q(n). The group
generated by {,_&k, V,x} modulo this subgroup can be seen to have order 8. Therefore 9” has order 8p(n). The subgroup Y,, has order n*. Since %&is the semi-direct product of the subgroup Y” by &, it has order 8q(n)n2.
3.TRANSFORMATIONSOF PATHS In this section we describe the action of the group $ on the set of paths. If r is a virtual path, we may assume by Proposition 1.10 that 7~is the path of some element c in a PL-square A, i.e. c = A(x, r(x)) for each x E Z,. Let (YE %,,.Define the path CYTto be the path of c in the square CYA;that is, y = (YT(X)if and only if (aA)(x, y) = c. To see that (YET is independent of the choice of A and c, let p’, p2 denote the projections on the coordinates (p’(x, y) = x, p2(x, y) = y) and recall that ((YA)0 n(i, j) = A(i, j). It follows that y=
aa A(p’dx, t)
p2a-‘(x,
Y), pzdx,
~1) = c
y) = ?T(p,fY’(x, y)) = c.
The last condition evidently depends only on (Yand 7~.We may thus define (YET to be the unique y satisfying P2d4
Y) = dP’~-‘(x,
Y)).
We now determine the action of the generators of 9” on an arbitrary path 7~. PROPOSITION 3.1. Let v by any path. Then (a) 7[i,jj7r(X) = 7T(X- i) + j, (b) VT(X)= - P(X), (c) pkr(X) = kr(k-‘X), (d) XV(X)= y, where y is the unique solution of (x + y)/2 = ~T((x- y)/2). Proof. (4 Y = T(i, j)dx) iff p2~1;:,‘j)(% Y) = 7TP’TG,‘j)(X, Y) ifTp2(x - i, Y y-j=p(x-ii) i#y=p(x-i)+j.
j) =
m(X
-
i, y-j)
if
(b) Y= VT(X)i#p2v-‘(X, Y)= n~‘f’b, Y) ifp2k - Y) = TP,(X, - Y) if - Y = P(X). y = hr(x) if p+;‘(x, y) = rp’&(x, y) if p*(k-‘x, k-‘y) = vp’(k-‘x, k-‘y) if k-‘y = 7r(K’x). (c)
(4 Y = XT(X) if7pY’(x, Y)= ~PIX-‘(x, Y) i$ pz((X- y)/2, (X+ ~)/2) = rp’((X - y)/2, (x + y)/2) if7 (x + y)/2 = 4x - y)/2. Denote the set of (YE 5%which map the normalized path 7~to a normalized path by Y&,“.
Enumeration and construction of pandiagonal Latin squares of prime order
27s
LEMMA3.2 If P is any normalized path, then 6p, c %$,*. Proof. Assume 7r is normalized and LY E 9”; then ~(0) = 0 and (~(0, 0) = (0, 0). It easily follows that pzcu-‘(0, 0) = ~T(~~(Y-~(O, 0)) which implies or(O) = 0.
Let Y,,,”denote Y,, n %“‘,“. PROPOSITION 3.3. $qe”=yy-” Pioof. iy “Lemma 3.2, J&Y”,lrc $“. For the converse inclusion, let (YE 9”“. By Corollary 2.9, Q = /?S where p E 9” and 6 E F,,. By Lemma 3.2, S = /.-‘a E %“‘,”and hence 6 E F,,,“. Hence CeTCTTs. It rem”aiis ti characterize Y"," . LEMMA3.4. Let 7~be a normalized path. Then T(i,j) E Y”,” if and only if j = - P(- i). Proof. By Proposition 3.1(a), r(i,j,P(x) = ~T(X - i) + j; hence rci,,n(O) = 0 if and only if 7~(- i) + j = 0, i.e. j = - r( - i). PROPOSITION 3.5. Let T be a normalized path, and let ai” denote TV,,_,). Then !?in,”= {ai”li E Z,} and, for each i, ai”n(x) = ~T(X- i) - 7~(- i). Proof. By Lemma 3.4 and Proposition 3.1(a). We call a;~ a shift of the normalized path r; we will in general omit the superscript and write
giip for Viff77. LEMMA3.6. If 7~is a normalized path then gi(rjr) = oii+ir+ Proof. Here ~ii(~j~TT) denotes up”uyn. By Proposition 3.5, UiUja(X)
=
UF”UjT(X)
=
Uj?T(X
-
i) -
Uj+
i)
=7~(x-i-j)-7~(-j)-(7~(-i-j)-7~(-j)) =
r(X
-
i-j)
- 7f(- i-j)
4. CLASSIFICATION
=
Ui+j7T(X).
OF PATHS
In this section we describe a scheme for classifying paths in terms of subgroups of Zz. This classification scheme was originally motivated by the observation that for n = 13, paths were of the form r(x) = cXx,where c, depended only on the coset of x modulo some subgroup of Zg,. Let 7~be a normalized path. The type of r is defined to be the subgroup T, = {k E Z$P = P) = {k E Z*,lkn(x) = I
for all x}.
The index of 7~is the number [ZX: T,]. If the index of 7~is 2, we will often call r a quadratic path; if the index is 3, we will often call r a cubic path, etc. In the case where n is prime, then Zz is a cyclic group and the type T,, is determined by the index of r. LEMMA4.1. If a E 2?,, and 7~is a normalized path, then Q and ~7 have the same type. Proof. Since p.ka = a&, it is clear that ,.&@r = 77if and only if j.&(Y?r = (~7i-.Hence k E T,, if and only if k E T,, In the case where n is prime, we will use ZAto denote Z, -{O, 2 1). LEMMA4.2. Let n be prime and let IT be a normalized path. If x and x’ are in the same coset of T, then Camwa Vol 9. No. 2-c
216
A. 0. L. ATKIN et al. 7r(x)/x
Proof. Assume x’ = tx for some t E T, f?r(X)/fX= rr(x)/x.
= P(X’)/X’.
Then I
=I
= h(x).
Hence r(x’)/x’ =
PROPOSITION 4.3. Let n be prime. If the normalized path r has type T, then there is a function f : .Zz/ T + 2; such that P(X) = f(xT)x for each x# 0. Proof. f exists by Lemma 4.2. If f(xT) = + 1 for some xf 0, then V(X)T x = T(O)TO,
contradicting Definition 1.5. COROLLARY 4.4.
Let n be prime and let 7~be a normalized path. Then n has index 1 if and only if for some c E z;, 7r(x) = cx for all x E 2,. Proof. Suppose r(x) = cx, and let k be an arbitrary element of 2:. Then /q(x)
=
kT(K’X) = kck-‘x = cx = r(x);
hence T, = 2: and 7~ has index 1. Conversely, if 7r has index 1, then T,, = Zz; hence the function f(xT) in Proposition 4.3 is independent of x, i.e. IT(X)= cx for some c E Z$. Thus the paths of index 1 are the extended Knight’s move paths mentioned in the introduction. In the following, 0 will denote (0, 0) and v, w will denote elements of Z,, X Z,. We now note for later use the following easily verified facts about 3”. LEMMA 4.5.
(a) ~“7, = 7,+, for all v, w; (b) r,r= rrv for all v and r; (C) Fk$-, = ,&,.‘k for
k#
0
and all V.
Proof. Left to the reader. LEMMA 4.6. Assume n is prime and 7~is a normalized path. If r,7~ = r for some v # 0, then r(x) = cx for somecEZz. Proof. Assume v= (i, j) # 0. If 7,~ = r then T,E 9*-,” and hence by Proposition 3.4, j = - P( - i). Since 7~is normalized, i = 0 if and only if n(i) = 0; hence v # 0 implies i, j# 0. Let r denote i-‘. Then by Lemma 4.5(b),
hence by Proposition 3.1(a), T(X) =
T(,,
i,~(x) = P(X - 1) + rj
i.e. ~T(X+ 1) = IT(~)+ 4 for all x E Z,. An easy induction on x now shows that r(x) = rjx for all x E Z,, and d# 0.
LEMMA 4.7. Assume n is prime and 7~is a normalized path. If t&r = ITfor k# 1 and t.Lioir = oin for i# 0 and j# 1 then 7,~ = P for some v # 0.
Enumeration and construction of pandiagonal Latin squares of prime order
271
Proof. Assume the hypotheses. Now mir = 7,~ where w = (i, - GT( - i)) # 0 since if 0. Hence r,n = ~~7~7~for j# 1, which implies 77 =
T_,/JdjTwlT
=
r_~Tj~/LjP
=
T(j_lhpjT
by Lemma 4.5. Since j E 2: we can let j’ = (j - 1)/j (mod n). Then j’ # 0 and IT =
Tjj’w/JdjlT
=
/Jdj?i*T
=
/Jdj?,P
where u = j’w # 0. Since by assumption pkk7T = 7~for k# 1,
The conclusion now follows with v = (k - 1)ju # 0 since k# 1 and II Z 0. PROPOSITION4.8.
Let n be prime and let 7~ be a normalized path. Let 7; denote the type of the shift air.
Th
following conditions are then equivalent: (a) IThas index’ 1; (b) r(x) = cx for some c E 2;; (C)Uia=7rforalliEZ,; (d) oir=rforsomei#O; (e) Ti 211) and Tj 211) for some if j. Proof. (a) is equivalent to (b) by Corollary 4.4. We next show (b)+(c)+ (d)+(b). Clearly (c)+(d) is trivial. (b) + (c): Assume r(x) 7 cx; then by Proposition 3.5, for all iE Z,,, air(X) = 7r(x-i)-7r(-i)=c(x-i)-c(-i)=cx=7T(x).
(d)+(b): Assume uir = 7~for some i# 0. NOWUiV= 7,~ where v = (i, - 7~(- i)) f 0; by Lemma 4.6 this implies r(x) = cx for some x E Z,, and cf 2 1 by Lemma 1.6. Finally we show (a)+(e) and (e)+(b). (a)+(e): If IT has index 1, then T, = Zz. Since (a) implies (c), air = P for all i E Z.; hence q = T, = ZX, for all i E Z,. (e)+(b): Suppose if j, k E T, k’ E q and k,k’ f 1, SO that /.&kuip= Uir and Let P’ = ain; then by Lemma 3.6, ojr = or-i(oir) = ur_ir where j- i# 0. NOW pkd= 7~’ and for k,k’ # 1 which by Lemma 4.7 implies 7,~’ = 7~’for some v # 0. But IT’= Uilr = 7,7r for W = (i, - r( - i)); hence 7-r = r,r,,r = r,+,7~ which implies 7~= r,r for v # 0. The result now follows from Lemma 4.6. This completes the proof of the proposition. pk’ujn
/&u(j_i)v’=
=
UjT.
u+~)T
COROLLARY4.9.
Let n be prime and 7~be a normalized path. Let mi denote the index of ui~ for each i E Z,. If IT has index > 1 then one of the following must hold: (a)rni=n-1 foralliEZ,; (b) 1~ mi < n - 1 for some i E Z,,, and mt = n - 1 for all j# i. Proof. Assume 7~has index > 1. If mi = 1 for some i E Z,, then air has index 1; then by Lemma
4.8 o-i(oir) = urn. But then 7r = o-i(uin) has index 1, contrary to hypothesis; SO ltzi > 1 for all i E Z,. Let Ti denote the type of uin and suppose mi < n - 1 for some i. If Tt 111) for some j# i, # then by Lemma 4.8 7~has index 1, contrary to hypothesis. So q = {I}for all j f i, which proves that (b) must hold if (a) does not. This justifies the following definition. DEFINITION4.10.
Let n be prime and r be a normalized path. The intrinsic index m* of 7~is the least index of any shift air of 7~.7~is a basic normalized path if index P = intrinsic index n:
A. 0. L. ATKIN el al.
278
COROLLARY 4.11.
Let n be prime and m be a normalized path of intrinsic index m*. If 1 < m* < n - 1 then there is a unique basic normalized path 7~’and a unique v such that rr = r,+. Proof. By Corollary 4.9, m* is the index of Fir for some unique i E 2,. Recall that Uiia= Tci,i)rwhere j = - a(- i). Hence 7r = 7,~’ for the basic-path r’ = rin and u = (- i, 7~(- i)). We will call v the starting point of the path 7~.
We now give a description on the normalized paths of index > 1. PROPOSITION 4.12.
Let n beprime and ITbe a normalizedpath.
Suppose mln - 1, Uis the subgroup of Z*, of index m
and Z*,lU={a,U,
azU, . . . . a,U}.
Then index nlrn if and only if there exist Ci E Z:, 15 i 5 m, such that a(x) = cIx for all x E aiU, l
n(x) = f(xT)x for all x# 0. Then f induces a function g: Zz/ U+ ZA such that if Ci = g(aiU), 7T(X)= Ci(X)for all X E UiU, 1 5 i 5 m. Conversely, assume such Ci exist, 1 I i 5 m. We will show that U is a subgroup of T. Suppose k E U; then x E aiU if and only if k-lx E aiU. It follows for x E aiU that /Jam
= kdk-‘x) = kcik-‘x since k-lx E aiU = CiX= T(X) since X E UiU*
This shows pI,r = 7~and k E T; hence UC T and [Z*,: ZJ = index r/m = [Zt: U].
COROLLARY 4.13.
Let n be prime and P be a normalized path. Suppose m is prime, mJn - 1, U is the subgroup of Zt of index m and Z$lU={a,U,..., a,U}. Then 7~has index m if and only if there exist Cl,. . . 3c, E ZA, c;f ci for some i, j and such that r(X) = CiXfor Ull X E UiU, 15 i 5 m. Proof. By Proposition 4.12, index pjrn if and only if there exist cl, . . . , c, E ZA such that r(x) = ciXfor x E UiU. Hence the ci exist if and only if index 7r = 1 or m, since m is prime. But by Corollary 4.4, index 7~= 1 if and only if ci = cj for all i, j. Hence index IT= m if and only if the ci exist and Ci# cj for some i, j. If n is prime, the previous results provide a simple means of describing any normalized path: If 7~has index 1, then r(x) = cx for some c E ZAand we shall denote 7~by or. If 7~has index k > 1 then we fix the enumeration of Zt/T = {aIT, azT, . . . , UkT} where Ui is the least element of aiT and ai < Uj for i < j; then IT determines a unique sequence of “multipliers” Ci such that P(X) = CiXfor x E UiT. We may thus denote 7~by r(,,, , Cl). We will in fact use this description only for basic normalized paths. Other paths of index > 1 will be identified as shifts of basic normalized paths.
Enumerationand constructionof pandiagonalLatin squaresof prime order
219
As an example, let n = 13 and k = 3. The cosets of the subgroup of index 3 are {‘I, 2T, 4T) and 7ro,8,s) denotes the path defined by n-(O)= 0, 7r(x) = 5x if x E T,
r(x)=8x
if xE2Tor
xE4T.
We leave it to the reader to verify that this defines a normalized path; it will be discussed further in the next section. 5. CONSTRUCTION OF PATHS
In this section we describe methods of constructing normalized paths of various indices. We also describe computations which give all normalized paths for PL-squares of order n I 13. Throughout this section we will suppose n is prime. In the last section we classified normalized paths in terms of a subgroup T of Zz and a set of multipliers associated with the cosets of T in Zz. We now consider which sets of multipliers can be associated with cosets of a subgroup of Zl: in order to give a normalized path. If T is a subgroup of ZX, let Pr denote the group homomorphism of Z,* onto Zz/T. PROPOSITION 5.1. Let f be any function from Zzl T to ZA. Define 7rf: Z, + Z, by
7rf(x) = f(PT(x))x for xf 0; then rf is a normalized path if and only if the three functions
(5.2)
are permutations of Z*,I T. Proof. Recall the condition for rf to be a path is that the three functions
x
H TfW,
x -
?rf(X) +
x,
(5.3)
x H 7r,(x) - x, be permutations of Z,. Suppose this condition is satisfied when 7rf(x) = f(PT(x)),. We show the functions (5.2) are surjective and hence permutations. Let w E Z*,/T; then w = Pr(y) for some y E Z$. Since the functions (5.3) are surjective, y = 7rf(x) for some x E Z,, and x# 0 since y# 0; hence y = f(PT(x))x which implies
w = Mf(Mx))x)
= Mm)z
for z = PT(x). The other cases of (5.2) proceed similarly. Conversely, suppose that the functions (5.2) are permutations. We show that the functions (5.3) are injective and hence permutations. Suppose r,(x) = n,(y). Note that x = 0 if and only if y = 0 since if, say, y E Z*,, we cannot have rf(y) = f(P,(y))y = rf(0) = 0. Suppose, x, y# 0. Then ?rf(x) = rf(y) implies f(PT(x))x = f(PT(y))y. Applying PT yields
Mf(Mx)))Mx)
= PTWT(Y)NPT(Y)
which implies PT(x) = PT(y) since the functions (5.2) are injective.
280
A. 0. L. ATKINet al.
Hence
f(PT(X))X = f(MYNY
= fWTW)Y
which implies x = y since f(Pr(x)) E Z$ Now suppose am f x = n,(y) -+y. As in the previous case, x = 0 if and only if y = 0 since (j&(y)) 2 I)y E Z; for yf 0, due to the assumption that f(z) Z + 1 for z = PT(y). If x, yf 0, then
cf&-(x)) + 1)x= U(MYN f l)Y implies
Mf(MXN f l)P,(x) = w._f(PT(YN f l)MY) which as above yields PT(x) = PT(y) and hence
CfvMx)) +-1)x= (f(M4) + UY. Since by assumption f(P,(x)) f + 1 it follows that f(PT(x)) + 1 E ZX and hence x = y. This completes the proof of the proposition. As an example, let n = 13 and T be the subgroup of index 6. If f is defined by f(r) = 2, f(2T) = 10, f(3 T) = 6, f(4 T) = 9, f(5 T) = 8, f(6 T) = 8, it may be directly verified that f satisfies the condition of Proposition 5.1. Hence ‘rrf= 7roLo,6,9,8,8) is a normalized path of index 6. As an application of Proposition 5.1 we obtain COROLLARY 5.4.
Let f be a function from ZtlT to ZL. Suppose there are cosets C,, C,, C, of T such that
UW)lx E Z9 c G, UW) + lb E ZIG G, If(xT) - 11xE Z:} c C,; then f determines the multipliers of a normalized path (i.e., the function IT defined by r,(O) = 0, q(x) = f(PT(x))x for xf 0, is a normalized path.) Proof. The hypothesis implies that the three functions
z - Mf(zh z - w_f(z) + 11, z I+ Mm)
- 11,
are constant functions from Zz/T to Zz/T; hence the condition of Proposition 5.1 is satisfied since multiplication by a constant is a permutation of Z$ Note that the function f given in the example after Proposition 5.1 which determines 7rc2 cannot satisfy the hypothesis of Corollary 5.4 since if T has index 6 in ZT3, the cosets 9106988j 0.. of T contain 2 elements while If(x E Zz} = {2,10,6,9,8}has 5 elements. Hence Corollary 5.4 gives a sufficient but not necessary condition for f to determine the set of multipliers of a normalized path. It is however easy to see that if 7rfis a path of index 2, then f must satisfy the conditions of Corollary 5.4, since any permutation of the group (1, - 1) is multiplication by a constant. As another example we show that the normalized path q$& mentioned in the previous section corresponds to a function f which satisfies the hypothesis of Corollary 5.4. To see this, let T denote the subgroup of ZTj of index 3, and let f denote PT(x). The following list tabulates the values of PT on ZT3.
Enumeration and construction of pandiagonal Latin squares of prime order x
X
1 2
3
4
5
6
7
8
9
281
10 11 12
i 2 Z 5 i 4 4 i 4 T 2 i.
Observe that the sequence of values P,(4), P,(5), P,(6) is the same as the sequence P,(7), P,(8), P,(9). Hence if f(xT) = 5 for x E T and f(xT) = 8 for x E .ZTI- T, it follows that
IS, 8)= If(x
E
ZTJ c T,
(4, 7) = (f(xT) - 1(x E ZT3}c 4T, {6,9}=(f(xT)+l(x~ZT~}~4T, so that we may take C, = T, C, = C, = 4T to satisfy the hypothesis of Corollary 5.4. More generally, Corollary 5.4 gives a simple method of constructing normalized paths of index > 1, as follows: Suppose T is a subgroup of Z*, of index k > 1, and suppose we can find m, # m2 E ZL such that PT(m,) = PT(m2), PT(m, + 1) = PT(m2+ 1) and PT(mI - 1) = PT(m2 - 1).
Then the function
f:
Zzl T + Z): defined by
f(T) = ml, f(xT) = m2 if xT# T,
will satisfy the hypothesis of Corollary 5.4; hence nf is a normalized path, where
r,(x) = m,x if x E T, n,(x) = mzx if xE T.
(here T may be replaced by any of its cosets.) Since ml Z m2 it follows by Corollary 4.4 that 7~ has index > 1. By Proposition 4.12, index nfjk; if m < k, however, and U is the subgroup of index m, U 3 T; hence T~(x)/x is not constant on U. It follows by Proposition 4.12 that index TJ’ m and hence index nf = k. Note that for m E ZA there are k3 possible sequences of values of PT on the elements m - 1, m, m + 1, while there are n - 3 such triples in Z*. Hence if n -3 > k3 some sequence of values PT(m - l), P,(m), PT(m + 1) must be repeated; the “center points” m,, m2 are then the required multipliers. This proves PROPOSITION 5.5. For any k > 1 there exist normalized n>k3+3 andn=l (mod k).
paths
of index k for all prime orders n such that
Note that infinitely many such primes exist by Dirichlet’s theorem. For k = 2, it follows by Proposition 5.5 that quadratic paths exist for all primes n 2 13. (This result was obtained independently in [3].) 6. CLASSIFICATION
OF PATHS OF SMALL ORDER
We now consider the normalized paths for n = 5, 7, 11 and 13. A computer program was written in the SNOBOL4 programming language to generate all possible normalized paths in a PL-square of given order n. This program was run for n = 5, 7, 11 and 13. We will discuss the results in the light of the previous theory. For n = 5,7 and 11 all normalized paths were found to have index 1; i.e., they were found to be of the form P(X) = cx where 1 < c < n - 1. It follows by Lemma 1.14 that every path in a PL-square of order 5,7 or 11 must be of the form r(x) = cx + d. LEMMA 6.1. If r,(x) = c,x + d, and n2(x) = c2x + d2 are paths of distinct elements in the same PL-square then cl = c2.
A. 0. L. ATKINet al.
282
Proof. As noted in Section 1, two paths in the same PL-square must be compatible, i.e., must satisfy 7~r(x)f 7&x) for each x. If cl # c2, however, 7~r(x)= Q(X) for x = (d2 - d,)l(c, - cz). This yields a complete description of the possible PL-squares of order 5, 7 and 11. PROPOSITION 6.2. There are exactly classes of PL-squares Proof. Let n = 5,7 n(x) = cx, 1 < c < n -
(a) 2 equivalence classes of PL-squares of order 5; (b) 4 equivalence of order 7; (c) 8 equivalence classes of PL-squares of order 11. or 11. We know from Corollary 1.12 that for each of the normalized paths 1, there is a PL-square ACof order n containing it as the path of 0; and as noted there these PL-squares are inequivalent. Now any PL-square A of order n must contain a normalized path and for n = 5,7 or 11 this path must be P(X) = cx where 1< c < n - 1. But by
Lemma 6.1 it is then easy to see that for both A and ACthe set of paths of elements must be {cx + did E 2,) and hence A and AC are equivalent under renaming. Thus for n = 5, 7 and 11 each PL-square is equivalent to one of the form
A&, Y) = Y - cx for some c, 1 < c < n - 1. (Note that this is the PL-square containing the normalized path P(X) = cx in which the path of i is cx + i.) After the computations were done it was observed that the result of Proposition 6.2 can be obtained by hand computation. This was in fact done by Rosser and Walker[lS] as announced in [14]. We now describe the results of the computer search for n = 13, using the convention established at the end of Section 4. FACT 6.3. For n = 13, (a) There are 10 normalized paths of index 1:
n(,, for l
for(cl, cd = (2, 111, (3, 9), (4, LO), (6,7), (7,6), (9, 3), (LO, 4), (11,2);
(c) there are 78 = 13 x 6 normalized paths which are shifts of thefollowing
6 basic paths of index
3: ~k,,c2,CI)for (cl, ~2, c3 = (5, 5, 8), (5, 8, 5), (5, 8, 8), (895, 5), (8, 5, 8), (8, 8, 5), (d) there are 156 x 13 x 12 normalized paths which are shifts of the following index 6:
12 basic paths of
Enumeration and construction of pandiagonal Latin squares of prime order
283
Q,. _. ., cg)for (cl, . . . , 4 = (2, lo,& 9, 8, g), (334, 5, 597, ll), (4, 5, 11, 7, 5, 3), (597, 3, 5, 11,4), (5, 11, 5, 3,4,7), (6, 8, 9, 2, 10, g), (7, 534, 11, 3, 5), (8, 2, 8, 10, 9,6), (g,6, 10, 8, 2, 9), (9, 8, 2, 67% lo), (10,9, 8, 8, 6, 2), (11, 3,774, 5, 5); (e) there are no other normalized paths. Hence there are 348 normalized paths.
It may be verified that for n = 13 the basic normalized paths of index 1, 2 and 3 satisfy the sufficiency condition of Corollary 5.4, while those of index 6 do not. By Lemma 4.1, the group & maps paths of index k to paths of index k. In fact, for k > 1, it can be shown that JZr, acts transitively on the set of paths of index k. The set of paths of index 1 has two orbits under the action of Yr3: one orbit contains 7rrcs, and 7rc8),and the other orbit contains the remaining 10 paths. Knowledge of the orbits of the group J’re,,enabled us to substantially reduce the amount of computation necessary to enumerate the PL-squares of order 13, as described in Section 9.
7. LINEAR
SIMPLE
PL-SQUARES
In this section we consider PL-squares which arise in some sense from a single path, Throughout this section we will assume that n is prime. DEFINITION 7.1.
A PL-square is simple if the path of every element is a translation on a fixed normalized path or,that is, if the path of every element is of the form r(cj)r for some (i, j). A simple PL-square is linear if there is a fixed normalized path such that the paths of the elements are the paths x E Z,, for some fixed vector (a, b). We say in this case that the linear simple 7(a,,bx)rv PL-square is made from translations in the direction of (a,b). The direction of (a,b) is specified by the slope b/a. (As usual, we denote b/O by 00). It is easily seen that if 7~is a normalized path of index k and A is made from translations of rr, then A is linear simple in the direction of (a, b) if and only if the starting points of the paths in A lie on a line parallel to the line {(ax, bx)}. It follows from this that elements of d;p,transform linear simple PL-squares into linear simple PL-squares. It was shown in Lemma 1.9 and Proposition 1.10 that we can construct a linear simple PL-square from a normalized path 7~by translating in the direction of (0, l), (i.e., we let the path ?rkof the element k be defined by r&(x) = n(x)+ k.) We now consider the question: If P is a normalized path and (a,b) a non-zero vector, when can we construct a linear simple PL-square from translations in the direction of (a, b)? PROPOSITION7.2.
The distinct translations function
of 7~in the direction of (a, b) make a PL-square if and only if the
x -
v(ax) - bx
is a permutation of 2,. Proof. Suppose the translations of r in the direction of (a, b) make a PL-square. Since any PL-square can be replaced by an equivalent one, we may assume that T(,&,)r is the path of r
284
A. 0. L. ATKIN et
al.
in the PL-square. Recall that T(~~,,~)TT(x) = T(X - ru) + rb. Since y ++A(O,y) is a permutation, the inverse map, which is r H n(-ru)+rb,
is also a permutation. It follows that the map x I+ I - bx is a permutation, Conversely, suppose that the map x * a(~) - bx is a permutation. For each r E Z,, let T,(X) = T(,~,,I,)~T(x) = P(X - ru) + rb. show that the translations of 7~in the direction of (a, b) make a PL-square, by Proposition 1.8 it is sufficient to show that the sequence ro, . . ., rn-, is compatible; that is, we must show that ~Jx) # IT,(X)for rf s. If a = 0, then bf 0 and the result is clear. Suppose that a# 0. Since n is prime, u-l exists. Now
To
7T,(x)f IT,(x) if and only if P(U(U-‘x - r)) - b(u-‘x - r) # ~r(u(u-‘x - s)) - b(u-‘x - s).
But since a-‘x - r# a-‘x - s and the function x H I - bx is a permutation, these inequalities hold. This completes the proof of the Proposition. COROLLARY 7.3.
If 7~is any normulizedputh, PL-squares can be constructed by translating ITin the directions with slopes 0, ~0, 1 and - 1. Proof. It follows from the properties of a virtual path given in Definition 1.5 that the
condition of Proposition 7.2 is satisfied for these directions. It is easily seen that if 7~has index 1, the PL-squares made by translating 7~in all directions are equivalent. The situation is more complicated in the case where 7~has index > 1, as shown by the following: LEMMA7.4.
Let r be a normalized path of index > 1, and let A, A’ be linear simple PL-squares made by trunslqting P in the directions of (a, b), (a’, b’) respectively. Then A and A’ are equivalent if and only if (a, b) and (a’, b’) have the same direction. Proof. If (a, b) and (a’, b’) are multiples of each other, then A and A’ are clearly equivalent.
Conversely, suppose the two PL-squares are equivalent; then the paths of their elements must be the same, under suitable renaming. In particular,
for some s# 0. This implies that ‘+,,‘,
b-sb’)r
=
a;
from Proposition 4.8 it then follows since IThas index > 1 that (a - su’, b - sb’) = (0, 0). Therefore (a, b) = ~(a’, b’), which completes the proof of the lemma.
Enumeration and construction of pandiagonal Latin squares of prime order
285
PROPOSITION 7.5. For each normalized path of index > 1 there are at feast four equivalence classes of linear simple PL-squares. Proof. By Corollary 7.3 and Lemma 7.4. By Fact 6.3, for n = 13 there 338 normalized paths of index > 1 and 10 normalized paths of
index 1. Since we have one equivalence class of linear simple PL-squares for each normalized path of index 1, it follows from Proposition 7.5 that there are at least 1362= 10 + 4(338) equivalence classes of linear simple PL-squares of order 13. Suppose that P if a fixed normalized path. We now give necessary and sufficient conditions, and easily verifiable sufficient conditions, for the existence of a PL-square made of translations of ?Tin the direction (a, b). Suppose that 7 has type T and index k, and recall that
4x)= f(Mx))x
= 7Tf(x)
for some function f: 2:/T+ 2:. By Proposition 7.2, the condition for the existence of a PL-square made of translations of 7~in the direction of (a, b) is that x
H
n(ax) - bx
be a permutation. Suppose that a# 0; since a(ax)-bx=(a(ax)/ax-
b/a)ax
= (f(PAax))
- bla)ax
and x H ax is a permutation, we obtain the following: PROPOSITION 7.6. Let rf be a normalized path and let a# 0. There exists a PL-square rf in the direction (a, b) if and only if the map z *
made of translations of
PT(f(z) - bla)z
is a permutation of ZzlT. Proof. By the above remarks and an argument similar to the proof of Proposition 5.1.
We have as an immediate consequence: COROLLARY 7.7. Let rf be a normalized path of type T and suppose a# 0. If the map z H
is a constant function direction of (a, b).
&-V(z)
- b/a)
on ZXIT, then there is a PL-square made of translations
of +rrfin the
A straightforward computation shows that for n = 13, the functions f associated with the basic normalized paths of index > 2 satisfy the hypothesis of Corollary 7.7 only with the slopes co, 1 and - 1 already provided by Corollary 7.3. Hence the same holds of the shifts of paths of index > 2. On the other hand, if 7rf= ~~~,,r)then the slope b/a in Corollary 7.7 can take on the additional values 4 and 9. Therefore this path gives rise to at least 6 non-equivalent linear simple PL-squares. Since the group & acts transitively on the paths of index 2, any normalized path which is a shift of a normalized path of index 2 also gives rise to at least 6 non-equivalent linear simple PL-squares. An example of such a square is given in Fig. 1. 8. PL-SQUARES
OF ORDER 13
An exhaustive computer search (described in detail in later sections) was done to find all
286
A. 0. L. ATKIN et al. 08175934486C2 97031C2864485 BSC6481420397 14A8C607B9253 A36425B90718C 8290B47536CAl 70B293AlC5864 697581C3A4820 5C317A869204B 315C60428B97A
CA8B426071539 264AOB9CS3718 4829375BlCA06 Fig. I. (A = 10, B = 11, C= 12). A PL-square cyclic in the direction of (1,4): 1 down, 4 across.
PL-squares
of order 13. The following was found:
FACT8.1. All simple PL-squares of order 13 are linear, and satisfy the condition of Corollary 7.7.
With this information we can now count the equivalence classes of simple PL-squares of order 13. Recall that by Definition 4.10 a normalized path has intrinsic index k if it is a shift of a basic normalized path of index k. PROPOSITION 8.2. For n = 13, the simple PL-squares are as follows: (a) there are 10 = 1 x 10 equivalence classes from the paths of index 1; (b) there are 624 = 6 x 104 equivalence classes from the paths of intrinsic index 2; (c) there are 312 = 4 X 78 equivalence classes from the paths of intrinsic index 3; (d) there are 624 = 4 x 156 equivalence classes from the paths of intrinsic index 6. Hence there are 1570 equivalence classes of simple PL-squares. Proof. By Facts 6.3, 8.1 and the remarks at the end of the previous section.
In addition to the simple PL-squares enumerated above, the computer search produced several non-simple PL-squares. All of these were transformable into the PL-squares given in Figures 2 and 3 by the group 9”. In Figs. 2 and 3 the plane Z,, x Z,, is represented with the origin at the upper left hand corner, the first coordinate axis pointing down, and the second coordinate axis pointing to the right, so that the element A(i, j) is located where the i&h entry of the figure, thought of as a matrix, would be found. Since the PL-square in Fig. 2 contains one path of index 1 with multipliers 2 and the PL-square in Fig. 3 contains one path of index 1 with multiplier 5, and since these paths cannot be transformed into each other under the action of %“‘,, it follows that the two PL-squares given in Figs. 2 and 3 cannot be transformed into each other. We now compute the number of non-simple PL-squares into which these two PL-squares can be transformed by computing the indices of their stabilizers in %“. LEMMA8.3. The stabilizer of the PL-square in Fig. 2 is {pklk = + 1). Proof. The PL-square in Fig. 2 is made up of the following 13 paths: rC2),six shifts of 7ro11)
with starting points (0, l), (0, 12), (5, 6), (5, 7), (8, 6), (8, 7) and six shifts of 7ru1,2)with starting points (2, 2), (2, 1l), (4, 0), (9, 0), (11, 2), (11, 11). Now every element a E 9” can be written
a = l&X
i j
V T(m,n)
(8.4)
where k E Zly,, 0 i i 5 3, 0 5 j I 1 and m, n E Z,,. If a fixes the PL-square being considered, then (r must send 7rC2) to itself; this is possible only if i = j = 0. Therefore a must send rows to rows and columns to columns. It also must fix the sets of starting points of paths of given index with given multipliers. Note that, except for the paths starting at (0, 1) and (0, 12), each of the shifts of nC2,,,) has its starting point in the same column as another such path. This property must be preserved by any (Yin the stabilizer; hence (Ymust fix (0, l), (0, 12) which implies that it
Enumeration and construction of pandiagonal Latin squares of prime order
287
sends row 0 into itself. Similarly, looking at the shifts of 7rol,2), (Ymust send column 0 into itself. This implies that m = n = 0 in (8.4), that is, (Y= pk for k E ZT3. It is easily checked that the only k E Z’f, for which & fixes the set of starting points are k = 1, 12. This completes the proof of the lemma. PROPOSITION8.5.
There are 8112 equivalence classes of PL-squares which transform into the PL-square given in Fig. 2. Proof.
The number of equivalence classes is the index of the stabilizer, which is 8(13*)~(13)/2= 8112. LEMMA 8.6.
The stabilizer of the PL-square in Fig. 3 is a cyclic group of order 6 generated by p12x2. Proof. The PL-square in Fig. 3 is made up of the following paths: ro), three shifts of rr(3,9)
with starting points (1, 4), (3, 12), (9, lo), three shifts of w(~,~,with starting points (7, 7), (8, 8), (11, ll), three shifts of ~(4, 10) with starting points (12, l), (10, 3), (4, 9), and three shifts of T(,,,~)with starting points (2, 6), (5, 2) (6, 5). It can be shown that for each of the four basic quadratic paths, the three starting points of its shifts lie on a straight line through the origin. Since any transformation fixing the PL-square must send starting points into starting points and must transform multipliers for the paths uniformly (i.e., all shifts of a single basic quadratic path must be sent to shifts of a single quadratic path), it must fix the origin. This means that it must be of the form
where k E ZT3, 0 d i I 3, 0 I j I 1. If a is a transformation fixing the PL-square, it must map 7rC5) to itself. This implies that j = 0, so that (Y= pai. Now the slopes of the aforementioned lines on which the starting points lie are 4, 1, 12 and 3, and a must carry the set of these lines into itself. This implies that i = 0 or 2, that is, (Y= & or (Y= ~LH*for k E Zf3. If (Y= ,.& then a must map the set of starting points of the shifts of 7rC9,3) to itself; since these starting points are
0123456789ABC 7COlB289A6534 34B209A6C8175 8589ACO127346 867534BC0129A 9AC6173458082 C217865834940 10349A28756CB 4B50289A6C713 534BC0129A867 27946BCO13458 A86C517340B29 69A87345B2COl Fig. 2. (A = 10, B = 11, C = 12). T(~,together with 6 shifts of TV*, ,,) and 6 shifts of TT~,,, *,.
0123456789ABC 48C9102358674. 526A7CB143089 470B56A891C23 183498C0267AS 6C81324A75B90 29460758341C8 B475291C6083A 701CB389A2456 C358A406B7912 94426175C8308 8690CB321A547 35B78A940C261 Fig. 3. (A = 10, B = 11, C = 12). n(5)together with 3 shifts of T~~,~,, 3 shifts of T~~,~,, 3 shifts of T(~,,,,and 3 shifts of T,,~,~).
A. 0. L.
288
ATKIN et al.
(7, 7), (8, 8), (11, ll), it follows that (7, 8, ll} = {7k, 8k, 1I&}, which implies that k = 1, 3 or 9. Suppose a = pkx2. Now x2 maps the set ((7, 7), (8, 8), (11, ll)} to the set ((1, 12), (3, lo), (9,4)}. These lie on the line through the origin with slope 12 and hence since pk preserves slopes, ,.&k must map the latter set into the set of starting points of the shifts of T~~,~,,). It follows that ((12, l), (10, 3), (4, 9)) = I(k, 12k), (3k, lOk), Vk, 4k)I which implies that k = 4, 10 or 12. It can be checked that &, k = 1, 3, 9 and ,.&x2,k = 4, 10, 12 map the set of starting points and multipliers of the basic quadratic paths to itself in a uniform manner. This implies that these six transformations map the PL-square to itself. Since x4 = p9, &x2)2 = p9 is of order 3; hence p12,$ is of order 6, and must generate the stabilizer. PROPOSITION8.7.
There are 2704 equivalence classes of PL-squares which transform into the PL-square in Fig. 3. Proof. The index of the stabilizer is 8(132)(p(13)/6= 2704.
given
PROPOSITION8.8.
There are 12,386 equivalence classes of PL-squares of order 13. Proof. By Proposition 8.2(e) there are 1570 equivalence classes of simple PL-squares, while
by Propositions 8.5 and 8.7 there are 8112 + 2704 equivalence classes of non-simple PL-squares, for a total of 12,386.
9. COMPUTATION OF PL-SQUARES OF ORDER 13
We now describe in general terms the computations done to find all equivalence classes of PL-squares of order 13. The main content of this section is the sequence of reductions used to make the computations manageable in size. A program written in SNOBOL4 was used to generate all possible normalized paths. This was a relatively simple backtrack program. The output from this program was examined to determine what pattern emerged. It was at this point that it was observed that all 348 normalized paths for n = 13 were shifts of the 36 basic normalized paths described in Section 6. The critical part of the computation was a program written in FORTRAN and IBM 370 Assembler to find compatible sequences of length n which can be formed from a set of normalized paths. The program finds compatible sequences by a backtrack search: given a compatible sequence of paths TO,
Tl,
. . . , rk-1
with ~~(0)= i, 0 5 i < k, the program searches for a normalized path 7~such that if Irk = 7(o,k)n, then
is a compatible sequence with pi = i, 0 5 i < k. The program then searches for a further extension, etc. When a compatible sequence of length n is obtained, it is output. When a sequence is reached which cannot be further extended, the program backs up one step to try another alternative. In this manner, starting with a given compatible sequence, the program will eventually output all compatible sequences of length n with the given sequence as initial segment. Throughout the remainder of this section, n = 13. To find all PL-squares of order n, it is sufficient to find one in each orbit of 3” acting on the set of PL-squares. For efficiency, we want to arrange the backtrack search so that we enumerate as few PL-squares as possible in each orbit, while enumerating at least one in each orbit. Suppose that no, rl, . . . , rn_, is a compatable sequence of paths determining the PL-square A. If r,, is not a basic normalized path, then 7V?rois a basic normalized path for some rVE Y,,.,
Enumerationand constructionof pandiagonalLatin squaresof prime order
289
and
is a compatible sequence determining the PL-square T,A. Hence to enumerate one PL-square in each orbit, we may assume that the first path 7~~in the compatible sequence we are constructing is a basic normalized path. If (YE 2”‘.,then a?rf),
LYPl,
. .
.)
cYlr,_1
is a compatible sequence determining the PL-square CUA. Therefore we need consider only one r. from each orbit of the action of Y,,. In summary:
LEMMA 9.1. In order to enumerate at least one PL-square in each orbit of the action of %,,, it sufices to enumerate all compatible sequences ro, . . . , nn_l for which 7ro lies in a set of representatives the orbits of T,, acting on the set of basic normalized paths.
of
This means that instead of considering 348 choices for ro, we need consider only 5 choices teegOT(2)? “~5)~ %,9)? TW,8)~ ?9,8.2,6.8,10$ The above technique of using Y,, and 2” to limit the choice of no can be further refined. Suppose first that the PL-square A contains a path which, when normalized, has index 1. By applying some element of Y”-,,we may assume that r. has index 1. By applying some element of 2’,,,we may replace no by any other normalized path in its orbit under the action of 3”. That is, we may assume that no = rC2)or 7ro= or,,,. Say that q. = rCsr,,,. By Lemma 5.3 none of the other paths in the PL-square can be translates of paths of index 1 with multiplier # c. Therefore rl, We now show that we . . . , TT_, must be chosen from the paths of index > 1, together with GT~,,. can further restrict the choice of ITS.Let 7~~= Q,) 7~where P is a basic normalized path. Now TV_,, _-(ICj fixes the path no = r(,,. Let
=
r(O.
b-oc)r*
Since 770,. . . , T”_~ is a compatible sequence, ac = To(a) # 7r,(a) = ‘r@,b)r(a) = b,
hence b - acf 0 has an inverse d in 2:. Now ,.&,fixes 7r(,,, and by Lemma 4.5,
k‘d”+= pd?O.b-oc)r = 7(0, I),.&,~. Since ,_&,ris a basic normalized path, this shows that the original PL-square is in the same orbit as one with 7ro= r(,, and 7~~= T(~,,)7~‘,with IT’a basic normalized path. The following computations were done: COMPUTATION 9.2. Enumeration of all compatible sequences of paths ro, . . . , r12 with r. = rcz), with 7rI constrained to be rco,,,7~where either r = rcz, or 7~is a basic normalized path of index > 1, and with ri, 2 I i I 12, constrained to be r(o,i)p where either 7~= r(2) or 7~is any path of index > 1. (This gives 27 possibilities for 7~~and 339 possibilities for each ?r, 2 5 i I 12.)
COMPUTATION 9.3. Same as Computation
9.2, with rt2) replaced everywhere by rc5).
Assume now that all paths in the PL-square A, when normalized, have index > 1. Suppose
290
A. 0. L. ATKINet al
that some path, when normalized, has intrinsic index 2. Applying elements of .Ynand Z,, as before we may assume that no is some fixed basic normalized path of index 2. COMPUTATION9.4
Enumeration
of all compatible sequences of paths 7ro, . . . , ~~~ with ?ro= 7r(3,9),and with 7~!, to be T~o,i~7T, where the index of 7~> 1. (This gives 338 possibilities for each of rl, . . . , a,*.)
15 i 5 12, constrained
Assume now that all paths in the PL-square A, when normalized, have intrinsic index > 2. Suppose that some path, when normalized, has intrinsic index = 3. As before we may assume that 7rois some fixed basic normalized path of index 3. COMPUTATION9.5.
Enumeration
of all compatible sequences of paths ro, . . . , 7r12with ro= 7~(5,~,~), and with vi, to be T(~,i)ry where the intrinsic index of 7~2 3. (This gives 234 possibilities for each of 7~~~ . . . , q2.)
1 5 i % 12, constrained
Finally, assume that all paths in the PL-square A, when normalized, have intrinsic index > 3, that is, they all have intrinsic index = 6. As before, we may assume that r. is some fixed basic normalized path of index 6. COMPUTATION9.6.
Enumeration of all compatible sequences of paths no, . . , , 7~~~ with no = 7rC9,8,2,6,8.10) and with riri, 1 5 i 5 12, constrained to be rCo,i)r where the intrinsic index of P = 6. (This gives 156 possibilities for each of plr . . . , 7r12.)
The results of these computations were as follows: Computation 9.2 produced one simple PL-square and six non-simple PL-squares which are all in the same orbit as the PL-square in Fig. 1. Computation 9.3 produced one simple PL-square and eight non-simple PL-squares which are all in the same orbit as the PL-square in Fig. 2. Computation 9.4 produced six simple PL-squares. Computations 9.5 and 9.6 each produced four simple PL-squares. The PL-squares are described in more detail in Section 8. 10. METHODS OF COMPUTATION
In this section we briefly discuss some of the technical aspects of the computations described in the previous section, and make some informal empirical observations on compatible sequences. The basic program, when given a compatible sequence no, . . ., vi, searched for a normalized path 7r* for which
would be a compatible sequence. This requires repeated checking of whether pi = Tco,i)rand rj = ~~o,j~~’ are compatible for i < j. This compatibility depends only on n, 7~’and j - i. The machine which was used has a large (2 megabytes) memory. This allowed us to precompute this compatibility information and store it in a large array, rather than repeatedly recomputing it. Another feature of the machine (an IBM 370 Model 158) of which we were able to take advantage is a “cache”, a small very high speed memory which holds a short segment of instructions. We coded the compatibility checks as an inner loop small enough to fit into this “cache” (using Kirkhoff’s Law in the spirit of [9] to identify the components of the inner loop.) The computations 9.2-9.6 took over 32 hr of CPU time, which made even very slight improvements in efficiency significant. As the program ran, statistics were kept on the lengths of compatible sequences which could not be extended. Apparently, compatibility is a very complex phenomenon, and depends on interaction between many paths. Two facts illustrate this: First, any compatible sequence of length 12 can evidently be extended to one of length 13 (by defining 7r12(i)to be the unique element of Z13not in {rj(i)[O s j I 1l}.) However, there exist compatible sequences of length 11 which cannot be extended. Second, the number of compatible sequences grows until a length of 6 or 7 is reached, and then drops off very quickly. This suggests that it takes interaction between several different paths to make a comptaible sequence non-extendable.
Enumeration and construction of pandiagonal Latin squares of prime order
291
11. HISTORY OF THE SUBJECT
The work described in this paper was undertaken in response to a question posed by Hedayat on the number of inequivalent “Knut Vik designs”; until shortly before its completion we were, somewhat naively, unaware of any results in the subject other than those contained in Refs. [6, 71. This ignorance may perhaps be partly excused by the fact that almost none of the published work relevant to our problem had appeared under the heading of Latin squares; rather it occurs in the recreational mathematics literature concerning magic squares and the n-queens problem. A search of the literature was initiated when one of us fortuitously obtained a copy of Benson and Jacoby[2] and found therein a reference to the work of Stern[l6]. We now attempt to give a survey of previously known results, insofar as our knowledge extends. (“This saving clause, which for convenience will be suppressed in what follows, will kindly be understood and supplied by the reader concerning every other historical statement herein contained. It is needed, for very many have written on this subject in all sorts of odd ways and places” ([lo], p. 117).) The subject of pandiagonal Latin squares was originated by Euler. In 141he gave a proof of the nonexistence of cyclic PL-squares of order divisible by 2 or 3, as well as the method of construction and the enumeration formula for cyclic PL-squares of all orders not divisible by 2 or 3([4], p. 322); also given is a proof (though not an explicit statement) of the nonexistence of Latin squares of even order (cyclic or otherwise) satisfying the wraparound diagonal condition in even one direction ([4], p. 309). This fact appears to have been rediscovered by a number of people in several different contexts, and is well known. The use of the path of an element in a PL-square of order n as a solution to the n-queens problem dates back to the 1880’s (see Ahrens ([l], p. 133, footnote 2)). Such solutions, called “doubly periodic”, were shown to be impossible when n is divisible by 3 by Polya[l3], using an argument credited to Hurwitz. This proves the nonexistence of PL-squares (cyclic or otherwise) for all orders divisible by 3, a fact independently proved by Hedayat[6]. Polya[l3] also demonstrated by an example the existence of a path for n = 13 that was not an extended Knight’s move, and described a method for constructing such paths when n is composite. A proof that such paths exist for prime n if and only if n 2 13 was given by Rosser and Walker in [15], using a combination of geometric and number-theoretic arguments; in [14], Rosser and Walker determined the group which transforms the set of rows, columns and diagonals of a square into itself. Methods for constructing semi-cyclic squares from cyclic ones were given by Stern in Refs. 116, 17, 181for special values of n (e.g. n = 2sk + 1 for s, k > 1, n a prime of form 4k + 1, etc.); these methods, which also combine geometric and number-theoretic arguments, have been extended by Bensonl21. It should be mentioned that Stern grouped under the name “noncyclic” all PL-squares which are not cyclic in rows, columns or diagonals, whether or not they are cyclic in some other direction. Finally, it was found that our proof of the existence of quadratic paths for all prime n 2 13, using the patterns of quadratic residues, was independently discovered by Bruen and Dixon[3], in the context of “modular” (i.e. doubly periodic) solutions to the n-queens problem. REFERENCES W. Ahrens, Mathematische Unterhaltungen und Spieie. Teubner, Leipzig (1901). W. H. Benson and 0. Jacoby, New MnthemaGcol Recreations with Magic Squares. Dover, New York (1976). A. Bruen and R. Dixon, The n-queens problem. Discrete Math. 12, 393-395(1975). L. Euler, Recherches sur une nouvelle espbce de carrts de magiques, Verh. uan het Genootshap te Vlissingen 9,85-239 (1782); reprinted in Leonardi Euleri Comment. Arith. Coil. Vol. II, Section LXX, pp. 302-361.Petropoli (1849). 5. R. A. Fisher, The Design of Experiments. Oliver & Boyd, Edinburgh (1935). 6. A. Hedayat, A complete solution to the existence and nonexistence of Knut Vik designs and orthogonal Knut Vik designs. J. Comb. Theory (A) 22, 331-337(1977). 7. A. Hedayat and W. T. Federer, On the nonexistence of Knut Vik designs for all even orders. Ann. Statistics 3,445447 1. 2. 3. 4.
(1975). 8. 0. Kempthome, Design and Analysis of Experiments. Wiley, New York (1952). 9. D. E. Knuth, Estimating the efficiency of backtrack programming. Math. Computation 29, 121-136 (1975).
10. E. McClintock, On the most perfect forms of magic squares, with methods for their production. Am. J. Math 19, 99-120 (1897). 11. 0. Nissen. The use of systematic 5 x 5 squares. Biometrics 7, 167-170(1951). 12. E. T. Parker, Computer investigation of orthogonal Latin squares of order 10. AMS Proc. Symp. Appl. Math. 15,73-Q (1%2). Camwa Vol 9. No. 2-D
292
A. 0. L. ATKIN ef al.
13. G. Polya, ober die “doppelt-periodischen” Losiingen des n-Damenproblem, Mathematische Unterha/tungen und Spiele (Edited by W. Ahrens), pp. 364374. 2nd Edn, Teubner, Leipzig, 1918. 14. B. Rosser and R. J. Walker, The algebraic theory of diabolic magic squares. Duke Math. 1. $705-728 (1939). 15. B. Rosser and R. J. Walker. Manic Sauares. Published Paoers and Suoolement. Section 6. .DD. ._ . 729-753. Cornell University Library (typed manuscript). _ 16. E. Stern, Number of magic squares belonging to certain classes, Am. Math. Monthly 46,555-581 (1939). 17. E. Stern, iiber eine Zahlentheoretische Methode zur Bildune. und Anzahlbestimmung neuerartige lateinischer Quadrate;.Timisoara, Rumania. Institutul Politehnic. Bulletin de &iience et Technique 10, cl-131 (1941). 18. E. Stem, Uber irregulare pandiagonale lateinische Quadrate mit Primzahlseitenliinge. Niew Archief uoor Wiskunde 19, 257-271(1938). 19. K. Vik, Bedemmelse av feilen pi forseksfelter med og uten malestokk. Meldinger fra Norges Landbrukshflgskole 4, 129-181 (1924).
Added in Proof
The contents of this paper appeared in abstracted form in A. 0. L. Atkin, L. Hay and R. G. Larson, Construction of Knut Vik designs, J. Statist. Plann. Inference 1,289-297 (1977). We thank Martin Gardner for bringing to our attention A. K. Chandra, Independent permutations, as related to a problem of Moser and a theorem of Polya, J. Comb. Theory (A) 16, 111-120(1974) in which new proofs are given of Polya’s theorem[l3] and of the fact that non-extended Knight’s move paths exist only if ” 2 13.