The Chinese Remainder Theorem
Suppose we are asked to solve
for . Notice if we have a solution , then is also a solution, and in fact so is plus any mulitple of . So we only need to look for solutions modulo . By brute force, we find the only solution is .
For any system of equations like this, the Chinese Remainder Theorem not only tells us that there is a solution, but also that it is unique. Additonally, the theorem describes how to find the solution efficiently.
Theorem: Let be coprime. Then the system of equations
has a unique solution for modulo .
The reverse direction is trivial: given , we can reduce modulo and modulo to obtain two equations of the above form.
Proof: Let and . These must exist since are coprime. Then we claim that if is an integer such that
then satisfies both equations:
Modulo , we have since . Similarly . Thus is a solution for .
It remains to show no other solutions exist modulo . If then is a multiple of . If as well, then is also a multiple of . Since and are coprime, this implies is a multiple of , hence .
This theorem implies we can represent an element of by one element of and one element of , and vice versa. In other words, we have a bijection between and .
Examples: We can write as . We can write as .
In fact, this correspondence goes further than a simple relabelling. Suppose correspond to respectively. Then a little thought shows corresponds to , and similarly corresponds to .
A practical application: if we have many computations to perform on (e.g. RSA signing and decryption), we can convert to and do all the computations on and instead before converting back. This is often cheaper because for many algorithms, doubling the size of the input more than doubles the running time.
Example: To compute , we can compute in , and then apply the Chinese Remainder Theorem to find that is .
Let us restate the Chinese Remainder Theorem in the form it is usually presented.
For Several Equations
Theorem: Let be pairwise coprime (that is whenever ). Then the system of equations
has a unique solution for modulo where .
Proof: This is an easy induction from the previous form of the theorem, or we can write down the solution directly.
Define (the product of all the moduli except for ) and . Then by a similar argument to before,
is the unique solution.
Prime Powers First
An important consequence of the theorem is that when studying modular arithmetic in general, we can first study modular arithmetic a prime power and then appeal to the Chinese Remainder Theorem to generalize any results. For any integer , we factorize into primes and then use the Chinese Remainder Theorem to get
To prove statements in , one starts from , and inductively works up to . Thus the most important case to study is .