Large permutation groups
The Rubik's cube group has 43,252,003,274,489,856,000 elements, far too many to list. Yet six permutations of 48 stickers generate it, and from those six alone one can find its exact order, decide whether a scrambled position can be solved, and write the solution as a word in the face turns. The tool is a base and strong generating set, found by the Schreier–Sims algorithm.
A chain of stabilisers
Let act on the points . Pick points (a base) so that only the identity fixes all of them, and let be the subgroup fixing :
By the orbit–stabiliser theorem the index of each step is the size of an orbit, , so
For the cube the eighteen orbit sizes multiply to the famous number. Each orbit is stored with, for every point in it, one permutation in carrying there (a transversal). The whole group of elements is described by a few hundred permutations.
Sifting
To test whether a permutation is in : look at where sends . If that point is not in the first orbit, . Otherwise multiply by the inverse of the stored permutation that does the same; now fixes , and the question repeats one level down. If falls through every level and what remains is the identity, then is in , and that product is the only way to write it with one transversal element from each level. Membership costs at most multiplications, whatever the order of the group.
Finding the chain
Schreier's lemma says the stabiliser of a point is generated by the elements , with running over the orbit and over the generators. Sims's observation was that almost all of these are redundant: sift each one through the chain built so far and keep it only if something is left over, as a new generator at the level where it stuck. The version here is the deterministic one, so the chain is proved complete, not just probably complete. Each kept generator also remembers how it was made, which is what lets word return an expression in the original generators.
import { schreierSims, largeGroups } from "@ratmath/structures";
const G = largeGroups.rubik(); // generators U, D, L, R, F, B on 48 stickers
G.order; // 43252003274489856000n
G.base.length; // 18
G.orbitLengths; // [24, 21, 18, 15, 24, 12, 9, 22, 20, 18, 16, 6, 14, 12, 10, 8, 6, 2]
const g = G.random({ seed: 3 }); // a scrambled cube
G.contains(g); // true
const w = G.word(g); // { text: "U L³ U D⁻¹ …", length, word, check: true }
// one corner twisted in place: fixes every point not on that corner
G.orbits().map((o) => o.length); // [24, 24]: corner stickers and edge stickers never mix
Permutations are arrays of images counting from 0, as elsewhere in the library, while bases, orbits and blocks are reported counting from 1. Words from sifting are correct but long, tens of thousands of turns for the cube; finding short ones is a different and much harder problem.
What else the chain gives
With a membership test, a good deal of group theory becomes computable for groups of any size. The normal closure of a set is found by conjugating by generators until nothing new appears; the commutator subgroup is the normal closure of the commutators of the generators, and iterating gives the derived series and a test for solvability. A transitive group is primitive if it preserves no partition of the points into blocks other than the two trivial ones; the smallest block containing two given points is found by Atkinson's method of merging classes.
const M = largeGroups.mathieu(24);
M.order; // 244823040n
M.isPrimitive; // true
M.isPerfect; // true: M24 is simple
M.stabilizer(1).order; // 10200960n, the order of M23
const D = schreierSims([[1, 2, 3, 4, 5, 0], [5, 4, 3, 2, 1, 0]]); // symmetries of a hexagon
D.blockSystems(); // [[[1,3,5],[2,4,6]], [[1,4],[2,5],[3,6]]]: two triangles, three diagonals
D.derivedSeries().map((H) => H.order); // [12n, 3n, 1n], so it is solvable
G.derivedSubgroup().order; // 21626001637244928000n: index 2 in the cube group
A group small enough to list can be handed to the rest of the library with toGroup(), which gives the same kind of object as symmetric(4) with classes, subgroups and Sylow theory.
@ratmath/structures and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.