Lecture 8 - Chinese Remainder Theorem and Wilson's Theorem

Recap & Summary

Last class period we talked about solving linear congruence equations. Among other techniques, we discussed multiplicative inverses and how they can be used to help solve equations. Along the way we made the statement

$5x \equiv 2 \mod{67}$ if and only if $27\cdot 5x \equiv 27\cdot 2 \mod{67}$

We did this because 27 is the multiplicative inverse of 5. But recall that we have

Lemma: $cx \equiv cy \mod{m}$ if and only if $x \equiv y \mod{\frac{m}{(c,m)}}$.

In light of this result, our multiplication by 27 on both sides of the equivalence above requires that we have $(27,67) = 1$. We could have checked this by using the Euclidean Algorith, but we claim that we could instead prove

If b is the multiplicative inverse of a modulo m, then $(b,m) = 1$.

To see that this is true, notice that if b is the multiplicative inverse of a, then a must be the multiplicative inverse of b. Now since b has a multiplicative inverse modulo m, we know that we must have $(b,m) = 1$.

In today's class, we'll be discussing the Chinese Remainder Theorem and Wilson's Theorem. The former is a technique for finding simultaneous solutions to multiple congruence equations, whereas the latter is a congruence equation which characterizes primes.

# The Chinese Remainder Theorem

Recall that in the last class period we showed that the congruence equations

(1)
\begin{align} \begin{split} x &\equiv 1 \mod{2} \\ x &\equiv 2 \mod{3} \end{split} \end{align}

has integer solutions $x = -1,5,11,\cdots$. The way we came about these solutions was simply by using a "guess and check" technique. What we'd like to do is to develop a more systematic way of coming at this problem. For that, we have

The Chinese Remainder Theorem: If $m_1,\cdots,m_k$ are pairwise relatively prime integers, then the congruence equations $x \equiv a_i \mod{m_i}$ for each $1 \leq i \leq k$ have a unique solution modulo $\prod_{i=1}^k m_i$.

Proof: We'll break the proof into two pieces: first we'll construct a simultaneous solution to the given congruences, and then we'll show this solution is unique in the given modulus.

