(** shifts and constants *)

(* Specifications: *)
Lemma shiftl_1_l : forall n, 1 << n == 2^n.
Lemma shiftl_0_r : forall a, a << 0 == a.
Lemma shiftr_0_r : forall a, a >> 0 == a.
Lemma shiftl_0_l : forall n, 0 << n == 0.
Lemma shiftr_0_l : forall n, 0 >> n == 0.
Lemma shiftl_eq_0_iff : forall a n, a << n == 0 <-> a == 0.
Lemma shiftr_eq_0_iff : forall a n,
a >> n == 0 <-> a==0 \/ (0<a /\ log2 a < n).
Lemma shiftr_eq_0 : forall a n, log2 a < n -> a >> n == 0.
(** Properties of [div2]. *)
Lemma div2_div : forall a, div2 a == a/2.
Lemma div2_0 : div2 0 == 0.
Lemma div2_1 : div2 1 == 0.
#[global]
Instance div2_wd : Proper (eq==>eq) div2.
Lemma div2_odd : forall a, a == 2*(div2 a) + odd a.
Lemma div2_even : forall a, div2 (2 * a) == a.
Lemma div2_odd' : forall a, div2 (2 * a + 1) == a.
Lemma le_div2_diag_l a : div2 a <= a.
Lemma div2_le_upper_bound a q : a <= 2 * q -> div2 a <= q.
Lemma div2_le_lower_bound a q : 2 * q <= a -> q <= div2 a.
Lemma lt_div2_diag_l a : a ~= 0 -> div2 a < a.
Lemma le_div2 n : div2 (S n) <= n.
Lemma lt_div2 n : 0 < n -> div2 n < n.
#[global]
Instance lxor_wd : Proper (eq ==> eq ==> eq) lxor.
Lemma shiftl_1_l : forall n, 1 << n == 2^n.
Lemma shiftl_0_r : forall a, a << 0 == a.
Lemma shiftr_0_r : forall a, a >> 0 == a.
Lemma shiftl_0_l : forall n, 0 << n == 0.
Lemma shiftr_0_l : forall n, 0 >> n == 0.
Lemma shiftl_eq_0_iff : forall a n, 0<=n -> (a << n == 0 <-> a == 0).
Lemma shiftr_eq_0_iff : forall a n,
a >> n == 0 <-> a==0 \/ (0<a /\ log2 a < n).
Lemma shiftr_eq_0 : forall a n, 0<=a -> log2 a < n -> a >> n == 0.
(** Properties of [div2]. *)
Lemma div2_div : forall a, div2 a == a/2.
#[global]
Instance div2_wd : Proper (eq==>eq) div2.
Lemma div2_odd : forall a, a == 2*(div2 a) + odd a.
#[global]
Instance lxor_wd : Proper (eq ==> eq ==> eq) lxor.