MathLabs
TheoremProved

Chinese Remainder Theorem (Sunzi, Qin Jiushao)

Statement

Let m1,m2,…,mkm_1,m_2,\dots,m_k be pairwise coprime positive integers and let a1,…,aka_1,\dots,a_k be any integers. Then the system of congruences x≡ai(modmi)x\equiv a_i\pmod{m_i} for every ii has a solution xx, and this solution is unique modulo M=m1m2⋯mkM=m_1m_2\cdots m_k.

Why is it true?

First recorded around the 3rd–5th century in the Sunzi Suanjing ('the unknown number of things') and given a complete general algorithm by Qin Jiushao in 1247 (Da-yan rule), this theorem says that pairwise-coprime moduli carry independent information: knowing a number's remainder mod 3, mod 5, mod 7 pins it down uniquely mod 105, with no information lost or contradictory, because the moduli never 'overlap'.

Proof sketch

Existence, step 1 (build the pieces): for each ii define Mi=M/miM_i=M/m_i, the product of all moduli except mim_i. Because the mjm_j are pairwise coprime, every prime factor of mim_i is absent from every mjm_j (j≠ij\neq i), so gcd⁡(Mi,mi)=1\gcd(M_i,m_i)=1. By Bezout's identity (extended Euclidean algorithm) there exists an integer yiy_i — the modular inverse of MiM_i mod mim_i — with Miyi≡1(modmi)M_iy_i\equiv1\pmod{m_i}.

Existence, step 2 (assemble the solution): set x=∑i=1kaiMiyi mod Mx=\sum_{i=1}^{k}a_iM_iy_i\bmod M. Fix any index ii and reduce this sum mod mim_i. For every j≠ij\neq i, the factor Mj=M/mjM_j=M/m_j contains mim_i as one of its factors (since i≠ji\neq j), so mi∣Mjm_i\mid M_j and the term ajMjyj≡0(modmi)a_jM_jy_j\equiv0\pmod{m_i}. Only the ii-th term survives: x≡aiMiyi≡ai⋅1=ai(modmi)x\equiv a_iM_iy_i\equiv a_i\cdot1=a_i\pmod{m_i} (using Miyi≡1(modmi)M_iy_i\equiv1\pmod{m_i}). Since ii was arbitrary, xx satisfies every congruence x≡ai(modmi)x\equiv a_i\pmod{m_i} at once.

Uniqueness mod MM: suppose x′x' is another integer satisfying every x≡ai(modmi)x\equiv a_i\pmod{m_i}. Then x−x′≡0(modmi)x-x'\equiv0\pmod{m_i} for every ii, i.e. every mim_i divides x−x′x-x'. Because the mim_i are pairwise coprime, their least common multiple equals their product MM, so M∣(x−x′)M\mid(x-x') as well — any common multiple of pairwise-coprime numbers must already be a multiple of their product. Hence x≡x′(modM)x\equiv x'\pmod M: the solution is unique modulo MM, exactly as claimed.

Toy verification: take m1=3,m2=5m_1=3,m_2=5 with a1=2,a2=3a_1=2,a_2=3, i.e. the system x≡2(mod3), x≡3(mod5)x\equiv2\pmod3,\ x\equiv3\pmod5. Here M=15M=15; M1=5M_1=5 needs 5y1≡1(mod3)5y_1\equiv1\pmod3, i.e. 2y1≡1(mod3)2y_1\equiv1\pmod3, so y1=2y_1=2; M2=3M_2=3 needs 3y2≡1(mod5)3y_2\equiv1\pmod5, so y2=2y_2=2. Then x=2⋅5⋅2+3⋅3⋅2=20+18=38≡8(mod15)x=2\cdot5\cdot2+3\cdot3\cdot2=20+18=38\equiv8\pmod{15}, so x=8x=8. Check: 8=2⋅3+28=2\cdot3+2 leaves remainder 22 mod 33, and 8=1⋅5+38=1\cdot5+3 leaves remainder 33 mod 55 — both congruences hold, confirming the construction.

Topics that use this theorem

Step-by-step proofs

No step-by-step proof yet for this theorem.

References

  1. Victor J. Katz (2009). A History of Mathematics: An Introduction
  2. Oliver Knill (2012). A Multivariable Chinese Remainder Theorem · arXiv:1206.5114