The previous entry ended with a bit of a cliffhanger. We explained the math of the Euclidean Algorithm and then followed that up with a Python implementation for the integers. However, we didn’t prove that the algorithm actually returns a greatest common divisor. We’ll do that right now.
Theorem: Correctness of The Euclidean Algorithm
Proof
We’ll be referencing the Euclidean Algorithm as implemented in the previous entry. Follow the above link for definitions of the variables we’ll be using.
We noted in the previous entry that
which, when combined with this mini-lemma “divisor across a sum” tells us that if and , then .
Applying induction, we see that anything which divides and will also divide all the other ’s.
Let be the index such that . Then the algorithm returns . From what we said in the previous paragraph, is a multiple of the gcd of the input, and .
Now we show that divides the gcd of and , so they are equal (up to multiplication by units).
Since and
We see that divides and, again, by the “divisor across a sum” lemma, we have divides for all of the ’s down to . Thus, divides and , and therefore will divide their greatest common divisor.
QED
In the previous entry, we gave a definition for irreducible element and ring norm. We then showed that having a ring norm implies that we can factor elements into irreducibles. Now we’re going to show that having a norm map does not guarantee unique factorization. This will also provide us an example of irreducible elements which are not prime.
This is a classic example; it’s fairly simple and is found in many text books.
Example: Irreducibles which aren’t prime
Let , the set of complex numbers of the form
We can then define such that
Notice that
so if
and we let
then
Now we want to show that
which can be done by calculating the left-hand and the right-hand side of the above equation. If
then both sides evaluate to
so the result holds. Now we can more easily prove that , because
Finally, we have to show that if and only if is a unit. It’s clear that . Suppose that . Then we’ve shown that . Therefore, . So if , then we have
Thus, and . This means that is the only unit in .
This means that is, indeed, a norm map, so every element of can be factored into irreducibles.
We will now show that , , and are all irreducible.
Notice that
so if an element is a proper divisor of any of them, then its norm must either be or . However, it’s not difficult to see that no element has either value as its norm, because then we’d have or .
Finally, notice that
so we’ve factored into irreducibles in two distinct ways. From this we see that, for example, cannot be prime, since it divides , but and .
One of the most important lessons to take away from that example is that we have to be careful with factorization. We cannot assume unique factorization, even if we have a norm map (and thus factorization into irreducibles).
You should also note that our proof that is a norm map works for every square-free negative integer, . I.e.
where
is a norm map.
We’re now going to introduce a kind of ring which always has unique factorization (by definition).
Definition: Unique Factorization Domain
Let be a commutative integral domain such that every element of can be factored into irreducibles. Further suppose that for any element , if we have
where each element of and is irreducible and each element of and is a unit, then there exists a bijection
where , for all . What this means is that the elements of and are the same “up to multiplication by units.”
When this happens, is said to be a Unique Factorization Domain.
Unique Factorization Domains are often abbreviated as “UFD’s”.
Lemma: Factorization into Primes is Unique
Lat be a commutative integral domain with identity, such that every element can be factored into units and prime elements. Then is a UFD.
Proof
The proof is little more than induction applied to the definition of a prime element. Let
be two factorizations of an arbitrary non-zero non-unit element , where and are units and and are prime elements. Then we have for some .
implies , and since is prime, we know that either or . Suppose that . Then
so , which means that is a unit. This contradict our assumption that is prime.
Then, a similar argument shows that must be a unit, so . We can continue this for , , … , . When we’ve done this, we have to have , otherwise we would have a product of primes equal to a unit, which cannot happen.
Thus, we see that each is equal to some times a unit.
QED
Definition: Principal Ideal Domain
Let be a commutative integral domain with identity such that for any ideal, , we have , for some . Then is said to be a Principal Ideal Domain.
I.e. every ideal of is generated by a single element of .
Principal Ideal Domains are often abbreviated as “PID’s”.
Theorem: A PID is a UFD
Let be a Principal Ideal Domain, then is a Unique Factorization Domain.
The proof will involve several steps. We would typically break them down into lemmas and “mini-lemmas”, but here we’ll simply include them as different parts of one proof.
Proof
Part 1: Let , where be an increasing sequence of ideals of , then is an ideal of . (This result holds for an arbitrary ring)
Proof: Let and be in , then there are indices and , such that and , so , and thus . We can similarly show that for any and , we have . So part 1 holds.
Part 2: Since is a PID, any infinite increasing sequence of ideals, will have an , such that implies that .
Proof: By the previous paragraph’s result, we know that is an ideal of . Since is a PID, , for some . Then there must be an , such that . This establishes part 2.
Part 3: Every non-zero, non-unit element of can be factored into irreducible elements.
Proof Suppose not, then let , where at least one of and is neither a unit nor irreducible. Without loss of generality, let’s let that be . Then, we can repeat this process and express , where we can let be neither a unit nor irreducible. We can repeat this process arbitrarily often, so that we get
for any
but this generates a sequence of strictly increasing ideals, , where
which contradict part 2. This establishes part 3.
Part 4: Let be irreducible, then implies either or . (This means that is a maximal ideal).
Proof: Since is a PID, we know that for some . That means that , for some (because ). Since is irreducible, is either a unit or irreducible. If is a unit, then . On the other hand, if is not a unit, then must be a unit, so , which implies that . This implies that . This establishes part 4.
Part 5: Irreducible elements of are prime.
Proof: Suppose is an irreducible element of and that . Further, suppose that . Since , we know that , so . By part 4, this means that , so we have
for some elements, . Multiplying through by , we get
and since , this is equivalent to
which means that
Thus, and is prime. This establishes part 5.
Since we’ve shown that every element of can be factored into primes, we have unique factorization.
QED
Theorem: A Euclidean Domain is a PID
Let be a Euclidean Domain, then is a Principal Ideal Domain.
Proof
Let be the map, such that for any pair of non-zero elements, , we have , where , for some and in . We are guaranteed such a map, since is a Euclidean Domain
Let be an arbitrary ideal of . Let be an element of , such that
We claim that . Suppose, for a contradiction, that , and let , but . Then there are elements and , such that , and . However, if and , then is also in , but that’s impossible, since . This contradicts the minimality of in .
QED
Combining the last two theorems, we see that every Euclidean Domain has unique factorization.
Letting , where , we immediately see that is a Euclidean Domain… Whew! It’s a good thing, too, because our implementation of the Euclidean Algorithm depended on that!
RSA Encryption Algorithm
We’re now going to take a slight detour for the remainder of this entry to discuss the RSA encryption algorithm. Don’t worry, we’ll actually develop a little bit more ring theory along the way.
It works by starting with two distinct prime numbers, let’s call them and . Then we consider the ideal, . That ideal is the kernel of a homomorphism,
where represents an entire coset of the ideal. The image of is a finite ring of order , it is often written,
or more succinctly as . Since is commutative, is also commutative. However, it is not an integral domain. For example, notice that and are both zero divisors, since is equal to
So, clearly, not every element of is a unit. However, there are some units.
Let . We want to find a , such that . Notice that if we use our Extended Euclidean Algorithm, and set and , then we get , , and , where
so, if , then
This means that is a unit exactly when . We showed that the set of units of a ring is a group under multiplication. We’ll denote it, “.”
Let’s figure out how many elements there are in . We’ll do it by first counting all of the elements which aren’t units. Suppose is not a unit. Then , which means there are three possibilities.
How many elements satisfy 1? The only possible elements are: , , , …, . I.e. there are such elements.
A similar count shows that there are elements that satisfy 2.
There is exactly one element, that satisfies 3.
Adding them all up, we have
non-units. Which means that everything else is a unit. I.e. there are
units. That is, . This is a crucial calculation for the RSA algorithm.
Here’s how RSA works. There are two communicators, “Alice” and “Bob” (They’re pretty much always given those names).
- Before they start communicating, Alice picks two “large” prime numbers, and . Then she multiplies them together to get . She then calculates , and chooses a third number, , such that ( needs to be larger than . It can be fairly large, but doesn’t have to be absolutely huge). She also calculates , such that
with the extended euclidean algorithm. This means that
for some integer, .
- She then publishes and . However, she keeps, and a secret!
If Bob wants to communicate a secret with Alice, he then somehow encodes it as a number, , which should really be thought of as an element of . This means that . Then,
-
Bob then calculates and communicates it to Alice somehow.
-
Alice receives the message and computes
Let’s see what that gets her. Recall that , the group of units of . Therefore, , the subgroup generated by (defined in an earlier entry) will have an order which divides the size of by Lagrange’s Theorem.
Let’s call the order of , . We then have (By Lagrange’s Theorem), so , for some integer, . This means that
which means that
Thus, Alice get’s Bob’s message back!
There’s just one fairly large detail we haven’t addressed, and that is this: what happens if is huge? There’s a trick that can be used, and it’s Repeated Squaring. It allows Alice to calculate with roughly multiplications. We’ll cover it in the next entry. We’ll also go into more of the math of why RSA seems to be a good Public Key Encryption system for sending small payloads.
That’s all for this entry. Thanks for reading!!