please enable javascript

Lagrange's Theorem

Alexander Comerford
July 16th, 2023 · 5 min read

What is Lagrange's Theorem?

Over the past year I've gone down a deep dive of cryptography of which group theory is a pivotal dependency. One theorem I've seem that are leaned on heavily when using popular cryptographic objects like finite fields is Lagrange's Theorem.

Simply put Lagrange's theorem states:

If HH is a subgroup of a finite group GG. Then the order of HH divides the order of GG.

Or in terse mathematical notation:

HGord(H)  ord(G)H \leq G \rightarrow {\rm ord}\left(H\right) \space | \space {\rm ord}\left(G\right)

This a pretty elegant finding! Thanks Lagrange!

To understand why this is true we'll go through four checkpoints.

  1. What is a coset?
  2. When are cosets the same?
  3. Why cosets are equal xor disjoint?
  4. Why cosets split the group?

What is a coset?

While the word "coset" seems like a fancy unrelated term, but in reality it's a very simple concept that will be core in proving Lagrange's Theorem.

If HH is a subgroup of GG, then a coset is the set of elements where gg is applied on HH where gg is an element of GG.

In other words, the cosets of a subgroup HH can be thought of as applying the group operation as a mapping function on the elements of HH with the elements of GG

For a more terse math notation, cosets can be described like this:

Hg={ghhH}H g = \{ g h \| h \in H \}

Note: There is a notion of "left" and "right" cosets, but for this post we'll be assuming GG is abelian.

Let's make this a little more concrete with an example. Lets consider the cosets of the group Z/24Z\Z/24\Z with the subgroup generated by 44 via group addition.

CosetCoset ElementsCoset Size
0 + H[0, 4, 8, 12, 16, 20]6
1 + H[1, 5, 9, 13, 17, 21]6
2 + H[2, 6, 10, 14, 18, 22]6
3 + H[3, 7, 11, 15, 19, 23]6
4 + H[0, 4, 8, 12, 16, 20]6

Here are some things worth noticing about this table:

  1. 0+H0 + H and 4+H4 + H are the same! I left this in intentionally to point out the fact that if we keep incrementing our added term to the 0+H0 + H coset, we eventually wrap around with what we started with! Is this a coincidence or is this always the case?
  2. The size of all the cosets are the same. This makes sense because when we have a subgroup and we add a number to it, it can be thought of as a "translation" of all the elements, hence the sizes will all the same as 0+H0 + H. But how do we know the elements of a coset of any subgroup have no shared elements? If this were the case this could result in different coset sizes!
  3. All the elements of the cosets contain all the elements of the group! Does this mean that all the cosets split the group?

It's not that obvious now, but proving that these observations are always true will give us all the information needed to prove Lagranges Theorem!

When are cosets the same?

In our first observation we saw the same coset twice, this begs the question when are any two cosets equal? We will show that if two cosets have a single element in common, then all their elements will be in common, making them the same. In terse math notation we can write this assumption as:

aHbHa=Hba \in H b \rightarrow H a = H b

One of the most effective ways to show that two cosets are equal is by showing that if each coset shares an element, then it's a subset of the other. Let's break it down.

The first thing we can observe is that if aHba \in H b, then there must exist an element h1h_1 such that:

a=bh1a = b h_{1}

This means we can take our first coset HaH a, select a random element xx from it, and rewrite it as x=ah2x = a h_{2}. By doing this and rewriting in terms aa like so:

x=ah2x=bh1h2bh1h2Hb\begin{alignedat}{2} x = a h_{2} \\ x = b h_{1} h_{2} \\ \therefore b h_{1} h_{2} \in H b \end{alignedat}

By doing this reduction, we know that any random element of HaH a is an element of HbH b. Now we need to show the inverse is true and that any random element of HbH b is an element of HaH a.

We can do this by leveraging the property of inverses of groups to rewrite a=bh1a = b h_{1} into ah11=ba h_1^{-1} = b. With this we can show that for some yHby \in H b the follow reduction can be done:

yHby=bh3y=ah3h1ah3h1Ha\begin{alignedat}{2} y \in H b \\ y = b h_{3} \\ y = a h_{3} {h^{-1}} \\ \therefore a h_{3} {h^{-1}} \in H a \end{alignedat}

