(** ** Properties of [shrx] (signed division by a power of 2) *)

(* Specifications: *)
Lemma Zquot_Zdiv:
forall x y,
y > 0 ->
Z.quot x y = if zlt x 0 then (x + y - 1) / y else x / y.
Theorem shrx_zero:
forall x, zwordsize > 1 -> shrx x zero = x.
Theorem shrx_shr:
forall x y,
ltu y (repr (zwordsize - 1)) = true ->
shrx x y = shr (if lt x zero then add x (sub (shl one y) one) else x) y.
Theorem shrx_shr_2:
forall x y,
ltu y (repr (zwordsize - 1)) = true ->
shrx x y = shr (add x (shru (shr x (repr (zwordsize - 1))) (sub iwordsize y))) y.
Lemma Zdiv_shift:
forall x y, y > 0 ->
(x + (y - 1)) / y = x / y + if zeq (Z.modulo x y) 0 then 0 else 1.
Theorem shrx_carry:
forall x y,
ltu y (repr (zwordsize - 1)) = true ->
shrx x y = add (shr x y) (shr_carry x y).