diff options
Diffstat (limited to 'theories/NArith')
-rw-r--r-- | theories/NArith/BinNat.v | 7 | ||||
-rw-r--r-- | theories/NArith/BinNatDef.v | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/theories/NArith/BinNat.v b/theories/NArith/BinNat.v index 228be4d1a..418fd8e58 100644 --- a/theories/NArith/BinNat.v +++ b/theories/NArith/BinNat.v @@ -442,6 +442,13 @@ Proof. now destruct p. Qed. +(** Specification of square *) + +Lemma square_spec n : square n = n * n. +Proof. + destruct n; trivial. simpl. f_equal. apply Pos.square_spec. +Qed. + (** Specification of Base-2 logarithm *) Lemma size_log2 n : n<>0 -> size n = succ (log2 n). diff --git a/theories/NArith/BinNatDef.v b/theories/NArith/BinNatDef.v index d459f8509..d7660422a 100644 --- a/theories/NArith/BinNatDef.v +++ b/theories/NArith/BinNatDef.v @@ -181,6 +181,14 @@ Definition pow n p := Infix "^" := pow : N_scope. +(** Square *) + +Definition square n := + match n with + | 0 => 0 + | Npos p => Npos (Pos.square p) + end. + (** Base-2 logarithm *) Definition log2 n := |