Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
This file is part of the Flocq formalization of floating-point arithmetic in Coq: http://flocq.gforge.inria.fr/
Copyright (C) 2011-2018 Sylvie Boldo
Copyright (C) 2011-2018 Guillaume Melquiond
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details.
From Coq Require Import ZArith Lia Zquot.

Require Import SpecFloatCompat.

Notation cond_Zopp := cond_Zopp (only parsing).
Notation iter_pos := iter_pos (only parsing).

Section Zmissing.
About Z

forall x y : Z, (- y <= - x)%Z -> (x <= y)%Z

forall x y : Z, (- y <= - x)%Z -> (x <= y)%Z
x, y:Z
Hxy:(- y <= - x)%Z

(x <= y)%Z
x, y:Z
Hxy:(- y <= - x)%Z

(x + (- x - y) <= y + (- x - y))%Z
now ring_simplify. Qed.

forall x y : Z, (y < x)%Z -> x <> y

forall x y : Z, (y < x)%Z -> x <> y
x, y:Z
H:(y < x)%Z
Hn:x = y

False
x, y:Z
H:(y < x)%Z
Hn:x = y

(x < x)%Z
now rewrite Hn at 1. Qed. End Zmissing. Section Proof_Irrelevance. Scheme eq_dep_elim := Induction for eq Sort Type. Definition eqbool_dep P (h1 : P true) b := match b return P b -> Prop with | true => fun (h2 : P true) => h1 = h2 | false => fun (h2 : P false) => False end.

forall (b : bool) (h1 h2 : b = true), h1 = h2

forall (b : bool) (h1 h2 : b = true), h1 = h2

forall h : true = true, eq_refl = h
H:forall h : true = true, eq_refl = h
forall (b : bool) (h1 h2 : b = true), h1 = h2
H:forall h : true = true, eq_refl = h

forall (b : bool) (h1 h2 : b = true), h1 = h2
H:forall h : true = true, eq_refl = h
b:bool

forall h1 h2 : b = true, h1 = h2
H:forall h : true = true, eq_refl = h
b:bool

forall h1 h2 : true = true, h1 = h2
H:forall h : true = true, eq_refl = h
b:bool
forall h1 h2 : false = true, h1 = h2
H:forall h : true = true, eq_refl = h
b:bool
h1, h2:true = true

h1 = h2
H:forall h : true = true, eq_refl = h
b:bool
forall h1 h2 : false = true, h1 = h2
H:forall h : true = true, eq_refl = h
b:bool

forall h1 h2 : false = true, h1 = h2
H:forall h0 : true = true, eq_refl = h0
b:bool
h:false = true

forall h2 : false = true, h = h2
discriminate h. Qed. End Proof_Irrelevance. Section Even_Odd.

forall x : Z, exists p : Z, x = (2 * p + (if Z.even x then 0 else 1))%Z

forall x : Z, exists p : Z, x = (2 * p + (if Z.even x then 0 else 1))%Z

