Modular Rings and Units
The Ring of Integers Modulo n#
Recall the number system
which has the same addition and multiplication as , except that every result is always reduced to its smallest non-negative remainder modulo . For instance, in we have , since leaves a remainder of when divided by .
Each element is really a representative of a residue class; the set of all integers leaving the same remainder as when divided by ,
In for example, the element stands for the class . Basically, chops the integers up into classes and does arithmetic on the classes themselves; we just use the smallest non-negative member of each class as its name.
Fact
is a (commutative unital) ring for any positive integer .
So is our first example of a finite ring. Recall that a commutative unital ring is a set closed under two operations and , where both operations are associative and commutative, there is an additive identity and a multiplicative identity , every element has an additive inverse, and multiplication distributes over addition.
Example. Show that is a ring.
We can draw up the full addition and multiplication tables for ;
From the tables we can read off most of the ring laws directly:
- Every entry in both tables lies in , so is closed under both operations.
- The row of the addition table and the row of the multiplication table copy the headers, so and are the additive and multiplicative identities.
- The element appears in every row of the addition table, so every element has an additive inverse; , , and .
- Both tables are symmetric about the main diagonal, so both operations are commutative.
Associativity and distributivity hold because they already hold in , and reducing modulo at each step does not change which residue class an answer lands in. Therefore, satisfies all of the ring axioms and is a ring. The same argument works for any , which is exactly the Fact above.
A First Look at Modular Fields#
Recall that a field is a commutative ring in which every nonzero element has a multiplicative inverse; you can divide by anything except .
Notice that cannot be a field, since the nonzero element does not have a multiplicative inverse. This is clear from the multiplication table above; does not appear anywhere in 's row, so no element multiplies with to give .
Alternatively, we can argue it directly: if there were some with in , then we would need ; but is odd for every integer , so can never divide it.
On the other hand, consider the multiplication table for ;
Here every nonzero element does have a multiplicative inverse ( and , since in ), so is a field.
A natural question to ask is: for which is a field? To answer this, we first need some language for the elements that do have inverses.
Units and Unit Groups#
Definition
An element of a ring is called a unit (or invertible) if it has a multiplicative inverse in ; that is, if there exists some with .
Basically, the units are the elements you are allowed to divide by. In we just saw that is not a unit while is (since in ); a field is then simply a commutative ring where every nonzero element is a unit.
Definition
The unit group of a ring is the set of all units in , and is denoted by .
Example. Find the following unit groups.
- ; every nonzero fraction has the inverse , but nothing multiplies with to give .
- ; for any we would need with , which is impossible since is either or at least .
- , since and , but no other integer has an integer inverse.
- , since and in .
- , since and in , while and have no inverse.
Notice how the unit group depends heavily on the ring; rescues in , but in or there is no such element available.
Properties of Units#
Fact
If is a ring and is a unit, then is unique.
Proof. Suppose and are both inverses of , so and . Then
This is why we can safely write for the inverse of ; there is never more than one candidate.
Fact
If is a ring and , then ; in fact .
Proof. Since and are units, and exist in , and
So the units are closed under multiplication. This is exactly why is called the unit group: a group is a set with one operation satisfying the closure, associativity, identity and inverse laws, and under multiplication has all four. Closure is the Fact we just proved; associativity is inherited from ; the identity is (which is a unit since ); and if is a unit then so is , because its inverse is just again. The remaining details are inherited straight from the ring so I'm not gonna belabour them.
Example. In , both and are units. Their product in , which is certainly a unit; and indeed reduced mod . Closure holds exactly as promised.
Zero Divisors#
So units are the "good" elements. The next Fact tells us that, in a finite ring, the non-units are bad in a very specific way.
Fact
If is a finite ring and is not a unit, then or for some nonzero .
Proof. Suppose and is not a unit; we must produce a nonzero with .
Consider multiplying by every single element of . Since is finite, if all of these products were distinct then they would account for every element of ; in particular, for some , which would make a unit. But is not a unit, so the products cannot all be distinct. Hence two of them coincide,
and taking gives .
Definition
A nonzero element of a ring is called a zero divisor if there exists a nonzero such that .
Basically, a zero divisor is a nonzero element that manages to multiply with another nonzero element and still produce ; something that never happens in , or . Combining the Fact and the Definition, we get a clean three-way split:
Note
It is important to remember that itself is neither a unit nor a zero divisor; it sits in a category of its own.
Example. Find all zero divisors of .
We check each nonzero non-unit for a nonzero partner that kills it;
Therefore, the zero divisors of are ; precisely the nonzero elements sharing a common factor with . The remaining nonzero elements will turn out to be exactly the units.
You cannot cancel a zero divisor. In we have and , so does not imply ; cancelling is really multiplying both sides by an inverse, and zero divisors have none. Cancellation in is only valid when the element being cancelled is a unit.
Units in Z_n#
We now characterise exactly which elements of are units.
Theorem
The element is a unit in if and only if .
Proof. () Suppose . By Bézout's identity, there exist integers such that
Reducing both sides modulo kills the term, leaving in ; so (reduced mod ) is a multiplicative inverse of , and is a unit.
() Suppose is a unit, so in for some . Then , i.e. for some , which rearranges to
Any common divisor of and divides the left hand side, hence divides ; so .
Basically, being a unit mod is the same as being coprime with . This makes sense: any common factor shared between and can never be multiplied away, because every multiple of still carries that factor mod . In fact if , then
where is nonzero in ; so every nonzero non-unit of is a zero divisor, confirming the three-way split from before.
Corollary
The unit group . That is, the group of units in is the set of all natural numbers less than that are coprime with .
Example. Find and the inverse of each of its elements.
By the corollary, ; the four numbers less than coprime with . We can confirm each is a unit by finding its inverse directly;
This gives us the full table for ;
Notice how inverses come in pairs; once you know , you get for free.
Example. Classify every element of as , a unit, or a zero divisor.
Using the units criterion, we compute for each element;
| Status | Witness | ||
|---|---|---|---|
| zero | — | ||
| unit | |||
| zero divisor | |||
| zero divisor | |||
| zero divisor | |||
| unit | |||
| zero divisor | |||
| unit | |||
| zero divisor | |||
| zero divisor | |||
| zero divisor | |||
| unit |
Therefore, and the zero divisors are ; every element is accounted for by the three-way split. Notice the curious bonus: every unit in is its own inverse, since , and in .
When Z_n Is a Field#
We can now answer the question from the start: since a field needs every nonzero element to be a unit, we need every one of to be coprime with .
Theorem
Let be a positive integer greater than . Then is a field if and only if is prime.
Proof. () Suppose is prime. Then for every we have , since the only divisors of are and itself, and . By the units criterion, every nonzero element of is a unit, so is a field.
() Suppose is composite, say with . Then , so is a nonzero element with no inverse, and is not a field.
This correlates with what we saw earlier; is a field while is not, matching the fact that is prime while is not.
Example. must be a field since is prime, so every nonzero element of has a multiplicative inverse. We can check this by pairing everything up;
Every nonzero element appears in the bottom row, so is indeed a field.
Example. How many solutions does have in ?
In a field, factorises as , and since fields have no zero divisors one of the factors must be ; so there are at most the two solutions . But is not prime, so is not a field, and we should check every element rather than trust the factorisation;
Therefore, has four solutions in : . The factorisation logic breaks precisely because of zero divisors; taking gives with neither factor being zero. In for composite , a polynomial of degree can have more than roots, so always check all candidates rather than assuming field behaviour.
Finding Inverses#
Multiplication tables are fine for small , but useless for something like . To find the multiplicative inverse (often just called the inverse) of an element in , we follow these steps:
- Find . If it is not , there is no inverse and we stop.
- Find integers and such that ; either via the extended Euclidean algorithm, or just by checking small multiples of for a number that is away from a multiple of .
- The inverse of in is the value of its coefficient , reduced into .
This works because reducing modulo leaves in ; the term vanishes.
Example. Find the multiplicative inverse of in .
First check the gcd;
Therefore, is not a unit in and has no multiplicative inverse. (In fact in , so is a zero divisor.)
Example. Find in .
Here , so the inverse exists. Running the Euclidean algorithm;
The last nonzero remainder is , confirming the gcd. Rearranging the first line for ;
So , and reducing into gives . Checking: in . Therefore, in .
Alternative solution. Check small multiples of for a number that is away from a multiple of ;
So , i.e. in , giving as before. This trial method is often faster when is small; the extended Euclidean algorithm is the reliable choice when the numbers are large.
Note
The inverse produced by the algorithm is frequently negative; always reduce it modulo before writing the final answer.
Example. Find in .
Here trial and error would be painful, so we use the extended Euclidean algorithm in full. First, the Euclidean algorithm to find ;
The last nonzero remainder is , so and the inverse exists. Now back-substitute from the second-last line, replacing each remainder in turn;
So , which is already in . Checking: . Therefore, in .
Solving Equations with Inverses#
The whole point of inverses is that they let us divide, which means we can solve linear equations in the same way we do in ; provided the coefficient is a unit.
Example. Solve in .
Since is prime, is a unit; from the table earlier, . Multiplying both sides by the inverse;
Checking: in . Therefore, is the unique solution; uniqueness is guaranteed because we multiplied by an inverse, which is a reversible step.
Example. Solve in .
Here , so has no inverse and we cannot just divide; but that does not mean there are no solutions. The equation says , and since divides every term we can factorise the whole congruence by ;
Now , so is invertible mod with (since in );
Lifting back to , the elements congruent to mod are . Checking each: , , and in . Therefore, the equation has three solutions, .
The decision process here is worth internalising: check first. If it is , invert and get a unique solution; if , then solutions exist only when divides the right hand side, in which case dividing the whole congruence (including the modulus!) by gives exactly solutions in .
Irreducible and Prime Elements#
Now that we have encountered units, we can refine our earlier definitions of irreducible and prime elements so that they make sense in any ring.
Definition
An irreducible element of a ring is any such that both
- and , and
- whenever for elements , we must have or .
Definition
A prime element of a ring is any such that both
- and , and
- whenever for elements , we must have or .
Basically, irreducible means "cannot be factorised except trivially" (a unit times something is a trivial factorisation, since units can always be absorbed), while prime means "whenever it divides a product it divides one of the factors". These used to look like the same idea; in they coincide, which is why we never needed to distinguish them before. The unit condition also explains our old exclusions: for we banned since , and for we banned since .
Example. No element of is irreducible nor prime.
Since is prime, is a field by the field theorem; so every element is either or a unit, and nothing survives the first bullet point of either definition.
Example. Show that in , the element is prime but not irreducible.
First, the setup: (the elements coprime with ), and with , so passes the first bullet of both definitions.
Not irreducible. We need a factorisation of using no units. Notice that
so where and ; neither factor is a unit. Therefore, is not irreducible in .
Prime. The multiples of in are , so in exactly when . Suppose and , i.e. . Checking all products of these residues;
every product lands back in , so . By the contrapositive, forces or . Therefore, is prime in , despite not being irreducible. Prime and irreducible are genuinely different notions in a general ring; they only happen to agree in familiar rings like .