Abelian groups
Every finitely generated abelian group is a product of cyclic groups, in exactly one standard way. Finding that product from generators and relations is integer linear algebra: the Smith normal form.
The structure theorem
A finitely generated abelian group is isomorphic to
and the invariant factors and the rank are determined by the group. Splitting each into prime powers gives the other standard form, by elementary divisors: by the Chinese remainder theorem. So the abelian groups of order correspond to choosing a partition of each , and there are of them: six of order .
import { abelianGroup, cyclicProduct, abelianGroups } from "@ratmath/structures";
String(cyclicProduct([4, 6])); // "Z/2 × Z/12"
cyclicProduct([4, 6]).toString({ primary: true }); // "Z/2 × Z/4 × Z/3"
cyclicProduct([3, 5]).isCyclic; // true: Z/3 × Z/5 ≅ Z/15
abelianGroups(72).map(String);
// ["Z/72", "Z/3 × Z/24", "Z/2 × Z/36", "Z/6 × Z/12", "Z/2 × Z/2 × Z/18", "Z/2 × Z/6 × Z/6"]
abelianGroup([2, 4]).order; // 8n
From generators and relations
Write the group additively, with generators and relations . It is , where is spanned by the rows of the relation matrix . Row operations on (with integer multipliers, and swaps) change the relations but not ; column operations change the generators. The Smith normal form uses both to reach
with , integer matrices of determinant . The new generators then satisfy just : the structure theorem, computed. The algorithm brings the smallest entry to the corner, divides it into its row and column, and if it fails to divide some other entry, adds that row in and goes again; the corner entry gets smaller each time, so it stops.
import { fromRelations, smithForm } from "@ratmath/structures";
// three generators, three relations
const R = [[2, 4, 4], [-6, 6, 12], [10, -4, -16]];
smithForm(R).diagonal; // [2n, 6n, 12n]
const G = fromRelations(R);
String(G); // "Z/2 × Z/6 × Z/12"
G.order; // 144n
G.generators.map((g) => `${g.order}: ${g.vector}`); // ["2: 1,2,2", "6: 0,3,4", "12: 0,1,1"]
String(fromRelations([[2, 0, 0]], 3)); // "Z/2 × Z^2": no relation on two of the generators
The last line reads: the element has order 2, has order 6, has order 12, and together they generate the group as a direct product. The tests check the Smith forms against @ratmath/linalg's own, and that each listed generator has exactly the stated order.
Abelianising a group
For any group, is abelian, the largest abelian quotient. Given a presentation, it is the abelian group with the same generators and the relators read additively (count how many times each generator appears, with signs). So abelianInvariants works for infinite groups too, and for a finite group (through a presentation of it) it agrees with G.quotient(G.derivedSubgroup()).
import { abelianInvariants, presentation, GL, symmetric } from "@ratmath/structures";
String(abelianInvariants(GL(2, 3))); // "Z/2"
String(abelianInvariants(presentation("a, b | a^2, b^3, (ab)^3"))); // "Z/3"
String(abelianInvariants(presentation("a, b | [a, b]"))); // "Z^2"
@ratmath/structures and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.