Lesson 3 of 15

Subgroups

Subgroups

A subgroup HH of a group (G,∗)(G, *) is a subset H⊆GH \subseteq G that is itself a group under the same operation.

Subgroup Test

A non-empty subset HH of GG is a subgroup if and only if for all a,b∈Ha, b \in H: a∗b−1∈Ha * b^{-1} \in H

This single condition captures closure, identity, and inverses simultaneously.

Example: Subgroups of Z6\mathbb{Z}_6

The group Z6={0,1,2,3,4,5}\mathbb{Z}_6 = \{0,1,2,3,4,5\} under addition mod 6 has these subgroups:

  • {0}\{0\} — trivial subgroup
  • {0,3}\{0, 3\} — order 2
  • {0,2,4}\{0, 2, 4\} — order 3
  • {0,1,2,3,4,5}\{0, 1, 2, 3, 4, 5\} — the whole group

Notice that the subgroup orders (1, 2, 3, 6) all divide ∣G∣=6|G| = 6. This is Lagrange's theorem, which we will prove later.

Finding Subgroups Computationally

For Zn\mathbb{Z}_n under addition, a subset HH is a subgroup if:

  1. 0∈H0 \in H (identity)
  2. For each a∈Ha \in H, (n−a)%n∈H(n - a) \% n \in H (inverses)
  3. For each a,b∈Ha, b \in H, (a+b)%n∈H(a + b) \% n \in H (closure)

Generated Subgroups

The subgroup generated by an element aa, written ⟨a⟩\langle a \rangle, is the smallest subgroup containing aa:

⟨a⟩={e,a,a2,a3,…}\langle a \rangle = \{e, a, a^2, a^3, \ldots\}

In Zn\mathbb{Z}_n, ⟨a⟩={0,a,2a,3a,…}(modn)\langle a \rangle = \{0, a, 2a, 3a, \ldots\} \pmod{n}.

Your Task

Implement generated_subgroup(a, n) that returns the sorted list of elements in ⟨a⟩\langle a \rangle within Zn\mathbb{Z}_n, and find_all_subgroups(n) that returns all subgroups of Zn\mathbb{Z}_n (each as a sorted list), sorted by size then lexicographically.

Pyodide loading...
Loading...
Click "Run" to execute your code.