(** 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 *)
(** Existence *)
(** Functions *)
Definition LimSup_seq (u : nat -> R) :=
proj1_sig (ex_LimSup_seq u).
Definition LimInf_seq (u : nat -> R) :=
proj1_sig (ex_LimInf_seq u).
(** Uniqueness *)
(** ** Operations and order *)
(** Constant *)
(** Opposite *)
(** Rbar_le *)
(** Scalar multplication *)
(** Index shifting *)
(** * Limit of sequences *)
(** ** Definition *)
Definition is_lim_seq (u : nat -> R) (l : Rbar) :=
filterlim u eventually (Rbar_locally l).
Definition is_lim_seq' (u : nat -> R) (l : Rbar) :=
match l with
| Finite l => forall eps : posreal, eventually (fun n => Rabs (u n - l) < eps)
| p_infty => forall M : R, eventually (fun n => M < u n)
| m_infty => forall M : R, eventually (fun n => u n < M)
end.
Definition ex_lim_seq (u : nat -> R) :=
exists l, is_lim_seq u l.
Definition ex_finite_lim_seq (u : nat -> R) :=
exists l : R, is_lim_seq u l.
Definition Lim_seq (u : nat -> R) : Rbar :=
Rbar_div_pos (Rbar_plus (LimSup_seq u) (LimInf_seq u))
{| pos := 2; cond_pos := Rlt_R0_R2 |}.
(** Equivalence with standard library Reals *)
(** Extensionality *)
(** Unicity *)

Lemma is_lim_seq_unique (u : nat -> R) (l : Rbar) :
is_lim_seq u l -> Lim_seq u = l.