From d2204e78c2d8bfc4f46ba541749b07dedd5e7969 Mon Sep 17 00:00:00 2001 From: letouzey Date: Fri, 1 Jul 2011 17:38:17 +0000 Subject: 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 --- theories/PArith/BinPos.v | 10 ++++++++++ theories/PArith/BinPosDef.v | 9 +++++++++ 2 files changed, 19 insertions(+) (limited to 'theories/PArith') 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 := -- cgit v1.2.3