(**
This file is part of the Coquelicot formalization of real
analysis in Coq: http://coquelicot.saclay.inria.fr/

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Copyright (C) 2011-2015 Sylvie Boldo
#<br />#
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Copyright (C) 2011-2015 Catherine Lelay
#<br />#
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
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.
*)

Require Import Reals Psatz.
Require Import mathcomp.ssreflect.ssreflect.
Require Import Rcomplements.
Require Import Rbar Lub Markov Hierarchy.

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

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
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))
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
                                       /\ (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.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition is_inf_seq (u : nat -> Rbar) (l : Rbar) :=
  match l with
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    | 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 *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_inf_opp_sup_seq (u : nat -> Rbar) (l : Rbar) :
  is_inf_seq (fun n => Rbar_opp (u n)) (Rbar_opp l)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  <-> is_sup_seq u l.
Proof.
(* Goal: iff (is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp l)) (is_sup_seq u l) *)
  destruct l as [l | | ] ; split ; intros Hl.
(* l = Finite l *)
(* Goal: is_sup_seq u (Finite l) *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp (Finite l)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  intro eps ; case (Hl eps) ; clear Hl ; intros lb (n, glb) ; split.
(* Goal: forall n : nat, Rbar_lt (u n) (Finite (Rplus l (pos eps))) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite (Rminus l (pos eps))) (u n)) *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp (Finite l)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  intro n0 ; apply Rbar_opp_lt ; simpl ; rewrite (Ropp_plus_distr l eps) ; apply lb.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite (Rminus l (pos eps))) (u n)) *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp (Finite l)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  exists n ; apply Rbar_opp_lt ; assert (Rw : -(l-eps) = -l+eps).
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  ring.
(* Goal: Rbar_lt (Rbar_opp (u n)) (Rbar_opp (Finite (Rminus l (pos eps)))) *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp (Finite l)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  simpl ; rewrite Rw ; clear Rw ; auto.
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp (Finite l)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  intro eps ; case (Hl eps) ; clear Hl ; intros ub (n, lub) ; split.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  intros n0 ; unfold Rminus ; rewrite <-(Ropp_plus_distr l eps) ;
  apply (Rbar_opp_lt (Finite (l+eps)) (u n0)) ; simpl ; apply ub.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps)))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  exists n ; assert (Rw : -(l-eps) = -l+eps).
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  ring.
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  simpl ; rewrite <-Rw ; apply (Rbar_opp_lt (u n) (Finite (l-eps))) ; auto.
(* l = p_infty *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  intro M ; case (Hl (-M)) ; clear Hl ; intros n Hl ; exists n ; apply Rbar_opp_lt ; auto.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  intro M ; case (Hl (-M)) ; clear Hl ; intros n Hl ; exists n ; apply Rbar_opp_lt ;
  rewrite Rbar_opp_involutive ; auto.
(* l = m_infty *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  intros M n ; apply Rbar_opp_lt, Hl.
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  intros M n ; apply Rbar_opp_lt ; rewrite Rbar_opp_involutive ; apply Hl.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_sup_opp_inf_seq (u : nat -> Rbar) (l : Rbar) :
  is_sup_seq (fun n => Rbar_opp (u n)) (Rbar_opp l)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  <-> is_inf_seq u l.
Proof.
(* Goal: iff (is_LimSup_seq u l) (is_LimSup_seq (fun n : nat => u (S n)) l) *)
  case: l => [l | | ] ; split => Hl.
(* l = Finite l *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hl eps) => {Hl} [lb [n lub]] ; split.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  move => n0 ; apply Rbar_opp_lt ; have : (-(l-eps) = -l+eps) ; first by ring.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by move => /= ->.
(* Goal: @ex nat (fun n : nat => Rbar_lt (u n) (Finite (Rplus l (pos eps)))) *)
(* Goal: is_sup_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp (Finite l)) *)
(* Goal: is_inf_seq u p_infty *)
(* Goal: is_sup_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_inf_seq u m_infty *)
(* Goal: is_sup_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  exists n ; apply Rbar_opp_lt ; rewrite /= (Ropp_plus_distr l eps) ; apply lub.
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hl eps) => {Hl} [ub [n lub]] ; split.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  move => n0 ; have : (-(l-eps) = (-l+eps)) ; first by ring.
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move => /= <- ; by apply (Rbar_opp_lt (u n0) (Finite (l-eps))).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  exists n ; rewrite /Rminus -(Ropp_plus_distr l eps) ;
  by apply (Rbar_opp_lt (Finite (l+eps)) (u n)).
(* l = p_infty *)
(* Goal: is_inf_seq u p_infty *)
(* Goal: is_sup_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_inf_seq u m_infty *)
(* Goal: is_sup_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  move => M n ; apply Rbar_opp_lt, Hl.
(* Goal: is_sup_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_inf_seq u m_infty *)
(* Goal: is_sup_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  move => M n ; apply Rbar_opp_lt ; rewrite Rbar_opp_involutive ; apply Hl.
(* l = m_infty *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (v n) (Finite M)) *)
  move => M ; case: (Hl (-M)) => {Hl} n Hl ; exists n ; by apply Rbar_opp_lt.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  move => M ; case: (Hl (-M)) => {Hl} n Hl ; exists n ; apply Rbar_opp_lt ;
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Rbar_opp_involutive.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_sup_seq_lub (u : nat -> Rbar) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_sup_seq u l -> Rbar_is_lub (fun x => exists n, x = u n) l.
Proof.
(* Goal: forall _ : is_sup_seq u l, Rbar_is_lub (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) l *)
  destruct l as [l | | ] ; intro Hl ; split.
(* l = Finite l *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) (Finite l) *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le (Finite l) b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  intro x ; destruct x as [x | | ] ; simpl ; intros (n, Hn).
(* Goal: Rle x l *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le (Finite l) b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  apply le_epsilon ; intros e He ; set (eps := mkposreal e He).
(* Goal: Rle x (Rplus l e) *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le (Finite l) b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  change (Rbar_le x (l + e)).
(* Goal: Rbar_le (Finite x) (Finite (Rplus l e)) *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le (Finite l) b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  rewrite Hn ; apply Rbar_lt_le, (Hl eps).
(* Goal: False *)
(* Goal: True *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le (Finite l) b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  now generalize (proj1 (Hl (mkposreal _ Rlt_0_1)) n) ; clear Hl ; simpl ; intros Hl ; rewrite <-Hn in Hl.
(* Goal: Rbar_le m_infty m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  easy.
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le (Finite l) b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  intros b ; destruct b as [b | | ] ; intros Hb ; apply Rbar_not_lt_le ; auto ; intros He.
(* Goal: False *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  set (eps := mkposreal _ (Rlt_Rminus _ _ He)) ; case (proj2 (Hl eps)) ; clear Hl ; intros n.
(* Goal: forall _ : Rbar_lt (Finite (Rminus l (pos eps))) (u n), False *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  apply Rbar_le_not_lt ; assert (l - eps = b) .
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  simpl ; ring.
(* Goal: Rbar_le (u n) (Finite (Rminus l (pos eps))) *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  rewrite H ; clear H ; apply Hb ; exists n ; auto.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  generalize (Rbar_ub_m_infty _ Hb) ; clear Hb ; intros Hb.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  case (proj2 (Hl (mkposreal _ Rlt_0_1))) ; clear Hl ; simpl ; intros n Hl.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  assert (H : (exists n0 : nat, u n = u n0)).
(* Goal: @ex nat (fun n0 : nat => @eq Rbar (u n) (u n0)) *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  exists n ; auto.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  generalize (Hb (u n) H) Hl ; clear Hb ; now case (u n).
(* l = p_infty *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) p_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  apply Rbar_ub_p_infty.
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le p_infty b *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  intro b ; destruct b as [b | | ] ; simpl ; intro Hb.
(* Goal: False *)
(* Goal: True *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  case (Hl b) ; clear Hl ; intros n Hl.
(* Goal: @ex nat (fun n0 : nat => @eq Rbar (u n) (u n0)) *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  contradict Hl ; apply Rbar_le_not_lt, Hb ; exists n ; auto.
(* Goal: Rbar_le m_infty m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  easy.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  generalize (Rbar_ub_m_infty _ Hb) ; clear Hb ; intro Hb.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  case (Hl 0) ; clear Hl; intros n Hl.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  assert (H : (exists n0 : nat, u n = u n0)).
(* Goal: @ex nat (fun n0 : nat => @eq Rbar (u n) (u n0)) *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  exists n ; auto.
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  generalize (Hb (u n) H) Hl ; clear Hl ; now case (u n).
(* l = m_infty *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  intro x ; destruct x as [x | | ] ; intros (n, Hx).
(* Goal: Rbar_le (Finite x) m_infty *)
(* Goal: Rbar_le p_infty m_infty *)
(* Goal: Rbar_le m_infty m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  generalize (Hl x n) ; clear Hl ; intro Hl ; rewrite <-Hx in Hl ; apply Rlt_irrefl in Hl ; intuition.
(* Goal: Rbar_le p_infty m_infty *)
(* Goal: Rbar_le m_infty m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  generalize (Hl 0 n) ; rewrite <-Hx ; intuition.
(* Goal: Rbar_le m_infty m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  easy.
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  now intros b ; destruct b as [b | | ].
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Rbar_is_lub_sup_seq (u : nat -> Rbar) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Rbar_is_lub (fun x => exists n, x = u n) l -> is_sup_seq u l.
Proof.
(* Goal: forall _ : Rbar_is_lub (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) l, is_sup_seq u l *)
  destruct l as [l | | ] ; intros (ub, lub).
(* l = Finite l *)
(* Goal: is_sup_seq u (Finite l) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_sup_seq u m_infty *)
  intro eps ; split.
(* Goal: forall n : nat, Rbar_lt (u n) (Finite (Rplus l (pos eps))) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite (Rminus l (pos eps))) (u n)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_sup_seq u m_infty *)
  intro n ; apply Rbar_le_lt_trans with (y := Finite l).
(* Goal: @ex nat (fun n0 : nat => @eq Rbar (u n) (u n0)) *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  apply ub ; exists n ; auto.
(* Goal: Rbar_lt (Finite l) (Finite (Rplus l (pos eps))) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite (Rminus l (pos eps))) (u n)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_sup_seq u m_infty *)
  pattern l at 1 ; rewrite <-(Rplus_0_r l) ; apply Rplus_lt_compat_l, eps.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite (Rminus l (pos eps))) (u n)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_sup_seq u m_infty *)
  apply LPO_notforall.
(* Goal: forall n : nat, or (Rbar_lt (Finite M) (u n)) (not (Rbar_lt (Finite M) (u n))) *)
(* Goal: not (forall n : nat, not (Rbar_lt (Finite M) (u n))) *)
(* Goal: is_sup_seq u m_infty *)
  intro n.
(* Goal: or (Rbar_lt (Finite (Rminus l (pos eps))) (u n)) (not (Rbar_lt (Finite (Rminus l (pos eps))) (u n))) *)
(* Goal: not (forall n : nat, not (Rbar_lt (Finite (Rminus l (pos eps))) (u n))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_sup_seq u m_infty *)
  destruct (Rbar_lt_dec (l - eps) (u n)) as [H|H].
(* Goal: or (Rbar_lt (Finite M) (u n)) (not (Rbar_lt (Finite M) (u n))) *)
(* Goal: or (Rbar_lt (Finite M) (u n)) (not (Rbar_lt (Finite M) (u n))) *)
(* Goal: not (forall n : nat, not (Rbar_lt (Finite M) (u n))) *)
(* Goal: is_sup_seq u m_infty *)
  now left.
(* Goal: or (@eq Rbar p_infty m_infty) (not (@eq Rbar p_infty m_infty)) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
  now right.
(* Goal: not (forall n : nat, not (Rbar_lt (Finite M) (u n))) *)
(* Goal: is_sup_seq u m_infty *)
  intro H.
(* Goal: False *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_sup_seq u m_infty *)
  assert (H0 : (Rbar_is_upper_bound (fun x : Rbar => exists n : nat, x = u n) (Finite (l - eps)))).
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) (Finite M) *)
(* Goal: False *)
(* Goal: is_sup_seq u m_infty *)
  intros x (n,Hn) ; rewrite Hn ; clear Hn ; apply Rbar_not_lt_le, H.
  generalize (lub _ H0) ; clear lub ; apply Rbar_lt_not_le ; pattern l at 2 ;
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite <-(Rplus_0_r l) ;
  apply Rplus_lt_compat_l, Ropp_lt_gt_0_contravar, eps.
(* l = p_infty *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite (Rminus l (pos eps))) (u n)) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_sup_seq u m_infty *)
  intro M ; apply LPO_notforall.
(* Goal: forall n : nat, or (Rbar_lt (Finite M) (u n)) (not (Rbar_lt (Finite M) (u n))) *)
(* Goal: not (forall n : nat, not (Rbar_lt (Finite M) (u n))) *)
(* Goal: is_sup_seq u m_infty *)
  intro n.
(* Goal: or (Rbar_lt (Finite M) (u n)) (not (Rbar_lt (Finite M) (u n))) *)
(* Goal: not (forall n : nat, not (Rbar_lt (Finite M) (u n))) *)
(* Goal: is_sup_seq u m_infty *)
  destruct (Rbar_lt_dec M (u n)) as [H|H].
(* Goal: or (Rbar_lt (Finite M) (u n)) (not (Rbar_lt (Finite M) (u n))) *)
(* Goal: or (Rbar_lt (Finite M) (u n)) (not (Rbar_lt (Finite M) (u n))) *)
(* Goal: not (forall n : nat, not (Rbar_lt (Finite M) (u n))) *)
(* Goal: is_sup_seq u m_infty *)
  now left.
(* Goal: or (@eq Rbar p_infty m_infty) (not (@eq Rbar p_infty m_infty)) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
  now right.
(* Goal: not (forall n : nat, not (Rbar_lt (Finite M) (u n))) *)
(* Goal: is_sup_seq u m_infty *)
  intro H.
(* Goal: False *)
(* Goal: is_sup_seq u m_infty *)
  assert (H0 : Rbar_is_upper_bound (fun x : Rbar => exists n : nat, x = u n) (Finite M)).
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) (Finite M) *)
(* Goal: False *)
(* Goal: is_sup_seq u m_infty *)
  intros x (n,Hn) ; rewrite Hn ; clear Hn ; apply Rbar_not_lt_le, H.
(* Goal: False *)
(* Goal: is_sup_seq u m_infty *)
  generalize (lub _ H0) ; clear lub ; apply Rbar_lt_not_le ; simpl ; auto.
(* l = m_infty *)
(* Goal: is_sup_seq u m_infty *)
  intros M n.
(* Goal: Rbar_lt (u n) (Finite M) *)
  apply Rbar_le_lt_trans with (y := m_infty) ; simpl ; auto.
(* Goal: @ex nat (fun n0 : nat => @eq Rbar (u n) (u n0)) *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  apply ub ; exists n ; auto.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_inf_seq_glb (u : nat -> Rbar) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_inf_seq u l -> Rbar_is_glb (fun x => exists n, x = u n) l.
Proof.
  move => H ;
  apply Rbar_lub_glb ;
  apply (Rbar_is_lub_ext (fun x : Rbar => exists n : nat, x = Rbar_opp (u n))).
(* Goal: forall x : Rbar, iff (@ex nat (fun n : nat => @eq Rbar x (Rbar_opp (u n)))) (@ex nat (fun n : nat => @eq Rbar (Rbar_opp x) (u n))) *)
(* Goal: Rbar_is_lub (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (Rbar_opp (u n)))) (Rbar_opp l) *)
  move => x ; split ; case => n Hn ; exists n.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Hn Rbar_opp_involutive.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite -Hn Rbar_opp_involutive.
  apply (is_sup_seq_lub (fun n => Rbar_opp (u n)) (Rbar_opp l)) ;
  by apply is_sup_opp_inf_seq.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Rbar_is_glb_inf_seq (u : nat -> Rbar) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Rbar_is_glb (fun x => exists n, x = u n) l -> is_inf_seq u l.
Proof.
  move => H ;
  apply is_sup_opp_inf_seq ;
  apply Rbar_is_lub_sup_seq ;
  apply Rbar_glb_lub.
  rewrite Rbar_opp_involutive ;
  apply (Rbar_is_glb_ext (fun x : Rbar => exists n : nat, x = u n)) => // x ;
  split ; case => n Hx ; exists n ; by apply Rbar_opp_eq.
Qed.

(** Extensionality *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_sup_seq_ext (u v : nat -> Rbar) (l : Rbar) :
  (forall n, u n = v n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> is_sup_seq u l -> is_sup_seq v l.
Proof.
(* Goal: iff (is_LimSup_seq u l) (is_LimSup_seq (fun n : nat => u (S n)) l) *)
  case: l => [l | | ] Heq ; rewrite /is_sup_seq => Hu.
(* l \in R *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hu eps) => {Hu} Hu1 Hu2 ; split.
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move => n ; by rewrite -Heq.
(* Goal: @ex nat (fun n : nat => Rbar_lt (v n) (Finite (Rplus l (pos eps)))) *)
(* Goal: forall (M : R) (n : nat), Rbar_lt (Finite M) (v n) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (v n) (Finite M)) *)
  case: Hu2 => n Hu2 ; exists n ; by rewrite -Heq.
(* l = p_infty *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (v n) (Finite M)) *)
  move => M ; case: (Hu M) => {Hu} n Hu ; exists n ; by rewrite -Heq.
(* l = m_infty *)
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move => M n ; by rewrite -Heq.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_inf_seq_ext (u v : nat -> Rbar) (l : Rbar) :
  (forall n, u n = v n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> is_inf_seq u l -> is_inf_seq v l.
Proof.
(* Goal: iff (is_LimSup_seq u l) (is_LimSup_seq (fun n : nat => u (S n)) l) *)
  case: l => [l | | ] Heq ; rewrite /is_inf_seq => Hu.
(* l \in R *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hu eps) => {Hu} Hu1 Hu2 ; split.
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move => n ; by rewrite -Heq.
(* Goal: @ex nat (fun n : nat => Rbar_lt (v n) (Finite (Rplus l (pos eps)))) *)
(* Goal: forall (M : R) (n : nat), Rbar_lt (Finite M) (v n) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (v n) (Finite M)) *)
  case: Hu2 => n Hu2 ; exists n ; by rewrite -Heq.
(* l = p_infty *)
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move => M n ; by rewrite -Heq.
(* l = m_infty *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (v n) (Finite M)) *)
  move => M ; case: (Hu M) => {Hu} n Hu ; exists n ; by rewrite -Heq.
Qed.

(** Existence *)

Lemma ex_sup_seq (u : nat -> Rbar) : {l : Rbar | is_sup_seq u l}.
Proof.
  case (LPO (fun n => p_infty = u n)) => [/= |  [np Hnp] | Hnp].
(* Goal: forall n : nat, or (@eq Rbar p_infty (u n)) (not (@eq Rbar p_infty (u n))) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
    intro n0 ; destruct (u n0) as [r | | ].
(* Goal: or (@eq Rbar p_infty m_infty) (not (@eq Rbar p_infty m_infty)) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
    now right.
(* Goal: or (@eq Rbar p_infty p_infty) (not (@eq Rbar p_infty p_infty)) *)
(* Goal: or (@eq Rbar p_infty m_infty) (not (@eq Rbar p_infty m_infty)) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
    left ; auto.
(* Goal: or (@eq Rbar p_infty m_infty) (not (@eq Rbar p_infty m_infty)) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
    now right.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists p_infty => M.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
  exists np ; by rewrite -Hnp.
(* Goal: @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
  case (Rbar_ex_lub (fun x => exists n, x = u n)).
(* Goal: forall (x : Rbar) (_ : Rbar_is_lub (fun x0 : Rbar => @ex nat (fun n : nat => @eq Rbar x0 (u n))) x), @sig Rbar (fun l : Rbar => is_sup_seq u l) *)
  intros l Hl ; exists l ; apply Rbar_is_lub_sup_seq ; auto.
Qed.

Lemma ex_inf_seq (u : nat -> Rbar) : {l : Rbar | is_inf_seq u l}.
Proof.
(* Goal: False *)
  case : (ex_sup_seq (fun n => Rbar_opp (u n))) => l Hl.
(* Goal: @sig Rbar (fun l : Rbar => is_inf_seq u l) *)
  exists (Rbar_opp l) ; apply is_sup_opp_inf_seq ; by rewrite Rbar_opp_involutive.
Qed.

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

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_sup_seq_unique (u : nat -> Rbar) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_sup_seq u l -> Sup_seq u = l.
Proof.
  move => Hl ; rewrite /Sup_seq ; case: (ex_sup_seq _) => l0 Hl0 /= ;
  case: l Hl => [l | | ] Hl ; case: l0 Hl0 => [l0 | | ] Hl0 //.
  apply Rbar_finite_eq, Rle_antisym ; apply le_epsilon => e He ;
  set eps := mkposreal e He ; apply Rlt_le ;
  case: (Hl (pos_div_2 eps)) => {Hl} Hl [n Hn] ;
  case: (Hl0 (pos_div_2 eps)) => {Hl0} Hl0 [n0 Hn0].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have: (l0 = (l0 - eps/2) + eps/2) ; [by field | move => -> ] ;
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have : (l + e = (l + eps/2) + eps/2) ; [ simpl ; field | move => -> ] ;
  apply Rplus_lt_compat_r, (Rbar_lt_trans
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    (Finite (l0 - eps/2)) (u n0) (Finite (l + eps/2)) Hn0 (Hl _)).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have: (l = (l - eps/2) + eps/2) ; [by field | move => -> ] ;
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have : (l0 + e = (l0 + eps/2) + eps/2) ; [ simpl ; field | move => -> ] ;
  apply Rplus_lt_compat_r, (Rbar_lt_trans
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    (Finite (l - eps/2)) (u n) (Finite (l0 + eps/2)) Hn (Hl0 _)).
  case: (Hl0 (l + 1)) => n {Hl0} Hl0 ; contradict Hl0 ;
    apply Rbar_le_not_lt, Rbar_lt_le, (Hl (mkposreal _ Rlt_0_1)).
  case: (Hl (mkposreal _ Rlt_0_1)) => {Hl} _ [n Hl] ; contradict Hl ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl0.
  case: (Hl (l0 + 1)) => n {Hl} Hl ; contradict Hl ;
    apply Rbar_le_not_lt, Rbar_lt_le, (Hl0 (mkposreal _ Rlt_0_1)).
  case: (Hl 0) => n {Hl} Hl ; contradict Hl ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl0.
  case: (Hl0 (mkposreal _ Rlt_0_1)) => {Hl0} _ [n Hl0] ; contradict Hl0 ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl.
  case: (Hl0 0) => n {Hl0} Hl0 ; contradict Hl0 ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Sup_seq_correct (u : nat -> Rbar) :
  is_sup_seq u (Sup_seq u).
Proof.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /Sup_seq ; case: (ex_sup_seq _) => l Hl //.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_inf_seq_unique (u : nat -> Rbar) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_inf_seq u l -> Inf_seq u = l.
Proof.
  move => Hl ; rewrite /Inf_seq ; case: (ex_inf_seq _) => l0 Hl0 /= ;
  case: l Hl => [l | | ] Hl ; case: l0 Hl0 => [l0 | | ] Hl0 //.
  apply Rbar_finite_eq, Rle_antisym ; apply le_epsilon => e He ;
  set eps := mkposreal e He ; apply Rlt_le ;
  case: (Hl (pos_div_2 eps)) => {Hl} Hl [n Hn] ;
  case: (Hl0 (pos_div_2 eps)) => {Hl0} Hl0 [n0 Hn0].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have: (l0 = (l0 - eps/2) + eps/2) ; [by field | move => -> ] ;
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have : (l + e = (l + eps/2) + eps/2) ; [ simpl ; field | move => -> ] ;
  apply Rplus_lt_compat_r, (Rbar_lt_trans
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    (Finite (l0 - eps/2)) (u n) (Finite (l + eps/2)) (Hl0 _) Hn).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have: (l = (l - eps/2) + eps/2) ; [by field | move => -> ] ;
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  have : (l0 + e = (l0 + eps/2) + eps/2) ; [ simpl ; field | move => -> ] ;
  apply Rplus_lt_compat_r, (Rbar_lt_trans
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    (Finite (l - eps/2)) (u n0) (Finite (l0 + eps/2)) (Hl _) Hn0).
  case: (Hl (mkposreal _ Rlt_0_1)) => {Hl} _ [n Hl] ; contradict Hl ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl0.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (Hl0 (l - 1)) => n {Hl0} Hl0 ; contradict Hl0 ;
    apply Rbar_le_not_lt, Rbar_lt_le, (Hl (mkposreal _ Rlt_0_1)).
  case: (Hl0 (mkposreal _ Rlt_0_1)) => {Hl0} _ [n Hl0] ; contradict Hl0 ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl.
  case: (Hl0 0) => n {Hl0} Hl0 ; contradict Hl0 ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (Hl (l0 - 1)) => n {Hl} Hl ; contradict Hl ;
    apply Rbar_le_not_lt, Rbar_lt_le, (Hl0 (mkposreal _ Rlt_0_1)).
  case: (Hl 0) => n {Hl} Hl ; contradict Hl ;
    apply Rbar_le_not_lt, Rbar_lt_le, Hl0.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Inf_seq_correct (u : nat -> Rbar) :
  is_inf_seq u (Inf_seq u).
Proof.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /Inf_seq ; case: (ex_inf_seq _) => l Hl //.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Sup_seq_ext (u v : nat -> Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, (u n) = (v n)) -> Sup_seq u = Sup_seq v.
Proof.
  intro Heq ; rewrite {2}/Sup_seq ;
  case (ex_sup_seq v) ; simpl ; intros l2 Hv.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply (is_sup_seq_unique u), is_sup_seq_ext with v.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Inf_seq_ext (u v : nat -> Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, (u n) = (v n)) -> Inf_seq u = Inf_seq v.
Proof.
  intro Heq ; rewrite {2}/Inf_seq ;
  case (ex_inf_seq v) ; simpl ; intros l2 Hv.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply (is_inf_seq_unique u), is_inf_seq_ext with v.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Rbar_sup_eq_lub (u : nat -> Rbar) :
  Sup_seq u = Rbar_lub (fun x => exists n, x = u n).
Proof.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /Sup_seq ; case: (ex_sup_seq _) => /= s Hs.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /Rbar_lub ; case: (Rbar_ex_lub _) => /= l Hl.
  apply (Rbar_is_lub_eq
    (fun x : Rbar => exists n : nat, x = u n)
    (fun x : Rbar => exists n : nat, x = u n)) => // ;
  by apply is_sup_seq_lub.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Inf_eq_glb (u : nat -> Rbar) :
  Inf_seq u = Rbar_glb (fun x => exists n, x = u n).
Proof.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /Inf_seq ; case: (ex_inf_seq _) => /= s Hs.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /Rbar_glb ; case: (Rbar_ex_glb _) => /= l Hl.
  apply (Rbar_is_glb_eq
    (fun x : Rbar => exists n : nat, x = u n)
    (fun x : Rbar => exists n : nat, x = u n)) => // ;
  by apply is_inf_seq_glb.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Sup_opp_inf (u : nat -> Rbar) :
  Sup_seq u = Rbar_opp (Inf_seq (fun n => Rbar_opp (u n))).
Proof.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /Inf_seq ; case: (ex_inf_seq _) => iu Hiu /=.
(* Goal: @eq Rbar (Sup_seq (fun _ : nat => Finite (IZR Z0))) (Finite (IZR Z0)) *)
(* Goal: @eq Rbar (Finite (IZR Z0)) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  apply is_sup_seq_unique.
(* Goal: is_sup_seq u (Rbar_opp iu) *)
  apply is_inf_opp_sup_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Rbar_opp_involutive.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Inf_opp_sup (u : nat -> Rbar) :
  Inf_seq u = Rbar_opp (Sup_seq (fun n => Rbar_opp (u n))).
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Sup_opp_inf Rbar_opp_involutive.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Inf_seq.
(* Goal: @eq Rbar (@proj1_sig Rbar (fun l : Rbar => is_inf_seq u l) (ex_inf_seq u)) (@proj1_sig Rbar (fun l : Rbar => is_inf_seq (fun n : nat => Rbar_opp (Rbar_opp (u n))) l) (ex_inf_seq (fun n : nat => Rbar_opp (Rbar_opp (u n))))) *)
  repeat (case: ex_inf_seq ; intros) => /=.
(* Goal: @eq Rbar x x0 *)
  apply is_inf_seq_glb in p.
(* Goal: @eq Rbar x x0 *)
  apply is_inf_seq_glb in p0.
(* Goal: @eq Rbar x x0 *)
  move: p p0 ; apply Rbar_is_glb_eq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  move => x1 ; split ; case => n -> ; exists n ; by rewrite Rbar_opp_involutive.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Sup_seq_scal_l (a : R) (u : nat -> Rbar) : 0 <= a ->
  Sup_seq (fun n => Rbar_mult a (u n)) = Rbar_mult a (Sup_seq u).
Proof.
(* Goal: False *)
  case => Ha.
(* 0 < a *)
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Sup_seq.
(* Goal: False *)
  case: ex_sup_seq => al Hau.
(* Goal: False *)
  case: ex_sup_seq => l Hu.
(* Goal: @eq Rbar (@proj1_sig Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) (@exist Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) al Hau)) (Rbar_mult (Finite a) (@proj1_sig Rbar (fun l : Rbar => is_sup_seq u l) (@exist Rbar (fun l : Rbar => is_sup_seq u l) l Hu))) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  simpl proj1_sig.
(* Goal: @eq Rbar al (Rbar_mult (Finite a) l) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  apply Rbar_le_antisym.

(* Goal: Rbar_le l (Rbar_div_pos al (mkposreal a Ha)) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  apply is_sup_seq_lub in Hau.
(* Goal: Rbar_le l (Rbar_div_pos al (mkposreal a Ha)) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  apply is_sup_seq_lub in Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Hau => _ [n ->].
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff : Rbar_le (u n) l.
    case: (u n) => [un | | ] ; case: (l) => [l' | | ] /= ; try (by case) ;
    try (case: Rle_dec (Rlt_le _ _ Ha) => //= Ha' _ ;
    case: Rle_lt_or_eq_dec (Rlt_not_eq _ _ Ha) => //= _ _ _ ; by left).
  intros H ; apply Rmult_le_compat_l => // ;
  by apply Rlt_le.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  apply Hu.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists n.

(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff : Rbar_le l (Rbar_div_pos al (mkposreal a Ha)).
  case: (al) => [al' | | ] ; case: (l) => [l' | | ] /= ; try (by case) ;
    try (case: Rle_dec (Rlt_le _ _ Ha) => //= Ha' _ ;
    case: Rle_lt_or_eq_dec (Rlt_not_eq _ _ Ha) => //= _ _ _ ; by left).
  intros H ; rewrite Rmult_comm ;
  apply Rle_div_r => //.
(* Goal: Rbar_le l (Rbar_div_pos al (mkposreal a Ha)) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  apply is_sup_seq_lub in Hau.
(* Goal: Rbar_le l (Rbar_div_pos al (mkposreal a Ha)) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  apply is_sup_seq_lub in Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Hu => _ [n ->].
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff : Rbar_le (Rbar_mult a (u n)) al.
    case: (u n) => [un | | ] ; case: (al) => [al' | | ] /= ; try (by case) ;
    try (case: Rle_dec (Rlt_le _ _ Ha) => //= Ha' _ ;
    case: Rle_lt_or_eq_dec (Rlt_not_eq _ _ Ha) => //= _ _ ; try (by case) ; by left).
  intros H ; rewrite Rmult_comm in H ;
  apply Rle_div_r => //.
(* Goal: Rbar_le (Rbar_mult (Finite a) (u n)) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  apply Hau.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists n.

(* a = 0 *)
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -Ha.
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite (IZR Z0)) (u n))) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  transitivity (Sup_seq (fun _ => 0)).
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite (IZR Z0)) (u n))) (Sup_seq (fun _ : nat => Finite (IZR Z0))) *)
(* Goal: @eq Rbar (Sup_seq (fun _ : nat => Finite (IZR Z0))) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  apply Sup_seq_ext.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => n ; case: (u n) => [un | | ] /=.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply f_equal ; ring.
(* Goal: False *)
  case: Rle_dec (Rle_refl 0) => //= H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rle_not_lt _ _ H) => //= H _.
(* Goal: False *)
  case: Rle_dec (Rle_refl 0) => //= H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rle_not_lt _ _ H) => //= H _.

(* Goal: @eq Rbar (Sup_seq (fun _ : nat => Finite (IZR Z0))) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  transitivity 0.
(* Goal: @eq Rbar (Sup_seq (fun _ : nat => Finite (IZR Z0))) (Finite (IZR Z0)) *)
(* Goal: @eq Rbar (Finite (IZR Z0)) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  apply is_sup_seq_unique.
(* Goal: eventually (fun n : nat => Rle (Ropp (v n)) (Ropp (u n))) *)
  move => eps ; split => /=.
(* Goal: forall _ : nat, Rlt (IZR Z0) (Rplus (IZR Z0) (pos eps)) *)
(* Goal: @ex nat (fun _ : nat => Rlt (Rminus (IZR Z0) (pos eps)) (IZR Z0)) *)
(* Goal: @eq Rbar (Finite (IZR Z0)) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  move => _ ; ring_simplify ; by apply eps.
(* Goal: @ex nat (fun _ : nat => Rlt (Rminus (IZR Z0) (pos eps)) (IZR Z0)) *)
(* Goal: @eq Rbar (Finite (IZR Z0)) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  exists 0%nat ; apply Rminus_lt_0 ; ring_simplify ; by apply eps.

(* Goal: False *)
  case: (Sup_seq u) => [l | | ] /=.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply f_equal ; ring.
(* Goal: False *)
  case: Rle_dec (Rle_refl 0) => //= H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rle_not_lt _ _ H) => //= H _.
(* Goal: False *)
  case: Rle_dec (Rle_refl 0) => //= H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rle_not_lt _ _ H) => //= H _.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Inf_seq_scal_l (a : R) (u : nat -> Rbar) : 0 <= a ->
  Inf_seq (fun n => Rbar_mult a (u n)) = Rbar_mult a (Inf_seq u).
Proof.
(* Goal: False *)
  move => Ha.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Inf_opp_sup.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -(Sup_seq_ext (fun n => Rbar_mult a (Rbar_opp (u n)))).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Sup_seq_scal_l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite -Rbar_mult_opp_r -(Inf_opp_sup u).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move => n ; by rewrite Rbar_mult_opp_r.
Qed.

(** ** Order *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_sup_seq_le (u v : nat -> Rbar) {l1 l2 : Rbar} :
  (forall n, Rbar_le (u n) (v n))
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> (is_sup_seq u l1) -> (is_sup_seq v l2) -> Rbar_le l1 l2.
Proof.
  destruct l1 as [l1 | | ] ; destruct l2 as [l2 | | ] ; intros Hle Hu Hv ;
  case (is_sup_seq_lub _ _ Hu) ; clear Hu ; intros _ Hu ;
  case (is_sup_seq_lub _ _ Hv) ; clear Hv ; intros Hv _ ;
(* Goal: @ex nat (fun n0 : nat => @eq Rbar (u n) (u n0)) *)
(* Goal: False *)
(* Goal: Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  apply Hu ; intros x (n,Hn) ; rewrite Hn ; clear x Hn ; apply Rbar_le_trans with (1 := Hle _), Hv ; exists n ; auto.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_inf_seq_le (u v : nat -> Rbar) {l1 l2 : Rbar} :
  (forall n, Rbar_le (u n) (v n))
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> (is_inf_seq u l1) -> (is_inf_seq v l2) -> Rbar_le l1 l2.
Proof.
  case: l1 => [l1 | | ] ; case: l2 => [l2 | | ] Hle Hu Hv ;
  case: (is_inf_seq_glb _ _ Hu) => {Hu} Hu _ ;
  case: (is_inf_seq_glb _ _ Hv) => {Hv} _ Hv ;
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  apply Hv => _ [n ->] ; apply Rbar_le_trans with (2 := Hle _), Hu ; by exists n.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Sup_seq_le (u v : nat -> Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, Rbar_le (u n) (v n)) -> Rbar_le (Sup_seq u) (Sup_seq v).
Proof.
  intros Heq ; unfold Sup_seq ;
  case (ex_sup_seq u) ; intros l1 Hu ; case (ex_sup_seq v) ; simpl ; intros l2 Hv.
(* Goal: Rbar_le l1 l2 *)
  apply (is_sup_seq_le u v) ; auto.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Inf_seq_le (u v : nat -> Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, Rbar_le (u n) (v n)) -> Rbar_le (Inf_seq u) (Inf_seq v).
Proof.
  move => Heq ; rewrite /Inf_seq ;
  case: (ex_inf_seq u) => l1 Hu ; case: (ex_inf_seq v) => /= l2 Hv.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply (is_inf_seq_le u v).
Qed.

Lemma Inf_le_sup (u : nat -> Rbar) : Rbar_le (Inf_seq u) (Sup_seq u).
Proof.
  rewrite /Inf_seq ; case: (ex_inf_seq _) ; case => [iu | | ] Hiu ;
  rewrite /Sup_seq ; case: (ex_sup_seq _) ; case => [su | | ] Hsu //=.
(* Finite, Finite *)
  apply le_epsilon => e He ; set eps := mkposreal e He ;
  case: (Hiu (pos_div_2 eps)) => {Hiu} Hiu _ ;
  case: (Hsu (pos_div_2 eps)) => {Hsu} Hsu _ ;
  apply Rlt_le.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  have : (iu = iu - e/2 + e/2) ; first by ring.
(* Goal: forall _ : @eq R iu (Rplus (Rminus iu (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))), Rlt iu (Rplus su e) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  move => -> ; have : (su+e = su + e/2 + e/2) ; first by field.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  by move => -> ; apply Rplus_lt_compat_r,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (Rbar_lt_trans (Finite (iu - e/2)) (u O) (Finite (su + e/2))).
(* Finite, m_infty *)
  set eps := mkposreal _ Rlt_0_1 ; case: (Hiu eps) => {Hiu} Hiu _ ;
  move: (Hiu O) => {Hiu} ; apply Rbar_le_not_lt, Rbar_lt_le, Hsu.
(* p_infty, Finite *)
  set eps := mkposreal _ Rlt_0_1 ; case: (Hsu eps) => {Hsu} Hsu _ ;
  move: (Hsu O) => {Hsu} ; apply Rbar_le_not_lt, Rbar_lt_le, Hiu.
(* p_infty, m_infty *)
(* Goal: False *)
  move: (Hiu 0 O) => {Hiu} ; apply Rbar_le_not_lt, Rbar_lt_le, Hsu.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_sup_seq_major (u : nat -> Rbar) (l : Rbar) (n : nat) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_sup_seq u l -> Rbar_le (u n) l.
Proof.
(* Goal: False *)
  case: l => [l | | ] //= Hl.
(* Goal: False *)
  move: (fun eps => proj1 (Hl eps) n) => {Hl}.
(* Goal: False *)
  case: (u n) => [un | | ] //= Hun.
(* Goal: Rle un l *)
(* Goal: False *)
(* Goal: Rbar_le (u n) p_infty *)
(* Goal: Rbar_le (u n) m_infty *)
  apply le_epsilon => e He ; apply Rlt_le.
(* Goal: F (fun x : T => Rle (g x) (h x)) *)
  apply: Hun (mkposreal e He).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by move: (Hun (mkposreal _ Rlt_0_1)).
(* Goal: False *)
  case: (u n) => [un | | ] //.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move: (Hl (u n) n) ; case: (u n) => [un | | ] //= {Hl} Hl.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rlt_irrefl in Hl.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Sup_seq_minor_lt (u : nat -> Rbar) (M : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Rbar_lt M (Sup_seq u) <-> exists n, Rbar_lt M (u n).
Proof.
(* Goal: iff (Rbar_lt (Finite M) (Sup_seq u)) (@ex nat (fun n : nat => Rbar_lt (Finite M) (u n))) *)
  rewrite /Sup_seq ; case: ex_sup_seq => l Hl ; simpl proj1_sig ; split => H.
(* Goal: False *)
  case: l Hl H => [l | | ] Hl H.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: Rbar_lt (Finite M) l *)
  apply Rminus_lt_0 in H.
(* Goal: iff (is_LimSup_seq u l) (is_LimSup_seq (fun n : nat => u (S n)) l) *)
  case: (proj2 (Hl (mkposreal _ H))) ; simpl pos => {Hl} n Hl.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: Rbar_lt (Finite M) l *)
  exists n.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace M with (l - (l - M)) by ring.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (u n)) *)
(* Goal: Rbar_lt (Finite M) l *)
  apply (Hl M).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: False *)
  case: H => n Hn.
(* Goal: Rbar_lt (Finite M) l *)
  apply Rbar_lt_le_trans with (u n).
(* Goal: Rbar_lt (Finite M) (u n) *)
(* Goal: Rbar_le (u n) l *)
  exact: Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_sup_seq_major.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Sup_seq_minor_le (u : nat -> Rbar) (M : R) (n : nat) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Rbar_le M (u n) -> Rbar_le M (Sup_seq u).
Proof.
(* Goal: forall _ : Rbar_le (Finite M) (u n), Rbar_le (Finite M) (Sup_seq u) *)
  intros H'.
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
  destruct (Rbar_le_lt_or_eq_dec _ _ H') as [H|H].
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
  apply Rbar_lt_le.
(* Goal: Rbar_lt (Finite M) (Sup_seq (fun n : nat => Finite (u (Init.Nat.add n N)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Sup_seq_minor_lt.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists n.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite H.
(* Goal: @eq Rbar (@proj1_sig Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) (@exist Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) al Hau)) (Rbar_mult (Finite a) (@proj1_sig Rbar (fun l : Rbar => is_sup_seq u l) (@exist Rbar (fun l : Rbar => is_sup_seq u l) l Hu))) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  rewrite /Sup_seq ; case: ex_sup_seq => l Hl ; simpl proj1_sig.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_sup_seq_major.
Qed.

(** * LimSup and LimInf of sequences *)

(** ** Definitions *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition is_LimSup_seq (u : nat -> R) (l : Rbar) :=
  match l with
    | Finite l => forall eps : posreal,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
        (forall N : nat, exists n : nat, (N <= n)%nat /\ l - eps < u n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
        /\ (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)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    | m_infty => forall M : R, (exists N : nat, forall n : nat, (N <= n)%nat -> u n < M)
  end.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
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)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
        /\ (exists N : nat, forall n : nat, (N <= n)%nat -> l - eps < u n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    | 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 *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_opp_LimSup_seq (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimInf_seq (fun n => - u n) (Rbar_opp l)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    <-> is_LimSup_seq u l.
Proof.
(* Goal: iff (is_LimSup_seq u l) (is_LimSup_seq (fun n : nat => u (S n)) l) *)
  case: l => [l | | ] /= ; split => Hl.
(* l \in R *)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
(* * -> *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hl eps) => {Hl} H1 H2 ; split.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => N ; case: (H1 N) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rlt_le_trans with (1 := H1) ; right ; ring.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rle_lt_trans with (2 := H2 _ Hn) ; right ; ring.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
(* * <- *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hl eps) => {Hl} H1 H2 ; split.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => N ; case: (H1 N) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt (Ropp (u n)) M *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (Ropp (u n)))) *)
  apply Ropp_lt_cancel ; rewrite Ropp_involutive.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rle_lt_trans with (2 := H1) ; right ; ring.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (Ropp (u n)) M *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (Ropp (u n)))) *)
  apply Ropp_lt_cancel ; rewrite Ropp_involutive.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rlt_le_trans with (1 := H2 _ Hn) ; right ; ring.
(* l = p_infty *)
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hl (-M) N) => {Hl} n [Hn Hl].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt eps (Ropp y) *)
  by apply Ropp_lt_cancel.
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hl (-M) N) => {Hl} n [Hn Hl].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rgt (Ropp q) (IZR (Zpos xH)) *)
(* Goal: Rlt q (IZR Z0) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Ropp_lt_cancel ; by rewrite Ropp_involutive.
(* l = m_infty *)
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl (-M)) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl (-M)) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (Ropp (u n)) M *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (Ropp (u n)))) *)
  apply Ropp_lt_cancel ; rewrite Ropp_involutive.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_opp_LimInf_seq (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq (fun n => - u n) (Rbar_opp l)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    <-> is_LimInf_seq u l.
Proof.
(* Goal: iff (is_LimSup_seq u l) (is_LimSup_seq (fun n : nat => u (S n)) l) *)
  case: l => [l | | ] /= ; split => Hl.
(* l \in R *)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
(* * -> *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hl eps) => {Hl} H1 H2 ; split.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => N ; case: (H1 N) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rle_lt_trans with (2 := H1) ; right ; ring.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rlt_le_trans with (1 := H2 _ Hn) ; right ; ring.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
(* * <- *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (u n) (Rplus l (pos eps))))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rminus l (pos eps)) (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt M (u n)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
  move => eps ; case: (Hl eps) => {Hl} H1 H2 ; split.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => N ; case: (H1 N) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt (Ropp (u n)) M *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (Ropp (u n)))) *)
  apply Ropp_lt_cancel ; rewrite Ropp_involutive.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rlt_le_trans with (1 := H1) ; right ; ring.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (Ropp (u n)) M *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (Ropp (u n)))) *)
  apply Ropp_lt_cancel ; rewrite Ropp_involutive.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply Rle_lt_trans with (2 := H2 _ Hn) ; right ; ring.
(* l = p_infty *)
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl (-M)) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl (-M)) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (Ropp (u n)) M *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt (u n) M)) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (Ropp (u n)))) *)
  apply Ropp_lt_cancel ; rewrite Ropp_involutive.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl.
(* l = m_infty *)
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hl (-M) N) => {Hl} n [Hn Hl].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt eps (Ropp y) *)
  by apply Ropp_lt_cancel.
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hl (-M) N) => {Hl} n [Hn Hl].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rgt (Ropp q) (IZR (Zpos xH)) *)
(* Goal: Rlt q (IZR Z0) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Ropp_lt_cancel ; by rewrite Ropp_involutive.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_infSup_seq (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq u l <-> is_inf_seq (fun m => Sup_seq (fun n => u (n + m)%nat)) l.
Proof.
  case: l => [l | | ] ;
  rewrite /is_LimSup_seq /is_inf_seq ;
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  split => Hl.
(* l \in R *)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
(* * -> *)
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: False *)
  move => N.
(* Goal: Rbar_lt (Finite M) (Sup_seq (fun n : nat => Finite (u (Init.Nat.add n N)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Sup_seq_minor_lt.
(* Goal: False *)
  case: (proj1 (Hl eps) N) => {Hl} n Hl.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (Finite (u (Init.Nat.add n N)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (n - N)%nat.
(* Goal: Rlt (v n) M *)
  rewrite MyNat.sub_add ; intuition.
(* Goal: False *)
  case: (proj2 (Hl (pos_div_2 eps))) => /= {Hl} N Hl.
(* Goal: @eq Rbar (@proj1_sig Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) (@exist Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) al Hau)) (Rbar_mult (Finite a) (@proj1_sig Rbar (fun l : Rbar => is_sup_seq u l) (@exist Rbar (fun l : Rbar => is_sup_seq u l) l Hu))) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  exists N ; rewrite /Sup_seq ; case: ex_sup_seq => un Hun ; simpl proj1_sig.
(* Goal: False *)
  case: un Hun => [un | | ] /= Hun.
(* Goal: False *)
  case: (proj2 (Hun (pos_div_2 eps))) => {Hun} /= n Hun.
(* Goal: Rlt un M *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rlt_minus_l in Hun.
(* Goal: Rlt un M *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rlt_trans with (1 := Hun).
(* Goal: Rlt (Rplus (u (Init.Nat.add n N)) (IZR (Zpos xH))) M *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rlt_minus_r.
(* Goal: Rlt (u (Init.Nat.add n N)) (Rminus (Rplus l (pos eps)) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall eps : posreal, and (forall N : nat, @ex nat (fun n : nat => and (le N n) (Rlt (Rminus l (pos eps)) (u n)))) (@ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) (Rplus l (pos eps)))) *)
(* Goal: forall (M : R) (n : nat), Rbar_lt (Finite M) (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rlt_le_trans with (1 := Hl _ (le_plus_r _ _)) ; right ; field.
(* Goal: False *)
  case: (Hun (l + eps / 2)) => {Hun} n.
(* Goal: forall _ : Rlt (Rminus M (IZR (Zpos xH))) (u (Init.Nat.add n N)), False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rle_not_lt, Rlt_le, Hl, le_plus_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
(* * <- *)
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: False *)
  move => N.
(* Goal: False *)
  move: (proj1 (Hl eps) N) => {Hl} Hl.
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Sup_seq_minor_lt in Hl.
(* Goal: False *)
  case: Hl => /= n Hl.
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (n + N)%nat ; intuition.
(* Goal: False *)
  case: (proj2 (Hl eps)) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: forall (M : R) (n : nat), Rbar_lt (Finite M) (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply (Rbar_not_le_lt (l + eps) (u n)).
(* Goal: not (Rbar_le (Finite M) (Finite (u n))) *)
  contradict Hl.
(* Goal: not (Rbar_lt (Sup_seq (fun n : nat => Finite (u (Init.Nat.add n N)))) (Finite M)) *)
  apply Rbar_le_not_lt.
(* Goal: Rbar_le (Finite M) (Sup_seq (fun n : nat => Finite (u (Init.Nat.add n N)))) *)
  apply Sup_seq_minor_le with (n - N)%nat.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite MyNat.sub_add.
(* l = p_infty *)
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hl M N) => {Hl} n Hl.
(* Goal: Rbar_lt (Finite M) (Sup_seq (fun n : nat => Finite (u (Init.Nat.add n N)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Sup_seq_minor_lt.
(* Goal: @ex nat (fun n : nat => Rbar_lt (Finite M) (Finite (u (Init.Nat.add n N)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (n - N)%nat.
(* Goal: Rlt (v n) M *)
  rewrite MyNat.sub_add ; intuition.
(* Goal: False *)
  move => M N.
(* Goal: False *)
  move: (Hl M N) => {Hl} Hl.
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Sup_seq_minor_lt in Hl.
(* Goal: False *)
  case: Hl => /= n Hl.
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun n : nat => Rbar_lt (Sup_seq (fun n0 : nat => Finite (u (Init.Nat.add n0 n)))) (Finite M)) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (n + N)%nat ; intuition.
(* l = m_infty *)
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl (M-1)) => {Hl} N Hl.
(* Goal: @eq Rbar (@proj1_sig Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) (@exist Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) al Hau)) (Rbar_mult (Finite a) (@proj1_sig Rbar (fun l : Rbar => is_sup_seq u l) (@exist Rbar (fun l : Rbar => is_sup_seq u l) l Hu))) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  exists N ; rewrite /Sup_seq ; case: ex_sup_seq => un Hun ; simpl proj1_sig.
(* Goal: False *)
  case: un Hun => [un | | ] /= Hun.
(* Goal: False *)
  case: (proj2 (Hun (mkposreal _ Rlt_0_1))) => {Hun} /= n Hun.
(* Goal: Rlt un M *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rlt_minus_l in Hun.
(* Goal: Rlt un M *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rlt_trans with (1 := Hun).
(* Goal: Rlt (Rplus (u (Init.Nat.add n N)) (IZR (Zpos xH))) M *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rlt_minus_r.
(* Goal: Rlt (u (Init.Nat.add n N)) (Rminus M (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Hl ; intuition.
(* Goal: False *)
  case: (Hun (M-1)) => {Hun} n.
(* Goal: forall _ : Rlt (Rminus M (IZR (Zpos xH))) (u (Init.Nat.add n N)), False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  apply Rle_not_lt, Rlt_le, Hl, le_plus_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl M) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (u n) M *)
  apply (Rbar_not_le_lt M (u n)).
(* Goal: not (Rbar_le (Finite M) (Finite (u n))) *)
  contradict Hl.
(* Goal: not (Rbar_lt (Sup_seq (fun n : nat => Finite (u (Init.Nat.add n N)))) (Finite M)) *)
  apply Rbar_le_not_lt.
(* Goal: Rbar_le (Finite M) (Sup_seq (fun n : nat => Finite (u (Init.Nat.add n N)))) *)
  apply Sup_seq_minor_le with (n - N)%nat.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite MyNat.sub_add.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_supInf_seq (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimInf_seq u l <-> is_sup_seq (fun m => Inf_seq (fun n => u (n + m)%nat)) l.
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -is_LimSup_opp_LimInf_seq.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite is_LimSup_infSup_seq.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -is_sup_opp_inf_seq.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rbar_opp_involutive.
  split ; apply is_sup_seq_ext => n ;
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Inf_opp_sup.
Qed.

(** Extensionality *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_seq_ext_loc (u v : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n = v n) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq u l -> is_LimSup_seq v l.
Proof.
(* Goal: False *)
  case: l => [l | | ] /= [Next Hext] Hu.
(* Goal: False *)
  move => eps.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  case: (Hu eps) => {Hu} H1 H2 ; split.
(* Goal: False *)
  move => N.
(* Goal: False *)
  case: (H1 (N + Next)%nat) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (v n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (v n) M) *)
  exists n ; rewrite -Hext ; intuition.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (N + Next)%nat => n Hn.
(* Goal: Rlt (v n) M *)
  rewrite -Hext ; intuition.
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hu M (N + Next)%nat) => {Hu} n [Hn Hu].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (v n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (v n) M) *)
  exists n ; rewrite -Hext ; intuition.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hu M) => {Hu} N Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (N + Next)%nat => n Hn.
(* Goal: Rlt (v n) M *)
  rewrite -Hext ; intuition.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_seq_ext (u v : nat -> R) (l : Rbar) :
  (forall n, u n = v n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> is_LimSup_seq u l -> is_LimSup_seq v l.
Proof.
(* Goal: False *)
  move => Hext.
(* Goal: forall _ : is_LimSup_seq u l, is_LimSup_seq v l *)
  apply is_LimSup_seq_ext_loc.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => u (Init.Nat.add n (S N)))) (Lim_seq (fun n : nat => u (S (Init.Nat.add n N)))) *)
  exists O => n _ ; by apply Hext.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_seq_ext_loc (u v : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n = v n) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimInf_seq u l -> is_LimInf_seq v l.
Proof.
(* Goal: False *)
  case => N Hext Hu.
(* Goal: is_LimInf_seq u l *)
  apply is_LimSup_opp_LimInf_seq.
(* Goal: is_LimSup_seq (fun n : nat => Ropp (v n)) (Rbar_opp l) *)
  apply is_LimSup_seq_ext_loc with (fun n => - u n).
(* Goal: @eq Rbar (Lim_seq (fun n : nat => u (Init.Nat.add n (S N)))) (Lim_seq (fun n : nat => u (S (Init.Nat.add n N)))) *)
  exists N => n Hn ; by rewrite Hext.
(* Goal: is_LimInf_seq u l *)
  by apply is_LimSup_opp_LimInf_seq.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_seq_ext (u v : nat -> R) (l : Rbar) :
  (forall n, u n = v n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> is_LimInf_seq u l -> is_LimInf_seq v l.
Proof.
(* Goal: False *)
  move => Hext.
(* Goal: forall _ : is_LimInf_seq u l, is_LimInf_seq v l *)
  apply is_LimInf_seq_ext_loc.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => u (Init.Nat.add n (S N)))) (Lim_seq (fun n : nat => u (S (Init.Nat.add n N)))) *)
  exists O => n _ ; by apply Hext.
Qed.

(** Existence *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_LimSup_seq (u : nat -> R) :
  {l : Rbar | is_LimSup_seq u l}.
Proof.
(* Goal: False *)
  case: (ex_inf_seq (fun m : nat => Sup_seq (fun n : nat => u (n + m)%nat))) => l Hl.
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  exists l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_LimSup_infSup_seq.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_LimInf_seq (u : nat -> R) :
  {l : Rbar | is_LimInf_seq u l}.
Proof.
(* Goal: False *)
  case: (ex_sup_seq (fun m : nat => Inf_seq (fun n : nat => u (n + m)%nat))) => l Hl.
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  exists l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_LimInf_supInf_seq.
Qed.

(** Functions *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition LimSup_seq (u : nat -> R) :=
  proj1_sig (ex_LimSup_seq u).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition LimInf_seq (u : nat -> R) :=
  proj1_sig (ex_LimInf_seq u).

(** Uniqueness *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_seq_unique (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq u l -> LimSup_seq u = l.
Proof.
(* Goal: False *)
  move => H.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /LimSup_seq.
(* Goal: False *)
  case: ex_LimSup_seq => lu Hu /=.
(* Goal: @eq Rbar lu l *)
  apply is_LimSup_infSup_seq in H.
(* Goal: @eq Rbar lu l *)
  apply is_LimSup_infSup_seq in Hu.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -(is_inf_seq_unique _ _ Hu).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_inf_seq_unique.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_seq_unique (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimInf_seq u l -> LimInf_seq u = l.
Proof.
(* Goal: False *)
  move => H.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /LimInf_seq.
(* Goal: False *)
  case: ex_LimInf_seq => lu Hu /=.
(* Goal: @eq Rbar lu l *)
  apply is_LimInf_supInf_seq in H.
(* Goal: @eq Rbar lu l *)
  apply is_LimInf_supInf_seq in Hu.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -(is_sup_seq_unique _ _ Hu).
(* Goal: @eq Rbar (Sup_seq (fun _ : nat => Finite (IZR Z0))) (Finite (IZR Z0)) *)
(* Goal: @eq Rbar (Finite (IZR Z0)) (Rbar_mult (Finite (IZR Z0)) (Sup_seq u)) *)
  by apply is_sup_seq_unique.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma LimSup_InfSup_seq (u : nat -> R) :
  LimSup_seq u = Inf_seq (fun m => Sup_seq (fun n => u (n + m)%nat)).
Proof.
(* Goal: @eq Rbar (LimSup_seq u) l *)
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimSup_seq_unique.
(* Goal: is_LimSup_seq u (Inf_seq (fun m : nat => Sup_seq (fun n : nat => Finite (u (Init.Nat.add n m))))) *)
  apply is_LimSup_infSup_seq.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Inf_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by case: ex_inf_seq.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma LimInf_SupInf_seq (u : nat -> R) :
  LimInf_seq u = Sup_seq (fun m => Inf_seq (fun n => u (n + m)%nat)).
Proof.
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimInf_seq_unique.
(* Goal: is_LimInf_seq u (Sup_seq (fun m : nat => Inf_seq (fun n : nat => Finite (u (Init.Nat.add n m))))) *)
  apply is_LimInf_supInf_seq.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Sup_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by case: ex_sup_seq.
Qed.

(** ** Operations and order *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_LimInf_seq_le (u : nat -> R) (ls li : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq u ls -> is_LimInf_seq u li -> Rbar_le li ls.
Proof.
(* Goal: False *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  case: ls => [ls | | ] ; case: li => [li | | ] //= Hls Hli.
  apply le_epsilon => e He ;
  set eps := pos_div_2 (mkposreal e He).
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace li with ((li - eps) + eps) by ring.
(* Goal: Rle (Rplus (Rminus li (pos eps)) (pos eps)) (Rplus ls e) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  replace (ls + e) with ((ls + eps) + eps) by (simpl ; field).
(* Goal: Rle (Rplus (Rminus li (pos eps)) (pos eps)) (Rplus (Rplus ls (pos eps)) (pos eps)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Rplus_le_compat_r, Rlt_le.
(* Goal: False *)
  case: (proj2 (Hls eps)) => {Hls} Ns Hls.
(* Goal: False *)
  case: (proj2 (Hli eps)) => {Hli} Ni Hli.
(* Goal: Rlt (Rminus li (pos eps)) (Rplus ls (pos eps)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Rlt_trans with (u (Ns + Ni)%nat).
(* Goal: Rlt (IZR Z0) (u (Init.Nat.add Ns Ni)) *)
  apply Hli ; by intuition.
(* Goal: Rlt (u (Init.Nat.add Ns Ni)) (Rplus ls (pos eps)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Hls ; by intuition.
(* Goal: False *)
  case: (proj2 (Hls (mkposreal _ Rlt_0_1))) => {Hls} /= Ns Hls.
(* Goal: False *)
  case: (Hli (ls + 1)) => {Hli} Ni Hli.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  absurd (ls + 1 < u (Ns + Ni)%nat).
(* Goal: not (Rlt (IZR Z0) (u (Init.Nat.add Ns Ni))) *)
(* Goal: Rlt (IZR Z0) (u (Init.Nat.add Ns Ni)) *)
  apply Rle_not_lt, Rlt_le, Hls ; by intuition.
(* Goal: Rlt (IZR Z0) (u (Init.Nat.add Ns Ni)) *)
  apply Hli ; by intuition.
(* Goal: False *)
  case: (proj2 (Hli (mkposreal _ Rlt_0_1))) => {Hli} /= Ni Hli.
(* Goal: False *)
  case: (Hls (li - 1)) => {Hls} Ns Hls.
(* Goal: False *)
(* Goal: False *)
  absurd (li - 1 < u (Ns + Ni)%nat).
(* Goal: not (Rlt (IZR Z0) (u (Init.Nat.add Ns Ni))) *)
(* Goal: Rlt (IZR Z0) (u (Init.Nat.add Ns Ni)) *)
  apply Rle_not_lt, Rlt_le, Hls ; by intuition.
(* Goal: Rlt (IZR Z0) (u (Init.Nat.add Ns Ni)) *)
  apply Hli ; by intuition.
(* Goal: False *)
  case: (Hli 0) => {Hli} /= Ni Hli.
(* Goal: False *)
  case: (Hls 0) => {Hls} Ns Hls.
(* Goal: False *)
  absurd (0 < u (Ns + Ni)%nat).
(* Goal: not (Rlt (IZR Z0) (u (Init.Nat.add Ns Ni))) *)
(* Goal: Rlt (IZR Z0) (u (Init.Nat.add Ns Ni)) *)
  apply Rle_not_lt, Rlt_le, Hls ; by intuition.
(* Goal: Rlt (IZR Z0) (u (Init.Nat.add Ns Ni)) *)
  apply Hli ; by intuition.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma LimSup_LimInf_seq_le (u : nat -> R) :
  Rbar_le (LimInf_seq u) (LimSup_seq u).
Proof.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /LimInf_seq ; case: ex_LimInf_seq => /= li Hli.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /LimSup_seq ; case: ex_LimSup_seq => /= ls Hls.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_LimSup_LimInf_seq_le with u.
Qed.

(** Constant *)

Lemma is_LimSup_seq_const (a : R) :
  is_LimSup_seq (fun _ => a) a.
Proof.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  intros eps ; split.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  intros N ; exists N ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_refl.
(* Goal: Rlt (Rminus a (pos eps)) a *)
  apply Rminus_lt_0 ; ring_simplify.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply eps.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists O => _ _.
(* Goal: Rlt (Rminus a (pos eps)) a *)
  apply Rminus_lt_0 ; ring_simplify.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply eps.
Qed.
Lemma LimSup_seq_const (a : R) :
  LimSup_seq (fun _ => a) = a.
Proof.
(* Goal: @eq Rbar (LimSup_seq u) l *)
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimSup_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_LimSup_seq_const.
Qed.

Lemma is_LimInf_seq_const (a : R) :
  is_LimInf_seq (fun _ => a) a.
Proof.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  intros eps ; split.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  intros N ; exists N ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_refl.
(* Goal: Rlt (Rminus a (pos eps)) a *)
  apply Rminus_lt_0 ; ring_simplify.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply eps.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists O => _ _.
(* Goal: Rlt (Rminus a (pos eps)) a *)
  apply Rminus_lt_0 ; ring_simplify.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply eps.
Qed.
Lemma LimInf_seq_const (a : R) :
  LimInf_seq (fun _ => a) = a.
Proof.
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimInf_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_LimInf_seq_const.
Qed.

(** Opposite *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma LimSup_seq_opp (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  LimSup_seq (fun n => - u n) = Rbar_opp (LimInf_seq u).
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite LimSup_InfSup_seq LimInf_SupInf_seq.
(* Goal: @eq Rbar (Sup_seq (fun m : nat => Inf_seq (fun n : nat => Finite (Ropp (u (Init.Nat.add n m)))))) (Rbar_opp (Inf_seq (fun m : nat => Sup_seq (fun n : nat => Finite (u (Init.Nat.add n m)))))) *)
  rewrite Inf_opp_sup ; apply f_equal, Sup_seq_ext => m.
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite Inf_opp_sup ; by apply f_equal, Sup_seq_ext => n.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma LimInf_seq_opp (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  LimInf_seq (fun n => - u n) = Rbar_opp (LimSup_seq u).
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite LimSup_InfSup_seq LimInf_SupInf_seq.
(* Goal: @eq Rbar (Sup_seq (fun m : nat => Inf_seq (fun n : nat => Finite (Ropp (u (Init.Nat.add n m)))))) (Rbar_opp (Inf_seq (fun m : nat => Sup_seq (fun n : nat => Finite (u (Init.Nat.add n m)))))) *)
  rewrite Sup_opp_inf ; apply f_equal, Inf_seq_ext => m.
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite Sup_opp_inf ; by apply f_equal, Inf_seq_ext => n.
Qed.

(** Rbar_le *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma LimSup_le (u v : nat -> R) :
  eventually (fun n => u n <= v n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> Rbar_le (LimSup_seq u) (LimSup_seq v).
Proof.
  intros (N,H).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /LimSup_seq.
  case: ex_LimSup_seq ; case => [lu | | ] //= Hlu ;
  case: ex_LimSup_seq ; case => [lv | | ] //= Hlv.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Rnot_lt_le => Hl.
  apply Rminus_lt_0 in Hl.
(* Goal: False *)
  case: (Hlv (pos_div_2 (mkposreal _ Hl))) => {Hlv} /= _ [n Hlv].
(* Goal: False *)
  case: (proj1 (Hlu (pos_div_2 (mkposreal _ Hl))) (N + n)%nat) => {Hlu} m /= [Hm Hlu].
(* Goal: False *)
  move: (H _ (le_trans _ _ _ (le_plus_l _ _) Hm)).
  apply Rlt_not_le.
  eapply Rlt_trans, Hlu.
  eapply Rlt_le_trans.
  eapply Hlv, le_trans, Hm.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.
  apply Req_le ; field.

(* Goal: False *)
  case: (Hlv (lu - 1)) => {Hlv} n Hlv.
(* Goal: False *)
  case: (proj1 (Hlu (mkposreal _ Rlt_0_1)) (N + n)%nat) => {Hlu} m /= [Hm Hlu].
(* Goal: False *)
  move: (H _ (le_trans _ _ _ (le_plus_l _ _) Hm)).
  apply Rlt_not_le.
  eapply Rlt_trans, Hlu.
  eapply Hlv, le_trans, Hm.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.

(* Goal: False *)
  case: (Hlv (mkposreal _ Rlt_0_1)) => {Hlv} /= _ [n Hlv].
(* Goal: False *)
  case: (Hlu (lv + 1) (N + n)%nat) => {Hlu} /= m [Hm Hlu].
(* Goal: False *)
  move: (H _ (le_trans _ _ _ (le_plus_l _ _) Hm)).
  apply Rlt_not_le.
  eapply Rlt_trans, Hlu.
  eapply Hlv, le_trans, Hm.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.

(* Goal: False *)
  case: (Hlv 0) => {Hlv} n Hlv.
(* Goal: False *)
  case: (Hlu 0 (N + n)%nat) => {Hlu} m [Hm Hlu].
(* Goal: False *)
  move: (H _ (le_trans _ _ _ (le_plus_l _ _) Hm)).
  apply Rlt_not_le.
  eapply Rlt_trans, Hlu.
  eapply Hlv, le_trans, Hm.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma LimInf_le (u v : nat -> R) :
  eventually (fun n => u n <= v n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> Rbar_le (LimInf_seq u) (LimInf_seq v).
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: Rbar_le (LimInf_seq u) (LimInf_seq v) *)
  apply Rbar_opp_le.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -!LimSup_seq_opp.
(* Goal: Rbar_le (LimSup_seq (fun n : nat => Ropp (v n))) (LimSup_seq (fun n : nat => Ropp (u n))) *)
  apply LimSup_le.
(* Goal: eventually (fun n : nat => Rle (Ropp (v n)) (Ropp (u n))) *)
  move: H ; apply filter_imp => n.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Ropp_le_contravar.
Qed.

(** Scalar multplication *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_seq_scal_pos (a : R) (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (0 < a) -> is_LimSup_seq u l ->
    is_LimSup_seq (fun n => a * u n) (Rbar_mult a l).
Proof.
(* Goal: False *)
  case: l => [l | | ] /= Ha Hu.
(* Goal: False *)
  move => eps.
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff He : 0 < eps / a.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  case: (Hu (mkposreal _ He)) => {Hu} /= H1 H2 ; split.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => N ; case: (H1 N) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt M (Rmult a (u n)) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  rewrite (Rmult_comm _ (u n)) ; apply Rlt_div_l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt (Rdiv (Rminus (Rmult a l) (pos eps)) a) (u n) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rmult a (u n)) (Rplus (Rmult a l) (pos eps))) *)
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) a) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar p_infty else @None Rbar | right n => @Some Rbar m_infty end with | Some z => z | None => Finite (IZR Z0) end *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  apply Rle_lt_trans with (2 := H1) ; right ; field ; by apply Rgt_not_eq.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (Rmult a (u n)) M *)
  rewrite (Rmult_comm _ (u n)) ; apply Rlt_div_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt (u n) (Rdiv (Rplus (Rmult a l) (pos eps)) a) *)
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) a) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar p_infty else @None Rbar | right n => @Some Rbar m_infty end with | Some z => z | None => Finite (IZR Z0) end *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  apply Rlt_le_trans with (1 := H2 _ Hn) ; right ; field ; by apply Rgt_not_eq.
(* Goal: Rlt (IZR Z0) (Rdiv (pos eps) a) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar p_infty else @None Rbar | right n => @Some Rbar m_infty end with | Some z => z | None => Finite (IZR Z0) end *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  apply Rdiv_lt_0_compat ; [ by case eps | by [] ].
(* Goal: False *)
  case: Rle_dec (Rlt_le _ _ Ha) => // H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rlt_not_eq _ _ Ha) => {H} // _ _.
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hu (M / a) N) => {Hu} n [Hn Hu].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (Rmult a (u n)))) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  exists n ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt M (Rmult a (u n)) *)
(* Goal: is_LimSup_seq (fun n : nat => Rmult a (u n)) match match Rle_dec (IZR Z0) a with | left H => if Rle_lt_or_eq_dec (IZR Z0) a H then @Some Rbar m_infty else @None Rbar | right n => @Some Rbar p_infty end with | Some z => z | None => Finite (IZR Z0) end *)
  rewrite (Rmult_comm _ (u n)) ; apply Rlt_div_l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: False *)
  case: Rle_dec (Rlt_le _ _ Ha) => // H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rlt_not_eq _ _ Ha) => {H} // _ _.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hu (M / a)) => {Hu} N Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (Rmult a (u n)) M *)
  rewrite (Rmult_comm _ (u n)) ; apply Rlt_div_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  by apply Hu.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_seq_scal_pos (a : R) (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (0 < a) -> is_LimInf_seq u l ->
    is_LimInf_seq (fun n => a * u n) (Rbar_mult a l).
Proof.
(* Goal: False *)
  move => Ha Hu.
(* Goal: is_LimInf_seq (fun n : nat => Rmult a (u n)) (Rbar_mult (Finite a) l) *)
  apply is_LimSup_opp_LimInf_seq in Hu.
(* Goal: is_LimInf_seq u l *)
  apply is_LimSup_opp_LimInf_seq.
(* Goal: is_LimSup_seq (fun n : nat => Ropp (Rmult a (u n))) (Rbar_opp (Rbar_mult (Finite a) l)) *)
  replace (Rbar_opp (Rbar_mult a l)) with (Rbar_mult a (Rbar_opp l)).
(* Goal: is_LimSup_seq (fun n : nat => Ropp (Rmult a (u n))) (Rbar_mult (Finite a) (Rbar_opp l)) *)
(* Goal: @eq Rbar (Rbar_mult (Finite a) (Rbar_opp l)) (Rbar_opp (Rbar_mult (Finite a) l)) *)
  apply is_LimSup_seq_ext with (fun n => a * - u n).
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  move => n ; ring.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_LimSup_seq_scal_pos.
(* Goal: False *)
  case: (l) => [x | | ] /=.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  apply f_equal ; ring.
(* Goal: False *)
  case: Rle_dec (Rlt_le _ _ Ha) => // H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rlt_not_eq _ _ Ha) => // H _.
(* Goal: False *)
  case: Rle_dec (Rlt_le _ _ Ha) => // H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rlt_not_eq _ _ Ha) => // H _.
Qed.

(** Index shifting *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_seq_ind_1 (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq u l <->
    is_LimSup_seq (fun n => u (S n)) l.
Proof.
(* Goal: iff (is_LimSup_seq u l) (is_LimSup_seq (fun n : nat => u (S n)) l) *)
  case: l => [l | | ] ; split => //= Hu.
(* l \in R *)
(* Goal: False *)
  move => eps.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  case: (Hu eps) => {Hu} H1 H2 ; split.
(* Goal: False *)
  move => N.
(* Goal: False *)
  case: (H1 (S N)) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u (S n)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u (S n)) M) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (pred n).
(* Goal: False *)
  case: (n) Hn H1 => /= [ | m] Hm H1.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_O in Hm.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_S_n.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H1.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (u n) (Rplus l (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: Rlt (Rplus l (Rdiv (pos eps) (IZR (Zpos (xO xH))))) (Rplus l (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
  apply H2 ; intuition.
(* Goal: False *)
  move => eps.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  case: (Hu eps) => {Hu} H1 H2 ; split.
(* Goal: False *)
  move => N.
(* Goal: False *)
  case: (H1 N) => {H1} n [Hn H1].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u (S n)) M) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (S n) ; intuition.
(* Goal: False *)
  case: H2 => N H2.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (S N) => n Hn.
(* Goal: False *)
  case: (n) Hn => /= [ | m] Hm.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_O in Hm.
(* Goal: Rlt (u n) (Rplus l (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: Rlt (Rplus l (Rdiv (pos eps) (IZR (Zpos (xO xH))))) (Rplus l (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
  apply H2 ; intuition.
(* l = p_infty *)
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hu M (S N)) => {Hu} n [Hn Hu].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u (S n)))) *)
(* Goal: forall (M : R) (N : nat), @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u (S n)) M) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (pred n).
(* Goal: False *)
  case: (n) Hn Hu => /= [ | m] Hm Hu.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_O in Hm.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_S_n.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  by apply Hu.
(* Goal: False *)
  move => M N.
(* Goal: False *)
  case: (Hu M N) => {Hu} n [Hn Hu].
(* Goal: @ex nat (fun n : nat => and (le N n) (Rlt M (u n))) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u (S n)) M) *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  exists (S n) ; intuition.
(* l = m_infty *)
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hu M) => {Hu} N Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (u (S m)) M *)
  apply Hu ; intuition.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hu M) => {Hu} N Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (S N) => n Hn.
(* Goal: False *)
  case: (n) Hn => /= [ | m] Hm.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_O in Hm.
(* Goal: Rlt (u (S m)) M *)
  apply Hu ; intuition.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_seq_ind_1 (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimInf_seq u l <->
    is_LimInf_seq (fun n => u (S n)) l.
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -?is_LimSup_opp_LimInf_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_LimSup_seq_ind_1.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_seq_ind_k (u : nat -> R) (k : nat) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq u l <->
    is_LimSup_seq (fun n => u (n + k)%nat) l.
Proof.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: k u => [ | k IH] /= u.
(* Goal: iff (is_LimSup_seq (fun n : nat => u (S (Init.Nat.add n k))) l) (is_LimSup_seq (fun n : nat => u (Init.Nat.add n (S k))) l) *)
  split ; apply is_LimSup_seq_ext => n ; by rewrite -plus_n_O.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite is_LimSup_seq_ind_1.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite (IH (fun n => u (S n))).
(* Goal: iff (is_LimSup_seq (fun n : nat => u (S (Init.Nat.add n k))) l) (is_LimSup_seq (fun n : nat => u (Init.Nat.add n (S k))) l) *)
  split ; apply is_LimSup_seq_ext => n ; by rewrite plus_n_Sm.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimInf_seq_ind_k (u : nat -> R) (k : nat) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimInf_seq u l <->
    is_LimInf_seq (fun n => u (n + k)%nat) l.
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite -?is_LimSup_opp_LimInf_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply (is_LimSup_seq_ind_k (fun n => - u n)).
Qed.

(** * Limit of sequences *)

(** ** Definition *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition is_lim_seq (u : nat -> R) (l : Rbar) :=
  filterlim u eventually (Rbar_locally l).

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition is_lim_seq' (u : nat -> R) (l : Rbar) :=
  match l with
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    | 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.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition ex_lim_seq (u : nat -> R) :=
  exists l, is_lim_seq u l.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition ex_finite_lim_seq (u : nat -> R) :=
  exists l : R, is_lim_seq u l.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
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 |}.

Lemma is_lim_seq_spec :
  forall u l,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq' u l <-> is_lim_seq u l.
Proof.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
destruct l as [l| |] ; split.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- intros H P [eps LP].
(* Goal: @filtermap nat R u eventually P *)
(* Goal: forall _ : is_lim_seq u (Finite l), is_lim_seq' u (Finite l) *)
(* Goal: forall _ : is_lim_seq' u p_infty, is_lim_seq u p_infty *)
(* Goal: forall _ : is_lim_seq u p_infty, is_lim_seq' u p_infty *)
(* Goal: forall _ : is_lim_seq' u m_infty, is_lim_seq u m_infty *)
(* Goal: forall _ : is_lim_seq u m_infty, is_lim_seq' u m_infty *)
  destruct (H eps) as [N HN].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: eventually (fun n : nat => Rlt (u n) M) *)
  apply LP.
(* Goal: Rlt (u n) M *)
(* Goal: forall _ : is_lim_seq u m_infty, is_lim_seq' u m_infty *)
  now apply HN.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- intros LP eps.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  specialize (LP (fun y => Rabs (y - l) < eps)).
(* Goal: eventually (fun n : nat => Rlt (u n) M) *)
  apply LP.
(* Goal: Rbar_locally (Finite l) (fun y : R => Rlt (Rabs (Rminus y l)) (pos eps)) *)
(* Goal: @filtermap T R g F P *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  now exists eps.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- intros H P [M LP].
(* Goal: @filtermap nat R u eventually P *)
(* Goal: forall _ : is_lim_seq u m_infty, is_lim_seq' u m_infty *)
  destruct (H M) as [N HN].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: eventually (fun n : nat => Rlt (u n) M) *)
  apply LP.
(* Goal: Rlt (u n) M *)
(* Goal: forall _ : is_lim_seq u m_infty, is_lim_seq' u m_infty *)
  now apply HN.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- intros LP M.
(* Goal: eventually (fun n : nat => Rlt M (u n)) *)
(* Goal: forall _ : is_lim_seq' u m_infty, is_lim_seq u m_infty *)
(* Goal: forall _ : is_lim_seq u m_infty, is_lim_seq' u m_infty *)
  specialize (LP (fun y => M < y)).
(* Goal: eventually (fun n : nat => Rlt (u n) M) *)
  apply LP.
(* Goal: Rbar_locally m_infty ineq *)
(* Goal: @filtermap T R g F P *)
  now exists M.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- intros H P [M LP].
(* Goal: @filtermap nat R u eventually P *)
(* Goal: forall _ : is_lim_seq u m_infty, is_lim_seq' u m_infty *)
  destruct (H M) as [N HN].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: eventually (fun n : nat => Rlt (u n) M) *)
  apply LP.
(* Goal: Rlt (u n) M *)
(* Goal: forall _ : is_lim_seq u m_infty, is_lim_seq' u m_infty *)
  now apply HN.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- intros LP M.
(* Goal: eventually (fun n : nat => Rlt (u n) M) *)
  specialize (LP (fun y => y < M)).
(* Goal: eventually (fun n : nat => Rlt (u n) M) *)
  apply LP.
(* Goal: Rbar_locally m_infty ineq *)
(* Goal: @filtermap T R g F P *)
  now exists M.
Qed.

(** Equivalence with standard library Reals *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_Reals (u : nat -> R) (l : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l <-> Un_cv u l.
Proof.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  split => Hl.
(* Goal: False *)
  move => e He.
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : ge n N), Rlt (R_dist (u n) l) e) *)
(* Goal: is_lim_seq u (Finite l) *)
  apply (Hl (fun y => R_dist y l < e)).
(* Goal: Rbar_locally (Finite l) (fun y : R => Rlt (R_dist y l) e) *)
(* Goal: is_lim_seq u (Finite l) *)
  now exists (mkposreal _ He).
(* Goal: is_lim_seq u (Finite l) *)
  unfold is_lim_seq.
(* Goal: @filterlim nat R u eventually (Rbar_locally (Finite l)) *)
  change (Rbar_locally l) with (locally l).
(* Goal: @filterlim nat R u eventually (@locally R_UniformSpace l) *)
  apply (filterlim_locally u l).
(* Goal: False *)
  case => e He.
(* Goal: False *)
  case: (Hl e He) => {Hl} /= N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply (Hl n Hn).
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_p_infty_Reals (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u p_infty <-> cv_infty u.
Proof.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  split => Hl.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl (fun x => M < x)) => {Hl} [ | N Hl].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists M.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists N.
(* Goal: False *)
  move => P [M HP].
  eapply filter_imp.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply HP.
(* Goal: False *)
  case: (Hl M) => {Hl} N HN.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists N.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_LimSup_seq (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l -> is_LimSup_seq u l.
Proof.
(* Goal: False *)
  move /is_lim_seq_spec.
(* Goal: False *)
  case: l => [l | | ] /= Hu.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  move => eps ; case: (Hu eps) => {Hu} N Hu ; split.
(* Goal: False *)
  move => N0.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  exists (N + N0)%nat ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rabs_lt_between', Hu, le_plus_l.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rabs_lt_between', Hu.
(* Goal: False *)
  move => M N0.
(* Goal: False *)
  case: (Hu M) => {Hu} N Hu.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  exists (N + N0)%nat ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hu, le_plus_l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_LimInf_seq (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l -> is_LimInf_seq u l.
Proof.
(* Goal: False *)
  move /is_lim_seq_spec.
(* Goal: False *)
  case: l => [l | | ] /= Hu.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  move => eps ; case: (Hu eps) => {Hu} N Hu ; split.
(* Goal: False *)
  move => N0.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  exists (N + N0)%nat ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rabs_lt_between', Hu, le_plus_l.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rabs_lt_between', Hu.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: False *)
  move => M N0.
(* Goal: False *)
  case: (Hu M) => {Hu} N Hu.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  exists (N + N0)%nat ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_plus_r.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hu, le_plus_l.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_LimSup_LimInf_lim_seq (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_LimSup_seq u l -> is_LimInf_seq u l -> is_lim_seq u l.
Proof.
(* Goal: forall (_ : is_LimSup_seq u l) (_ : is_LimInf_seq u l), is_lim_seq u l *)
  case: l => [l | | ] /= Hs Hi ; apply is_lim_seq_spec.
(* Goal: False *)
  move => eps.
(* Goal: False *)
  case: (proj2 (Hs eps)) => {Hs} Ns Hs.
(* Goal: False *)
  case: (proj2 (Hi eps)) => {Hi} Ni Hi.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (Ns + Ni)%nat => n Hn.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between' ; split.
(* Goal: Rlt (Rminus l (pos eps)) (u n) *)
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: is_lim_seq' u p_infty *)
(* Goal: is_lim_seq' u m_infty *)
  apply Hi ; intuition.
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: is_lim_seq' u p_infty *)
(* Goal: is_lim_seq' u m_infty *)
  apply Hs ; intuition.
(* Goal: is_lim_seq' u p_infty *)
(* Goal: is_lim_seq' u m_infty *)
  exact Hi.
(* Goal: is_lim_seq' u m_infty *)
  exact Hs.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_LimSup_LimInf_seq (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u <-> LimSup_seq u = LimInf_seq u.
Proof.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  split => Hl.
(* Goal: False *)
  case: Hl => l Hu.
(* Goal: @eq Rbar (LimSup_seq u) (LimInf_seq u) *)
(* Goal: ex_lim_seq u *)
  transitivity l.
(* Goal: @eq Rbar (LimSup_seq u) l *)
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimSup_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimSup_seq.
(* Goal: @eq Rbar l (LimInf_seq u) *)
(* Goal: ex_lim_seq u *)
  apply sym_eq, is_LimInf_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimInf_seq.
(* Goal: ex_finite_lim_seq u *)
  exists (LimSup_seq u).
(* Goal: is_lim_seq u l *)
  apply is_LimSup_LimInf_lim_seq.
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite /LimSup_seq ; by case: ex_LimSup_seq.
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite Hl /LimInf_seq ; by case: ex_LimInf_seq.
Qed.

(** Extensionality *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_ext_loc (u v : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n = v n) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l -> is_lim_seq v l.
Proof.
(* Goal: forall (_ : eventually (fun n : nat => @eq R (u n) (v n))) (_ : is_lim_seq u l), is_lim_seq v l *)
  apply filterlim_ext_loc.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_ext_loc (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n = v n) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v.
Proof.
(* Goal: False *)
  move => H [l H0].
(* Goal: ex_lim_seq v *)
  exists l ; by apply is_lim_seq_ext_loc with u.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_ext_loc (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n = v n) ->
  Lim_seq u = Lim_seq v.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Lim_seq.
(* Goal: @eq Rbar (Rbar_div_pos (Rbar_plus (LimSup_seq u) (LimInf_seq u)) (mkposreal (IZR (Zpos (xO xH))) Rlt_R0_R2)) (Rbar_div_pos (Rbar_plus l l) (mkposreal (IZR (Zpos (xO xH))) Rlt_R0_R2)) *)
  apply (f_equal (fun x => Rbar_div_pos x _)).
(* Goal: @eq Rbar (Rbar_plus (LimSup_seq u) (LimInf_seq u)) (Rbar_plus (LimSup_seq v) (LimInf_seq v)) *)
  apply f_equal2 ; apply sym_eq.
(* Goal: @eq Rbar (LimSup_seq u) l *)
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimSup_seq_unique.
(* Goal: is_LimSup_seq v (LimSup_seq u) *)
(* Goal: @eq Rbar (LimInf_seq v) (LimInf_seq u) *)
  apply is_LimSup_seq_ext_loc with u.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite /LimSup_seq ; by case: ex_LimSup_seq.
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimInf_seq_unique.
(* Goal: is_LimInf_seq v (LimInf_seq u) *)
  apply is_LimInf_seq_ext_loc with u.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite /LimInf_seq ; by case: ex_LimInf_seq.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_ext (u v : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, u n = v n) -> is_lim_seq u l -> is_lim_seq v l.
Proof.
(* Goal: False *)
  move => Hext.
(* Goal: forall _ : is_lim_seq u l, is_lim_seq v l *)
  apply is_lim_seq_ext_loc.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists O.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_ext (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, u n = v n) -> ex_lim_seq u -> ex_lim_seq v.
Proof.
(* Goal: False *)
  move => H [l H0].
(* Goal: ex_lim_seq v *)
  exists l ; by apply is_lim_seq_ext with u.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_ext (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, u n = v n) ->
  Lim_seq u = Lim_seq v.
Proof.
(* Goal: False *)
  move => Hext.
(* Goal: @eq Rbar (Lim_seq u) (Lim_seq v) *)
  apply Lim_seq_ext_loc.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by exists O.
Qed.

(** Unicity *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_unique (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l -> Lim_seq u = l.
Proof.
(* Goal: False *)
  move => Hu.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Lim_seq.
  replace l with (Rbar_div_pos (Rbar_plus l l) {| pos := 2; cond_pos := Rlt_R0_R2 |})
    by (case: (l) => [x | | ] //= ; apply f_equal ; field).
(* Goal: @eq Rbar (Rbar_div_pos (Rbar_plus (LimSup_seq u) (LimInf_seq u)) (mkposreal (IZR (Zpos (xO xH))) Rlt_R0_R2)) (Rbar_div_pos (Rbar_plus l l) (mkposreal (IZR (Zpos (xO xH))) Rlt_R0_R2)) *)
  apply (f_equal (fun x => Rbar_div_pos x _)).
(* Goal: @eq Rbar (Rbar_plus (LimSup_seq u) (LimInf_seq u)) (Rbar_plus l l) *)
  apply f_equal2.
(* Goal: @eq Rbar (LimSup_seq u) l *)
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimSup_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimSup_seq.
(* Goal: @eq Rbar (LimInf_seq u) l *)
  apply is_LimInf_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimInf_seq.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_correct (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> is_lim_seq u (Lim_seq u).
Proof.
(* Goal: forall _ : ex_finite_lim_seq u, is_lim_seq u (Finite (real (Lim_seq u))) *)
  intros (l,H).
(* Goal: is_lim_seq u (Lim_seq u) *)
  cut (Lim_seq u = l).
(* Goal: forall _ : @eq R (real (Lim_seq u)) l, is_lim_seq u (Finite (real (Lim_seq u))) *)
(* Goal: @eq R (real (Lim_seq u)) l *)
    intros ; rewrite H0 ; apply H.
(* Goal: @eq Rbar (Lim_seq u) l *)
  apply is_lim_seq_unique, H.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_correct' (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_finite_lim_seq u -> is_lim_seq u (real (Lim_seq u)).
Proof.
(* Goal: forall _ : ex_finite_lim_seq u, is_lim_seq u (Finite (real (Lim_seq u))) *)
  intros (l,H).
(* Goal: is_lim_seq u (Finite (real (Lim_seq u))) *)
  cut (real (Lim_seq u) = l).
(* Goal: forall _ : @eq R (real (Lim_seq u)) l, is_lim_seq u (Finite (real (Lim_seq u))) *)
(* Goal: @eq R (real (Lim_seq u)) l *)
    intros ; rewrite H0 ; apply H.
(* Goal: @eq R (real (Lim_seq u)) l *)
  replace l with (real l) by auto.
(* Goal: @eq R (real (Lim_seq u)) (real (Finite l)) *)
  apply f_equal, is_lim_seq_unique, H.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_finite_lim_seq_correct (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_finite_lim_seq u <-> ex_lim_seq u /\ is_finite (Lim_seq u).
Proof.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: False *)
  case => l Hl.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  by exists l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite (is_lim_seq_unique _ _ Hl).
(* Goal: forall _ : and (ex_lim_seq u) (is_finite (Lim_seq u)), ex_finite_lim_seq u *)
  case ; case => l Hl H.
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  exists l.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(is_lim_seq_unique _ _ Hl).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite H (is_lim_seq_unique _ _ Hl).
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_dec (u : nat -> R) :
  {ex_lim_seq u} + {~ex_lim_seq u}.
Proof.
(* Goal: False *)
  case: (Rbar_eq_dec (LimSup_seq u) (LimInf_seq u)) => H.
(* Goal: sumbool (ex_finite_lim_seq u) (not (ex_finite_lim_seq u)) *)
(* Goal: sumbool (ex_finite_lim_seq u) (not (ex_finite_lim_seq u)) *)
(* Goal: sumbool (ex_finite_lim_seq u) (not (ex_finite_lim_seq u)) *)
(* Goal: sumbool (ex_finite_lim_seq u) (not (ex_finite_lim_seq u)) *)
  left ; by apply ex_lim_LimSup_LimInf_seq.
(* Goal: sumbool (ex_lim_seq u) (not (ex_lim_seq u)) *)
  right ; contradict H ; by apply ex_lim_LimSup_LimInf_seq.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_finite_lim_seq_dec (u : nat -> R) :
  {ex_finite_lim_seq u} + {~ ex_finite_lim_seq u}.
Proof.
(* Goal: False *)
  case: (ex_lim_seq_dec u) => H.
(* Goal: ex_lim_seq (fun n : nat => Rdiv (u n) (v n)) *)
  apply Lim_seq_correct in H.
(* Goal: False *)
  case: (Lim_seq u) H => [l | | ] H.
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  left ; by exists l.
(* Goal: sumbool (ex_finite_lim_seq u) (not (ex_finite_lim_seq u)) *)
  right ; rewrite ex_finite_lim_seq_correct.
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite (is_lim_seq_unique _ _ H) /is_finite //= ; by case.
(* Goal: sumbool (ex_finite_lim_seq u) (not (ex_finite_lim_seq u)) *)
  right ; rewrite ex_finite_lim_seq_correct.
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite (is_lim_seq_unique _ _ H) /is_finite //= ; by case.
(* Goal: sumbool (ex_finite_lim_seq u) (not (ex_finite_lim_seq u)) *)
  right ; rewrite ex_finite_lim_seq_correct.
(* Goal: not (and (ex_lim_seq u) (is_finite (Lim_seq u))) *)
  contradict H ; by apply H.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Definition ex_lim_seq_cauchy (u : nat -> R) :=
  forall eps : posreal, exists N : nat, forall n m,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    (N <= n)%nat -> (N <= m)%nat -> Rabs (u n - u m) < eps.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_cauchy_corr (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (ex_finite_lim_seq u) <-> ex_lim_seq_cauchy u.
Proof.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  split => Hcv.

(* Goal: ex_lim_seq_cauchy u *)
(* Goal: ex_finite_lim_seq u *)
  apply Lim_seq_correct' in Hcv.
(* Goal: ex_lim_seq_cauchy u *)
(* Goal: ex_finite_lim_seq u *)
  apply is_lim_seq_spec in Hcv.
(* Goal: False *)
  move => eps.
(* Goal: False *)
  case: (Hcv (pos_div_2 eps)) => /= {Hcv} N H.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n m Hn Hm.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace (u n - u m) with ((u n - (real (Lim_seq u))) - (u m - (real (Lim_seq u)))) by ring.
(* Goal: Rlt (Rabs (Rminus (Rminus (u n) (real (Lim_seq u))) (Rminus (u m) (real (Lim_seq u))))) (pos eps) *)
(* Goal: ex_finite_lim_seq u *)
  apply Rle_lt_trans with (1 := Rabs_triang _ _).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_Ropp (double_var eps).
(* Goal: Rlt (Rplus (Rabs (Rminus (u n) (real (Lim_seq u)))) (Rabs (Rminus (u m) (real (Lim_seq u))))) (Rplus (Rdiv (pos eps) (IZR (Zpos (xO xH)))) (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: ex_finite_lim_seq u *)
  apply Rplus_lt_compat ; by apply H.

(* Goal: ex_finite_lim_seq u *)
  exists (LimSup_seq u).
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: is_lim_seq' u (Finite (Ropp l)) *)
  intros eps.
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (real (LimSup_seq u)))) (pos eps)) *)
  rewrite /LimSup_seq ; case: ex_LimSup_seq => /= l Hl.
(* Goal: False *)
  case: (Hcv (pos_div_2 eps)) => {Hcv} /= Ncv Hcv.
(* Goal: False *)
  case: l Hl => [l | | ] /= Hl.
(* Goal: False *)
  case: (Hl (pos_div_2 eps)) => {Hl} /= H1 [Nl H2].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (Ncv + Nl)%nat => n Hn.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between' ; split.
(* Goal: False *)
  case: (H1 Ncv) => {H1} m [Hm H1].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  replace (l - eps) with ((l - eps / 2) - eps / 2) by field.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  apply Rlt_trans with (u m - eps / 2).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rplus_lt_compat_r.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between'.
(* Goal: Rlt (Rabs (Rminus (u n) (u m))) (Rdiv (pos eps) (IZR (Zpos (xO xH)))) *)
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
  apply Hcv ; intuition.
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
  apply Rlt_trans with (l + eps / 2).
(* Goal: Rlt (u n) (Rplus l (Rdiv (pos eps) (IZR (Zpos (xO xH))))) *)
(* Goal: Rlt (Rplus l (Rdiv (pos eps) (IZR (Zpos (xO xH))))) (Rplus l (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
  apply H2 ; intuition.
(* Goal: Rlt (Rplus l (Rdiv (pos eps) (IZR (Zpos (xO xH))))) (Rplus l (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
  apply Rminus_lt_0 ; field_simplify ; rewrite ?Rdiv_1.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_pos_div_2.
  move: (fun n Hn => proj2 (proj1 (Rabs_lt_between' _ _ _) (Hcv n Ncv Hn (le_refl _))))
  => {Hcv} Hcv.
(* Goal: False *)
  case: (Hl (u Ncv + eps / 2) Ncv) => {Hl} n [Hn Hl].
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
  contradict Hl ; apply Rle_not_lt, Rlt_le.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hcv.
  move: (fun n Hn => proj1 (proj1 (Rabs_lt_between' _ _ _) (Hcv n Ncv Hn (le_refl _))))
  => {Hcv} Hcv.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (Hl (u Ncv - eps / 2)) => {Hl} N Hl.
(* Goal: False *)
  move: (Hcv _ (le_plus_l Ncv N)) => H.
(* Goal: forall _ : Rlt (Rminus M (IZR (Zpos xH))) (u (Init.Nat.add n N)), False *)
(* Goal: True *)
(* Goal: forall M : R, @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (u n) M) *)
  contradict H ; apply Rle_not_lt, Rlt_le, Hl, le_plus_r.
Qed.

(** ** Arithmetic operations and order *)

(** Identity *)

Lemma is_lim_seq_INR :
  is_lim_seq INR p_infty.
Proof.
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: False *)
  move => M.
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff Hm : 0 <= Rmax 0 M.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (S (nfloor (Rmax 0 M) Hm)) => n Hn.
(* Goal: Rlt M (INR n) *)
(* Goal: Rle (IZR Z0) (Rmax (IZR Z0) M) *)
  apply Rlt_le_trans with (2 := le_INR _ _ Hn).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /nfloor S_INR.
(* Goal: False *)
  case: nfloor_ex => {n Hn} /= n Hn.
(* Goal: Rlt M (Rplus (INR n) (IZR (Zpos xH))) *)
(* Goal: Rle (IZR Z0) (Rmax (IZR Z0) M) *)
  apply Rle_lt_trans with (1 := Rmax_r 0 M).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hn.
(* Goal: Rle (IZR Z0) (Rmax (IZR Z0) M) *)
  apply Rmax_l.
Qed.
Lemma ex_lim_seq_INR :
  ex_lim_seq INR.
Proof.
(* Goal: ex_lim_seq INR *)
  exists p_infty ; by apply is_lim_seq_INR.
Qed.
Lemma Lim_seq_INR :
  Lim_seq INR = p_infty.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq INR p_infty *)
  apply is_lim_seq_INR.
Qed.

(** Constants *)

Lemma is_lim_seq_const (a : R) :
  is_lim_seq (fun n => a) a.
Proof.
(* Goal: is_lim_seq (fun _ : nat => a) (Finite a) *)
apply filterlim_const.
Qed.
Lemma ex_lim_seq_const (a : R) :
  ex_lim_seq (fun n => a).
Proof.
(* Goal: ex_lim_seq (fun _ : nat => a) *)
  exists a ; by apply is_lim_seq_const.
Qed.
Lemma Lim_seq_const (a : R) :
  Lim_seq (fun n => a) = a.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun _ : nat => a) (Finite a) *)
  apply is_lim_seq_const.
Qed.

(** Subsequences *)

Lemma eventually_subseq_loc :
  forall phi,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => (phi n < phi (S n))%nat) ->
  filterlim phi eventually eventually.
Proof.
(* Goal: forall (phi : forall _ : nat, nat) (_ : eventually (fun n : nat => lt (phi n) (phi (S n)))), @filterlim nat nat phi eventually eventually *)
intros phi [M Hphi] P [N HP].
(* Goal: @filtermap nat nat phi eventually P *)
exists (N+M)%nat.
(* Goal: forall (n : nat) (_ : le (S N) n), P (u n) *)
intros n Hn.
(* Goal: P (Rabs x) *)
apply HP.
(* Goal: le N (phi n) *)
apply plus_le_reg_l with M.
(* Goal: le (Init.Nat.add M N) (Init.Nat.add M (phi n)) *)
rewrite Arith.Plus.plus_comm ; apply le_trans with (1:=Hn).
(* Goal: le n (Init.Nat.add M (phi n)) *)
apply le_trans with (1:=le_plus_r (phi M) _).
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
assert (H:(forall x, M+phi M + x <= M+phi (x+M))%nat).
(* Goal: forall x : nat, le (Init.Nat.add (Init.Nat.add M (phi M)) x) (Init.Nat.add M (phi (Init.Nat.add x M))) *)
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
induction x as [|x IH].
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
rewrite plus_0_l plus_0_r.
(* Goal: le n n *)
(* Goal: le M n *)
(* Goal: @eq nat n (Init.Nat.add (Init.Nat.sub n M) M) *)
apply le_refl.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
rewrite <- plus_n_Sm.
(* Goal: le (S (Init.Nat.add (Init.Nat.add M (phi M)) x)) (Init.Nat.add M (phi (Init.Nat.add (S x) M))) *)
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
apply lt_le_S.
(* Goal: lt (Init.Nat.add (Init.Nat.add M (phi M)) x) (Init.Nat.add M (phi (Init.Nat.add (S x) M))) *)
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
apply le_lt_trans with (1:=IH).
(* Goal: lt (Init.Nat.add M (phi (Init.Nat.add x M))) (Init.Nat.add M (phi (Init.Nat.add (S x) M))) *)
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
apply plus_lt_compat_l.
(* Goal: lt (phi (Init.Nat.add x M)) (phi (Init.Nat.add (S x) M)) *)
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
apply Hphi.
(* Goal: le M (Init.Nat.add x M) *)
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
apply le_plus_r.
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
assert (M <= n)%nat.
(* Goal: le M (Init.Nat.add x M) *)
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
apply le_trans with (2:=Hn); apply le_plus_r.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
specialize (H (n-M)%nat).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
replace (n-M+M)%nat with n in H.
(* Goal: le (Init.Nat.add (phi M) n) (Init.Nat.add M (phi n)) *)
(* Goal: @eq nat n (Init.Nat.add (Init.Nat.sub n M) M) *)
apply le_trans with (2:=H).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
rewrite (Arith.Plus.plus_comm _ (phi M)) -Arith.Plus.plus_assoc.
(* Goal: le (Init.Nat.add (phi M) n) (Nat.add (phi M) (Nat.add M (Init.Nat.sub n M))) *)
(* Goal: @eq nat n (Init.Nat.add (Init.Nat.sub n M) M) *)
apply plus_le_compat_l.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
rewrite le_plus_minus_r.
(* Goal: le n n *)
(* Goal: le M n *)
(* Goal: @eq nat n (Init.Nat.add (Init.Nat.sub n M) M) *)
apply le_refl.
(* Goal: le M n *)
(* Goal: @eq nat n (Init.Nat.add (Init.Nat.sub n M) M) *)
exact H0.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
rewrite Arith.Plus.plus_comm.
(* Goal: @eq nat n (Nat.add M (Init.Nat.sub n M)) *)
now apply sym_eq, le_plus_minus_r.
Qed.
Lemma eventually_subseq :
  forall phi,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, (phi n < phi (S n))%nat) ->
  filterlim phi eventually eventually.
Proof.
(* Goal: forall (phi : forall _ : nat, nat) (_ : forall n : nat, lt (phi n) (phi (S n))), @filterlim nat nat phi eventually eventually *)
intros phi Hphi.
(* Goal: @filterlim nat nat phi eventually eventually *)
apply eventually_subseq_loc.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
by apply filter_forall.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_subseq (u : nat -> R) (l : Rbar) (phi : nat -> nat) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim phi eventually eventually ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l ->
  is_lim_seq (fun n => u (phi n)) l.
Proof.
(* Goal: forall (_ : @filterlim nat nat phi eventually eventually) (_ : is_lim_seq u l), is_lim_seq (fun n : nat => u (phi n)) l *)
intros Hphi.
(* Goal: forall _ : is_lim_seq u l, is_lim_seq (fun n : nat => u (phi n)) l *)
now apply filterlim_comp.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_subseq (u : nat -> R) (phi : nat -> nat) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim phi eventually eventually ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u ->
  ex_lim_seq (fun n => u (phi n)).
Proof.
(* Goal: False *)
  move => Hphi [l Hu].
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  exists l.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_seq_subseq.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_subseq (u : nat -> R) (phi : nat -> nat) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim phi eventually eventually ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u ->
  Lim_seq (fun n => u (phi n)) = Lim_seq u.
Proof.
(* Goal: False *)
  move => Hphi Hu.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => u (phi n)) (Lim_seq u) *)
  apply is_lim_seq_subseq.
(* Goal: @filterlim nat nat phi eventually eventually *)
(* Goal: is_lim_seq u (Lim_seq u) *)
  exact Hphi.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Lim_seq_correct.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_incr_1 (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l <-> is_lim_seq (fun n => u (S n)) l.
Proof.
(* Goal: iff (is_lim_seq u l) (is_lim_seq (fun n : nat => u (S n)) l) *)
split ; intros H P HP ; destruct (H P HP) as [N HN].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- exists N.
(* Goal: forall (n : nat) (_ : le (S N) n), P (u n) *)
  intros n Hn.
(* Goal: P (u (S n)) *)
  apply HN.
(* Goal: le N (S n) *)
(* Goal: @filtermap nat R u eventually P *)
  now apply le_S.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- exists (S N).
(* Goal: forall (n : nat) (_ : le (S N) n), P (u n) *)
  intros n Hn.
(* Goal: Rbar_le m_infty m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
  destruct n as [|n] ; try easy.
(* Goal: P (u (S n)) *)
  apply HN.
(* Goal: le N n *)
  now apply le_S_n.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_incr_1 (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u <-> ex_lim_seq (fun n => u (S n)).
Proof.
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  split ; move => [l H] ; exists l.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  by apply -> is_lim_seq_incr_1.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_seq_incr_1.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_incr_1 (u : nat -> R) :
  Lim_seq (fun n => u (S n)) = Lim_seq u.
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Lim_seq.
  replace (LimSup_seq (fun n : nat => u (S n)))
    with (LimSup_seq u).
  replace (LimInf_seq (fun n : nat => u (S n)))
    with (LimInf_seq u).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* LimInf *)
  rewrite /LimInf_seq ;
  case: ex_LimInf_seq => l1 H1 ;
  case: ex_LimInf_seq => l2 H2 /= ;
  case: l1 H1 => [l1 | | ] /= H1 ;
  case: l2 H2 => [l2 | | ] /= H2.
  apply Rbar_finite_eq, Rle_antisym ;
  apply le_epsilon => e He ; set eps := mkposreal e He ;
  apply Rlt_le.
(* Goal: False *)
  case: (proj2 (H1 (pos_div_2 eps))) => /= {H1} N H1.
(* Goal: False *)
  case: (proj1 (H2 (pos_div_2 eps)) N) => /= {H2} n [Hn H2].
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply Rlt_trans with (u (S n) + e/2).
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace l1 with ((l1-e/2)+e/2) by ring.
(* Goal: Rlt (Rplus (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus (Rplus l1 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  apply Rplus_lt_compat_r.
(* Goal: Rlt (Rminus l1 (Rdiv e (IZR (Zpos (xO xH))))) (u (S n)) *)
(* Goal: Rlt (Rplus (u (S n)) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l2 e) *)
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply H1.
(* Goal: le N (S n) *)
(* Goal: Rlt (Rplus (u (S n)) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l2 e) *)
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply le_trans with (1 := Hn).
(* Goal: le n (S n) *)
(* Goal: Rlt (Rplus (u (S n)) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l2 e) *)
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply le_n_Sn.
(* Goal: Rlt (Rplus (Rminus l1 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l2 e) *)
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  replace (l2+e) with ((l2+e/2)+e/2) by field.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rplus_lt_compat_r, H2.
(* Goal: False *)
  case: (proj2 (H2 (pos_div_2 eps))) => /= {H2} N H2.
(* Goal: False *)
  case: (proj1 (H1 (pos_div_2 eps)) (S N)) => /= {H1} .
(* Goal: False *)
  case => [ | n] [Hn H1].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply Rlt_trans with (u (S n) + e/2).
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace l2 with ((l2-e/2)+e/2) by ring.
(* Goal: Rlt (Rplus (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus (Rplus l1 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  apply Rplus_lt_compat_r.
(* Goal: Rlt (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (u (S n)) *)
(* Goal: Rlt (Rplus (u (S n)) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply H2.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_S_n, Hn.
(* Goal: Rlt (Rplus (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  replace (l1+e) with ((l1+e/2)+e/2) by field.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rplus_lt_compat_r, H1.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (H2 (l1+1)) => {H2} N /= H2.
  case: (proj1 (H1 (mkposreal _ Rlt_0_1)) (S N)) ;
  case => /= {H1} [ | n] [Hn].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: forall _ : Rlt (u (S n)) (Rplus l1 (IZR (Zpos xH))), False *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply Rle_not_lt, Rlt_le, H2.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_S_n.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (proj2 (H1 (mkposreal _ Rlt_0_1))) => {H1} N /= H1.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: ((H2 (l1-1)) N) => /= {H2}  n [Hn].
(* Goal: forall _ : Rlt (u (S n)) (IZR Z0), False *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply Rle_not_lt, Rlt_le, H1.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_trans with (2 := le_n_Sn _).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (H1 (l2+1)) => {H1} N /= H1.
  case: (proj1 (H2 (mkposreal _ Rlt_0_1)) N) => /= {H2}  n [Hn].
(* Goal: forall _ : Rlt (u (S n)) (IZR Z0), False *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply Rle_not_lt, Rlt_le, H1.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_trans with (2 := le_n_Sn _).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (H1 0) => {H1} N H1.
(* Goal: False *)
  case: (H2 0 N)=> {H2} n [Hn].
(* Goal: forall _ : Rlt (u (S n)) (IZR Z0), False *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
(* Goal: @eq Rbar (LimSup_seq u) (LimSup_seq (fun n : nat => u (S n))) *)
  apply Rle_not_lt, Rlt_le, H1.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_trans with (2 := le_n_Sn _).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (proj2 (H2 (mkposreal _ Rlt_0_1))) => /= {H2} N H2.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (H1 (l2-1) (S N)) ;
  case => [ | n] [Hn].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H2, le_S_n.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (H2 0) => {H2} N H2.
  case: (H1 0 (S N)) ;
  case => [ | n] [Hn].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H2, le_S_n.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* LimSup *)
  rewrite /LimSup_seq ;
  case: ex_LimSup_seq => l1 H1 ;
  case: ex_LimSup_seq => l2 H2 /= ;
  case: l1 H1 => [l1 | | ] /= H1 ;
  case: l2 H2 => [l2 | | ] /= H2.
  apply Rbar_finite_eq, Rle_antisym ;
  apply le_epsilon => e He ; set eps := mkposreal e He ;
  apply Rlt_le.
(* Goal: False *)
  case: (proj2 (H2 (pos_div_2 eps))) => /= {H2} N H2.
  case: ((proj1 (H1 (pos_div_2 eps))) (S N)) ;
  case => /= {H1} [ | n] [Hn H1].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace l1 with ((l1-e/2)+e/2) by ring.
(* Goal: Rlt (Rplus (Rminus l1 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l2 e) *)
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  replace (l2+e) with ((l2+e/2)+e/2) by field.
(* Goal: Rlt (Rplus (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus (Rplus l1 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  apply Rplus_lt_compat_r.
(* Goal: Rlt (Rminus l1 (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l2 (Rdiv e (IZR (Zpos (xO xH))))) *)
(* Goal: Rlt l2 (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  apply Rlt_trans with (1 := H1).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H2, le_S_n.
(* Goal: False *)
  case: (proj2 (H1 (pos_div_2 eps))) => /= {H1} N H1.
(* Goal: False *)
  case: ((proj1 (H2 (pos_div_2 eps))) N) => /= {H2} n [Hn H2].
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace l2 with ((l2-e/2)+e/2) by ring.
(* Goal: Rlt (Rplus (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l1 e) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  replace (l1+e) with ((l1+e/2)+e/2) by field.
(* Goal: Rlt (Rplus (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) (Rplus (Rplus l1 (Rdiv e (IZR (Zpos (xO xH))))) (Rdiv e (IZR (Zpos (xO xH))))) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  apply Rplus_lt_compat_r.
(* Goal: Rlt (Rminus l2 (Rdiv e (IZR (Zpos (xO xH))))) (Rplus l1 (Rdiv e (IZR (Zpos (xO xH))))) *)
(* Goal: @eq Rbar (Finite l1) p_infty *)
(* Goal: @eq Rbar (Finite l1) m_infty *)
(* Goal: @eq Rbar p_infty (Finite l2) *)
(* Goal: @eq Rbar p_infty p_infty *)
(* Goal: @eq Rbar p_infty m_infty *)
(* Goal: @eq Rbar m_infty (Finite l2) *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: @eq Rbar m_infty m_infty *)
  apply Rlt_trans with (1 := H2).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H1, le_trans with (2 := le_n_Sn _).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (proj2 (H1 (mkposreal _ Rlt_0_1))) => /= {H1} N H1.
(* Goal: False *)
  case: (H2 (l1+1) N) => n [Hn].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H1, le_trans with (2 := le_n_Sn _).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (H2 (l1-1)) => {H2} N H2.
  case: (proj1 (H1 (mkposreal _ Rlt_0_1)) (S N)) ;
  case => [ | n] [Hn] /= .
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H2, le_S_n.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (proj2 (H2 (mkposreal _ Rlt_0_1))) => {H2} /= N H2.
  case: (H1 (l2+1) (S N)) ;
  case => [ | n] [Hn] /= .
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H2, le_S_n.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (H2 0) => {H2} N H2.
  case: (H1 0 (S N)) ;
  case => [ | n] [Hn] /= .
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply le_Sn_0 in Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H2, le_S_n.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (H1 (l2-1)) => {H1} N H1.
(* Goal: False *)
  case: (proj1 (H2 (mkposreal _ Rlt_0_1)) N) => /= {H2} n [Hn].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H1, le_trans with (2 := le_n_Sn _).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  have : False => //.
(* Goal: False *)
  case: (H1 0) => {H1} N H1.
(* Goal: False *)
  case: (H2 0 N) => {H2} n [Hn].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rlt_le, H1, le_trans with (2 := le_n_Sn _).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_incr_n (u : nat -> R) (N : nat) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l <-> is_lim_seq (fun n => u (n + N)%nat) l.
Proof.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: N u => [ | N IH] u Hu.
(* Goal: forall M : R, eventually (fun n : nat => Rlt (u n) M) *)
  move: Hu ; apply is_lim_seq_ext => n ; by rewrite plus_0_r.
(* Goal: is_lim_seq (fun n : nat => u (Init.Nat.add n (S N))) l *)
(* Goal: forall _ : is_lim_seq (fun n : nat => u (Init.Nat.add n N)) l, is_lim_seq u l *)
  apply is_lim_seq_incr_1, IH in Hu.
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move: Hu ; by apply is_lim_seq_ext => n ; by rewrite plus_n_Sm.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: N u => [ | N IH] u Hu.
(* Goal: forall M : R, eventually (fun n : nat => Rlt (u n) M) *)
  move: Hu ; apply is_lim_seq_ext => n ; by rewrite plus_0_r.
(* Goal: is_lim_seq u l *)
  apply is_lim_seq_incr_1, IH.
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move: Hu ; by apply is_lim_seq_ext => n ; by rewrite plus_n_Sm.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_incr_n (u : nat -> R) (N : nat) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u <-> ex_lim_seq (fun n => u (n + N)%nat).
Proof.
(* Goal: ex_lim_seq (fun n : nat => u (phi n)) *)
  split ; move => [l H] ; exists l.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  by apply -> is_lim_seq_incr_n.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_seq_incr_n in H.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_incr_n (u : nat -> R) (N : nat) :
  Lim_seq (fun n => u (n + N)%nat) = Lim_seq u.
Proof.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: N u => [ | N IH] u.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => u (Init.Nat.add n (S N)))) (Lim_seq (fun n : nat => u (S (Init.Nat.add n N)))) *)
  apply Lim_seq_ext => n ; by rewrite plus_0_r.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(Lim_seq_incr_1 u) -(IH (fun n => u (S n))).
(* Goal: @eq Rbar (Lim_seq (fun n : nat => u (Init.Nat.add n (S N)))) (Lim_seq (fun n : nat => u (S (Init.Nat.add n N)))) *)
  apply Lim_seq_ext => n ; by rewrite plus_n_Sm.
Qed.

(** *** Order *)

Lemma filterlim_le :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  forall {T F} {FF : ProperFilter' F} (f g : T -> R) (lf lg : Rbar),
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  F (fun x => f x <= g x) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim f F (Rbar_locally lf) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim g F (Rbar_locally lg) ->
  Rbar_le lf lg.
Proof.
(* Goal: forall (T : Type) (F : forall _ : forall _ : T, Prop, Prop) (_ : @ProperFilter' T F) (f g : forall _ : T, R) (lf lg : Rbar) (_ : F (fun x : T => Rle (f x) (g x))) (_ : @filterlim T R f F (Rbar_locally lf)) (_ : @filterlim T R g F (Rbar_locally lg)), Rbar_le lf lg *)
intros T F FF f g lf lg H Hf Hg.
(* Goal: Rbar_le lf lg *)
apply Rbar_not_lt_le.
(* Goal: not (Rbar_lt lg lf) *)
intros Hl.
(* Goal: False *)
apply filter_not_empty.
(* Goal: Rbar_le m_infty m_infty *)
(* Goal: forall (b : Rbar) (_ : Rbar_is_upper_bound (fun x : Rbar => @ex nat (fun n : nat => @eq Rbar x (u n))) b), Rbar_le m_infty b *)
destruct lf as [lf| |] ; destruct lg as [lg| |] ; try easy.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- assert (Hl' : 0 < (lf - lg) / 2).
(* Goal: Rlt (IZR Z0) (Rdiv (Rminus lf lg) (IZR (Zpos (xO xH)))) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply Rdiv_lt_0_compat.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    now apply -> Rminus_lt_0.
(* Goal: Rlt (IZR Z0) (IZR (Zpos (xO xH))) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply Rlt_R0_R2.
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  assert (Hlf : locally lf (fun y => (lf + lg) / 2 < y)).
(* Goal: @locally R_UniformSpace lf (fun y : UniformSpace.sort R_UniformSpace => Rlt (Rminus lf (IZR (Zpos xH))) y) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply open_gt.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    replace ((lf + lg) / 2) with (lf - (lf - lg) / 2) by field.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
    apply Rabs_lt_between'.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by rewrite /Rminus Rplus_opp_r Rabs_R0.
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  assert (Hlg : locally lg (fun y => y < (lf + lg) / 2)).
(* Goal: @locally R_UniformSpace lg (fun y : UniformSpace.sort R_UniformSpace => Rlt y (Rplus lg (IZR (Zpos xH)))) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply open_lt.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    replace ((lf + lg) / 2) with (lg + (lf - lg) / 2) by field.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
    apply Rabs_lt_between'.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by rewrite /Rminus Rplus_opp_r Rabs_R0.
(* Goal: F (fun _ : T => False) *)
  specialize (Hf _ Hlf).
(* Goal: F (fun _ : T => False) *)
  specialize (Hg _ Hlg).
(* Goal: F (fun _ : T => False) *)
  unfold filtermap in Hf, Hg.
(* Goal: F (fun _ : T => False) *)
  generalize (filter_and _ _ (filter_and _ _ Hf Hg) H).
(* Goal: forall _ : F (fun x : T => and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply filter_imp.
(* Goal: forall (x : T) (_ : and (and (Rbar_lt (Finite (IZR Z0)) (Finite (f x))) (Rbar_lt (Finite (g x)) (Finite (IZR Z0)))) (Rle (f x) (g x))), False *)
  intros x [[H1 H2] H3].
(* Goal: False *)
  apply Rle_not_lt with (1 := H3).
(* Goal: Rlt (g x) (f x) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  now apply Rlt_trans with ((lf + lg) / 2).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- assert (Hlf : locally lf (fun y => lf - 1 < y)).
(* Goal: @locally R_UniformSpace lf (fun y : UniformSpace.sort R_UniformSpace => Rlt (Rminus lf (IZR (Zpos xH))) y) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply open_gt.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
    apply Rabs_lt_between'.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    rewrite /Rminus Rplus_opp_r Rabs_R0.
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply Rlt_0_1.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  assert (Hlg : Rbar_locally m_infty (fun y => Rbar_lt y (lf - 1))).
(* Goal: Rbar_locally m_infty (fun y : R => Rbar_lt (Finite y) (Finite (IZR Z0))) *)
(* Goal: F (fun _ : T => False) *)
    now apply open_Rbar_lt'.
(* Goal: F (fun _ : T => False) *)
  specialize (Hf _ Hlf).
(* Goal: F (fun _ : T => False) *)
  specialize (Hg _ Hlg).
(* Goal: F (fun _ : T => False) *)
  unfold filtermap in Hf, Hg.
(* Goal: F (fun _ : T => False) *)
  generalize (filter_and _ _ (filter_and _ _ Hf Hg) H).
(* Goal: forall _ : F (fun x : T => and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply filter_imp.
(* Goal: forall (x : T) (_ : and (and (Rbar_lt (Finite (IZR Z0)) (Finite (f x))) (Rbar_lt (Finite (g x)) (Finite (IZR Z0)))) (Rle (f x) (g x))), False *)
  intros x [[H1 H2] H3].
(* Goal: False *)
  apply Rle_not_lt with (1 := H3).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  now apply Rlt_trans with (lf - 1).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- assert (Hlf : Rbar_locally p_infty (fun y => Rbar_lt (lg + 1) y)).
(* Goal: Rbar_locally p_infty (fun y : R => Rbar_lt (Finite (IZR Z0)) (Finite y)) *)
(* Goal: F (fun _ : T => False) *)
    now apply open_Rbar_gt'.
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  assert (Hlg : locally lg (fun y => y < lg + 1)).
(* Goal: @locally R_UniformSpace lg (fun y : UniformSpace.sort R_UniformSpace => Rlt y (Rplus lg (IZR (Zpos xH)))) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply open_lt.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
    apply Rabs_lt_between'.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    rewrite /Rminus Rplus_opp_r Rabs_R0.
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
    apply Rlt_0_1.
(* Goal: F (fun _ : T => False) *)
  specialize (Hf _ Hlf).
(* Goal: F (fun _ : T => False) *)
  specialize (Hg _ Hlg).
(* Goal: F (fun _ : T => False) *)
  unfold filtermap in Hf, Hg.
(* Goal: F (fun _ : T => False) *)
  generalize (filter_and _ _ (filter_and _ _ Hf Hg) H).
(* Goal: forall _ : F (fun x : T => and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply filter_imp.
(* Goal: forall (x : T) (_ : and (and (Rbar_lt (Finite (IZR Z0)) (Finite (f x))) (Rbar_lt (Finite (g x)) (Finite (IZR Z0)))) (Rle (f x) (g x))), False *)
  intros x [[H1 H2] H3].
(* Goal: False *)
  apply Rle_not_lt with (1 := H3).
(* Goal: Rlt (g x) (f x) *)
(* Goal: F (fun _ : T => False) *)
  now apply Rlt_trans with (lg + 1).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- assert (Hlf : Rbar_locally p_infty (fun y => Rbar_lt 0 y)).
(* Goal: Rbar_locally p_infty (fun y : R => Rbar_lt (Finite (IZR Z0)) (Finite y)) *)
(* Goal: F (fun _ : T => False) *)
    now apply open_Rbar_gt'.
(* Goal: F (fun _ : T => False) *)
  assert (Hlg : Rbar_locally m_infty (fun y => Rbar_lt y 0)).
(* Goal: Rbar_locally m_infty (fun y : R => Rbar_lt (Finite y) (Finite (IZR Z0))) *)
(* Goal: F (fun _ : T => False) *)
    now apply open_Rbar_lt'.
(* Goal: F (fun _ : T => False) *)
  specialize (Hf _ Hlf).
(* Goal: F (fun _ : T => False) *)
  specialize (Hg _ Hlg).
(* Goal: F (fun _ : T => False) *)
  unfold filtermap in Hf, Hg.
(* Goal: F (fun _ : T => False) *)
  generalize (filter_and _ _ (filter_and _ _ Hf Hg) H).
(* Goal: forall _ : F (fun x : T => and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply filter_imp.
(* Goal: forall (x : T) (_ : and (and (Rbar_lt (Finite (IZR Z0)) (Finite (f x))) (Rbar_lt (Finite (g x)) (Finite (IZR Z0)))) (Rle (f x) (g x))), False *)
  intros x [[H1 H2] H3].
(* Goal: False *)
  apply Rle_not_lt with (1 := H3).
(* Goal: Rlt (g x) (f x) *)
  now apply Rlt_trans with 0.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_le_loc (u v : nat -> R) (l1 l2 : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n <= v n) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 ->
  Rbar_le l1 l2.
Proof.
(* Goal: forall (_ : is_lim_seq u l1) (_ : is_lim_seq v l2), Rbar_le l1 l2 *)
  apply filterlim_le.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_le_loc (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n <= v n) ->
  Rbar_le (Lim_seq u) (Lim_seq v).
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: False *)
  move: (LimSup_le _ _ H) (LimInf_le _ _ H).
(* Goal: False *)
  move: (LimSup_LimInf_seq_le u) (LimSup_LimInf_seq_le v).
(* Goal: forall (_ : Rbar_le (LimInf_seq u) (LimSup_seq u)) (_ : Rbar_le (LimInf_seq v) (LimSup_seq v)) (_ : Rbar_le (LimSup_seq u) (LimSup_seq v)) (_ : Rbar_le (LimInf_seq u) (LimInf_seq v)), Rbar_le (Lim_seq u) (Lim_seq v) *)
  unfold Lim_seq.
  case: (LimSup_seq u) => [lsu | | ] //= ;
  case: (LimInf_seq u) => [liu | | ] //= ;
  case: (LimSup_seq v) => [lsv | | ] //= ;
  case: (LimInf_seq v) => [liv | | ] //= ;
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: Rle (Rdiv (Rplus lsu liu) (IZR (Zpos (xO xH)))) (Rdiv (Rplus lsv liv) (IZR (Zpos (xO xH)))) *)
(* Goal: Rle (Rdiv (IZR Z0) (IZR (Zpos (xO xH)))) (Rdiv (IZR Z0) (IZR (Zpos (xO xH)))) *)
  apply Rmult_le_compat_r.
(* Goal: Rle (IZR Z0) (Rinv (IZR (Zpos (xO xH)))) *)
(* Goal: Rle (Rplus lsu liu) (Rplus lsv liv) *)
(* Goal: Rle (Rdiv (IZR Z0) (IZR (Zpos (xO xH)))) (Rdiv (IZR Z0) (IZR (Zpos (xO xH)))) *)
  apply Rlt_le, Rinv_0_lt_compat, Rlt_0_2.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rplus_le_compat.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Req_le.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_le (u v : nat -> R) (l1 l2 : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, u n <= v n) -> is_lim_seq u l1 -> is_lim_seq v l2 -> Rbar_le l1 l2.
Proof.
(* Goal: forall (_ : forall n : nat, and (Rle (u n) (v n)) (Rle (v n) (w n))) (_ : is_lim_seq u l) (_ : is_lim_seq w l), is_lim_seq v l *)
  intros H.
(* Goal: forall (_ : is_lim_seq u l1) (_ : is_lim_seq v l2), Rbar_le l1 l2 *)
  apply filterlim_le.
(* Goal: eventually (fun x : nat => and (Rle (u x) (v x)) (Rle (v x) (w x))) *)
  now apply filter_forall.
Qed.

Lemma filterlim_ge_p_infty :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  forall {T F} {FF : Filter F} (f g : T -> R),
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  F (fun x => f x <= g x) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim f F (Rbar_locally p_infty) ->
  filterlim g F (Rbar_locally p_infty).
Proof.
(* Goal: forall (T : Type) (F : forall _ : forall _ : T, Prop, Prop) (_ : @Filter T F) (f g : forall _ : T, R) (_ : F (fun x : T => Rle (g x) (f x))) (_ : @filterlim T R f F (Rbar_locally m_infty)), @filterlim T R g F (Rbar_locally m_infty) *)
intros T F FF f g H Hf.
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
intros P [M HM].
(* Goal: @filtermap T R g F P *)
assert (H' : Rbar_locally p_infty (fun y => M < y)).
(* Goal: Rbar_locally m_infty ineq *)
(* Goal: @filtermap T R g F P *)
  now exists M.
(* Goal: @filtermap T R g F P *)
unfold filtermap.
(* Goal: F (fun x : T => P (g x)) *)
generalize (filter_and (fun x : T => f x <= g x) _ H (Hf (fun y : R => M < y) H')).
(* Goal: forall _ : F (fun x : T => and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
apply filter_imp.
(* Goal: forall (x : T) (_ : and (Rle (g x) (f x)) (ineq (f x))), P (g x) *)
intros x [H1 H2].
(* Goal: P (g x) *)
apply HM.
(* Goal: Rlt M (g x) *)
now apply Rlt_le_trans with (f x).
Qed.

Lemma filterlim_le_m_infty :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  forall {T F} {FF : Filter F} (f g : T -> R),
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  F (fun x => g x <= f x) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim f F (Rbar_locally m_infty) ->
  filterlim g F (Rbar_locally m_infty).
Proof.
(* Goal: forall (T : Type) (F : forall _ : forall _ : T, Prop, Prop) (_ : @Filter T F) (f g : forall _ : T, R) (_ : F (fun x : T => Rle (g x) (f x))) (_ : @filterlim T R f F (Rbar_locally m_infty)), @filterlim T R g F (Rbar_locally m_infty) *)
intros T F FF f g H Hf.
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
intros P [M HM].
(* Goal: @filtermap T R g F P *)
pose ineq (y : R) := y < M.
(* Goal: @filtermap T R g F P *)
assert (H' : Rbar_locally m_infty ineq).
(* Goal: Rbar_locally m_infty ineq *)
(* Goal: @filtermap T R g F P *)
  now exists M.
(* Goal: @filtermap T R g F P *)
unfold filtermap.
(* Goal: F (fun x : T => P (g x)) *)
generalize (filter_and _ (fun x : T => ineq (f x)) H (Hf ineq H')).
(* Goal: forall _ : F (fun x : T => and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
apply filter_imp.
(* Goal: forall (x : T) (_ : and (Rle (g x) (f x)) (ineq (f x))), P (g x) *)
intros x [H1 H2].
(* Goal: P (g x) *)
apply HM.
(* Goal: Rlt (g x) M *)
now apply Rle_lt_trans with (f x).
Qed.

Lemma filterlim_le_le :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  forall {T F} {FF : Filter F} (f g h : T -> R) (l : Rbar),
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  F (fun x => f x <= g x <= h x) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim f F (Rbar_locally l) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  filterlim h F (Rbar_locally l) ->
  filterlim g F (Rbar_locally l).
Proof.
(* Goal: forall (T : Type) (F : forall _ : forall _ : T, Prop, Prop) (_ : @Filter T F) (f g h : forall _ : T, R) (l : Rbar) (_ : F (fun x : T => and (Rle (f x) (g x)) (Rle (g x) (h x)))) (_ : @filterlim T R f F (Rbar_locally l)) (_ : @filterlim T R h F (Rbar_locally l)), @filterlim T R g F (Rbar_locally l) *)
intros T F FF f g h l H Hf Hh.
(* Goal: False *)
destruct l as [l| |].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- intros P [eps He].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  assert (H' : Rbar_locally l (fun y => Rabs (y - l) < eps)).
(* Goal: Rbar_locally (Finite l) (fun y : R => Rlt (Rabs (Rminus y l)) (pos eps)) *)
(* Goal: @filtermap T R g F P *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
    now exists eps.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  unfold filterlim, filter_le, filtermap in Hf, Hh |- *.
(* Goal: F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  generalize (filter_and _ _ H (filter_and _ _ (Hf _ H') (Hh _ H'))).
(* Goal: forall _ : F (fun x : T => and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), F (fun x : T => P (g x)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply filter_imp.
(* Goal: forall (x : T) (_ : and (and (Rle (f x) (g x)) (Rle (g x) (h x))) (and (Rlt (Rabs (Rminus (f x) l)) (pos eps)) (Rlt (Rabs (Rminus (h x) l)) (pos eps)))), P (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  intros x [H1 [H2 H3]].
(* Goal: P (Ropp y) *)
  apply He.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between'.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  split.
(* Goal: Rlt (Rminus l (pos eps)) (g x) *)
(* Goal: Rlt (g x) (Rplus l (pos eps)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rlt_le_trans with (2 := proj1 H1).
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  now apply Rabs_lt_between'.
(* Goal: Rlt (g x) (Rplus l (pos eps)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rle_lt_trans with (1 := proj2 H1).
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  now apply Rabs_lt_between'.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- apply filterlim_ge_p_infty with (2 := Hf).
(* Goal: F (fun x : T => Rle (g x) (h x)) *)
  apply: filter_imp H.
(* Goal: forall (x : T) (_ : and (Rle (f x) (g x)) (Rle (g x) (h x))), Rle (f x) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  now intros x [H _].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- apply filterlim_le_m_infty with (2 := Hh).
(* Goal: F (fun x : T => Rle (g x) (h x)) *)
  apply: filter_imp H.
(* Goal: forall (x : T) (_ : and (Rle (f x) (g x)) (Rle (g x) (h x))), Rle (g x) (h x) *)
  now intros x [_ H].
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_le_le_loc (u v w : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n <= v n <= w n) -> is_lim_seq u l -> is_lim_seq w l -> is_lim_seq v l.
Proof.
(* Goal: forall (_ : is_lim_seq u l) (_ : is_lim_seq w l), is_lim_seq v l *)
  apply filterlim_le_le.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_le_le (u v w : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, u n <= v n <= w n) -> is_lim_seq u l -> is_lim_seq w l -> is_lim_seq v l.
Proof.
(* Goal: forall (_ : forall n : nat, and (Rle (u n) (v n)) (Rle (v n) (w n))) (_ : is_lim_seq u l) (_ : is_lim_seq w l), is_lim_seq v l *)
  intros H.
(* Goal: forall (_ : is_lim_seq u l) (_ : is_lim_seq w l), is_lim_seq v l *)
  apply filterlim_le_le.
(* Goal: eventually (fun x : nat => and (Rle (u x) (v x)) (Rle (v x) (w x))) *)
  now apply filter_forall.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_le_p_loc (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => u n <= v n) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u p_infty ->
  is_lim_seq v p_infty.
Proof.
(* Goal: forall (_ : eventually (fun n : nat => Rle (u n) (v n))) (_ : is_lim_seq u p_infty), is_lim_seq v p_infty *)
  apply filterlim_ge_p_infty.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_le_m_loc (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  eventually (fun n => v n <= u n) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u m_infty ->
  is_lim_seq v m_infty.
Proof.
(* Goal: forall (_ : eventually (fun n : nat => Rle (v n) (u n))) (_ : is_lim_seq u m_infty), is_lim_seq v m_infty *)
  apply filterlim_le_m_infty.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_decr_compare (u : nat -> R) (l : R) :
  is_lim_seq u l
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> (forall n, (u (S n)) <= (u n))
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> forall n, l <= u n.
Proof.
(* Goal: False *)
  move /is_lim_seq_spec => Hu H n.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Rnot_lt_le => H0.
(* Goal: False *)
  apply Rminus_lt_0 in H0.
(* Goal: False *)
  case: (Hu (mkposreal _ H0)) => {Hu} /= Nu Hu.
(* Goal: False *)
  move: (Hu _ (le_plus_r n Nu)).
(* Goal: forall _ : Rlt (pow q (Init.Nat.mul (S (S O)) N)) (IZR Z0), False *)
  apply Rle_not_lt.
(* Goal: Rle (Rminus l (u n)) (Rabs (Rminus (u (Init.Nat.add n Nu)) l)) *)
  apply Rle_trans with (2 := Rabs_maj2 _).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Ropp_minus_distr'.
(* Goal: Rle (Rminus l (u n)) (Rminus l (u (Init.Nat.add n Nu))) *)
  apply Rplus_le_compat_l.
(* Goal: Rle (Ropp (u n)) (Ropp (u (Init.Nat.add n Nu))) *)
  apply Ropp_le_contravar.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: (Nu) => [ | m IH].
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite plus_0_r ; by apply Rle_refl.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -plus_n_Sm.
(* Goal: Rle (u (S n)) (u N) *)
  apply Rle_trans with (2 := IH).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_incr_compare (u : nat -> R) (l : R) :
  is_lim_seq u l
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> (forall n, (u n) <= (u (S n)))
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> forall n, u n <= l.
Proof.
(* Goal: False *)
  move /is_lim_seq_spec => Hu H n.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Rnot_lt_le => H0.
(* Goal: False *)
  apply Rminus_lt_0 in H0.
(* Goal: False *)
  case: (Hu (mkposreal _ H0)) => {Hu} /= Nu Hu.
(* Goal: False *)
  move: (Hu _ (le_plus_r n Nu)).
(* Goal: forall _ : Rlt (pow q (Init.Nat.mul (S (S O)) N)) (IZR Z0), False *)
  apply Rle_not_lt.
(* Goal: Rle (Rminus (u n) l) (Rabs (Rminus (u (Init.Nat.add n Nu)) l)) *)
  apply Rle_trans with (2 := Rle_abs _).
(* Goal: Rle (Rminus (u n) l) (Rminus (u (Init.Nat.add n Nu)) l) *)
  apply Rplus_le_compat_r.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: (Nu) => [ | m IH].
(* Goal: Rlt M (Rplus M (IZR (Zpos xH))) *)
(* Goal: Rle (Rplus M (IZR (Zpos xH))) (pow q n) *)
  rewrite plus_0_r ; by apply Rle_refl.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -plus_n_Sm.
(* Goal: Rle (u N) (u (S n)) *)
(* Goal: forall M : R, eventually (fun n : nat => Rlt (u n) M) *)
  apply Rle_trans with (1 := IH).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_decr (u : nat -> R) :
  (forall n, (u (S n)) <= (u n))
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    -> ex_lim_seq u.
Proof.
(* Goal: False *)
  move => H.
(* Goal: ex_lim_seq u *)
  exists (Inf_seq u).
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: is_lim_seq' u (Finite (real (Inf_seq (fun x : nat => Finite (u x))))) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  rewrite /Inf_seq ; case: ex_inf_seq ; case => [l | | ] //= Hl.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => eps ; case: (Hl eps) => Hl1 [N Hl2].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between' ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl1.
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply Rle_lt_trans with (2 := Hl2).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: n N {Hl2} Hn => [ | n IH] N Hn.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite (le_n_O_eq _ Hn).
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply Rle_refl.
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply le_lt_eq_dec in Hn.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: Hn => [Hn | ->].
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: Rle (u (S n)) (u (S n)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply Rle_trans with (1 := H _), IH ; intuition.
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  move => M ; exists O => n _ ; by apply Hl.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl M) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt (u n) M *)
  apply Rle_lt_trans with (2 := Hl).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: Hn => [ | {n} n Hn IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: Rle (u (S n)) (u N) *)
  apply Rle_trans with (2 := IH).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_incr (u : nat -> R) :
  (forall n, (u n) <= (u (S n)))
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    -> ex_lim_seq u.
Proof.
(* Goal: False *)
  move => H.
(* Goal: ex_lim_seq u *)
  exists (Sup_seq u).
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: is_lim_seq' u (Finite (real (Inf_seq (fun x : nat => Finite (u x))))) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  rewrite /Sup_seq ; case: ex_sup_seq ; case => [l | | ] //= Hl.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => eps ; case: (Hl eps) => Hl1 [N Hl2].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between' ; split.
(* Goal: Rlt (Rminus l (pos eps)) (u n) *)
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: forall M : R, eventually (fun n : nat => Rlt M (u n)) *)
(* Goal: forall M : R, eventually (fun n : nat => Rlt (u n) M) *)
  apply Rlt_le_trans with (1 := Hl2).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: Hn => [ | {n} n Hn IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: Rle (u N) (u (S n)) *)
(* Goal: forall M : R, eventually (fun n : nat => Rlt (u n) M) *)
  apply Rle_trans with (1 := IH).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl1.
(* Goal: False *)
  move => M.
(* Goal: False *)
  case: (Hl M) => {Hl} N Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt M (u n) *)
(* Goal: forall M : R, eventually (fun n : nat => Rlt (u n) M) *)
  apply Rlt_le_trans with (1 := Hl).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: Hn => [ | {n} n Hn IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: Rle (u N) (u (S n)) *)
(* Goal: forall M : R, eventually (fun n : nat => Rlt (u n) M) *)
  apply Rle_trans with (1 := IH).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply H.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  move => M ; exists O => n Hn ; by apply Hl.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_finite_lim_seq_decr (u : nat -> R) (M : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, (u (S n)) <= (u n)) -> (forall n, M <= u n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    -> ex_finite_lim_seq u.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: ex_finite_lim_seq u *)
  apply ex_finite_lim_seq_correct.
(* Goal: False *)
(* Goal: False *)
  have H1 : ex_lim_seq u.
(* Goal: ex_lim_seq u *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  exists (real (Inf_seq u)).
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: is_lim_seq' u (Finite (real (Inf_seq (fun x : nat => Finite (u x))))) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  rewrite /Inf_seq ; case: ex_inf_seq ; case => [l | | ] //= Hl.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) l)) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  move => eps ; case: (Hl eps) => Hl1 [N Hl2].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: and (Rlt (Rminus l (pos eps)) (g x)) (Rlt (g x) (Rplus l (pos eps))) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between' ; split.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Hl1.
(* Goal: Rlt (u n) (Rplus l (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply Rle_lt_trans with (2 := Hl2).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: n N {Hl2} Hn => [ | n IH] N Hn.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite (le_n_O_eq _ Hn).
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply Rle_refl.
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply le_lt_eq_dec in Hn.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: Hn => [Hn | ->].
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: Rle (u (S n)) (u (S n)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply Rle_trans with (1 := H _), IH ; intuition.
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move: (Hl (u O) O) => H1 ; by apply Rlt_irrefl in H1.
(* Goal: False *)
  case: (Hl M) => {Hl} n Hl.
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  apply Rlt_not_le in Hl.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by move: (Hl (H0 n)).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  split => //.
(* Goal: is_finite (Lim_seq u) *)
  apply Lim_seq_correct in H1.
(* Goal: False *)
  case: (Lim_seq u) H1 => [l | | ] /= Hu.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
(* Goal: is_lim_seq u (Finite (IZR Z0)) *)
  apply is_lim_seq_spec in Hu.
(* Goal: False *)
  case: (Hu (u O)) => {Hu} N Hu.
(* Goal: False *)
  move: (Hu N (le_refl _)) => {Hu} Hu.
(* Goal: forall _ : Rlt (pow q (Init.Nat.mul (S (S O)) N)) (IZR Z0), False *)
  contradict Hu ; apply Rle_not_lt.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: N => [ | N IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_trans with (1 := H _).
(* Goal: is_lim_seq u (Finite (IZR Z0)) *)
  apply is_lim_seq_spec in Hu.
(* Goal: False *)
  case: (Hu M) => {Hu} N Hu.
(* Goal: False *)
  move: (Hu N (le_refl _)) => {Hu} Hu.
(* Goal: forall _ : Rlt (pow q (Init.Nat.mul (S (S O)) N)) (IZR Z0), False *)
  contradict Hu ; by apply Rle_not_lt.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_finite_lim_seq_incr (u : nat -> R) (M : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, (u n) <= (u (S n))) -> (forall n, u n <= M)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    -> ex_finite_lim_seq u.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (ex_finite_lim_seq_decr (fun n => - u n) (- M)).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  move => n ; by apply Ropp_le_contravar.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  move => n ; by apply Ropp_le_contravar.
(* Goal: False *)
  move => l ; move => Hu.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  exists (- l).
(* Goal: is_lim_seq u (Finite (IZR Z0)) *)
  apply is_lim_seq_spec in Hu.
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: is_lim_seq' u (Finite (Ropp l)) *)
  intros eps.
(* Goal: False *)
  case: (Hu eps) => {Hu} N Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace (u n - - l) with (-(- u n - l)) by ring.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  rewrite Rabs_Ropp ; by apply Hu.
Qed.

(** *** Additive operators *)

(** Opposite *)

Lemma filterlim_Rbar_opp :
  forall x,
  filterlim Ropp (Rbar_locally x) (Rbar_locally (Rbar_opp x)).
Proof.
(* Goal: forall x : Rbar, @filterlim R R Ropp (Rbar_locally x) (Rbar_locally (Rbar_opp x)) *)
intros [x| |] P [eps He].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- exists eps.
(* Goal: forall (x : R) (_ : Rlt x (Ropp eps)), P (Ropp x) *)
  intros y Hy.
(* Goal: P (Ropp y) *)
  apply He.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Ropp_involutive Rplus_comm Rabs_minus_sym.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- exists (-eps).
(* Goal: forall (x : R) (_ : Rlt x (Ropp eps)), P (Ropp x) *)
  intros y Hy.
(* Goal: P (Ropp y) *)
  apply He.
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Ropp_involutive.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
- exists (-eps).
(* Goal: forall (x : R) (_ : Rlt x (Ropp eps)), P (Ropp x) *)
  intros y Hy.
(* Goal: P (Ropp y) *)
  apply He.
(* Goal: Rlt eps (Ropp y) *)
  apply Ropp_lt_cancel.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Ropp_involutive.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_opp (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l <-> is_lim_seq (fun n => -u n) (Rbar_opp l).
Proof.
(* Goal: False *)
  split ; move => Hu.
(* Goal: is_lim_seq u l *)
  apply is_LimSup_LimInf_lim_seq.
(* Goal: is_LimInf_seq u l *)
  apply is_LimSup_opp_LimInf_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimInf_seq.
(* Goal: is_LimSup_seq u l *)
(* Goal: is_LimInf_seq u l *)
  apply is_LimInf_opp_LimSup_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimSup_seq.
(* Goal: is_lim_seq u l *)
  apply is_LimSup_LimInf_lim_seq.
(* Goal: is_LimSup_seq u l *)
(* Goal: is_LimInf_seq u l *)
  apply is_LimInf_opp_LimSup_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimInf_seq.
(* Goal: is_LimInf_seq u l *)
  apply is_LimSup_opp_LimInf_seq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_LimSup_seq.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_opp (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u <-> ex_lim_seq (fun n => -u n).
Proof.
(* Goal: iff (ex_lim_seq u) (ex_lim_seq (fun n : nat => Ropp (u n))) *)
  split ; case => l Hl ; exists (Rbar_opp l).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  by apply -> is_lim_seq_opp.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  apply is_lim_seq_ext with (fun n => - - u n).
(* Goal: Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps) *)
  move => n ; by apply Ropp_involutive.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  by apply -> is_lim_seq_opp.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_opp (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Lim_seq (fun n => - u n) = Rbar_opp (Lim_seq u).
Proof.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Lim_seq.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite LimSup_seq_opp LimInf_seq_opp.
  case: (LimInf_seq u) => [li | | ] ;
  case: (LimSup_seq u) => [ls | | ] //= ;
  apply f_equal ; field.
Qed.

(** Addition *)

Lemma filterlim_Rbar_plus :
  forall x y z,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_Rbar_plus x y z ->
  filterlim (fun z => fst z + snd z) (filter_prod (Rbar_locally x) (Rbar_locally y)) (Rbar_locally z).
Proof.
  intros x y z.
  wlog: x y z / (Rbar_le 0 z).
    intros Hw.
(* Goal: False *)
    case: (Rbar_le_lt_dec 0 z) => Hz Hp.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply Hw.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    apply (filterlim_ext (fun z => - (- fst z + - snd z))).
    intros t.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
    ring.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -(Rbar_opp_involutive z).
    eapply filterlim_comp.
    2: apply filterlim_Rbar_opp.
    assert (Hw' : filterlim (fun z => fst z + snd z) (filter_prod (Rbar_locally (Rbar_opp x)) (Rbar_locally (Rbar_opp y))) (Rbar_locally (Rbar_opp z))).
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult (Ropp a) (Ropp (u n)))) (Rbar_mult (Rbar_opp (Finite a)) (Lim_seq (fun n : nat => Ropp (u n)))) *)
(* Goal: forall n : nat, @eq R (Rmult (Ropp a) (Ropp (u n))) (Rmult a (u n)) *)
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult a (u n))) (Rbar_mult (Finite a) (Lim_seq u)) *)
    apply Hw.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -Ropp_0 -/(Rbar_opp 0).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    apply <- Rbar_opp_le.
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
    now apply Rbar_lt_le.
    revert Hp.
    clear.
    destruct x as [x| |] ; destruct y as [y| |] ; destruct z as [z| |] => //=.
    unfold is_Rbar_plus ; simpl => H.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    injection H => <-.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
    apply f_equal, f_equal ; ring.
    clear Hw.
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
    intros P HP.
    specialize (Hw' P HP).
    destruct Hw' as [Q R H1 H2 H3].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    exists (fun x => Q (- x)) (fun x => R (- x)).
    now apply filterlim_Rbar_opp.
    now apply filterlim_Rbar_opp.
    intros u v HQ HR.
    exact (H3 _ _ HQ HR).

  unfold is_Rbar_plus.
  case: z => [z| |] Hz Hp ;
  try by case: Hz.

(* x + y \in R *)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: x y Hp Hz => [x| |] ; case => [y| |] //= ; case => <- Hz.
(* Goal: @filterlim T R g F (Rbar_locally (Finite l)) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  intros P [eps He].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  exists (fun u => Rabs (u - x) < pos_div_2 eps) (fun v => Rabs (v - y) < pos_div_2 eps).
  now exists (pos_div_2 eps).
  now exists (pos_div_2 eps).
  intros u v Hu Hv.
(* Goal: P (Ropp y) *)
  apply He.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace (u + v + - (x + y)) with ((u - x) + (v - y)) by ring.
  rewrite (double_var eps) ;
  apply Rle_lt_trans with (1 := Rabs_triang _ _), Rplus_lt_compat.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  now apply Hu.
  now apply Hv.

(* x + y = p_infty *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  wlog: x y Hp {Hz} / (is_finite x) => [Hw|Hx].
    case: x y Hp {Hz} => [x| |] ;
    case => [y| |] // _.
    now apply (Hw x p_infty).
    assert (Hw': filterlim (fun z => fst z + snd z) (filter_prod (Rbar_locally y) (Rbar_locally p_infty)) (Rbar_locally p_infty)).
(* Goal: Rbar_lt (Finite M) (u n) *)
(* Goal: Rbar_le (u n) l *)
    exact: Hw.
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
    intros P HP.
    specialize (Hw' P HP).
    destruct Hw' as [Q R H1 H2 H3].
    exists R Q ; try assumption.
    intros u v Hu Hv.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    rewrite Rplus_comm.
    now apply (H3 v u).
    clear Hw.
    intros P [N HN].
    exists (fun x => N/2 < x) (fun x => N/2 < x).
    now exists (N/2).
    now exists (N/2).
    intros x y Hx Hy.
    simpl.
(* Goal: P (u (S n)) *)
    apply HN.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    rewrite (double_var N).
    now apply Rplus_lt_compat.
  case: x y Hp Hx => [x| |] ;
  case => [y| | ] //= _ _.
  intros P [N HN].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  exists (fun u => Rabs (u - x) < 1) (fun v => N - x + 1 < v).
  now exists (mkposreal _ Rlt_0_1).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  now exists (N - x + 1).
  intros u v Hu Hv.
  simpl.
(* Goal: P (u (S n)) *)
  apply HN.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace N with (x - 1 + (N - x + 1)) by ring.
  apply Rplus_lt_compat.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  now apply Rabs_lt_between'.
  exact Hv.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_plus (u v : nat -> R) (l1 l2 l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_Rbar_plus l1 l2 l ->
  is_lim_seq (fun n => u n + v n) l.
Proof.
(* Goal: forall (_ : ex_lim_seq u) (_ : ex_lim_seq v) (_ : ex_Rbar_minus (Lim_seq u) (Lim_seq v)), @eq Rbar (Lim_seq (fun n : nat => Rminus (u n) (v n))) (Rbar_minus (Lim_seq u) (Lim_seq v)) *)
intros Hu Hv Hl.
(* Goal: is_lim_seq (fun n : nat => Rmult (u n) (v n)) l *)
eapply filterlim_comp_2 ; try eassumption.
(* Goal: @filterlim (prod R R) R (fun x : prod R R => Rplus (@fst R R x) (@snd R R x)) (@filter_prod R R (Rbar_locally l1) (Rbar_locally l2)) (Rbar_locally l) *)
now apply filterlim_Rbar_plus.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_plus' (u v : nat -> R) (l1 l2 : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 ->
  is_lim_seq (fun n => u n + v n) (l1 + l2).
Proof.
(* Goal: forall (_ : is_lim_seq u (Finite l1)) (_ : is_lim_seq v (Finite l2)), is_lim_seq (fun n : nat => Rmult (u n) (v n)) (Finite (Rmult l1 l2)) *)
intros Hu Hv.
eapply is_lim_seq_plus.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
by apply Hu.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
by apply Hv.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
by [].
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_plus (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_plus (Lim_seq u) (Lim_seq v) ->
  ex_lim_seq (fun n => u n + v n).
Proof.
(* Goal: forall (_ : ex_lim_seq u) (_ : ex_lim_seq v) (_ : ex_Rbar_plus (Lim_seq u) (Lim_seq v)), ex_lim_seq (fun n : nat => Rplus (u n) (v n)) *)
  intros [lu Hu] [lv Hv] Hl ; exists (Rbar_plus lu lv).
(* Goal: is_lim_seq (fun n : nat => Rplus (u n) (v n)) (Rbar_plus lu lv) *)
  apply is_lim_seq_plus with lu lv ; try assumption.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(is_lim_seq_unique u lu) //.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(is_lim_seq_unique v lv) //.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_plus_correct.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_plus (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_plus (Lim_seq u) (Lim_seq v) ->
  Lim_seq (fun n => u n + v n) = Rbar_plus (Lim_seq u) (Lim_seq v).
Proof.
(* Goal: forall (_ : ex_lim_seq u) (_ : ex_lim_seq v) (_ : ex_Rbar_minus (Lim_seq u) (Lim_seq v)), @eq Rbar (Lim_seq (fun n : nat => Rminus (u n) (v n))) (Rbar_minus (Lim_seq u) (Lim_seq v)) *)
  intros Hu Hv Hl.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rplus (u n) (v n)) (Rbar_plus (Lim_seq u) (Lim_seq v)) *)
  eapply is_lim_seq_plus ; try apply Lim_seq_correct ; try assumption.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_plus_correct.
Qed.

(** Subtraction *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_minus (u v : nat -> R) (l1 l2 l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_Rbar_minus l1 l2 l ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq (fun n => u n - v n) l.
Proof.
(* Goal: forall (_ : is_lim_seq u l1) (_ : is_lim_seq v l2) (_ : is_Rbar_minus l1 l2 l), is_lim_seq (fun n : nat => Rminus (u n) (v n)) l *)
  intros H1 H2 Hl.
(* Goal: is_lim_seq (fun n : nat => Rminus (u n) (v n)) l *)
  eapply is_lim_seq_plus ; try eassumption.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  apply -> is_lim_seq_opp ; apply H2.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_minus' (u v : nat -> R) (l1 l2 : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq (fun n => u n - v n) (l1 - l2).
Proof.
(* Goal: forall (_ : is_lim_seq u (Finite l1)) (_ : is_lim_seq v (Finite l2)), is_lim_seq (fun n : nat => Rmult (u n) (v n)) (Finite (Rmult l1 l2)) *)
intros Hu Hv.
(* Goal: is_lim_seq (fun n : nat => Rminus (u n) (v n)) (Rbar_minus lu lv) *)
eapply is_lim_seq_minus ; try eassumption.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
by [].
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_minus (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_minus (Lim_seq u) (Lim_seq v) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq (fun n => u n - v n).
Proof.
(* Goal: forall (_ : ex_lim_seq u) (_ : ex_lim_seq v) (_ : ex_Rbar_minus (Lim_seq u) (Lim_seq v)), ex_lim_seq (fun n : nat => Rminus (u n) (v n)) *)
  intros [lu Hu] [lv Hv] Hl ; exists (Rbar_minus lu lv).
(* Goal: is_lim_seq (fun n : nat => Rminus (u n) (v n)) (Rbar_minus lu lv) *)
  eapply is_lim_seq_minus ; try eassumption.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(is_lim_seq_unique u lu) //.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(is_lim_seq_unique v lv) //.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_plus_correct.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_minus (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_minus (Lim_seq u) (Lim_seq v) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Lim_seq (fun n => u n - v n) = Rbar_minus (Lim_seq u) (Lim_seq v).
Proof.
(* Goal: forall (_ : ex_lim_seq u) (_ : ex_lim_seq v) (_ : ex_Rbar_minus (Lim_seq u) (Lim_seq v)), @eq Rbar (Lim_seq (fun n : nat => Rminus (u n) (v n))) (Rbar_minus (Lim_seq u) (Lim_seq v)) *)
  intros Hu Hv Hl.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rminus (u n) (v n)) (Rbar_minus (Lim_seq u) (Lim_seq v)) *)
  eapply is_lim_seq_minus ; try apply Lim_seq_correct ; try assumption.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_plus_correct.
Qed.

(** *** Multiplicative operators *)

(** Inverse *)

Lemma filterlim_Rbar_inv :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  forall l : Rbar, l <> 0 ->
  filterlim Rinv (Rbar_locally l) (Rbar_locally (Rbar_inv l)).
Proof.
  intros l.
  wlog: l / (Rbar_lt 0 l).
    intros Hw.
(* Goal: False *)
    case: (Rbar_lt_le_dec 0 l) => Hl.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply Hw.
(* Goal: False *)
    case: (Rbar_le_lt_or_eq_dec _ _ Hl) => // {Hl} Hl Hl0.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -(Rbar_opp_involutive (Rbar_inv l)).
    replace (Rbar_opp (Rbar_inv l)) with (Rbar_inv (Rbar_opp l))
    by (case: (l) Hl0 => [x | | ] //= Hl0 ; apply f_equal ;
      field ; contradict Hl0 ; by apply f_equal).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    apply (filterlim_ext_loc (fun x => (- / - x))).
(* Goal: False *)
    case: l Hl {Hl0} => [l| |] //= Hl.
    apply Ropp_0_gt_lt_contravar in Hl.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    exists (mkposreal _ Hl) => /= x H.
    field ; apply Rlt_not_eq.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /= in H.
    apply Rabs_lt_between' in H.
    apply Rlt_le_trans with (1 := proj2 H), Req_le.
    apply Rplus_opp_r.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    exists 0 => x H.
    field ; by apply Rlt_not_eq.
    eapply filterlim_comp.
    2: apply filterlim_Rbar_opp.
    eapply filterlim_comp.
    apply filterlim_Rbar_opp.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult (Ropp a) (Ropp (u n)))) (Rbar_mult (Rbar_opp (Finite a)) (Lim_seq (fun n : nat => Ropp (u n)))) *)
(* Goal: forall n : nat, @eq R (Rmult (Ropp a) (Ropp (u n))) (Rmult a (u n)) *)
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult a (u n))) (Rbar_mult (Finite a) (Lim_seq u)) *)
    apply Hw.
    apply Rbar_opp_lt.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    rewrite Rbar_opp_involutive /= Ropp_0 ; by apply Hl.
    contradict Hl0.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
    rewrite -(Rbar_opp_involutive l) Hl0 /= ; apply f_equal ; ring.
(* Goal: False *)
  case: l => [l| |] //= Hl _.
  (* l \in R *)
  assert (H1: 0 < l / 2).
  apply Rdiv_lt_0_compat with (1 := Hl).
(* Goal: Rlt (IZR Z0) (IZR (Zpos (xO xH))) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  apply Rlt_R0_R2.
  intros P [eps HP].
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff He : 0 < Rmin (eps * ((l / 2) * l)) (l / 2).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (mkposreal _ He) => x /= Hx.
(* Goal: P (Rabs x) *)
  apply HP.
  assert (H2: l / 2 < x).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  apply Rle_lt_trans with (l - l / 2).
  apply Req_le ; field.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  apply Rabs_lt_between'.
(* Goal: Rlt N (Rabs x) *)
(* Goal: @filterlim R R Rabs (Rbar_locally m_infty) (Rbar_locally p_infty) *)
  apply Rlt_le_trans with (1 := Hx).
  apply Rmin_r.
  assert (H3: 0 < x).
  now apply Rlt_trans with (l / 2).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  replace (/ x + - / l) with (- (x - l) / (x * l)).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_div.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_Ropp.
  apply Rlt_div_l.
  apply Rabs_pos_lt, Rgt_not_eq.
  now apply Rmult_lt_0_compat.
  apply Rlt_le_trans with (eps * ((l / 2) * l)).
(* Goal: Rlt N (Rabs x) *)
(* Goal: @filterlim R R Rabs (Rbar_locally m_infty) (Rbar_locally p_infty) *)
  apply Rlt_le_trans with (1 := Hx).
  apply Rmin_l.
  apply Rmult_le_compat_l.
  apply Rlt_le, eps.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_mult.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite (Rabs_pos_eq l).
(* Goal: Rle (Rdiv (Rplus lsu liu) (IZR (Zpos (xO xH)))) (Rdiv (Rplus lsv liv) (IZR (Zpos (xO xH)))) *)
(* Goal: Rle (Rdiv (IZR Z0) (IZR (Zpos (xO xH)))) (Rdiv (IZR Z0) (IZR (Zpos (xO xH)))) *)
  apply Rmult_le_compat_r.
  now apply Rlt_le.
(* Goal: Rle (Rminus (u n) l) (Rabs (Rminus (u (Init.Nat.add n Nu)) l)) *)
  apply Rle_trans with (2 := Rle_abs _).
  now apply Rlt_le.
  now apply Rlt_le.
  apply Rgt_not_eq.
  now apply Rmult_lt_0_compat.
  field ; split ; apply Rgt_not_eq => //.
  apply Rmin_case.
  apply Rmult_lt_0_compat.
  apply cond_pos.
  now apply Rmult_lt_0_compat.
  exact H1.
  (* l = p_infty *)
  intros P [eps HP].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists (/eps) => n Hn.
(* Goal: P (Rabs x) *)
  apply HP.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Ropp_0 Rplus_0_r Rabs_Rinv.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(Rinv_involutive eps).
  apply Rinv_lt_contravar.
  apply Rmult_lt_0_compat.
  apply Rinv_0_lt_compat, eps.
  apply Rabs_pos_lt, Rgt_not_eq, Rlt_trans with (/eps).
  apply Rinv_0_lt_compat, eps.
  exact Hn.
  apply Rlt_le_trans with (2 := Rle_abs _).
  exact Hn.
  apply Rgt_not_eq, eps.
  apply Rgt_not_eq, Rlt_trans with (/eps).
  apply Rinv_0_lt_compat, eps.
  exact Hn.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_inv (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l -> l <> 0 ->
  is_lim_seq (fun n => / u n) (Rbar_inv l).
Proof.
(* Goal: forall (_ : is_lim_seq u l) (_ : not (@eq Rbar l (Finite (IZR Z0)))), is_lim_seq (fun n : nat => Rinv (u n)) (Rbar_inv l) *)
intros Hu Hl.
(* Goal: is_lim_seq (fun n : nat => Rabs (u n)) (Rbar_abs l) *)
apply filterlim_comp with (1 := Hu).
(* Goal: @filterlim R R Rinv (Rbar_locally l) (Rbar_locally (Rbar_inv l)) *)
now apply filterlim_Rbar_inv.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_inv (u : nat -> R) :
  ex_lim_seq u
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> Lim_seq u <> 0
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    -> ex_lim_seq (fun n => / u n).
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: ex_lim_seq (fun n : nat => Rdiv (u n) (v n)) *)
  apply Lim_seq_correct in H.
(* Goal: ex_lim_seq (fun n : nat => Rinv (u n)) *)
  exists (Rbar_inv (Lim_seq u)).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_seq_inv.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_inv (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> (Lim_seq u <> 0)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    -> Lim_seq (fun n => / u n) = Rbar_inv (Lim_seq u).
Proof.
(* Goal: False *)
  move => Hl Hu.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rinv (u n)) (Rbar_inv (Lim_seq u)) *)
  apply is_lim_seq_inv.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Lim_seq_correct.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  by apply Hu.
Qed.

(** Multiplication *)

Lemma filterlim_Rbar_mult :
  forall x y z,
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_Rbar_mult x y z ->
  filterlim (fun z => fst z * snd z) (filter_prod (Rbar_locally x) (Rbar_locally y)) (Rbar_locally z).
Proof.
  intros x y z.
  wlog: x y z / (Rbar_le 0 x).
    intros Hw.
(* Goal: False *)
    case: (Rbar_le_lt_dec 0 x) => Hx Hp.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply Hw.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    apply (filterlim_ext (fun z => - (- fst z * snd z))).
    intros t.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
    ring.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -(Rbar_opp_involutive z).
    eapply filterlim_comp.
    2: apply filterlim_Rbar_opp.
    assert (Hw' : filterlim (fun z => fst z * snd z) (filter_prod (Rbar_locally (Rbar_opp x)) (Rbar_locally y)) (Rbar_locally (Rbar_opp z))).
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult (Ropp a) (Ropp (u n)))) (Rbar_mult (Rbar_opp (Finite a)) (Lim_seq (fun n : nat => Ropp (u n)))) *)
(* Goal: forall n : nat, @eq R (Rmult (Ropp a) (Ropp (u n))) (Rmult a (u n)) *)
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult a (u n))) (Rbar_mult (Finite a) (Lim_seq u)) *)
    apply Hw.
    replace (Finite 0) with (Rbar_opp 0) by apply (f_equal Finite), Ropp_0.
(* Goal: Rbar_le (LimInf_seq u) (LimInf_seq v) *)
    apply Rbar_opp_le.
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
    by apply Rbar_lt_le.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply is_Rbar_mult_opp_l.
    clear Hw.
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
    intros P HP.
    specialize (Hw' P HP).
    destruct Hw' as [Q R H1 H2 H3].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    exists (fun x => Q (- x)) R.
    now apply filterlim_Rbar_opp.
    exact H2.
    intros u v HQ HR.
    exact (H3 _ _ HQ HR).
  wlog: x y z / (Rbar_le 0 y).
    intros Hw.
(* Goal: False *)
    case: (Rbar_le_lt_dec 0 y) => Hy Hx Hp.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply Hw.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    apply (filterlim_ext (fun z => - (fst z * -snd z))).
    intros t.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
    ring.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -(Rbar_opp_involutive z).
    eapply filterlim_comp.
    2: apply filterlim_Rbar_opp.
    assert (Hw' : filterlim (fun z => fst z * snd z) (filter_prod (Rbar_locally x) (Rbar_locally (Rbar_opp y))) (Rbar_locally (Rbar_opp z))).
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult (Ropp a) (Ropp (u n)))) (Rbar_mult (Rbar_opp (Finite a)) (Lim_seq (fun n : nat => Ropp (u n)))) *)
(* Goal: forall n : nat, @eq R (Rmult (Ropp a) (Ropp (u n))) (Rmult a (u n)) *)
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult a (u n))) (Rbar_mult (Finite a) (Lim_seq u)) *)
    apply Hw.
    replace (Finite 0) with (Rbar_opp 0) by apply (f_equal Finite), Ropp_0.
(* Goal: Rbar_le (LimInf_seq u) (LimInf_seq v) *)
    apply Rbar_opp_le.
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
    by apply Rbar_lt_le.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by [].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply is_Rbar_mult_opp_r.
    clear Hw.
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
    intros P HP.
    specialize (Hw' P HP).
    destruct Hw' as [Q R H1 H2 H3].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    exists Q (fun x => R (- x)).
    exact H1.
    now apply filterlim_Rbar_opp.
    intros u v HQ HR.
    exact (H3 _ _ HQ HR).
  wlog: x y z / (Rbar_le x y).
    intros Hw.
(* Goal: False *)
    case: (Rbar_le_lt_dec x y) => Hl Hx Hy Hp.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply Hw.
    assert (Hw' : filterlim (fun z => fst z * snd z) (filter_prod (Rbar_locally y) (Rbar_locally x)) (Rbar_locally z)).
    apply Hw ; try assumption.
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
(* Goal: Rbar_le (Finite M) (Sup_seq u) *)
    by apply Rbar_lt_le.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply is_Rbar_mult_sym.
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
    intros P HP.
    specialize (Hw' P HP).
    destruct Hw' as [Q R H1 H2 H3].
    exists R Q ; try assumption.
    intros u v HR HQ.
    simpl.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    rewrite Rmult_comm.
    exact (H3 _ _ HQ HR).
  case: x => [x| | ] ; case: y => [y| | ] ; case: z => [z| | ] Hl Hy Hx Hp ;
  try (by case: Hl) || (by case: Hx) || (by case: Hy).
(* x, y \in R *)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: Hp => <-.
  intros P [eps HP].
  assert (He: 0 < eps / (x + y + 1)).
(* Goal: Rlt (IZR Z0) (Rdiv (Rminus lf lg) (IZR (Zpos (xO xH)))) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  apply Rdiv_lt_0_compat.
  apply cond_pos.
  apply Rplus_le_lt_0_compat.
  now apply Rplus_le_le_0_compat.
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  apply Rlt_0_1.
  set (d := mkposreal _ (Rmin_stable_in_posreal (mkposreal _ Rlt_0_1) (mkposreal _ He))).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  exists (fun u => Rabs (u - x) < d) (fun v => Rabs (v - y) < d).
  now exists d.
  now exists d.
  simpl.
  intros u v Hu Hv.
(* Goal: P (Rabs x) *)
  apply HP.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /ball /= /AbsRing_ball /abs /minus /plus /opp /=.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace (u * v + - (x * y)) with (x * (v - y) + y * (u - x) + (u - x) * (v - y)) by ring.
  replace (pos eps) with (x * (eps / (x + y + 1)) + y * (eps / (x + y + 1)) + 1 * (eps / (x + y + 1))).
(* Goal: Rlt (Rabs (Rminus (Rminus (u n) (real (Lim_seq u))) (Rminus (u m) (real (Lim_seq u))))) (pos eps) *)
(* Goal: ex_finite_lim_seq u *)
  apply Rle_lt_trans with (1 := Rabs_triang _ _).
  apply Rplus_le_lt_compat.
  apply Rle_trans with (1 := Rabs_triang _ _).
  apply Rplus_le_compat.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_mult Rabs_pos_eq //.
  apply Rmult_le_compat_l with (1 := Hx).
  apply Rlt_le.
  apply Rlt_le_trans with (1 := Hv).
  apply Rmin_r.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_mult Rabs_pos_eq //.
  apply Rmult_le_compat_l with (1 := Hy).
  apply Rlt_le.
  apply Rlt_le_trans with (1 := Hu).
  apply Rmin_r.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_mult.
  apply Rmult_le_0_lt_compat ; try apply Rabs_pos.
  apply Rlt_le_trans with (1 := Hu).
  apply Rmin_l.
  apply Rlt_le_trans with (1 := Hv).
  apply Rmin_r.
  field.
  apply Rgt_not_eq.
  apply Rplus_le_lt_0_compat.
  now apply Rplus_le_le_0_compat.
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  apply Rlt_0_1.
(* x \in R and y = p_infty *)
  move: Hp ; unfold is_Rbar_mult, Rbar_mult'.
(* Goal: False *)
  case: Rle_dec => // Hx'.
(* Goal: False *)
  case: Rle_lt_or_eq_dec => {Hl Hx Hy Hx'} // Hx.
  move: Hp ; unfold is_Rbar_mult, Rbar_mult'.
(* Goal: False *)
  case: Rle_dec => // Hx'.
(* Goal: False *)
  case: Rle_lt_or_eq_dec => {Hl Hx Hy Hx'} // Hx _.
  intros P [N HN].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  exists (fun u => Rabs (u - x) < x / 2) (fun v => Rmax 0 (N / (x / 2)) < v).
  now exists (pos_div_2 (mkposreal _ Hx)).
  now exists (Rmax 0 (N / (x / 2))).
  intros u v Hu Hv.
  simpl.
(* Goal: P (u (S n)) *)
  apply HN.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  apply Rle_lt_trans with ((x - x / 2) * Rmax 0 (N / (x / 2))).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Rmax_case_strong => H.
  rewrite Rmult_0_r ; apply Rnot_lt_le ; contradict H ; apply Rlt_not_le.
(* Goal: @eq Rbar (@proj1_sig Rbar (fun l : Rbar => is_inf_seq u l) (ex_inf_seq u)) (@proj1_sig Rbar (fun l : Rbar => is_inf_seq (fun n : nat => Rbar_opp (Rbar_opp (u n))) l) (ex_inf_seq (fun n : nat => Rbar_opp (Rbar_opp (u n))))) *)
  repeat apply Rdiv_lt_0_compat => //.
(* Goal: Rlt (IZR Z0) (IZR (Zpos (xO xH))) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  by apply Rlt_R0_R2.
  apply Req_le ; field.
  by apply Rgt_not_eq.
  apply Rmult_le_0_lt_compat.
  lra.
(* Goal: Rle (IZR Z0) (Rmax (IZR Z0) M) *)
  apply Rmax_l.
(* Goal: @ball R_UniformSpace l (pos eps) (g x) *)
(* Goal: @filterlim T R g F (Rbar_locally p_infty) *)
(* Goal: @filterlim T R g F (Rbar_locally m_infty) *)
  now apply Rabs_lt_between'.
  exact Hv.
  move: Hp ; unfold is_Rbar_mult, Rbar_mult'.
(* Goal: False *)
  case: Rle_dec => // Hx'.
(* Goal: False *)
  case: Rle_lt_or_eq_dec => {Hl Hx Hy Hx'} // Hx.
(* l1 = l2 = p_infty *)
  clear.
  intros P [N HN].
  exists (fun u => 1 < u) (fun v => Rabs N < v).
  now exists 1.
  now exists (Rabs N).
  intros u v Hu Hv.
  simpl.
(* Goal: P (u (S n)) *)
  apply HN.
  apply Rle_lt_trans with (1 := Rle_abs _).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(Rmult_1_l (Rabs N)).
  apply Rmult_le_0_lt_compat.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_0_1.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rabs_pos.
  exact Hu.
  exact Hv.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_mult (u v : nat -> R) (l1 l2 l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_Rbar_mult l1 l2 l ->
  is_lim_seq (fun n => u n * v n) l.
Proof.
(* Goal: forall (_ : is_lim_seq u l1) (_ : is_lim_seq v l2) (_ : is_Rbar_mult l1 l2 l), is_lim_seq (fun n : nat => Rmult (u n) (v n)) l *)
intros Hu Hv Hp.
(* Goal: is_lim_seq (fun n : nat => Rmult (u n) (v n)) l *)
eapply filterlim_comp_2 ; try eassumption.
(* Goal: @filterlim (prod R R) R (fun x : prod R R => Rmult (@fst R R x) (@snd R R x)) (@filter_prod R R (Rbar_locally l1) (Rbar_locally l2)) (Rbar_locally l) *)
now apply filterlim_Rbar_mult.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_mult' (u v : nat -> R) (l1 l2 : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 ->
  is_lim_seq (fun n => u n * v n) (l1 * l2).
Proof.
(* Goal: forall (_ : is_lim_seq u (Finite l1)) (_ : is_lim_seq v (Finite l2)), is_lim_seq (fun n : nat => Rmult (u n) (v n)) (Finite (Rmult l1 l2)) *)
intros Hu Hv.
(* Goal: is_lim_seq (fun n : nat => Rdiv (u n) (v n)) l *)
eapply is_lim_seq_mult ; try eassumption.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
by [].
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_mult (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_mult (Lim_seq u) (Lim_seq v) ->
  ex_lim_seq (fun n => u n * v n).
Proof.
(* Goal: forall (_ : ex_lim_seq u) (_ : ex_lim_seq v) (_ : ex_Rbar_mult (Lim_seq u) (Lim_seq v)), ex_lim_seq (fun n : nat => Rmult (u n) (v n)) *)
  intros [lu Hu] [lv Hv] H ; exists (Rbar_mult lu lv).
(* Goal: is_lim_seq (fun n : nat => Rdiv (u n) (v n)) l *)
  eapply is_lim_seq_mult ; try eassumption.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(is_lim_seq_unique u lu) //.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(is_lim_seq_unique v lv) //.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_mult_correct.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_mult (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_mult (Lim_seq u) (Lim_seq v) ->
  Lim_seq (fun n => u n * v n) = Rbar_mult (Lim_seq u) (Lim_seq v).
Proof.
(* Goal: False *)
  move => H1 H2 Hl.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rmult (u n) (v n)) (Rbar_mult (Lim_seq u) (Lim_seq v)) *)
  eapply is_lim_seq_mult ; try apply Lim_seq_correct ; try eassumption.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_mult_correct.
Qed.

(** Multiplication by a scalar *)

Lemma filterlim_Rbar_mult_l :
  forall (a : R) (l : Rbar),
  filterlim (Rmult a) (Rbar_locally l) (Rbar_locally (Rbar_mult a l)).
Proof.
(* Goal: forall (a : R) (l : Rbar), @filterlim R R (fun x : R => Rmult x a) (Rbar_locally l) (Rbar_locally (Rbar_mult l (Finite a))) *)
  intros a l.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (Req_dec a 0) => [->|Ha].
  apply (filterlim_ext (fun _ => 0)).
  intros x.
  apply sym_eq, Rmult_0_l.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rbar_mult_0_l.
(* Goal: is_lim_seq (fun _ : nat => a) (Finite a) *)
  apply filterlim_const.
  eapply filterlim_comp_2.
(* Goal: is_lim_seq (fun _ : nat => a) (Finite a) *)
  apply filterlim_const.
  apply filterlim_id.
  eapply (filterlim_Rbar_mult a l).
  apply Rbar_mult_correct ; by case: l.
Qed.

Lemma filterlim_Rbar_mult_r :
  forall (a : R) (l : Rbar),
  filterlim (fun x => Rmult x a) (Rbar_locally l) (Rbar_locally (Rbar_mult l a)).
Proof.
(* Goal: forall (a : R) (l : Rbar), @filterlim R R (fun x : R => Rmult x a) (Rbar_locally l) (Rbar_locally (Rbar_mult l (Finite a))) *)
intros a l.
(* Goal: @filterlim R R (fun x : R => Rmult x a) (Rbar_locally l) (Rbar_locally (Rbar_mult l (Finite a))) *)
apply (filterlim_ext (fun x => a * x)).
(* Goal: forall x : R, @eq R (Rmult a x) (Rmult x a) *)
(* Goal: @filterlim R R (fun x : R => Rmult a x) (Rbar_locally l) (Rbar_locally (Rbar_mult l (Finite a))) *)
apply Rmult_comm.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
rewrite Rbar_mult_comm.
(* Goal: @filterlim R R (fun x : R => Rmult a x) (Rbar_locally l) (Rbar_locally (Rbar_mult (Finite a) l)) *)
apply filterlim_Rbar_mult_l.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_scal_l (u : nat -> R) (a : R) (lu : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u lu ->
  is_lim_seq (fun n => a * u n) (Rbar_mult a lu).
Proof.
(* Goal: forall _ : is_lim_seq u lu, is_lim_seq (fun n : nat => Rmult a (u n)) (Rbar_mult (Finite a) lu) *)
intros Hu H.
(* Goal: is_lim_seq (fun n : nat => Rabs (u n)) (Rbar_abs l) *)
apply filterlim_comp with (1 := Hu).
(* Goal: @filterlim R R (fun x : R => Rmult a x) (Rbar_locally l) (Rbar_locally (Rbar_mult (Finite a) l)) *)
by apply filterlim_Rbar_mult_l.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_scal_l (u : nat -> R) (a : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq (fun n => a * u n).
Proof.
(* Goal: False *)
  move => [l H].
(* Goal: ex_lim_seq (fun n : nat => Rmult a (u n)) *)
  exists (Rbar_mult a l).
(* Goal: is_lim_seq (fun n : nat => Rmult a (u n)) (Rbar_mult (Finite a) l) *)
  eapply is_lim_seq_scal_l ; try eassumption.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_scal_l (u : nat -> R) (a : R) :
  Lim_seq (fun n => a * u n) = Rbar_mult a (Lim_seq u).
Proof.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  case: (Req_dec a 0) => [ -> | Ha].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(Lim_seq_ext (fun _ => 0)) /=.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Lim_seq_const.
(* Goal: False *)
  case: (Lim_seq u) => [x | | ] //=.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Rmult_0_l.
(* Goal: False *)
  case: Rle_dec (Rle_refl 0) => // H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rlt_irrefl 0) => // _ _.
(* Goal: False *)
  case: Rle_dec (Rle_refl 0) => // H _.
(* Goal: False *)
  case: Rle_lt_or_eq_dec (Rlt_irrefl 0) => // _ _.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  move => n ; by rewrite Rmult_0_l.

(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  wlog: a u Ha / (0 < a) => [Hw | {Ha} Ha].
(* Goal: False *)
    case: (Rlt_le_dec 0 a) => Ha'.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply Hw.
(* Goal: False *)
    case: Ha' => // Ha'.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -(Lim_seq_ext (fun n => - a * - u n)).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -Rbar_mult_opp.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
    rewrite -Lim_seq_opp.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult (Ropp a) (Ropp (u n)))) (Rbar_mult (Rbar_opp (Finite a)) (Lim_seq (fun n : nat => Ropp (u n)))) *)
(* Goal: forall n : nat, @eq R (Rmult (Ropp a) (Ropp (u n))) (Rmult a (u n)) *)
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult a (u n))) (Rbar_mult (Finite a) (Lim_seq u)) *)
    apply Hw.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
    contradict Ha ; rewrite -(Ropp_involutive a) Ha ; ring.
(* Goal: Rgt (Ropp q) (IZR (Zpos xH)) *)
(* Goal: Rlt q (IZR Z0) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
    apply Ropp_lt_cancel ; by rewrite Ropp_0 Ropp_involutive.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
    move => n ; ring.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite /Lim_seq.
  rewrite {2}/LimSup_seq ; case: ex_LimSup_seq => ls Hs ;
(* Goal: @eq Rbar (@proj1_sig Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) (@exist Rbar (fun l : Rbar => is_sup_seq (fun n : nat => Rbar_mult (Finite a) (u n)) l) al Hau)) (Rbar_mult (Finite a) (@proj1_sig Rbar (fun l : Rbar => is_sup_seq u l) (@exist Rbar (fun l : Rbar => is_sup_seq u l) l Hu))) *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  rewrite {2}/LimInf_seq ; case: ex_LimInf_seq => li Hi ; simpl proj1_sig.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply (is_LimSup_seq_scal_pos a) in Hs => //.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply (is_LimInf_seq_scal_pos a) in Hi => //.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite (is_LimSup_seq_unique _ _ Hs).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite (is_LimInf_seq_unique _ _ Hi).
  case: ls {Hs} => [ls | | ] ; case: li {Hi} => [li | | ] //= ;
  case: (Rle_dec 0 a) (Rlt_le _ _ Ha) => // Ha' _ ;
  case: (Rle_lt_or_eq_dec 0 a Ha') (Rlt_not_eq _ _ Ha) => //= _ _ ;
  apply f_equal ; field.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_scal_r (u : nat -> R) (a : R) (lu : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u lu ->
    is_lim_seq (fun n => u n * a) (Rbar_mult lu a).
Proof.
(* Goal: False *)
  move => Hu Ha.
(* Goal: forall _ : Rbar_locally (Rbar_mult lu (Finite a)) Ha, @filtermap nat R (fun n : nat => Rmult (u n) a) eventually Ha *)
  apply is_lim_seq_ext with ((fun n : nat => a * u n)).
(* Goal: forall x : R, @eq R (Rmult a x) (Rmult x a) *)
(* Goal: @filterlim R R (fun x : R => Rmult a x) (Rbar_locally l) (Rbar_locally (Rbar_mult l (Finite a))) *)
  move => n ; by apply Rmult_comm.
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rbar_mult_comm.
(* Goal: is_lim_seq (fun n : nat => Rmult a (u n)) (Rbar_mult (Finite a) lu) *)
  apply is_lim_seq_scal_l.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  by apply Hu.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_scal_r (u : nat -> R) (a : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq (fun n => u n * a).
Proof.
(* Goal: False *)
  move => Hu.
(* Goal: ex_lim_seq (fun n : nat => Rmult (u n) a) *)
  apply ex_lim_seq_ext with ((fun n : nat => a * u n)) ; try by intuition.
(* Goal: ex_lim_seq (fun n : nat => Rmult a (u n)) *)
  apply ex_lim_seq_scal_l.
(* Goal: Rbar_le (u n) l *)
(* Goal: Rbar_le (Rbar_mult (Finite a) l) al *)
(* Goal: @eq Rbar (Sup_seq (fun n : nat => Rbar_mult (Finite a) (u n))) (Rbar_mult (Finite a) (Sup_seq u)) *)
  by apply Hu.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_scal_r (u : nat -> R) (a : R) :
  Lim_seq (fun n => u n * a) = Rbar_mult (Lim_seq u) a.
Proof.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite Rbar_mult_comm -Lim_seq_scal_l.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => Rmult (u n) a)) (Lim_seq (fun n : nat => Rmult a (u n))) *)
  apply Lim_seq_ext ; by intuition.
Qed.

(** Division *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_div (u v : nat -> R) (l1 l2 l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 -> l2 <> 0 ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_Rbar_div l1 l2 l ->
  is_lim_seq (fun n => u n / v n) l.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: is_lim_seq (fun n : nat => Rdiv (u n) (v n)) l *)
  eapply is_lim_seq_mult ; try eassumption.
(* Goal: is_lim_seq (fun n : nat => Rinv (u n)) (Rbar_inv (Lim_seq u)) *)
  now apply is_lim_seq_inv.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_div' (u v : nat -> R) (l1 l2 : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l1 -> is_lim_seq v l2 -> l2 <> 0 ->
  is_lim_seq (fun n => u n / v n) (l1 / l2).
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: is_lim_seq (fun n : nat => Rdiv (u n) (v n)) (Rbar_div (Lim_seq u) (Lim_seq v)) *)
  eapply is_lim_seq_div ; try eassumption.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  now contradict H1 ; case: H1 => ->.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by [].
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_div (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v -> Lim_seq v <> 0 ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_div (Lim_seq u) (Lim_seq v) ->
  ex_lim_seq (fun n => u n / v n).
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: ex_lim_seq (fun n : nat => Rdiv (u n) (v n)) *)
  apply Lim_seq_correct in H.
(* Goal: ex_lim_seq (fun n : nat => Rdiv (u n) (v n)) *)
  apply Lim_seq_correct in H0.
(* Goal: ex_lim_seq (fun n : nat => Rdiv (u n) (v n)) *)
  exists (Rbar_div (Lim_seq u) (Lim_seq v)).
(* Goal: is_lim_seq (fun n : nat => Rdiv (u n) (v n)) (Rbar_div (Lim_seq u) (Lim_seq v)) *)
  eapply is_lim_seq_div ; try eassumption.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_mult_correct.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_div (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq v -> (Lim_seq v <> 0) ->
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_Rbar_div (Lim_seq u) (Lim_seq v) ->
  Lim_seq (fun n => u n / v n) = Rbar_div (Lim_seq u) (Lim_seq v).
Proof.
(* Goal: False *)
  move => H0 H1 H2 H3.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rdiv (u n) (v n)) (Rbar_div (Lim_seq u) (Lim_seq v)) *)
  eapply is_lim_seq_div ; try apply Lim_seq_correct ; try eassumption.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rbar_mult_correct.
Qed.

(** *** Additional limits *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_adj (u v : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  (forall n, u n <= u (S n)) -> (forall n, v (S n) <= v n)
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> is_lim_seq (fun n => v n - u n) 0
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> ex_finite_lim_seq u /\ ex_finite_lim_seq v /\ Lim_seq u = Lim_seq v.
Proof.
(* Goal: False *)
  move => Hu Hv H0.
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff H : forall n, u n <= v n.
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff Eu : ex_finite_lim_seq u.
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
    split ; try auto.
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  suff Ev : ex_finite_lim_seq v.
(* Goal: and (ex_finite_lim_seq v) (@eq Rbar (Lim_seq u) (Lim_seq v)) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
    split ; try auto.

(* Goal: @eq Rbar (Lim_seq u) (Lim_seq v) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  apply is_lim_seq_unique in H0.
(* Goal: @eq Rbar (Lim_seq u) (Lim_seq v) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  rewrite Lim_seq_minus in H0 ; try by intuition.
(* Goal: ex_Rbar_minus (Lim_seq v) (Lim_seq u) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  apply ex_finite_lim_seq_correct in Eu.
(* Goal: ex_Rbar_minus (Lim_seq v) (Lim_seq u) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  apply ex_finite_lim_seq_correct in Ev.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(proj2 Eu) -(proj2 Ev) /= in H0 |- *.
(* Goal: @eq Rbar (Finite (real (Lim_seq u))) (Finite (real (Lim_seq v))) *)
(* Goal: ex_lim_seq v *)
(* Goal: ex_lim_seq u *)
(* Goal: ex_Rbar_minus (Lim_seq v) (Lim_seq u) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  apply Rbar_finite_eq in H0 ; apply Rbar_finite_eq.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply sym_eq, Rminus_diag_uniq, H0.
(* Goal: ex_finite_lim_seq u *)
  by apply ex_finite_lim_seq_correct.
(* Goal: ex_finite_lim_seq u *)
  by apply ex_finite_lim_seq_correct.
(* Goal: ex_Rbar_minus (Lim_seq v) (Lim_seq u) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  apply ex_finite_lim_seq_correct in Eu.
(* Goal: ex_Rbar_minus (Lim_seq v) (Lim_seq u) *)
(* Goal: ex_finite_lim_seq v *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  apply ex_finite_lim_seq_correct in Ev.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  by rewrite -(proj2 Eu) -(proj2 Ev).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply ex_finite_lim_seq_decr with (u O) => //.
(* Goal: forall n : nat, Rle (u O) (v n) *)
(* Goal: ex_finite_lim_seq u *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  move => n ; apply Rle_trans with (2 := H _).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: n => [ | n IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_trans with (2 := Hu _).
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply ex_finite_lim_seq_incr with (v O) => //.
(* Goal: forall n : nat, Rle (u n) (v O) *)
(* Goal: forall n : nat, Rle (u n) (v n) *)
  move => n ; apply Rle_trans with (1 := H _).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: n => [ | n IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  by apply Rle_refl.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_trans with (1 := Hv _).
(* Goal: forall n : nat, Rle (u n) (v n) *)
  move => n0 ; apply Rnot_lt_le ; move/Rminus_lt_0 => H.
(* Goal: False *)
  apply is_lim_seq_spec in H0.
(* Goal: False *)
  case: (H0 (mkposreal _ H)) => /= {H0} N H0.
(* Goal: forall _ : Rlt (pow q (Init.Nat.mul (S (S O)) N)) (IZR Z0), False *)
  move: (H0 _ (le_plus_r n0 N)) ; apply Rle_not_lt.
(* Goal: Rle (Rminus l (u n)) (Rabs (Rminus (u (Init.Nat.add n Nu)) l)) *)
  rewrite Rminus_0_r ; apply Rle_trans with (2 := Rabs_maj2 _).
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Ropp_minus_distr'.
(* Goal: Rle (Rminus (u n0) (v n0)) (Rminus (u (Init.Nat.add n0 N)) (v (Init.Nat.add n0 N))) *)
  apply Rplus_le_compat, Ropp_le_contravar.
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: (N) => [ | m IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  rewrite plus_0_r ; apply Rle_refl.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -plus_n_Sm ; by apply Rle_trans with (2 := Hu _).
(* Goal: Rle (v (Init.Nat.add n0 N)) (v n0) *)
  elim: (N) => [ | m IH].
(* Goal: Rle (u N) (u N) *)
(* Goal: Rle (u (S n)) (u N) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: forall eps : posreal, eventually (fun n : nat => Rlt (Rabs (Rminus (u n) (IZR Z0))) (pos eps)) *)
(* Goal: and (ex_lim_seq u) (is_finite (Lim_seq u)) *)
  rewrite plus_0_r ; apply Rle_refl.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -plus_n_Sm ; by apply Rle_trans with (1 := Hv _).
Qed.

(** Image by a continuous function *)

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_continuous (f : R -> R) (u : nat -> R) (l : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  continuity_pt f l -> is_lim_seq u l
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  -> is_lim_seq (fun n => f (u n)) (f l).
Proof.
(* Goal: False *)
  move => Cf Hu.
(* Goal: is_lim_seq (fun n : nat => f (u n)) (Finite (f l)) *)
  apply continuity_pt_filterlim in Cf.
(* Goal: is_lim_seq (fun n : nat => Rabs (u n)) (Rbar_abs l) *)
  apply filterlim_comp with (1 := Hu).
(* Goal: @filterlim R R f (Rbar_locally (Finite l)) (Rbar_locally (Finite (f l))) *)
  exact Cf.
Qed.

(** Absolute value *)

Lemma filterlim_Rabs :
  forall l : Rbar,
  filterlim Rabs (Rbar_locally l) (Rbar_locally (Rbar_abs l)).
Proof.
(* Goal: False *)
  case => [l| |] /=.

(* Goal: @filterlim R R Rabs (Rbar_locally (Finite l)) (Rbar_locally (Finite (Rabs l))) *)
(* Goal: @filterlim R R Rabs (Rbar_locally p_infty) (Rbar_locally p_infty) *)
(* Goal: @filterlim R R Rabs (Rbar_locally m_infty) (Rbar_locally p_infty) *)
  apply @filterlim_norm.

(* Goal: @filterlim R R Rabs (Rbar_locally m_infty) (Rbar_locally p_infty) *)
  intros P [N HP].
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => x Hx.
(* Goal: P (Rabs x) *)
  apply HP.
(* Goal: Rlt N (Rabs x) *)
(* Goal: @filterlim R R Rabs (Rbar_locally m_infty) (Rbar_locally p_infty) *)
  apply Rlt_le_trans with (1 := Hx).
(* Goal: Rle x (Rabs x) *)
(* Goal: @filterlim R R Rabs (Rbar_locally m_infty) (Rbar_locally p_infty) *)
  apply Rle_abs.

(* Goal: @filterlim R R Rabs (Rbar_locally m_infty) (Rbar_locally p_infty) *)
  intros P [N HP].
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  exists (-N) => x Hx.
(* Goal: P (Rabs x) *)
  apply HP.
(* Goal: Rlt N (Rabs x) *)
  apply Rlt_le_trans with (2 := Rabs_maj2 _), Ropp_lt_cancel.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by rewrite Ropp_involutive.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_abs (u : nat -> R) (l : Rbar) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u l -> is_lim_seq (fun n => Rabs (u n)) (Rbar_abs l).
Proof.
(* Goal: forall _ : is_lim_seq u l, is_lim_seq (fun n : nat => Rabs (u n)) (Rbar_abs l) *)
intros Hu.
(* Goal: is_lim_seq (fun n : nat => Rabs (u n)) (Rbar_abs l) *)
apply filterlim_comp with (1 := Hu).
(* Goal: @filterlim R R Rabs (Rbar_locally l) (Rbar_locally (Rbar_abs l)) *)
apply filterlim_Rabs.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma ex_lim_seq_abs (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u -> ex_lim_seq (fun n => Rabs (u n)).
Proof.
(* Goal: False *)
  move => [l Hu].
(* Goal: ex_lim_seq (fun n : nat => Rabs (u n)) *)
  exists (Rbar_abs l) ; by apply is_lim_seq_abs.
Qed.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma Lim_seq_abs (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  ex_lim_seq u ->
  Lim_seq (fun n => Rabs (u n)) = Rbar_abs (Lim_seq u).
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rabs (u n)) (Rbar_abs (Lim_seq u)) *)
  apply is_lim_seq_abs.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Lim_seq_correct.
Qed.

(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
Lemma is_lim_seq_abs_0 (u : nat -> R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  is_lim_seq u 0 <-> is_lim_seq (fun n => Rabs (u n)) 0.
Proof.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  split => Hu.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -Rabs_R0.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply (is_lim_seq_abs _ 0).
(* Goal: is_lim_seq u (Finite (IZR Z0)) *)
  apply is_lim_seq_spec in Hu.
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: False *)
  move => eps.
(* Goal: False *)
  case: (Hu eps) => {Hu} N Hu.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
  move: (Hu n Hn) ;
  by rewrite ?Rminus_0_r Rabs_Rabsolu.
Qed.

(** Geometric sequences *)

Lemma is_lim_seq_geom (q : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Rabs q < 1 -> is_lim_seq (fun n => q ^ n) 0.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, is_lim_seq (fun n : nat => pow q n) p_infty *)
  intros Hq.
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: False *)
  move => [e He] /=.
(* Goal: False *)
  case: (pow_lt_1_zero q Hq e He) => N H.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rminus_0_r ; by apply H.
Qed.
Lemma ex_lim_seq_geom (q : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Rabs q < 1 -> ex_lim_seq (fun n => q ^ n).
Proof.
(* Goal: forall _ : Rlt (Rabs q) (IZR (Zpos xH)), ex_lim_seq (fun n : nat => pow q n) *)
  move => Hq ; exists 0 ; by apply is_lim_seq_geom.
Qed.
Lemma Lim_seq_geom (q : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  Rabs q < 1 -> Lim_seq (fun n => q ^ n) = 0.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_seq_geom.
Qed.

Lemma is_lim_seq_geom_p (q : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  1 < q -> is_lim_seq (fun n => q ^ n) p_infty.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, is_lim_seq (fun n : nat => pow q n) p_infty *)
  intros Hq.
(* Goal: is_lim_seq (fun n : nat => pow q n) p_infty *)
  apply is_lim_seq_spec.
(* Goal: False *)
  move => M /=.
(* Goal: False *)
  case: (fun Hq => Pow_x_infinity q Hq (M+1)) => [ | N H].
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rlt_le_trans with (1 := Hq), Rle_abs.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  exists N => n Hn.
(* Goal: Rlt M (pow q n) *)
  apply Rlt_le_trans with (M+1).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -{1}(Rplus_0_r M) ; by apply Rplus_lt_compat_l, Rlt_0_1.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite -(Rabs_pos_eq (q^n)).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rge_le, H.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply pow_le, Rlt_le, Rlt_trans with (1 := Rlt_0_1).
Qed.
Lemma ex_lim_seq_geom_p (q : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  1 < q -> ex_lim_seq (fun n => q ^ n).
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, ex_lim_seq (fun n : nat => pow q n) *)
  move => Hq ; exists p_infty ; by apply is_lim_seq_geom_p.
Qed.
Lemma Lim_seq_geom_p (q : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  1 < q -> Lim_seq (fun n => q ^ n) = p_infty.
Proof.
(* Goal: forall _ : Rlt (IZR (Zpos xH)) q, @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  intros.
(* Goal: @eq Rbar (Lim_seq (fun n : nat => pow q n)) p_infty *)
  apply is_lim_seq_unique.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply is_lim_seq_geom_p.
Qed.

Lemma ex_lim_seq_geom_m (q : R) :
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  q <= -1 -> ~ ex_lim_seq (fun n => q ^ n).
Proof.
(* Goal: forall _ : Rle q (IZR (Zneg xH)), not (ex_lim_seq (fun n : nat => pow q n)) *)
  intros Hq [l H].
(* Goal: False *)
  apply is_lim_seq_spec in H.
(* Goal: False *)
  destruct l as [l| |].
(* Goal: False *)
  case: Hq => Hq.
(* ~ is_lim_seq (q^n) l *)
(* Goal: False *)
  case: (H (mkposreal _ Rlt_0_1)) => /= {H} N H.
(* Goal: False *)
  move: (fun n Hn => Rabs_lt_between_Rmax _ _ _ (proj1 (Rabs_lt_between' _ _ _) (H n Hn))).
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  set M := Rmax (l + 1) (- (l - 1)) => H0.
(* Goal: False *)
  case: (fun Hq => Pow_x_infinity q Hq M) => [ | N0 H1].
(* Goal: Rgt (Rabs q) (IZR (Zpos xH)) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Rabs_left.
(* Goal: Rgt (Ropp q) (IZR (Zpos xH)) *)
(* Goal: Rlt q (IZR Z0) *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  apply Ropp_lt_cancel ; by rewrite Ropp_involutive.
  apply Rlt_trans with (1 := Hq) ;
  apply Ropp_lt_cancel ;
  rewrite Ropp_involutive Ropp_0 ;
(* Goal: Rlt (IZR Z0) (IZR (Zpos xH)) *)
(* Goal: F (fun _ : T => False) *)
(* Goal: F (fun _ : T => False) *)
  by apply Rlt_0_1.
(* Goal: False *)
  move: (H0 _ (le_plus_l N N0)).
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_not_lt, Rge_le, H1, le_plus_r.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
(* ~ is_lim_seq ((-1)^n) l *)
(* Goal: False *)
  case: (H (mkposreal _ Rlt_0_1)) => /= {H} N H.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  rewrite Hq in H => {q Hq}.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  move: (H _ (le_n_2n _)) ; rewrite pow_1_even ; case/Rabs_lt_between' => _ H1.
(* Goal: False *)
(* Goal: False *)
  have H2 : (N <= S (2 * N))%nat.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply le_trans with (1 := le_n_2n _), le_n_Sn.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  move: (H _ H2) ; rewrite pow_1_odd ; case/Rabs_lt_between' => {H H2} H2 _.
(* Goal: False *)
(* Goal: False *)
(* Goal: False *)
  move: H1 ; apply Rle_not_lt, Rlt_le.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  pattern 1 at 2 ; replace (1) with ((-1)+2) by ring.
(* Goal: @eq R (Ropp (Rminus l (pos eps))) (Rplus (Ropp l) (pos eps)) *)
(* Goal: Rbar_lt (Rbar_opp (u n)) (Finite (Rplus (Ropp l) (pos eps))) *)
(* Goal: is_sup_seq u p_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp p_infty) *)
(* Goal: is_sup_seq u m_infty *)
(* Goal: is_inf_seq (fun n : nat => Rbar_opp (u n)) (Rbar_opp m_infty) *)
  replace (l+1) with ((l-1)+2) by ring.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rplus_lt_compat_r.
(* ~ Rbar_is_lim_seq (q^n) p_infty *)
(* Goal: False *)
  case: (H 0) => {H} N H.
(* Goal: False *)
(* Goal: False *)
  have H0 : (N <= S (2 * N))%nat.
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
    by apply le_trans with (1 := le_n_2n _), le_n_Sn.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  move: (H _ H0) ; apply Rle_not_lt ; rewrite /pow -/pow.
(* Goal: Rle (Rmult q (pow q (Init.Nat.mul (S (S O)) N))) (IZR Z0) *)
(* Goal: False *)
  apply Rmult_le_0_r.
  apply Rle_trans with (1 := Hq), Ropp_le_cancel ;
  rewrite Ropp_involutive Ropp_0 ;
(* Goal: le N (S (Init.Nat.mul (S (S O)) N)) *)
(* Goal: False *)
(* Goal: False *)
  by apply Rle_0_1.
(* Goal: Rle (IZR Z0) (pow q (Init.Nat.mul (S (S O)) N)) *)
  apply Ropp_le_contravar in Hq ; rewrite Ropp_involutive in Hq.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite pow_sqr -Rmult_opp_opp ; apply pow_le, Rmult_le_pos ;
  apply Rle_trans with (2 := Hq), Rle_0_1.
(* ~ Rbar_is_lim_seq (q^n) m_infty *)
(* Goal: False *)
  case: (H 0) => {H} N H.
(* Goal: False *)
  move: (H _ (le_n_2n _)).
(* Goal: forall _ : Rlt (pow q (Init.Nat.mul (S (S O)) N)) (IZR Z0), False *)
  apply Rle_not_lt.
(* Goal: Rle (IZR Z0) (pow q (Init.Nat.mul (S (S O)) N)) *)
  apply Ropp_le_contravar in Hq ; rewrite Ropp_involutive in Hq.
(* Goal: @filtermap R R Ropp (Rbar_locally m_infty) P *)
  rewrite pow_sqr -Rmult_opp_opp ; apply pow_le, Rmult_le_pos ;
  apply Rle_trans with (2 := Hq), Rle_0_1.
Qed.

(** Rbar_loc_seq converges *)

Lemma is_lim_seq_Rbar_loc_seq (x : Rbar) :
  is_lim_seq (Rbar_loc_seq x) x.
Proof.
(* Goal: is_lim_seq (Rbar_loc_seq x) x *)
  intros P HP.
(* Goal: @filtermap nat R (Rbar_loc_seq x) eventually P *)
  apply filterlim_Rbar_loc_seq.
(* Goal: Rbar_locally' x P *)
  now apply Rbar_locally'_le.
Qed.
