Path: blob/main/foundations/01-modular-arithmetic-groups/sage/01e-subgroups-lagrange.ipynb
483 views
Subgroups and Lagrange's Theorem
Module 01e | Modular Arithmetic and Groups
Some elements can't reach the whole group, but the little group they DO reach is surprisingly constrained.
Where we left off. In 01d we discovered that in only generates , three elements out of six. Meanwhile reaches all six. But here's a question we didn't answer: is itself a group? And could it have been size 5 instead of size 3? What sizes are even possible?
Objectives
By the end of this notebook you will be able to:
Recognize a subgroup by checking the group axioms on a subset.
State Lagrange's theorem: a subgroup's size must divide the group's size.
Explain why it works using cosets (shifted copies of the subgroup).
Apply Lagrange's theorem to predict which element orders are possible.
This smaller group living inside the bigger one has a name: it's a subgroup.
Definition. A subset is a subgroup of (written ) if is itself a group under the same operation.
Two subgroups always exist for free:
The trivial subgroup (just the identity), here .
The whole group (every group is a subgroup of itself).
The interesting subgroups are the ones in between.
What Sizes Are Possible?
has 6 elements. The subgroup has 3 elements. Could we find a subgroup of size 4? Or size 5?
Let's generate the subgroup for every element and see what sizes appear.
Subgroup sizes 1, 2, 3, 6. Group size 6. Every subgroup size divides 6.
Is this a coincidence? Let's try a bigger group to find out.
More Evidence: Additive Groups
has 12 elements, so 12 has many divisors: 1, 2, 3, 4, 6, 12. This gives us more room to spot the pattern.
In an additive group, the subgroup generated by is , keep adding until you cycle back to 0.
Checkpoint. Before reading on, try to predict: in , what subgroup sizes are possible? (Hint: divisors of 15 are 1, 3, 5, 15.)
Lagrange's Theorem
This pattern has been proven true for ALL finite groups, not just our examples.
Lagrange's Theorem. If is a subgroup of a finite group , then divides .
That's it. Subgroup sizes must divide the group size. No exceptions, ever.
This is arguably the most important theorem in elementary group theory. But why is it true? The answer involves a beautiful idea: cosets.
Why It Works: Cosets
Here's the key idea. Take a subgroup and "slide" it around the group. Each slide produces a coset.
Concretely, in with :
Slide by 0:
Slide by 1:
Slide by 2:
Slide by 3:
Slide by 4? That gives , the same as the first coset. We've already covered everything.
Think of it like dealing cards into piles. Each pile (coset) has the same number of cards as . The piles never overlap. Together they use up every card in the deck.
The argument works for ANY subgroup of ANY finite group:
Every coset has the same size as (sliding doesn't change the count).
Cosets never overlap (if two cosets share an element, they're identical).
Cosets cover everything (every element lives in the coset ).
So the group is partitioned into equal-sized pieces: . Since both sides are integers, must divide . Done.
The number of cosets is called the index of in , written .
Why cosets never partially overlap
The non-overlap property is the heart of the proof. Let's see it concretely. Elements 1 and 5 both live in the coset . Elements 1 and 2 live in different cosets. Watch what happens when we compute cosets starting from each element.
Seeing Cosets
Let's color the elements of by which coset they belong to. This makes the partition visible.
The pattern is striking: the cosets are evenly spaced around the circle. Each coset is a "rotated copy" of .
Checkpoint. What happens if we use instead? How many cosets would there be, and what size? (Answer: cosets of size 4.)
Cosets in multiplicative groups
Everything we just did with addition works identically with multiplication. Back to our opening example: is a subgroup of . The cosets are .
Consequences for Element Orders
Here is the key chain of reasoning. Pick any element in a group :
The subgroup generated by repeating the group operation ( for multiplication, or for addition) is always a subgroup.
By Lagrange, must divide .
But (the subgroup size equals the cycle length).
So divides .
Corollary. The order of every element must divide the size of the group.
Let's trace this chain for element 8 in . Here , keep adding 8 until we return to 0.
We traced the chain for one element. Now let's verify the constraint holds for every element in . The group has 12 elements, so Lagrange says the only possible orders are the divisors of 12: . No element can have order 5, 7, 8, 9, 10, or 11.
Back to Multiplication: A Surprise
Let's apply Lagrange to . This group has elements, so Lagrange says element orders can only be divisors of 8: that's 1, 2, 4, or 8.
Let's check.
This is an important subtlety:
Common mistake. "Lagrange says every divisor of appears as a subgroup size." No! Lagrange only goes one direction: subgroup sizes must be divisors. It does NOT promise that every divisor appears. For cyclic groups (like ) every divisor does give a subgroup, but for non-cyclic groups some divisors can be missing.
Why This Matters for Cryptography
Lagrange's theorem explains why cryptographers care about safe primes.
If is prime, has order . The subgroup sizes are the divisors of . If has lots of small factors, there are lots of small subgroups, and an attacker can exploit them.
The Pohlig-Hellman idea
Suppose you need to solve in a group of order . If has a small factor , here is the trick:
Raise both sides to the power : compute and .
Both and now live in a subgroup of size (Lagrange guarantees this, since ).
Solve the DLP in this tiny subgroup by brute force: find with .
This gives you , one piece of the secret.
Repeat for each small factor of , then combine with the Chinese Remainder Theorem (Module 04). If has many small factors, you solve several tiny DLPs instead of one massive one.
A safe prime (where is also prime) blocks this: has no small factors beyond 2, so there are no useful small subgroups to exploit.
Exercises
Exercise 1 (Worked)
Find all subgroups of . For each, list its elements and verify its size divides 6.
Exercise 2 (Guided)
Compute the cosets of in . How many cosets are there? Verify they partition .
Exercise 3 (Independent)
In , the group has order 30.
List all possible subgroup sizes (= divisors of 30).
For each divisor , find an element whose order is .
Is there a divisor with no corresponding element? Is cyclic?
Summary
| Concept | Key idea |
|---|---|
| Subgroup | A subset that is itself a group under the same operation |
| Cosets | Shifted copies that tile into equal-sized, non-overlapping pieces |
| Lagrange's theorem | divides , because the coset tiling forces |
| Index | , the number of cosets |
| Order constraint | is a subgroup of size , so Lagrange forces |
| Pohlig-Hellman | Small subgroups leak partial DLP solutions; project via , brute-force in the small subgroup, recover |
| Safe primes | leaves only subgroups of size , blocking Pohlig-Hellman |
The punchline: Lagrange says group structure is not free-form. Subgroup sizes, element orders, and coset counts are all locked together by divisibility. Cryptographers exploit this rigidity: choosing a safe prime controls exactly which subgroups exist, shutting down the Pohlig-Hellman attack.
Next: Visualizing Group Structure, where we'll draw Cayley graphs, subgroup lattices, and multiplication heatmaps to see everything we've computed.