# Applying Burnside's Lemma to translations

I want to know how to calculate the number of unique arrangements of $T$ different types of objects on an $M \times N$ grid, not counting "toroidal translations". That is, translations where the objects pushed of the edge of the grid reappear on the other side. For a specific example let's use $T = 2, M = 2, N = 3$ since it is simple but non-trivial and conveniently enough we can use Unicode braille characters to represent arrangements.

Here's some examples of "toroidal translations" applied to ⠝:

• Up: ⠮
• Down: ⠳
• Right (the same as Left): ⠫

When looking for techniques to solve this problems I came across Burnside's Lemma, primarily through this video but I'm having some trouble applying it to this case.

Here's what I've tried so far:

There are $2^6 = 64$ possible arrangements, so that's 64 fixed points for the "do nothing" translation. When $M=2$ a rightward translation will always be the same as a leftward one so we only need to consider one of those. In order for a rightward translation to not affect the arrangement the columns must match so there are $2^3 = 8$ fixed points (, ⠉,⠀⠒ ... ⠶, and ⠿). Regarding upward and downward translations, two upward translations are the same as one downward one and vice versa, so we only need to consider two different cases. In both of those cases, the rows must match so we have two sets of $2^2 = 4$ fixed points, (, ⠇,⠀⠸, and ⠿.) Applying the lemma we get $\frac{64 + 8 + 4 + 4}{4} = \frac{80}{4} = 20$.

But then I tried finding the orbits by checking manually to make sure I had done this correctly, and I was only able to find $14$ different ones!

Here are some representatives of each orbit I found, paired to show some symmetry:

• /⠿
• ⠁/⠾
• ⠃/⠼
• ⠉/⠶
• ⠊/⠵
• ⠋/⠴
• ⠇
• ⠕

So it seems like I must have either missed some fixed points or that set of orbits is incomplete. Can someone spot my mistake?

What we have here is the cyclic group of order $M$ acting on the rows and of order $N$ acting on the columns. We may apply Burnside if we succeed in computing the cycle index of this action, call it $Z(Q_{M, N}).$ Now the cycle index of the cyclic group of order $M$ is given by

$$Z(C_M) = \frac{1}{M} \sum_{d|M} \varphi(d) a_d^{M/d}.$$

We therefore require the factorization into cycles of a permutation with factorization $a_d^{M/d}$ and another with factorization $b_f^{N/f}$ acting simultaneously on the row-column pairs that identify the slots of the matrix, with the first one acting on the rows and the second one on the columns. The combination creates $d\times f$ row-column pairs of cycle length $\mathrm{lcm}(d,f)$, for a contribution of

$$c_{\mathrm{lcm}(d,f)}^{df/\mathrm{lcm}(d,f)} = c_{\mathrm{lcm}(d,f)}^{\gcd(d,f)}.$$

We thus have for the desired cycle index

$$Z(Q_{M,N}) = \frac{1}{MN} \sum_{d|M}\sum_{f|N} \varphi(d)\varphi(f) c_{\mathrm{lcm}(d,f)}^{\gcd(d,f) (M/d)(N/f)}.$$

This yields for the count of configurations involving at most $T$ types by Burnside (colors must be constant on the cycles, giving the substitution $c_q = T$)

$$\bbox[5px,border:2px solid #00A000]{ \frac{1}{MN} \sum_{d|M}\sum_{f|N} \varphi(d)\varphi(f) T^{\gcd(d,f) (M/d)(N/f)}.}$$

This formula was implemented in the following Maple code which also includes a routine to verify its correctness by total enumeration.

with(numtheory);

EX :=
proc(M,N,T)
1/M/N*
f in divisors(N)), d in divisors(M));
end;

ENUM :=
proc(M,N,T)
option remember;
local idx, d, all, orbit, orbits, rotM, rotN,
pos, row, col, perm;

if T = 1 then return 1 fi;

all := M*N;
orbits := table();

for idx from T^all to 2*T^all-1 do
d := convert(idx, base, T)[1..all];

orbit := [];

for rotM from 0 to M-1 do
for rotN from 0 to N-1 do
perm := [];
for pos from 0 to all-1 do
col := pos mod N;
row := (pos-col)/N;

