Chapter 4
Chapter 4
In this chapter we develop basic algebraic notions and facts to the extent
needed for the applications in this book. Equally important are the examples
for such structures from number theory. At the center of attention are basic
facts from group theory, especially about cyclic groups, which are central in
the analysis of the deterministic primality test. We discuss (commutative)
rings (with 1), with the central example being Zm . Finally, we develop the
basic facts about finite fields, in particular we establish that in finite fields
the multiplicative group is cyclic.
M. Dietzfelbinger: Primality Testing in Polynomial Time, LNCS 3000, pp. 55-71, 2004.
Springer-Verlag Berlin Heidelberg 2004
56 4. Basics from Algebra: Groups, Rings, and Fields
Example 4.1.2. (a) The set Z with integer addition as operation and 0 as
neutral element is a group.
(b) For each positive integer m, the set mZ = {m · z | z ∈ Z} of all multiples
of m, with integer addition as operation and 0 as neutral element, is a
group.
(c) For each integer n > 1 the set Zn = {0, 1, . . . , n − 1} with addition
modulo n as operation and 0 as neutral element is a group. (See Defini-
tion 3.3.1.) The set {0} with the operation 0 ◦ 0 = 0 also is a group (the
trivial group).
(d) For each integer n > 1 the set Z∗n = {a | 0 ≤ a < n, gcd(a, n) = 1}
with multiplication modulo n and 1 as neutral element is a group. (See
Definition 3.3.7 and Example 3.3.9.)
(e) Let S be an arbitrary set, and consider the set Bij(S) of all bijective
mappings f : S → S. The operation ◦ denotes the composition of mappings
(i.e., f ◦ g(x) = f (g(x)) for all x ∈ S, f, g ∈ G). Then (Bij(S), ◦, idS ) forms
a group, with idS : S x → x ∈ S, the identity map, as neutral element.
(f) Let GLn (Q) denote the set of all invertible n×n-matrices over the field Q
of rational numbers. Let ◦n denote the multiplication of such matrices, and
let In denote the n × n identity matrix (1 on all positions of the diagonal,
0 everywhere else). Then (GLn (Q), ◦n , In ) is a group.
Notation: In the cases (a), (b), and (c), the group operation is written as
“+” or +m , and the neutral element as 0.
For small groups, we may describe the group operation by writing down
or storing a table with rows and columns indexed by the elements of G, the
element in row a and column b being a ◦ b. For example, the group table of
(Z∗9 , ·9 , 1) looks as follows.
·9 1 2 4 5 7 8
1 1 2 4 5 7 8
2 2 4 8 1 5 7
4 4 8 7 2 1 5
5 5 1 2 7 8 4
7 7 5 1 8 4 2
8 8 7 5 4 2 1
there are elements a, b ∈ G with a◦b = b◦a. For example, in Example 4.1.2(d)
(set of bijections from S to S) there are such elements as soon as |S| ≥ 3;
in Example 4.1.2(e) (invertible matrices) there are such elements as soon as
n ≥ 2. In this book, though, we will be dealing exclusively with groups in
which such a thing does not occur.
Definition 4.1.3. We say a group (G, ◦, e) is commutative or abelian if
a ◦ b = b ◦ a for all a, b ∈ G.
The groups from Example 4.1.2(a), (b), and (c) are abelian. In abelian
groups, in expressions involving elements of G and the operation ◦, we may
change the order arbitrarily without affecting the result.
We list some facts that hold for all groups, commutative or not, and follow
easily from the definitions.
Proposition 4.1.4. (a) In a group, there is exactly one neutral element
(called e or 1 from here on).
(b) For each element a of a group G, there is exactly one b ∈ G such that
a ◦ b = b ◦ a = e. (This element is denoted a−1 from here on.)
(c) (Cancellation rule) If a ◦ c = b ◦ c, then a = b. Likewise, if c ◦ a = c ◦ b,
then a = b.
Proof. (a) If e and e are neutral elements, i.e., satisfy (ii) from Defini-
tion 4.1.1, then we get e = e ◦ e = e by using first that e is neutral and then
that e is neutral.
(b) If b and b are inverse to a, i.e. satisfy (iii) from Definition 4.1.1, then we
get
b = b ◦ e = b ◦ (a ◦ b ) = (b ◦ a) ◦ b = e ◦ b = b ,
by using in addition that e is neutral and associativity.
(c) Assume a ◦ c = b ◦ c. Then, by associativity,
a = a ◦ (c ◦ c−1 ) = (a ◦ c) ◦ c−1 = (b ◦ c) ◦ c−1 = b ◦ (c ◦ c−1 ) = b.
In the other case, we multiply with c−1 from the left.
Let a ∈ G, and consider a−1 . Since a ◦ a−1 = a−1 ◦ a = e, a is the inverse
of a−1 , in short (a−1 )−1 = a.
Notation: In the situation of Example 4.1.2(a), (b), and (c), where we use
additive notation for the groups, the inverse of a is denoted by −a. Thus,
a + (−a) = (−a) + a = 0. For a + (−b) we write a − b.
Definition 4.1.5. Let (G, ◦, e) be a group. A set H ⊆ G is called a subgroup
of G if H together with the operation ◦ and the neutral element inherited from
(G, ◦, e) forms a group. More exactly, we require that
(i) e ∈ H,
(ii) a ◦ b ∈ H for all a, b ∈ H,
(iii) a−1 ∈ H for all a ∈ H.
58 4. Basics from Algebra: Groups, Rings, and Fields
Note that the condition that G is finite is necessary to draw this conclu-
sion, since, for example, N is a subset of Z that contains 0 and is closed under
addition, but N is not a subgroup of (Z, +, 0).
fa : H → H, b → a ◦ b,
a ∼H b , if b−1 ◦ a ∈ H.
gb : [b]H → G, a → b−1 ◦ a.
By the very definition of [b]H and of ∼H we have that gb (a) ∈ H for all
a ∈ [b]H . We show that actually gb maps [b]H one-to-one onto H: Every c ∈ H
occurs in the image gb ([b]H ), since b ◦ c ∈ [b]H and gb (b ◦ c) = c. Further, gb
is one-to-one, since gb (a) = gb (a ) implies a = b ◦ gb (a) = b ◦ gb (a ) = a .
4.2 Cyclic Groups 59
◦ ·
ai = a · · ◦ a and a−i = a −1
· · ◦ a−1 ,
◦ ·
i times i times
By using associativity and the fact that we can interchange a and b, this can
be transformed into a ◦ · · · ◦ a ◦ b ◦ · · · ◦ b = ai ◦ bi . Now we turn to the case
of negative exponents. Note first that (b ◦ a) ◦ (a−1 ◦ b−1 ) = e, which means
that (a ◦ b)−1 = (b ◦ a)−1 = a−1 ◦ b−1 . By symmetry, (b ◦ a)−1 = b−1 ◦ a−1 ,
which means that also a−1 ◦ b−1 = b−1 ◦ a−1 . Thus, for i = −k < 0, we may
apply our result for positive exponents to get
(a ◦ b)i = ((a ◦ b)−1 )k = (a−1 ◦ b−1 )k = (a−1 )k ◦ (b−1 )k = ai ◦ bi ,
as desired.
Note that (b) in particular says that ai ◦ aj = aj ◦ ai for all integers i
and j, so among arbitrary powers of a we have commutativity. Because they
are so natural, the rules listed in Lemma 4.2.1 will be used without further
comment in what follows.
Proposition 4.2.2. Let (G, ◦, e) be a group. For a ∈ G define
a = {ai | i ∈ Z} = {e, a, a−1 , a2 , (a−1 )2 , a3 , (a−1 )3 , . . . }.
Then a is a (commutative) subgroup of G and it contains a. In fact, it
is the smallest subgroup of G with this property. (It is called the subgroup
generated by a.)
4.2 Cyclic Groups 61
·9 1 5 7 8 4 2
1 1 5 7 8 4 2
5 5 7 8 4 2 1
7 7 8 4 2 1 5
8 8 4 2 1 5 7
4 4 2 1 5 7 8
2 2 1 5 7 8 4
Table 4.2. A group operation table of a cyclic group. The group operation is
multiplication modulo 9 on the set {1, 2, 4, 5, 7, 8}
Although we do not prove it here, it is a fact that all groups Z∗p , where p
is an odd prime number, are cyclic.
(d) The set Ur of “rth roots of unity” in the field C is the set of all solutions
of the equation xr = 1 in C. It is well known that
3
i=ζ
4
ζ ζ
2
5 ζ
ζ
6 0 12
ζ 1= ζ = ζ
0
11
ζ
7
ζ
8 10
ζ ζ
ζ9
Fig. 4.1. The cyclic group of the rth roots of unity in C, for r = 12
structure as (Z, +, 0), the finite ones have the structure of some (Zm , +, 0).
In this text, only finite groups are relevant.
Proof. (a) Assume that all ai , i ∈ Z, are different. Then the mapping i → ai
is a bijection between Z and a. That it is also an isomorphism between
(Z, +, 0) and (a, ◦, e), i.e., that 0 is mapped to e and i + j to ai ◦ aj and −i
to (ai )−1 , corresponds to the rules in Lemma 4.2.1(a) and (b).
(b) Assume that ai = aj for i < j. Then for k = j − i > 0 we have ak =
aj+(−i) = aj ◦ (aj )−1 = e. Now for ∈ Z arbitrary, we may write = qk + r
for some integer q and some r with 0 ≤ r < k, by Proposition 3.1.8. Hence
a = aqk ◦ ar = (ak )q ◦ ar = eq ◦ ar = e ◦ ar = ar .
This implies a = {a0 , a1 , . . . , ak−1 }, hence |a| ≤ k. (Warning: In the list
a0 , . . . , ak−1 there may be repetitions, so k need not be the order of a.)
Proposition 4.2.7. Let (G, ◦, e) be a group, and let a ∈ G with ordG (a) =
m, for some m ≥ 1. Then the following holds:
(a) a = {e, a, a2 , . . . , am−1 }.
(b) ai = aj if and only if m | j − i. (This implies that ai = ai mod m for all
i ∈ Z.)
(c) The group a is isomorphic to Zm = {0, . . . , m−1} with addition modulo
m via the mapping i → ai , i ∈ Zm . In particular, (ai )−1 = am−i .
Proof. (a) In Lemma 4.2.6(b) we have seen that if i < j and ai = aj then
ordG (a) ≤ j − i. This implies that the elements a0 , a1 , . . . , am−1 must be
different, and hence must exhaust a.
(b) By (a), we have am ∈ {a0 , . . . , am−1 }. If am were equal to ai for some i,
1 ≤ i < m, then by Lemma 4.2.6(b) we would have ordG (a) ≤ m − i < m,
which is impossible. Hence am = a0 = e. Now if j −i = mq, then ai = ai ◦eq =
ai ◦ (am )q = ai ◦ amq = ai+mq = aj . Conversely, assume that ai = aj . Then
aj−i = e = a0 . Find q and r, 0 ≤ r < m, with j − i = mq + r. Then
e = aj−i = amq+r = (am )q ◦ ar = eq ◦ ar = ar . Since a0 = e and a0 , . . . , am−1
are distinct, this implies that r = 0, which means that j − i = mq.
(c) By (a), the mapping h : {0, . . . , m − 1} i → ai ∈ a is a bijection.
Clearly, a0 = e. Now assume 0 ≤ i, j < m. Then a(i+j) mod m = ai+j = ai ◦aj ,
by (b). Finally, the inverse of i in Zm is m − i, and ai ◦ am−i = am = e, by
(b). Hence (am )−1 = am−i .
For later use, we note two simple, but important consequences of this
proposition.
64 4. Basics from Algebra: Groups, Rings, and Fields
Proof. Apply Proposition 4.2.8 to the finite group Z∗m , which has cardinality
ϕ(m).
If m = p is a prime number, we have Z∗p = {1, 2, . . . , p − 1}, a set with
p − 1 elements, and the previous theorem turns into the following.
Now we have understood the structure of finite cyclic groups (they look like
some Zm ), we gather more information by analyzing their subgroup structure
and the order of their elements. By Proposition 4.1.9 we know that if G is a
finite cyclic group and H is a subgroup of G, then |H| is a divisor of |G|. We
will see that indeed there is exactly one subgroup of size d for each divisor d
of m.
(c) Since m is a divisor of jzd for 0 ≤ j < d, we have (ajz )d = e for all
elements ajz ∈ H. Conversely, if bd = e, for b = ai , then aid = e, and hence
m is a divisor of id = im/z. This implies that i/z is an integer, and hence
that ai ∈ H, by (b).
We consider a converse of part (c) of Lemma 4.2.11.
Hs = {a ∈ G | as = e}
d 20/d Hd
1 20 {0}
2 10 {0, 10}
4 5 {0, 5, 10, 15}
5 4 {0, 4, 8, 12, 16}
10 2 {0, 2, 4, 6, 8, 10, 12, 14, 16, 18}
20 1 {0, 1, 2, 3, . . . , 19}
m | ki ⇔ m | ki ⇔ m | k,
Proof. We just have to check the basic rules of operation of modular addition
and multiplication:
– (a + b) mod m = (b + a) mod m.
– ((a + b) mod m + c) mod m = (a + (b + c) mod m) mod m.
– Existence of inverses: (a + (m − a)) mod m = 0.
– (a + 0) mod m = (0 + a) mod m = a.
– (a · b) mod m = (b · a) mod m.
– (((a · b) mod m) · c) mod m = (a · (b · c) mod m) mod m.
– (a · 1) mod m = (1 · a) mod m = a.
– (a · (b + c) mod m) mod m = ((a · b mod m) + (a · c mod m)) mod m.
The straightforward proofs are left to the reader.
Example 4.3.6. Some infinite fields are well known, viz., the rational num-
bers Q, the real numbers R, and the complex numbers C, with the standard
operations.
In this book, however, finite fields are at the center of interest. The sim-
plest finite fields are obtained by considering Zp for a prime number p.
calculated using the Extended Euclidean Algorithm 3.2.4 (see the remarks
after Proposition 3.3.8).
We illustrate these observations by little numerical examples. Z12 =
{0, 1, . . . , 11} with arithmetic modulo 12 is not a field, since, for example,
3 · 4 = 12 ≡ 0 (mod 12), and hence {1, . . . , 11} is not closed under multipli-
cation. On the other hand, Z13 is a field. We find the multiplicative inverse of
6 by applying the Extended Euclidean Algorithm to 6 and 13, which shows
that (−2) · 6 + 1 · 13 = 1, from which we get that (−2) mod 13 = 11 is an
inverse of 6 modulo 13.
To close the section, we note that monoids really are the natural structures
in which to carry out fast exponentiation.
The analysis is exactly the same as that for Algorithm 2.3.3. On input a and
n it carries out no more than 2n = O(log n) multiplications of elements of
M , and the result is correct.
Of course, if the elements of M are structured elements (like polynomials),
then the total cost of carrying out Algorithm 4.3.9 is O(log n) multiplied with
the cost of one such multiplication.
In this section we shall establish the basic fact that the multiplicative groups
in finite fields are cyclic.
70 4. Basics from Algebra: Groups, Rings, and Fields
Now reduce these fractions to lowest terms, by dividing numerator and de-
nominator by their greatest common divisor:
1 1 1 1 5 1 7 2 3 5 11 1
12 , 6 , 4 , 3 , 12 , 2 , 12 , 3 , 4 , 6 , 12 , 1 ,
Combining (4.4.1) and (4.4.2) with the claim, we see that in fact none of the
Bd ’s can be empty. In particular Bq−1 = ∅, and each of the ϕ(q − 1) elements
g ∈ Bq−1 is a primitive element of F .
Corollary 4.4.4. If p is a prime number, then Z∗p is a cyclic group with
ϕ(p − 1) generators (called “primitive elements modulo p”).
Example 4.4.5. The ϕ(12) = 4 primitive elements modulo 13 are 2, 6, 7, and
11.
Definition 4.4.6. If p is a prime number, and n is an integer not divisible
by p, we write ordp (n) for ordZ∗p (n mod p), and call this number the order
of n modulo p.
Clearly, ordp (n) is the smallest i ≥ 1 that satisfies ni mod p = 1, and ordp (n)
is a divisor of |Z∗p | = p − 1.