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 cmodz_lt (x y : int) : y != 0 -> (2%:R * `|x %c% y| <= `|y|)%Z.