perm :=
[op(perm),
(row+rotM mod M)*N+
(col+rotN mod N)];
od;

orbit :=
[op(orbit),
[seq(d[perm[q]+1], q=1..all)]];
od;
od;

orbits[sort(orbit)[1]] := 1;
od;

numelems(orbits);
end;


Here are the colorings using at most $T$ colors of the $3\times 2$ case starting with one color / object type:

$$1, 14, 130, 700, 2635, 7826, 19684, 43800, 88725, \\ 166870, 295526, 498004, \ldots$$

Sequel. It is easy to compute the number of colorings using exactly $T$ colors as opposed to at most $T$. We get the following formula from first principles using Stirling numbers of the second kind:

$$\bbox[5px,border:2px solid #00A000]{ \frac{T!}{MN} \sum_{d|M}\sum_{f|N} \varphi(d)\varphi(f) {\gcd(d,f) (M/d)(N/f) \brace T}.}$$

This yields the following finite sequence for the $3\times 2$ (with only six slots available we cannot represent more than six colors):

$$1, 12, 91, 260, 300, 120.$$

The last term in this sequence is a useful sanity check: with six different colors all orbits have the same size namely six (representing six permutations from the product $C_3\times C_2$) and we indeed obtain $6!/6 = 120.$ This was implemented in Maple as well.

with(numtheory);
with(combinat);

EX :=
proc(M,N,T)
T!/M/N*
f in divisors(N)), d in divisors(M));
end;

ENUM :=
proc(M,N,T)
option remember;
local idx, d, all, orbit, orbits, rotM, rotN,
pos, row, col, perm;

if T = 1 then return 1 fi;

all := M*N;
orbits := table();

for idx from T^all to 2*T^all-1 do
d := convert(idx, base, T)[1..all];

if nops(convert(d, set)) < T then
next;
fi;

orbit := [];

for rotM from 0 to M-1 do
for rotN from 0 to N-1 do
perm := [];
for pos from 0 to all-1 do
col := pos mod N;
row := (pos-col)/N;

perm :=
[op(perm),
(row+rotM mod M)*N+
(col+rotN mod N)];
od;

orbit :=
[op(orbit),
[seq(d[perm[q]+1], q=1..all)]];
od;
od;

orbits[sort(orbit)[1]] := 1;
od;

numelems(orbits);
end;



Addendum. There is another interpretation of the problem that merits additional investigation, which is to ask about the colorings of the torus using some exact number of colors where we do not only have translational symmetry of the shapes that appear but also the $T$ colors may be permuted in any one of $T!$ ways. What we have here is a case of Power Group Enumeration as defined by Harary and also by Fripertinger and the answer is simple to compute. We present the Maple code in order to document the algorithm. In PGE we have objects being distributed into slots and two permutation groups, one of them permuting the slots and the other one the objects and we seek the count of the orbits under this combined action. In the present case there are $M\times N$ slots being permuted by $C_M\times C_N$ and $T$ objects (colors) being permuted by the symmetric group $S_T.$ For a pair of permutations from these two groups we have that if we cover the cycles from the grid permutation with complete, consecutive and directed copies of cycles from the object permutation we have an assignment that is fixed under the combined action as required by Burnside. Moreover every cycle from the object permutation must be used at least once because we require all colors to be present. This means we need to partition the cycles of the grid permutation into non-empty sets, one for each cycle from the object permutation. Evidently this is possible only if the lengths of the latter cycles all divide the length of the cycles from the grid permutation, which is unique as seen in the closed form. The contribution from a set of size $Q$ is $\ell^Q$ where $\ell$ is the length of the corresponding cycle. The total contribution may be extracted from a basic EGF, the same as with Stirling numbers of the second kind as we saw earlier. We get the closed form

