2.2  Finite Fields from Modular Arithmetic

Every field of Section 2.1 is infinite. Number Systems: From N to R has already met finite ones: it proved that the integers modulo a prime p form a field (Number Systems: From N to R, Theorem 3.5.2). This section restates that result in the language of Definition 2.1.1, gives these fields a name of their own, Fp, and computes in them: inverses, linear equations, and the elimination method of Section 2.1, now run modulo 5. Finite fields are not a curiosity; coding theory and computer algebra do linear algebra over them every day.

2.2.1. Arithmetic modulo n, recalled

Fix an integer n≥1. The ring Z/nZ of Number Systems: From N to R, Definition 3.4.2 consists of the classes [a] of integers a under congruence modulo n, and two classes are equal exactly when their representatives differ by a multiple of n: [a]=[b]⟺n∣a−b. This is the class test of Number Systems (Number Systems: From N to R, Theorem 3.4.1 (a), read with Number Systems: From N to R, Definition 3.4.2). Sums and products are computed on representatives. The first example collects what is known about this arithmetic, in the language of Definition 2.1.1.

Example (Arithmetic on Z/nZ and the Field F2)

Let n≥1, and define [a]+[b]:=[a+b] and [a][b]:=[ab] for a,b∈Z. Show that these operations are well defined, that they satisfy every clause of Definition 2.1.1 except possibly (F8) and the condition 1≠0 in (F7), and that [1]≠[0] holds exactly when n≥2. Then write out the addition and multiplication tables for n=2.

Solution. All of this was proved in Number Systems, and we collect it.

Well-definedness. The formulas use representatives, so the answer must not depend on which representatives are chosen. For the ideal nZ of Z this is Number Systems: From N to R, Theorem 3.4.1 (b), and Z/nZ is defined as that quotient (Number Systems: From N to R, Definition 3.4.2).

The clauses. By Number Systems: From N to R, Theorem 3.4.3 (a), Z/nZ is a commutative ring with zero [0] and one [1]: clauses (F1)–(F6) and (F9) hold, and so does (F7) without the condition 1≠0. The negative of [a] is [−a], since [a]+[−a]=[a+(−a)]=[0].

The condition 1≠0. By Number Systems: From N to R, Theorem 3.4.3 (c), [1]≠[0] if and only if n≥2. For n=1 every class equals [0], and Z/1Z is the zero ring.

Size. By Number Systems: From N to R, Theorem 3.4.3 (b), each class is [r] for exactly one r∈{0,1,…,n−1}, the remainder of any representative on division by n. So Z/nZ has exactly n elements.

The tables for n=2. Write 0 and 1 for [0] and [1]. Since 1+1=2 and 2−0=2⋅1, the class test gives [1]+[1]=[2]=[0]; the other entries are read off directly: +01001110⋅01000101 Here (F8) holds as well: the only non-zero element is 1, and 1⋅1=1. So F2:=Z/2Z is a field. In it 1+1=0, and therefore −1=1.

The tables of F2 are those of the two-element field of Number Systems: From N to R, Example (A field with two elements that cannot be ordered), with 0 and 1 read as classes. The one surprise is 1+1=0: it says that 2 is even, and nothing more. It is also the field promised by the warning on order in Section 2.1, where “1+1≠0” fails.

2.2.2. Which moduli give fields

For n≥2, whether Z/nZ is a field now comes down to one clause, (F8): does every non-zero class have an inverse? An inverse of [a] is a class [x] with [ax]=[1], that is, an integer x with n∣ax−1, that is, integers x,y with ax+ny=1. Such a combination is what Bézout’s theorem produces. The linear-algebra volumes cite it in the following special form.

Lemma 2.2.1 (Bézout’s Lemma for Integers)

Let a,n∈Z with n≥1, and suppose that the only positive integer dividing both a and n is 1. Then there are x,y∈Z with ax+ny=1.

Proof. Since n≥1, (a,n)≠(0,0), so g:=gcd(a,n) is a common divisor of a and n with g≥1 (Number Systems: From N to R, Definition 3.2.2 and the well-definedness paragraph after it). By hypothesis, g=1. So a and n are coprime, and Number Systems: From N to R, Corollary 3.2.2 gives x,y∈Z with ax+ny=1.

The general statement, for any pair of integers not both zero and with gcd(a,n) in place of 1, is Number Systems: From N to R, Theorem 3.2.1; the Euclidean algorithm computes the x and y. We keep the special case under its own name because the linear-algebra volumes cite it in this form.

Theorem 2.2.2 (Z/nZ Is a Field Exactly for Prime n)

