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 < - pforall p q : Q, p < q -> - q < - prewrite !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.a1:Za2:positiveb1:Zb2:positive(a1 * Z.pos b2 < b1 * Z.pos a2)%Z -> (- b1 * Z.pos a2 < - a1 * Z.pos b2)%Zforall z : Z, Qfloor z = zforall z : Z, Qfloor z = zz:ZQfloor z = zauto with *. Qed.z:Z(z / 1)%Z = zforall z : Z, Qceiling z = zforall z : Z, Qceiling z = zz:ZQceiling z = zz:Z(- Qfloor (- z))%Z = zz:Z(- (- z / 1))%Z = zauto with *. Qed.z:Z(- - z)%Z = zforall x : Q, Qfloor x <= xforall x : Q, Qfloor x <= xn:Zd:positiveQfloor (n # d) <= n # dn:Zd:positive(n / Z.pos d)%Z <= n # dn:Zd:positive(Qnum (n / Z.pos d)%Z * QDen (n # d) <= Qnum (n # d) * QDen (n / Z.pos d)%Z)%Zn:Zd:positive(n / Z.pos d * Z.pos d <= n * 1)%Zn:Zd:positive(n / Z.pos d * Z.pos d <= n)%Zn:Zd:positive(Z.pos d * (n / Z.pos d) <= n)%Zauto with *. Qed. Hint Resolve Qfloor_le : qarith.n:Zd:positive(Z.pos d > 0)%Zforall x : Q, x <= Qceiling xforall x : Q, x <= Qceiling xx:Qx <= Qceiling xx:Qx <= - - xx:Q- - x <= Qceiling xx:Qx <= xx:Q- - x <= Qceiling xx:Q- - x <= Qceiling xauto with *. Qed. Hint Resolve Qle_ceiling : qarith.x:Q- - x <= - Qfloor (- x)forall x : Q, Qfloor x <= Qceiling xeauto with qarith. Qed.forall x : Q, Qfloor x <= Qceiling xforall x : Q, x < (Qfloor x + 1)%Zforall x : Q, x < (Qfloor x + 1)%Zn:Zd:positiven # d < (Qfloor (n # d) + 1)%Zn:Zd:positiven # d < (n / Z.pos d + 1)%Zn:Zd:positive(Qnum (n # d) * QDen (n / Z.pos d + 1)%Z < Qnum (n / Z.pos d + 1)%Z * QDen (n # d))%Zn:Zd:positive(n * 1 < (n / Z.pos d + 1) * Z.pos d)%Zn:Zd:positive(n < (n / Z.pos d + 1) * Z.pos d)%Zn:Zd:positive(n < n / Z.pos d * Z.pos d + Z.pos d)%Zn:Zd:positive(n < Z.pos d * (n / Z.pos d) + n mod Z.pos d + Z.pos d - n mod Z.pos d)%Zn:Zd:positive(n < n + Z.pos d - n mod Z.pos d)%Zdestruct (Z_mod_lt n (Zpos d)); auto with *. Qed. Hint Resolve Qlt_floor : qarith.n:Zd:positive(n + n mod Z.pos d < n + Z.pos d)%Zforall x : Q, (Qceiling x - 1)%Z < xforall x : Q, (Qceiling x - 1)%Z < xx:Q(Qceiling x - 1)%Z < xx:Q(- Qfloor (- x) - 1)%Z < xx:Q(- (Qfloor (- x) + 1))%Z < xx:Q- (Qfloor (- x) + 1)%Z < xx:Q- - x <= xauto with *. Qed. Hint Resolve Qceiling_lt : qarith.x:Qx <= xforall x y : Q, x <= y -> (Qfloor x <= Qfloor y)%Zforall x y : Q, x <= y -> (Qfloor x <= Qfloor y)%Zxn:Zxd:positiveyn:Zyd:positiveHxy:xn # xd <= yn # yd(Qfloor (xn # xd) <= Qfloor (yn # yd))%Zxn:Zxd:positiveyn:Zyd:positiveHxy:(Qnum (xn # xd) * QDen (yn # yd) <= Qnum (yn # yd) * QDen (xn # xd))%Z(Qfloor (xn # xd) <= Qfloor (yn # yd))%Zxn:Zxd:positiveyn:Zyd:positiveHxy:(xn * Z.pos yd <= yn * Z.pos xd)%Z(xn / Z.pos xd <= yn / Z.pos yd)%Zxn:Zxd:positiveyn:Zyd:positiveHxy:(xn * Z.pos yd <= yn * Z.pos xd)%Z(xn * Z.pos yd / (Z.pos xd * Z.pos yd) <= yn / Z.pos yd)%Zxn:Zxd:positiveyn:Zyd:positiveHxy:(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))%Zapply Z_div_le; auto with *. Qed. Hint Resolve Qfloor_resp_le : qarith.xn:Zxd:positiveyn:Zyd:positiveHxy:(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))%Zforall x y : Q, x <= y -> (Qceiling x <= Qceiling y)%Zforall x y : Q, x <= y -> (Qceiling x <= Qceiling y)%Zx, y:QHxy:x <= y(Qceiling x <= Qceiling y)%Zcut (Qfloor (-y) <= Qfloor (-x))%Z; auto with *. Qed. Hint Resolve Qceiling_resp_le : qarith.x, y:QHxy:x <= y(- Qfloor (- x) <= - Qfloor (- y))%Zforall x y : Q, x == y -> Qfloor x = Qfloor yforall x y : Q, x == y -> Qfloor x = Qfloor yx, y:QH:x == yQfloor x = Qfloor yx, y:QH:x == y(Qfloor x <= Qfloor y)%Zx, y:QH:x == y(Qfloor y <= Qfloor x)%Zsymmetry in H; auto with *. Qed.x, y:QH:x == y(Qfloor y <= Qfloor x)%Zforall x y : Q, x == y -> Qceiling x = Qceiling yforall x y : Q, x == y -> Qceiling x = Qceiling yx, y:QH:x == yQceiling x = Qceiling yx, y:QH:x == y(Qceiling x <= Qceiling y)%Zx, y:QH:x == y(Qceiling y <= Qceiling x)%Zsymmetry in H; auto with *. Qed.x, y:QH:x == y(Qceiling y <= Qceiling x)%Zn, 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))%Zn:Z(n / 0)%Z = (n * 0 / 1)%Zn:Zp:positive(n / Z.pos p)%Z = (n * 1 / Z.pos p)%Zn:Zp:positive(n / Z.neg p)%Z = (n * -1 / Z.pos p)%Zn:Zp:positive(n / Z.pos p)%Z = (n * 1 / Z.pos p)%Zn:Zp:positive(n / Z.neg p)%Z = (n * -1 / Z.pos p)%Zn:Zp:positive(n / Z.neg p)%Z = (n * -1 / Z.pos p)%Zn:Zp:positive(n / Z.neg p)%Z = (- n / Z.pos p)%Znow rewrite Zdiv_opp_opp. Qed.n:Zp:positive(n / Z.neg p)%Z = (- n / - - Z.pos p)%Z