(** 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 describes properties and definitions about limits of real sequences. This includes properties about the predicates [is_lim_seq] and [ex_lim_seq]. This file also defines several total functions using the Limited Principle of Omniscience. These total functions on [R] sequences are [Sup_seq], [Inf_seq], [LimSup_seq], [LimInf_seq] and of course [Lim_seq]. *)
Open Scope R_scope.
(** * 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.
(** Equivalent forms *)
(** Extensionality *)
(** Existence *)
(** Notations *)
Definition Sup_seq (u : nat -> Rbar) := proj1_sig (ex_sup_seq u).
Definition Inf_seq (u : nat -> Rbar) := proj1_sig (ex_inf_seq u).
(** ** Order *)
(** * LimSup and LimInf of sequences *)
(** ** Definitions *)
Definition is_LimSup_seq (u : nat -> R) (l : Rbar) :=
match l with
| Finite l => forall eps : posreal,
(forall N : nat, exists n : nat, (N <= n)%nat /\ l - eps < u n)
/\ (exists N : nat, forall n : nat, (N <= n)%nat -> u n < l + eps)
| p_infty => forall M : R, (forall N : nat, exists n : nat, (N <= n)%nat /\ M < u n)
| m_infty => forall M : R, (exists N : nat, forall n : nat, (N <= n)%nat -> u n < M)
end.
Definition is_LimInf_seq (u : nat -> R) (l : Rbar) :=
match l with
| Finite l => forall eps : posreal,
(forall N : nat, exists n : nat, (N <= n)%nat /\ u n < l + eps)
/\ (exists N : nat, forall n : nat, (N <= n)%nat -> l - eps < u n)
| p_infty => forall M : R, (exists N : nat, forall n : nat, (N <= n)%nat -> M < u n)
| m_infty => forall M : R, (forall N : nat, exists n : nat, (N <= n)%nat /\ u n < M)
end.
(** Equivalent forms *)
(** Extensionality *)

Lemma is_LimInf_seq_ext_loc (u v : nat -> R) (l : Rbar) :
eventually (fun n => u n = v n) ->
is_LimInf_seq u l -> is_LimInf_seq v l.