Let n≥2 be an integer. Then Z/nZ is a field (Definition 2.1.1) if and only if n is prime.

Idea. By Example (Arithmetic on Z/nZ and the Field F2), only (F8) is in question. If n=p is prime and [a]≠[0], then p∤a, so the only positive common divisor of a and p is 1, and Lemma 2.2.1 hands over ax+py=1, that is, [a][x]=[1]. If instead n=rs with 1<r,s<n, then [r][s]=[n]=[0] with both factors non-zero, which Theorem 2.1.1 (f) forbids in a field. Number Systems ran this argument, with Number Systems: From N to R, Theorem 3.5.1 in the role of the lemma.

Proof. By Number Systems: From N to R, Theorem 3.5.2, Z/nZ is a field in the sense of Number Systems: From N to R, Definition 2.3.1 if and only if n is prime. By the remark after Definition 2.1.1, a field in that sense is the same as a field in the sense of Definition 2.1.1. This proves the theorem.

So for each prime p there is a field with exactly p elements, and for each composite n≥4 the ring Z/nZ is not a field. The fields deserve a short name.

2.2.3. The fields with p elements

Definition 2.2.1 (The Field Fp)

Let p be a prime. The field Fp is Z/pZ, with the operations of Example (Arithmetic on Z/nZ and the Field F2). It has exactly p elements (Number Systems: From N to R, Theorem 3.4.3 (b)), which we write 0,1,…,p−1, without brackets: the number r∈{0,…,p−1} stands for the class [r]. For integers a,b, “a=b in Fp” means [a]=[b], that is, p∣a−b.

So F2, F3, F5, F7, F11, … are fields, by Theorem 2.2.2, while Z/4Z, Z/6Z and Z/9Z are not. To decide that a given p is prime, the remark after Number Systems: From N to R, Lemma 3.3.4 says it is enough to check that no d≥2 with d⋅d≤p divides p.

Computing in Fp is computing with integers and replacing the answer by its remainder on division by p. The words “in Fp” must be said whenever an equation would be false in Z: “3⋅5=1 in F7” is true, because 15−1=2⋅7; “3⋅5=1” alone is false. Every result of Section 2.1 now holds in Fp. For instance, by Corollary 2.1.2 the only elements of Fp whose square is 1 are 1 and −1=p−1.

Quick check. Find the inverse of 3 in F7.

Solution. The inverse is the x∈{1,…,6} with 7∣3x−1. Testing the candidates in turn, the products 3,6,9,12,15 leave remainders 3,6,2,5,1, and 3⋅5=15=2⋅7+1. So 3−1=5 in F7, and by Theorem 2.1.1 (c) it is the only inverse.

For small p, trial is fast. For larger p the Euclidean algorithm of Number Systems finds the inverse directly: if ax+py=1, then gcd(a,p)=1 by Number Systems: From N to R, Corollary 3.2.2, and Number Systems: From N to R, Theorem 3.5.1 gives [a]−1=[x].

Example (Inverses in F7 and in F101)
  • (i) List the inverses of the non-zero elements of F7. (ii) Find the inverse of 17 in F101.

Solution.

  • (i) In F7: 1⋅1=1,2⋅4=8=1,3⋅5=15=1,6⋅6=36=1, since 8−1=7, 15−1=2⋅7 and 36−1=5⋅7. So 1−1=1, 2−1=4, 4−1=2, 3−1=5, 5−1=3, 6−1=6, using (F6) for the reversed pairs. Each element of F7×:=F7∖{0} appears exactly once as an inverse, as it must: the inverse of a−1 is a (Theorem 2.1.1 (g)), so two elements with the same inverse are equal. The elements 1 and 6=−1 are their own inverses, and by Corollary 2.1.2 no others are.

  • (ii) First, 101 is prime, by the criterion recalled after Definition 2.2.1: no d with 2≤d≤10 divides it (the remainders of 101 on division by 2,3,…,10 are 1,2,1,1,5,3,5,2,1), and 11⋅11=121>101. Run the Euclidean algorithm on (101,17): 101=5⋅17+16,17=1⋅16+1. Back-substitute from the last line: 1=17−16=17−(101−5⋅17)=6⋅17−101. So 17⋅6+101⋅(−1)=1, hence gcd(17,101)=1 (Number Systems: From N to R, Corollary 3.2.2), and Number Systems: From N to R, Theorem 3.5.1 gives 17−1=6 in F101. Check: 17⋅6=102=101+1.

Since Fp is a field, each result of Section 2.1 about equations holds there word for word; what changes is how the numbers are computed. An elimination of the same kind as Section 2.1’s opening one, done over F5, looks like this.

