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.
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *   INRIA, CNRS and contributors - Copyright 1999-2018       *)
(* <O___,, *       (see CREDITS file for the list of authors)           *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)

Require Import QArith.


forall p q : Q, p < q -> - q < - p

forall p q : Q, p < q -> - q < - p
a1:Z
a2:positive
b1:Z
b2:positive

(a1 * Z.pos b2 < b1 * Z.pos a2)%Z -> (- b1 * Z.pos a2 < - a1 * Z.pos b2)%Z
rewrite !Z.mul_opp_l; omega. Qed. Hint Resolve Qopp_lt_compat : qarith. (************) Coercion inject_Z : Z >-> Q. Definition Qfloor (x:Q) := let (n,d) := x in Z.div n (Zpos d). Definition Qceiling (x:Q) := (-(Qfloor (-x)))%Z.

forall z : Z, Qfloor z = z

forall z : Z, Qfloor z = z
z:Z

Qfloor z = z
z:Z

(z / 1)%Z = z
auto with *. Qed.

forall z : Z, Qceiling z = z

forall z : Z, Qceiling z = z
z:Z

Qceiling z = z
z:Z

(- Qfloor (- z))%Z = z
z:Z

(- (- z / 1))%Z = z
z:Z

(- - z)%Z = z
auto with *. Qed.

forall x : Q, Qfloor x <= x

forall x : Q, Qfloor x <= x
n:Z
d:positive