This implies that if we select any element from either coset, it must belong to the other, implying that all the elements of one coset must be in the other, or in other words, they are the same!

Why cosets are equal xor disjoint?

We showed when cosets are equal, but in order to show our second observation is always the case, we need to show that if two cosets don't share an element, then they are disjoint (no shared elements). Luckily we can build on our previous coset equality result to show this.

To show that cosets are disjoint we will assume that the intersection of HaH a and HbH b is empty, but if there is a shared element, they are equal. With this assumption we can do the following:

xHbHax=ah1x=bh2a=h11xa=bh2h11aHb\begin{alignedat}{2} x \in H b \cap H a \\ x = a h_{1} \\ x = b h_{2} \\ a = {h_{1}^{-1}} x \\ a = b h_{2} {h_{1}^{-1}} \\ \therefore a \in H b \end{alignedat}

Here we show that if we pull an element from the intersection of two cosets, the coset generated by aa must be in HbH b. But this should look familiar because we just proved above that if aHba \in H b, then both cosets must be equal! This implies that if there are shared elements between both cosets, they must be equal which also implies if they don't have common element(s), they have nothing in common.

Why do cosets split the group?

Our last observation to prove is that all cosets of a group split the group. To show this is true, we just need to ensure that every element gGg \in G belongs to some coset HgH g. Luckily this is simple to show:

eHegHggHg\begin{alignedat}{2} e \in H \\ e g \in H g \\ g \in H g \end{alignedat}

Since HH is a subgroup, it must have an identity element. Then we can create the coset HgH g of which ege g must be an element. And since applying the group operation with the identity element returns the applied element, we know that gg will always belong the coset it generates, meaning every element in GG belongs to a coset.

Lagrange's Theorem

Now that we have all the component information for Lagrange's Theorem, we can move forward in proving it. We showed in the beginning that the theorem can be stated as:

HGord(H)  ord(G)H \leq G \rightarrow {\rm ord}\left(H\right) \space | \space {\rm ord}\left(G\right)

To reach this conclusion we will start with our previous result that all the cosets split the group, meaning by "unioning" all the cosets we reconstruct the original group:

G=Ha1...Han\begin{alignedat}{2} G = H a_{1} \cup ... \cup H a_{n} \end{alignedat}

Keep in mind there will be some integer nn number of cosets. If we transition to thinking about orders, then the total order of the group will be the sum of the number of elements of the cosets:

G=Ha1+...+Han\begin{alignedat}{2} {\left| G \right|} = {\left| H a_{1} \right|} + ... + {\left| H a_{n} \right|} \end{alignedat}

But since we know that all cosets of the subgroup are the same size as the subgroup, we can rewrite this as:

G=nH\begin{alignedat}{2} {\left| G \right|} = n {\left| H \right|} \end{alignedat}

And we're done! This shows that the order of a group GG is a multiple of the order of a subgroup HH which is functionally the same as saying the order of the subgroup divides the order of the group!

This incredible result attributed to Lagrange means that just by knowing the order of a group allows us to infer information about the order of subgroups (and vice versa). But one of the most important details to keep in mind about this proof is that just because the order of a subgroup must divide the order of the group, it doesn't guarantee a subgroup of a dividing order exists. In essence this is a "one way" proof stating that any subgroups that exist will divide the order of the group.

Downstream implications

This theorem has large implications for the rest of group theory. For example if we consider groups that are of prime order pp ... well by definition nothing divides it except itself and one, so the only subgroups that can exist are the identity element and the group itself! This type of group has a special name, a "cyclic" group because any non identity element of the group can generate the rest of the group.

There are also many practical applications of Lagrange's Theorem. For example in the ZKHACK 2021 hackathon in the second puzzle, participants need to leverage Lagrange's Theorem to break the discrete log of an unsafe group with small prime cofactors.

Thanks for reading! Stay tuned for breakdowns of more group theory theorems like the primitive root theorem, and maybe more regarding implementing ECC pairings 😮!

More posts from The Art of Abstraction

Shape typing numpy with pyright and variadic generics

MxN * NxM

February 27th, 2023 · 7 min read

Setting up ipad screen mirroring on nixos

Screens on screens

December 27th, 2022 · 2 min read