Definition Rcompare x y :=
  match total_order_T x y with
  | inleft (left _) => Lt
  | inleft (right _) => Eq
  | inright _ => Gt
  end.Inductive Rcompare_prop (x y : R) : comparison -> Prop :=
  | Rcompare_Lt_ : (x < y)%R -> Rcompare_prop x y Lt
  | Rcompare_Eq_ : x = y -> Rcompare_prop x y Eq
  | Rcompare_Gt_ : (y < x)%R -> Rcompare_prop x y Gt.Inductive Rcompare_prop (x y : R) : comparison -> Prop :=
  | Rcompare_Lt_ : (x < y)%R -> Rcompare_prop x y Lt
  | Rcompare_Eq_ : x = y -> Rcompare_prop x y Eq
  | Rcompare_Gt_ : (y < x)%R -> Rcompare_prop x y Gt.Inductive Rcompare_prop (x y : R) : comparison -> Prop :=
  | Rcompare_Lt_ : (x < y)%R -> Rcompare_prop x y Lt
  | Rcompare_Eq_ : x = y -> Rcompare_prop x y Eq
  | Rcompare_Gt_ : (y < x)%R -> Rcompare_prop x y Gt.Inductive Rcompare_prop (x y : R) : comparison -> Prop :=
  | Rcompare_Lt_ : (x < y)%R -> Rcompare_prop x y Lt
  | Rcompare_Eq_ : x = y -> Rcompare_prop x y Eq
  | Rcompare_Gt_ : (y < x)%R -> Rcompare_prop x y Gt.

(* Specifications: *)
Theorem Rcompare_spec : forall x y, Rcompare_prop x y (Rcompare x y).
Theorem Rcompare_Lt : forall x y, (x < y)%R -> Rcompare x y = Lt.
Theorem Rcompare_Lt_inv : forall x y, Rcompare x y = Lt -> (x < y)%R.
Theorem Rcompare_not_Lt : forall x y, (y <= x)%R -> Rcompare x y <> Lt.
Theorem Rcompare_not_Lt_inv : forall x y, Rcompare x y <> Lt -> (y <= x)%R.
Theorem Rcompare_Eq : forall x y, x = y -> Rcompare x y = Eq.
Theorem Rcompare_Eq_inv : forall x y, Rcompare x y = Eq -> x = y.
Theorem Rcompare_Gt : forall x y, (y < x)%R -> Rcompare x y = Gt.
Theorem Rcompare_Gt_inv : forall x y, Rcompare x y = Gt -> (y < x)%R.
Theorem Rcompare_not_Gt : forall x y, (x <= y)%R -> Rcompare x y <> Gt.
Theorem Rcompare_not_Gt_inv : forall x y, Rcompare x y <> Gt -> (x <= y)%R.
Theorem Rcompare_Z2R : forall x y, Rcompare (Z2R x) (Z2R y) = Zcompare x y.
Theorem Rcompare_sym : forall x y, Rcompare x y = CompOpp (Rcompare y x).
Theorem Rcompare_plus_r : forall z x y, Rcompare (x + z) (y + z) = Rcompare x y.
Theorem Rcompare_plus_l : forall z x y, Rcompare (z + x) (z + y) = Rcompare x y.
Theorem Rcompare_mult_r : forall z x y, (0 < z)%R -> Rcompare (x * z) (y * z) = Rcompare x y.
Theorem Rcompare_mult_l : forall z x y, (0 < z)%R -> Rcompare (z * x) (z * y) = Rcompare x y.
Theorem Rcompare_middle : forall x d u, Rcompare (x - d) (u - x) = Rcompare x ((d + u) / 2).
Theorem Rcompare_half_l : forall x y, Rcompare (x / 2) y = Rcompare x (2 * y).
Theorem Rcompare_half_r : forall x y, Rcompare x (y / 2) = Rcompare (2 * x) y.
Theorem Rcompare_sqr : forall x y, (0 <= x)%R -> (0 <= y)%R -> Rcompare (x * x) (y * y) = Rcompare x y.
Theorem Rmin_compare : forall x y, Rmin x y = match Rcompare x y with Lt => x | Eq => x | Gt => y end.