![]() | ||
The Chinese remainder theorem is a theorem of number theory, which states that, if one knows the remainders of the division of an integer n by several integers, then one can determine uniquely the remainder of the division of n by the product of these integers, under the condition that the divisors are pairwise coprime.
Contents
- History
- Theorem statement
- Proof
- Uniqueness
- Existence first proof
- Existence constructive proof
- Case of two moduli
- General case
- Existence direct construction
- Computation
- Systematic search
- Search by sieving
- Using the existence construction
- As a linear Diophantine system
- Over principal ideal domains
- Over univariate polynomial rings and Euclidean domains
- Lagrange interpolation
- Hermite interpolation
- Generalization to arbitrary rings
- Sequence numbering
- Fast Fourier transform
- Encryption
- Range ambiguity resolution
- Dedekinds theorem
- References
This theorem has this name because it is a theorem about remainders, which was first discovered in the 3rd century AD by the Chinese mathematician Sunzi in Sunzi Suanjing.
The Chinese remainder theorem is widely used for computing with large integers, as it allows replacing a computation for which one knows a bound on the size of the result by several similar computations on small integers.
The Chinese remainder theorem (expressed in terms of congruences) is true over every principal ideal domain. It has been generalized to any commutative ring, with a formulation involving ideals.
History
The earliest known statement of the theorem, as a problem with specific numbers, appears in the 3rd-century book Sunzi Suanjing by the Chinese mathematician Sunzi:
Sunzi's work contains neither a proof nor a full algorithm. What amounts to an algorithm for solving this problem was described by Aryabhata (6th century). Special cases of the Chinese remainder theorem were also known to Brahmagupta (7th century), and appear in Fibonacci's Liber Abaci (1202). The result was later generalized with a complete solution called Dayanshu (大衍術) in Qin Jiushao's 1247 Mathematical Treatise in Nine Sections (數書九章, Shushu Jiuzhang).
The notion of congruences was first introduced and used by Gauss in his Disquisitiones Arithmeticae of 1801. Gauss illustrates the Chinese remainder theorem on a problem involving calendars, namely, "to find the years that have a certain period number with respect to the solar and lunar cycle and the Roman indiction." Gauss introduces a procedure for solving the problem that had already been used by Euler but was in fact an ancient method that had appeared several times.
Theorem statement
Let n1, ..., nk be integers greater than 1, which are often called moduli or divisors. Let us denote by N the product of the ni.
The Chinese remainder theorem asserts that if the ni are pairwise coprime, and if a1, ..., ak are integers such that 0 ≤ ai < ni for every i, then there is one and only one integer x, such that 0 ≤ x < N and the remainder of the Euclidean division of x by ni is ai for every i.
This may be restated as follows in term of congruences: If the ni are pairwise coprime, and if a1, ..., ak are any integers, then there exists an integer x such that
and any two such x are congruent modulo N.
In abstract algebra, the theorem is often restated as: if the ni are pairwise coprime, the map
defines a ring isomorphism
between the ring of integers modulo N and the direct product of the rings of integers modulo the ni. This means that for doing a sequence of arithmetic operations in
The theorem can also be restated in the language of combinatorics as the fact that the infinite arithmetic progressions of integers form a Helly family.
Proof
The existence and the uniqueness of the solution may be proved independently. However the first proof of existence, given below, uses the uniqueness.
Uniqueness
Suppose that x and y are both solutions to all the congruences. As x and y give the same remainder, when divided by ni, their difference x − y is a multiple of each ni. As the ni are pairwise coprime, their product N divides also x − y, and thus x and y are congruent modulo N. If x and y are supposed to be non negative and less than N (as in the first statement of the theorem), then their difference may be a multiple of N only if x = y.
Existence (first proof)
The map
maps congruence classes modulo N to sequences of congruence classes modulo ni. The proof of uniqueness shows that this map is injective. As the domain and the codomain of this map have the same number of elements, the map is also surjective, which proves the existence of the solution.
This proof is very simple, but does not provide any direct way for computing a solution. Moreover, it cannot be generalized to other situations where the following proof can.
Existence (constructive proof)
Existence may be established by an explicit construction of x. This construction may be split in two steps, firstly by solving the problem in the case of two moduli, and the second one by extending this solution to the general case by induction on the number of moduli.
Case of two moduli
We want to solve the system
where
Bézout's identity asserts the existence of two integers
The integers
A solution is given by
In fact
This shows that
General case
Let us consider a sequence of congruence equations
where the
As the other
Existence (direct construction)
For constructing a solution, it is not necessary to make an induction on the number of moduli. However, such a direct construction involves more computation with large numbers, which makes it less efficient and less used. Nevertheless, Lagrange interpolation is a special case of this construction, applied to polynomials instead of integers.
Let
A solution of the system of congruences is
In fact, as
for every
Computation
Let us consider a system of congruences
where the
Systematic search
It is easy to check whether a value of x is a solution: it suffices to compute the remainder of the Euclidean division of x by each ni. Thus, to find the solution, it suffices to check successively the integers from 0 to N until finding the solution.
Although very simple this method is very inefficient: for the simple example considered here, 40 integers (including 0) have to be checked for finding the solution 39. This is an exponential time algorithm, as the size of the input is, up to a constant factor, the number of digits of N, and the average number of operations is of the order of N.
Therefore, this method is rarely used, for hand-written computation as well on computers.
Search by sieving
The search of the solution may be made dramatically faster by sieving. For this method, we suppose, without loss of generality, that
By testing the values of these numbers modulo
Testing the values of these numbers modulo
This method is faster if the moduli have been ordered by decreasing value, that is if
This method works well for hand-written computation with a product of moduli that is not too big. However it is much slower than other methods, for very large products of moduli. Although dramatically faster than the systematic search, this method has also an exponential time complexity, and is therefore not used on computers.
Using the existence construction
The constructive existence proof shows that, in the case of two moduli, the solution may be obtained by the computation of the Bézout coefficients of the moduli, followed by a few multiplications, additions and reductions modulo
For more than two moduli, the method for two moduli allows the replacement of any two congruences by a single congruence modulo the product of the moduli. Iterating this process provides eventually the solution with a complexity, which is quadratic in the number of digits of the product of all moduli. This quadratic time complexity does not depend on the order in which the moduli are regrouped. One may regroup the two first moduli, then regrouping the resulting modulus with the next one, and so on. This is the strategy which is the easiest to implement, but it needs more computation involving large numbers.
Another strategy consists in partitioning the moduli in pairs whose product have comparable sizes (as much as possible), applying parallely the method of two moduli to each pair, and iterating with a number of moduli approximatively divided by two. This method allows an easy parallelization of the algorithm. Also, if fast algorithms (that is algorithms working in quasilinear time) are used for the basic operations, this method provides an algorithm for the whole computation that works in quasilinear time.
On the current example (which has only three moduli), both strategies are identical, and works as follows.
Bézout's identity for 3 and 4 is
Putting this in the formula given for proving the existence gives
for a solution of the two first congruences, the other solutions being obtained by adding to −9 any multiple of 3×4 = 12. One may continue with any of these solutions, but the solution 3 = −9 +12 is smaller (in absolute value) and thus leads probably to an easier computation
Bézout identity for 5 and 3×4 = 12 is
Applying the same formula again, we get a solution of the problem:
The other solutions are obtained by adding any multiple of 3×4×5 = 60, and the smallest positive solution is −21 + 60 = 39.
As a linear Diophantine system
The system of congruences solved by the Chinese remainder theorem may be rewritten as a system of simultaneous linear Diophantine equations
where the unknown integers are
Over principal ideal domains
In § Theorem statement, the Chinese remainder theorem has been stated in three different ways: in terms of remainders, of congruences and of a ring isomorphism. The statement in terms of remainders does not apply, in general, to principal ideal domains, as remainders are not defined in such rings. However, the two other versions make sense over a principal ideal domain R: it suffices to replace "integer" by "element of the domain" and
However, in general, the theorem is only an existence theorem, and does not provide any way for computing the solution, unless one has an algorithm for computing the coefficients of Bézout's identity.
Over univariate polynomial rings and Euclidean domains
The statement in terms of remainders given in § Theorem statement cannot be generalized to any principal ideal domain, but its generalization to Euclidean domains is straightforward. The univariate polynomials over a field is the typical example of a Euclidean domain, which is not the integers. therefore, we state the theorem for the case of a ring of univariate domain
The Chinese remainder theorem for polynomials is thus: Let
The construction of the solution may be done as in § Existence (constructive proof) or § Existence (direct proof). However, the latter construction may be simplified by using, as follows, partial fraction decomposition instead of extended Euclidean algorithm.
Thus, we want to find a polynomial
for
Let us consider the polynomials
The partial fraction decomposition of
and thus
Then a solution of the simultaneous congruence system is given by the polynomial
In fact, we have
for
This solution may have a degree larger that
Lagrange interpolation
A special case of Chinese remainder theorem for polynomials is Lagrange interpolation. For this, let us consider k monic polynomials of degree one:
They are pairwise coprime if the
Now, let
for every i.
Lagrange interpolation formula is exactly the result, in this case, of the above construction of the solution. More precisely, let
The partial fraction decomposition of
In fact, reducing the right-hand side to a common denominator one gets
Using the above general formula, we get the Lagrange interpolation formula
Hermite interpolation
Hermite interpolation is an application of Chinese remainder theorem for univariate polynomials, which may involve moduli of arbitrary degrees (Lagrange interpolation involves only moduli of degree one).
The problem consists of finding a polynomial of the least possible degree, such that the polynomial and its first derivatives take given values at some fixed points.
More precisely, let
Let us consider the polynomial
This is the Taylor polynomial of order
Conversely, any polynomial
therefore
There are several ways for computing the solution
Generalization to arbitrary rings
The Chinese remainder theorem can be generalized to any ring, by using coprime ideals (also called comaximal ideals). Two ideals I and J are coprime if there are elements
Let I1, ..., Ik be two-sided ideals of a ring
between the quotient ring
Sequence numbering
The Chinese remainder theorem has been used to construct a Gödel numbering for sequences, which is involved in the proof of Gödel's incompleteness theorems.
Fast Fourier transform
The prime-factor FFT algorithm (also called Good-Thomas algorithm) uses the Chinese remainder theorem for reducing the computation of a fast Fourier transform of size
Encryption
Most implementations of RSA use the Chinese remainder theorem during signing of HTTPS certificates and during decryption.
The Chinese remainder theorem can also be used in secret sharing, which consists of distributing a set of shares among a group of people who, all together (but no one alone), can recover a certain secret from the given set of shares. Each of the shares is represented in a congruence, and the solution of the system of congruences using the Chinese remainder theorem is the secret to be recovered. Secret sharing using the Chinese remainder theorem uses, along with the Chinese remainder theorem, special sequences of integers that guarantee the impossibility of recovering the secret from a set of shares with less than a certain cardinality.
Range ambiguity resolution
The range ambiguity resolution techniques used with medium pulse repetition frequency radar can be seen as a special case of the Chinese remainder theorem.
Dedekind's theorem
Dedekind's Theorem on the Linear Independence of Characters. Let M be a monoid and k an integral domain, viewed as a monoid by considering the multiplication on k. Then any finite family ( fi )i∈I of distinct monoid homomorphisms fi : M → k is linearly independent. In other words, every family (αi)i∈I of elements αi ∈ k satisfying
must be equal to the family (0)i∈I.
Proof. First assume that k is a field, otherwise, replace the integral domain k by its quotient field, and nothing will change. We can linearly extend the monoid homomorphisms fi : M → k to k-algebra homomorphisms Fi : k[M] → k, where k[M] is the monoid ring of M over k. Then, by linearity, the condition
yields
Next, for i, j ∈ I; i ≠ j the two k-linear maps Fi : k[M] → k and Fj : k[M] → k are not proportional to each other. Otherwise fi and fj would also be proportional, and thus equal since as monoid homomorphisms they satisfy: fi (1) = 1 = fj (1), which contradicts the assumption that they are distinct.
Therefore, the kernels Ker Fi and Ker Fj are distinct. Since k[M]/Ker Fi ≅ Fi(k[M]) = k is a field, Ker Fi is a maximal ideal of k[M] for every i ∈ I. Because they are distinct and maximal the ideals Ker Fi and Ker Fj are coprime whenever i ≠ j. The Chinese Remainder Theorem (for general rings) yields an isomorphism:
where
Consequently, the map
is surjective. Under the isomorphisms k[M]/Ker Fi → Fi(k[M]) = k, the map Φ corresponds to:
Now,
yields
for every vector (ui)i∈I in the image of the map ψ. Since ψ is surjective, this means that
for every vector
Consequently, (αi)i∈I = (0)i∈I. QED.