Packing of permutations into Latin squares

For every positive integer $n$ greater than $4$ there is a set of Latin squares of order $n$ such that every permutation of the numbers $1,\ldots,n$ appears exactly once as a row, a column, a reverse row or a reverse column of one of the given Latin squares. If $n$ is greater than $4$ and not of the form $p$ or $2p$ for some prime number $p$ congruent to $3$ modulo $4$, then there always exists a Latin square of order $n$ in which the rows, columns, reverse rows and reverse columns are all distinct permutations of $1,\ldots,n$, and which constitute a permutation group of order $4n$. If $n$ is prime congruent to $1$ modulo $4$, then a set of $(n-1)/4$ mutually orthogonal Latin squares of order $n$ can also be constructed by a classical method of linear algebra in such a way, that the rows, columns, reverse rows and reverse columns are all distinct and constitute a permutation group of order $n(n-1)$.


Introduction
A permutation is a bijective map f from a finite, n-element set (the domain of the permutation) to itself. When the domain is fixed, or it is an arbitrary n-element set, the group of all permutations on that domain is denoted by S n (full symmetric group). If the elements of the domain are enumerated in some well defined order as z 1 , . . . , z n , then the sequence f (z 1 ), . . . , f (z n ) is called the sequence representation of the permutation f . This sequence representation then fully determines the permutation, and the term "permutation" may mean this sequence itself or the bijective map that it represents.
In every n-by-n square matrix L there are sequences of length n occurring as rows, columns, reverse rows or reverse columns. These at most 4n sequences will be called lines of the matrix. The columns are the rows of the transpose L T , the reverse columns are the rows of the conjugate JLJ where J = J −1 is the exchange matrix given by J(i, j) = δ i,n+1−j (where δ i,j is the Kronecker delta), and the reverse rows are the rows of the transpose of the conjugate JLJ (also equal to JL T J). The four matrix operators mapping L to L, L T , JLJ, and JL T J, respectively, form a group under composition. The matrix L is symmetric if L = L T , and centrosymmetric if L = JLJ. Either of these properties implies the other, and both may hold at the same time: such matrices have been studied e.g. in [1,2,5,8].
The opposite of this situation is when the 4n lines of the matrix L are all distinct, in this paper we call such a matrix strongly asymmetric. In this paper we are interested in matrices that are actually Latin squares. For the general theory of Latin squares see Keedwell and Dénes [7].
Given a finite, n-element set R, a set S of m Latin squares of order n with entries in R (meaning that each line of each member of S represents a permutation of R) is called a packing if (i) all members of S are strongly asymmetric, (ii) no line of any member of S appears as a line in any other member of S. Equivalently, S is a packing if the number of distinct sequences appearing as lines in the members of S is 4nm. In that case the 4nm permutations represented by these 4nm sequences are said to be packed into the set S of Latin squares. Proposition 1. If some subgroup G of the full symmetric group S n of all permutations is packed into a set S of strongly asymmetric Latin squares, then every subgroup H of S n containing G is also packed into some set of strongly asymmetric Latin squares.
Proof. Let Q be a set of |H|/4n distinct representatives of the (left) cosets of G in H. Apply each representative to each matrix M in S elementwise, i.e. for each q in Q and each M form the matrix qM given by (qM )(i, j) = q(M (i, j)).

Latin squares of odd order
Fact 1. Let C and R be subgroups of a group G. For any element g ∈ G the following conditions are equivalent: (i) the map from the Cartesian product set C × R to the double coset CgR that sends (c, r) to cgr is bijective, (ii) the conjugate subgroup gRg −1 intersects C trivially. Fact 2. Let C and R be subgroups of a finite group G. The following conditions are equivalent: (i) all the double cosets have cardinality equal to Card(C)×Card(R), (ii) every conjugate of C meets every conjugate of R trivially.
Fact 3. Let C and R be two subgroups of a finite group G whose orders are relatively prime. Then all the double cosets have cardinality equal to Card(C)×Card(R).
The following Proposition will be proved by an appropriate application of the "addition square" construction appearing in Gilbert [6]. Proposition 2. If n is a positive odd number at least 5, then the full symmetric group S n can be packed into some set of strongly asymmetric Latin squares.
Proof. Fact 3 applies in particular if G is the full symmetric group of all permutations of the n-element set {1, . . . , n}, for odd n ≥ 5, C is the subgroup generated by the circular shift permutation whose sequence representation is (2, . . . , n, 1), and R is the two-element subgroup containing the reversal permutation whose sequence representation is (n, . . . , 1).
All double cosets CgR have cardinality 2n. The number (n − 1)!/2 of double cosets is even. Arrange the double cosets in matched pairs. From each matched pair (A, B) of double cosets choose representatives p, q from A, B, respectively, Construct the matrix M given by M (i, j) = p(i) + q(j).
The columns and reverse columns of M are precisely the members of the double coset A, and the rows and reverse rows of M are the members of the double coset B. In the set of (n − 1)!/4 matrices so constructed every permutation occurs exactly once as a row, column, reverse row or reverse column. Remark 1. The above construction does not work for even n, because the circular shift applied n/2 times is then a conjugate of the reversal (has similar cyclic structure).

