Section PreliminaryLemmas.
Definition cdivz (x y : int) : int :=
(let q := (x %/ y) in
if (y == 0) || (2%:R * (x %% y)%Z <= `|y|) then
q else q + (-1) ^+ (y < 0)%R)%Z.
Infix "%c/" := cdivz (at level 40) : int_scope.
Definition cmodz (x y : int) : int := x - (x %c/ y)%Z * y.
Infix "%c%" := cmodz (at level 40) : int_scope.

Lemma cdivz_eq (x y :  int) : x = (x %c/ y)%Z * y + (x %c% y)%Z.