Chinese remainder theorem

Dependencies:

  1. Existence of Modular Inverse
  2. ab is coprime to x iff a and b are coprime to x
  3. Product of coprime divisors is divisor

Define the function $\textrm{crt}$ as \[ \operatorname{crt}(A, M) = \left( \sum_{i=1}^k a_iN_iy_i \right) \% N \]

Then \[ (\forall i, x \equiv a_i \pmod{m_i}) \iff x \equiv \operatorname{crt}(A, M) \pmod{N} \]

Proof

\[ (\forall j \neq i, \gcd(m_j, m_i) = 1) \implies \gcd\left( \prod_{j \neq i} m_j, m_i \right) = 1 \implies \gcd(N_i, m_i) = 1 \] Therefore, $y_i$ exists.

Suppose \[ x \equiv \sum_{i=1}^k a_iN_iy_i \pmod{N} \] Since $\forall j \neq i, m_i \mid N_j$, $x \equiv a_iN_iy_i \pmod{m_i}$. Since $y_i = N_i^{-1} \pmod{m_i}$, $x \equiv a_iN_iy_i \equiv a_i \pmod{m_i}$.

Let $S = \{x \in \mathbb{Z}_N: \forall i, x \equiv a_i \pmod{m_i} \}$. By the above result, we know that $\operatorname{crt}(A, M) \in S$, so $|S| \ge 1$.

Suppose $x, y \in S$ and $x \neq y$. \[ (\forall i, x \equiv a_i \wedge y \equiv a_i \pmod{m_i}) \implies (\forall i, m_i \mid (y-x)) \implies N \mid (y-x) \implies y = x \] This is a contradiction. Therefore, there cannot be 2 distinct elements in $S$. Therefore, $S = \{ \operatorname{crt}(A, M) \}$. Therefore, \[ (\forall i, x \equiv a_i \pmod{m_i}) \implies x \equiv \operatorname{crt}(A, M) \pmod{N} \]

Dependency for: None

Info:

Transitive dependencies:

  1. Every number has a prime factorization
  2. Integer Division Theorem
  3. GCD is the smallest Linear Combination
  4. Euclid's lemma
  5. ab is coprime to x iff a and b are coprime to x
  6. Product of coprime divisors is divisor
  7. Existence of Modular Inverse