Latin squares of even order
Definition 1. An n-by-n matrix (possibly Latin square) is called a double occurrence matrix if every sequence appearing as a line (row, column, reverse row, or reverse column) appears exactly twice, and every sequence appearing as a row of index i (i-th row) also appears as the column of the same index i. A set of double occurrence matrices is called a double occurrence matrix set if no sequence appears as a line in more than one of the matrices. The set of permutations whose sequence representations appear as lines in a double occurrence matrix or matrix set is called the set covered by the matrix or matrix set. Proof. First we observe that for every n > 2, there is an n-by-n double occurrence matrix such that the lines appearing in the matrix constitute the sequence representations of a permutation group on the numbers 1, . . . , n. Indeed, such a matrix can be defined by letting the element of the matrix in row i and column j be the number i + j, with addition defined modulo n.
Secondly, let M be any n by n double occurrence matrix whose lines constitute a permutation group G. Let R be any complete system of representatives of the left cosets of G in the full symmetric group of all permutations of 1, . . . , n. Applying the various permutations r ∈ R (viewed as functions) entrywise to M we obtain the matrix set required.
For an n by n Latin square L and each n-by-n Boolean matrix A (0 − 1 matrix), let the 2n-by-2n composite matrix L − A be defined by replacing each entry of L in row i and column j whose value is k by the 2-by-2 block B k A(i,j) .
Remark 3. Both L and A are encoded into the composite L − A without loss of information: A(i, j) is 0 or 1 according to whether L − A(2i − 1, 2j − 1) is smaller or larger than L − A(2i − 1, 2j), and L(i, j) is half the larger of these two entries of L − A.
Proposition 4. For every even number 2n > 4, there is a set S of Latin squares of order 2n, such that every sequence representing a permutation preserving the partition of the numbers 1, 2, . . . , 2n − 1, 2n into pairs of consecutive numbers occurs exactly once as a line of some member of S.
Proof. Partition into pairs {v, w} in any manner the set of 0 − 1 vectors of length n whose first component is 0 (actually partitioning into pairs of any complementfree set of 2 n−1 vectors will do). Order each pair {v, w} arbitrarily into an ordered pair (v, w). For each such ordered pair define the n-by-n Boolean matrix A vw by We obtain thus a set of 2 n−2 Boolean matrices with the property that if a vector v appears as the i-th row in one of the matrices, then the i-th column of that matrix is neither v nor its Boolean complement.
Let E be a double occurrence matrix set covering all permutations of 1, . . . , n, which exists according to Proposition 3 and consists of (n − 1)!/2 matrices.
Let S consist of all the composite matrices L − A vw , where L can be any member of E. In view of Remark 3, the set S consists of (n − 1)!2 n−3 matrices. The key to verifying that no vector can appear twice as a line anywhere in S, is to note that because of the double occurrence property of E the only possible coincidences to worry about concern rows and columns of the same member matrix of S, but such coincidences are excluded due to the complement-free property of the set of Boolean vectors used to define the matrices A vw .
The proof is concluded by observing that the number of (distinct) lines appearing in members of S is (n − 1)!2 n−3 /8n = n!2 n , which is the number of the partitionpreserving permutations specified in the statement of the proposition. The question that is opposite to the one asking for as many distinct lines in Latin squares is that of how many of the 4n lines of a Latin square of order n must be distinct, can a Latin square of order n contain only n distinct lines (each of which would then have to appear as a row, a column, a reverse row and also as a reverse column). The answer is obviously negative for odd n > 1. But for all even n = 2m, we can construct such Latin squares of order n containing exactly n permutations appearing as lines.
For any i = 1, . . . , n the i-th row, the i-th column, the (n − i + 1)-th reverse row and the (n − i + 1)-th reverse column of a symmetric centrosymmetric Latin square of order n are the same permutation. In other words a symmetric centrosymmetric Latin square of order n contains exactly n different permutations. Some examples of symmetric centrosymmetric Latin squares can be constructed by starting from symmetric Latin squares as follows: Let A be a symmetric Latin square of order m and let B be defined by B(i, j) = A(i, j)+m for i, j ∈ {1, . . . , m}. Then the following matrix is a symmetric centrosymmetric Latin square of order n: where J is the exchange matrix given by J(i, j) = δ i,m+1−j for i, j ∈ {1, . . . , m}. A similar construction for centrosymmetric Latin squares is given in [4].

