Actions and counting
A group acts on a set when each of its elements moves the points around, compatibly with the product. Watching where points can go answers counting questions: how many different necklaces, how many ways to paint a cube.
Actions, orbits and stabilisers
An action of on a set assigns to each and a point , with and . The orbit of is everywhere it can be moved, ; the orbits split into disjoint pieces. The stabiliser is a subgroup, and the points of the orbit match the cosets of the stabiliser, so
Every named group comes with its natural action as G.natural: and on the vertices of the polygon, on , matrix groups on the vectors of . action(G, points, act) makes any other. Each group element becomes a permutation of the points, built from the generators and checked against act, so a rule that is not an action is refused instead of giving wrong counts.
import { dihedral, GL, symmetric, action, conjugationAction, cosetAction, cyclic } from "@ratmath/structures";
const D = dihedral(6);
D.natural.orbit(0); // [0, 1, 2, 5, 3, 4]: all six vertices of the hexagon
D.natural.stabiliser(0).order; // 2: the identity and one reflection; 6 · 2 = 12
D.natural.fixedPoints("s"); // [0, 3]
GL(2, 3).natural.orbits().map((o) => o.length); // [1, 8]: zero, and all other vectors
conjugationAction(symmetric(4)).orbits().length; // 5: the conjugacy classes
action(cyclic(4), [0, 1, 2], (g, x) => (x + 1) % 3); // throws: not an action
Two standard actions turn group theory into this language. acting on itself by left multiplication is free and transitive, and it embeds in the symmetric group on points (Cayley's theorem). acting on the cosets of a subgroup by has as kernel the largest normal subgroup inside . Conjugation acting on elements has the conjugacy classes as orbits, and the class equation is orbit–stabiliser for it.
The orbit-counting lemma
Counting orbits directly needs the orbits. The lemma usually credited to Burnside (and known to Cauchy and Frobenius) counts them from fixed points:
To see it, count the pairs with both ways: by it is the sum on the right; by it is , and each orbit contributes exactly . Since is the same for conjugate elements, the sum can be taken class by class. countOrbits() does that, and also counts the orbits directly as a check.
Necklaces and cubes
A colouring gives each point one of colours; the group acts on colourings by moving the points, and two colourings are the same up to symmetry when they are in one orbit. A.onColourings(k) is that action. For beads on a ring of 6 turned by , the rotation by steps fixes a colouring exactly when the colouring repeats with period , which gives necklaces in two colours; allowing the necklace to be turned over () gives 13 bracelets.
import { cyclic, dihedral, permutationGroup, burnside } from "@ratmath/structures";
const necklaces = cyclic(6).natural.onColourings(2);
String(necklaces.countOrbits()); // "(1/6)·(64 + 8 + 4 + 4 + 2 + 2) = 14"
dihedral(6).natural.onColourings(2).countOrbits().count; // 13
// the 24 rotations of a cube, acting on its 6 faces
const cube = permutationGroup([[0, 2, 3, 4, 1, 5], [1, 5, 2, 0, 4, 3]], 6);
cube.order; // 24
String(burnside(cube.natural.onColourings(3))); // "(1/24)·(729 + 3·81 + 6·27 + 8·9 + 6·27) = 57"
cube.natural.onSubsets(3).orbits().length; // 2: three faces round a corner, or a band
Listing colourings stops being practical around a million of them. For larger counts, and for the full pattern inventory (how many orbits use each colour how often), use Pólya's cycle index in @ratmath/discrete: countColourings(A.toPermGroup(), k) and patternInventory(A.toPermGroup(), colours) take the image of any action from here.
@ratmath/structures and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.