Example (Elimination over F5)

Solve the system 2x+y=3, 3x+2y=4 over F5.

Solution. In F5 the inverses are 1−1=1, 2−1=3, 3−1=2 and 4−1=4, since 2⋅3=6=5+1 and 4⋅4=16=3⋅5+1.

By elimination. Scale the first equation by 2−1=3. In F5, 3⋅2=1, 3⋅1=3 and 3⋅3=9=4, so the scaled equation reads x+3y=4. Taking 3 times it away from the second equation removes x and leaves (2−9)y=4−12,that is,3y=2  in F5, since −7=−10+3 and −8=−10+2. Multiply by 3−1=2: y=4. Then x=4−3y=4−12=−8=2 in F5.

By the formula. With a=2, b=1, c=3, d=2, e=3, f=4, the coefficient ad−bc=4−3=1 is non-zero, so Proposition 2.1.3 (b) applies: x=3⋅2−1⋅41=2,y=2⋅4−3⋅31=−1=4  in F5. The two methods agree. Check: 2⋅2+4=8=3 and 3⋅2+2⋅4=14=4 in F5. By Proposition 2.1.3 (b), (x,y)=(2,4) is the only solution.

Quick check. Which elements x∈F11 satisfy x2=1?

Solution. Exactly 1 and 10. By Corollary 2.1.2, x2=1 if and only if x=1 or x=−1, and −1=10 in F11, since 10−(−1)=11. Check: 102=100=9⋅11+1.

Warning. A non-zero class of Z/nZ need not have an inverse. In Z/6Z the equation [2]x=[1] has no solution, since [2]x is always one of [0],[2],[4]; and [2]x=[4] has two solutions, x=[2] and x=[5] (as 10−4=6). So division by [a] modulo n is allowed when n is prime and [a]≠[0], or more generally when gcd(a,n)=1 (Number Systems: From N to R, Theorem 3.5.1), and not otherwise.

Remark (No order on Fp). For n≥2, no relation < makes Z/nZ an ordered commutative ring (Number Systems: From N to R, Theorem 3.4.3 (e)). So the inequalities of Number Systems have no meaning in Fp, as the warning on order in Section 2.1 said. The representatives 0,1,…,p−1 are ordered as integers, but that order is not compatible with the arithmetic: 0<p−1 as integers, and adding 1 to both sides would give 1<0, since (p−1)+1=0 in Fp.

2.2.4. Exercises

A. Check your understanding

Exercise (A1)
  • (a) True or false: Z/8Z is a field. Justify your answer.
  • (b) List the inverses of 1,2,3,4 in F5.
  • (c) Compute 4⋅4+3 in F5.
  • (d) True or false: x2=x for every x∈F2.
  • (e) How many elements does F13 have, and is 13=0 in F13?

Solution.

  • (a) False. 8=2⋅4 is not prime, so Theorem 2.2.2 applies; concretely [2][4]=[8]=[0] with [2]≠[0] and [4]≠[0], which Theorem 2.1.1 (f) forbids in a field.

  • (b) 1−1=1, 2−1=3, 3−1=2, 4−1=4, as in Example (Elimination over F5).

  • (c) 4⋅4+3=19=3⋅5+4, so the answer is 4.

  • (d) True: 0⋅0=0 and 1⋅1=1 in F2. (This agrees with Exercise (B1) (c): the solutions of x2=x in any field are 0 and 1, and F2 has no other elements.)

  • (e) 13 is prime (neither 2 nor 3 divides it, and 4⋅4=16>13), so F13 is defined and has 13 elements. And 13=0 in F13, since 13∣13−0.

B. Practice

Exercise (B1)
  • (a) Solve 3x+5=2 in F7.
  • (b) Solve the system x+2y=3, 3x+y=1 over F7.

Solution.

  • (a) Adding −5 to both sides gives 3x=2−5=−3=4 in F7. Since 3⋅5=15=1 in F7, 3−1=5, and Proposition 2.1.3 (a) gives x=5⋅4=20=6. Check: 3⋅6+5=23=3⋅7+2.

  • (b) Here a=1, b=2, c=3, d=1, e=3, f=1, and ad−bc=1−6=−5=2≠0 in F7. Since 2⋅4=8=1, 2−1=4. By Proposition 2.1.3 (b), x=(3⋅1−2⋅1)⋅4=4,y=(1⋅1−3⋅3)⋅4=−32=3, since −32=−5⋅7+3. Check: 4+2⋅3=10=3 and 3⋅4+3=15=1 in F7. Hence (x,y)=(4,3), and it is the only solution.

