An integral domain is a commutative ring with identity $1 \neq 0$ in which $ab = 0$ forces $a = 0$ or $b = 0$; a field is one in which every nonzero element is also a unit. Every field is an integral domain. A commutative ring with $1 \neq 0$ is an integral domain exactly when nonzero factors cancel ($ab = ac$ with $a \neq 0$ gives $b = c$), and there $x^2 = 1$ has no solutions besides $\pm 1$. Every finite integral domain is a field, though $\mathbb{Z}$ shows that an infinite one need not be. For a prime $p$, the Gaussian integers modulo $p$, $\mathbb{Z}_p[i]$, form a field exactly when $-1$ has no square root in $\mathbb{Z}_p$; for odd $p$ that means $p \equiv 3 \pmod 4$. So $\mathbb{Z}_3[i]$ is a field with nine elements and $\mathbb{Z}_5[i]$ is not.
The equation $x^2 = 1$ has two solutions in $\mathbb{Z}_{13}$, namely 1 and 12, but eight in $\mathbb{Z}_{24}$, as the integers modulo $n$ showed. School algebra solves it by factoring: $(x - 1)(x + 1) = 0$, so $x - 1 = 0$ or $x + 1 = 0$, and $x = \pm 1$. The second step, from a product equal to 0 to a factor equal to 0, is a property of the number system and not of algebra in general. The rings in which that step works have a name, and so do the rings in which division is possible as well.
Counting the solutions in four rings shows how much depends on the step.
| Ring | Solutions of $x^2 = 1$ |
|---|---|
| $\mathbb{Z}_{13}$ | 2: $1, 12$ |
| $\mathbb{Z}_{24}$ | 8: $1, 5, 7, 11, 13, 17, 19, 23$ |
| $\mathbb{Z}_5[i]$ (defined below) | 4: $1, 4, 2i, 3i$ |
| functions $\mathbb{R} \to \mathbb{R}$ | infinitely many: every function whose values are all $\pm 1$ |
In the three rings with extra solutions, the factoring step fails because nonzero elements can multiply to zero. Commutative rings with identity in which this cannot happen are the integral domains, and the factoring argument works in every one of them. Those in which, beyond that, every nonzero element can be divided by are the fields. They are the rings in which the algebra of the integers, and of the rational numbers, can be carried out unchanged. This article is the home of both definitions.
First we define the two kinds of ring and sort the examples so far. Then we prove that every field is an integral domain and that integral domains are the rings with cancellation. Next we build the Gaussian integers modulo $n$ and prove that every finite integral domain is a field. Finally we decide which $\mathbb{Z}_p[i]$ are fields.
This is the third article of Rings. It covers the definitions of integral domain and field in §3.1 of the course text and Theorems 3.7, 3.8 and 3.9 of §3.2 (Hungerford, 2014). It uses the units and zero divisors of an arbitrary ring from Basic Properties of Rings.
Definitions
Definition. An integral domain is a commutative ring $R$ with identity $1_R \neq 0_R$ in which, for all $a$ and $b$ in $R$,
$$ab = 0_R \quad \text{implies} \quad a = 0_R \text{ or } b = 0_R.$$
Equivalently, an integral domain is a commutative ring with identity $1_R \neq 0_R$ that has no zero divisors: the product of two nonzero elements is nonzero.
Definition. A field is a commutative ring $R$ with identity $1_R \neq 0_R$ in which every nonzero element is a unit.
The condition $1_R \neq 0_R$ excludes only the zero ring, by the proposition on the identity; a field must have at least the two elements $0$ and $1$. In a field, division by a nonzero element $b$ is defined as multiplication by $b^{-1}$. With that definition the rules for fractions of school algebra hold, because their proofs use only the field properties. Write $\frac{a}{b}$ for $ab^{-1}$, and let $b$ and $d$ be nonzero. Since $b$ and $d$ are units, so is $bd$, and $(bd)^{-1} = d^{-1}b^{-1} = b^{-1}d^{-1}$, by the proposition on products of units and commutativity. The rules are
$$\frac{a}{b} + \frac{c}{d} = \frac{ad + bc}{bd}, \qquad \frac{a}{b} \cdot \frac{c}{d} = \frac{ac}{bd}, \qquad \frac{a}{b} = \frac{c}{d} \iff ad = bc.$$
For the sum, $(ad + bc)(bd)^{-1} = ad\,b^{-1}d^{-1} + bc\,b^{-1}d^{-1} = ab^{-1} + cd^{-1}$. For the product, $ac\,(bd)^{-1} = ac\,b^{-1}d^{-1} = (ab^{-1})(cd^{-1})$. For the last rule, multiplying $ab^{-1} = cd^{-1}$ by $bd$ gives $ad = bc$, and multiplying $ad = bc$ by $b^{-1}d^{-1}$ gives $ab^{-1} = cd^{-1}$.
The rings of the course so far sort as follows.
| Ring | Integral domain | Field |
|---|---|---|
| $\mathbb{Q}$, $\mathbb{R}$, $\mathbb{C}$ | yes | yes |
| $\mathbb{Z}_p$, $p$ prime | yes | yes |
| $\mathbb{Z}$ | yes | no: 2 is not a unit |
| Gaussian integers $\mathbb{Z}[i]$ | yes | no: $2 + i$ is not a unit |
| polynomials $\mathbb{Z}[x]$ | yes | no: $x$ is not a unit |
| $\mathbb{Z}_n$, $n$ composite | no | no |
| functions $\mathbb{R} \to \mathbb{R}$ | no: $\max(\sin x, 0)$ is a zero divisor | no |
| even integers $2\mathbb{Z}$ | no: no identity | no |
| $2 \times 2$ real matrices | no: not commutative | no |
The entries for $\mathbb{Z}_n$ are the theorem on prime moduli: $\mathbb{Z}_n$ has no zero divisors, and every nonzero element is a unit, exactly when $n$ is prime. The units of $\mathbb{Z}[i]$ and of the functions are found in Basic Properties of Rings, and the absence of zero divisors in $\mathbb{Z}[i]$ is proved below. The first row records that every nonzero rational, real or complex number has a reciprocal. The row for $\mathbb{Z}$ records that a product of nonzero integers is nonzero, and that the only units of $\mathbb{Z}$ are $\pm 1$.
For $\mathbb{Z}[x]$, let $f$ and $g$ be nonzero with leading terms $ax^m$ and $bx^k$, so that $a$ and $b$ are nonzero integers. Multiplying out, the only term of $fg$ of degree $m + k$ is $abx^{m+k}$, and no term has higher degree. The leading coefficient of $fg$ is $ab \neq 0$, so $fg \neq 0$. And $x$ is not a unit, because $xg$ has no constant term for any polynomial $g$, so it is never $1$.
Rings that satisfy every condition for a field except commutativity are called division rings; the quaternions are the standard example (Judson, 2026, Example 16.1.7). They do not appear in this course.
Every field is an integral domain
The second definition is the stronger one. Here is the idea in one sentence: a unit cannot be a zero divisor, and in a field every nonzero element is a unit.
Theorem. Every field is an integral domain.
Proof. A field $F$ is commutative with $1_F \neq 0_F$ by definition, so it remains to show that $F$ has no zero divisors. Every nonzero element of $F$ is a unit, and a unit is not a zero divisor, by the proposition in Basic Properties of Rings. So no nonzero element of $F$ is a zero divisor. $\blacksquare$
This is the course text's Theorem 3.8. The converse is false: $\mathbb{Z}$, $\mathbb{Z}[i]$ and $\mathbb{Z}[x]$ are integral domains that are not fields. Since the two notions coincide for the rings $\mathbb{Z}_n$, it is easy to think they are the same. "No zero divisors" says that multiplying by $a \neq 0$ loses no information; "every nonzero element is a unit" says that the multiplication can be undone inside the ring. In $\mathbb{Z}$, multiplying by 2 loses nothing, yet no integer $\frac{1}{2}$ undoes it.
The theorem also gives an easy way to recognize integral domains. A subset of a field that contains 1 and is closed under subtraction and multiplication is a subring of the field, and it inherits the absence of zero divisors.
Proposition. Let $F$ be a field and let $D$ be a subset of $F$ that contains $1_F$ and is a ring under the operations of $F$. Then $D$ is an integral domain.
The idea: a product computed in $D$ is computed in $F$, so if it is 0, a factor was already 0 in $F$.
Proof. Multiplication in $D$ is multiplication in $F$, so it is commutative; $1_F$ is an identity for $D$ and differs from $0_F$. If $a$ and $b$ are in $D$ and $ab = 0$, then $ab = 0$ in $F$, which is an integral domain by the theorem, so $a = 0$ or $b = 0$. $\blacksquare$
So $\mathbb{Z}$ and $\mathbb{Z}[i]$, which sit inside the field $\mathbb{C}$ and contain 1, are integral domains. The converse holds as well, in the sense that every integral domain sits inside some field. The integers sit inside the rationals. In general an integral domain sits inside its field of fractions, built from pairs $(a, b)$ with $b \neq 0$, exactly as the rationals are built from pairs of integers in Equivalence Relations and Partitions (Judson, 2026, Theorem 18.1.4).
Cancellation
The definition talks about products equal to zero. Ordinary algebra uses the property in another form: a nonzero factor can be canceled from both sides of an equation. In $\mathbb{Z}_{21}$ it cannot always: $14 \cdot 1 = 14$ and $14 \cdot 4 = 56 = 14$, but $1 \neq 4$. Cancellation is exactly the property that defines integral domains, phrased differently.
Theorem. Let $R$ be a commutative ring with identity $1_R \neq 0_R$. Then $R$ is an integral domain if and only if cancellation holds: whenever $a \neq 0$ and $ab = ac$, then $b = c$.
The idea: $ab = ac$ is the same as $a(b - c) = 0$, so canceling $a$ is the same as concluding that the factor $b - c$ is 0.
Proof. Suppose $R$ is an integral domain, $a \neq 0$ and $ab = ac$. Then
$$a(b - c) = ab - ac = 0$$
by the rules of signs. Since $a \neq 0$ and $R$ has no zero divisors, $b - c = 0$, that is, $b = c$.
Conversely, suppose cancellation holds, and let $ab = 0$. If $a = 0$ we are done. If $a \neq 0$, write the equation as $ab = a \cdot 0$, which is true because $a \cdot 0 = 0$. Canceling $a$ gives $b = 0$. $\blacksquare$
The first half is the course text's Theorem 3.7, and the equivalence is Judson's Proposition 16.2.4.
Back to the opening equation. The factoring argument for $x^2 = 1$ now works in any integral domain $R$. If $x^2 = 1$, then $(x - 1)(x + 1) = x^2 + x - x - 1 = x^2 - 1 = 0$, so $x - 1 = 0$ or $x + 1 = 0$, and $x = 1$ or $x = -1$. There are at most two solutions, and exactly one when $1 = -1$. Each extra solution in the table at the top of this article is evidence of zero divisors.
Example (a factor that cannot be canceled). In $\mathbb{Z}_{1729}$, the running pair gave $1001 \cdot 19 = 0$. Then $1001 \cdot 38 = 0$ as well, and cancellation fails. Since $38 = 2 \cdot 19$, $1001 \cdot 38 = 2 \cdot (1001 \cdot 19) = 0$, as the script confirms. So $1001 \cdot 19 = 1001 \cdot 38$ with $19 \neq 38$: the factor 1001 cannot be canceled, and $\mathbb{Z}_{1729}$ is not an integral domain.
The Gaussian integers modulo $n$
The finite rings so far have all been rings $\mathbb{Z}_n$, in which the integral domains and the fields turned out to be the same, those with $n$ prime. A second family of finite rings shows more. For a positive integer $n$ let
$$\mathbb{Z}_n[i] = \{\, a + bi : a, b \in \mathbb{Z}_n \,\},$$
with $i$ a symbol, and with $a + bi = c + di$ exactly when $a = c$ and $b = d$ in $\mathbb{Z}_n$. The operations are copied from the Gaussian integers:
$$(a + bi) + (c + di) = (a + c) + (b + d)i, \qquad (a + bi)(c + di) = (ac - bd) + (ad + bc)i,$$
with the arithmetic in the coordinates done in $\mathbb{Z}_n$. This is the rule $i^2 = -1$, applied with the coordinates taken modulo $n$. The ring has $n^2$ elements; $\mathbb{Z}_3[i]$ has the nine elements $0, 1, 2, i, 1 + i, 2 + i, 2i, 1 + 2i, 2 + 2i$.
Proposition. $\mathbb{Z}_n[i]$ is a commutative ring with identity $1 = 1 + 0i$.
The plan: expand both sides of each law with the formulas and compare, using only the laws of $\mathbb{Z}_n$.
Proof. Addition is coordinatewise, so its laws are those of $\mathbb{Z}_n$: the zero is $0 + 0i$, and the negative of $a + bi$ is $(-a) + (-b)i$. Multiplication is commutative because the formula is symmetric under exchanging $(a, b)$ with $(c, d)$, and $(1 + 0i)(c + di) = c + di$. The identity works because $(1 + 0i)(c + di) = (1c - 0d) + (1d + 0c)i$. For associativity, expand both groupings with the formula:
$$\begin{aligned} \big((a + bi)(c + di)\big)(e + fi) &= \big((ac - bd) + (ad + bc)i\big)(e + fi) \\ &= \big((ac - bd)e - (ad + bc)f\big) + \big((ac - bd)f + (ad + bc)e\big)i, \\ (a + bi)\big((c + di)(e + fi)\big) &= (a + bi)\big((ce - df) + (cf + de)i\big) \\ &= \big(a(ce - df) - b(cf + de)\big) + \big(a(cf + de) + b(ce - df)\big)i. \end{aligned}$$
Multiplied out, both are
$$(ace - adf - bcf - bde) + (acf + ade + bce - bdf)i,$$
and the two expansions use only the commutative, associative and distributive laws of $\mathbb{Z}_n$, so they agree. For distributivity,
$$\begin{aligned} (a + bi)\big((c + di) + (e + fi)\big) &= \big(a(c + e) - b(d + f)\big) + \big(a(d + f) + b(c + e)\big)i, \\ (a + bi)(c + di) + (a + bi)(e + fi) &= \big((ac - bd) + (ae - bf)\big) + \big((ad + bc) + (af + be)\big)i, \end{aligned}$$
and both equal $(ac + ae - bd - bf) + (ad + af + bc + be)i$. The distributive law on the other side follows from this one, because multiplication is commutative. $\blacksquare$
The script also verifies every ring law by brute force for $n = 2, 3, 4, 5$. The proof used only the laws of a commutative ring with identity. So with $\mathbb{Z}_n$ replaced by any commutative ring $R$ with identity, it shows that $R[i]$ is a ring; with $R = \mathbb{Z}$ it is the Gaussian integers.
The norm $N(a + bi) = a^2 + b^2$, now an element of $\mathbb{Z}_n$, is still multiplicative: $N(zw) = N(z)N(w)$. The expansion in the proof for $\mathbb{Z}[i]$ used only the laws of a commutative ring, so it proves the statement here as well. The norm is also still $z$ times its conjugate: $(a + bi)(a - bi) = a^2 + b^2$.
Two examples
$\mathbb{Z}_3[i]$ has no zero divisors. The squares in $\mathbb{Z}_3$ are $0^2 = 0$, $1^2 = 1$ and $2^2 = 1$. So a sum of two squares $a^2 + b^2$ is $0$ only when $a = b = 0$, and the norm of a nonzero element is nonzero. Now suppose $zw = 0$ in $\mathbb{Z}_3[i]$. Then $N(z)N(w) = N(0) = 0$ in $\mathbb{Z}_3$. Since $\mathbb{Z}_3$ is an integral domain, $N(z) = 0$ or $N(w) = 0$, and therefore $z = 0$ or $w = 0$. So $\mathbb{Z}_3[i]$ is an integral domain.
$\mathbb{Z}_5[i]$ has zero divisors. In $\mathbb{Z}_5$, $2^2 = 4 = -1$, so $-1$ has a square root, and
$$(2 + i)(2 - i) = 4 - i^2 = 4 + 1 = 5 = 0.$$
The script finds 8 zero divisors and 16 units among the 24 nonzero elements of $\mathbb{Z}_5[i]$; every nonzero element is one or the other. Cancellation fails accordingly: $(2 + i) \cdot 1 = 2 + i$ and $(2 + i)(3 + 4i) = 2 + 11i = 2 + i$, but $1 \neq 3 + 4i$. The difference of the two canceled factors, $(3 + 4i) - 1 = 2 + 4i = 2 - i$, is the partner that $2 + i$ sends to zero.
Finite integral domains are fields
The table of $\mathbb{Z}_3[i]$ shows more than the absence of zero divisors: every nonzero element has an inverse. Is that a coincidence?
It is not. Here is the idea: multiplying every element of a finite integral domain by a fixed $a \neq 0$ gives a list with no repeats, by cancellation, and $m$ different elements of an $m$-element ring are the whole ring, 1 included.
Theorem. Every finite integral domain is a field.
Proof. Let $R$ be a finite integral domain and let $a$ be a nonzero element. It must be shown that $a$ is a unit. List the elements of $R$ as $r_1, r_2, \ldots, r_m$, all different, and consider the products
$$ar_1, \; ar_2, \; \ldots, \; ar_m.$$
These are all different: if $ar_j = ar_k$, then $r_j = r_k$ by cancellation, which holds in an integral domain, so $j = k$. Thus the list contains $m$ different elements of $R$, and $R$ has only $m$ elements, so every element of $R$ appears in the list. In particular $1_R$ does: $ar_j = 1_R$ for some $j$. Since $R$ is commutative, also $r_j a = 1_R$, so $a$ is a unit. $\blacksquare$
This is the course text's Theorem 3.9 and Judson's Theorem 16.2.5. The argument is the one used for $\mathbb{Z}_n$ in Units and Zero Divisors in the Integers Modulo n, where multiplying by a fixed unit rearranged the elements. Here the hypothesis is only that $a$ is not a zero divisor, and finiteness supplies the rest. It gives a second proof that $\mathbb{Z}_p$ is a field for $p$ prime. $\mathbb{Z}_p$ is finite, and it is an integral domain because $p \mid ab$ implies $p \mid a$ or $p \mid b$ by Euclid's lemma.
Now the check on the running example. In $\mathbb{Z}_3[i]$, multiplying the eight nonzero elements $1, 2, i, 1 + i, 2 + i, 2i, 1 + 2i, 2 + 2i$ by $1 + i$ gives
$$1 + i, \; 2 + 2i, \; 2 + i, \; 2i, \; 1, \; 1 + 2i, \; 2, \; i,$$
the same eight elements in a new order. The fifth entry is 1, so $(1 + i)(2 + i) = 1$: indeed $(1 + i)(2 + i) = 2 + i + 2i + i^2 = 1 + 3i = 1$ in $\mathbb{Z}_3[i]$.
The theorem guarantees that the inverse exists without saying how to find it. The norm finds it directly: from $z \bar{z} = N(z)$, where $\bar z = a - bi$,
$$z^{-1} = N(z)^{-1} \, \bar{z}$$
whenever $N(z)$ is a unit of $\mathbb{Z}_n$. For $z = 1 + i$, $N(z) = 2$, whose inverse in $\mathbb{Z}_3$ is 2, so $z^{-1} = 2(1 - i) = 2 - 2i = 2 + i$.
So $\mathbb{Z}_3[i]$ is a field with nine elements, the first field in the course whose number of elements is not prime. The unit on building fields from irreducible polynomials constructs it again, as a quotient of the polynomial ring $\mathbb{Z}_3[x]$, along with fields of every prime power size.
Finiteness is necessary. In $\mathbb{Z}$, multiplying by 2 sends the integers to the even integers, all different, but the list never reaches 1. That is possible only because the list is infinite.
When is $\mathbb{Z}_p[i]$ a field?
Why is $\mathbb{Z}_3[i]$ a field and $\mathbb{Z}_5[i]$ not? The two examples differ in one respect: $-1$ has a square root in $\mathbb{Z}_5$ but not in $\mathbb{Z}_3$. That is the whole story.
Theorem. Let $p$ be a prime. Then $\mathbb{Z}_p[i]$ is a field if and only if there is no $x$ in $\mathbb{Z}_p$ with $x^2 = -1$.
Here is the plan. A square root $x$ of $-1$ factors $x^2 + 1 = 0$ as $(x + i)(x - i)$, a pair of zero divisors. Without one, the norm of every nonzero element is nonzero, and the norm formula for the inverse works.
Proof. Suppose $x^2 = -1$ for some $x$ in $\mathbb{Z}_p$. Then
$$(x + i)(x - i) = x^2 - xi + xi - i^2 = x^2 + 1 = 0,$$
and $x + i$ and $x - i$ are nonzero, because their coefficients of $i$ are $1$ and $-1$, which are nonzero in $\mathbb{Z}_p$. So $\mathbb{Z}_p[i]$ has zero divisors and is not a field.
Conversely, suppose $-1$ has no square root in $\mathbb{Z}_p$, and let $z = a + bi$ be nonzero. Suppose $N(z) = a^2 + b^2$ were 0. Then $b \neq 0$, since $b = 0$ would give $a^2 = 0$ and hence $a = 0$ in the integral domain $\mathbb{Z}_p$. So $b$ is a unit of the field $\mathbb{Z}_p$, and dividing $a^2 + b^2 = 0$ by $b^2$ gives $(ab^{-1})^2 = -1$, contrary to the assumption. So $N(z) \neq 0$, which makes $N(z)$ a unit of $\mathbb{Z}_p$, and
$$z \cdot N(z)^{-1}(a - bi) = N(z)^{-1}(a^2 + b^2) = 1.$$
So every nonzero element of $\mathbb{Z}_p[i]$ is a unit, and since $\mathbb{Z}_p[i]$ is commutative with $1 \neq 0$, it is a field. $\blacksquare$
The proof of the converse did not use the theorem on finite integral domains; it produced the inverse directly. For $p = 2$, $-1 = 1 = 1^2$, so $\mathbb{Z}_2[i]$ is not a field, and indeed $(1 + i)^2 = 1 + 2i + i^2 = 0$ there.
The primes with a square root of $-1$ follow a pattern. Running the test over the primes below 100, the script finds that $\mathbb{Z}_p[i]$ is a field for
$$p = 3, 7, 11, 19, 23, 31, 43, 47, 59, 67, 71, 79, 83,$$
and not for $p = 2, 5, 13, 17, 29, 37, 41, 53, 61, 73, 89, 97$. Every prime in the first list leaves remainder 3 on division by 4, and every odd prime in the second leaves remainder 1. The pattern holds for every prime.
Theorem. Let $p$ be an odd prime. Then $x^2 = -1$ has a solution in $\mathbb{Z}_p$ if and only if $p \equiv 1 \pmod 4$. Consequently $\mathbb{Z}_p[i]$ is a field if and only if $p \equiv 3 \pmod 4$.
Here is the plan of the proof. When $p \equiv 1 \pmod 4$, Wilson's theorem, with its factors paired as $k$ and $-k$, writes $-1$ as a square. When $-1$ has a square root $x$, multiplying by $x$ and by $-1$ sorts the nonzero elements into blocks of four, so 4 divides $p - 1$.
Proof. Suppose $p \equiv 1 \pmod 4$. By Wilson's theorem, $(p - 1)! \equiv -1 \pmod p$. Pairing each factor $k$ with $p - k \equiv -k$, for $k = 1, \ldots, (p - 1)/2$, rewrites the factorial as
$$(p - 1)! \equiv \prod_{k=1}^{(p-1)/2} k \cdot (-k) = (-1)^{(p-1)/2} \left( \left(\tfrac{p - 1}{2}\right)! \right)^2 \pmod p.$$
Since $(p - 1)/2$ is even, $x = \left(\frac{p - 1}{2}\right)!$ satisfies $x^2 \equiv -1 \pmod p$.
Conversely, suppose $x^2 = -1$ in $\mathbb{Z}_p$. Then $x \neq 1$ and $x \neq -1$, since either would give $x^2 = 1$, and $1 \neq -1$ because $p$ is odd. For each nonzero $a$ in $\mathbb{Z}_p$ consider the set
$$Q_a = \{a, \; xa, \; -a, \; -xa\}.$$
Its four elements are different. If two of them were equal, then canceling the nonzero factor $a$ in the field $\mathbb{Z}_p$ would give $1 = x$, $1 = -1$, $1 = -x$ or $x = -x$. Each of these is impossible; $x = -x$ would give $2x = 0$, so $x = 0$, but $0^2 \neq -1$.
Each $Q_a$ consists of nonzero elements. Multiplying its elements by $x$ or by $-1$ gives elements of $Q_a$ again, because $x \cdot xa = -a$ and $x \cdot (-xa) = a$. So if $b$ lies in $Q_a$, then $xb$, $-b$ and $-xb$ lie in $Q_a$ too, and $Q_b = Q_a$, since both sets have four elements. For example $b = xa$ gives $Q_b = \{xa, -a, -xa, a\}$. Hence two of these sets are either equal or disjoint: if $c$ lies in both $Q_a$ and $Q_b$, then $Q_a = Q_c = Q_b$. Every nonzero $a$ lies in its own set $Q_a$. So the sets split the $p - 1$ nonzero elements of $\mathbb{Z}_p$ into disjoint blocks of four, as in a partition. Therefore $4 \mid p - 1$, that is, $p \equiv 1 \pmod 4$.
The last sentence of the theorem follows from the previous theorem, since an odd prime leaves remainder 1 or 3 on division by 4. $\blacksquare$
A check with $p = 13$: $x = 6! = 720 \equiv 5$, and $5^2 = 25 \equiv -1 \pmod{13}$, so $(5 + i)(5 - i) = 0$ in $\mathbb{Z}_{13}[i]$. There the twelve nonzero elements split into the blocks $\{1, 5, 12, 8\}$, $\{2, 10, 11, 3\}$ and $\{4, 7, 9, 6\}$. The script confirms the factorial formula for every prime $p \equiv 1 \pmod 4$ below 100. A second proof of the converse, with powers instead of blocks, comes from Fermat's little theorem in the next unit: if $x^2 = -1$, then $x^{p - 1} = (x^2)^{(p-1)/2} = (-1)^{(p-1)/2}$, and Fermat's theorem says that $x^{p-1} = 1$. Since $-1 \neq 1$ for odd $p$, the exponent $(p - 1)/2$ is even, that is, $p \equiv 1 \pmod 4$.
Example (two more primes). Without a table: $\mathbb{Z}_7[i]$ is a field, and $\mathbb{Z}_{17}[i]$ is not, with the zero divisors $4 + i$ and $4 - i$. Since $7 \equiv 3 \pmod 4$, $\mathbb{Z}_7[i]$ is a field with 49 elements; the script finds all 48 nonzero elements to be units. Since $17 \equiv 1 \pmod 4$, $\mathbb{Z}_{17}[i]$ is not. Here $4^2 = 16 \equiv -1$, so $(4 + i)(4 - i) = 16 + 1 = 17 = 0$. The script counts 32 zero divisors among its 288 nonzero elements.
Worked problems
These problems are from the course's assignment on §3.1 (Problems 1 and 2) and its assignment on §4.1, §5.1 and §5.2 (Problems 3 and 4). Each is solved in full from the results of this unit.
Problem 1. Find all the units and all the zero divisors of each ring: (a) $\mathbb{Z}$; (b) $\mathbb{Q}$; (c) $\mathbb{Z}_7$; (d) $\mathbb{Z}_8$; (e) $\mathbb{Z}_{12}$.
(a) The units of $\mathbb{Z}$ are $1$ and $-1$, and $\mathbb{Z}$ has no zero divisors. The units were found in Basic Properties of Rings. If $a$ and $b$ are nonzero integers, then $\lvert ab \rvert = \lvert a \rvert \lvert b \rvert \ge 1$, so $ab \neq 0$. $\mathbb{Z}$ is an integral domain that is not a field.
(b) The units of $\mathbb{Q}$ are all the nonzero rational numbers, and $\mathbb{Q}$ has no zero divisors. A nonzero rational number $\frac{a}{b}$ has $a \neq 0$, and $\frac{a}{b} \cdot \frac{b}{a} = 1$. So $\mathbb{Q}$ is a field. Every field is an integral domain, so there are no zero divisors.
For the three rings $\mathbb{Z}_n$, the two theorems of Units and Zero Divisors in the Integers Modulo n sort every nonzero class with one greatest common divisor. For $0 < a < n$, the class $a$ is a unit when $\gcd(a, n) = 1$ and a zero divisor when $\gcd(a, n) > 1$, and it is never both. The class 0 is neither: $0 \cdot b = 0 \neq 1$ for every $b$, and a zero divisor is nonzero by definition.
(c) The units of $\mathbb{Z}_7$ are $1, 2, 3, 4, 5, 6$, and there are no zero divisors. Since 7 is prime, $\gcd(a, 7) = 1$ for $a = 1, \ldots, 6$. The inverses are
$$1 \cdot 1 = 1, \qquad 2 \cdot 4 = 8 = 1, \qquad 3 \cdot 5 = 15 = 1, \qquad 6 \cdot 6 = 36 = 1.$$
$\mathbb{Z}_7$ is a field.
(d) The units of $\mathbb{Z}_8$ are $1, 3, 5, 7$ and the zero divisors are $2, 4, 6$.
| $a$ | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| $\gcd(a, 8)$ | 1 | 2 | 1 | 4 | 1 | 2 | 1 |
Each unit is its own inverse: $3 \cdot 3 = 9 = 1$, $5 \cdot 5 = 25 = 24 + 1 = 1$ and $7 \cdot 7 = 49 = 48 + 1 = 1$. The zero divisors multiply to zero as $2 \cdot 4 = 8 = 0$, $4 \cdot 2 = 0$ and $6 \cdot 4 = 24 = 0$.
(e) The units of $\mathbb{Z}_{12}$ are $1, 5, 7, 11$ and the zero divisors are $2, 3, 4, 6, 8, 9, 10$.
| $a$ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| $\gcd(a, 12)$ | 1 | 2 | 3 | 4 | 1 | 6 | 1 | 4 | 3 | 2 | 1 |
Each unit is its own inverse: $5 \cdot 5 = 25 = 24 + 1$, $7 \cdot 7 = 49 = 48 + 1$ and $11 \cdot 11 = 121 = 120 + 1$. Each zero divisor has a nonzero partner:
$$2 \cdot 6 = 12, \quad 3 \cdot 4 = 12, \quad 4 \cdot 3 = 12, \quad 6 \cdot 2 = 12, \quad 8 \cdot 3 = 24, \quad 9 \cdot 4 = 36, \quad 10 \cdot 6 = 60,$$
and each of these products is a multiple of 12, so it is 0 in $\mathbb{Z}_{12}$.
In the terms of this article: $\mathbb{Q}$ and $\mathbb{Z}_7$ are fields, $\mathbb{Z}$ is an integral domain but not a field, and $\mathbb{Z}_8$ and $\mathbb{Z}_{12}$ are neither.
Problem 2. In $\mathbb{Z}_{12}$, give two zero divisors whose product is zero, and two zero divisors whose product is not zero. Count the ordered pairs of each kind.
For the first, $3 \cdot 4 = 12 = 0$. For the second, $2 \cdot 3 = 6 \neq 0$.
By Problem 1 there are seven zero divisors, $2, 3, 4, 6, 8, 9, 10$, and so $49$ ordered pairs $(a, b)$ of them. The product $ab$ is 0 in $\mathbb{Z}_{12}$ exactly when 12 divides the integer $ab$. The pairs with that property are listed by their first entry.
| $a$ | $b$ with $ab = 0$ | Number |
|---|---|---|
| 2 | 6 | 1 |
| 3 | 4, 8 | 2 |
| 4 | 3, 6, 9 | 3 |
| 6 | 2, 4, 6, 8, 10 | 5 |
| 8 | 3, 6, 9 | 3 |
| 9 | 4, 8 | 2 |
| 10 | 6 | 1 |
So 17 ordered pairs have product zero, and the other 32 have a nonzero product. The table includes $6 \cdot 6 = 36 = 0$: a nonzero element whose square is zero. Each nonzero product is again a zero divisor, by the worked problem in Basic Properties of Rings. For example $2 \cdot 3 = 6$, and $6 \cdot 2 = 0$.
Problem 3. Let $R$ be a ring, and let $a$, $x$, $y$ be elements of $R$ with $a \neq 0$ and $ax = ay$. (a) If $R$ has an identity and $a$ is a unit, then $x = y$. (b) If $a$ is not a zero divisor, then $x = y$. (c) Give a ring $R$ and elements $a \neq 0$, $x \neq y$ with $ax = ay$, and say for which $a$ such elements exist.
The assignment states (a) for "a ring"; a unit only makes sense in a ring with identity, so that hypothesis is added. Nothing here needs $R$ to be commutative.
(a) Proof. Multiply $ax = ay$ on the left by $a^{-1}$. By associativity, $x = (a^{-1}a)x = a^{-1}(ax) = a^{-1}(ay) = (a^{-1}a)y = y$. $\blacksquare$
(b) Proof. By the rules of signs, $a(x - y) = ax - ay = 0$. Suppose $x \neq y$. Then $x - y \neq 0$, since $x - y = 0$ would give $x = (x - y) + y = y$. So the nonzero element $a$ multiplies the nonzero element $x - y$ to zero, and $a$ is a zero divisor by definition. That contradicts the hypothesis. So $x = y$. $\blacksquare$
Part (b) is the cancellation theorem of this article, proved for one element at a time and without commutativity or an identity. Part (a) also follows from (b), because a unit is not a zero divisor.
(c) In $\mathbb{Z}_{12}$ take $a = 6$, $x = 1$ and $y = 3$. Then $ax = 6$ and $ay = 18 = 6$, but $1 \neq 3$. By (b), every example must use a zero divisor $a$, and 6 is one, since $6 \cdot 2 = 0$.
The complete answer: for a nonzero $a$ in a ring $R$, there are $x \neq y$ with $ax = ay$ exactly when $ac = 0$ for some nonzero $c$. If $ac = 0$ with $c \neq 0$, then $a \cdot c = a \cdot 0$ and $c \neq 0$. Conversely, if $ax = ay$ with $x \neq y$, then $c = x - y$ is nonzero and $ac = 0$, as in (b). In a commutative ring such $a$ are exactly the zero divisors. In a noncommutative ring they are the zero divisors with $ac = 0$ for some nonzero $c$. A zero divisor with only $ca = 0$ can still be canceled on the left. The shift $s$ of the remark in Basic Properties of Rings is one: $ps = 0$ makes it a zero divisor, but $sx = sy$ forces $x = y$, because $s(x(v)) = s(y(v))$ gives $x(v) = y(v)$ for every sequence $v$, the function $s$ being one-to-one. In $\mathbb{Z}_{12}$ they are $2, 3, 4, 6, 8, 9, 10$, by Problem 1.
Problem 4. Give examples of (a) a finite field; (b) an infinite field; (c) an integral domain that is not a field.
Every example below is justified by a result of this unit or of the unit before it.
(a) Finite fields. $\mathbb{Z}_p$ is a field with $p$ elements for every prime $p$, by the theorem on prime moduli; the smallest is $\mathbb{Z}_2 = \{0, 1\}$, and $\mathbb{Z}_7$ is the field of Problem 1. These are the only fields among the rings $\mathbb{Z}_n$, by the same theorem. A finite field of another kind is $\mathbb{Z}_3[i]$, with 9 elements, and more generally $\mathbb{Z}_p[i]$, with $p^2$ elements, for every prime $p \equiv 3 \pmod 4$, such as $\mathbb{Z}_7[i]$ with 49.
(b) Infinite fields. $\mathbb{Q}$, $\mathbb{R}$ and $\mathbb{C}$. Each is a commutative ring with $1 \neq 0$ in which every nonzero element has a reciprocal, and each contains the infinitely many integers.
(c) Integral domains that are not fields. $\mathbb{Z}$: a product of nonzero integers is nonzero, and 2 is not a unit, since the units are $\pm 1$. The Gaussian integers $\mathbb{Z}[i]$: they contain 1 and lie in the field $\mathbb{C}$, so they form an integral domain by the proposition on subrings of fields, and $2 + i$, of norm 5, is not a unit. Both are infinite, and they have to be: a finite integral domain is a field. The polynomial ring $\mathbb{Z}[x]$ is a third example, by the argument after the table of this article; polynomial rings are treated in full in Polynomial Rings.
No part of the problem needs a polynomial ring or a quotient of one. Further finite fields, such as one with 4 elements, are built systematically as quotients of polynomial rings in Building Fields from Irreducible Polynomials.
Where it leads
- Fields are the natural coefficients for polynomials: over a field, polynomials have a division algorithm and unique factorization, in parallel with the integers.
- The field $\mathbb{Z}_3[i]$ with nine elements is the first of the finite fields that the unit on Building Fields from Irreducible Polynomials constructs from irreducible polynomials.
- Whether a quotient ring is an integral domain or a field is decided by the ideal it comes from, in Congruence Modulo an Ideal and Quotient Rings.
- Building larger rings from smaller ones, and finding rings inside rings, is the subject of Subrings and Direct Products of Rings, which shows that a product of two fields is never a field.
What we have learned
Integral domains are the commutative rings with $1 \neq 0$ in which nonzero factors can be canceled, and there $x^2 = 1$ has at most two solutions. Fields add that every nonzero element is a unit. Every field is an integral domain, and every finite integral domain is a field, but $\mathbb{Z}$ shows that an infinite one need not be. $\mathbb{Z}_p[i]$ is a field exactly when $-1$ has no square root modulo $p$, so $\mathbb{Z}_3[i]$ is a field with nine elements.
$\mathbb{Z}_p$ sits inside $\mathbb{Z}_p[i]$, and the rationals inside the reals. The last article of the unit, Subrings and Direct Products of Rings, gives a test for when a subset of a ring is a ring in its own right, and combines two rings into one.
References
- Hungerford, T. W. (2014). Abstract Algebra: An Introduction (3rd ed.), §3.1 and §3.2. Brooks/Cole, Cengage Learning. The course text: the definitions of integral domain and field, both with $1_R \neq 0_R$ (§3.1); cancellation in an integral domain (Theorem 3.7); every field is an integral domain (Theorem 3.8); every finite integral domain is a field (Theorem 3.9). record · 44 pages
- Judson, T. W. (2026). Abstract Algebra: Theory and Applications (annual edition, August 2026). Free online at judsonbooks.org. §16.2 (integral domains, division rings and fields); Proposition 16.2.4 (a commutative ring with identity is an integral domain if and only if cancellation holds); Theorem 16.2.5 (every finite integral domain is a field); Example 16.1.7 (the quaternions, a noncommutative division ring); Theorem 18.1.4 (every integral domain embeds in a field, its field of fractions). record · 44 pages
Reviewed: verified, 16 Nov 2026 · editorial review, 23 Nov 2026 · 7 revisions