Suppose there is an integer \(x\) such that \(x ≡ a_1 \bmod m_1\) and \(x ≡ a_2 \bmod m_2\). This means:
Since \((m_1,m_2)\) divides both \(m_1\) and \(m_2\), then it should also divide \(a_1 - a_2\). The contrapositive is that if \((m_1,m_2) \nmid (a_1 - a_2)\), then the system of congruences does not have a solution.
Now assume that we don't know whether there is a solution but we do know that \((m_1,m_2) | (a_1 - a_2)\). This means \((m_1,m_2)n = a_1 - a_2 \). Since the \(\gcd\) can be written as a linear combination, then there are integers \(p\) and \(q\) such that \((m_1,m_2)=m_2 p - m_1 q\). This means \(m_2 pn - m_1 qn = a_1 - a_2 \) or:
Let \(x=m_2 s +a_2\), then \(x=m_1 t + a_1\). Therefore:
Thus we have shown that if \((m_1,m_2) | (a_1 - a_2)\), then the system of congruences has a solution.
Now suppose we have another solution \(y\):
This means:
If \(x-y\) is a common multiple of both \(m_1\) and \(m_2\), then it is a multiple of the lowest common mutiple:
This means \(x ≡y \bmod [m_1, m_2]\). Therefore, the solution is unique modulo \([m_1,m_2]\).