(** 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).

Lemma is_lub_Rbar_unique (E : R -> Prop) (l : Rbar) :
is_lub_Rbar E l -> Lub_Rbar E = l.