This proof models sharing through repeated subtraction.
Consider the following algorithm for \(\textcolor{olive}{a}\in\mathbb{N}\) and \(\textcolor{colordef}{b}\in\mathbb{N}^*\):
- Initialization: Set \(\textcolor{orange}{r}=\textcolor{olive}{a}\) and \(\textcolor{colorprop}{q}=0\).
- Loop: While \(\textcolor{orange}{r}\ge \textcolor{colordef}{b}\) do: $$ \textcolor{orange}{r}\leftarrow \textcolor{orange}{r}-\textcolor{colordef}{b} \quad\text{and}\quad \textcolor{colorprop}{q}\leftarrow \textcolor{colorprop}{q}+1. $$
Termination: Since \(\textcolor{colordef}{b}>0\), \(\textcolor{orange}{r}\) decreases at each step and remains non-negative. It eventually reaches \(\textcolor{orange}{r}<\textcolor{colordef}{b}\) in finite time.
Invariant: The relation \(\textcolor{olive}{a}=\textcolor{colordef}{b}\textcolor{colorprop}{q}+\textcolor{orange}{r}\) is preserved at each iteration. Upon termination, we have \(0\le \textcolor{orange}{r}<\textcolor{colordef}{b}\).
Uniqueness: If \(\textcolor{olive}{a}=\textcolor{colordef}{b}q+r=\textcolor{colordef}{b}q'+r'\) with \(0\le r,r'<\textcolor{colordef}{b}\), then \(\textcolor{colordef}{b}(q-q')=r'-r\). The right-hand side satisfies \(-(\textcolor{colordef}{b}-1)\le r'-r\le \textcolor{colordef}{b}-1\), so the only multiple of \(\textcolor{colordef}{b}\) in this range is \(0\). Hence \(r=r'\) and \(q=q'\).