apriiori
random

fully diagonalized latin k-cubes ii

One way of defining a fully diagonalized latin $k$-cube is by giving a function $A : \{0, \ldots, n-1\}^k \to \{0, \ldots, n-1\}$11 Or any $n$-element set. such that the function restricted to any diagonal is an injection. A diagonal, here, involves choosing for each of the $k$ coordinates to either run it forwards from $0$ to $n-1$, to run it backwards from $n-1$ to $0$, or to fix it at some value in $\{0, \ldots, n-1\}$22 Note that if you swap every moving coordinate between running forwards / backwards, you end up with the same diagonal that you had originally. If this is a particular issue, you can normalize so that the first moving coordinate is in the +1 direction, but it’s really easier to just double count. You don’t really introduce any additional complexities if you phrase your definitions to require that both the top-left → down-right and the down-right → top-left diagonals include all n colors.. This produces a notion of the dimensionality of a diagonal: a diagonal of dimension $d$ has $d$ of its coordinates run forwards or backwards, and $n-d$ of its coordinates fixed.

In a $3$-cube, the rows, columns, and aisles are $1$-dimensional diagonals, the face diagonals are $2$-dimensional, and the space diagonals are $3$-dimensional. Each cell in the cube is a $0$-dimensional diagonal, where every coordinate is fixed. Only the $0$-dimensional diagonal maps are merely injective — the rest are necessarily bijective, for the diagonal contains $n$ cells. We will call those diagonals trivial.

The $\sum_i 2^i x_i \bmod n$ for $n$ with no nontrivial33 Equivalently, prime. factors below $2^k$ construction from the first post is a special case of a more general construction:

Theorem: Let $G$ be an (additive) abelian group of order $n$ and $\lambda : \{0, \ldots, n-1\} \to G$ a bijective labelling such that $\lambda(n-1-x) = u - \lambda(x)$, and let $\varphi_0, \ldots, \varphi_{k-1} : G \to G$ be endomorphisms of $G$. Then, the array

$$ A(x_1, \cdots, x_k) = \sum_{i=0}^{k-1} \varphi_i(\lambda(x_i)) $$

is an FDL $k$-cube if and only if, for any sign vector $e \in \{0, +1, -1\}^k$ other than zero, the map $\sum_i e_i \varphi_i$ is a bijection. FDL $k$-cubes constructed this way are said to be linear over $G$ or, in general, group-linear.

Note that such a $\lambda$ exists regardless of our choice of $G$: by the fundamental theorem of finite abelian groups, $G$ is isomorphic to a direct product of cyclic groups44 Of prime power order, but we don’t need that part. $\mathbb{Z}/q_1\mathbb{Z} \times \cdots \times \mathbb{Z}/q_m\mathbb{Z}$. Write $x \in \{0, \ldots, n-1\}$ in mixed-radix digits:

$$ x = x_m (q_1 q_2 \cdots q_{m-1}) + x_{m-1}(q_1 q_1 \cdots q_{m-2}) + \cdots + x_3 (q_1 q_2) + x_2 (q_1) + x_1. $$

We can then set $\lambda(x) = (x_1, \ldots, x_m)$, and we’ll have $\lambda(n-1-x) = (q_1-1, \ldots, q_m-1) - \lambda(x)$: because $(n-1)_j = q_j-1$, $(n-1-x)_j$ is just $(q_j-1 - x_j)$ (that is, there’s no carrying when you do the mixed-radix subtraction), so subtracting $x$ works the same whether you do it in the mixed-radix digits or in the group.

As an aside: there’s a slightly more general class of group-affine constructions which allow the addition of a group element $c$ to give $A(x) = c + \sum \varphi_i(\lambda(x_i))$. Some of the quasigroup literature would consider these to be linear. The distinction is irrelevant in this context, because adding $c$ is an automorphism of $G$ and thus a bijection, so it maintains FDLness. So you can take $c = 0$ without losing anything.

In the mod $n$ construction, we have:

We’ll now give a general proof, which you can use the $\mathbb{Z}/n\mathbb{Z}$ case as a concrete example for. Then we’ll give other constructions from this class as examples.

Fix a nontrivial diagonal $d : \{0, \ldots, n-1\} \to \{0, \ldots, n-1\}^k$ of the cube. This consists of signs $e_i \in \{0, +1, -1\}$ for $i \in \{0, \ldots, k-1\}$ determining whether that coordinate is constant or moves forwards or backwards, and constants $c_i \in \{0, \ldots, n-1\}$ fixing the starting point $d(0)_i$ of the diagonal, where $c_i = 0$ if $e_i = +1$ and $c_i = n-1$ if $e_i = -1$ (and otherwise can be anything). Then we have:

$$ d(t)_i = c_i + e_i t. $$

and the image of $d$ gives the cells contained in the diagonal.

We then have $d(t)_i = \lambda(t)$ if $e_i = +1$ and $d(t)_i = \lambda(n-1 - t) = u - \lambda(t)$ if $e_i = -1$.

