Division Theorem

Theorem
For every pair of integers $$a, b$$ where $$b \ne 0$$, there exist unique integers $$q, r$$ such that $$a = q b + r$$ and $$0 \le r < \left|{b}\right|$$.

$$\forall a, b \in \mathbb{Z}, b \ne 0: \exists! q, r \in \mathbb{Z}: a = q b + r, 0 \le r < \left|{b}\right|$$

Proof

 * First we need to prove $$\forall a, b \in \mathbb{Z}, a \ge 0, b > 0: \exists! q, r \in \mathbb{Z}: a = q b + r, 0 \le r < b$$.

That is, we prove the theorem for non-negative $$a$$ and positive $$b$$.

Let us define the set $$S$$ as:

$$S = \left\{{x \in \mathbb{Z}: x = a - z b, z \in \mathbb{Z}, x \ge 0}\right\}$$

$$S \ne \varnothing$$ because, by putting $$z = 0$$, we find that $$a \in S$$.

Now $$S$$ is bounded below by $$0$$ and therefore has a least element, which we will call $$r$$.

Thus $$\exists q \in \mathbb{Z}: a - q b = r \Longrightarrow \exists q \in \mathbb{Z}: a = q b + r$$.

So we have proved the existence of $$q$$ and $$r$$ such that $$a = q b + r$$.

Now we need to show that $$0 \le r < b$$.

We already know that $$0 \le r$$ as $$r \in S$$ and is therefore bounded below by $$0$$.

Suppose $$b \le r$$. As $$b > 0$$, we see that $$r < r + b$$.

Thus $$b \le r < r + b \Longrightarrow 0 \le r - b < r$$.

So $$r - b = \left({a - q b}\right) - b = a - b \left({q + 1}\right)$$.

So $$r - b \in S$$ as it is of the correct form.

But $$r - b < r$$ contradicts the choice of $$r$$ as the least element of $$S$$.

Hence $$r < b$$ as required.

So we have now established the existence of $$q$$ and $$r$$ satisfying $$a = q b + r, 0 \le r < b$$.


 * Now we need to prove that $$q$$ and $$r$$ are unique.

Suppose $$q_1, r_1$$ and $$q_2, r_2$$ are two pairs of $$q, r$$ that satisfy $$a = q b + r, 0 \le r < b$$.

That is:

$$a = q_1 b + r_1, 0 \le r_1 < b$$

$$a = q_2 b + r_2, 0 \le r_2 < b$$

This gives $$0 = b \left({q_1 - q_2}\right) + \left({r_1 - r_2}\right)$$.

If $$q_1 \ne q_2$$, let $$q_1 > q_2 \Longrightarrow q_1 - q_2 \ge 1$$.

Since $$b > 0$$, we get $$r_2 - r_1 = b \left({q_1 - q_2}\right) \ge b \times 1 = b$$.

So $$r_2 \ge r_1 + b \ge b$$ which contradicts the assumption that $$r_2 < b$$.

Similarly for if $$q_1 < q_2$$.

Therefore $$q_1 = q_2$$ and so $$r_1 = r_2$$, and so $$q$$ and $$r$$ are unique after all.

Thus we have proved the Division Theorem for $$a \ge 0, b > 0$$.


 * Now we need to prove the Theorem for $$a < 0$$.

Now, we know that $$\exists \tilde q, \tilde r \in \mathbb{Z}: \left|{a}\right| = \tilde q b + \tilde r, 0 \le \tilde r < b$$.

Since $$\left|{a}\right| = -a$$, this gives:

If $$\tilde r = 0$$, then $$q = -\tilde q, r = \tilde r = 0$$, which gives $$a = q b + r, 0 \le r < b$$ as required.

Otherwise we have $$0 < \tilde r < b \Longrightarrow 0 < b - \tilde r < b$$, which suggests we rearrange the expression for $$a$$ above:

Now if we take $$q = \left({-1 - \tilde q}\right)$$ and $$r = \left({b - \tilde r}\right)$$, we have the required result.


 * Now the proof is extended to take on negative values of $$b$$.

Let $$b < 0$$.

Consider $$\left|{b}\right| = -b > 0$$.

By the above, we have the existence of $$\tilde q, \tilde r \in \mathbb{Z}$$ such that $$a = \tilde q \left|{b}\right| + \tilde r, 0 \le \tilde r < \left|{b}\right|$$.

Since $$\left|{b}\right| = -b$$, we have:

$$a = \tilde q \left({-b}\right) + \left({\tilde r}\right) = \left({-\tilde q}\right) b + \tilde r$$

We define $$q = -\tilde q, r = \tilde r$$ and we have proved the existence of integers that satisfy the requirements.

The proof that they are unique is the same as that for the proof for positive $$b$$, but with $$\left|{b}\right|$$ replacing $$b$$.

That finishes the proof.

Comment
Otherwise known as the Quotient-Remainder Theorem.

Some sources call this the division algorithm but it is preferable not to offer up a possible source of confusion between this and the Euclidean Algorithm to which it is closely related.