The Chinese remainder theorem is about solutions to congruences so let’s review solutions to linear congruences.
This is solvable if and only \(b\) is divisible by \((a,m)\). Euclid’s algorithm can show this is sufficient. For example \(6x \equiv 7 \pmod{45}\) has no solutions since \((6,45) = 3\) but \(3 \not\mid 7\). On the other hand, \(6x \equiv 3 \pmod{45}\) has a solution since \((6,45) \mid 3\). How do we find the solution? \(6x \equiv 3 \pmod{45}\) implies that
We can now use Euclide’s algorithm to see that
So now \(8\) is a solution to the original equation but so is \(8+15, 8+30\) since we’re still okay module \(45\). Only when \((a,m) = 1\)m then the solution is unique and always exists. If \((a,m) > 1\), the solution might not exist or we might have many solution.
Polynomial Congruences
Suppose we want to solve a polynomial congruence such as
There are a few cases
- \(m\) is prime. This is easier since since if \((a,m) = 1\), then \(a\) has an inverse module \(m\)
- \(m=p^n\) is a prime power. This can be reduced to the first case (we will see this in a later lecture).
- \(m=p_1^{n_1}p_2^{n_2}\cdots\). We will reduce this to the case \(m = p^n\) using the Chinese Remainder Theorem (CRT).
In this lecture, we will study the reduction from case 3 to case 2.
System of Two Linear Congruences
Suppose we want to solve the following system of linear congruences
In general, to have a solution to this system we want \(m_1\) and \(m_2\) to be coprime. This solution is even unique when \(m_1\) and \(m_2\) are coprime. If they were not co-prime, then it’s not guaranteed. We could or could not have a solution.
Example
As an example, suppose we want to solve the following system of linear congruences
Here, we see that \((17,21) = 1\). So then we have
which simplifes to
By Euclid’s algorithm, \(-21z + 17y = 1\) has the solution \(z = 4, y = 5\). So now we can just double to get
System of Three Linear Congruences
Suppose now that we have more than two linear congruences. Then by CRT:
Proof
So let’s focus on the first two equations and instead of using Euclid’s algorithm, let’s define a map from the set of all numbers from \(0\) up to \(m_1m_2 - 1\) to the product set of the numbers from \(0\) to \(m_1\) and \(0\) to \(m_2\).
Given by
We claim that this is is a bijection. First we will show that \(f\) is injective. So suppose that \(f(x) = f(y)\), then we want to show that \(x = y\). Since \(f(x) = f(y)\), then
Therefore
But equations imply \(x - y\) is divisible by \(m_1\) and \(m_2\). But \(m_1\) and \(m_2\) are coprime so \(x-y\) must also be divisible by the product \(m_1m_2\) which means that
This implies that \(f\) is injective. Now, since we have an injective map between two sets of equal size, then this map must be surjective as well. Therefore, \(f\) is a bijection.
So now since this map is a bijection, then given a pair \((a_1, a_2) \in \mathbb{Z}/m_1, \mathbb{Z}/m_2\), this pair must correspond to exactly one \(x\) in \(\mathbb{Z}/(m_1m_2)\) such that
which is what we wanted to show. Note that this argument actually fails when \(m_1\) and \(m_2\) are not coprime. The map will not be injective.
Example
Suppose we want to solve the following
What does this equation mean? We want to find a number such that they have the same last digit if you square it. For example, 6^2 = 36. Note here that that \(6^2 \pmod{10^1} = 6\). Similarly, \(76^2 = 5776 \pmod{10^3} = 6\). Note that \(10^n = 2^n \cdot 5^n\) and that \((5^n, 2^n) = 1\). By CRT, this is the same as solving the following two equations
For \(x^2 \equiv x \pmod{5^n}\), observe that
There are at least two solutions \(x \equiv 0 \pmod{5^n}\) and \(x \equiv 1 \pmod{5^n}\). Similarly, for \(x^5 \equiv x \pmod{2^n}\), we also get the same two solutions. So now by CRT, we can combine these solutions. For example. When \(x \equiv 1\) in both,
By CRT,
so yes \(1^2 \equiv 1 \pmod{10^n}\) though it’s not an interesting solution. Let’s try another combination
From the first equation, \(x\) is divisible by \(2^n\) so \(x = 2^n \cdot t\). Plugging this in into the second equation
Suppose \(n = 1\), then
The smallest \(t\) satisfying this is \(t = 3\) since \(6 \equiv 1 \pmod{5}\). Then \(x = 2^n \cdot t = 2^1 \cdot 3 = 6\) so \(x = 6\) is a solution. If we try \(n = 2\), then
The smallest \(t\) satisfying this is \(t = 19\). Then \(x = 2^2 \cdot 19 = 76\) so \(x = 76\) is a solution.