Because each $\varphi_i$ is a homeomorphism, we have (defining $u_i = u$ if $e_i = -1$ and $0$ otherwise)

$$ \begin{align} A(d(t)) &= \sum_{i=0}^{k-1} \varphi_i(\lambda(d(t)_i)) \\ &= \sum_{i=0}^{k-1} \varphi_i (\lambda(c_i + e_i t))\\ &= \sum_{\{i: e_i = \pm 1\}} \varphi_i(u_i + e_i \lambda(t)) + \sum_{\{i: e_i = 0\}} \varphi_i(\lambda(c_i))\\ &= \sum_{\{i: e_i = \pm 1\}} e_i \varphi_i(\lambda(t)) + \sum_{\{i: e_i = \pm 1\}} \varphi_i(u_i) + \sum_{\{i: e_i = 0\}} \varphi_i(\lambda(c_i)). \end{align} $$

Note that the latter two terms in that sum add up to a constant that does not depend upon $t$, so it is fixed over the whole diagonal. Thus this particular diagonal $d$ is a bijection iff $t \mapsto \sum_i e_i \varphi_i(\lambda(t)) + (\text{const})$ is a bijection. Since adding a constant in an abelian group is an automorphism and $\lambda$ is a bijection, this is equivalent to $t \mapsto \sum_i e_i \varphi_i(\lambda(t))$ on its own being a bijection.

  1. (For all nonzero $e$, $\sum_i e_i \varphi_i$ is a bijection $\Rightarrow$ FDL)
    For any particular diagonal $d$, if $\sum_i e_i \varphi_i$ is a bijection, then $t \mapsto \sum_i e_i \varphi_i(\lambda(t))$ is also a bijection.

  2. (FDL $\Rightarrow$ for all nonzero $e$, $\sum_i e_i \varphi_i$ is a bijection)
    Suppose $\sum_i e_i \varphi_i$ is not a bijection for some $e \ne 0$. Take any diagonal $d$ with the sign vector $e$ (the choice of $c_i$ for the fixed coordinates where $e_i = 0$ doesn’t matter). This diagonal will fail to have $t \mapsto \sum_i e_i \varphi_i(\lambda(t))$ be a bijection, because the $\sum_i e_i \varphi_i$ part is not a bijection.

One of the main purposes of this construction is that it gives us cubes of order $2^k$ in any dimension:

Let $G = \mathrm{GF}(2^m) = \mathbb{F}_2[\alpha]/p(\alpha)$ for some irreducible polynomial $p$ and pick any $\lambda$ (such that $\lambda(n-1-x) = u - \lambda(x)$). Set $\varphi_i(x) = \alpha^i x$. So we have:

$$ A(x_0, ..., x_{n-1}) = \lambda(x_0) + \alpha \lambda(x_1) + \alpha^2 \lambda(x_2) + \cdots + \alpha^{n-1} \lambda(x_{n-1}). $$

This gives a $k$-cube of size $2^k$ for any $k$. For example, consider the $4 \times 4$:

$$ \begin{bmatrix} 0 & 1 & \alpha & \alpha + 1 \\ \alpha & \alpha +1 & 0 & 1 \\ \alpha + 1 & \alpha & 1 & 0 \\ 1 & 0 & \alpha + 1 & \alpha \end{bmatrix} $$

The $8 \times 8 \times 8$ from back in the day is isomorphic to $8 \times 8 \times 8$s of this form. This is also the construction from Taylor 1972.

You can also make a $25 \times 25 \times 25$ using a similar method over the field of order $25$. If we write $\mathrm{GF}(25) = \mathbb{F}_5[\alpha]/(\alpha^2 + \alpha + 2)$ and then take

$$ A(x, y, z) = x + 2y + \alpha z $$

then this gives a FDL $25 \times 25 \times 25$:

But I’m not really used to working in finite fields, so I don’t understand the full details of choosing coefficients beyond “powers of $\alpha$ work fine in $\mathrm{GF}(2^k)$”. There’s some fiddly details here.

We can do something more general than just multiplying by elements of the finite field: if we’re working in $G = \mathrm{GF}(p^n)$, then we can regard this as a vector space over $\mathbb{F}_p$ and take the $\varphi_i$ to be $n \times n$ matrices over $\mathbb{F}_p$. So you can, for example, make a $9 \times 9$ square just using matrices and $\mathbb{F}_3^2$ even though there’s no way to get $\mathbb{Z}/9\mathbb{Z}$ to work.

There’s more to say about when exactly this construction works, but it’s getting late and I should get off my laptop soon. Go check out the FDL $k$-cube library if you want.

  1. Or any $n$-element set.

  2. Note that if you swap every moving coordinate between running forwards / backwards, you end up with the same diagonal that you had originally. If this is a particular issue, you can normalize so that the first moving coordinate is in the +1 direction, but it’s really easier to just double count. You don’t really introduce any additional complexities if you phrase your definitions to require that both the top-left → down-right and the down-right → top-left diagonals include all n colors.

  3. Equivalently, prime.

  4. Of prime power order, but we don’t need that part.