Opaque Qred.
(** Addition is associative: *)

(* Specifications: *)
Theorem Qcplus_assoc : forall x y z, x+(y+z)=(x+y)+z.
(** [0] is a neutral element for addition: *)
Lemma Qcplus_0_l : forall x, 0+x = x.
Lemma Qcplus_0_r : forall x, x+0 = x.
(** Commutativity of addition: *)
Theorem Qcplus_comm : forall x y, x+y = y+x.
(** Properties of [Qopp] *)
Lemma Qcopp_involutive : forall q, - -q = q.
Theorem Qcplus_opp_r : forall q, q+(-q) = 0.
(** Multiplication is associative: *)
Theorem Qcmult_assoc : forall n m p, n*(m*p)=(n*m)*p.
(** [0] is absorbing for multiplication: *)
Lemma Qcmult_0_l : forall n, 0*n = 0.
Theorem Qcmult_0_r : forall n, n*0=0.
(** [1] is a neutral element for multiplication: *)
Lemma Qcmult_1_l : forall n, 1*n = n.
Theorem Qcmult_1_r : forall n, n*1=n.
(** Commutativity of multiplication *)
Theorem Qcmult_comm : forall x y, x*y=y*x.
(** Distributivity *)
Theorem Qcmult_plus_distr_r : forall x y z, x*(y+z)=(x*y)+(x*z).
Theorem Qcmult_plus_distr_l : forall x y z, (x+y)*z=(x*z)+(y*z).
(** Integrality *)
Theorem Qcmult_integral : forall x y, x*y=0 -> x=0 \/ y=0.
Theorem Qcmult_integral_l : forall x y, ~ x = 0 -> x*y = 0 -> y = 0.
(** Inverse and division. *)
Theorem Qcmult_inv_r : forall x, x<>0 -> x*(/x) = 1.
Theorem Qcmult_inv_l : forall x, x<>0 -> (/x)*x = 1.
Lemma Qcinv_mult_distr : forall p q, / (p * q) = /p * /q.
Theorem Qcdiv_mult_l : forall x y, y<>0 -> (x*y)/y = x.
Theorem Qcmult_div_r : forall x y, ~ y = 0 -> y*(x/y) = x.
(** Properties of order upon Qc. *)
Lemma Qcle_refl : forall x, x<=x.
Lemma Qcle_antisym : forall x y, x<=y -> y<=x -> x=y.
Lemma Qcle_trans : forall x y z, x<=y -> y<=z -> x<=z.
Lemma Qclt_not_eq : forall x y, x<y -> x<>y.
(** Large = strict or equal *)
Lemma Qclt_le_weak : forall x y, x<y -> x<=y.
Lemma Qcle_lt_trans : forall x y z, x<=y -> y<z -> x<z.
Lemma Qclt_le_trans : forall x y z, x<y -> y<=z -> x<z.
Lemma Qclt_trans : forall x y z, x<y -> y<z -> x<z.
(** [x<y] iff [~(y<=x)] *)
Lemma Qcnot_lt_le : forall x y, ~ x<y -> y<=x.
Lemma Qcnot_le_lt : forall x y, ~ x<=y -> y<x.
Lemma Qclt_not_le : forall x y, x<y -> ~ y<=x.
Lemma Qcle_not_lt : forall x y, x<=y -> ~ y<x.
Lemma Qcle_lt_or_eq : forall x y, x<=y -> x<y \/ x=y.
(** Some decidability results about orders. *)
Lemma Qc_dec : forall x y, {x<y} + {y<x} + {x=y}.
Lemma Qcle_minus_iff : forall p q, p <= q <-> 0 <= q+-p.
Lemma Qclt_minus_iff : forall p q, p < q <-> 0 < q+-p.
Lemma Qcplus_le_compat :
forall x y z t, x<=y -> z<=t -> x+z <= y+t.
Lemma Qcmult_le_compat_r : forall x y z, x <= y -> 0 <= z -> x*z <= y*z.
Lemma Qcmult_lt_0_le_reg_r : forall x y z, 0 <  z  -> x*z <= y*z -> x <= y.
Lemma Qcmult_lt_compat_r : forall x y z, 0 < z  -> x < y -> x*z < y*z.
Fixpoint Qcpower (q:Qc)(n:nat) : Qc :=
match n with
| O => 1
| S n => q * (Qcpower q n)
end.