(*****************************************************)
(**            Logarithm for the base 2              *)

Definition log (x : N.t) : N.t :=
strong_rec 0
           (fun g x =>
              if x << 2 then 0
              else S (g (half x)))
           x.#[global]
Instance log_prewd :
 Proper ((N.eq==>N.eq)==>N.eq==>N.eq)
   (fun g x => if x<<2 then 0 else S (g (half x))).#[global]
Instance log_wd : Proper (N.eq==>N.eq) log.

Theorem pow2_log : forall n, 0 < n -> half n < 2^^(log n) <= n.