Packing a permutation group into a single Latin square
In this section we give a construction showing that if n is either a composite odd integer or a prime congruent to 1 mod 4, then the full symmetric group S n can be packed into a set of strongly asymmetric Latin squares. By a ring we always mean a commutative ring with unit element 1.
In every finite cyclic group Z m there is an element u such that x + x = u is only possible for at most one element x. We can take u = −1. Taking direct products we can see that in every finite Abelian group there is an element u such that x + x = u is only possible for at most one element x.
Since the additive group of every finite ring is the direct product of cyclic groups, every finite ring R has an element u such that 2x = u has at most one solution x. With such an element u of R being fixed, for each element x of R denote u − x by x ′ . Mapping x to x ′ defines an involution on R, called reflection, which has at most one fixed point. It has a fixed point if and only if x + x = u has a solution (which happens if and only if the number of elements of R is odd). Proposition 6. Given a reflection x → x ′ of an n-element ring R, the elements of R can be enumerated z 1 , . . . , z n in such a way that the reverse sequence z n , . . . , z 1 coincides with the reflected sequence z ′ 1 , . . . , z ′ n . Proof. If the reflection has no fixed point, n is even and the elements of R can be partitioned into n/2 pairwise disjoint pairs so that the reflection exchanges the elements of each pair. Choose in any way one element from each pair and enumerate them in any order as z 1 , . . . , z n/2 . Then let z n−i+1 = z ′ i for i = 1, . . . , n/2. If the reflection has a fixed point y, then the other elements of R can be partitioned into (n − 1)/2 pairwise disjoint pairs so that the reflection exchanges the elements of each pair. Again, choose in any way one element from each pair and enumerate them in any order as z 1 , . . . , z (n−1)/2 . Let z (n+1)/2 = y and let z n−i+1 = z ′ i for i = 1, . . . , (n − 1)/2.
Fixing a reflection x → x ′ of the ring R, and an enumeration z 1 , ..., z n , we shall say that this enumeration is reflectable if z ′ i = z n−i+1 for all i. Definition 2. We shall say that in a finite ring R a 4-element subgroup G of the multiplicative group of units is a quartet if it consists of two distinct elements and their negatives. (Necessarily 1 and −1 belong then to the quartet G.) Lemma 1. If q is a prime power congruent to 1 mod 4, then the finite field GF (q) has a quartet.
Proof. The quartet consists of 1, −1 and the two square roots of −1.
Counter-examples. GF (p) with a prime p congruent to 3 mod 4, or GF (q) with q an odd power of a prime congruent to 3 mod 4, has no quartet.
Proposition 7. Let n be an integer at least 5. The following conditions are equivalent: (i) there exists an n-element commutative ring R with unit that has a quartet, (ii) n is not a prime congruent to 3 mod 4, and it is not 2 times such a prime.
Proof. If (ii) does not hold but (i) does, then the additive group of R must be cyclic, therefore R is isomorphic to Z n . Euler's phi function takes value n − 1 on n, where n is a prime, or the value (n/2) − 1 if n is 2 times a prime, thus the order of the group of units of Z n is not divisible by 4 and therefore it cannot have any 4-element subgroup, contradicting (i). If (ii) holds, we need to examine the following cases. Case 1. If n is composite odd, let n = mq be a proper factorization. Obviously both m and q are greater then 2. The direct product ring Z m × Z q has a quartet, namely (1, 1), (−1, −1), (1, −1), (−1, 1). Case 2. If n is prime congruent to 1 mod 4 then in Z n = GF (n) the element −1 has a square root r and {1, −1, r, −r} is a quartet (this is a special case of Lemma 1). Case 3. If n is divisible by 4, then in Z n the residues 1, −1, (n − 2)/2 and (n + 2)/2 form a quartet. Case 4. If n is of the form 2m where m is odd, then by applying Cases 1. and 2. we see that some m-element ring A has a quartet Q. Then in the direct product ring Z 2 × A the set of elements of the form (1, q), where q is in Q, is a quartet. Remark 4. From the above proof it is clear that when n satisfies the conditions of Proposition 7, then an n-element ring having a quartet exists that is either a ring of residue classes of Z, or a direct product of two such rings, or a finite field. There is no quartet in Z 9 because the group of units of Z 9 has order 6. There is no quartet in GF (27) because the 26-element group of units of GF (27) cannot have any 4-element subgroup. There is no quartet in Z 27 because the order of its group of units is 18. There is a quartet in GF (25) -consisting of the units in the prime subfield -but not in the direct product ring Z 5 × Z 5 . Because non-prime fields can be replaced by direct products of rings in constructing quartets (see Case 1 in the proof of Proposition 7), rings of the form Z k × Z m suffice, where k may be 1, to construct rings with a quartet having the prescribed number of elements. for some element b of R. The corresponding reverse column is the sequence for some element a of R.
As for distinct columns the corresponding elements b in (1) are distinct, the columns of the matrix M are all distinct, and by a similar argument the rows of M are distinct from each other too.
If a column (1) were to coincide with a reverse column (2), then for all i = 1, . . . , n we would have cz i + b = (−c)z i + a. In particular, taking z i = 0, we would have to have a = b, and then z i = −z i for all i by the invertibility of c, implying in particular 1 = −1, which is impossible. Thus no column is identical with a reverse column.
Suppose that a column (1)  Corollary 1. If for the integer n there is an n-element ring having a quartet, then the full symmetric group S n has a subgroup (necessarily of order 4n) that can be packed into a single Latin square (whose 4n lines are all distinct).
Applying Proposition 1 we obtain: Corollary 2. If for the integer n there is an n-element ring having a quartet, then the full symmetric group S n can be packed into a set S of n!/4n Latin squares whose n! lines are all distinct.
Combining Corollary 2 and Proposition 8 we have: Corollary 3. If the integer n > 4 is not of the form p or 2p with prime p congruent to 3 modulo 4, then there exists a strongly asymmetric Latin square of order n the 4n distinct lines of which form a permutation group (subgroup of S n ).
When n is a prime congruent to 3 modulo 4, then by the non-existence of subgroups of order 4n in S n (see Proposition 10 in the Appendix), obviously no permutation group can be packed into a single Latin square of order n. Finally, if n is of the form 2p with p prime congruent to 3 modulo 4, then subgroups of order 4n do exist in S n (Proposition 11 in the Appendix), but we do not know if such a subgroup can be packed into a Latin square. Proposition 9. For every prime number p congruent to 1 modulo 4, there is a permutation group G of order (p − 1)p and a set of (p − 1)/4 mutually orthogonal Latin squares of order p such that every permutation in G occurs exactly once as a line of the one of these Latin squares.

