<s>[INST] Why does the CRT formula yield a solution of a congruence system? I understand there is a method for solving simultaneous modular equations. For example;
$$x = 2 \mod{3}$$
$$x = 3 \mod{5}$$
$$x = 2 \mod{7}$$
We find numbers equal to the product of every given modulo except one of them - giving $5 \cdot 7$, $3 \cdot 7$ and $3 \cdot 5$. We then find the multiplicative inverses of these numbers with modulo equal to the number missing from the product. The numbers found are then 2, 1 and 1 in this case. The value of x is then given by:
$$x = 2 \cdot (5 \cdot 7) \cdot 2 + 3 \cdot (3 \cdot 7) \cdot 1 + 2 \cdot (3 \cdot 5) \cdot 1 = 233 = 23 \mod{3\cdot5\cdot7}$$
But I do not understand how this method correctly gives the value of $x$. I understand that the Chinese remainder theorem proves that there is a unique value of $0\le x \lt 3\cdot5\cdot7 \mod{3\cdot5\cdot7}$ but can someone please explain why this method finds this value of x?
 [/INST] This is a generalisation of the formula for the solutions of a system of two congruences modulo two coprime numbers $a$ and $b$?. This formula uses a Bézout's relation: $\;ua+vb=1$ and it is:
$$\begin{cases}
x\equiv \alpha\mod a,\\
x\equiv \beta\mod b,
\end{cases}
\quad\text{which is }\qquad x\equiv \beta ua+\alpha vb\mod ab$$
Indeed we have $\;\beta ua+\alpha vb\equiv \alpha vb\equiv \alpha\mod a$ since  $\;vb\equiv 1\mod a$. Similarly modulo $b$.
Now, as $v \equiv b^{-1}\bmod a\:$ and $\;u\equiv a^{-1}\bmod b$, this formula can be written as
$$x\equiv \beta\, a (a^{-1}\bmod b)+\alpha\, b(b^{-1}\bmod a)\mod ab.$$
Some details with the example in the question:
In each term of $x$:
$$ 2 \cdot (5 \cdot 7) \cdot 2 + 3 \cdot (3 \cdot 7) \cdot 1 + 2 \cdot (3 \cdot 5) \cdot 1 $$
the first factor is the r.h.s. of a congruence equation mod. $m_i$, the second (between parentheses) is the product of the other moduli and the last factor is the inverse of the former mod. $m_i$.
For instance, consider the first congruence: as $5\cdot 7\equiv 2\mod 3$, which is its own inverse, and $\equiv 0\mod 5,7$,we see that
$$(5\cdot7)\cdot 2\begin{cases}\equiv 1\mod3,\\[1ex]\equiv 0 \mod 5,7 \end{cases}\quad\text{hence }\quad\alpha\cdot(5\cdot7)\cdot 2\begin{cases}\equiv \alpha\mod3\\[1ex]\equiv 0 \mod 5,7 \end{cases}$$
So we obtain a formula analog to Lagrange's interpolation formula:
$$ \alpha \cdot (5 \cdot 7) \cdot 2 + \beta \cdot (3 \cdot 7) \cdot 1 + \gamma\cdot (3 \cdot 5) \cdot 1 \equiv\begin{cases}\alpha\mod 3, \\[1ex]\beta\mod 5,\\[1ex]\gamma\mod 7. \end{cases}$$
</s>