Chinese remainder theorem
The Chinese remainder theorem is a result about congruences in number theory and its generalizations in abstract algebra. It was first published some time between the 3rd and 5th centuries by the Chinese mathematician Sun Tzu.
In its basic form, the Chinese remainder theorem will determine a number n that, when divided by some given divisors, leaves given remainders. In Sun Tzu's example (stated in modern terminology),[2] what is the smallest number n that when divided by 3 leaves a remainder of 2, when divided by 5 leaves a remainder of 3, and when divided by 7 leaves a remainder of 2?
Theorem statement
Suppose n1, ..., nk are positive integers that are pairwise coprime. Then, for any given sequence of integers a1, ..., ak, there exists an integer x solving the following system of simultaneous congruences.
Furthermore, any two solutions of this system are congruent modulo the product, N = n1 ... nk.[3] Hence, there is a unique (non-negative) solution less than N.
Sometimes, the simultaneous congruences can be solved even if the ni are not pairwise coprime. A solution x exists if and only if
for all i and j. All solutions, x, are then congruent modulo the least common multiple of the ni.[4]
A modern restatement of the theorem in algebraic language is that for a positive integer with prime factorization
we have the isomorphism between a ring and the direct sum of its prime power parts[5]
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.[6]
Existence and uniqueness
Existence is established by an explicit construction of x.[7] Let [a−1]b denote the multiplicative inverse of a (mod b), that is, a [a−1]b ≡ 1 (mod b). It is defined exactly when a and b are coprime and can be obtained from the Extended Euclidean algorithm.
For notational convenience, with N = n1n2...nk, define Nj := N/nj for j = 1, ..., k. Because the ni's are relatively coprime, ni divides Nj for each i ≠ j and we have
- (the Kronecker delta),
that is, 1 if i = j and 0 if i ≠ j. So, the expression
satisfies the congruences x ≡ ai (mod ni) for all i = 1, ..., k, since, for each i, all the terms on the right are zero except the ith term, which evaluates to ai.
Suppose that x and y are both solutions to all the congruences. Then x - y ≡ 0 (mod ni) for all i = 1, ..., k. Since the ni are coprime, x - y ≡ 0 (mod N). Therefore, any two solutions are congruent modulo N, or, stated another way, the solution is unique (mod N).
History
The earliest known statement of the theorem, as a problem with specific numbers, appears in the 3rd-century book Sunzi's Mathematical Classic (孫子算經) by the Chinese mathematician Sun Tzu.[2] Sun Tzu's work contains neither a proof nor a full algorithm.[8] What amounts to an algorithm for solving this problem was described by Aryabhata (6th century).[9] Special cases of the Chinese remainder theorem were also known to Brahmagupta (7th century), and appear in Fibonacci's Liber Abaci (1202).[10] The result was later generalized with a complete solution called Dayanshu (大衍術) in Qin Jiushao's 1247 Mathematical Treatise in Nine Sections (數書九章, Shushu Jiuzhang).[11]
The notion of congruences was first introduced and used by Gauss in his Disquisitiones Arithmeticae of 1801.[12] 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."[13] Gauss introduces a procedure for solving the problem that had already been used by Euler but was in fact the ancient method that had appeared several times.[14]
Finding the solution
As an example, consider the problem of finding an integer x such that
Brute-force approach
A brute-force approach converts these congruences into sets and writes the elements out to the product of 3×4×5 = 60 (the solutions modulo 60 for each congruence):
- x ∈ {2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59}
- x ∈ {3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59}
- x ∈ {1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56}
To find an x that satisfies all three congruences, intersect the three sets to get:
This solution is modulo 60, hence all solutions are expressed as
An algebraic approach
Another way to find a solution is with basic algebra, modular arithmetic, and stepwise substitution.
We start by translating these congruences into equations for some t, s, and u:
Start by substituting the x from the first equation into the second congruence:
meaning that t = 3 + 4s for some integer s. Substitute t into the first equation:
Substitute this x into the third congruence:
meaning that s = 0 + 5u for some integer u. Finally,
So, we have solutions {11, 71, 131, 191, ...}.
Notice that 60 = lcm(3,4,5). If the moduli are pairwise coprime (as they are in this example), the solutions will be congruent modulo their product.
Using the existence construction
Since the ni are pairwise coprime we may use the construction given in the existence section above. (For simultaneous congruences when the moduli are not pairwise coprime, one of the other methods given above can often yield solutions.)
In this example, N = 3 × 4 × 5 = 60, so N3 = N/3 = 20, N4 = 15 and N5 = 12. Using the extended Euclidean algorithm, we obtain [(N3)-1]3 ≡ 2 (notice that 20 × 2 = 40 ≡ 1 (mod 3)), [(N4)-1]4 ≡ 3 and [(N5)-1]5 ≡ 3. Therefore, x = 2(20)(2) + 3(15)(3) + 1(12)(3) = 80 + 135 + 36 = 251. Since all solutions are congruent modulo N, the smallest non-negative solution is 11 ≡ 251 (mod 60).
Using the same principle, the answer to Sun Tzu's original question (in the introduction) is therefore 23, since for divisors 3, 5, 7: 2(35)(2) + 3(21)(1) + 2(15)(1) = 233 ≡ 23 (mod 105).
Statement for principal ideal domains
- Chinese Remainder Theorem for Principal Ideal Domains. Let R be principal ideal domain. If u1, ..., uk are pairwise coprime elements of R where u = u1...uk, then the quotient ring R/uR and the product ring R/u1R × ... × R/ukR are isomorphic via the following map:
This statement is a straightforward generalization of the above theorem about integer congruences: Z is a principal ideal domain, the surjectivity of the map f shows that every system of congruences of the form
can be solved for x, and the injectivity of the map f shows that all the solutions x are congruent modulo u.
Proof. This map is well-defined and a homomorphism of rings. An inverse homomorphism can be constructed as follows, showing that it is in fact an isomorphism. For each i, the elements ui and u/ui are coprime, and therefore there exist elements r and s in R with
Set ei = su/ui. Then it is clear that
Thus the inverse of f is the map
Statement for general rings
The general form of the Chinese remainder theorem, which implies all the statements given above, can be formulated for commutative rings and ideals.
Chinese Remainder Theorem for Commutative Rings. If R is a commutative ring with identity and I1, ..., Ik are ideals of R that are pairwise coprime (meaning Ii + Ij = R for all i ≠ j), then the product I of these ideals is equal to their intersection, and the quotient ring R/I is isomorphic to the direct sum of rings R/I1 ⊕ ... ⊕ R/Ik via the isomorphism[15]
Here is a version of the theorem where R is not required to be commutative:
Chinese Remainder Theorem for Noncommutative Rings. Let R be any ring with 1 (not necessarily commutative) and I1, ..., Ik be pairwise coprime 2-sided ideals. Then the canonical ring homomorphism R → R/I1 × ... × R/Ik is onto, with kernel I1 ∩ ... ∩ Ik. Hence, .
Applications
Sequence numbering
The Chinese remainder theorem can be used to construct an elegant Gödel numbering for sequences, which is needed to prove Gödel's incompleteness theorems.
Fast Fourier transform
The Good-Thomas (or prime-factor) fast Fourier transform algorithm exploits a re-indexing of the data based on the Chinese remainder theorem. The prime-factor FFT algorithm contains an implementation.
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.
Hermite interpolation
The General Hermite Interpolation Problem. Given r complex points ("interpolation nodes") λ1, …, λr and complex data {aj,k: 1 ≤ j ≤ r, 0 ≤ k < νj}, find P(x) ∈ C[x] such that:
Solution. Introducing the polynomials
the problem may be equivalently reformulated as a system of r simultaneous congruences:
By the Chinese remainder theorem in the principal ideal domain C[x], there is a unique polynomial P(x) such that:
A direct construction, in analogy with the above proof for the integer number case, can be performed as follows. Define the polynomials
The partial fraction decomposition of 1/Q gives r polynomials Sj with degrees deg(Sj) < νj such that
so that
Then a solution of the simultaneous congruence system is given by the polynomial
and the minimal degree solution is this one reduced modulo Q, that is the unique with degree less than n.
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.
Non-commutative case: a caveat
Sometimes in the commutative case, the conclusion of the Chinese Remainder Theorem is stated as R/(I1 ... Ik) ≅ R/I1 × ... × R/Ik. This version does not hold in the non-commutative case, since I1 ∩ ... ∩ Ik ≠ I1 ... Ik, as can be seen from the following case:
- Proposition. Let R be the ring of non-commutative real polynomials in x and y. Let I be the principal two-sided ideal generated by x and J the principal two-sided ideal generated by xy + 1. Then I + J = R but I ∩ J ≠ IJ.
Proof. Observe that I is formed by all polynomials with an x in every term and that every polynomial in J vanishes under the substitution y = − 1/x. Then clearly p = (xy + 1)x ∈ I ∩ J. Define a "term in R", as an element of the multiplicative monoid of R generated by x and y, and its degree as the usual degree of the term after the substitution y = x. On the other hand, suppose q ∈ J. Observe that a term in q of maximum degree depends on y otherwise q under the substitution y = − 1/x can not vanish. The same happens then for an element q ∈ IJ. Note that the last y, from left to right, in a term of maximum degree in an element of IJ is preceded by more than one x. (We are counting here all the preceding xs. E.g., in x2yxyx5 the last y is preceded by three xs.) This proves that p = (xy + 1)x ∉ IJ since the last y in the term of maximum degree in p (xyx) is preceded by only one x. Hence I ∩ J ≠ IJ.
However, it is true in general that I + J = R implies I ∩ J = IJ + JI. To see this, note that I ∩ J = (I ∩ J)(I + J) ⊂ IJ + JI, while the opposite inclusion is obvious. Also, we have in general that, provided I1, ..., Im are pairwise coprime two-sided ideals in R, the natural map
is an isomorphism. Note that I1 ∩ ... ∩ Im can be replaced by a sum over all orderings of I1, ..., Im of their product (or just a sum over enough orderings, using inductively that I ∩ J = IJ + JI for coprime ideals I, J ⊂ R).
See also
- Covering system
- Hasse principle
- Residue number system
- Secret sharing using the Chinese remainder theorem
Notes
- ↑ Gauss & Clarke 1986, Art. 32-36
- 1 2 Katz 1998, p. 197
- ↑ Ireland & Rosen 1990, p. 34
- ↑ Ore 1988, p. 244
- ↑ Ireland & Rosen 1990, p. 35
- ↑ Duchet 1995
- ↑ Rosen 1993, p. 136
- ↑ Dauben 2007, p. 302
- ↑ Kak 1986
- ↑ Leonardo Pisano; Sigler, Laurence E. (translator into English) (2002), Fibonacci's Liber Abaci, Springer-Verlag, pp. 402–403, ISBN 0-387-95419-8
- ↑ Dauben 2007, p. 310
- ↑ Ireland & Rosen 1990, p. 36
- ↑ Ore 1988, p. 247
- ↑ Ore 1988, p. 245
- ↑ Ireland & Rosen 1990, p. 181
References
- Dauben, Joseph W. (2007), "Chapter 3: Chinese Mathematics", in Katz, Victor J., The Mathematics of Egypt, Mesopotamia, China, India and Islam : A Sourcebook, Princeton University Press, pp. 187–384, ISBN 978-0-691-11485-9
- Duchet, Pierre (1995), "Hypergraphs", in Graham, R. L.; Grötschel, M.; Lovász, L., Handbook of combinatorics, Vol. 1, 2, Amsterdam: Elsevier, pp. 381–432, MR 1373663. See in particular Section 2.5, "Helly Property", pp. 393–394.
- Gauss, Carl Friedrich; Clarke, Arthur A. (translator into English) (1986), Disquisitiones Arithemeticae (Second, corrected ed.), New York: Springer, ISBN 978-0-387-96254-2
- Ireland, Kenneth; Rosen, Michael (1990), A Classical Introduction to Modern Number Theory (2nd ed.), Springer-Verlag, ISBN 0-387-97329-X
- Kak, Subhash (1986), "Computational aspects of the Aryabhata algorithm" (PDF), Indian Journal of History of Science 21 (1): 62–71
- Katz, Victor J. (1998), A History of Mathematics / An Introduction (2nd ed.), Addison Wesley Longman, ISBN 978-0-321-01618-8
- Ore, Oystein (1988) [1948], Number Theory and Its History, Dover, ISBN 978-0-486-65620-5
- Rosen, Kenneth H. (1993), Elementary Number Theory and its Applications (3rd ed.), Addison-Wesley, ISBN 978-0201-57889-8
Further reading
- Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford (2001), Introduction to Algorithms (Second ed.), MIT Press and McGraw-Hill, ISBN 0-262-03293-7. See Section 31.5: The Chinese remainder theorem, pp. 873–876.
- Ding, Cunsheng; Pei, Dingyi; Salomaa, Arto (1996), Chinese Remainder Theorem: Applications in Computing, Coding, Cryptography, World Scientific Publishing, pp. 1–213, ISBN 981-02-2827-9
- Hungerford, Thomas W. (1974), Algebra, Graduate Texts in Mathematics, Vol. 73, Springer-Verlag, pp. 131–132, ISBN 978-1-4612-6101-8
- Knuth, Donald (1997), The Art of Computer Programming, Volume 2: Seminumerical Algorithms (Third ed.), Addison-Wesley, ISBN 0-201-89684-2. See Section 4.3.2 (pp. 286–291), exercise 4.6.2–3 (page 456).
External links
- Hazewinkel, Michiel, ed. (2001), "Chinese remainder theorem", Encyclopedia of Mathematics, Springer, ISBN 978-1-55608-010-4
- Weisstein, Eric W., "Chinese Remainder Theorem", MathWorld.
- Full text of the Sunzi Suanjing (Chinese) — Chinese Text Project