Groups

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 GG on a set XX assigns to each gg and xx a point g⋅xg\cdot x, with e⋅x=xe \cdot x = x and g⋅(h⋅x)=(gh)⋅xg\cdot(h\cdot x) = (gh)\cdot x. The orbit of xx is everywhere it can be moved, G⋅xG\cdot x; the orbits split XX into disjoint pieces. The stabiliser Stab⁡(x)={g:g⋅x=x}\operatorname{Stab}(x) = \{g : g\cdot x = x\} is a subgroup, and the points of the orbit match the cosets of the stabiliser, so

∣G⋅x∣⋅∣Stab⁡(x)∣=∣G∣(orbit–stabiliser). |G \cdot x| \cdot |\operatorname{Stab}(x)| = |G| \qquad \text{(orbit–stabiliser).}

Every named group comes with its natural action as G.natural: DnD_n and CnC_n on the vertices 0,…,n−10, \dots, n-1 of the polygon, SnS_n on 1,…,n1, \dots, n, matrix groups on the vectors of Fpn\mathbb F_p^n. 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. GG acting on itself by left multiplication is free and transitive, and it embeds GG in the symmetric group on ∣G∣|G| points (Cayley's theorem). GG acting on the cosets of a subgroup HH by g⋅xH=gxHg \cdot xH = gxH has as kernel the largest normal subgroup inside HH. 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:

#orbits=1∣G∣∑g∈G∣Fix⁡(g)∣,Fix⁡(g)={x:g⋅x=x}. \#\text{orbits} = \frac{1}{|G|} \sum_{g \in G} |\operatorname{Fix}(g)|, \qquad \operatorname{Fix}(g) = \{x : g\cdot x = x\}.

To see it, count the pairs (g,x)(g, x) with g⋅x=xg \cdot x = x both ways: by gg it is the sum on the right; by xx it is ∑x∣Stab⁡(x)∣=∑x∣G∣/∣G⋅x∣\sum_x |\operatorname{Stab}(x)| = \sum_x |G|/|G\cdot x|, and each orbit contributes exactly ∣G∣|G|. Since ∣Fix⁡(g)∣|\operatorname{Fix}(g)| 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 kk 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 C6C_6, the rotation by jj steps fixes a colouring exactly when the colouring repeats with period gcd⁡(j,6)\gcd(j, 6), which gives 16(26+21+22+23+22+21)=14\tfrac16(2^6 + 2^1 + 2^2 + 2^3 + 2^2 + 2^1) = 14 necklaces in two colours; allowing the necklace to be turned over (D6D_6) 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.

Try itEdit the code and run it with @ratmath/structures and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs