(** 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.
(** Basic properties *)
(** Decidability *)
(** Order *)
(** ** Least upper bound and Greatest Lower Bound *)
Definition Rbar_is_lub (E : Rbar -> Prop) (l : Rbar) :=
Rbar_is_upper_bound E l /\
(forall b : Rbar, Rbar_is_upper_bound E b -> Rbar_le l b).
Definition Rbar_is_glb (E : Rbar -> Prop) (l : Rbar) :=
Rbar_is_lower_bound E l /\
(forall b : Rbar, Rbar_is_lower_bound E b -> Rbar_le b l).
(** Functions *)
Definition Rbar_lub (E : Rbar -> Prop)
:= proj1_sig (Rbar_ex_lub E).
Definition Rbar_glb (E : Rbar -> Prop)
:= proj1_sig (Rbar_ex_glb E).

Lemma Rbar_opp_lub_glb (E : Rbar -> Prop) :
Rbar_lub (fun x => E (Rbar_opp x)) = Rbar_opp (Rbar_glb E).