Counting objects up to symmetry — necklaces, colourings, board positions that are equivalent under rotation or reflection.
Burnside’s lemma
where is the set of objects fixed by the symmetry .
The number of distinct objects equals the average number of objects fixed by each symmetry.
Counting fixed points is usually easy; counting orbits directly is not. That asymmetry is the whole value of the lemma.
The canonical example: necklaces
Count necklaces of beads in colours, up to rotation. The group is the rotations. A rotation by fixes a colouring iff the colouring is constant on each cycle of that rotation — and rotation by has cycles. So:
long long necklaces(long long n, long long k, long long MOD) {
long long total = 0;
for (long long d = 1; d * d <= n; d++) {
if (n % d) continue;
total = (total + phi(n / d) % MOD * powmod(k, d, MOD)) % MOD;
if (d != n / d) total = (total + phi(d) % MOD * powmod(k, n / d, MOD)) % MOD;
}
return total % MOD * modinv(n % MOD, MOD) % MOD;
}— and it handles up to .
With reflections — the dihedral group
Add the reflections ():
- odd: every reflection has cycles, contributing .
- even: reflections through opposite vertices give each, and through edge midpoints give each.
The recipe
- Identify the group of symmetries (rotations, reflections, permutations of coordinates…).
- For each , decompose its action on the positions into cycles.
- A colouring is fixed by iff it is constant on every cycle, so where is the cycle count.
- Average over .
When is small (a square’s 8 symmetries, a cube’s 24), just enumerate the group elements and count cycles directly.
Pólya enumeration theorem
The refinement that tracks how many of each colour. Define the cycle index
where is the number of -cycles of . Then substituting gives a generating function whose coefficient of counts colourings using exactly of colour .
Burnside is Pólya with all .
Example. Necklaces with exactly black and white beads, up to rotation:
Common groups and their cycle counts
| Object | Group | Order | Cycle structure |
|---|---|---|---|
| Necklace, rotations | rotation by : cycles | ||
| Bracelet, + reflections | as above | ||
| Square grid, rotations | 4 | positions in 4-cycles (centre fixed) | |
| Square grid, + reflections | 8 | ||
| Cube faces | rotations | 24 | 6 faces under 24 rotations |
| Cube vertices | rotations | 24 | |
| Unordered pairs / graphs | acting on edges | hard; needs Pólya |
Counting non-isomorphic graphs on vertices is Pólya applied to acting on the edges — feasible for or so by enumerating conjugacy classes (integer partitions of ).
Practical notes
- The division by needs a modular inverse — make sure (true for unless is a multiple of it).
- Sum over divisors rather than all group elements whenever the group is cyclic — that turns into .
- For small explicit groups, brute-force the cycle counts; it is less error-prone than deriving formulas.
See also: Combinatorics · Euler Totient · Special Numbers