aboutsummaryrefslogtreecommitdiffhomepage
path: root/theories/PArith
diff options
context:
space:
mode:
authorGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2011-07-01 17:38:17 +0000
committerGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2011-07-01 17:38:17 +0000
commitd2204e78c2d8bfc4f46ba541749b07dedd5e7969 (patch)
treed2c9de4d986dc2f37744fad6f434ddac1506a8e0 /theories/PArith
parentae95b79d0912a7b1a5370854cb6fb1aadb1db6b2 (diff)
Cleanup of files related with power over Z.
- Zpow_def, Zpower, Zpow_facts shortened thanks to stuff in BinInt.Z - The alternative Zpower_alt is now in a separate file Zpow_alt.v, not loaded by default. - Some more injection lemmas in Znat (pow, div, mod, quot, rem) - Btw, added a "square" function in Z, N, Pos, ... (instead of Zpow_facts.Zsquare). git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@14253 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'theories/PArith')
-rw-r--r--theories/PArith/BinPos.v10
-rw-r--r--theories/PArith/BinPosDef.v9
2 files changed, 19 insertions, 0 deletions
diff --git a/theories/PArith/BinPos.v b/theories/PArith/BinPos.v
index 956421785..2e4d52a29 100644
--- a/theories/PArith/BinPos.v
+++ b/theories/PArith/BinPos.v
@@ -629,6 +629,16 @@ Proof.
unfold pow. now rewrite iter_succ.
Qed.
+(** ** Properties of square *)
+
+Lemma square_spec p : square p = p * p.
+Proof.
+ induction p.
+ - rewrite square_xI. simpl. now rewrite IHp.
+ - rewrite square_xO. simpl. now rewrite IHp.
+ - trivial.
+Qed.
+
(** ** Properties of [sub_mask] *)
Lemma sub_mask_succ_r p q :
diff --git a/theories/PArith/BinPosDef.v b/theories/PArith/BinPosDef.v
index b6b7ab7a5..7916511a4 100644
--- a/theories/PArith/BinPosDef.v
+++ b/theories/PArith/BinPosDef.v
@@ -210,6 +210,15 @@ Definition pow (x y:positive) := iter y (mul x) 1.
Infix "^" := pow : positive_scope.
+(** ** Square *)
+
+Fixpoint square p :=
+ match p with
+ | p~1 => (square p + p)~0~1
+ | p~0 => (square p)~0~0
+ | 1 => 1
+ end.
+
(** ** Division by 2 rounded below but for 1 *)
Definition div2 p :=