Common Factor Cancelling in Congruence

Theorem
Let $a, b, x, y, m \in \Z$.

Let:
 * $a x \equiv b y \left({\bmod\, m}\right)$ and $a \equiv b \left({\bmod\, m}\right)$

where $a \equiv b \left({\bmod\, m}\right)$ denotes that $a$ is congruent modulo $m$ to $b$.

Then:
 * $x \equiv y \left({\bmod\, \dfrac m d}\right)$

where $d = \gcd \left\{{a, m}\right\}$.

Proof
We have that $d = \gcd \left\{{a, m}\right\}$.

From Law of Inverses (Modulo Arithmetic), we have:
 * $\exists a' \in \Z: a a' \equiv d \left({\bmod\, m}\right)$

Hence:

Then:

Hence the result.

Proof of Corollary
If $a \perp m$ then $\gcd \left\{{a, m}\right\} = 1$ by definition.

The result is immediate.