Subsection5.3.1Introducing the Chinese Remainder Theorem
In Section 5.2, we were able to solve any one linear congruence completely. It's a good feeling.
But we know that this is a pretty restricted result. If you've had a course in linear algebra, you've tried to solve big systems over the reals or complex numbers; sometimes in real-life operations research problems, there can be hundreds of thousands of linear equations to solve simultaneously!
It turns out this is true for modular arithmetic too, especially in encryption standards. Can we solve a system of linear congruences? Of course, one could ask a computer to do it by simply checking all possibilities.
As one might expect, this is not the most promising solution strategy. If you dig into the code a bit you'll see that many cases aren't even treated properly, which could be very tedious to catch.
However, in considering systems of congruences, there is a famous theorem. This kind of simultaneous solution was apparently first considered by the Chinese mathematician Sun Tzu, about the same time as the late Greek mathematicians were coming up with what we now call Diophantine equations. A very full solution (see Subsection 5.5.1) was given by Qin Jiushao in the 13th century and rediscovered only in the 19th century in the West.
Theorem5.3.1Chinese Remainder Theorem
Consider a general system of \(k\) (linear) congruences:
\(x\equiv a_1\) (mod \(n_1\))
\(x\equiv a_2\) (mod \(n_2\))
\(\ldots\)
\(x\equiv a_k\) (mod \(n_k\))
where all the \(n_i\) are mutually coprime. In this case, we have an algorithm for solving the system.
Proof
This will be done in a completely constructive fashion in Subsection 5.4.1.
The name comes from the provenance, and is often abbreviated CRT. Whether any actual Chinese rulers used it to decide how many troops they had by lining them up in threes, fours, fives, etc. is questionable. However, many of the example problems in Qin's text mention divination, alignment of different calendars, and the like, so we can assume such problems were of practical interest as well as theoretical, even at that time. Similar questions of astronomical/astrological importance pepper the history of mathematics.
Finally, note that one can also go much further and do linear algebra modulo \(n\), and this is a lot of what modern cryptography is about, not to mention the modern hard-core computational number theory Sage was largely invented to help do. We can't do everything in this text, but you should be aware that everything done in linear algebra has very interesting modulo \(n\) counterparts, as part of the theme of number theory showing the unity of mathematics.
Subsection5.3.2The inverse of a number
To do this justice, we need a very useful preliminary concept.
Definition5.3.2The Inverse of a Number
The inverse of a number \(a\) modulo \(n\) is the least nonnegative solution of the congruence \begin{equation*}ax\equiv 1\text{ (mod }n)\end{equation*}.
Example5.3.3
For example, the inverse of \(26\) modulo \(31\) is the least nonnegative solution of \begin{equation*}26x\equiv 1\text{ (mod }31\text{)}\, .\end{equation*} This is called the inverse because you can think of the solution as \(26^{-1}\), or \(\frac{1}{26}\), in the numbers modulo \(n=31\).
Note that there is not always an inverse! Here are some questions to ponder regarding inverses.
Question5.3.4
What connection do \(a\) and \(n\) need if we expect there to exist an inverse of \(a\) modulo \(n\)?
How many inverses modulo \(n\) should \(a\) have, assuming it has one at all?
As a first step, try to find inverses to all the number you can modulo \(10\). Then do it again modulo \(11\).
The following Sage command computes the “inverse of 26 modulo 31”.
The point is that this is definitely something we can compute, using the methods of last time of solving solitary linear congruences.