(** ** Properties of division and modulus *)

(* Specifications: *)
Lemma modu_divu_Euclid:
forall x y, y <> zero -> x = add (mul (divu x y) y) (modu x y).
Theorem modu_divu:
forall x y, y <> zero -> modu x y = sub x (mul (divu x y) y).
Lemma mods_divs_Euclid:
forall x y, x = add (mul (divs x y) y) (mods x y).
Theorem mods_divs:
forall x y, mods x y = sub x (mul (divs x y) y).
Theorem divu_one:
forall x, divu x one = x.
Theorem divs_one:
forall x, zwordsize > 1 -> divs x one = x.
Theorem modu_one:
forall x, modu x one = zero.
Theorem divs_mone:
forall x, divs x mone = neg x.
Theorem mods_mone:
forall x, mods x mone = zero.
Theorem divmodu2_divu_modu:
forall n d,
d <> zero -> divmodu2 zero n d = Some (divu n d, modu n d).
Lemma unsigned_signed:
forall n, unsigned n = if lt n zero then signed n + modulus else signed n.
Theorem divmods2_divs_mods:
forall n d,
d <> zero -> n <> repr min_signed \/ d <> mone ->
divmods2 (if lt n zero then mone else zero) n d = Some (divs n d, mods n d).
Lemma modu_divu_Euclid:
forall x y, y <> zero -> x = add (mul (divu x y) y) (modu x y).
Theorem modu_divu:
forall x y, y <> zero -> modu x y = sub x (mul (divu x y) y).
Lemma mods_divs_Euclid:
forall x y, x = add (mul (divs x y) y) (mods x y).
Theorem mods_divs:
forall x y, mods x y = sub x (mul (divs x y) y).
Theorem divu_one:
forall x, divu x one = x.
Theorem divs_one:
forall x, zwordsize > 1 -> divs x one = x.
Theorem modu_one:
forall x, modu x one = zero.
Theorem divs_mone:
forall x, divs x mone = neg x.
Theorem mods_mone:
forall x, mods x mone = zero.
Theorem divmodu2_divu_modu:
forall n d,
d <> zero -> divmodu2 zero n d = Some (divu n d, modu n d).
Lemma unsigned_signed:
forall n, unsigned n = if lt n zero then signed n + modulus else signed n.
Theorem divmods2_divs_mods:
forall n d,
d <> zero -> n <> repr min_signed \/ d <> mone ->
divmods2 (if lt n zero then mone else zero) n d = Some (divs n d, mods n d).