exists p : Z, 0%Z = (2 * p + (if Z.even 0 then 0 else 1))%Z
n:positive
exists p : Z, Z.pos n~1 = (2 * p + (if Z.even (Z.pos n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.pos n~0 = (2 * p + (if Z.even (Z.pos n~0) then 0 else 1))%Z

exists p : Z, 1%Z = (2 * p + (if Z.even 1 then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~1 = (2 * p + (if Z.even (Z.neg n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z
n:positive

exists p : Z, Z.pos n~1 = (2 * p + (if Z.even (Z.pos n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.pos n~0 = (2 * p + (if Z.even (Z.pos n~0) then 0 else 1))%Z

exists p : Z, 1%Z = (2 * p + (if Z.even 1 then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~1 = (2 * p + (if Z.even (Z.neg n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z
n:positive

exists p : Z, Z.pos n~0 = (2 * p + (if Z.even (Z.pos n~0) then 0 else 1))%Z

exists p : Z, 1%Z = (2 * p + (if Z.even 1 then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~1 = (2 * p + (if Z.even (Z.neg n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z

exists p : Z, 1%Z = (2 * p + (if Z.even 1 then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~1 = (2 * p + (if Z.even (Z.neg n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z
n:positive

exists p : Z, Z.neg n~1 = (2 * p + (if Z.even (Z.neg n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z
n:positive

Z.neg n~1 = (2 * (Z.neg n - 1) + (if Z.even (Z.neg n~1) then 0 else 1))%Z
n:positive
exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z
n:positive

(2 * Z.neg n - 1)%Z = (2 * (Z.neg n - 1) + 1)%Z
n:positive
exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z
n:positive

exists p : Z, Z.neg n~0 = (2 * p + (if Z.even (Z.neg n~0) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z

exists p : Z, (-1)%Z = (2 * p + (if Z.even (-1) then 0 else 1))%Z
now exists (-1)%Z. Qed. End Even_Odd. Section Zpower.

forall n k1 k2 : Z, (0 <= k1)%Z -> (0 <= k2)%Z -> (n ^ (k1 + k2))%Z = (n ^ k1 * n ^ k2)%Z

forall n k1 k2 : Z, (0 <= k1)%Z -> (0 <= k2)%Z -> (n ^ (k1 + k2))%Z = (n ^ k1 * n ^ k2)%Z
n, k1, k2:Z
H1:(0 <= k1)%Z
H2:(0 <= k2)%Z

(n ^ (k1 + k2))%Z = (n ^ k1 * n ^ k2)%Z
now apply Zpower_exp ; apply Z.le_ge. Qed.

forall b e : Z, (0 <= e)%Z -> (b ^ e)%Z = Zpower_nat b (Z.abs_nat e)

forall b e : Z, (0 <= e)%Z -> (b ^ e)%Z = Zpower_nat b (Z.abs_nat e)
b:Z
He:(0 <= 0)%Z

(b ^ 0)%Z = Zpower_nat b (Z.abs_nat 0)
b:Z
e:positive
He:(0 <= Z.pos e)%Z
(b ^ Z.pos e)%Z = Zpower_nat b (Z.abs_nat (Z.pos e))
b:Z
e:positive
He:(0 <= Z.neg e)%Z
(b ^ Z.neg e)%Z = Zpower_nat b (Z.abs_nat (Z.neg e))
b:Z
e:positive
He:(0 <= Z.pos e)%Z

(b ^ Z.pos e)%Z = Zpower_nat b (Z.abs_nat (Z.pos e))
b:Z
e:positive
He:(0 <= Z.neg e)%Z
(b ^ Z.neg e)%Z = Zpower_nat b (Z.abs_nat (Z.neg e))
b:Z
e:positive
He:(0 <= Z.neg e)%Z

(b ^ Z.neg e)%Z = Zpower_nat b (Z.abs_nat (Z.neg e))
b:Z
e:positive
He:(0 <= Z.neg e)%Z

(0 ?= Z.neg e)%Z = Gt
apply refl_equal. Qed.

forall (b : Z) (e : nat), Zpower_nat b (S e) = (b * Zpower_nat b e)%Z

forall (b : Z) (e : nat), Zpower_nat b (S e) = (b * Zpower_nat b e)%Z
b:Z
e:nat

Zpower_nat b (S e) = (b * Zpower_nat b e)%Z
b:Z
e:nat

(Zpower_nat b 1 * Zpower_nat b e)%Z = (b * Zpower_nat b e)%Z
b:Z
e:nat

Zpower_nat b 1 = b
apply Zmult_1_r. Qed.

forall (b : Z) (p : positive), (0 < b)%Z -> (0 < Z.pow_pos b p)%Z

forall (b : Z) (p : positive), (0 < b)%Z -> (0 < Z.pow_pos b p)%Z
b:Z
p:positive
Hb:(0 < b)%Z

(0 < Z.pow_pos b p)%Z
b:Z
p:positive
Hb:(0 < b)%Z

(0 < Zpower_nat b (Pos.to_nat p))%Z
b:Z
p:positive
Hb:(0 < b)%Z

(0 < Zpower_nat b 0)%Z
b:Z
p:positive
Hb:(0 < b)%Z
n:nat
IHn:(0 < Zpower_nat b n)%Z
(0 < Zpower_nat b (S n))%Z
b:Z
p:positive
Hb:(0 < b)%Z
n:nat
IHn:(0 < Zpower_nat b n)%Z

(0 < Zpower_nat b (S n))%Z
b:Z
p:positive
Hb:(0 < b)%Z
n:nat
IHn:(0 < Zpower_nat b n)%Z

(0 < b * Zpower_nat b n)%Z
now apply Zmult_lt_0_compat. Qed.

forall b e : Z, (0 <= e)%Z -> Z.even b = false -> Z.even (b ^ e) = false

forall b e : Z, (0 <= e)%Z -> Z.even b = false -> Z.even (b ^ e) = false
b, e:Z
He:(0 <= e)%Z
Hb:Z.even b = false

Z.even (b ^ e) = false
b, e:Z
He:(0 <= e)%Z
Hb:Z.even b = false
He':(0 < e)%Z

Z.even (b ^ e) = false
b, e:Z
He:(0 <= e)%Z
Hb:Z.even b = false
He':0%Z = e
Z.even (b ^ e) = false
b, e:Z
He:(0 <= e)%Z
Hb:Z.even b = false
He':(0 < e)%Z

Z.even (b ^ e) = Z.even b
b, e:Z
He:(0 <= e)%Z
Hb:Z.even b = false
He':0%Z = e
Z.even (b ^ e) = false
b, e:Z
He:(0 <= e)%Z
Hb:Z.even b = false
He':0%Z = e

Z.even (b ^ e) = false
now rewrite <- He'. Qed.
The radix must be greater than 1
Record radix := { radix_val :> Z ; radix_prop : Zle_bool 2 radix_val = true }.


forall r1 r2 : radix, r1 = r2 -> r1 = r2

forall r1 r2 : radix, r1 = r2 -> r1 = r2
r1:Z
H1:(2 <=? r1)%Z = true
r2:Z
H2:(2 <=? r2)%Z = true
H:{| radix_val := r1; radix_prop := H1 |} = {| radix_val := r2; radix_prop := H2 |}

{| radix_val := r1; radix_prop := H1 |} = {| radix_val := r2; radix_prop := H2 |}
r1:Z
H1:(2 <=? r1)%Z = true
r2:Z
H2:(2 <=? r2)%Z = true
H:r1 = r2

{| radix_val := r1; radix_prop := H1 |} = {| radix_val := r2; radix_prop := H2 |}
r1, r2:Z
H2:(2 <=? r2)%Z = true
H:r1 = r2

forall H1 : (2 <=? r1)%Z = true, {| radix_val := r1; radix_prop := H1 |} = {| radix_val := r2; radix_prop := H2 |}
r1, r2:Z
H2:(2 <=? r2)%Z = true
H:r1 = r2

forall H1 : (2 <=? r2)%Z = true, {| radix_val := r2; radix_prop := H1 |} = {| radix_val := r2; radix_prop := H2 |}
r1, r2:Z
H2:(2 <=? r2)%Z = true
H:r1 = r2
H1:(2 <=? r2)%Z = true

{| radix_val := r2; radix_prop := H1 |} = {| radix_val := r2; radix_prop := H2 |}
r1, r2:Z
H2:(2 <=? r2)%Z = true
H:r1 = r2
H1:(2 <=? r2)%Z = true

H1 = H2
apply eqbool_irrelevance. Qed. Definition radix2 := Build_radix 2 (refl_equal _). Variable r : radix.
r:radix

(0 < r)%Z
r:radix

(0 < r)%Z
r:radix

(0 < 2)%Z
r:radix
(2 <= r)%Z
r:radix

(2 <= r)%Z
r:radix

(2 <=? r)%Z = true
apply r. Qed.
r:radix

(1 < r)%Z
r:radix

(1 < r)%Z
r:radix
v:Z
Hr:(2 <=? v)%Z = true

(1 < {| radix_val := v; radix_prop := Hr |})%Z
r:radix
v:Z
Hr:(2 <=? v)%Z = true

(1 < v)%Z
r:radix
v:Z
Hr:(2 <=? v)%Z = true

(1 < 2)%Z
r:radix
v:Z
Hr:(2 <=? v)%Z = true
(2 <= v)%Z
r:radix
v:Z
Hr:(2 <=? v)%Z = true

(2 <= v)%Z
now apply Zle_bool_imp_le. Qed.
r:radix

forall p : Z, (0 < p)%Z -> (1 < r ^ p)%Z
r:radix

forall p : Z, (0 < p)%Z -> (1 < r ^ p)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z

(1 < r ^ Z.pos p)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z

(1 < Z.pow_pos r p)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z

(1 < Zpower_nat r (Pos.to_nat p))%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z

0 < Pos.to_nat p -> (1 < Zpower_nat r (Pos.to_nat p))%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z

0 < 0 -> (1 < Zpower_nat r 0)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
0 < S n -> (1 < Zpower_nat r (S n))%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z

0 < S n -> (1 < Zpower_nat r (S n))%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z

(1 < Zpower_nat r (S n))%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z

(1 < r * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z

(0 < Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 < r * Zpower_nat r n)%Z
r:radix
n:nat

(0 < Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 < r * Zpower_nat r n)%Z
r:radix

(0 < Zpower_nat r 0)%Z
r:radix
n:nat
IHn:(0 < Zpower_nat r n)%Z
(0 < Zpower_nat r (S n))%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 < r * Zpower_nat r n)%Z
r:radix
n:nat
IHn:(0 < Zpower_nat r n)%Z

(0 < Zpower_nat r (S n))%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 < r * Zpower_nat r n)%Z
r:radix
n:nat
IHn:(0 < Zpower_nat r n)%Z

(0 < r * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 < r * Zpower_nat r n)%Z
r:radix
n:nat
IHn:(0 < Zpower_nat r n)%Z

(0 < r)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 < r * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z

(1 < r * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z

(1 <= 1 * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 * Zpower_nat r n < r * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z

(1 <= Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z
(1 * Zpower_nat r n < r * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z

(1 * Zpower_nat r n < r * Zpower_nat r n)%Z
r:radix
p:positive
Hp:(0 < Z.pos p)%Z
n:nat
IHn:0 < n -> (1 < Zpower_nat r n)%Z
H:(0 < Zpower_nat r n)%Z

(1 < r)%Z
apply radix_gt_1. Qed.
r:radix

forall p : Z, (0 <= p)%Z -> (0 < r ^ p)%Z
r:radix

forall p : Z, (0 <= p)%Z -> (0 < r ^ p)%Z
r:radix
p:Z
Hp:(0 <= p)%Z

(0 < r ^ p)%Z
r:radix
p:Z
Hp:(0 <= p)%Z

(0 < Zpower_nat r (Z.abs_nat p))%Z
r:radix
p:Z
Hp:(0 <= p)%Z

(0 < Zpower_nat r 0)%Z
r:radix
p:Z
Hp:(0 <= p)%Z
n:nat
IHn:(0 < Zpower_nat r n)%Z
(0 < Zpower_nat r (S n))%Z
r:radix
p:Z
Hp:(0 <= p)%Z
n:nat
IHn:(0 < Zpower_nat r n)%Z

(0 < Zpower_nat r (S n))%Z
r:radix
p:Z
Hp:(0 <= p)%Z
n:nat
IHn:(0 < Zpower_nat r n)%Z

(0 < r * Zpower_nat r n)%Z
r:radix
p:Z
Hp:(0 <= p)%Z
n:nat
IHn:(0 < Zpower_nat r n)%Z

(0 < r)%Z
apply radix_gt_0. Qed.
r:radix

forall e : Z, (0 <= r ^ e)%Z
r:radix

forall e : Z, (0 <= r ^ e)%Z
r:radix
e:positive

(0 <= r ^ Z.pos e)%Z
r:radix
e:positive

(0 < r ^ Z.pos e)%Z
now apply Zpower_gt_0. Qed.
r:radix

forall e1 e2 : Z, (e1 <= e2)%Z -> (r ^ e1 <= r ^ e2)%Z
r:radix

forall e1 e2 : Z, (e1 <= e2)%Z -> (r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z

(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 <= r ^ (e2 - e1 + e1))%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 <= r ^ (e2 - e1) * r ^ e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(1 * r ^ e1 <= r ^ (e2 - e1) * r ^ e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(1 <= r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= r ^ e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(0 < r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= r ^ e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= r ^ e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(0 <= r ^ e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(0 <= e1)%Z

(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
He:(e1 <= e2)%Z
H1:(e1 < 0)%Z

(r ^ e1 <= r ^ e2)%Z
r:radix
e1, e2:Z
H1:(e1 < 0)%Z

(r ^ e1 <= r ^ e2)%Z
r:radix
e1:positive
e2:Z
H1:(Z.neg e1 < 0)%Z

(r ^ Z.neg e1 <= r ^ e2)%Z
apply Zpower_ge_0. Qed.
r:radix

forall e1 e2 : Z, (0 <= e2)%Z -> (e1 < e2)%Z -> (r ^ e1 < r ^ e2)%Z
r:radix

forall e1 e2 : Z, (0 <= e2)%Z -> (e1 < e2)%Z -> (r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z

(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 < r ^ (e2 - e1 + e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 < r ^ (e2 - e1) * r ^ e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 < r ^ e1 * r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 * 1 < r ^ e1 * r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(0 < r ^ e1 <= r ^ e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 < 1 < r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(0 < r ^ e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(r ^ e1 <= r ^ e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 < 1 < r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(r ^ e1 <= r ^ e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 < 1 < r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(0 < 1 < r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(0 < 1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(1 < r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(1 < r ^ (e2 - e1))%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(0 < e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z
(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(0 <= e2 - e1)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(0 <= e1)%Z

(e1 <= e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z
(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z
H1:(e1 < 0)%Z

(r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z
He:(e1 < e2)%Z

(e1 < 0)%Z -> (r ^ e1 < r ^ e2)%Z
r:radix
e1, e2:Z
He2:(0 <= e2)%Z

(e1 < 0)%Z -> (r ^ e1 < r ^ e2)%Z
r:radix
p:positive
e2:Z
He2:(0 <= e2)%Z

(Z.neg p < 0)%Z -> (r ^ Z.neg p < r ^ e2)%Z
r:radix
p:positive
e2:Z
He2:(0 <= e2)%Z

(r ^ Z.neg p < r ^ e2)%Z
now apply Zpower_gt_0. Qed.
r:radix

forall e1 e2 : Z, (r ^ (e1 - 1) < r ^ e2)%Z -> (e1 <= e2)%Z
r:radix

forall e1 e2 : Z, (r ^ (e1 - 1) < r ^ e2)%Z -> (e1 <= e2)%Z
r:radix
e1, e2:Z
He:(r ^ (e1 - 1) < r ^ e2)%Z

(e1 <= e2)%Z
r:radix
e1, e2:Z
He:(r ^ (e1 - 1) < r ^ e2)%Z

~ (e1 > e2)%Z
r:radix
e1, e2:Z
He:(r ^ (e1 - 1) < r ^ e2)%Z
H:(e1 > e2)%Z

False
r:radix
e1, e2:Z
He:(r ^ (e1 - 1) < r ^ e2)%Z
H:(e1 > e2)%Z

(r ^ e2 <= r ^ (e1 - 1))%Z
r:radix
e1, e2:Z
He:(r ^ (e1 - 1) < r ^ e2)%Z
H:(e1 > e2)%Z

(e2 <= e1 - 1)%Z
clear -H ; omega. Qed.
r:radix

forall n : Z, (n < r ^ n)%Z
r:radix

forall n : Z, (n < r ^ n)%Z
r:radix
n:positive

(Z.pos n < r ^ Z.pos n)%Z
r:radix
n:positive

(Z.pos n < Z.pow_pos r n)%Z
r:radix
n:positive

(Z.pos n < Zpower_nat r (Pos.to_nat n))%Z
r:radix
n:positive

(Z.of_nat (Pos.to_nat n) < Zpower_nat r (Pos.to_nat n))%Z
r:radix
n:positive

(Z.of_nat 0 < Zpower_nat r 0)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(Z.of_nat (S n0) < Zpower_nat r (S n0))%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(Z.of_nat (S n0) < Zpower_nat r (S n0))%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(Z.succ (Z.of_nat n0) < Zpower_nat r (S n0))%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(Z.succ (Z.of_nat n0) < r * Zpower_nat r n0)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(Z.of_nat n0 + 1 < r * Zpower_nat r n0)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(Z.of_nat n0 + 1 < r * (Z.of_nat n0 + 1))%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(Z.of_nat n0 + 1 < r * (Z.of_nat n0 + 1))%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(0 < r * (Z.of_nat n0 + 1) - (Z.of_nat n0 + 1))%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(0 < (r - 1) * (Z.of_nat n0 + 1))%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(0 < r - 1)%Z
r:radix
n0:nat
(0 < Z.of_nat n0 + 1)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(2 <= r)%Z -> (0 < r - 1)%Z
r:radix
n0:nat
(2 <= r)%Z
r:radix
n0:nat
(0 < Z.of_nat n0 + 1)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(2 <= r)%Z
r:radix
n0:nat
(0 < Z.of_nat n0 + 1)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(2 <=? r)%Z = true
r:radix
n0:nat
(0 < Z.of_nat n0 + 1)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(0 < Z.of_nat n0 + 1)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n0:nat

(0 <= Z.of_nat n0)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(r * (Z.of_nat n0 + 1) <= r * Zpower_nat r n0)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(Z.of_nat n0 + 1 <= Zpower_nat r n0)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(0 <= r)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(0 <= r)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(0 <= 2)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z
(2 <= r)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(2 <= r)%Z
r:radix
n:positive
n0:nat
IHn0:(Z.of_nat n0 < Zpower_nat r n0)%Z

(2 <=? r)%Z = true
apply r. Qed. End Zpower. Section Div_Mod.

forall n a b : Z, (0 < a)%Z -> (0 <= b)%Z -> ((n mod (a * b)) mod b)%Z = (n mod b)%Z

forall n a b : Z, (0 < a)%Z -> (0 <= b)%Z -> ((n mod (a * b)) mod b)%Z = (n mod b)%Z
n, a:Z
Ha:(0 < a)%Z
Hb:(0 <= 0)%Z

((n mod (a * 0)) mod 0)%Z = (n mod 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z
((n mod (a * Z.pos b)) mod Z.pos b)%Z = (n mod Z.pos b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

((n mod (a * Z.pos b)) mod Z.pos b)%Z = (n mod Z.pos b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

((n - n / (a * Z.pos b) * (a * Z.pos b)) mod Z.pos b)%Z = (n mod Z.pos b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z
(a * Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

((n - n / (a * Z.pos b) * a * Z.pos b) mod Z.pos b)%Z = (n mod Z.pos b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z
(a * Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

((n + - (n / (a * Z.pos b) * a * Z.pos b)) mod Z.pos b)%Z = (n mod Z.pos b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z
(a * Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

((n + - (n / (a * Z.pos b) * a) * Z.pos b) mod Z.pos b)%Z = (n mod Z.pos b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z
(a * Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

(Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z
(a * Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

(a * Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

(a > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z
(Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.pos b)%Z

(Z.pos b > 0)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z
((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
n, a:Z
b:positive
Ha:(0 < a)%Z
Hb:(0 <= Z.neg b)%Z

((n mod (a * Z.neg b)) mod Z.neg b)%Z = (n mod Z.neg b)%Z
now elim Hb. Qed.

forall a b : Z, Z.rem a b = (a - a ÷ b * b)%Z

forall a b : Z, Z.rem a b = (a - a ÷ b * b)%Z
a, b:Z

Z.rem a b = (a - a ÷ b * b)%Z
a, b:Z

Z.rem a b = (b * (a ÷ b) + Z.rem a b - a ÷ b * b)%Z
ring. Qed.

forall n a b : Z, Z.rem (Z.rem n (a * b)) b = Z.rem n b

forall n a b : Z, Z.rem (Z.rem n (a * b)) b = Z.rem n b
n, a, b:Z

Z.rem (Z.rem n (a * b)) b = Z.rem n b
n, a, b:Z

Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z
n, a, b:Z
H:Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z
Z.rem (Z.rem n (a * b)) b = Z.rem n b
n, a, b:Z

Z.rem n (a * b) = (n + - (n ÷ (a * b) * a * b))%Z
n, a, b:Z
H:Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z
Z.rem (Z.rem n (a * b)) b = Z.rem n b
n, a, b:Z

Z.rem n (a * b) = (n + - (n ÷ (a * b) * (a * b)))%Z
n, a, b:Z
H:Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z
Z.rem (Z.rem n (a * b)) b = Z.rem n b
n, a, b:Z
H:Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z

Z.rem (Z.rem n (a * b)) b = Z.rem n b
n, a, b:Z
H:Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z

Z.rem (n + - (n ÷ (a * b) * a) * b) b = Z.rem n b
n, a, b:Z
H:Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z

(0 <= (n + - (n ÷ (a * b) * a) * b) * n)%Z
n, a, b:Z
H:Z.rem n (a * b) = (n + - (n ÷ (a * b) * a) * b)%Z

(0 <= Z.rem n (a * b) * n)%Z
apply Zrem_sgn2. Qed.

forall n a b : Z, (0 <= a)%Z -> (0 <= b)%Z -> (n mod (a * b) / a)%Z = ((n / a) mod b)%Z

forall n a b : Z, (0 <= a)%Z -> (0 <= b)%Z -> (n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z

(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z

(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

((n - n / (a * b) * (a * b)) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

((n - n / (a * b) * (b * a)) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

((n - n / (a * b) * b * a) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

((n + - (n / (a * b) * b * a)) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

((n + - (n / (a * b) * b) * a) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

(n / a + - (n / (a * b) * b))%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

(n / a + - (n / a / b * b))%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

((n / a) mod b)%Z = (n / a + - (n / a / b * b))%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

(b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z
(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':(0 < b)%Z

(a * b > 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b

(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b

(n mod (a * 0) / a)%Z = ((n / a) mod 0)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':(0 < a)%Z
Hb':0%Z = b

(0 / a)%Z = 0%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a
(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a

(n mod (a * b) / a)%Z = ((n / a) mod b)%Z
n, a, b:Z
Ha:(0 <= a)%Z
Hb:(0 <= b)%Z
Ha':0%Z = a

(n mod (0 * b) / 0)%Z = ((n / 0) mod b)%Z
now rewrite 2!Zdiv_0_r, Zmod_0_l. Qed.

forall n a b : Z, (Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b

forall n a b : Z, (Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z

(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a = 0%Z

(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z
(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a = 0%Z

(Z.rem n (0 * b) ÷ 0)%Z = Z.rem (n ÷ 0) b
n, a, b:Z
Za:a <> 0%Z
(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z

(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z

Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z
(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z

(n - n ÷ (a * b) * (a * b))%Z = (n + - (n ÷ a ÷ b * b) * a)%Z
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z
(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z

(n - n ÷ (a * b) * (a * b))%Z = (n + - (n ÷ (a * b) * b) * a)%Z
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z
(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z

(Z.rem n (a * b) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z

((n + - (n ÷ a ÷ b * b) * a) ÷ a)%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z

(n ÷ a + - (n ÷ a ÷ b * b))%Z = Z.rem (n ÷ a) b
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z
(0 <= (n + - (n ÷ a ÷ b * b) * a) * n)%Z
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z

Z.rem (n ÷ a) b = (n ÷ a + - (n ÷ a ÷ b * b))%Z
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z
(0 <= (n + - (n ÷ a ÷ b * b) * a) * n)%Z
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z

(0 <= (n + - (n ÷ a ÷ b * b) * a) * n)%Z
n, a, b:Z
Za:a <> 0%Z
H:Z.rem n (a * b) = (n + - (n ÷ a ÷ b * b) * a)%Z

(0 <= Z.rem n (a * b) * n)%Z
apply Zrem_sgn2. Qed.

forall a b : Z, (Z.abs a < b)%Z -> (a ÷ b)%Z = 0%Z

forall a b : Z, (Z.abs a < b)%Z -> (a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z

(a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

(a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
(a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

(0 <= a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
(a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

(0 <= a)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z
(a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
(a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

(a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
(a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

(a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

(- (a ÷ b))%Z = (- 0)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

(- a ÷ b)%Z = 0%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

(0 <= - a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

((a <= 0)%Z -> Z.abs a = (- a)%Z) -> (0 <= - a < b)%Z
omega. Qed.

forall a b : Z, (Z.abs a < b)%Z -> Z.rem a b = a

forall a b : Z, (Z.abs a < b)%Z -> Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z

Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

(0 <= a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

(0 <= a)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z
(a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z
H:(0 <= a)%Z

(a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z
Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

Z.rem a b = a
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

(- Z.rem a b)%Z = (- a)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

Z.rem (- a) b = (- a)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

(0 <= - a < b)%Z
a, b:Z
Ha:(Z.abs a < b)%Z
H:(a < 0)%Z

((a <= 0)%Z -> Z.abs a = (- a)%Z) -> (0 <= - a < b)%Z
omega. Qed.

forall a b c : Z, (0 <= a * b)%Z -> ((a + b) ÷ c)%Z = (a ÷ c + b ÷ c + (Z.rem a c + Z.rem b c) ÷ c)%Z

forall a b c : Z, (0 <= a * b)%Z -> ((a + b) ÷ c)%Z = (a ÷ c + b ÷ c + (Z.rem a c + Z.rem b c) ÷ c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z

((a + b) ÷ c)%Z = (a ÷ c + b ÷ c + (Z.rem a c + Z.rem b c) ÷ c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c = 0%Z

((a + b) ÷ c)%Z = (a ÷ c + b ÷ c + (Z.rem a c + Z.rem b c) ÷ c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
((a + b) ÷ c)%Z = (a ÷ c + b ÷ c + (Z.rem a c + Z.rem b c) ÷ c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z

((a + b) ÷ c)%Z = (a ÷ c + b ÷ c + (Z.rem a c + Z.rem b c) ÷ c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z

((a + b) ÷ c * c)%Z = ((a ÷ c + b ÷ c + (Z.rem a c + Z.rem b c) ÷ c) * c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z

((a + b) ÷ c * c)%Z = (a ÷ c * c + b ÷ c * c + (Z.rem a c + Z.rem b c) ÷ c * c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z

forall d : Z, (d ÷ c * c)%Z = (d - Z.rem d c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
H:forall d : Z, (d ÷ c * c)%Z = (d - Z.rem d c)%Z
((a + b) ÷ c * c)%Z = (a ÷ c * c + b ÷ c * c + (Z.rem a c + Z.rem b c) ÷ c * c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
d:Z

(d ÷ c * c)%Z = (d - Z.rem d c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
H:forall d : Z, (d ÷ c * c)%Z = (d - Z.rem d c)%Z
((a + b) ÷ c * c)%Z = (a ÷ c * c + b ÷ c * c + (Z.rem a c + Z.rem b c) ÷ c * c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
d:Z

(d ÷ c * c)%Z = (d - (d - d ÷ c * c))%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
H:forall d : Z, (d ÷ c * c)%Z = (d - Z.rem d c)%Z
((a + b) ÷ c * c)%Z = (a ÷ c * c + b ÷ c * c + (Z.rem a c + Z.rem b c) ÷ c * c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
H:forall d : Z, (d ÷ c * c)%Z = (d - Z.rem d c)%Z

((a + b) ÷ c * c)%Z = (a ÷ c * c + b ÷ c * c + (Z.rem a c + Z.rem b c) ÷ c * c)%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
H:forall d : Z, (d ÷ c * c)%Z = (d - Z.rem d c)%Z

(a + b - Z.rem (a + b) c)%Z = (a - Z.rem a c + (b - Z.rem b c) + (Z.rem a c + Z.rem b c - Z.rem (Z.rem a c + Z.rem b c) c))%Z
a, b, c:Z
Hab:(0 <= a * b)%Z
Zc:c <> 0%Z
H:forall d : Z, (d ÷ c * c)%Z = (d - Z.rem d c)%Z

(a + b - Z.rem (a + b) c)%Z = (a - Z.rem a c + (b - Z.rem b c) + (Z.rem a c + Z.rem b c - Z.rem (a + b) c))%Z
ring. Qed. End Div_Mod. Section Same_sign.

forall v u w : Z, v <> 0%Z -> (0 <= u * v)%Z -> (0 <= v * w)%Z -> (0 <= u * w)%Z

forall v u w : Z, v <> 0%Z -> (0 <= u * v)%Z -> (0 <= v * w)%Z -> (0 <= u * w)%Z
intros [|v|v] [|u|u] [|w|w] Zv Huv Hvw ; try easy ; now elim Zv. Qed.

forall v u w : Z, (v = 0%Z -> w = 0%Z) -> (0 <= u * v)%Z -> (0 <= v * w)%Z -> (0 <= u * w)%Z

forall v u w : Z, (v = 0%Z -> w = 0%Z) -> (0 <= u * v)%Z -> (0 <= v * w)%Z -> (0 <= u * w)%Z
intros [|v|v] [|u|u] [|w|w] Zv Huv Hvw ; try easy ; now discriminate Zv. Qed.

forall u v : Z, ((0 < u)%Z -> (0 <= v)%Z) -> ((0 < - u)%Z -> (0 <= - v)%Z) -> (0 <= u * v)%Z

forall u v : Z, ((0 < u)%Z -> (0 <= v)%Z) -> ((0 < - u)%Z -> (0 <= - v)%Z) -> (0 <= u * v)%Z
v:Z
Hp:(0 < 0)%Z -> (0 <= v)%Z
Hn:(0 < - 0)%Z -> (0 <= - v)%Z

(0 <= 0 * v)%Z
u:positive
v:Z
Hp:(0 < Z.pos u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.pos u)%Z -> (0 <= - v)%Z
(0 <= Z.pos u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(0 <= Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.pos u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.pos u)%Z -> (0 <= - v)%Z

(0 <= Z.pos u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(0 <= Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.pos u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.pos u)%Z -> (0 <= - v)%Z

(0 <= Z.pos u)%Z
u:positive
v:Z
Hp:(0 < Z.pos u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.pos u)%Z -> (0 <= - v)%Z
(0 <= v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(0 <= Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.pos u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.pos u)%Z -> (0 <= - v)%Z

(0 <= v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(0 <= Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z

(0 <= Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z

(0 <= Z.pos u * - v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(Z.pos u * - v)%Z = (Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z

(0 <= Z.pos u)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(0 <= - v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(Z.pos u * - v)%Z = (Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z

(0 <= - v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z
(Z.pos u * - v)%Z = (Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z

(Z.pos u * - v)%Z = (Z.neg u * v)%Z
u:positive
v:Z
Hp:(0 < Z.neg u)%Z -> (0 <= v)%Z
Hn:(0 < - Z.neg u)%Z -> (0 <= - v)%Z

(- (Z.pos u * v))%Z = (Z.neg u * v)%Z
apply Zopp_mult_distr_l. Qed.

forall u v : Z, (0 <= v)%Z -> (0 <= u * (u ÷ v))%Z

forall u v : Z, (0 <= v)%Z -> (0 <= u * (u ÷ v))%Z
u, v:Z
Hv:(0 <= v)%Z

(0 <= u * (u ÷ v))%Z
u, v:Z
Hv:(0 <= v)%Z
Hu:(0 < u)%Z

(0 <= u ÷ v)%Z
u, v:Z
Hv:(0 <= v)%Z
Hu:(0 < - u)%Z
(0 <= - (u ÷ v))%Z
u, v:Z
Hv:(0 <= v)%Z
Hu:(0 < u)%Z

(0 <= u)%Z
u, v:Z
Hv:(0 <= v)%Z
Hu:(0 < - u)%Z
(0 <= - (u ÷ v))%Z
u, v:Z
Hv:(0 <= v)%Z
Hu:(0 < - u)%Z

(0 <= - (u ÷ v))%Z
u, v:Z
Hv:(0 <= v)%Z
Hu:(0 < - u)%Z

(0 <= - u ÷ v)%Z
u, v:Z
Hv:(0 <= v)%Z
Hu:(0 < - u)%Z

(0 <= - u)%Z
now apply Zlt_le_weak. Qed. End Same_sign.
Boolean comparisons
Section Zeq_bool.

Inductive Zeq_bool_prop (x y : Z) : bool -> Prop :=
  | Zeq_bool_true_ : x = y -> Zeq_bool_prop x y true
  | Zeq_bool_false_ : x <> y -> Zeq_bool_prop x y false.


forall x y : Z, Zeq_bool_prop x y (Zeq_bool x y)

forall x y : Z, Zeq_bool_prop x y (Zeq_bool x y)
x, y:Z

Zeq_bool_prop x y (Zeq_bool x y)
x, y:Z

x = y <-> Zeq_bool x y = true -> Zeq_bool_prop x y (Zeq_bool x y)
x, y:Z
H1:x = y -> true = true
H2:true = true -> x = y

x = y
x, y:Z
H1:x = y -> false = true
H2:false = true -> x = y
x <> y
x, y:Z
H1:x = y -> false = true
H2:false = true -> x = y

x <> y
x, y:Z
H1:x = y -> false = true
H2:false = true -> x = y
H:x = y

False
x, y:Z
H1:false = true
H2:false = true -> x = y
H:x = y

False
discriminate H1. Qed.

forall x y : Z, x = y -> Zeq_bool x y = true

forall x y : Z, x = y -> Zeq_bool x y = true
x, y:Z

x = y -> Zeq_bool x y = true
apply -> Zeq_is_eq_bool. Qed.

forall x y : Z, x <> y -> Zeq_bool x y = false

forall x y : Z, x <> y -> Zeq_bool x y = false
x, y:Z

x <> y -> Zeq_bool x y = false
x, y:Z

(Zeq_bool x y = true -> x = y) -> x <> y -> Zeq_bool x y = false
x, y:Z

(true = true -> x = y) -> x <> y -> true = false
x, y:Z
(false = true -> x = y) -> x <> y -> false = false
x, y:Z
He:true = true -> x = y
Hn:x <> y

true = false
x, y:Z
(false = true -> x = y) -> x <> y -> false = false
x, y:Z
He:true = true -> x = y
Hn:x <> y

x = y
x, y:Z
(false = true -> x = y) -> x <> y -> false = false
x, y:Z

(false = true -> x = y) -> x <> y -> false = false
now intros _ _. Qed. End Zeq_bool. Section Zle_bool. Inductive Zle_bool_prop (x y : Z) : bool -> Prop := | Zle_bool_true_ : (x <= y)%Z -> Zle_bool_prop x y true | Zle_bool_false_ : (y < x)%Z -> Zle_bool_prop x y false.

forall x y : Z, Zle_bool_prop x y (x <=? y)%Z

forall x y : Z, Zle_bool_prop x y (x <=? y)%Z
x, y:Z

Zle_bool_prop x y (x <=? y)%Z
x, y:Z

(x <= y)%Z <-> (x <=? y)%Z = true -> Zle_bool_prop x y (x <=? y)%Z
x, y:Z
H1:(x <= y)%Z -> true = true
H2:true = true -> (x <= y)%Z

(x <= y)%Z
x, y:Z
H1:(x <= y)%Z -> false = true
H2:false = true -> (x <= y)%Z
(y < x)%Z
x, y:Z
H1:(x <= y)%Z -> false = true
H2:false = true -> (x <= y)%Z

(y < x)%Z
x, y:Z
H1:(x <= y)%Z -> false = true
H2:false = true -> (x <= y)%Z
H:(x <= y)%Z

(y < x)%Z
x, y:Z
H1:(x <= y)%Z -> false = true
H2:false = true -> (x <= y)%Z
H:(y < x)%Z
(y < x)%Z
x, y:Z
H1:(x <= y)%Z -> false = true
H2:false = true -> (x <= y)%Z
H:(y < x)%Z

(y < x)%Z
exact H. Qed.

forall x y : Z, (x <= y)%Z -> (x <=? y)%Z = true

forall x y : Z, (x <= y)%Z -> (x <=? y)%Z = true
x, y:Z

(x <= y)%Z -> (x <=? y)%Z = true
apply (proj1 (Zle_is_le_bool x y)). Qed.

forall x y : Z, (y < x)%Z -> (x <=? y)%Z = false

forall x y : Z, (y < x)%Z -> (x <=? y)%Z = false
x, y:Z
Hxy:(y < x)%Z

(x <=? y)%Z = false
x, y:Z
Hxy:(y < x)%Z

(if (x <=? y)%Z then (x <= y)%Z else (x > y)%Z) -> (x <=? y)%Z = false
x, y:Z
Hxy:(y < x)%Z
H:(x <= y)%Z

true = false
x, y:Z
Hxy:(y < x)%Z
H:(x > y)%Z
false = false
x, y:Z
Hxy:(y < x)%Z
H:(x <= y)%Z

(x < x)%Z
x, y:Z
Hxy:(y < x)%Z
H:(x > y)%Z
false = false
x, y:Z
Hxy:(y < x)%Z
H:(x > y)%Z

false = false
apply refl_equal. Qed. End Zle_bool. Section Zlt_bool. Inductive Zlt_bool_prop (x y : Z) : bool -> Prop := | Zlt_bool_true_ : (x < y)%Z -> Zlt_bool_prop x y true | Zlt_bool_false_ : (y <= x)%Z -> Zlt_bool_prop x y false.

forall x y : Z, Zlt_bool_prop x y (x <? y)%Z

forall x y : Z, Zlt_bool_prop x y (x <? y)%Z
x, y:Z

Zlt_bool_prop x y (x <? y)%Z
x, y:Z

(x < y)%Z <-> (x <? y)%Z = true -> Zlt_bool_prop x y (x <? y)%Z
x, y:Z
H1:(x < y)%Z -> true = true
H2:true = true -> (x < y)%Z

(x < y)%Z
x, y:Z
H1:(x < y)%Z -> false = true
H2:false = true -> (x < y)%Z
(y <= x)%Z
x, y:Z
H1:(x < y)%Z -> false = true
H2:false = true -> (x < y)%Z

(y <= x)%Z
x, y:Z
H1:(x < y)%Z -> false = true
H2:false = true -> (x < y)%Z
H:(y <= x)%Z

(y <= x)%Z
x, y:Z
H1:(x < y)%Z -> false = true
H2:false = true -> (x < y)%Z
H:(x < y)%Z
(y <= x)%Z
x, y:Z
H1:(x < y)%Z -> false = true
H2:false = true -> (x < y)%Z
H:(x < y)%Z

(y <= x)%Z
now specialize (H1 H). Qed.

forall x y : Z, (x < y)%Z -> (x <? y)%Z = true

forall x y : Z, (x < y)%Z -> (x <? y)%Z = true
x, y:Z

(x < y)%Z -> (x <? y)%Z = true
apply (proj1 (Zlt_is_lt_bool x y)). Qed.

forall x y : Z, (y <= x)%Z -> (x <? y)%Z = false

forall x y : Z, (y <= x)%Z -> (x <? y)%Z = false
x, y:Z
Hxy:(y <= x)%Z

(x <? y)%Z = false
x, y:Z
Hxy:(y <= x)%Z

(if (x <? y)%Z then (x < y)%Z else (x >= y)%Z) -> (x <? y)%Z = false
x, y:Z
Hxy:(y <= x)%Z
H:(x < y)%Z

true = false
x, y:Z
Hxy:(y <= x)%Z
H:(x >= y)%Z
false = false
x, y:Z
Hxy:(y <= x)%Z
H:(x < y)%Z

(x < x)%Z
x, y:Z
Hxy:(y <= x)%Z
H:(x >= y)%Z
false = false
x, y:Z
Hxy:(y <= x)%Z
H:(x >= y)%Z

false = false
apply refl_equal. Qed.

forall x y : Z, negb (x <=? y)%Z = (y <? x)%Z

forall x y : Z, negb (x <=? y)%Z = (y <? x)%Z
x, y:Z

negb (x <=? y)%Z = (y <? x)%Z
x, y:Z
H:(x <= y)%Z

negb true = (y <? x)%Z
x, y:Z
H:(y < x)%Z
negb false = (y <? x)%Z
x, y:Z
H:(y < x)%Z

negb false = (y <? x)%Z
now rewrite Zlt_bool_true. Qed.

forall x y : Z, negb (x <? y)%Z = (y <=? x)%Z

forall x y : Z, negb (x <? y)%Z = (y <=? x)%Z
x, y:Z

negb (x <? y)%Z = (y <=? x)%Z
x, y:Z
H:(x < y)%Z

negb true = (y <=? x)%Z
x, y:Z
H:(y <= x)%Z
negb false = (y <=? x)%Z
x, y:Z
H:(y <= x)%Z

negb false = (y <=? x)%Z
now rewrite Zle_bool_true. Qed. End Zlt_bool. Section Zcompare. Inductive Zcompare_prop (x y : Z) : comparison -> Prop := | Zcompare_Lt_ : (x < y)%Z -> Zcompare_prop x y Lt | Zcompare_Eq_ : x = y -> Zcompare_prop x y Eq | Zcompare_Gt_ : (y < x)%Z -> Zcompare_prop x y Gt.

forall x y : Z, Zcompare_prop x y (x ?= y)%Z

forall x y : Z, Zcompare_prop x y (x ?= y)%Z
x, y:Z

Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x < y)%Z

Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x > y)%Z
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x < y)%Z

match (x ?= y)%Z with | Lt => True | _ => False end -> Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x > y)%Z
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x < y)%Z

True -> Zcompare_prop x y Lt
x, y:Z
H:(x > y)%Z
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x > y)%Z

Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x > y)%Z

match (x ?= y)%Z with | Gt => True | _ => False end -> Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x > y)%Z

True -> Zcompare_prop x y Gt
x, y:Z
H:x = y
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:(x > y)%Z
H0:True

(y < x)%Z
x, y:Z
H:x = y
Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y

Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y

(x ?= y)%Z = Eq -> Zcompare_prop x y (x ?= y)%Z
x, y:Z
H:x = y

Eq = Eq -> Zcompare_prop x y Eq
now constructor. Qed.

forall x y : Z, (x < y)%Z -> (x ?= y)%Z = Lt

forall x y : Z, (x < y)%Z -> (x ?= y)%Z = Lt
easy. Qed.

forall x y : Z, x = y -> (x ?= y)%Z = Eq

forall x y : Z, x = y -> (x ?= y)%Z = Eq
x, y:Z

x = y -> (x ?= y)%Z = Eq
apply <- Zcompare_Eq_iff_eq. Qed.

forall x y : Z, (y < x)%Z -> (x ?= y)%Z = Gt

forall x y : Z, (y < x)%Z -> (x ?= y)%Z = Gt
x, y:Z

(y < x)%Z -> (x ?= y)%Z = Gt
apply Z.lt_gt. Qed. End Zcompare. Section cond_Zopp.

forall (x : bool) (y : Z), SpecFloatCopy.cond_Zopp (negb x) y = (- SpecFloatCopy.cond_Zopp x y)%Z

forall (x : bool) (y : Z), SpecFloatCopy.cond_Zopp (negb x) y = (- SpecFloatCopy.cond_Zopp x y)%Z
y:Z

SpecFloatCopy.cond_Zopp (negb true) y = (- SpecFloatCopy.cond_Zopp true y)%Z
y:Z
SpecFloatCopy.cond_Zopp (negb false) y = (- SpecFloatCopy.cond_Zopp false y)%Z
y:Z

SpecFloatCopy.cond_Zopp (negb false) y = (- SpecFloatCopy.cond_Zopp false y)%Z
easy. Qed.

forall (b : bool) (m : Z), Z.abs (SpecFloatCopy.cond_Zopp b m) = Z.abs m

forall (b : bool) (m : Z), Z.abs (SpecFloatCopy.cond_Zopp b m) = Z.abs m
m:Z

Z.abs (SpecFloatCopy.cond_Zopp true m) = Z.abs m
m:Z
Z.abs (SpecFloatCopy.cond_Zopp false m) = Z.abs m
m:Z

Z.abs (SpecFloatCopy.cond_Zopp false m) = Z.abs m
apply refl_equal. Qed.

forall m : Z, SpecFloatCopy.cond_Zopp (m <? 0)%Z m = Z.abs m

forall m : Z, SpecFloatCopy.cond_Zopp (m <? 0)%Z m = Z.abs m
m:Z

SpecFloatCopy.cond_Zopp (m <? 0)%Z m = Z.abs m
m:Z

Z.abs m = SpecFloatCopy.cond_Zopp (m <? 0)%Z m
m:Z
Hm:(m < 0)%Z

Z.abs m = SpecFloatCopy.cond_Zopp true m
m:Z
Hm:(0 <= m)%Z
Z.abs m = SpecFloatCopy.cond_Zopp false m
m:Z
Hm:(m < 0)%Z

(m <= 0)%Z
m:Z
Hm:(0 <= m)%Z
Z.abs m = SpecFloatCopy.cond_Zopp false m
m:Z
Hm:(0 <= m)%Z

Z.abs m = SpecFloatCopy.cond_Zopp false m
now apply Z.abs_eq. Qed. End cond_Zopp. Section fast_pow_pos. Fixpoint Zfast_pow_pos (v : Z) (e : positive) : Z := match e with | xH => v | xO e' => Z.square (Zfast_pow_pos v e') | xI e' => Zmult v (Z.square (Zfast_pow_pos v e')) end.

forall (v : Z) (e : positive), Zfast_pow_pos v e = Z.pow_pos v e

forall (v : Z) (e : positive), Zfast_pow_pos v e = Z.pow_pos v e
v:Z
e:positive

Zfast_pow_pos v e = Z.pow_pos v e
v:Z
e:positive

(Zfast_pow_pos v e * 1)%Z = Z.pow_pos v e
v:Z
e:positive

(Zfast_pow_pos v e * 1)%Z = Pos.iter (Z.mul v) 1%Z e
v:Z
e:positive

forall z : Z, (Zfast_pow_pos v e * z)%Z = Pos.iter (Z.mul v) z e
e:positive

forall v z : Z, (Zfast_pow_pos v e * z)%Z = Pos.iter (Z.mul v) z e
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z

(v * Z.square (Zfast_pow_pos v e) * f)%Z = (v * Pos.iter (Z.mul v) (Pos.iter (Z.mul v) f e) e)%Z
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z
(Z.square (Zfast_pow_pos v e) * f)%Z = Pos.iter (Z.mul v) (Pos.iter (Z.mul v) f e) e
v, f:Z
(v * f)%Z = (v * f)%Z
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z

(v * Z.square (Zfast_pow_pos v e) * f)%Z = (v * Pos.iter (Z.mul v) (Pos.iter (Z.mul v) f e) e)%Z
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z

(v * Z.square (Zfast_pow_pos v e) * f)%Z = (v * (Zfast_pow_pos v e * (Zfast_pow_pos v e * f)))%Z
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z

(v * (Zfast_pow_pos v e * Zfast_pow_pos v e) * f)%Z = (v * (Zfast_pow_pos v e * (Zfast_pow_pos v e * f)))%Z
ring.
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z

(Z.square (Zfast_pow_pos v e) * f)%Z = Pos.iter (Z.mul v) (Pos.iter (Z.mul v) f e) e
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z

(Z.square (Zfast_pow_pos v e) * f)%Z = (Zfast_pow_pos v e * (Zfast_pow_pos v e * f))%Z
e:positive
IHe:forall v0 z : Z, (Zfast_pow_pos v0 e * z)%Z = Pos.iter (Z.mul v0) z e
v, f:Z

(Zfast_pow_pos v e * Zfast_pow_pos v e * f)%Z = (Zfast_pow_pos v e * (Zfast_pow_pos v e * f))%Z
apply eq_sym, Zmult_assoc.
v, f:Z

(v * f)%Z = (v * f)%Z
apply eq_refl. Qed. End fast_pow_pos. Section faster_div.

forall a b : Z, Z.div_eucl a b = ((a / b)%Z, (a mod b)%Z)

forall a b : Z, Z.div_eucl a b = ((a / b)%Z, (a mod b)%Z)
a, b:Z

Z.div_eucl a b = ((a / b)%Z, (a mod b)%Z)
a, b:Z

Z.div_eucl a b = (let (q, _) := Z.div_eucl a b in q, let (_, r) := Z.div_eucl a b in r)
now case Z.div_eucl. Qed. Fixpoint Zpos_div_eucl_aux1 (a b : positive) {struct b} := match b with | xO b' => match a with | xO a' => let (q, r) := Zpos_div_eucl_aux1 a' b' in (q, 2 * r)%Z | xI a' => let (q, r) := Zpos_div_eucl_aux1 a' b' in (q, 2 * r + 1)%Z | xH => (Z0, Zpos a) end | xH => (Zpos a, Z0) | xI _ => Z.pos_div_eucl a (Zpos b) end.

forall a b : positive, Zpos_div_eucl_aux1 a b = Z.pos_div_eucl a (Z.pos b)

forall a b : positive, Zpos_div_eucl_aux1 a b = Z.pos_div_eucl a (Z.pos b)
a, b:positive

Zpos_div_eucl_aux1 a b = Z.pos_div_eucl a (Z.pos b)
b:positive

forall a : positive, Zpos_div_eucl_aux1 a b = Z.pos_div_eucl a (Z.pos b)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~1 = Z.pos_div_eucl a (Z.pos b~1)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive
Zpos_div_eucl_aux1 a b~0 = Z.pos_div_eucl a (Z.pos b~0)
a:positive
Zpos_div_eucl_aux1 a 1 = Z.pos_div_eucl a 1
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~1 = Z.pos_div_eucl a (Z.pos b~1)
easy.
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~0 = Z.pos_div_eucl a (Z.pos b~0)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~0 = Z.div_eucl (Z.pos a) (Z.pos b~0)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~0 = ((Z.pos a / Z.pos b~0)%Z, (Z.pos a mod Z.pos b~0)%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~0 = ((Z.pos a / (2 * Z.pos b))%Z, (Z.pos a mod (2 * Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~0 = ((Z.pos a / (2 * Z.pos b))%Z, (Z.pos a mod 2 + 2 * ((Z.pos a / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a b~0 = ((Z.pos a / 2 / Z.pos b)%Z, (Z.pos a mod 2 + 2 * ((Z.pos a / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a~1 b~0 = ((Z.pos a~1 / 2 / Z.pos b)%Z, (Z.pos a~1 mod 2 + 2 * ((Z.pos a~1 / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive
Zpos_div_eucl_aux1 a~0 b~0 = ((Z.pos a~0 / 2 / Z.pos b)%Z, (Z.pos a~0 mod 2 + 2 * ((Z.pos a~0 / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a : positive, Zpos_div_eucl_aux1 a b = Z.pos_div_eucl a (Z.pos b)
Zpos_div_eucl_aux1 1 b~0 = ((1 / 2 / Z.pos b)%Z, (1 mod 2 + 2 * ((1 / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a~1 b~0 = ((Z.pos a~1 / 2 / Z.pos b)%Z, (Z.pos a~1 mod 2 + 2 * ((Z.pos a~1 / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

(let (q, r) := Zpos_div_eucl_aux1 a b in (q, (2 * r + 1)%Z)) = ((Z.pos a~1 / 2 / Z.pos b)%Z, (Z.pos a~1 mod 2 + 2 * ((Z.pos a~1 / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

(let (q, r) := Z.pos_div_eucl a (Z.pos b) in (q, (2 * r + 1)%Z)) = ((Z.pos a~1 / 2 / Z.pos b)%Z, (Z.pos a~1 mod 2 + 2 * ((Z.pos a~1 / 2) mod Z.pos b))%Z)
b, a:positive

(let (q, r) := Z.pos_div_eucl a (Z.pos b) in (q, (2 * r + 1)%Z)) = ((Z.pos a~1 / 2 / Z.pos b)%Z, (Z.pos a~1 mod 2 + 2 * ((Z.pos a~1 / 2) mod Z.pos b))%Z)
b, a:positive

(let (q, r) := Z.div_eucl (Z.pos a) (Z.pos b) in (q, (2 * r + 1)%Z)) = ((Z.pos a~1 / 2 / Z.pos b)%Z, (Z.pos a~1 mod 2 + 2 * ((Z.pos a~1 / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b) + 1)%Z) = ((Z.pos a~1 / 2 / Z.pos b)%Z, (Z.pos a~1 mod 2 + 2 * ((Z.pos a~1 / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b) + 1)%Z) = (((1 + 2 * Z.pos a) / 2 / Z.pos b)%Z, ((1 + 2 * Z.pos a) mod 2 + 2 * (((1 + 2 * Z.pos a) / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b) + 1)%Z) = (((1 + Z.pos a * 2) / 2 / Z.pos b)%Z, ((1 + Z.pos a * 2) mod 2 + 2 * (((1 + Z.pos a * 2) / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b) + 1)%Z) = (((1 / 2 + Z.pos a) / Z.pos b)%Z, ((1 + Z.pos a * 2) mod 2 + 2 * ((1 / 2 + Z.pos a) mod Z.pos b))%Z)
b, a:positive

(2 * (Z.pos a mod Z.pos b) + 1)%Z = ((1 + Z.pos a * 2) mod 2 + 2 * ((1 / 2 + Z.pos a) mod Z.pos b))%Z
b, a:positive

(2 * (Z.pos a mod Z.pos b) + 1)%Z = (1 mod 2 + 2 * ((1 / 2 + Z.pos a) mod Z.pos b))%Z
apply Zplus_comm.
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

Zpos_div_eucl_aux1 a~0 b~0 = ((Z.pos a~0 / 2 / Z.pos b)%Z, (Z.pos a~0 mod 2 + 2 * ((Z.pos a~0 / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

(let (q, r) := Zpos_div_eucl_aux1 a b in (q, (2 * r)%Z)) = ((Z.pos a~0 / 2 / Z.pos b)%Z, (Z.pos a~0 mod 2 + 2 * ((Z.pos a~0 / 2) mod Z.pos b))%Z)
b:positive
IHb:forall a0 : positive, Zpos_div_eucl_aux1 a0 b = Z.pos_div_eucl a0 (Z.pos b)
a:positive

(let (q, r) := Z.pos_div_eucl a (Z.pos b) in (q, (2 * r)%Z)) = ((Z.pos a~0 / 2 / Z.pos b)%Z, (Z.pos a~0 mod 2 + 2 * ((Z.pos a~0 / 2) mod Z.pos b))%Z)
b, a:positive

(let (q, r) := Z.pos_div_eucl a (Z.pos b) in (q, (2 * r)%Z)) = ((Z.pos a~0 / 2 / Z.pos b)%Z, (Z.pos a~0 mod 2 + 2 * ((Z.pos a~0 / 2) mod Z.pos b))%Z)
b, a:positive

(let (q, r) := Z.div_eucl (Z.pos a) (Z.pos b) in (q, (2 * r)%Z)) = ((Z.pos a~0 / 2 / Z.pos b)%Z, (Z.pos a~0 mod 2 + 2 * ((Z.pos a~0 / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b))%Z) = ((Z.pos a~0 / 2 / Z.pos b)%Z, (Z.pos a~0 mod 2 + 2 * ((Z.pos a~0 / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b))%Z) = ((2 * Z.pos a / 2 / Z.pos b)%Z, ((2 * Z.pos a) mod 2 + 2 * ((2 * Z.pos a / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b))%Z) = ((Z.pos a * 2 / 2 / Z.pos b)%Z, ((Z.pos a * 2) mod 2 + 2 * ((Z.pos a * 2 / 2) mod Z.pos b))%Z)
b, a:positive

((Z.pos a / Z.pos b)%Z, (2 * (Z.pos a mod Z.pos b))%Z) = ((Z.pos a / Z.pos b)%Z, ((Z.pos a * 2) mod 2 + 2 * (Z.pos a mod Z.pos b))%Z)
b, a:positive

(2 * (Z.pos a mod Z.pos b))%Z = ((Z.pos a * 2) mod 2 + 2 * (Z.pos a mod Z.pos b))%Z
now rewrite Z_mod_mult.
b:positive
IHb:forall a : positive, Zpos_div_eucl_aux1 a b = Z.pos_div_eucl a (Z.pos b)

Zpos_div_eucl_aux1 1 b~0 = ((1 / 2 / Z.pos b)%Z, (1 mod 2 + 2 * ((1 / 2) mod Z.pos b))%Z)
easy.
a:positive

Zpos_div_eucl_aux1 a 1 = Z.pos_div_eucl a 1
a:positive

Zpos_div_eucl_aux1 a 1 = Z.div_eucl (Z.pos a) 1
a:positive

Zpos_div_eucl_aux1 a 1 = ((Z.pos a / 1)%Z, (Z.pos a mod 1)%Z)
now rewrite Zdiv_1_r, Zmod_1_r. Qed. Definition Zpos_div_eucl_aux (a b : positive) := match Pos.compare a b with | Lt => (Z0, Zpos a) | Eq => (1%Z, Z0) | Gt => Zpos_div_eucl_aux1 a b end.

forall a b : positive, Zpos_div_eucl_aux a b = Z.pos_div_eucl a (Z.pos b)

forall a b : positive, Zpos_div_eucl_aux a b = Z.pos_div_eucl a (Z.pos b)
a, b:positive

Zpos_div_eucl_aux a b = Z.pos_div_eucl a (Z.pos b)
a, b:positive

match (a ?= b)%positive with | Eq => (1%Z, 0%Z) | Lt => (0%Z, Z.pos a) | Gt => Zpos_div_eucl_aux1 a b end = Z.pos_div_eucl a (Z.pos b)
a, b:positive

match (a ?= b)%positive with | Eq => (1%Z, 0%Z) | Lt => (0%Z, Z.pos a) | Gt => Zpos_div_eucl_aux1 a b end = Z.div_eucl (Z.pos a) (Z.pos b)
a, b:positive

match (a ?= b)%positive with | Eq => (1%Z, 0%Z) | Lt => (0%Z, Z.pos a) | Gt => Zpos_div_eucl_aux1 a b end = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:a = b

(1%Z, 0%Z) = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:(a < b)%positive
(0%Z, Z.pos a) = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:(b < a)%positive
Zpos_div_eucl_aux1 a b = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:(a < b)%positive

(0%Z, Z.pos a) = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:(b < a)%positive
Zpos_div_eucl_aux1 a b = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:(b < a)%positive

Zpos_div_eucl_aux1 a b = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:(b < a)%positive

Z.pos_div_eucl a (Z.pos b) = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
a, b:positive
H:(b < a)%positive

Z.div_eucl (Z.pos a) (Z.pos b) = ((Z.pos a / Z.pos b)%Z, (Z.pos a mod Z.pos b)%Z)
apply Zdiv_eucl_unique. Qed. Definition Zfast_div_eucl (a b : Z) := match a with | Z0 => (0, 0)%Z | Zpos a' => match b with | Z0 => (0, 0)%Z | Zpos b' => Zpos_div_eucl_aux a' b' | Zneg b' => let (q, r) := Zpos_div_eucl_aux a' b' in match r with | Z0 => (-q, 0)%Z | Zpos _ => (-(q + 1), (b + r))%Z | Zneg _ => (-(q + 1), (b + r))%Z end end | Zneg a' => match b with | Z0 => (0, 0)%Z | Zpos b' => let (q, r) := Zpos_div_eucl_aux a' b' in match r with | Z0 => (-q, 0)%Z | Zpos _ => (-(q + 1), (b - r))%Z | Zneg _ => (-(q + 1), (b - r))%Z end | Zneg b' => let (q, r) := Zpos_div_eucl_aux a' b' in (q, (-r)%Z) end end.

forall a b : Z, Zfast_div_eucl a b = Z.div_eucl a b

forall a b : Z, Zfast_div_eucl a b = Z.div_eucl a b

forall a b : Z, match a with | 0%Z => (0%Z, 0%Z) | Z.pos a' => match b with | 0%Z => (0%Z, 0%Z) | Z.pos b' => Zpos_div_eucl_aux a' b' | Z.neg b' => let (q, r) := Zpos_div_eucl_aux a' b' in match r with | 0%Z => ((- q)%Z, 0%Z) | _ => ((- (q + 1))%Z, (b + r)%Z) end end | Z.neg a' => match b with | 0%Z => (0%Z, 0%Z) | Z.pos b' => let (q, r) := Zpos_div_eucl_aux a' b' in match r with | 0%Z => ((- q)%Z, 0%Z) | _ => ((- (q + 1))%Z, (b - r)%Z) end | Z.neg b' => let (q, r) := Zpos_div_eucl_aux a' b' in (q, (- r)%Z) end end = Z.div_eucl a b
intros [|a|a] [|b|b] ; try rewrite Zpos_div_eucl_aux_correct ; easy. Qed. End faster_div. Section Iter. Context {A : Type}. Variable (f : A -> A). Fixpoint iter_nat (n : nat) (x : A) {struct n} : A := match n with | S n' => iter_nat n' (f x) | O => x end.
A:Type
f:A -> A

forall (p q : nat) (x : A), iter_nat (p + q) x = iter_nat p (iter_nat q x)
A:Type
f:A -> A

forall (p q : nat) (x : A), iter_nat (p + q) x = iter_nat p (iter_nat q x)
A:Type
f:A -> A
p:nat

forall x : A, iter_nat (p + 0) x = iter_nat p (iter_nat 0 x)
A:Type
f:A -> A
p, q:nat
IHq:forall x : A, iter_nat (p + q) x = iter_nat p (iter_nat q x)
forall x : A, iter_nat (p + S q) x = iter_nat p (iter_nat (S q) x)
A:Type
f:A -> A
p, q:nat
IHq:forall x : A, iter_nat (p + q) x = iter_nat p (iter_nat q x)

forall x : A, iter_nat (p + S q) x = iter_nat p (iter_nat (S q) x)
A:Type
f:A -> A
p, q:nat
IHq:forall x0 : A, iter_nat (p + q) x0 = iter_nat p (iter_nat q x0)
x:A

iter_nat (p + S q) x = iter_nat p (iter_nat (S q) x)
A:Type
f:A -> A
p, q:nat
IHq:forall x0 : A, iter_nat (p + q) x0 = iter_nat p (iter_nat q x0)
x:A

iter_nat (S (p + q)) x = iter_nat p (iter_nat (S q) x)
apply IHq. Qed.
A:Type
f:A -> A

forall (p : nat) (x : A), iter_nat (S p) x = f (iter_nat p x)
A:Type
f:A -> A

forall (p : nat) (x : A), iter_nat (S p) x = f (iter_nat p x)
A:Type
f:A -> A

forall x : A, iter_nat 1 x = f (iter_nat 0 x)
A:Type
f:A -> A
p:nat
IHp:forall x : A, iter_nat (S p) x = f (iter_nat p x)
forall x : A, iter_nat (S (S p)) x = f (iter_nat (S p) x)
A:Type
f:A -> A
p:nat
IHp:forall x : A, iter_nat (S p) x = f (iter_nat p x)

forall x : A, iter_nat (S (S p)) x = f (iter_nat (S p) x)
A:Type
f:A -> A
p:nat
IHp:forall x : A, iter_nat (S p) x = f (iter_nat p x)

forall x : A, iter_nat p (f (f x)) = f (iter_nat p (f x))
A:Type
f:A -> A
p:nat
IHp:forall x0 : A, iter_nat (S p) x0 = f (iter_nat p x0)
x:A

iter_nat p (f (f x)) = f (iter_nat p (f x))
apply IHp. Qed.
A:Type
f:A -> A

forall (p : positive) (x : A), SpecFloatCopy.iter_pos f p x = iter_nat (Pos.to_nat p) x
A:Type
f:A -> A

forall (p : positive) (x : A), SpecFloatCopy.iter_pos f p x = iter_nat (Pos.to_nat p) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p~1 x = iter_nat (Pos.to_nat p~1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A
SpecFloatCopy.iter_pos f p~0 x = iter_nat (Pos.to_nat p~0) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p~1 x = iter_nat (S (2 * Pos.to_nat p)) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A
SpecFloatCopy.iter_pos f p~0 x = iter_nat (Pos.to_nat p~0) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (SpecFloatCopy.iter_pos f p (f x)) = iter_nat (Pos.to_nat p + (Pos.to_nat p + 0)) (f x)
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A
SpecFloatCopy.iter_pos f p~0 x = iter_nat (Pos.to_nat p~0) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (SpecFloatCopy.iter_pos f p (f x)) = iter_nat (Pos.to_nat p + Pos.to_nat p) (f x)
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A
SpecFloatCopy.iter_pos f p~0 x = iter_nat (Pos.to_nat p~0) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (SpecFloatCopy.iter_pos f p (f x)) = iter_nat (Pos.to_nat p) (iter_nat (Pos.to_nat p) (f x))
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A
SpecFloatCopy.iter_pos f p~0 x = iter_nat (Pos.to_nat p~0) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (iter_nat (Pos.to_nat p) (f x)) = iter_nat (Pos.to_nat p) (iter_nat (Pos.to_nat p) (f x))
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A
SpecFloatCopy.iter_pos f p~0 x = iter_nat (Pos.to_nat p~0) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p~0 x = iter_nat (Pos.to_nat p~0) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p~0 x = iter_nat (2 * Pos.to_nat p) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (SpecFloatCopy.iter_pos f p x) = iter_nat (Pos.to_nat p + (Pos.to_nat p + 0)) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (SpecFloatCopy.iter_pos f p x) = iter_nat (Pos.to_nat p + Pos.to_nat p) x
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (SpecFloatCopy.iter_pos f p x) = iter_nat (Pos.to_nat p) (iter_nat (Pos.to_nat p) x)
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
p:positive
IHp:forall x0 : A, SpecFloatCopy.iter_pos f p x0 = iter_nat (Pos.to_nat p) x0
x:A

SpecFloatCopy.iter_pos f p (iter_nat (Pos.to_nat p) x) = iter_nat (Pos.to_nat p) (iter_nat (Pos.to_nat p) x)
A:Type
f:A -> A
x:A
SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
A:Type
f:A -> A
x:A

SpecFloatCopy.iter_pos f 1 x = iter_nat (Pos.to_nat 1) x
easy. Qed. End Iter.