(** Hence the number of bits of [a] is [1+log2 a] (see [Pos.size_nat] and [Pos.size]). *)
(** Testing bits after division or multiplication by a power of two *)

(* Specifications: *)
Lemma testbit_div2 : forall a n, (div2 a).[n] = a.[S n].
Lemma div2_bits : forall a n, (a/2).[n] = a.[S n].
Lemma div_pow2_bits : forall a n m, (a/2^n).[m] = a.[m+n].
Lemma double_bits_succ : forall a n, (2*a).[S n] = a.[n].
Lemma mul_pow2_bits_add : forall a n m, (a*2^n).[m+n] = a.[m].
Lemma mul_pow2_bits_high : forall a n m, n<=m -> (a*2^n).[m] = a.[m-n].
Lemma mul_pow2_bits_low : forall a n m, m<n -> (a*2^n).[m] = false.
(** Selecting the low part of a number can be done by a modulo *)
Lemma mod_pow2_bits_high : forall a n m, n<=m ->
(a mod 2^n).[m] = false.
Lemma mod_pow2_bits_low : forall a n m, m<n ->
(a mod 2^n).[m] = a.[m].