aboutsummaryrefslogtreecommitdiffhomepage
path: root/theories/ZArith
diff options
context:
space:
mode:
authorGravatar Pierre Boutillier <pierre.boutillier@ens-lyon.org>2014-04-25 16:17:15 +0200
committerGravatar Pierre Boutillier <pierre.boutillier@ens-lyon.org>2014-05-02 11:05:19 +0200
commit1432318faa4cb6a50eca2c7a371b43b3b9969666 (patch)
tree694d6a8266ec1aad5f0439cfb0a3fa41fb8fd270 /theories/ZArith
parentc3e091756e0030e29e231ca1d7c3bd12ded55760 (diff)
Pos.iter arguments in a better order for cbn.
Diffstat (limited to 'theories/ZArith')
-rw-r--r--theories/ZArith/BinInt.v6
-rw-r--r--theories/ZArith/BinIntDef.v8
-rw-r--r--theories/ZArith/Zpow_alt.v6
-rw-r--r--theories/ZArith/Zpower.v14
4 files changed, 17 insertions, 17 deletions
diff --git a/theories/ZArith/BinInt.v b/theories/ZArith/BinInt.v
index 6948d420a..452e3d148 100644
--- a/theories/ZArith/BinInt.v
+++ b/theories/ZArith/BinInt.v
@@ -959,7 +959,7 @@ Proof.
destruct m; easy || now destruct Hm.
destruct a as [ |a|a].
(* a = 0 *)
- replace (Pos.iter n div2 0) with 0
+ replace (Pos.iter div2 0 n) with 0
by (apply Pos.iter_invariant; intros; subst; trivial).
now rewrite 2 testbit_0_l.
(* a > 0 *)
@@ -982,7 +982,7 @@ Proof.
rewrite ?Pos.iter_succ; apply testbit_even_0.
destruct a as [ |a|a].
(* a = 0 *)
- replace (Pos.iter n (mul 2) 0) with 0
+ replace (Pos.iter (mul 2) 0 n) with 0
by (apply Pos.iter_invariant; intros; subst; trivial).
apply testbit_0_l.
(* a > 0 *)
@@ -1013,7 +1013,7 @@ Proof.
f_equal. now rewrite Pos.add_comm, Pos.add_sub.
destruct a; unfold shiftl.
(* ... a = 0 *)
- replace (Pos.iter n (mul 2) 0) with 0
+ replace (Pos.iter (mul 2) 0 n) with 0
by (apply Pos.iter_invariant; intros; subst; trivial).
now rewrite 2 testbit_0_l.
(* ... a > 0 *)
diff --git a/theories/ZArith/BinIntDef.v b/theories/ZArith/BinIntDef.v
index 958ce2ef7..4e7fdcdff 100644
--- a/theories/ZArith/BinIntDef.v
+++ b/theories/ZArith/BinIntDef.v
@@ -126,7 +126,7 @@ Infix "*" := mul : Z_scope.
(** ** Power function *)
-Definition pow_pos (z:Z) (n:positive) := Pos.iter n (mul z) 1.
+Definition pow_pos (z:Z) := Pos.iter (mul z) 1.
Definition pow x y :=
match y with
@@ -306,7 +306,7 @@ Definition to_pos (z:Z) : positive :=
Definition iter (n:Z) {A} (f:A -> A) (x:A) :=
match n with
- | pos p => Pos.iter p f x
+ | pos p => Pos.iter f x p
| _ => x
end.
@@ -568,8 +568,8 @@ Definition testbit a n :=
Definition shiftl a n :=
match n with
| 0 => a
- | pos p => Pos.iter p (mul 2) a
- | neg p => Pos.iter p div2 a
+ | pos p => Pos.iter (mul 2) a p
+ | neg p => Pos.iter div2 a p
end.
Definition shiftr a n := shiftl a (-n).
diff --git a/theories/ZArith/Zpow_alt.v b/theories/ZArith/Zpow_alt.v
index f3eb63a8a..73b1989e4 100644
--- a/theories/ZArith/Zpow_alt.v
+++ b/theories/ZArith/Zpow_alt.v
@@ -30,12 +30,12 @@ Infix "^^" := Zpower_alt (at level 30, right associativity) : Z_scope.
Lemma Piter_mul_acc : forall f,
(forall x y:Z, (f x)*y = f (x*y)) ->
- forall p k, Pos.iter p f k = (Pos.iter p f 1)*k.
+ forall p k, Pos.iter f k p = (Pos.iter f 1 p)*k.
Proof.
intros f Hf.
induction p; simpl; intros.
- - set (g := Pos.iter p f 1) in *. now rewrite !IHp, Hf, Z.mul_assoc.
- - set (g := Pos.iter p f 1) in *. now rewrite !IHp, Z.mul_assoc.
+ - set (g := Pos.iter f 1 p) in *. now rewrite !IHp, Hf, Z.mul_assoc.
+ - set (g := Pos.iter f 1 p) in *. now rewrite !IHp, Z.mul_assoc.
- now rewrite Hf, Z.mul_1_l.
Qed.
diff --git a/theories/ZArith/Zpower.v b/theories/ZArith/Zpower.v
index 7ccaa119c..1da3c7992 100644
--- a/theories/ZArith/Zpower.v
+++ b/theories/ZArith/Zpower.v
@@ -95,11 +95,11 @@ Section Powers_of_2.
[m] shifted by [n] positions *)
Definition shift_nat (n:nat) (z:positive) := nat_rect _ z (fun _ => xO) n.
- Definition shift_pos (n z:positive) := Pos.iter n xO z.
+ Definition shift_pos (n z:positive) := Pos.iter xO z n.
Definition shift (n:Z) (z:positive) :=
match n with
| Z0 => z
- | Zpos p => Pos.iter p xO z
+ | Zpos p => Pos.iter xO z p
| Zneg p => z
end.
@@ -247,10 +247,10 @@ Section power_div_with_rest.
end, 2 * d).
Definition Zdiv_rest (x:Z) (p:positive) :=
- let (qr, d) := Pos.iter p Zdiv_rest_aux (x, 0, 1) in qr.
+ let (qr, d) := Pos.iter Zdiv_rest_aux (x, 0, 1) p in qr.
Lemma Zdiv_rest_correct1 (x:Z) (p:positive) :
- let (_, d) := Pos.iter p Zdiv_rest_aux (x, 0, 1) in
+ let (_, d) := Pos.iter Zdiv_rest_aux (x, 0, 1) p in
d = two_power_pos p.
Proof.
rewrite Pos2Nat.inj_iter, two_power_pos_nat.
@@ -260,7 +260,7 @@ Section power_div_with_rest.
Qed.
Lemma Zdiv_rest_correct2 (x:Z) (p:positive) :
- let '(q,r,d) := Pos.iter p Zdiv_rest_aux (x, 0, 1) in
+ let '(q,r,d) := Pos.iter Zdiv_rest_aux (x, 0, 1) p in
x = q * d + r /\ 0 <= r < d.
Proof.
apply Pos.iter_invariant; [|omega].
@@ -287,7 +287,7 @@ Section power_div_with_rest.
Lemma Zdiv_rest_correct (x:Z) (p:positive) : Zdiv_rest_proofs x p.
Proof.
generalize (Zdiv_rest_correct1 x p); generalize (Zdiv_rest_correct2 x p).
- destruct (Pos.iter p Zdiv_rest_aux (x, 0, 1)) as ((q,r),d).
+ destruct (Pos.iter Zdiv_rest_aux (x, 0, 1) p) as ((q,r),d).
intros (H1,(H2,H3)) ->. now exists q r.
Qed.
@@ -299,7 +299,7 @@ Section power_div_with_rest.
Proof.
unfold Zdiv_rest.
generalize (Zdiv_rest_correct1 x p); generalize (Zdiv_rest_correct2 x p).
- destruct (Pos.iter p Zdiv_rest_aux (x, 0, 1)) as ((q,r),d).
+ destruct (Pos.iter Zdiv_rest_aux (x, 0, 1) p) as ((q,r),d).
intros H ->. now rewrite two_power_pos_equiv in H.
Qed.