Mutually orthogonal Latin squares
Proof. (Method based on Bose [3]) Let p be a prime number congruent to 1 mod 4, with the arithmetic of GF (p) on the set {1, . . . , p}. Using the subset V = {1, . . . , (p − 1)/2} let us form (p − 1)/4 ordered couples (r, s) so that every member of V occurs exactly once as a (first or second) component of such a couples (r, s). It is easy to see that the couples can be formed in a way that for any two distinct couples (r, s) and (r ′ , s ′ ) the determinant of the matrix r s r ′ s ′ is non-zero. For each of these couples (r, s) define the p-by-p matrix M rs by M rs (i, j) = ri + sj The (p − 1)/4 matrices so defined are mutually orthogonal. As the set V does not contain the negative of any of its members, every permutation of the elements of GF (p) given by the linear permutation polynomial f (x) = rx + c, with r ∈ V and c ∈ GF (p), will occur exactly once as a row or column of one of the (p − 1)/4 matrices given, and every permutation of the elements of GF (p) given by f (x) = rx + c, with r ∈ GF (p) − {0} and c ∈ GF (p) will occur exactly once as a line of one of these matrices. Moreover, the (p − 1)p permutations having this linear (affine) form constitute a group.

Appendix: Existence of permutation groups of order 4n
Proposition 10. There is no order 4n subgroup in S n for prime n congruent to 3 modulo 4.
Proof. Suppose the contrary, let G be such a subgroup of S n of order 4n. By Sylow, G has a subgroup C of order n. Choose any generator g of C, it must have a unique cycle of length n. Also by Sylow, some permutation r of order 2 (involution) must also belong to G and without loss of generality to the stabilizer of (n + 1)/2 in G. The stabilizer subgroups of G are all conjugates of each other by elements of C, and they all have the same order. Also, under the conjugation establishing an isomorphism between two stabilizers, corresponding elements of the stabilizers have similar cycle structure, in particular they have the same number of fixed points.
As G is transitive with orbit of size n, the stabilizers must have order 4. We use the fact that a 4-element group is either cyclic or it is isomorphic to the direct product Z 2 × Z 2 (Klein group). Case 1. The stabilizer F of (n+1)/2 is cyclic. Then it is generated by a permutation f in F the square of which is r. Clearly f must have at least one cycle of length 4, but since n is congruent to 3 mod 4, there must be at least 2 elements of {1, . . . , n} different from (n + 1)/2 that are not on any cycle of length 4. Such an element x is either a fixed point of f or it belongs to a cycle of length 2. In either case the square of f must fix every such element x. Thus r has at least 3 fixed points.
Applying the Burnside Lemma to the group G acting on {1, . . . , n} (permutations being functions from {1, . . . , n} to itself), the sum of the number of fixed points of the various permutations h ∈ G taken over all members h of G should be 4n. The identity permutation has n fixed points. Each of the n conjugates of r by members of C has at least 3 fixed points, these are at least 3n points altogether. Each of the n conjugates of f by members of C has at least the fixed point (n + 1)/2, the sum of these is at least n.
The n conjugates are distinct since they are not all the same, and they form an orbit under conjugation by the elements of the prime subgroup C. Thus the Burnside count of fixed points is at least n + 3n + n = 5n: we have obtained a contradiction completing the proof. Case 2. The stabilizer F of (n + 1)/2 is a Klein group. Then it consists of the identity permutation, the permutation r, and two other permutations s and q of order 2, such that the product of any non-coinciding two of r, s, q is the third. The cycle structure of each of s and q consists of at least one cycle of length 2 and an odd number of fixed points including the point (n + 1)/2.
Consider the complete graph K on the (n − 1)-element vertex set The permutations r, s, q define respective matchings R, S, Q in K: a pair of vertices is an edge in the matching R, S, Q if it is transposed by r, s, q, respectively. Without loss of generality assume that the size of the matching R is not less than the size of S or Q. The connected components of the union of any two matchings can be only circuits of even length and paths.
We claim that any such circuit must have length 4. For suppose that one of these circuits, say in the union of matchings M and N , corresponding to two of the three permutations r, s, q, say to the permutations f, g, is a circuit of length 2m, m > 2. This would imply that the vertices of this circuit would not be fixed by the composite permutation f gf g, thus f g would not be of order 2, as any non-identity element of a Klein group should be: a contradiction proving the claim that all circuits in the union of any two of R, S, Q have length 4.
Next, observe that if (u, v, w, x) is a circuit (of length 4) in the union of S and Q, then, due to sq = qs = r, the edges uw and vx belong to R.
We claim that it is not possible for each of S and Q to cover all vertices in V . For in that case, by the maximality assumption on R, the matching R would also cover all vertices in V . As n − 1 is congruent to 2 mod 4, there would be an odd number m of edges in R that are not incident with any circuit in the union of S and call these edges free. As r = sq, the end vertices of each free edge must be connected by a unique path of length 2 in the union of S and Q.
We show that the end vertices of a free edge xy in R cannot indeed be connected by a path of length 2 in the union of S and Q. For suppose that they are so connected by the path xvy, with xv is S and vy in Q. Let w be the vertex r(v). Using rq = s and rs = q, it is easy to verify that (x, v, y, w) would be a circuit of length 4 in the union of S and Q, contradicting the assumption that xy is a free edge and proving the claim.
In other words, every free edge of R is either in S or Q. (A free edge xy cannot be in both S and Q, because then we would have sq(x) = x, contradicting r(x) = y). Without loss of generality at least one free edge xy of R is not in S.
The set f ix(s) of fixed points of s consists of (n + 1)/2 and the end vertices of the free edges of R that are not in S. Clearly f ix(s) has at least 3 elements, say k elements. Obviously k < n. The group C acts on G by conjugation, under this action the orbit of s is not trivial, and as its size must be a divisor of the order n of C, which is prime, this orbit must contain n distinct permutations, all having k fixed points, where 1 < k < n.
Applying the Burnside Lemma to the group G acting on {1, . . . , n} (permutations being functions from {1, . . . , n} to itself), the sum of the number of fixed points of the various permutations f ∈ G taken over all members f of G should be 4n. The indentity permutation has n fixed points. Each of the n conjugates of r by members of C has 1 fixed points, these are n points altogether. Each of the n conjugates of s by members of C has k fixed points, the sum of these is kn. As n + n + kn is at least 5n, we have obtained a contradiction completing the proof.
Proposition 11. For even integers n = 2m at least 6 the full symmetric group S n always has a subgroup of order 4n.