(** * Setoid compatibility results *)

#[global]
Instance Qplus_comp : Proper (Qeq==>Qeq==>Qeq) Qplus.#[global]
Instance Qopp_comp : Proper (Qeq==>Qeq) Qopp.#[global]
Instance Qminus_comp : Proper (Qeq==>Qeq==>Qeq) Qminus.#[global]
Instance Qmult_comp : Proper (Qeq==>Qeq==>Qeq) Qmult.#[global]
Instance Qinv_comp : Proper (Qeq==>Qeq) Qinv.#[global]
Instance Qdiv_comp : Proper (Qeq==>Qeq==>Qeq) Qdiv.#[global]
Instance Qcompare_comp : Proper (Qeq==>Qeq==>eq) Qcompare.#[global]
Instance Qle_comp : Proper (Qeq==>Qeq==>iff) Qle.#[global]
Instance Qlt_compat : Proper (Qeq==>Qeq==>iff) Qlt.#[global]
Instance Qeqb_comp : Proper (Qeq==>Qeq==>eq) Qeq_bool.#[global]
Instance Qleb_comp : Proper (Qeq==>Qeq==>eq) Qle_bool.

(* Specifications: *)
Lemma Q_apart_0_1 : ~ 1 == 0.
Theorem Qplus_assoc : forall x y z, x+(y+z)==(x+y)+z.
Lemma Qplus_0_l : forall x, 0+x == x.
Lemma Qplus_0_r : forall x, x+0 == x.
Theorem Qplus_comm : forall x y, x+y == y+x.
Lemma Qopp_involutive : forall q, - -q == q.
Theorem Qplus_opp_r : forall q, q+(-q) == 0.
Lemma Qplus_inj_r (x y z: Q): x + z == y + z <-> x == y.
Lemma Qplus_inj_l (x y z: Q): z + x == z + y <-> x == y.
Theorem Qmult_assoc : forall n m p, n*(m*p)==(n*m)*p.
Lemma Qmult_0_l : forall x , 0*x == 0.
Lemma Qmult_0_r : forall x , x*0 == 0.
Lemma Qmult_1_l : forall n, 1*n == n.
Theorem Qmult_1_r : forall n, n*1==n.
Theorem Qmult_comm : forall x y, x*y==y*x.
Theorem Qmult_plus_distr_r : forall x y z, x*(y+z)==(x*y)+(x*z).
Theorem Qmult_plus_distr_l : forall x y z, (x+y)*z==(x*z)+(y*z).
Theorem Qmult_integral : forall x y, x*y==0 -> x==0 \/ y==0.
Theorem Qmult_integral_l : forall x y, ~ x == 0 -> x*y == 0 -> y == 0.
Lemma inject_Z_plus (x y: Z): inject_Z (x + y) = inject_Z x + inject_Z y.
Lemma inject_Z_mult (x y: Z): inject_Z (x * y) = inject_Z x * inject_Z y.
Lemma inject_Z_opp (x: Z): inject_Z (- x) = - inject_Z x.
Lemma Qinv_involutive : forall q, (/ / q) == q.
Theorem Qmult_inv_r : forall x, ~ x == 0 -> x*(/x) == 1.
Lemma Qinv_mult_distr : forall p q, / (p * q) == /p * /q.
Lemma Qinv_pos: forall (a b : positive), / (Z.pos b # a) == Z.pos a # b.
Lemma Qinv_neg: forall (a b : positive), / (Z.neg b # a) == Z.neg a # b.
Theorem Qdiv_mult_l : forall x y, ~ y == 0 -> (x*y)/y == x.
Theorem Qmult_div_r : forall x y, ~ y == 0 -> y*(x/y) == x.
Lemma Qinv_plus_distr : forall a b c, ((a # c) + (b # c) == (a+b) # c)%Q.
Lemma Qinv_minus_distr : forall a b c, (a # c) + - (b # c) == (a-b) # c.
Lemma Qmult_inj_r (x y z: Q): ~ z == 0 -> (x * z == y * z <-> x == y).
Lemma Qmult_inj_l (x y z: Q): ~ z == 0 -> (z * x == z * y <-> x == y).
Lemma Qreduce_l : forall (a : Z) (b z : positive), (Zpos z)*a # z*b == a#b.
Lemma Qreduce_r : forall (a : Z) (b z : positive), a*(Zpos z) # b*z == a#b.
Lemma Qreduce_num_l : forall (a b : positive), Z.pos a # a * b == (1 # b).
Lemma Qreduce_num_r : forall (a b : positive), Z.pos b # a * b == (1 # a).
Lemma Qreduce_den_l : forall (a : positive) (b : Z), Z.pos a * b # a == (b # 1).
Lemma Qreduce_den_r : forall (a : Z) (b : positive), a * Z.pos b # b == (a # 1).
Lemma Qreduce_den_inject_Z_l : forall (a : positive) (b : Z), (Z.pos a * b # a == inject_Z b)%Q.
Lemma Qreduce_den_inject_Z_r : forall (a : Z) (b : positive), a * Z.pos b # b == inject_Z a.
Lemma Qreduce_zero: forall (d : positive), (0#d == 0)%Q.
Lemma Qmult_inject_Z_l : forall (a : Z) (b : positive) (z : Z), (inject_Z z) * (a#b) == z*a#b.
Lemma Qmult_inject_Z_r : forall (a : Z) (b : positive) (z : Z), (a#b) * inject_Z z == a*z#b.
Lemma Qmult_frac_l : forall (a:Z) (b c:positive), (a # (b * c)) == (1#b) * (a#c).
Lemma Qmult_frac_r : forall (a:Z) (b c:positive), (a # (b * c)) == (a#b) * (1#c).
Lemma Qle_refl x : x<=x.
Lemma Qle_antisym x y : x<=y -> y<=x -> x==y.
Lemma Qle_trans : forall x y z, x<=y -> y<=z -> x<=z.
Lemma Qlt_irrefl x : ~x<x.
Lemma Qlt_not_eq x y : x<y -> ~ x==y.
Lemma Zle_Qle (x y: Z): (x <= y)%Z = (inject_Z x <= inject_Z y).
Lemma Zlt_Qlt (x y: Z): (x < y)%Z = (inject_Z x < inject_Z y).
Lemma Qle_lteq x y : x<=y <-> x<y \/ x==y.
Lemma Qlt_leneq: forall p q : Q, p < q <-> p <= q /\ ~ (p == q).
Lemma Qlt_le_weak x y : x<y -> x<=y.
Lemma Qgt_lt: forall p q : Q, p > q -> q < p.
Lemma Qlt_gt: forall p q : Q, p < q -> q > p.
Lemma Qge_le: forall p q : Q, p >= q -> q <= p.
Lemma Qle_ge: forall p q : Q, p <= q -> q >= p.
Lemma Qle_lt_trans : forall x y z, x<=y -> y<z -> x<z.
Lemma Qlt_le_trans : forall x y z, x<y -> y<=z -> x<z.
Lemma Qlt_trans : forall x y z, x<y -> y<z -> x<z.
Lemma Qnot_lt_le x y : ~ x < y -> y <= x.
Lemma Qnot_le_lt x y : ~ x <= y -> y < x.
Lemma Qlt_not_le x y : x < y -> ~ y <= x.
Lemma Qle_not_lt x y : x <= y -> ~ y < x.
Lemma Qle_lt_or_eq : forall x y, x<=y -> x<y \/ x==y.
Lemma Q_dec : forall x y, {x<y} + {y<x} + {x==y}.
Lemma Qlt_le_dec : forall x y, {x<y} + {y<=x}.
Lemma Qarchimedean : forall q : Q, { p : positive | q < Z.pos p # 1 }.
Lemma Qopp_le_compat : forall p q, p<=q -> -q <= -p.
Lemma Qopp_lt_compat: forall p q : Q, p < q -> - q < - p.
Lemma Qle_minus_iff : forall p q, p <= q <-> 0 <= q+-p.
Lemma Qlt_minus_iff : forall p q, p < q <-> 0 < q+-p.
Lemma Qplus_le_compat : forall x y z t, x<=y -> z<=t -> x+z <= y+t.
Lemma Qplus_lt_le_compat : forall x y z t, x<y -> z<=t -> x+z < y+t.
Lemma Qplus_le_l (x y z: Q): x + z <= y + z <-> x <= y.
Lemma Qplus_le_r (x y z: Q): z + x <= z + y <-> x <= y.
Lemma Qplus_lt_l (x y z: Q): x + z < y + z <-> x < y.
Lemma Qplus_lt_r (x y z: Q): z + x < z + y <-> x < y.
Lemma Qplus_lt_compat : forall x y z t : Q, x < y -> z < t -> x + z < y + t.
Lemma Qmult_le_compat_r : forall x y z, x <= y -> 0 <= z -> x*z <= y*z.
Lemma Qmult_lt_0_le_reg_r : forall x y z, 0 < z -> x*z <= y*z -> x <= y.
Lemma Qmult_le_r (x y z: Q): 0 < z -> (x*z <= y*z <-> x <= y).
Lemma Qmult_le_l (x y z: Q): 0 < z -> (z*x <= z*y <-> x <= y).
Lemma Qmult_lt_compat_r : forall x y z, 0 < z -> x < y -> x*z < y*z.
Lemma Qmult_lt_r: forall x y z, 0 < z -> (x*z < y*z <-> x < y).
Lemma Qmult_lt_l (x y z: Q): 0 < z -> (z*x < z*y <-> x < y).
Lemma Qmult_le_0_compat : forall a b, 0 <= a -> 0 <= b -> 0 <= a*b.
Lemma Qmult_lt_0_compat : forall a b : Q, 0 < a -> 0 < b -> 0 < a * b.
Lemma Qmult_le_1_compat: forall a b : Q, 1 <= a -> 1 <= b -> 1 <= a * b.
Lemma Qmult_lt_1_compat: forall a b : Q, 1 < a -> 1 < b -> 1 < a * b.
Lemma Qmult_lt_compat_nonneg: forall x y z t : Q, 0 <= x < y -> 0 <= z < t -> x * z < y * t.
Lemma Qmult_le_lt_compat_pos: forall x y z t : Q, 0 < x <= y -> 0 < z < t -> x * z < y * t.
Lemma Qmult_le_compat_nonneg: forall x y z t : Q, 0 <= x <= y -> 0 <= z <= t -> x * z <= y * t.
Lemma Qinv_le_0_compat : forall a, 0 <= a -> 0 <= /a.
Lemma Qle_shift_div_l : forall a b c, 0 < c -> a*c <= b -> a <= b/c.
Lemma Qle_shift_inv_l : forall a c, 0 < c -> a*c <= 1 -> a <= /c.
Lemma Qle_shift_div_r : forall a b c, 0 < b -> a <= c*b -> a/b <= c.
Lemma Qle_shift_inv_r : forall b c, 0 < b -> 1 <= c*b -> /b <= c.
Lemma Qinv_lt_0_compat : forall a, 0 < a -> 0 < /a.
Lemma Qlt_shift_div_l : forall a b c, 0 < c -> a*c < b -> a < b/c.
Lemma Qlt_shift_inv_l : forall a c, 0 < c -> a*c < 1 -> a < /c.
Lemma Qlt_shift_div_r : forall a b c, 0 < b -> a < c*b -> a/b < c.
Lemma Qlt_shift_inv_r : forall b c, 0 < b -> 1 < c*b -> /b < c.
Lemma Qinv_lt_contravar : forall a b : Q, 0 < a -> 0 < b -> (a < b <-> /b < /a).