aboutsummaryrefslogtreecommitdiff
path: root/theories/Numbers/Integer/BigZ
diff options
context:
space:
mode:
Diffstat (limited to 'theories/Numbers/Integer/BigZ')
-rw-r--r--theories/Numbers/Integer/BigZ/BigZ.v3
-rw-r--r--theories/Numbers/Integer/BigZ/ZMake.v15
2 files changed, 18 insertions, 0 deletions
diff --git a/theories/Numbers/Integer/BigZ/BigZ.v b/theories/Numbers/Integer/BigZ/BigZ.v
index 92be49bdaf..b2bf8703ea 100644
--- a/theories/Numbers/Integer/BigZ/BigZ.v
+++ b/theories/Numbers/Integer/BigZ/BigZ.v
@@ -63,10 +63,13 @@ Arguments Scope BigZ.eq_bool [bigZ_scope bigZ_scope].
Arguments Scope BigZ.pow_pos [bigZ_scope positive_scope].
Arguments Scope BigZ.pow_N [bigZ_scope N_scope].
Arguments Scope BigZ.pow [bigZ_scope bigZ_scope].
+Arguments Scope BigZ.log2 [bigZ_scope].
Arguments Scope BigZ.sqrt [bigZ_scope].
Arguments Scope BigZ.div_eucl [bigZ_scope bigZ_scope].
Arguments Scope BigZ.modulo [bigZ_scope bigZ_scope].
Arguments Scope BigZ.gcd [bigZ_scope bigZ_scope].
+Arguments Scope BigZ.even [bigZ_scope].
+Arguments Scope BigZ.odd [bigZ_scope].
Local Notation "0" := BigZ.zero : bigZ_scope.
Local Notation "1" := BigZ.one : bigZ_scope.
diff --git a/theories/Numbers/Integer/BigZ/ZMake.v b/theories/Numbers/Integer/BigZ/ZMake.v
index 099554cd0b..b341b32095 100644
--- a/theories/Numbers/Integer/BigZ/ZMake.v
+++ b/theories/Numbers/Integer/BigZ/ZMake.v
@@ -332,6 +332,21 @@ Module Make (N:NType) <: ZType.
apply N.spec_0.
Qed.
+ Definition log2 x :=
+ match x with
+ | Pos nx => Pos (N.log2 nx)
+ | Neg nx => zero
+ end.
+
+ Theorem spec_log2: forall x, to_Z (log2 x) = Zlog2 (to_Z x).
+ Proof.
+ intros. destruct x as [p|p]; simpl. apply N.spec_log2.
+ rewrite N.spec_0.
+ destruct (Z_le_lt_eq_dec _ _ (N.spec_pos p)) as [LT|EQ].
+ rewrite Zlog2_nonpos; auto with zarith.
+ now rewrite <- EQ.
+ Qed.
+
Definition sqrt x :=
match x with
| Pos nx => Pos (N.sqrt nx)