(** This file is part of the Coquelicot formalization of real analysis in Coq: http://coquelicot.saclay.inria.fr/  Copyright (C) 2011-2015 Sylvie Boldo #<br /># Copyright (C) 2011-2015 Catherine Lelay #<br /># Copyright (C) 2011-2015 Guillaume Melquiond  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *)
(** This file gives properties of (least) upper and (greatest) lower bounds, especially in [Rbar]. - There are links between our bounds on [Rbar] and those of the standard library on [R]: for example Lemma [Rbar_ub_R_ub] between our [Rbar_is_upper_bound] and the standard library [is_upper_bound]. - From [Markov]'s principle, we deduce the construction of a lub (and of a glb) in [Rbar] from any non-empty set of reals: see Lemma [ex_lub_Rbar_ne].  *)
Open Scope R_scope.
(** * Bounds for sets in [R] *)
(** ** Upper and Lower bounds *)
Definition is_ub_Rbar (E : R -> Prop) (l : Rbar) :=
forall (x : R), E x -> Rbar_le x l.
Definition is_lb_Rbar (E : R -> Prop) (l : Rbar) :=
forall (x : R), E x -> Rbar_le l x.
(** Decidability *)
(** Order *)
(** ** Least upper bound and Greatest Lower Bound *)
Definition is_lub_Rbar (E : R -> Prop) (l : Rbar) :=
is_ub_Rbar E l /\ (forall b, is_ub_Rbar E b -> Rbar_le l b).
Definition is_glb_Rbar (E : R -> Prop) (l : Rbar) :=
is_lb_Rbar E l /\ (forall b, is_lb_Rbar E b -> Rbar_le b l).
(** Existence *)
(** Functions *)
Definition Lub_Rbar (E : R -> Prop) := proj1_sig (ex_lub_Rbar E).
Definition Glb_Rbar (E : R -> Prop) := proj1_sig (ex_glb_Rbar E).
(** Order *)
(** * Bounds for sets in [Rbar] *)
(** ** Upper and Lower bounds *)
Definition Rbar_is_upper_bound (E : Rbar -> Prop) (l : Rbar) :=
forall x, E x -> Rbar_le x l.
Definition Rbar_is_lower_bound (E : Rbar -> Prop) (l : Rbar) :=
forall x, E x -> Rbar_le l x.

Lemma Rbar_ub_lb (E : Rbar -> Prop) (l : Rbar) :
Rbar_is_upper_bound (fun x => E (Rbar_opp x)) (Rbar_opp l)
<-> Rbar_is_lower_bound E l.