Common Factor Cancelling in Congruence

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

Let:
 * $a x \equiv b y \pmod m$ and $a \equiv b \pmod m$

where $a \equiv b \pmod m$ denotes that $a$ is congruent modulo $m$ to $b$.

Then:
 * $x \equiv y \pmod {m / d}$

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

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

From Law of Inverses (Modulo Arithmetic), we have:
 * $\exists a' \in \Z: a a' \equiv d \pmod m$

Hence:

Then:

Hence the result.