Qfloor (n # d) <= n # d
n:Z
d:positive

(n / Z.pos d)%Z <= n # d
n:Z
d:positive

(Qnum (n / Z.pos d)%Z * QDen (n # d) <= Qnum (n # d) * QDen (n / Z.pos d)%Z)%Z
n:Z
d:positive

(n / Z.pos d * Z.pos d <= n * 1)%Z
n:Z
d:positive

(n / Z.pos d * Z.pos d <= n)%Z
n:Z
d:positive

(Z.pos d * (n / Z.pos d) <= n)%Z
n:Z
d:positive

(Z.pos d > 0)%Z
auto with *. Qed. Hint Resolve Qfloor_le : qarith.

forall x : Q, x <= Qceiling x

forall x : Q, x <= Qceiling x
x:Q

x <= Qceiling x
x:Q

x <= - - x
x:Q
- - x <= Qceiling x
x:Q

x <= x
x:Q
- - x <= Qceiling x
x:Q

- - x <= Qceiling x
x:Q

- - x <= - Qfloor (- x)
auto with *. Qed. Hint Resolve Qle_ceiling : qarith.

forall x : Q, Qfloor x <= Qceiling x

forall x : Q, Qfloor x <= Qceiling x
eauto with qarith. Qed.

forall x : Q, x < (Qfloor x + 1)%Z

forall x : Q, x < (Qfloor x + 1)%Z
n:Z
d:positive

n # d < (Qfloor (n # d) + 1)%Z
n:Z
d:positive

n # d < (n / Z.pos d + 1)%Z
n:Z
d:positive

(Qnum (n # d) * QDen (n / Z.pos d + 1)%Z < Qnum (n / Z.pos d + 1)%Z * QDen (n # d))%Z
n:Z
d:positive

(n * 1 < (n / Z.pos d + 1) * Z.pos d)%Z
n:Z
d:positive

(n < (n / Z.pos d + 1) * Z.pos d)%Z
n:Z
d:positive

(n < n / Z.pos d * Z.pos d + Z.pos d)%Z
n:Z
d:positive

(n < Z.pos d * (n / Z.pos d) + n mod Z.pos d + Z.pos d - n mod Z.pos d)%Z
n:Z
d:positive

(n < n + Z.pos d - n mod Z.pos d)%Z
n:Z
d:positive

(n + n mod Z.pos d < n + Z.pos d)%Z
destruct (Z_mod_lt n (Zpos d)); auto with *. Qed. Hint Resolve Qlt_floor : qarith.

forall x : Q, (Qceiling x - 1)%Z < x

forall x : Q, (Qceiling x - 1)%Z < x
x:Q

(Qceiling x - 1)%Z < x
x:Q

(- Qfloor (- x) - 1)%Z < x
x:Q

(- (Qfloor (- x) + 1))%Z < x
x:Q

- (Qfloor (- x) + 1)%Z < x
x:Q

- - x <= x
x:Q

x <= x
auto with *. Qed. Hint Resolve Qceiling_lt : qarith.

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

forall x y : Q, x <= y -> (Qfloor x <= Qfloor y)%Z
xn:Z
xd:positive
yn:Z
yd:positive
Hxy:xn # xd <= yn # yd

(Qfloor (xn # xd) <= Qfloor (yn # yd))%Z
xn:Z
xd:positive
yn:Z
yd:positive
Hxy:(Qnum (xn # xd) * QDen (yn # yd) <= Qnum (yn # yd) * QDen (xn # xd))%Z

(Qfloor (xn # xd) <= Qfloor (yn # yd))%Z
xn:Z
xd:positive
yn:Z
yd:positive
Hxy:(xn * Z.pos yd <= yn * Z.pos xd)%Z

(xn / Z.pos xd <= yn / Z.pos yd)%Z
xn:Z
xd:positive
yn:Z
yd:positive
Hxy:(xn * Z.pos yd <= yn * Z.pos xd)%Z

(xn * Z.pos yd / (Z.pos xd * Z.pos yd) <= yn / Z.pos yd)%Z
xn:Z
xd:positive
yn:Z
yd:positive
Hxy:(xn * Z.pos yd <= yn * Z.pos xd)%Z

(xn * Z.pos yd / (Z.pos xd * Z.pos yd) <= yn * Z.pos xd / (Z.pos yd * Z.pos xd))%Z
xn:Z
xd:positive
yn:Z
yd:positive
Hxy:(xn * Z.pos yd <= yn * Z.pos xd)%Z

(xn * Z.pos yd / (Z.pos xd * Z.pos yd) <= yn * Z.pos xd / (Z.pos xd * Z.pos yd))%Z
apply Z_div_le; auto with *. Qed. Hint Resolve Qfloor_resp_le : qarith.

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

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

(Qceiling x <= Qceiling y)%Z
x, y:Q
Hxy:x <= y

(- Qfloor (- x) <= - Qfloor (- y))%Z
cut (Qfloor (-y) <= Qfloor (-x))%Z; auto with *. Qed. Hint Resolve Qceiling_resp_le : qarith.

forall x y : Q, x == y -> Qfloor x = Qfloor y

forall x y : Q, x == y -> Qfloor x = Qfloor y
x, y:Q
H:x == y

Qfloor x = Qfloor y
x, y:Q
H:x == y

(Qfloor x <= Qfloor y)%Z
x, y:Q
H:x == y
(Qfloor y <= Qfloor x)%Z
x, y:Q
H:x == y

(Qfloor y <= Qfloor x)%Z
symmetry in H; auto with *. Qed.

forall x y : Q, x == y -> Qceiling x = Qceiling y

forall x y : Q, x == y -> Qceiling x = Qceiling y
x, y:Q
H:x == y

Qceiling x = Qceiling y
x, y:Q
H:x == y

(Qceiling x <= Qceiling y)%Z
x, y:Q
H:x == y
(Qceiling y <= Qceiling x)%Z
x, y:Q
H:x == y

(Qceiling y <= Qceiling x)%Z
symmetry in H; auto with *. Qed.
n, m:Z

(n / m)%Z = Qfloor (n / m)
n, m:Z

(n / m)%Z = Qfloor (n / m)
n, m:Z

(n / m)%Z = (let (n0, d) := n / m in (n0 / Z.pos d)%Z)
n, m:Z

(n / m)%Z = (let (n0, d) := n / m in (n0 / Z.pos d)%Z)
n, m:Z

(n / m)%Z = (n * Qnum (/ m) / QDen (/ m))%Z
n:Z

(n / 0)%Z = (n * 0 / 1)%Z
n:Z
p:positive
(n / Z.pos p)%Z = (n * 1 / Z.pos p)%Z
n:Z
p:positive
(n / Z.neg p)%Z = (n * -1 / Z.pos p)%Z
n:Z
p:positive

(n / Z.pos p)%Z = (n * 1 / Z.pos p)%Z
n:Z
p:positive
(n / Z.neg p)%Z = (n * -1 / Z.pos p)%Z
n:Z
p:positive

(n / Z.neg p)%Z = (n * -1 / Z.pos p)%Z
n:Z
p:positive

(n / Z.neg p)%Z = (- n / Z.pos p)%Z
n:Z
p:positive

(n / Z.neg p)%Z = (- n / - - Z.pos p)%Z
now rewrite Zdiv_opp_opp. Qed.