Exercise (B2: Which Are Fields?)

Determine which of Z/9Z, F5, Z/1Z and Z/91Z are fields. Justify your answer.

Solution. Z/9Z: not a field, since [3][3]=[9]=[0] with [3]≠[0], against Theorem 2.1.1 (f). F5: a field, by Theorem 2.2.2, since 5 is prime. Z/1Z: not a field, since [1]=[0] there (Example (Arithmetic on Z/nZ and the Field F2)), against the condition 1≠0 of (F7). Z/91Z: not a field, since 91=7⋅13 is not prime (Theorem 2.2.2); concretely [7][13]=[91]=[0].

Exercise (B3)

Find all solutions of x2=2 in F7, and all solutions of x2=2 in F5.

Solution. In F7, 32=9=2. By Corollary 2.1.2, x2=2=32 holds exactly for x=3 and x=−3=4. Check: 42=16=2⋅7+2.

In F5 the squares of 0,1,2,3,4 are 0,1,4,9=4,16=1. None is 2, so x2=2 has no solution in F5.

C. Going deeper

Exercise (C1: A Field with Four Elements)

Let F be the set of formal expressions a+bα with a,b∈F2: four symbols 0, 1, α and β:=1+α, where a+bα=c+dα means a=c and b=d. Define (a+bα)+(c+dα):=(a+c)+(b+d)α,(a+bα)(c+dα):=(ac+bd)+(ad+bc+bd)α, with all arithmetic of coefficients in F2. (The product is what multiplying out gives if α2 is replaced by 1+α.)

  • (a) Write out the addition and multiplication tables of F.
  • (b) Prove that F is a field.
  • (c) Show that there is no bijection φ:F→Z/4Z with φ(x+y)=φ(x)+φ(y) and φ(xy)=φ(x)φ(y) for all x,y∈F. So this four-element field is not Z/4Z in disguise.

Solution (Hint 1). For (c): where must φ send 0?

Solution (Hint 2). For (c): look for a non-zero element of Z/4Z whose square is zero, and ask which element of F is sent to it.

Solution.

  • (a) Using the formulas, with 1+1=0 in F2: +01αβ001αβ110βαααβ01ββα10⋅01αβ00000101αβα0αβ1β0β1α For instance, αα=(0+1α)(0+1α)=(0+1)+(0+0+1)α=1+α=β, and αβ=(0+1α)(1+1α)=(0+1)+(0+1+1)α=1.

  • (b) Let x=a+bα, y=c+dα, z=e+gα with a,b,c,d,e,g∈F2. Since F2 is a field (Example (Arithmetic on Z/nZ and the Field F2)), the coefficients obey every rule of Section 2.1, and in addition u+u=(1+1)u=0 for every u∈F2.

    Addition works on each coefficient separately, so (F1) and (F2) for F are (F1) and (F2) for F2, applied twice; the element 0=0+0α satisfies (F3); and −x=x satisfies (F4), since a+a=0 and b+b=0.

    (F6). Exchanging (a,b) with (c,d) leaves the product formula as it was: ac+bd=ca+db and ad+bc+bd=cb+da+db, by (F1) and (F6) in F2.

    (F7). With 1=1+0α, x⋅1=(a⋅1+b⋅0)+(a⋅0+b⋅1+b⋅0)α=a+bα=x. And 1≠0, because the first coefficients 1 and 0 of F2 differ.

    (F9). Since y+z=(c+e)+(d+g)α, x(y+z)=(a(c+e)+b(d+g))+(a(d+g)+b(c+e)+b(d+g))α, and multiplying out the coefficients regroups this as ((ac+bd)+(ae+bg))+((ad+bc+bd)+(ag+be+bg))α=xy+xz.

    (F5). Write xy=h+kα with h=ac+bd and k=ad+bc+bd. Then (xy)z=(he+kg)+(hg+ke+kg)α, and multiplying out, he+kg=ace+adg+bcg+bde+bdg,hg+ke+kg=acg+ade+adg+bce+bcg+bde, where the second line uses bdg+bdg=0. On the other side, yz=l+mα with l=ce+dg and m=cg+de+dg, and x(yz)=(al+bm)+(am+bl+bm)α. Multiplying out gives al+bm=ace+adg+bcg+bde+bdg and am+bl+bm=acg+ade+adg+bce+bcg+bde, again using bdg+bdg=0. The coefficients agree, so (xy)z=x(yz).

    (F8). From the table, 1⋅1=1 and αβ=βα=1. So every non-zero element has an inverse: 1−1=1, α−1=β, β−1=α.

    This proves that F is a field.

  • (c) Assume, for a contradiction, that φ is such a bijection. To begin, φ(0)=φ(0+0)=φ(0)+φ(0) in Z/4Z. Adding −φ(0) to both sides gives φ(0)=[0]; this is additive cancellation, whose proof (Theorem 2.1.1 (b), first half) uses only (F1)–(F4), which hold in the commutative ring Z/4Z (Number Systems: From N to R, Theorem 3.4.3 (a)). Surjectivity provides x∈F with φ(x)=[2]; this x is not 0, because φ(0)=[0]≠[2]. But φ(xx)=φ(x)φ(x)=[2][2]=[4]=[0]=φ(0), and injectivity turns this into xx=0. By (b), F is a field, so Theorem 2.1.1 (f) gives x=0, a contradiction. Hence no such φ exists.

