(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \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)         *)
(************************************************************************)
(*********************************************************)
(**          Complements for the real numbers            *)
(*                                                       *)
(*********************************************************)
Local Open Scope R_scope.
Implicit Type r : R.
(*******************************)
(** *        Rmin              *)
(*******************************)
(*********)
Definition Rmin (x y:R) : R :=
match Rle_dec x y with
| left _ => x
| right _ => y
end.

(* Specifications: *)
(*********)
Lemma Rmin_case : forall r1 r2 (P:R -> Type), P r1 -> P r2 -> P (Rmin r1 r2).
(*********)
Lemma Rmin_case_strong : forall r1 r2 (P:R -> Type),
(r1 <= r2 -> P r1) -> (r2 <= r1 -> P r2) -> P (Rmin r1 r2).
(*********)
Lemma Rmin_Rgt_l : forall r1 r2 r, Rmin r1 r2 > r -> r1 > r /\ r2 > r.
(*********)
Lemma Rmin_Rgt_r : forall r1 r2 r, r1 > r /\ r2 > r -> Rmin r1 r2 > r.
(*********)
Lemma Rmin_Rgt : forall r1 r2 r, Rmin r1 r2 > r <-> r1 > r /\ r2 > r.
(*********)
Lemma Rmin_l : forall x y:R, Rmin x y <= x.
(*********)
Lemma Rmin_r : forall x y:R, Rmin x y <= y.
(*********)
Lemma Rmin_left : forall x y, x <= y -> Rmin x y = x.
(*********)
Lemma Rmin_right : forall x y, y <= x -> Rmin x y = y.
(*********)
Lemma Rle_min_compat_r : forall x y z, x <= y -> Rmin x z <= Rmin y z.
(*********)
Lemma Rle_min_compat_l : forall x y z, x <= y -> Rmin z x <= Rmin z y.
(*********)
Lemma Rmin_comm : forall x y:R, Rmin x y = Rmin y x.
(*********)
Lemma Rmin_stable_in_posreal : forall x y:posreal, 0 < Rmin x y.
(*********)
Lemma Rmin_pos : forall x y:R, 0 < x -> 0 < y -> 0 < Rmin x y.
(*********)
Lemma Rmin_glb : forall x y z:R, z <= x -> z <= y -> z <= Rmin x y.
(*********)
Lemma Rmin_glb_lt : forall x y z:R, z < x -> z < y -> z < Rmin x y.
Definition Rmax (x y:R) : R :=
match Rle_dec x y with
| left _ => y
| right _ => x
end.