Module 2 — Congruences & Primitive Roots¶
Congruence¶
Definition. Given integers \(a, b, m\) with \(m > 0\), we say that \(a\) is congruent to \(b\) modulo \(m\), and write \(a \equiv b \pmod m\), if \(m \mid a - b\).
Examples.
-
\(19 \equiv 7 \pmod{12}\); \(\ 1 \equiv -1 \pmod 2\).
-
\(n \equiv 0 \pmod 2\) if \(n\) is even; \(n \equiv 1 \pmod 2\) if \(n\) is odd.
-
\(a \equiv b \pmod 1\) for all \(a, b \in \mathbb{Z}\).
-
\(a \equiv b \pmod m\) \(\Rightarrow a \equiv b \pmod d\) for \(d \mid m\).
-
\(a \equiv 0 \pmod m \iff m \mid a\); \(\ a \equiv b \pmod m\) \(\iff a - b \equiv 0 \pmod m\).
When \(a \not\equiv b \pmod m\), we say \(a\) and \(b\) are incongruent mod \(m\).
Lemma
Congruence modulo \(m\) is an equivalence relation on \(\mathbb{Z}\).
Proof.
-
Reflexive: \(a \equiv a \pmod m\) for all \(a \in \mathbb{Z}\).
-
Symmetric: \(a \equiv b \pmod m\) \(\Rightarrow m \mid a - b\) \(\Rightarrow m \mid b - a\) \(\Rightarrow b \equiv a \pmod m\).
-
Transitive: \(a \equiv b \pmod m\) and \(b \equiv c \pmod m\) \(\Rightarrow m \mid a - b\) and \(m \mid b - c\) \(\Rightarrow m \mid (a - b) + (b - c)\) \(\Rightarrow a \equiv c \pmod m\). \(\blacksquare\)
Thus the equivalence relation yields a partition of \(\mathbb{Z}\). Each of the parts is called a residue class. For \(a \in \mathbb{Z}\), the residue class of \(a\) is denoted by \(\bar a\).
Lemma
There exist exactly \(m\) distinct residue classes, given by \(\bar 0, \bar 1, \ldots, \overline{m-1}\).
Proof. If \(0 \le a, b \le m - 1\) and \(a \ne b\), then \(m \nmid a - b\) \(\Rightarrow a \not\equiv b \pmod m\). So all the residue classes \(\bar 0, \bar 1, \ldots, \overline{m-1}\) are distinct.
Now suppose \(a \in \mathbb{Z}\). By the division algorithm, \(a = qm + r\) where \(0 \le r < m\), so \(a \equiv r \pmod m\) \(\Rightarrow \bar a = \bar r\) (the classes \(\bar a\) and \(\bar r\) are the same), i.e. \(\bar a \in \{\bar 0, \bar 1, \ldots, \overline{m-1}\}\). This finishes the proof. \(\blacksquare\)
Denote the set \(\{\bar 0, \bar 1, \ldots, \overline{m-1}\}\) by \(\mathbb{Z}_m\) or \(\mathbb{Z}/m\mathbb{Z}\). Then \(\mathbb{Z}_m\) is an abelian group under the operation \(\bar a + \bar b = \overline{a + b}\).
Proposition
Let \(a \equiv b \pmod m\) and \(\alpha \equiv \beta \pmod m\). Then
-
\(ax + \alpha y \equiv bx + \beta y \pmod m\).
-
\(a\alpha \equiv b\beta \pmod m\).
-
\(a^n \equiv b^n \pmod m\) for all \(n \ge 1\).
-
\(f(a) \equiv f(b) \pmod m\) when \(f(x) \in \mathbb{Z}[x]\).
Proof. Exercise.
Linear Congruence and Chinese Remainder Theorem¶
Motivation. Given \(f(x) \in \mathbb{Z}[x]\), we are interested in finding integer solutions to \(f(x) = 0\). But this is difficult in general. Instead, if we consider \(f(x)\) in \(\mathbb{Z}_m[x]\) and ask for solutions in \(\mathbb{Z}_m\) to \(f(x) = 0\), it is relatively easier, as \(\mathbb{Z}_m\) is a finite set.
-
If \(f\) has a solution in \(\mathbb{Z}\), then \(f\) has a solution in \(\mathbb{Z}_m\) for every \(m\).
-
Thus \(f(x) = 0\) in \(\mathbb{Z}_m[x]\) gives information about local solutions (centered at \(m\)).
-
This turns an infinite problem into a sequence of finite problems. This is a "global to local" viewpoint.
Linear congruences are of the form \(ax \equiv b \pmod m\), or equivalently \(ax = b\) in \(\mathbb{Z}_m[x]\). Our interest is to find solutions of \(ax - b = 0\) in \(\mathbb{Z}_m\).
Example. \(2x \equiv 3 \pmod 4\) has no solution, as \(2x - 3\) is odd for every value of \(x\), so \(4 \nmid 2x - 3\).
Theorem
Let \(\gcd(a, m) = 1\). Then the equation \(ax \equiv b \pmod m\) has exactly one solution in \(\mathbb{Z}_m\).
Proof. \(\mathbb{Z}_m = \{\bar 0, \bar 1, \ldots, \overline{m-1}\}\). Since \(\gcd(a, m) = 1\), \(\mathbb{Z}_m = \{\bar 0, \bar a, \ldots, \overline{a(m-1)}\}\) (by an exercise in the assignment). Since \(\bar b \in \mathbb{Z}_m\), there exists a unique \(\bar r \in \mathbb{Z}_m\) such that \(\bar a \bar r = \bar b\). So \(\bar r\) is the unique solution to \(ax \equiv b \pmod m\). \(\blacksquare\)
Theorem
Let \(d = \gcd(a, m)\). Then the equation \(ax \equiv b \pmod m\) has a solution if and only if \(d \mid b\). Furthermore, in this case, the equation has exactly \(d\) incongruent solutions.
Proof. Solving \(ax \equiv b \pmod m\) \(\iff\) solving \(ax - b = my\) \(\iff\)
So \(ax \equiv b \pmod m\) has a solution \(\iff\) (1) has a solution \(\iff d \mid b\).
If \((x_0, y_0)\) is a particular solution to (1), then all the solutions are given by
Thus for any \(t \in \mathbb{Z}\), \(\overline{x_0 + \frac{m}{d} t}\) is a solution to \(ax \equiv b \pmod m\).
Claim: \(S = \left\{\overline{x_0 + \frac{m}{d} t} \;\middle|\; 0 \le t < d\right\}\) is the complete set of solutions of \(ax \equiv b \pmod m\).
-
If \(t \ge d\), write \(t = dq + r\) with \(0 \le r < d\). Then
\[x_0 + \frac{m}{d} t \equiv x_0 + mq + \frac{m}{d} r \equiv x_0 + \frac{m}{d} r \pmod m,\]which lies in \(S\).
-
If \(0 \le t_1, t_2 < d\) with \(t_1 \ne t_2\), then \(x_0 + \frac{m}{d} t_1\) and \(x_0 + \frac{m}{d} t_2\) are incongruent modulo \(m\). Indeed,
\[x_0 + \tfrac{m}{d} t_1 \equiv x_0 + \tfrac{m}{d} t_2 \pmod m \Rightarrow \tfrac{m}{d} t_1 \equiv \tfrac{m}{d} t_2 \pmod m \Rightarrow t_1 \equiv t_2 \pmod d \Rightarrow t_1 = t_2,\]a contradiction. (Apply the cancellative law with \(\gcd(m, \frac{m}{d}) = \frac{m}{d}\).)
This completes the proof. \(\blacksquare\)
Example. \(18x \equiv 30 \pmod{42}\). Here \(\gcd(18, 42) = 6\) and \(6 \mid 30\), so the equation has a solution. Using the Euclidean algorithm, check that \(x = 4\) is a solution. Then \(\{4 + 7t \mid 0 \le t < 6\}\) is the complete set of solutions.
Remark
The particular solution \(x_0\) is also a solution to \(\frac{a}{d} x \equiv \frac{b}{d} \pmod{\frac{m}{d}}\); i.e., \(x \equiv x_0 \pmod{\frac{m}{d}}\) is the unique solution to \(\frac{a}{d} x \equiv \frac{b}{d} \pmod{\frac{m}{d}}\).
Systems of linear congruences¶
Suppose we want to solve the system of linear congruences
The system admits no solution unless each individual congruence is solvable. Let \(d_k = \gcd(a_k, m_k)\) with \(d_k \mid b_k\). This leads us to solve the system
where \(n_k = \dfrac{m_k}{d_k}\).
Now consider the situation where \(n_1, \ldots, n_r\) are not pairwise prime; WLOG assume \(\gcd(n_1, n_2) = d_{12} > 1\). Then a common solution of \(x \equiv c_1 \pmod{n_1}\), \(x \equiv c_2 \pmod{n_2}\) will be a solution to \(x \equiv c_1 \pmod{d_{12}}\) and \(x \equiv c_2 \pmod{d_{12}}\), so \(c_1 \equiv c_2 \pmod{d_{12}}\). This is a strong condition on the system \((*)\).
The situation is better if we assume \(d_{12} = 1\), i.e. all of \(n_1, \ldots, n_r\) are pairwise coprime. Thus we have the following system of linear congruences:
with \(\gcd(n_i, n_j) = 1\) for \(i \ne j\).
Chinese Remainder Theorem
The system of linear congruences \((**)\) has a solution, and the solution is unique modulo \(n_1 \cdots n_r\).
Construction of the solution. Let \(n = n_1 n_2 \cdots n_r\) and \(N_k = \dfrac{n}{n_k}\).
-
Clearly \(N_k x \equiv 1 \pmod{n_k}\) has a unique solution, say \(x_k\); i.e. \(N_k x_k \equiv 1 \pmod{n_k}\) \(\Rightarrow c_k N_k x_k \equiv c_k \pmod{n_k}\).
-
Let \(x = c_1 N_1 x_1 + \cdots + c_r N_r x_r\). Then \(x \equiv c_k N_k x_k \equiv c_k \pmod{n_k}\) for each \(k\).
-
Therefore \(x \pmod{n_1 \cdots n_r}\) is the unique solution to \((**)\).
Example. Solve
Solution. \(n = 3 \cdot 5 \cdot 7 = 105\); \(N_1 = 35\), \(N_2 = 21\), \(N_3 = 15\). Now we solve:
| Congruence | Solution |
|---|---|
| \(35x \equiv 1 \pmod 3\) | \(x_1 = 2\) |
| \(21x \equiv 1 \pmod 5\) | \(x_2 = 1\) |
| \(15x \equiv 1 \pmod 7\) | \(x_3 = 1\) |
So
Therefore the system has the unique solution \(233 \equiv 23 \pmod{105}\).
Fermat's Little Theorem¶
Theorem (Euler–Fermat)
If \(\gcd(a, m) = 1\), then \(a^{\varphi(m)} \equiv 1 \pmod m\).
Proof. Let \(S = \{\bar k \in \mathbb{Z}_m \mid \gcd(k, m) = 1\}\). Then
Thus if \(S = \{\bar k_1, \ldots, \bar k_{\varphi(m)}\}\), then \(S = \{\overline{ak_1}, \ldots, \overline{ak_{\varphi(m)}}\}\). Multiplying out both descriptions of \(S\), with \(P = k_1 k_2 \cdots k_{\varphi(m)}\):
Since \(\gcd(P, m) = 1\), we can cancel \(P\) to get \(a^{\varphi(m)} \equiv 1 \pmod m\). \(\blacksquare\)
Corollary. Let \(p\) be a prime. Then
-
If \(p \nmid a\), then \(a^{p-1} \equiv 1 \pmod p\).
-
\(a^p \equiv a \pmod p\) for all \(a \in \mathbb{Z}\).
Corollary. If \(\gcd(a, m) = 1\), then the solution to \(ax \equiv b \pmod m\) is given by
Exercise.
-
Solve \(5x \equiv 3 \pmod{24}\).
-
Solve \(25x \equiv 15 \pmod{120}\).
Polynomial Congruence modulo \(p\)¶
Let
Call this polynomial \((*)\).
Our interest is to find solutions of \(f(x) \equiv 0 \pmod p\), where \(p\) is a prime.
Theorem (Lagrange)
Let \(p\) be a prime and \(f\) a polynomial as in \((*)\) such that \(p \nmid c_n\) (\(\iff c_n \not\equiv 0 \pmod p\)). Then the equation \(f(x) \equiv 0 \pmod p\) has at most \(n\) solutions modulo \(p\).
Corollary. If \(f\), as in \((*)\), is a polynomial of degree \(n\) and if \(f(x) \equiv 0 \pmod p\) has more than \(n\) solutions, then \(p \mid c_i\) for \(0 \le i \le n\).
Corollary. Let \(p\) be a prime number and \(d \mid p - 1\). Then \(x^d \equiv 1 \pmod p\) has exactly \(d\) solutions in \(\mathbb{Z}_p\).
Proof. Let \(p - 1 = dk\). Then
where
-
\(x^{p-1} - 1 \equiv 0 \pmod p\) has exactly \(p - 1\) solutions in \(\mathbb{Z}_p\).
-
\(f(x) \equiv 0 \pmod p\) has at most \(d(k-1)\) roots.
-
So \(x^d \equiv 1 \pmod p\) has at least \((p - 1) - d(k - 1) = d\) roots.
-
By Lagrange's theorem, \(x^d \equiv 1 \pmod p\) has exactly \(d\) roots in \(\mathbb{Z}_p\). \(\blacksquare\)
Theorem
For any prime \(p\), all the coefficients of
are divisible by \(p\).
Proof. Let \(g(x) = (x-1)(x-2)\cdots(x-p+1)\) and \(h(x) = x^{p-1} - 1\). Then \(f(x) = g(x) - h(x)\).
-
By Fermat's little theorem, \(\bar 1, \bar 2, \ldots, \overline{p-1}\) are solutions to \(h(x) \equiv 0 \pmod p\).
-
Evidently, \(\bar 1, \bar 2, \ldots, \overline{p-1}\) are solutions to \(g(x) \equiv 0 \pmod p\).
-
So \(\bar 1, \bar 2, \ldots, \overline{p-1}\) are solutions to \(f(x) \equiv 0 \pmod p\). But the degree of \(f\) is \(< p - 1\). Now apply the above corollary. \(\blacksquare\)
Wilson's Theorem
For any prime \(p\), \((p - 1)! \equiv -1 \pmod p\).
Proof. The constant term of \(f\), as in the previous theorem, is \((p - 1)! + 1\). By the above theorem, \((p - 1)! \equiv -1 \pmod p\). \(\blacksquare\)
Primitive Roots¶
By Fermat's theorem we know that if \(\gcd(a, n) = 1\), then \(a^{\varphi(n)} \equiv 1 \pmod n\).
Definition. Let \(n > 1\) and \(\gcd(a, n) = 1\). The order of \(a\) modulo \(n\) is the smallest positive integer \(k\) such that \(a^k \equiv 1 \pmod n\).
Remark
In the above definition, the condition \(\gcd(a, n) = 1\) is necessary. (Why?)
Proposition
Assume \(\gcd(a, n) = 1\) and \(a\) has order \(k\) modulo \(n\). Then \(a^h \equiv 1 \pmod n\) if and only if \(k \mid h\). In particular, \(k \mid \varphi(n)\).
Proof. By the division algorithm, \(h = kq + r\) with \(0 \le r < k\). Then
Corollary. If \(a\) has order \(k\) modulo \(n\), then \(a^i \equiv a^j \pmod n\) \(\iff i \equiv j \pmod k\).
Proof. For \(i \ge j\): \(a^i \equiv a^j \pmod n\) \(\iff a^{i-j} \equiv 1 \pmod n\) \(\iff k \mid i - j\) \(\iff i \equiv j \pmod k\). \(\blacksquare\)
Corollary. If \(a\) has order \(k\) modulo \(n\), then the integers \(a, a^2, \ldots, a^k\) are incongruent modulo \(n\).
Proof. For \(1 \le i, j \le k\): \(a^i \equiv a^j \pmod n\) \(\iff k \mid i - j\) \(\iff i = j\). \(\blacksquare\)
Proposition
If the integer \(a\) has order \(k\) modulo \(n\) and \(h > 0\), then \(a^h\) has order \(\dfrac{k}{\gcd(h, k)}\) modulo \(n\).
Proof. Let \(d = \gcd(h, k)\), so \(h = dh_1\), \(k = dk_1\) with \(\gcd(h_1, k_1) = 1\).
-
\((a^h)^{k_1} = a^{dh_1 k_1} \equiv (a^k)^{h_1} \equiv 1 \pmod n\). Let \(a^h\) have order \(r\) modulo \(n\); then \(r \mid k_1\).
-
Now \((a^h)^r \equiv 1 \pmod n\) \(\Rightarrow k \mid hr\) \(\Rightarrow dk_1 \mid dh_1 r\) \(\Rightarrow k_1 \mid h_1 r\) \(\Rightarrow k_1 \mid r\) (since \(\gcd(h_1, k_1) = 1\)).
-
Therefore \(r = k_1\). \(\blacksquare\)
Corollary. Let \(a\) have order \(k\) modulo \(n\). Then \(a^h\) has order \(k \iff \gcd(h, k) = 1\).
Definition. If \(\gcd(a, n) = 1\), we say \(a\) is a primitive root of \(n\) if \(a\) has order \(\varphi(n)\) modulo \(n\).
Example. 3 is a primitive root of 7.
Theorem
Let \(\gcd(a, n) = 1\), and let \(a_1, \ldots, a_{\varphi(n)}\) be the positive integers less than \(n\) and relatively prime to \(n\). If \(a\) is a primitive root of \(n\), then
Proof. \(\gcd(a^i, n) = 1\) for all \(i \ge 1\), so \(\bar a^i \in \{\bar a_1, \ldots, \bar a_{\varphi(n)}\}\) for all \(i \ge 1\). Since \(\bar a, \bar a^2, \ldots, \bar a^{\varphi(n)}\) are incongruent, i.e. \(\bar a^i \ne \bar a^j\) for \(1 \le i < j \le \varphi(n)\),
Corollary. If \(n\) has a primitive root, then the total number of primitive roots is \(\varphi(\varphi(n))\).
Theorem
If \(p\) is a prime number and \(d \mid p - 1\), then there are exactly \(\varphi(d)\) incongruent integers having order \(d\) modulo \(p\).
Proof. Let \(\psi(d)\) be the number of \(k\) with \(1 \le k \le p - 1\) such that \(k\) has order \(d\) modulo \(p\). Then
and by Gauss,
Therefore
It is enough to show that
-
For \(d \mid p - 1\), if \(\psi(d) = 0\), then (T) is true.
-
If \(\psi(d) \ne 0\), there exists \(a\) with \(1 \le a \le p - 1\) such that the order of \(a\) is \(d\). Then \(a\) is a solution to \(x^d \equiv 1 \pmod p\), and clearly \(a, a^2, a^3, \ldots, a^d\) are all distinct solutions to \(x^d \equiv 1 \pmod p\).
-
Therefore, by a corollary to Lagrange's theorem, \(\{a, a^2, \ldots, a^d\}\) is the solution set of the equation \(x^d \equiv 1 \pmod p\).
-
Since \(a\) has order \(d\) mod \(p\), \(a^i\) has order \(d\) mod \(p\) iff \(\gcd(i, d) = 1\). So in the set \(\{a, a^2, \ldots, a^d\}\) there are exactly \(\varphi(d)\) elements having order \(d\), i.e. \(\psi(d) = \varphi(d)\).
The claim is proved. \(\blacksquare\)
Corollary. If \(p\) is a prime, then there are exactly \(\varphi(p - 1)\) incongruent primitive roots of \(p\).