Marking scheme. (10 points)

  • 2: (a) both tables correct, with at least one product computed from the formula.
  • 1: (b) addition clauses (F1)–(F4), coefficientwise, with −x=x.
  • 1: (b) (F6) and (F7), including 1≠0.
  • 2: (b) (F5) and (F9) by expanding coefficients, with u+u=0 in F2 used and named.
  • 1: (b) (F8) from the table.
  • 1: (c) φ(0)=[0], with the cancellation justified in Z/4Z.
  • 2: (c) an x≠0 with φ(x)=[2] by surjectivity, then xx=0 by injectivity, contradicting the absence of zero divisors in F. A solution that instead takes x with φ(x)=[1] by surjectivity and uses x+x=0 in F (from the addition table) to get [0]=φ(0)=φ(x+x)=[1]+[1]=[2] earns these 2 points; φ(0)=[0] still earns the line above.

Fatal errors (0 for the step): “F is Z/4Z because both have four elements”; using in (c) that Z/4Z is a field. A solution of (b) that checks (F5) and (F9) by listing all 64 triples from the tables earns the same points.

By Theorem 2.2.2, Z/4Z is not a field, so a field with four elements cannot be found among the rings Z/nZ; part (c) shows that F is not even a disguised copy of Z/4Z. Chapter 5 builds this field again, from polynomials over F2, and explains where the rule α2=1+α comes from.

Exercise (C2: Find the error)

Here is a claim with a proof.

Claim. Let p be a prime. Then Z/pZ is a field.

Proof. (1) By Example (Arithmetic on Z/nZ and the Field F2), only (F8) needs checking. (2) Let [a]≠[0]; then a≠0. (3) Put [a]−1:=[1/a]. (4) Then [a][1/a]=[a⋅(1/a)]=[1]. (5) So every non-zero class has an inverse, and Z/pZ is a field.

Is the claim true? Does the proof prove it? If not, name the line that fails, the error, and give a counterexample to the step.

Solution. The claim is true: it is Theorem 2.2.2, direction (⇐).

The proof is wrong, at line (3), and line (4) inherits the fault. The classes of Z/pZ are classes of integers, and “[1/a]” names a class only when 1/a is an integer, that is, when a=1 or a=−1. The rule [x][y]=[xy] of Number Systems: From N to R, Definition 3.4.2 is stated for integers x,y only; line (4) applies it to the non-integer 1/a, a general “fact” that no result supplies. This is entry (N9) of Logic and Proof, Example (What is not allowed): citing a line that is not available. The proof also never uses that p is prime, a sign that something is wrong: the same lines would “prove” that Z/6Z is a field.

A counterexample to the step: p=5, a=2. Then 1/2∉Z, so [1/2] is not an element of Z/5Z. (The inverse of [2] exists, but it is [3], which line (3) does not produce.)

A repair: since p is prime and p∤a, the only positive common divisor of a and p is 1; Lemma 2.2.1 gives ax+py=1, and then [a][x]=[ax]=[1], because p∣ax−1.

Exercise (C3)

Find all solutions of x2+x+1=0 in F2, in F3 and in F7.

Solution. Each field is finite, so we can test every element; this finds all solutions.

In F2: the values at x=0,1 are 1 and 3=1. No solution.

In F3: the values at x=0,1,2 are 1, 3=0 and 7=1. The only solution is x=1.

In F7: the values at x=0,1,…,6 are the remainders of 1,3,7,13,21,31,43 on division by 7, namely 1,3,0,6,0,3,1. The solutions are x=2 and x=4, since 7=1⋅7 and 21=3⋅7.

The three answers differ in number (none, one, two), although the equation looks the same. Section 2.5 returns to this equation with completing the square, which needs 1+1 to be invertible: it is in F3 and F7, and it is not in F2.