Definition log2ceil (n: nat): nat :=
  match n with
  | 0 => 0
  | S n' => ceil_log2_S n'
  end.Function floor_log2_S (n: nat) {wf lt n}: nat :=
  match n with
  | 0 => 0
  | S n' => S (floor_log2_S (div2 n'))
  end.

(* Specifications: *)
Lemma pow2_ceil_log2: forall n, S n <= pow 2 (ceil_log2_S n).
Lemma ceil_log2_Sn_le_n: forall n, ceil_log2_S n <= n.
Lemma log2ceil_lt: forall n, 0 < n -> log2ceil n < n.
Lemma log2ceil_le: forall n, log2ceil n <= n.
Lemma log2ceil_S_preserves_le x y: x <= y -> ceil_log2_S x <= ceil_log2_S y.
Lemma log2ceil_preserves_le x y: x <= y -> log2ceil x <= log2ceil y.
Lemma INR_S_ne_0 n: INR (S n) <> 0%R.
Lemma O_le_inv_INR_S n: (0 <= / INR (S n))%R.
Lemma INR_0_inv n: INR n = 0%R -> n = 0.
Lemma O_lt_INR_S n: (0 < INR (S n))%R.