Lemma. Correctness of the division algorithm [01CW]

The division algorithm terminates on the appropriate inputs: for any natural number m and positive natural number n, the evaluation of \mathtt {divide}~m~n terminates with a pair {\mathopen {}\left (q,r\right )\mathclose {}} such that r < n and m = qn + r.