MathLabs
TheoremProved

Chinese remainder theorem (existence and uniqueness)

Statement

If m1,…,mkm_1,\dots,m_k are pairwise coprime (gcd⁡(mi,mj)=1(i≠j)\gcd(m_i,m_j)=1\quad(i\neq j)), then for any integers a1,…,aka_1,\dots,a_k the system x≡ai(modmi)(1≤i≤k)x \equiv a_i \pmod{m_i}\quad(1\le i\le k) has a solution xx, and any two solutions are congruent modulo M=m1⋯mkM=m_1\cdots m_k.

Why is it true?

Because the moduli share no prime factors, the condition of leaving remainder a1a_1 modulo m1m_1 and the condition of leaving remainder a2a_2 modulo m2m_2 are completely independent constraints — like specifying an object's xx-coordinate and yy-coordinate separately. Bézout's identity gives us "basis vectors" that are 11 modulo one modulus and 00 modulo all the others, letting us build a solution directly as a linear combination.

Proof sketch

We first prove the two-modulus case (k=2k=2) and then extend by induction. Since gcd⁡(m1,m2)=1\gcd(m_1,m_2)=1, Bézout's identity gives integers u,vu,v with m1u+m2v=1m_1 u + m_2 v = 1. Set x0=a1m2v+a2m1ux_0 = a_1 m_2 v + a_2 m_1 u.

Check modulo m1m_1: from m1u+m2v=1m_1 u + m_2 v = 1 we have m2v=1−m1u≡1(modm1)m_2 v = 1 - m_1 u \equiv 1 \pmod{m_1}, while m1u≡0(modm1)m_1 u \equiv 0 \pmod{m_1}, so x0≡a1⋅1+a2⋅0=a1(modm1)x_0 \equiv a_1\cdot 1 + a_2\cdot 0 = a_1 \pmod{m_1}.

Symmetrically, modulo m2m_2: m1u=1−m2v≡1(modm2)m_1 u = 1-m_2 v \equiv 1 \pmod{m_2} and m2v≡0(modm2)m_2 v \equiv 0 \pmod{m_2}, so x0≡a1⋅0+a2⋅1=a2(modm2)x_0 \equiv a_1\cdot 0 + a_2\cdot 1 = a_2 \pmod{m_2}. This proves existence for k=2k=2.

For uniqueness when k=2k=2: if xx and x′x' both solve the system, then x−x′≡0(modm1)x-x'\equiv0\pmod{m_1} and x−x′≡0(modm2)x-x'\equiv0\pmod{m_2}, i.e. both m1m_1 and m2m_2 divide d=x−x′d=x-x'. Multiply the Bézout equation m1u+m2v=1m_1 u+m_2 v=1 by dd: d=dm1u+dm2vd = d m_1 u + d m_2 v. Since m2∣dm_2\mid d, the first term dm1ud m_1 u is a multiple of m1m2m_1 m_2; since m1∣dm_1\mid d, the second term dm2vd m_2 v is also a multiple of m1m2m_1 m_2. Hence m1m2∣dm_1 m_2 \mid d, i.e. x≡x′(modm1m2)x\equiv x'\pmod{m_1 m_2}.

For general k>2k>2, induction: the first two congruences are equivalent (by the k=2k=2 case) to a single congruence modulo m1m2m_1 m_2; since m3m_3 is coprime to both m1m_1 and m2m_2, it is coprime to their product m1m2m_1 m_2, so we can combine again, and so on up to kk. Notice also that the explicit sum x≡∑i=1kaiMiyi(modM)x \equiv \sum_{i=1}^{k} a_i M_i y_i \pmod{M} works directly for any kk by the exact same reasoning: Mi=M/miM_i = M/m_i is coprime to mim_i so its inverse yiy_i exists, and every term j≠ij\neq i contains mim_i as a factor of MjM_j. ■\blacksquare

Topics that use this theorem

Step-by-step proofs

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

References

  1. Jean-Jacques Quisquater, Christophe Couvreur (1982). Fast decipherment algorithm for RSA public-key cryptosystem · DOI:10.1049/el:19820617
  2. David Harvey, Joris van der Hoeven (2021). Integer multiplication in time O(n log n) · DOI:10.4007/annals.2021.193.2.4