(** * Sup and Inf of sequences in Rbar *)

(** ** Definitions *)

Definition is_sup_seq (u : nat -> Rbar) (l : Rbar) :=
  match l with
    | Finite l => forall (eps : posreal), (forall n, Rbar_lt (u n) (l+eps))
                                       /\ (exists n, Rbar_lt (l-eps) (u n))
    | p_infty => forall M : R, exists n, Rbar_lt M (u n)
    | m_infty => forall M : R, forall n, Rbar_lt (u n) M
  end.Definition is_inf_seq (u : nat -> Rbar) (l : Rbar) :=
  match l with
    | Finite l => forall (eps : posreal), (forall n, Rbar_lt (Finite (l-eps)) (u n))
                                       /\ (exists n, Rbar_lt (u n) (Finite (l+eps)))
    | p_infty => forall M : R, forall n, Rbar_lt (Finite M) (u n)
    | m_infty => forall M : R, exists n, Rbar_lt (u n) (Finite M)
  end.

(* Specifications: *)
Lemma is_inf_opp_sup_seq (u : nat -> Rbar) (l : Rbar) : is_inf_seq (fun n => Rbar_opp (u n)) (Rbar_opp l) <-> is_sup_seq u l.
Lemma is_sup_opp_inf_seq (u : nat -> Rbar) (l : Rbar) : is_sup_seq (fun n => Rbar_opp (u n)) (Rbar_opp l) <-> is_inf_seq u l.
Lemma is_sup_seq_lub (u : nat -> Rbar) (l : Rbar) : is_sup_seq u l -> Rbar_is_lub (fun x => exists n, x = u n) l.
Lemma Rbar_is_lub_sup_seq (u : nat -> Rbar) (l : Rbar) : Rbar_is_lub (fun x => exists n, x = u n) l -> is_sup_seq u l.
Lemma is_inf_seq_glb (u : nat -> Rbar) (l : Rbar) : is_inf_seq u l -> Rbar_is_glb (fun x => exists n, x = u n) l.
Lemma Rbar_is_glb_inf_seq (u : nat -> Rbar) (l : Rbar) : Rbar_is_glb (fun x => exists n, x = u n) l -> is_inf_seq u l.
Lemma is_sup_seq_ext (u v : nat -> Rbar) (l : Rbar) : (forall n, u n = v n) -> is_sup_seq u l -> is_sup_seq v l.
Lemma is_inf_seq_ext (u v : nat -> Rbar) (l : Rbar) : (forall n, u n = v n) -> is_inf_seq u l -> is_inf_seq v l.
Lemma ex_sup_seq (u : nat -> Rbar) : {l : Rbar | is_sup_seq u l}.
Lemma ex_inf_seq (u : nat -> Rbar) : {l : Rbar | is_inf_seq u l}.