Note
Go to the end to download the full example code.
Lagrange’s theorem: subgroup order divides group order#
Enumerates every subgroup of Z_12 and confirms each subgroup’s order divides 12, and that its left cosets partition the whole group.
from mathematicskit.abstract_algebra import CyclicGroup, all_subgroups, cyclic_subgroup, left_cosets
Every subgroup of Z_12#
g = CyclicGroup(12)
for subgroup in sorted(all_subgroups(g), key=len):
print(f"subgroup of order {len(subgroup)}: {sorted(subgroup)} (divides 12: {12 % len(subgroup) == 0})")
subgroup of order 1: [0] (divides 12: True)
subgroup of order 2: [0, 6] (divides 12: True)
subgroup of order 3: [0, 4, 8] (divides 12: True)
subgroup of order 4: [0, 3, 6, 9] (divides 12: True)
subgroup of order 6: [0, 2, 4, 6, 8, 10] (divides 12: True)
subgroup of order 12: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] (divides 12: True)
Cosets of the order-3 subgroup {0, 4, 8}#
subgroup H = [0, 4, 8]
cosets of H: [[0, 4, 8], [1, 5, 9], [2, 6, 10], [3, 7, 11]]
index [G:H] = 4 = |G|/|H| = 12/3 = 4
Total running time of the script: (0 minutes 0.001 seconds)