End NZLog2Prop.
Module NZLog2UpProp
(Import A : NZDecOrdAxiomsSig')
(Import B : NZPow' A)
(Import C : NZLog2 A B)
(Import D : NZMulOrderProp A)
(Import E : NZPowProp A B D)
(Import F : NZLog2Prop A B C D E).
(** * [log2_up] : a binary logarithm that rounds up instead of down *)
(** For once, we define instead of axiomatizing, thanks to log2 *)
Definition log2_up a :=
match compare 1 a with
| Lt => S (log2 (P a))
| _ => 0
end.

(* Specifications: *)
Lemma log2_up_eqn0 : forall a, a<=1 -> log2_up a == 0.
Lemma log2_up_eqn : forall a, 1<a -> log2_up a == S (log2 (P a)).
Lemma log2_up_spec : forall a, 1<a ->
2^(P (log2_up a)) < a <= 2^(log2_up a).
Lemma log2_up_nonpos : forall a, a<=0 -> log2_up a == 0.
#[global]
Instance log2_up_wd : Proper (eq==>eq) log2_up.