To start, we'll define $M = \prod_{j=1}^k m_j$, and for each $1 \leq i \leq k$ we'll write $N_i$ for $\frac{M}{m_i}$. Now since the $m_i$ are pairwise relatively prime, you showed in your homework (in the course of #43(c) in chapter 1) that $(N_i,m_i) = 1$. Hence for every i, there exists an integer $x_i$ which satisfies $N_ix_i \equiv 1 \mod{m_i}$.

With the $N_i,x_i$ so constructed, we claim that

(2)
\begin{align} x = N_1x_1a_1 + \cdots + N_kx_ka_k \end{align}

is a solution to all the congruences $x \equiv a_i \mod{m_i}$. To see this is true, fix an integer i, and we'll show that $x \equiv a_i \mod{m_i}$. Notice that for every $j \neq i$ we have $m_i \mid N_j$, since $N_j$ is the product of all the moduli except for $m_j$ — in particular, $m_i$ shows up in the product which defines N_j]]. Hence we have (3) \begin{align} x = N_1x_1a_1 + \cdots + N_kx_ka_k \equiv N_ix_ia_i \mod{m_i}. \end{align} But now recall thatN_ix_i \equiv 1 \mod{m_i}$, and so the previous equation becomes$x \equiv a_i \mod{m_i}$as desired. Hence we've constructed a solution. To show that all solutions are equivalent modulo$M = m_1\cdots m_k$, notice that if$x_0,x_1$are two solutions to the congruence equations, then we have$x_0 \equiv a_i \equiv x_1 \mod{m_i}$for every i/. It follows that$x_0 \equiv x_1 \mod{m_i}$for every i, and so$m_i \mid x_0 - x_1$. By homework 43(c) in Chapter 1, since the$m_i$are relatively prime we can conclude that$M = m_1\cdots m_k \mid x_0 - x_1$.$\square#### Example: CRT in Action Suppose that we're given the simultaneous congruences (4) \begin{align} \begin{split} x &\equiv 3 \mod{10}\\ x &\equiv 4 \mod{7}\\ x &\equiv 2 \mod{9}. \end{split} \end{align} Our proof of the CRT says that we need to start by computingN_1,N_2,N_3$, which in this case are given as$N_1 = 7\cdot 9 = 63$,$N_2 = 10 \cdot 9 = 90$and$N_3 = 10\cdot 7 = 70$. With these numbers in hand, we now need to solve the congruence equations$N_i x_i \equiv 1 \mod{m_i}$for each i. To solve$63x_1 \equiv 1 \mod{10}$, notice that$63 \equiv 3 \mod{10}$. Hence we're really trying to solve$3x \equiv 1 \mod{10}$. Now we could solve this equation by using the Euclidean Algorithm to express the gcd of 10 and 3 as a linear combination of the two, but since the modulus is so small, we can just use "guess and check" to find this inverse. For this, notice that$3\cdot 7 = 21$, and that$21 \equiv 1 \mod{10}$. Hence we have$x_1 = 7$. To solve$90x_2 \equiv 1 \mod{7}$, we'll do a similar trick: since$90 \equiv -1 \mod{7}$, we're really trying to solve$-x_2 \equiv 1 \mod{7}$. But this makes it clear that we can take$x_2 = -1$. Finally, we need to solve$70x_3 \equiv 1 \mod{9}$. Since$70 \equiv 7 \mod{9}$, we're trying to solve$7x_3 \equiv 1 \mod{9}$. Using "guess and check", we see that$x_3 = 4$is the solution we're after. Now that we've computed all the appropriate terms, our desired solution modulo$10 \cdot 7 \cdot 9 = 630is therefore (5) \begin{align} x = N_1x_1a_1 + N_2x_2a_2 + N_3x_3a_3 = 63 \cdot 7 \cdot 3 + 90 \cdot (-1)\cdot 4 + 70 \cdot 4 \cdot 2. \end{align} You can expand that out and see what its least non-negative residue is, but you don't need to if you don't want.\square$The Chinese Remainder Theorem is a really powerful tool for solving simultaneous congruences, but it only tells us how to solve problems where the given moduli are pairwise relatively prime. There are plenty of "real life" scenarios in which the moduli for your system of congruences won't be so nice, though, in which case it's handy to know this stronger version of the CRT: Strengthened Chinese Remainder Theorem: For arbitrary integers$m_1,\cdots,m_k$and congruence equations$x \equiv a_i \mod{m_i}$, there exists a simultaneous solution if and only if$(m_i,m_j) \mid a_i - a_j$for every$i \neq j$. When a solution exists, it is unique modulo the least common multiple of the$m_i. We won't worry about proving this for now, but it is good to have in mind. #### Example: The Strengthened CRT Suppose someone asks you to solve the simultaneous equations (6) \begin{align} \begin{split} x &\equiv 3 \mod{4}\\ x &\equiv 5 \mod{8}. \end{split} \end{align} Since you know that(4,8) = 4$and since$4 \nmid 5-3 = 2$, you know that this simultaneous system has no solutions. # Wilson's Theorem We'll end class today by discussing Wilson's Theorem. This shows us another reason that modular arithmetic is powerful: it gives a modular criterion for determining whether an integer is prime or not. The statement of the theorem is as follows: Wilson's Theorem: An integer n satisfies$(n-1)! \equiv -1 \mod{n}$if and only if n is prime. In order to prove the theorem, we'll start with the following Lemma: For a prime p, the only congruence classes which are their own inverses (modulo p) are$\pm 1$. That is to say, the only a such that$aa \equiv 1 \mod{p}$are those a which satisfy$a \equiv \pm 1 \mod{p}$. Proof: It isn't hard to see that if$a \equiv \pm 1 \mod{p}$, then we must have$a^2 \equiv 1 \mod{p}$. So suppose we're told that$a^2 \equiv 1 \mod{p}$, and we'll show that$a \equiv \pm 1 \mod{p}$. Notice that the congruence$a^2 \equiv 1 \mod{p}$means that$p \mid a^2 - 1= (a-1)(a+1)$. Euclid says that either$p \mid a-1$— in which case$a \equiv 1 \mod{p}$— or$p \mid a+1$— in which case$a \equiv -1 \mod{p}$. In either case, then, we get the desired conclusion.$\square$#### Example: The prime 11 To see why this is handy, let's compute the inverses of each congruence class modulo 11. These are given by The number Its Inverse mod 11 1 1 2 6 3 4 4 3 5 9 6 2 7 8 8 7 9 5 10 10 This means when I compute$(11-1)! = 10!modulo 11, I get (7) \begin{align} \begin{split} 1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 \cdot 6 \cdot 7 \cdot 8 \cdot 9 \cdot 10 &= 1 \cdot (2\cdot 6) \cdot (3 \cdot 4) \cdot (5 \cdot 9) \cdot (7 \cdot 8) \cdot 10 \\ &\equiv 1\cdot 1 \cdot 1 \cdot 1 \cdot 1 \cdot 10 \equiv -1 \mod{11}. \end{split} \end{align}\square$With this as our motivating example, we're ready to prove If p is prime, then [{$(p-1)! \equiv -1 \mod{p}]]. Proof: If p is prime, then we know that every integer between 1 and p-1 is relatively prime to p. We'll take the integers between 1 and p-1 and put them into groups by pairing a number a with its multiplicative inverse modulo p. According to our lemma, only 1 and -1 can't be paired with another (different) integer in this way. Hence we can rearrange the numbers between 2 and p-2 so that they sit in a sequence where every pair of numbers multiplies to 1 modulo p. Hence we have (8) \begin{align} (p-1)! \equiv 1 \cdot 2 \cdot \cdots \cdot (p-2) \cdot (p-1) \equiv 1 \cdot (p-1) \equiv -1 \mod{p}. \end{align}\square\$

Add a New Comment
page revision: 3, last edited: 18 Sep 2008 14:41
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License