diff options
Diffstat (limited to 'theories/PArith')
-rw-r--r-- | theories/PArith/BinPos.v | 10 | ||||
-rw-r--r-- | theories/PArith/BinPosDef.v | 9 |
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 := |