\bbox[5px,border:2px solid #00A000]{ \begin{align} \frac{1}{T!}\frac{1}{MN} \sum_{\sigma\in S_T} \sum_{d|M}\sum_{f|N} & \varphi(d)\varphi(f) [[\forall j_\ell(\sigma) \gt 0: \ell\mid\mathrm{lcm}(d,f)]] \\ & \times P(\gcd(d,f) (M/d)(N/f), \sigma) \end{align}}

where

$$\bbox[5px,border:2px solid #00A000]{ P(F,\sigma) = F! [z^F] \prod_{\ell=1}^T (\exp(\ell z)-1)^{j_\ell(\sigma)}.}$$

Now clearly when we implement this we do not iterate over all $T!$ permutations but use the cycle index instead, which may be computed from the standard recurrence by Lovasz. There is more on PGE at e.g. the following links (various authors) where the permutation covering technique is explained in detail: Enumeration of finite automata, Sets of sequences with letters being permuted, and Coloring a plane grid and swapping colors.

For example we obtain for an $M\times M$ torus with exactly two swappable colors

$$0, 4, 31, 2107, 671103, 954459519, 5744387279871,\ldots$$

and with three colors

$$0, 3, 345, 447156, 5647919665, 694881637942816, \\ 813943290958393433377,\ldots$$

This is the Maple code.

with(numtheory);
with(combinat);

pet_cycleind_symm :=
proc(n)
option remember;

if n=0 then return 1; fi;

end;

pet_flatten_termA :=
proc(varp)
local terml, d, cf, v;

terml := [];

cf := varp;
for v in indets(varp) do
d := degree(varp, v);
terml := [op(terml), [op(1,v), d]];
cf := cf/v^d;
od;

[cf, terml];
end;

EX :=
proc(M,N,T)
option remember;
local res, len_a, inst_a,
idx_cols, b, flat_b, cycs_b, lcm_b, gf,
d, f;

if M*N < T then return 0 fi;
if T = 1 then return 1 fi;

idx_cols := pet_cycleind_symm(T);

res := 0;

for b in idx_cols do
flat_b := pet_flatten_termA(b);
cycs_b := flat_b[2];

lcm_b := lcm(seq(op(1, v), v in cycs_b));

for d in divisors(M) do
for f in divisors(N) do
len_a := lcm(d, f);
inst_a := gcd(d, f)*M/d*N/f;

if len_a mod lcm_b = 0 and
inst_a >= degree(b)  then
gf :=
mul((exp(z*op(1, cycs_b[q]))-1)
^op(2, cycs_b[q]),
q=1..nops(cycs_b));

res := res +
1/M/N*phi(d)*phi(f)*flat_b[1] *
inst_a! *
coeftayl(gf, z=0, inst_a);
fi;
od;
od;
od;

res;
end;

ENUM :=
proc(M,N,T)
option remember;
local ind, d, all, orbit, orbitA, orbits, rotM, rotN,
pos, row, col, perm, conf, pconf;

if T = 1 then return 1 fi;

all := M*N;
orbits := table();

for ind from T^all to 2*T^all-1 do
d := convert(ind, base, T)[1..all];

if nops(convert(d, set)) < T then
next;
fi;

orbit := [];

for rotM from 0 to M-1 do
for rotN from 0 to N-1 do
perm := [];
for pos from 0 to all-1 do
col := pos mod N;
row := (pos-col)/N;

perm :=
[op(perm),
(row+rotM mod M)*N+
(col+rotN mod N)];
od;

orbit :=
[op(orbit),
[seq(d[perm[q]+1], q=1..all)]];
od;
od;

orbitA := Array(1..M*N*T!); pos := 1;

perm := firstperm(T);
while type(perm, list) do
for conf in orbit do
pconf :=
subs([seq(q-1=perm[q]-1, q=1..T)], conf);

orbitA[pos] := pconf;
pos := pos + 1;
od;

perm := nextperm(perm);
od;

orbits[sort(orbitA)[1]] := 1;
od;

numelems(orbits);
end;

• An explicit formula for the solution is very helpful, thank you. This answer also helped me figure out which fixed points I had missed: I had not considered the combinations of both a vertical and horizontal translation. Both of the "all-the-same type" arrangements (⠀and ⠿ ) are the only fixed points of both cases of combining a horizontal translation with either of the two possible vertical translations. Adding those two orbits with two fixed points each into Burnside's formula gives the expected answer of 14. – Ryan1729 Nov 6 '17 at 0:37