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

Copyright (C) 2011-2015 Sylvie Boldo
#<br />#
Copyright (C) 2011-2015 Catherine Lelay
#<br />#
Copyright (C) 2011-2015 Guillaume Melquiond

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
COPYING file for more details.
*)

Require Import Reals Even Div2 Omega Psatz.
Require Import mathcomp.ssreflect.ssreflect.
Require Import Rcomplements Rbar Lim_seq Lub Hierarchy.
Require Import Continuity Derive Seq_fct Series.

(** This file describes power series: #&Sigma; a<sub>k</sub>
x<sup>k</sup>#. It contains definition, equivalence with the standard
library, differentiability, integrability, and many results about the
convergence circle. *)

Section Definitions.

(** * Definition *)

Context {K : AbsRing} {V : NormedModule K}.

Definition is_pseries (a : nat -> V) (x:K) (l : V) :=
  is_series (fun k => scal (pow_n x k) (a k)) l.

Definition ex_pseries (a : nat -> V) (x : K) :=
  ex_series (fun k => scal (pow_n x k) (a k)).

End Definitions.

Definition PSeries (a : nat -> R) (x : R) : R :=
  Series (fun k => a k * x ^ k).

Lemma ex_pseries_dec {V : NormedModule R_AbsRing} (a : nat -> R) (x : R) :
  {ex_pseries a x} + {~ ex_pseries a x}.
Proof.
(* Goal: sumbool (@ex_pseries R_AbsRing R_NormedModule a x) (not (@ex_pseries R_AbsRing R_NormedModule a x)) *)
  apply ex_series_dec.
Qed.

Lemma is_pseries_R (a : nat -> R) (x l : R) :
  is_pseries a x l <-> is_series (fun n : nat => a n * x ^ n) l.
Proof.
  split ; apply is_series_ext ;
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
  intros n ; rewrite pow_n_pow /= ; apply Rmult_comm.
Qed.

Lemma ex_pseries_R (a : nat -> R) (x : R) :
  ex_pseries a x <-> ex_series (fun n : nat => a n * x ^ n).
Proof.
  split ; apply ex_series_ext ;
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
  intros n ; rewrite pow_n_pow /= ; apply Rmult_comm.
Qed.

Lemma PSeries_eq (a : nat -> R) (x : R) :
  PSeries a x = Series (fun k => scal (pow_n x k) (a k)).
Proof.
(* Goal: @eq R (PSeries a x) (PSeries (fun n : nat => match n with | O => @zero (NormedModule.AbelianGroup R_AbsRing R_NormedModule) | S n0 => a (S n0) end) x) *)
  apply Series_ext.
(* Goal: forall n : nat, @eq R (Rmult (a n) (pow x n)) (@scal R_Ring R_ModuleSpace (@pow_n R_Ring x n) (a n)) *)
  intros n.
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
  apply Rmult_comm.
Qed.

Lemma PSeries_1 (a : nat -> R) :
  PSeries a 1 = Series a.
Proof.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Series_ext => n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite pow1 Rmult_1_r.
Qed.
Lemma ex_pseries_1 (a : nat -> R) :
  ex_pseries a 1 <-> ex_series a.
Proof.
(* Goal: iff (@ex_pseries R_AbsRing R_NormedModule a (IZR (Zpos xH))) (@ex_series R_AbsRing R_NormedModule a) *)
  assert (forall n : nat, scal (pow_n 1 n) (a n) = a n).
(* Goal: forall n : nat, @eq (ModuleSpace.sort R_Ring R_ModuleSpace) (@scal R_Ring R_ModuleSpace (@pow_n R_Ring (IZR (Zpos xH)) n) (a n)) (a n) *)
(* Goal: iff (@ex_pseries R_AbsRing R_NormedModule a (IZR (Zpos xH))) (@ex_series R_AbsRing R_NormedModule a) *)
    now intros n ; rewrite pow_n_pow pow1 scal_one.
(* Goal: iff (@ex_pseries R_AbsRing R_NormedModule a (IZR (Zpos xH))) (@ex_series R_AbsRing R_NormedModule a) *)
  split ; apply ex_series_ext => n ; by rewrite H.
Qed.

Lemma is_pseries_unique (a : nat -> R) (x l : R) :
  is_pseries a x l -> PSeries a x = l.
Proof.
(* Goal: forall n : nat, @eq R (Rdiv r (INR (S n))) (Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  move => Ha; rewrite PSeries_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_series_unique.
Qed.
Lemma PSeries_correct (a : nat -> R) (x : R) :
  ex_pseries a x -> is_pseries a x (PSeries a x).
Proof.
(* Goal: forall n : nat, @eq R (Rdiv r (INR (S n))) (Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  move => Ha; rewrite PSeries_eq.
(* Goal: @is_pseries R_AbsRing R_NormedModule a x (Series (fun k : nat => @scal R_Ring R_ModuleSpace (@pow_n R_Ring x k) (a k))) *)
  apply Series_correct.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.
Qed.

(** Equivalence with standard library Reals *)

Lemma is_pseries_Reals (a : nat -> R) (x l : R) :
  is_pseries a x l <-> Pser a x l.
Proof.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  split => H.
(* Goal: Pser a x l *)
(* Goal: @is_pseries R_AbsRing R_NormedModule a x l *)
  move => e He ; set eps := mkposreal e He.
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : ge n N), Rlt (R_dist (sum_f_R0 (fun n0 : nat => Rmult (a n0) (pow x n0)) n) l) e) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule a x l *)
  apply (is_lim_seq_spec _ l) in H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (H eps) => {H} N H.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists N => n Hn.
(* Goal: Rlt (R_dist (sum_f_R0 (fun n : nat => Rmult (a n) (pow x n)) n) l) e *)
(* Goal: @is_pseries R_AbsRing R_NormedModule a x l *)
  rewrite <- sum_n_Reals.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (sum_n_ext _ (fun n0 : nat => scal (pow_n x n0) (a n0))).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H.
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
  intros k; rewrite pow_n_pow /=; apply Rmult_comm.
(* Goal: @is_series R_AbsRing R_NormedModule An l *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
  apply (is_lim_seq_spec _ l).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => eps.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (H eps (cond_pos eps)) => {H} N H.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists N => n Hn.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (sum_n_ext _ (fun n0 : nat => a n0 * x ^ n0)).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_n_Reals.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H.
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  intros; now rewrite Rmult_comm pow_n_pow.
Qed.

(** Extensionality *)

Section Extensionality.

Context {K : AbsRing} {V : NormedModule K}.

Lemma is_pseries_ext (a b : nat -> V) (x : K) (l:V) :
  (forall n, a n = b n) -> (is_pseries a x l)
    -> is_pseries b x l.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Heq Ha.
(* Goal: @is_pseries K V b x l *)
  apply is_series_ext with (2 := Ha).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Heq.
Qed.

Lemma ex_pseries_ext (a b : nat -> V) (x : K) :
  (forall n, a n = b n) -> ex_pseries a x
    -> ex_pseries b x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Heq [l Ha].
(* Goal: @ex_pseries K V b x *)
  exists l ; by apply is_pseries_ext with a.
Qed.

End Extensionality.

Lemma PSeries_ext (a b : nat -> R) (x : R) :
  (forall n, a n = b n) -> PSeries a x = PSeries b x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Heq.
(* Goal: @eq R (PSeries a x) (PSeries (fun n : nat => match n with | O => @zero (NormedModule.AbelianGroup R_AbsRing R_NormedModule) | S n0 => a (S n0) end) x) *)
  apply Series_ext.
  move => n ;
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Heq.
Qed.

(** * Convergence circle *)
(** A power series is always defined at 0 *)

Section ConvergenceCircle.

Context {K : AbsRing} {V : NormedModule K}.

Lemma is_pseries_0 (a : nat -> V) :
  is_pseries a zero (a O).
Proof.
(* Goal: @is_pseries K V a (@zero (AbsRing.AbelianGroup K)) (a O) *)
  apply filterlim_ext with (fun _ => a O).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => [ | n IH] /=.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite sum_O scal_one.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_Sn -IH /=.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite mult_zero_l.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite scal_zero_l plus_zero_r.
(* Goal: @filterlim nat (NormedModule.sort K V) (fun _ : nat => @opp (NormedModule.AbelianGroup K V) (a O)) eventually (@locally (NormedModule.UniformSpace K V) (@opp (NormedModule.AbelianGroup K V) (a O))) *)
  apply filterlim_const.
Qed.

Lemma ex_pseries_0 (a : nat -> V) :
  ex_pseries a zero.
Proof.
(* Goal: @ex_pseries K V a (@zero (AbsRing.AbelianGroup K)) *)
  exists (a O) ; by apply is_pseries_0.
Qed.

End ConvergenceCircle.

Lemma PSeries_0 (a : nat -> R) :
  PSeries a 0 = a O.
Proof.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite PSeries_eq.
(* Goal: @eq R (Series (fun k : nat => @scal R_Ring R_ModuleSpace (@pow_n R_Ring (IZR Z0) k) (a k))) (a O) *)
  apply is_series_unique.
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) (IZR Z0) (Rdiv (Derive_n f O (IZR Z0)) (INR (fact O))) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  apply @is_pseries_0.
Qed.

(** Convergence disk *)
Definition CV_disk (a : nat -> R) (r : R) :=
  ex_series (fun n => Rabs (a n * r^n)).

Lemma CV_disk_le (a : nat -> R) (r1 r2 : R) :
  Rabs r1 <= Rabs r2 -> CV_disk a r2 -> CV_disk a r1.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => H.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply @ex_series_le => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /norm /= /abs /= Rabs_Rabsolu.
(* Goal: Rle (Rabs (Rmult x (Rdiv (Rmult (PS_derive a n) (pow x n)) (INR (S n))))) (Rmult (Rabs x) M) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  rewrite ?Rabs_mult ; apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rle (Rabs (pow r1 n)) (Rabs (pow r2 n)) *)
  rewrite -?RPow_abs ; apply pow_incr ; split.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H.
Qed.
Lemma CV_disk_correct (a : nat -> R) (x : R) :
  CV_disk a x -> ex_pseries a x.
Proof.
(* Goal: forall _ : CV_disk a x, @ex_pseries R_AbsRing R_NormedModule a x *)
  intros H; apply ex_series_Rabs.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n))) *)
  apply ex_series_ext with (2:=H).
(* Goal: forall n : nat, @eq (NormedModule.sort R_AbsRing R_NormedModule) (Rabs (Rmult (a n) (pow x n))) (Rabs (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n))) *)
  intros n; apply f_equal.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite Rmult_comm pow_n_pow.
Qed.

Lemma CV_disk_0 (a : nat -> R) :
  CV_disk a 0.
Proof.
(* Goal: CV_disk a (IZR Z0) *)
  exists (Rabs (a O)).
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (IZR Z0) n))) (Rabs (a O)) *)
  apply (is_lim_seq_ext (fun _ => Rabs (a O)) _ (Rabs (a O))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => /= [ | n IH].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite sum_O Rmult_1_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite sum_Sn /= Rmult_0_l Rmult_0_r Rabs_R0 /plus /= Rplus_0_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_lim_seq_const.
Qed.

Definition CV_radius (a : nat -> R) : Rbar :=
  Lub_Rbar (CV_disk a).

Lemma CV_radius_ge_0 (a : nat -> R) :
  Rbar_le (Finite 0) (CV_radius a).
Proof.
  rewrite /CV_radius /Lub_Rbar ;
  case: ex_lub_Rbar => /= l Hl.
(* Goal: match l with | Finite y => Rle (IZR Z0) y | p_infty => True | m_infty => False end *)
  apply Hl, CV_disk_0.
Qed.

Lemma CV_radius_bounded (a : nat -> R) :
  is_lub_Rbar (fun r => exists M, forall n, Rabs (a n * r ^ n) <= M) (CV_radius a).
Proof.
  rewrite /CV_radius /Lub_Rbar ;
  case: ex_lub_Rbar => cv /= [ub lub].
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  split.

(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => r /= [M Hr].

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have : forall y, Rabs y < Rabs r -> (CV_disk a) y.
(* Goal: forall n : nat, @eq R (Rdiv r (INR (S n))) (Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    move => y Hy ; rewrite /CV_disk /=.
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  set l := (Rabs (y / r)).
  assert (ex_series (fun n => M * l ^ n)).
  apply ex_series_ext with (fun n : nat => scal M (l ^ n)).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by elim.
(* Goal: False *)
  apply: ex_series_scal_l.
  apply ex_series_geom.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /l Rabs_Rabsolu Rabs_div.
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply Rlt_div_l.
  apply Rle_lt_trans with (2 := Hy), Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Rmult_1_l.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H : (Rabs r <> 0).
  apply Rgt_not_eq, Rle_lt_trans with (2 := Hy), Rabs_pos.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  contradict H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite H Rabs_R0.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply @ex_series_le with (2:=H) => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /norm /= /abs /= Rabs_Rabsolu.
  replace (Rabs (a n * y ^ n)) with (Rabs (a n * r ^ n) * l^n).
(* Goal: Rle (Rmult (Rabs (Rmult (a n) (pow x n))) (Rabs x)) (Rmult M (Rabs x)) *)
  apply Rmult_le_compat_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply pow_le ; by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hr.
  rewrite ?Rabs_mult Rmult_assoc ; apply Rmult_eq_compat_l.

(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /l RPow_abs -Rabs_mult.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  apply f_equal.
  elim: n  => /= [ | n IH].
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  ring.
(* Goal: @eq R (Rdiv r (INR (S n))) (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n)))) *)
(* Goal: Rle (IZR Z0) (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n)))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  rewrite -IH ; field.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Hr0 : Rabs r <> 0.
    apply Rgt_not_eq, Rle_lt_trans with (2 := Hy), Rabs_pos.
  contradict Hr0 ; by rewrite Hr0 Rabs_R0.

(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => H.

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have : forall y, Rabs y < Rabs r -> Rbar_le (Finite (y)) cv.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => y Hy.
(* Goal: Rle (IZR Z0) cv *)
(* Goal: CV_disk a (Rplus cv (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: False *)
  apply ub.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply (H y Hy).

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Hc0 : Rbar_le (Finite 0) cv.
  apply ub, CV_disk_0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (cv) Hc0 => [c | | ] // Hc0 Hcv.

(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Rle_lt_dec r 0) => Hr0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rle_trans with (1 := Hr0).

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H0 : forall e, 0 < e <= r -> r - e <= c.
    intros.
    apply Hcv.
(* Goal: Rlt cv (Rabs (Rplus cv (IZR (Zpos xH)))) *)
(* Goal: @eq Rbar (Finite cv) p_infty *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
    apply Rlt_le_trans with (2 := Rle_abs _).
    rewrite Rabs_pos_eq ; lra.

(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rnot_lt_le => H1.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H2: (c < ((c+r)/2) < r).
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
    lra.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H3 : 0 < ((r-c)/2) <= r.
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
    unfold Rbar_le in Hc0 ; lra.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (H0 _ H3).
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
  lra.

(* lub *)
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => b Hb.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply lub => x Hx.
  apply Hb.
  apply ex_series_lim_0 in Hx.
  apply is_lim_seq_spec in Hx.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Hx (mkposreal _ Rlt_0_1)) => /= {Hx} N Hx.

  set M := fix f N := match N with
    | O => Rabs (a O * x ^ O)
    | S n => Rmax (f n) (Rabs (a (n) * x ^ (n))) end.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (Rmax (M N) 1) => n.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (le_lt_dec N n) => Hn.
(* Goal: Rle (Rabs (Rmult (a (S n)) (Rmult x (pow x n)))) (Rmax (Rabs (a O)) (Rmult (Rabs x) M)) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rle_trans with (2 := Rmax_r _ _).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (Hx n Hn).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rminus_0_r Rabs_Rabsolu.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_le.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
  apply Rle_trans with (2 := Rmax_l _ _).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: N n Hn {Hx} => [ | N IH] /= n Hn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply lt_n_O in Hn.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
  apply lt_n_Sm_le, le_lt_eq_dec in Hn ; case: Hn => Hn.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
  apply Rle_trans with (2 := Rmax_l _ _).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply IH.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite Hn ; by apply Rle_trans with (2 := Rmax_r _ _), Rle_refl.
Qed.

(** Convergence theorems *)

Lemma CV_disk_inside (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> ex_series (fun n => Rabs (a n * x ^ n)).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
  assert (H : ~ ~ ex_series (fun n => Rabs (a n * x ^ n))).
(* Goal: not (not (@ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))))) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
    contradict Ha.
(* Goal: not (Rbar_lt (Finite (Rabs x)) (CV_radius a)) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
    apply Rbar_le_not_lt.
    rewrite /CV_radius /Lub_Rbar ;
    case: ex_lub_Rbar => l /= [ub lub].
(* Goal: False *)
    apply: lub => r Hr.
(* Goal: not (not (@ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))))) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
    apply Rnot_lt_le ; contradict Ha.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move: Hr.
(* Goal: forall _ : CV_disk a r, @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
    apply CV_disk_le.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le, Rlt_le_trans with (2 := Rle_abs _).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by case: (ex_series_dec (fun n => Rabs (a n * x ^ n))).
Qed.
Lemma CV_radius_inside (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> ex_pseries a x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_disk_correct, CV_disk_inside.
Qed.

Lemma CV_disk_outside (a : nat -> R) (x : R) :
  Rbar_lt (CV_radius a) (Finite (Rabs x))
    -> ~ is_lim_seq (fun n => a n * x ^ n) 0.
Proof.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (CV_radius_bounded a) => ub lub.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H : ~ (fun r : R => exists M : R, forall n : nat, Rabs (a n * r ^ n) <= M) x.
(* Goal: not (Rbar_lt (Finite (Rabs x)) (CV_radius a)) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
    contradict Hx ; apply Rbar_le_not_lt.
(* Goal: Rle (IZR Z0) cv *)
(* Goal: CV_disk a (Rplus cv (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: False *)
    apply ub.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: Hx => M Hx.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists M => n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite Rabs_mult RPow_abs Rabs_Rabsolu -Rabs_mult.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  contradict H.

(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply is_lim_seq_spec in H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (H (mkposreal _ Rlt_0_1)) => /= {Hx} N Hx.

  set M := fix f N := match N with
    | O => Rabs (a O * x ^ O)
    | S n => Rmax (f n) (Rabs (a (n) * x ^ (n))) end.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (Rmax (M N) 1) => n.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (le_lt_dec N n) => Hn.
(* Goal: Rle (Rabs (Rmult (a (S n)) (Rmult x (pow x n)))) (Rmax (Rabs (a O)) (Rmult (Rabs x) M)) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rle_trans with (2 := Rmax_r _ _).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (Hx n Hn).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rminus_0_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_le.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
  apply Rle_trans with (2 := Rmax_l _ _).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: N n Hn {Hx} => [ | N IH] /= n Hn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply lt_n_O in Hn.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
  apply lt_n_Sm_le, le_lt_eq_dec in Hn ; case: Hn => Hn.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rmax (M N) (Rabs (Rmult (a N) (pow x N)))) *)
  apply Rle_trans with (2 := Rmax_l _ _).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply IH.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite Hn ; by apply Rle_trans with (2 := Rmax_r _ _), Rle_refl.
Qed.

Lemma CV_radius_ext (a b : nat -> R) :
  (forall n, a n = b n) -> CV_radius a = CV_radius b.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Heq.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /CV_radius /Lub_Rbar.
  case: ex_lub_Rbar => la [ub_a lub_a] ;
  case: ex_lub_Rbar => lb [ub_b lub_b] /=.
(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
  apply Rbar_le_antisym.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply lub_a => x Hx.
(* Goal: Rbar_le (Finite x) lb *)
(* Goal: Rbar_le lb la *)
  apply ub_b ; move: Hx.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply ex_series_ext => n ; by rewrite Heq.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply lub_b => x Hx.
(* Goal: Rbar_le (Finite x) la *)
  apply ub_a ; move: Hx.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply ex_series_ext => n ; by rewrite Heq.
Qed.

(** ** Convergence criteria *)
(** D'Alembert criterion for power series *)

Lemma CV_disk_DAlembert_aux (a : nat -> R) (x k : R) :
  x <> 0 -> (forall n, a n <> 0) ->
  (is_lim_seq (fun n => Rabs (a (S n) / a n)) k
    <-> is_lim_seq (fun n => Rabs ((a (S n) * x^(S n)) / (a n * x ^ n))) (Rabs x * k)).
Proof.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  move => Hx Ha ; split => H.
  evar (l : Rbar).
  replace (Finite (Rabs x * k)) with l.
  apply is_lim_seq_ext with (fun n => Rabs x * Rabs (a (S n) / a n)).
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
  move => n ; rewrite ?Rabs_div => //=.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite ?Rabs_mult.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
  split ; apply Rabs_no_R0 => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply pow_nonzero.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rmult_integral_contrapositive_currified => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply pow_nonzero.
  apply is_lim_seq_scal_l.
  apply H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by simpl.
  evar (l : Rbar).
  replace (Finite k) with l.
  apply is_lim_seq_ext with (fun n : nat => /Rabs x * Rabs (a (S n) * x ^ S n / (a n * x ^ n))).
(* Goal: forall n : nat, @eq R (Rdiv r (INR (S n))) (Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  move => n ; rewrite /= ?Rabs_div ?Rabs_mult.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
  repeat split ; apply Rabs_no_R0 => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply pow_nonzero.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rmult_integral_contrapositive_currified => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply pow_nonzero.
  apply is_lim_seq_scal_l.
  apply H.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  apply Rbar_finite_eq ; field.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rabs_no_R0 => //.
Qed.

Lemma CV_disk_DAlembert (a : nat -> R) (x:R) l :
  (forall n:nat, a n <> 0) ->
  is_lim_seq (fun n:nat => Rabs (a (S n) / a n)) (Finite l) ->
  (l = 0 \/ (l <> 0 /\ Rabs x < / l))
    -> CV_disk a x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hl H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Req_dec x 0) => Hx.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Hx.
(* Goal: CV_disk a (IZR Z0) *)
  exists (Rabs (a O)).
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (IZR Z0) n))) (Rabs (a O)) *)
  apply (is_lim_seq_ext (fun _ => Rabs (a O)) _ (Rabs (a 0%nat))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => /= [ | n IH].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite sum_O Rmult_1_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite sum_Sn /= Rmult_0_l Rmult_0_r Rabs_R0 /plus /= Rplus_0_r.
(* Goal: is_lim_seq (fun _ : nat => Rabs (a O)) (Finite (Rabs (a O))) *)
(* Goal: CV_disk a x *)
  apply is_lim_seq_const.

(* Goal: CV_disk a x *)
  apply ex_series_DAlembert with (Rabs x * l).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: H => H.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite H Rmult_0_r ; by apply Rlt_0_1.
(* Goal: Rlt (Rmult (Rabs x) l) (IZR (Zpos xH)) *)
(* Goal: forall n : nat, not (@eq R (Rmult (a n) (pow x n)) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow x (S n))) (Rmult (a n) (pow x n)))) (Finite (Rmult (Rabs x) l)) *)
  replace 1 with (/ l * l) by (field ; apply H).
(* Goal: Rlt (Rmult (Rabs x) l) (Rmult (Rinv l) l) *)
(* Goal: forall n : nat, not (@eq R (Rmult (a n) (pow x n)) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow x (S n))) (Rmult (a n) (pow x n)))) (Finite (Rmult (Rabs x) l)) *)
  apply Rmult_lt_compat_r.
(* Goal: Rlt (IZR Z0) l *)
(* Goal: Rlt (Rabs x) (Rinv l) *)
(* Goal: forall n : nat, not (@eq R (Rmult (a n) (pow x n)) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow x (S n))) (Rmult (a n) (pow x n)))) (Finite (Rmult (Rabs x) l)) *)
  apply Rnot_le_lt ; case => H0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: H => H.
(* Goal: not (Rlt M (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rle_not_lt.
(* Goal: Rle (Rinv l) (Rabs x) *)
(* Goal: False *)
(* Goal: Rlt (Rabs x) (Rinv l) *)
(* Goal: forall n : nat, not (@eq R (Rmult (a n) (pow x n)) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow x (S n))) (Rmult (a n) (pow x n)))) (Finite (Rmult (Rabs x) l)) *)
  apply Rlt_le, Rlt_le_trans with 0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rinv_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by case: H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H.
(* Goal: forall n : nat, not (@eq R (Rmult (a n) (pow (Rplus cv (IZR (Zpos xH))) n)) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow (Rplus cv (IZR (Zpos xH))) (S n))) (Rmult (a n) (pow (Rplus cv (IZR (Zpos xH))) n)))) (Finite (IZR Z0)) *)
(* Goal: False *)
(* Goal: False *)
  move => n ; apply Rmult_integral_contrapositive_currified.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply pow_nonzero.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_disk_DAlembert_aux.
Qed.

Lemma CV_radius_finite_DAlembert (a : nat -> R) (l : R) :
  (forall n:nat, a n <> 0) -> 0 < l ->
  is_lim_seq (fun n:nat => Rabs (a (S n) / a n)) l ->
  CV_radius a = Finite (/l).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hl Hda.
(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
  apply Rbar_le_antisym.
  rewrite /CV_radius /Lub_Rbar ;
  case: ex_lub_Rbar => /= cv [ub lub].
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply lub => x Hax.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Rle_lt_dec x 0) => Hx.
(* Goal: Rbar_le (Finite x) (Finite (Rinv l)) *)
(* Goal: Rbar_le (Finite x) (Finite (Rinv l)) *)
(* Goal: Rbar_le (Finite (Rinv l)) (CV_radius a) *)
  apply Rlt_le, Rle_lt_trans with 0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hx.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rinv_0_lt_compat.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(Rabs_pos_eq x (Rlt_le _ _ Hx)).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(Rmult_1_l (/l)).
(* Goal: Rbar_le (Finite (Rabs x)) (Finite (Rmult (IZR (Zpos xH)) (Rinv l))) *)
(* Goal: Rbar_le (Finite (Rinv l)) (CV_radius a) *)
  replace (Rabs x) with ((Rabs x * l) /l) by (field ; apply Rgt_not_eq, Hl).
(* Goal: Rle (Rmult (Rabs (Rmult (a n) (pow x n))) (Rabs x)) (Rmult M (Rabs x)) *)
  apply Rmult_le_compat_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_le, Rinv_0_lt_compat.
(* Goal: Rle (Rmult (Rabs x) l) (IZR (Zpos xH)) *)
(* Goal: Rbar_le (Finite (Rinv l)) (CV_radius a) *)
  apply Rnot_lt_le.
(* Goal: not (Rlt (IZR (Zpos xH)) (Rmult (Rabs x) l)) *)
(* Goal: Rbar_le (Finite (Rinv l)) (CV_radius a) *)
  contradict Hax.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have : CV_disk a x -> is_lim_seq (fun n => a n * x ^ n) 0.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => H.
(* Goal: is_lim_seq (fun n : nat => Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n)) (Finite (IZR Z0)) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply ex_series_lim_0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply ex_series_Rabs.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => H H0.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (H H0) => {H H0}.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply not_ex_series_DAlembert with (Rabs x * l) => //.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => n.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rmult_integral_contrapositive_currified => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply pow_nonzero, Rgt_not_eq.
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow x (S n))) (Rmult (a n) (pow x n)))) (Finite (Rmult (Rabs x) l)) *)
(* Goal: Rbar_le (Finite (Rinv l)) (CV_radius a) *)
  apply CV_disk_DAlembert_aux.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rgt_not_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hda.

(* Goal: Rbar_le (Finite (Rinv l)) (CV_radius a) *)
  apply Rbar_not_lt_le.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move : (CV_disk_outside a).
  rewrite /CV_radius /Lub_Rbar ;
  case: ex_lub_Rbar ;
  case => [cv | | ] /= [ub lub] Hnot_ex H ; try by auto.
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  suff H0 : cv < ((cv+/l)/2) < /l.
(* Goal: False *)
(* Goal: and (Rlt cv (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) (Rinv l)) *)
(* Goal: False *)
  absurd (ex_series (fun n => Rabs (a n * ((cv+/l)/2)^n))).

(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  suff H1 : cv < Rabs ((cv + / l) / 2).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (Hnot_ex ((cv + / l) / 2) H1) => {Hnot_ex} Hnot_ex.
(* Goal: not (@ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) n)))) *)
(* Goal: Rlt cv (Rabs (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH))))) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) n))) *)
(* Goal: and (Rlt cv (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) (Rinv l)) *)
(* Goal: False *)
  contradict Hnot_ex ; by apply ex_series_lim_0, ex_series_Rabs.
(* Goal: Rlt cv (Rabs (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH))))) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) n))) *)
(* Goal: and (Rlt cv (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) (Rinv l)) *)
(* Goal: False *)
  apply Rlt_le_trans with (2 := Rle_abs _), H0.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) n))) *)
(* Goal: and (Rlt cv (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) (Rinv l)) *)
(* Goal: False *)
  apply (CV_disk_DAlembert) with l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hda.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  right ; split.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rgt_not_eq.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rabs_pos_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H0.
(* Goal: Rle (IZR Z0) (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) *)
(* Goal: and (Rlt cv (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus cv (Rinv l)) (IZR (Zpos (xO xH)))) (Rinv l)) *)
(* Goal: False *)
  apply Rlt_le, Rle_lt_trans with (2 := proj1 H0).
(* Goal: Rle (IZR Z0) cv *)
(* Goal: CV_disk a (Rplus cv (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: False *)
  apply ub.
(* Goal: CV_disk a (IZR Z0) *)
  exists (Rabs (a O)).
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (IZR Z0) n))) (Rabs (a O)) *)
  apply (is_lim_seq_ext (fun _ => Rabs (a O)) _ (Rabs (a 0%nat))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
    elim => [ | n IH] /=.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite sum_O Rmult_1_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite sum_Sn /= Rmult_0_l Rmult_0_r Rabs_R0 /plus /= Rplus_0_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply is_lim_seq_const.
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
  lra.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (ub 0) => //.
(* Goal: CV_disk a (IZR Z0) *)
  exists (Rabs (a O)).
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (IZR Z0) n))) (Rabs (a O)) *)
  apply (is_lim_seq_ext (fun _ => Rabs (a O)) _ (Rabs (a 0%nat))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
    elim => [ | n IH] /=.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite sum_O Rmult_1_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite sum_Sn /= Rmult_0_l Rmult_0_r Rabs_R0 /plus /= Rplus_0_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply is_lim_seq_const.
Qed.

Lemma CV_radius_infinite_DAlembert (a : nat -> R) :
  (forall n:nat, a n <> 0) ->
  is_lim_seq (fun n:nat => Rabs (a (S n) / a n)) 0 ->
  CV_radius a = p_infty.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hda.
  rewrite /CV_radius /Lub_Rbar ;
  case: ex_lub_Rbar ; case => [cv | | ] //= [ub lub] ;
  have : False => //.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H : CV_disk a (cv + 1).
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H : 0 < cv + 1.
(* Goal: Rlt (IZR Z0) (Rplus cv (IZR (Zpos xH))) *)
(* Goal: CV_disk a (Rplus cv (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: False *)
      apply Rlt_le_trans with (0+1).
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
      rewrite Rplus_0_l ; by apply Rlt_0_1.
(* Goal: Rle (Rplus (IZR Z0) (IZR (Zpos xH))) (Rplus cv (IZR (Zpos xH))) *)
(* Goal: CV_disk a (Rplus cv (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: False *)
      apply Rplus_le_compat_r.
(* Goal: Rle (IZR Z0) cv *)
(* Goal: CV_disk a (Rplus cv (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: False *)
      apply ub.
(* Goal: CV_disk a (IZR Z0) *)
      exists (Rabs (a O)).
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (IZR Z0) n))) (Rabs (a O)) *)
      apply (is_lim_seq_ext (fun _ => Rabs (a O)) _ (Rabs (a 0%nat))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
      elim => [ | k IH] /=.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by rewrite sum_O Rmult_1_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by rewrite sum_Sn /= Rmult_0_l Rmult_0_r Rabs_R0 /plus /= Rplus_0_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by apply is_lim_seq_const.

(* Goal: CV_disk a (Rplus cv (IZR (Zpos xH))) *)
(* Goal: False *)
(* Goal: False *)
    apply ex_series_DAlembert with 0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_0_1.
(* Goal: forall n : nat, not (@eq R (Rmult (a n) (pow (Rplus cv (IZR (Zpos xH))) n)) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow (Rplus cv (IZR (Zpos xH))) (S n))) (Rmult (a n) (pow (Rplus cv (IZR (Zpos xH))) n)))) (Finite (IZR Z0)) *)
(* Goal: False *)
(* Goal: False *)
    move => n ; apply Rmult_integral_contrapositive_currified.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by[].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rgt_not_eq, pow_lt.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(Rmult_0_r (Rabs (cv + 1))).
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rmult (a (S n)) (pow (Rplus cv (IZR (Zpos xH))) (S n))) (Rmult (a n) (pow (Rplus cv (IZR (Zpos xH))) n)))) (Finite (Rmult (Rabs (Rplus cv (IZR (Zpos xH)))) (IZR Z0))) *)
(* Goal: False *)
(* Goal: False *)
  apply (CV_disk_DAlembert_aux a (cv + 1)).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rgt_not_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (ub (cv+1) H).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rbar_lt_not_le, Rlt_n_Sn.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (ub 0) => //.
(* Goal: CV_disk a (IZR Z0) *)
  exists (Rabs (a O)).
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow (IZR Z0) n))) (Rabs (a O)) *)
  apply (is_lim_seq_ext (fun _ => Rabs (a O)) _ (Rabs (a 0%nat))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => [ | k IH] /=.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite sum_O Rmult_1_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite sum_Sn /= Rmult_0_l Rmult_0_r Rabs_R0 /plus /= Rplus_0_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_lim_seq_const.
Qed.

(** Equivalence with standard library Reals *)

Lemma CV_radius_Reals_0 (a : nat -> R) (r : posreal) :
  Rbar_lt (Finite r) (CV_radius a) -> CVN_r (fun n x => a n * x ^ n) r.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hr.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /CVN_r /Boule.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H := CV_radius_bounded a.
(* Goal: @sigT (forall _ : nat, R) (fun An : forall _ : nat, R => @sig R (fun l : R => and (Un_cv (fun n : nat => sum_f_R0 (fun k : nat => Rabs (An k)) n) l) (forall (n : nat) (y : R) (_ : Rlt (Rabs (Rminus y (IZR Z0))) (pos r)), Rle (Rabs (Rmult (a n) (pow y n))) (An n)))) *)
  exists (fun n => Rabs (a n * r ^ n)).
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  exists (Series (fun n => Rabs (a n * r ^ n))) ; split.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(Rabs_pos_eq r (Rlt_le _ _ (cond_pos r))) in Hr.
(* Goal: Un_cv (fun n : nat => sum_f_R0 (fun k : nat => Rabs (Rabs (Rmult (a k) (pow (pos r) k)))) n) (Series (fun n : nat => Rabs (Rmult (a n) (pow (pos r) n)))) *)
(* Goal: forall (n : nat) (y : R) (_ : Rlt (Rabs (Rminus y (IZR Z0))) (pos r)), Rle (Rabs (Rmult (a n) (pow y n))) (Rabs (Rmult (a n) (pow (pos r) n))) *)
  apply CV_disk_inside in Hr.
  apply Lim_seq_correct' in Hr ;
  rewrite -/(Series (fun n : nat => Rabs (a n * r ^ n))) in Hr.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => e He.
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : ge n N), Rlt (R_dist (sum_f_R0 (fun k : nat => Rabs (Rabs (Rmult (a k) (pow (pos r) k)))) n) (Series (fun n0 : nat => Rabs (Rmult (a n0) (pow (pos r) n0))))) e) *)
(* Goal: forall (n : nat) (y : R) (_ : Rlt (Rabs (Rminus y (IZR Z0))) (pos r)), Rle (Rabs (Rmult (a n) (pow y n))) (Rabs (Rmult (a n) (pow (pos r) n))) *)
  apply is_lim_seq_spec in Hr.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Hr (mkposreal e He)) => /= {Hr} N Hr.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists N => n Hn.
  replace (sum_f_R0 (fun k : nat => Rabs (Rabs (a k * r ^ k))) n)
    with (sum_f_R0 (fun k : nat => (Rabs (a k * r ^ k))) n).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite <- sum_n_Reals; by apply Hr.
(* Goal: @eq R (Rplus (sum_f_R0 (fun k : nat => Rmult (a (Init.Nat.mul (S (S O)) k)) (pow (pow x (S (S O))) k)) (S (Nat.div2 n))) (Rmult x (sum_f_R0 (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n)))) (sum_f_R0 (fun n : nat => Rmult (a n) (pow x n)) (S (S (Nat.double (Nat.div2 n))))) *)
(* Goal: @filterlim nat R (fun n : nat => Rplus (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.mul (S (S O)) k)) (pow (pow x (S (S O))) k)) (Nat.div2 n)) (Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end)) eventually (@locally (NormedModule.UniformSpace R_AbsRing R_NormedModule) (Rplus l1 (Rmult x l2))) *)
  elim: n {Hn} => /= [ | n IH] ; rewrite Rabs_Rabsolu.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite IH.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => n x Hx.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite ?Rabs_mult -?RPow_abs.
(* Goal: Rle (Rmult M (IZR (Zpos xH))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  apply pow_incr ; split.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (Rabs_pos_eq r).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rminus_0_r in Hx.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_le.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_le, r.
Qed.

Lemma CV_radius_Reals_1 (a : nat -> R) (r : posreal) :
  CVN_r (fun n x => a n * x ^ n) r -> Rbar_le (Finite r) (CV_radius a).
Proof.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case => An [l [H H0]].
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H1 : is_lub_Rbar (CV_disk a) (CV_radius a).
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    rewrite /CV_radius /Lub_Rbar ; by case: ex_lub_Rbar.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H2 : forall (y : R), 0 < y < r -> (CV_disk a y).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => y Hy.
(* Goal: CV_disk a y *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    apply @ex_series_le with An.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    move => n ; rewrite /norm /= /abs /= Rabs_Rabsolu.
(* Goal: Rbar_le (Finite y) (CV_radius (PS_derive a)) *)
    apply H0 ; rewrite /Boule Rabs_pos_eq Rminus_0_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le, Hy.
(* Goal: @ex_series R_AbsRing R_NormedModule An *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    exists l.
(* Goal: @is_series R_AbsRing R_NormedModule An l *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    apply (is_lim_seq_spec _ l).
(* Goal: is_lim_seq' (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) An) (Finite l) *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    intros eps.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (H eps (cond_pos eps)) => N {H} H.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists N => n Hn.
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    set v := sum_n _ _.
(* Goal: Rlt (Rabs (Rminus v l)) (pos eps) *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    replace v with (sum_n (fun k : nat => Rabs (An k)) n).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite sum_n_Reals; by apply H.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /v {v}.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
    elim: n {Hn} => /= [ | n IH].
(* Goal: @eq R (@sum_n R_AbelianGroup (fun k : nat => Rabs (An k)) O) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) An O) *)
(* Goal: @eq R (@sum_n R_AbelianGroup (fun k : nat => Rabs (An k)) (S n)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) An (S n)) *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    rewrite !sum_O ; apply Rabs_pos_eq.
(* Goal: Rle (IZR Z0) (An O) *)
(* Goal: @eq R (@sum_n R_AbelianGroup (fun k : nat => Rabs (An k)) (S n)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) An (S n)) *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    apply Rle_trans with (Rabs (a O * 0 ^ O)).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rabs_pos.
(* Goal: Rle (Rabs (Rmult (a (S n)) (pow (IZR Z0) (S n)))) (An (S n)) *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    apply H0 ; rewrite /Boule Rminus_0_r Rabs_R0 ; by apply r.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite !sum_Sn IH Rabs_pos_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: Rle (IZR Z0) (An (S n)) *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    apply Rle_trans with (Rabs (a (S n) * 0 ^ (S n))).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rabs_pos.
(* Goal: Rle (Rabs (Rmult (a (S n)) (pow (IZR Z0) (S n)))) (An (S n)) *)
(* Goal: Rbar_le (Finite (pos r)) (CV_radius a) *)
    apply H0 ; rewrite /Boule Rminus_0_r Rabs_R0 ; by apply r.
  have H3  : forall y, 0 < y < r -> Rbar_le (Finite (y)) (CV_radius a).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => y Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply H1, H2.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H4 := CV_radius_ge_0 a.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (CV_radius a) H3 H4 => /= [cv | | ] // H3 H4.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rnot_lt_le => /= H5.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H6 : 0 < (cv+r)/2 < r.
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
      lra.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move: (H3 _ H6).
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
    lra.
Qed.

Lemma CV_radius_Reals_2 (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
  -> exists r : posreal, CVU (fun n x => sum_f_R0 (fun k => a k * x ^ k) n) (PSeries a) x r.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H : exists r : posreal, Rabs x < r /\ Rbar_lt (Finite r) (CV_radius a).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (CV_radius a) Hx => /= [cv | | ] Hx.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H : 0 < (Rabs x + cv)/2.
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
      generalize (Rabs_pos x) ; lra.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (mkposreal _ H) => /=.
(* Goal: and (Rlt (Rabs x) (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH))))) (Rlt (Rdiv (Rplus (Rabs x) cv) (IZR (Zpos (xO xH)))) cv) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
    lra.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H : 0 < Rabs x + 1.
(* Goal: Rlt (IZR Z0) (Rplus (Rabs x) (IZR (Zpos xH))) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) True) *)
(* Goal: @ex posreal (fun r : posreal => and (Rlt (Rabs x) (pos r)) False) *)
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
      apply Rle_lt_0_plus_1, Rabs_pos.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (mkposreal _ H) => /=.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    split.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_plus_1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: H => r H.
(* Goal: @ex posreal (fun r : posreal => CVU (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (PSeries a) x r) *)
  apply CVN_CVU_r with r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_radius_Reals_0, H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H.
Qed.

(** * Operations *)

(** Addition of two power series *)

Section PS_plus.

Context {K : AbsRing} {V : NormedModule K}.

Definition PS_plus (a b : nat -> V) (n : nat) : V := plus (a n)  (b n).

Lemma is_pseries_plus (a b : nat -> V) (x :K) (la lb : V) :
  is_pseries a x la -> is_pseries b x lb
    -> is_pseries (PS_plus a b) x (plus la lb).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb.
  apply filterlim_ext with (f:=
    (fun n => plus (sum_n (fun k => scal (pow_n x k) (a k)) n) (sum_n (fun k => scal (pow_n x k) (b k)) n))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => [ | n IH].
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  simpl ; rewrite /PS_plus !sum_O.
(* Goal: @eq (NormedModule.sort K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x O) (a O))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x O) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (a O))) *)
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  now repeat rewrite scal_one.
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  simpl ; rewrite !sum_Sn -IH /PS_plus.
  generalize (sum_n (fun k : nat => scal (pow_n x k) (a k)) n) => a' ;
  generalize (sum_n (fun k : nat => scal (pow_n x k) (b k)) n) => b'.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  repeat rewrite -plus_assoc; apply f_equal.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  rewrite plus_comm -plus_assoc; apply f_equal.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S n)) (b (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S n)) (a (S n)))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S n)) (@plus (NormedModule.AbelianGroup K V) (a (S n)) (b (S n)))) *)
(* Goal: @filterlim nat (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (fun n : nat => @plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (b k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@plus (NormedModule.AbelianGroup K V) la lb)) *)
  rewrite scal_distr_l; apply plus_comm.
(* Goal: @filterlim nat (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (fun n : nat => @plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (b k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@plus (NormedModule.AbelianGroup K V) la lb)) *)
  now apply filterlim_comp_2 with (3 := filterlim_plus _ _).
Qed.

Lemma ex_pseries_plus (a b : nat -> V) (x : K) :
  ex_pseries a x -> ex_pseries b x
    -> ex_pseries (PS_plus a b) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => [la Ha] [lb Hb].
(* Goal: @ex_pseries K V (PS_plus a b) x *)
  exists (plus la lb).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_pseries_plus.
Qed.

End PS_plus.

Lemma PSeries_plus (a b : nat -> R) (x : R) :
  ex_pseries a x -> ex_pseries b x
    -> PSeries (PS_plus a b) x = PSeries a x + PSeries b x.
Proof.
(* Goal: forall (_ : @ex_pseries R_AbsRing R_NormedModule a x) (_ : @ex_pseries R_AbsRing R_NormedModule b x), @eq R (PSeries (@PS_plus R_AbsRing R_NormedModule a b) x) (Rplus (PSeries a x) (PSeries b x)) *)
  intros Ha Hb.
(* Goal: @eq R (PSeries (PS_mult a b) x) (Rmult (PSeries a x) (PSeries b x)) *)
  apply is_pseries_unique.
  apply: is_pseries_plus ; rewrite PSeries_eq ;
(* Goal: @is_pseries R_AbsRing R_NormedModule a x (Series (fun k : nat => @scal R_Ring R_ModuleSpace (@pow_n R_Ring x k) (a k))) *)
  apply Series_correct.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.
  by apply Hb.
Qed.

Lemma CV_disk_plus (a b : nat -> R) (x : R) :
  (CV_disk a x) -> (CV_disk b x)
  -> (CV_disk (PS_plus a b) x).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (ex_series_plus _ _ Ha Hb).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply @ex_series_le => n ; rewrite /norm /= /abs /= Rabs_Rabsolu.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rmult_plus_distr_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_triang.
Qed.
Lemma CV_radius_plus (a b : nat -> R) :
  Rbar_le (Rbar_min (CV_radius a) (CV_radius b)) (CV_radius (PS_plus a b)).
Proof.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  wlog: a b / (Rbar_le (CV_radius a) (CV_radius b)) => [ Hw | Hle ].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (Rbar_le_lt_dec (CV_radius a) (CV_radius b)) => Hle.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hw.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rbar_min_comm.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite (CV_radius_ext (PS_plus a b) (PS_plus b a)).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hw, Rbar_lt_le.
    now intros n ; apply Rplus_comm.

  replace (Rbar_min (CV_radius a) (CV_radius b)) with (CV_radius a).

  apply is_lub_Rbar_subset
    with (CV_disk (PS_plus a b))
    (fun x => (CV_disk a x) /\ (CV_disk b x)).
(* Goal: forall (n : nat) (x0 : R) (_ : Rbar_lt (Finite (Rabs x0)) (Finite (Rplus (Rabs x) (IZR (Zpos xH))))), and (ex_derive_n f n x0) (Rle (Rabs (Derive_n f n x0)) M) *)
(* Goal: @eq Rbar (Finite (real (Finite (Rplus (Rabs x) (IZR (Zpos xH)))))) (Finite (Rplus (Rabs x) (IZR (Zpos xH)))) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  move => x [Ha Hb] ; by apply CV_disk_plus.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite /CV_radius /Lub_Rbar ; by case: ex_lub_Rbar.

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Ha : is_lub_Rbar (fun x : R => CV_disk a x) (CV_radius a).
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    rewrite /CV_radius /Lub_Rbar ; by case: ex_lub_Rbar.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Hb : is_lub_Rbar (fun x : R => CV_disk b x) (CV_radius b).
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    rewrite /CV_radius /Lub_Rbar ; by case: ex_lub_Rbar.

(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  split.
  intros y [Hay Hby].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.

(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Rbar_le_lt_or_eq_dec _ _ (CV_radius_ge_0 a)) => Ha0.
  intros c Hc.
  assert (Rbar_le 0 c).
    apply Hc.
    split ; by apply CV_disk_0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: c Hc H => [c | | ] //= Hc H.
  2: by case: (CV_radius a).
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rbar_not_lt_le => Hac.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (Rbar_lt_le_trans _ _ _ Hac Hle) => Hbc.

(* Goal: not (Rbar_lt (Finite (Rabs x)) (CV_radius a)) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
  eapply Rbar_le_not_lt.
  apply (Hc ((c + Rbar_min (c + 1) (CV_radius a)) / 2)).

  assert (Rbar_lt (Rabs ((c + Rbar_min (c + 1) (CV_radius a)) / 2)) (CV_radius a)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (CV_radius a) Hac => //= l Hl.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rabs_pos_eq.
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rlt_div_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_0_2.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
    replace (l * 2) with (l+l) by ring.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rplus_lt_le_compat => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rmin_r.
    apply Rdiv_le_0_compat.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rplus_le_le_0_compat => //.
    apply Rmin_case.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rplus_le_le_0_compat => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rle_0_1.
    now eapply Rle_trans, Rlt_le, Hl.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_0_2.
  split ; apply CV_disk_inside.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
  now eapply Rbar_lt_le_trans, Hle.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (CV_radius a) Hac => [l | | ] //= Hl.
  apply Rmin_case.
(* Goal: Rlt (Rminus (IZR (Zpos xH)) (pos eps)) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply Rlt_div_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_0_2.
  apply Rminus_lt_0 ; simpl ; ring_simplify.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_0_1.
(* Goal: Rlt (Rminus (IZR (Zpos xH)) (pos eps)) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply Rlt_div_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_0_2.
  apply Rminus_lt_0 ; simpl ; ring_simplify.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Rplus_comm -Rminus_lt_0.
(* Goal: Rlt (Rminus (IZR (Zpos xH)) (pos eps)) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply Rlt_div_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_0_2.
  apply Rminus_lt_0 ; simpl ; ring_simplify.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_0_1.

(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Ha0 in Ha Hle |- *.
  intros c Hc.
  apply Hc ; split ; by apply CV_disk_0.

(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply Rbar_min_case_strong => //.
(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
  by apply Rbar_le_antisym.
Qed.

(** Scalar multiplication *)

Section PS_scal.

Context {K : AbsRing} {V : NormedModule K}.

Definition PS_scal (c : K) (a : nat -> V) (n : nat) : V := scal c (a n).

Lemma is_pseries_scal (c : K) (a : nat -> V) (x : K) (l : V) :
  mult x c = mult c x -> is_pseries a x l -> is_pseries (PS_scal c a) x (scal c l).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx Ha.
(* Goal: @is_pseries K V (PS_scal c a) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l) *)
  apply (filterlim_ext (fun n => scal c (sum_n (fun k => scal (pow_n x k) (a k)) n))).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => [ | n IH].
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  simpl ; rewrite /PS_scal.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite !sum_O.
(* Goal: @eq (NormedModule.sort K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x O) (a O))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x O) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (a O))) *)
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  now repeat rewrite scal_one.
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  simpl ; rewrite !sum_Sn -IH /PS_scal.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  rewrite scal_distr_l; apply f_equal.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite 2! scal_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) c (@pow_n (AbsRing.Ring K) x (S n))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@pow_n (AbsRing.Ring K) x (S n)) c) (a (S n))) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  apply f_equal2.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -/(pow_n x (S n)).
(* Goal: @eq (AbelianGroup.sort (AbsRing.AbelianGroup K)) (@one (AbsRing.Ring K)) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n))) *)
  clear -Hx.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: (S n) => {n} /= [ | n IH].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite mult_one_l mult_one_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite -mult_assoc -IH 2!mult_assoc Hx.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  now apply filterlim_comp with (2 := filterlim_scal_r _ _).
Qed.

Lemma ex_pseries_scal (c : K) (a : nat -> V) (x : K) :
  mult x c = mult c x -> ex_pseries a x -> ex_pseries (PS_scal c a) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx [l Ha].
  exists (scal c l).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_pseries_scal.
Qed.

End PS_scal.

Lemma PSeries_scal (c : R) (a : nat -> R) (x : R) :
  PSeries (PS_scal c a) x = c * PSeries a x.
Proof.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Series_scal_l.
(* Goal: @eq R (PSeries a x) (PSeries (fun n : nat => match n with | O => @zero (NormedModule.AbelianGroup R_AbsRing R_NormedModule) | S n0 => a (S n0) end) x) *)
  apply Series_ext.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => n /=.
(* Goal: @eq R (Rmult (@PS_scal R_AbsRing R_NormedModule c a n) (pow x n)) (Rmult c (Rmult (a n) (pow x n))) *)
  apply Rmult_assoc.
Qed.

Lemma CV_disk_scal (c : R) (a : nat -> R) (x : R) :
  (CV_disk a x)
  -> (CV_disk (PS_scal c a) x).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha.
(* Goal: CV_disk (PS_scal_r c a) x *)
  apply ex_series_ext with (fun n => Rabs c * Rabs (a n * x ^ n)).
  move => n ; rewrite -Rabs_mult ; apply f_equal ;
  by rewrite /PS_scal /= Rmult_assoc.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rmult (Rabs c) (Rabs (Rmult (a n) (pow x n)))) *)
  apply @ex_series_scal.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Ha.
Qed.

Lemma CV_radius_scal (c : R) (a : nat -> R) : c <> 0 ->
  (CV_radius (PS_scal c a)) = (CV_radius a).
Proof.
  rewrite /CV_radius /Lub_Rbar ;
  case: ex_lub_Rbar => la [ub_a lub_a] ;
  case: ex_lub_Rbar => lc [ub_c lub_c] /= Hc.
(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
  apply Rbar_le_antisym.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply lub_a => x Hx.
(* Goal: Rbar_le (Finite x) lc *)
(* Goal: Rbar_le lc la *)
  apply ub_c.
(* Goal: CV_disk a x *)
(* Goal: Rbar_le lc la *)
  assert (CV_disk (PS_scal (/c) (PS_scal c a)) x).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_disk_scal.
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
  move: H ; apply ex_series_ext => n.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  apply f_equal.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  rewrite /PS_scal /scal /= /mult /= ; by field.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply lub_c => x Hx.
(* Goal: Rbar_le (Finite x) la *)
  apply ub_a.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_disk_scal.
Qed.

Definition PS_scal_r (c : R) (a : nat -> R) (n : nat) : R :=
  a n * c.
Lemma PSeries_scal_r (c : R) (a : nat -> R) (x : R) :
  PSeries (PS_scal_r c a) x = PSeries a x * c.
Proof.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Series_scal_r.
(* Goal: @eq R (PSeries a x) (PSeries (fun n : nat => match n with | O => @zero (NormedModule.AbelianGroup R_AbsRing R_NormedModule) | S n0 => a (S n0) end) x) *)
  apply Series_ext.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => n /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite /PS_scal_r ; ring.
Qed.

Lemma CV_disk_scal_r (c : R) (a : nat -> R) (x : R) :
  (CV_disk a x)
  -> (CV_disk (PS_scal_r c a) x).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha.
(* Goal: CV_disk (PS_scal_r c a) x *)
  apply ex_series_ext with (fun n => Rabs c * Rabs (a n * x ^ n)).
  move => n ; rewrite -Rabs_mult ; apply f_equal ;
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite /PS_scal_r /= ; ring.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply @ex_series_scal ; apply Ha.
Qed.
Lemma CV_radius_scal_r (c : R) (a : nat -> R) : c <> 0 ->
  (CV_radius (PS_scal_r c a)) = (CV_radius a).
Proof.
(* Goal: forall _ : not (@eq R c (IZR Z0)), @eq Rbar (CV_radius (PS_scal_r c a)) (CV_radius a) *)
  intros Hc.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(CV_radius_scal c a).
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply CV_radius_ext => n.
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
  apply Rmult_comm.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
Qed.

(** Multiplication and division by a variable *)

Section PS_incr.

Context {K : AbsRing} {V : NormedModule K}.

Definition PS_incr_1 (a : nat -> V) (n : nat) : V :=
  match n with
    | 0 => zero
    | S n => a n
  end.

Lemma is_pseries_incr_1 (a : nat -> V) (x:K) (l : V) :
  is_pseries a x l -> is_pseries (PS_incr_1 a) x (scal x l).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha.
  apply filterlim_ext_loc with  (fun n : nat => scal x (sum_n (fun k => scal (pow_n x k) (a k)) (pred n))).
  exists 1%nat; intros n; case n.
  intros Hn; contradict Hn ; apply lt_n_O.
  clear n; intros n _ ;induction n.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite /= !sum_Sn !sum_O /= mult_one_r 2!scal_one plus_zero_l.
  apply trans_eq with (plus
   (sum_n (fun k : nat => scal (pow_n x k) (PS_incr_1 a k)) (S n))
      (scal (pow_n x (S (S n))) (PS_incr_1 a (S (S n))))).
 2: rewrite /= !sum_Sn ; reflexivity.
 rewrite -IHn; simpl.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
 rewrite !sum_Sn scal_distr_l; apply f_equal.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
 now rewrite scal_assoc.
 apply filterlim_comp with (f:= fun n => pred n) (G:=eventually)
  (g:=fun n => scal x (sum_n (fun k : nat => scal (pow_n x k) (a k)) n)).
 apply eventually_subseq_loc.
 exists 1%nat.
 intros n Hn.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
 rewrite -pred_Sn.
 now apply lt_pred_n_n.
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
 now apply filterlim_comp with (2 := filterlim_scal_r _ _).
Qed.

Lemma ex_pseries_incr_1 (a : nat -> V) (x : K) :
  ex_pseries a x -> ex_pseries (PS_incr_1 a) x.
Proof.
(* Goal: forall _ : @ex_pseries K V a x, @ex_pseries K V (PS_incr_1 a) x *)
  move => [l Ha] ; exists (scal x l) ; by apply is_pseries_incr_1.
Qed.

Fixpoint PS_incr_n (a : nat -> V) (n k : nat) : V :=
  match n with
    | O => a k
    | S n => PS_incr_1 (PS_incr_n a n) k
  end.

Lemma PS_incr_n_simplify (a : nat -> V) (n k : nat) :
  PS_incr_n a n k =
  match (le_lt_dec n k) with
    | left _ => a (k-n)%nat
    | right _ => zero
  end.
Proof.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: le_lt_dec => H.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n k H => [ | n IH] k H.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite /PS_incr_n ; by case: k H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: k H => [ | k] H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply le_Sn_0 in H.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_incr_n -/PS_incr_n /PS_incr_1.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite IH.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  apply f_equal.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by elim: n k H {IH} => /= [ | n IH] k H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply le_S_n.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n k H => [ | n IH] k H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply lt_n_O in H.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_incr_n -/PS_incr_n /PS_incr_1.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: k H => [ | k] H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply IH, lt_S_n.
Qed.

Lemma is_pseries_incr_n (a : nat -> V) (n : nat) (x : K) (l : V) :
  is_pseries a x l -> is_pseries (PS_incr_n a n) x (scal (pow_n x n) l).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n => /= [ | n IH].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite scal_one.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -scal_assoc.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_pseries_incr_1.
Qed.

Lemma ex_pseries_incr_n (a : nat -> V) (n : nat) (x : K) :
  ex_pseries a x -> ex_pseries (PS_incr_n a n) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => [l Ha].
(* Goal: @ex_pseries K V (PS_incr_n a n) x *)
  exists (scal (pow_n x n) l) ; by apply is_pseries_incr_n.
Qed.

Definition PS_decr_1 (a : nat -> V) (n : nat) : V := a (S n).

Lemma is_pseries_decr_1 (a : nat -> V) (x y : K) (l : V) :
  mult y x = one -> is_pseries a x l
    -> is_pseries (PS_decr_1 a) x (scal y (plus l (opp (a O)))).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx Ha.
  apply filterlim_ext with  (fun n : nat => scal y
    (sum_n (fun k => scal (pow_n x (S k)) (a (S k))) n)).
(* Goal: forall x0 : nat, @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S k)) (a (S k))) x0)) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_decr_1 a k)) x0) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S k)) (a (S k))) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (NormedModule.AbelianGroup K V) l (@opp (NormedModule.AbelianGroup K V) (a O))))) *)
  intros n; induction n; unfold PS_decr_1; simpl.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite !sum_O mult_one_r scal_one scal_assoc.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (@pow_n (AbsRing.Ring R_AbsRing) (Rinv x) n)) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  rewrite Hx; try assumption.
(* Goal: @eq (NormedModule.sort K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@one (AbsRing.Ring K)) (a (S O))) (a (S O)) *)
(* Goal: @eq (NormedModule.sort K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x k)) (a (S k))) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a (S k))) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S k)) (a (S k))) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (NormedModule.AbelianGroup K V) l (@opp (NormedModule.AbelianGroup K V) (a O))))) *)
  apply @scal_one.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite !sum_Sn -IHn.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  rewrite scal_distr_l; apply f_equal.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite scal_assoc (mult_assoc y).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Hx.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite mult_one_l.
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S k)) (a (S k))) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (NormedModule.AbelianGroup K V) l (@opp (NormedModule.AbelianGroup K V) (a O))))) *)
  apply filterlim_comp with (2 := filterlim_scal_r _ _).
  apply filterlim_ext with  (fun n : nat => plus
    (sum_n (fun k => scal (pow_n x k) (a k)) (S n)) (opp (a 0%nat))).
(* Goal: forall x0 : nat, @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S x0)) (@opp (NormedModule.AbelianGroup K V) (a O))) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S k)) (a (S k))) x0) *)
(* Goal: @filterlim nat (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (fun n : nat => @plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n)) (@opp (NormedModule.AbelianGroup K V) (a O))) eventually (@locally (NormedModule.UniformSpace K V) (@plus (NormedModule.AbelianGroup K V) l (@opp (NormedModule.AbelianGroup K V) (a O)))) *)
  intros n; induction n; simpl.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_Sn !sum_O /= mult_one_r scal_one.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite plus_comm plus_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite plus_opp_l plus_zero_l.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite !sum_Sn -IHn.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply sym_eq; rewrite plus_comm plus_assoc.
(* Goal: @eq (NormedModule.sort K V) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x (S n))) (a (S (S n)))) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@opp (NormedModule.AbelianGroup K V) (a O))) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S n)) (a (S n)))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x (S (S n))) (a (S (S n))))) (@opp (NormedModule.AbelianGroup K V) (a O))) *)
(* Goal: @filterlim nat (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (fun n : nat => @plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n)) (@opp (NormedModule.AbelianGroup K V) (a O))) eventually (@locally (NormedModule.UniformSpace K V) (@plus (NormedModule.AbelianGroup K V) l (@opp (NormedModule.AbelianGroup K V) (a O)))) *)
  apply f_equal2;[idtac|reflexivity].
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite !sum_Sn plus_comm.
(* Goal: @filterlim nat (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (fun n : nat => @plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n)) (@opp (NormedModule.AbelianGroup K V) (a O))) eventually (@locally (NormedModule.UniformSpace K V) (@plus (NormedModule.AbelianGroup K V) l (@opp (NormedModule.AbelianGroup K V) (a O)))) *)
  apply filterlim_comp_2 with (3 := filterlim_plus _ _).
(* Goal: @filterlim nat (NormedModule.sort K V) (fun x0 : nat => @sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S x0)) eventually (@locally (NormedModule.UniformSpace K V) l) *)
(* Goal: @filterlim nat (NormedModule.sort K V) (fun _ : nat => @opp (NormedModule.AbelianGroup K V) (a O)) eventually (@locally (NormedModule.UniformSpace K V) (@opp (NormedModule.AbelianGroup K V) (a O))) *)
  apply filterlim_comp with (f:= fun x => S x) (2:=Ha).
(* Goal: @filterlim nat nat (fun x : nat => S x) eventually eventually *)
(* Goal: @filterlim nat (NormedModule.sort K V) (fun _ : nat => @opp (NormedModule.AbelianGroup K V) (a O)) eventually (@locally (NormedModule.UniformSpace K V) (@opp (NormedModule.AbelianGroup K V) (a O))) *)
  apply eventually_subseq; intros n; omega.
(* Goal: @filterlim nat (NormedModule.sort K V) (fun _ : nat => @opp (NormedModule.AbelianGroup K V) (a O)) eventually (@locally (NormedModule.UniformSpace K V) (@opp (NormedModule.AbelianGroup K V) (a O))) *)
  apply filterlim_const.
Qed.

Lemma ex_pseries_decr_1 (a : nat -> V) (x : K) :
 (x = zero \/ exists y, mult y x = one) ->
 ex_pseries a x -> ex_pseries (PS_decr_1 a) x.
Proof.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
 case => [H | [y Hx]] [l Ha].
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
 rewrite H ; by apply ex_pseries_0.
(* Goal: @ex_pseries K V (PS_decr_1 a) x *)
 exists (scal y (plus l (opp (a 0%nat)))).
(* Goal: @is_pseries K V (fun k : nat => a (S k)) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (a O)))) *)
(* Goal: @is_pseries K V (fun k : nat => a (S (S (Init.Nat.add n k)))) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n))) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))))) *)
 now apply is_pseries_decr_1.
Qed.

Definition PS_decr_n (a : nat -> V) (n k : nat) : V := a (n + k)%nat.

Lemma is_pseries_decr_n (a : nat -> V) (n : nat) (x y:K) (l : V) :
  mult y x = one -> (0 < n)%nat -> is_pseries a x l
    -> is_pseries (PS_decr_n a n) x (scal (pow_n y n) (plus l (opp (sum_n (fun k => scal (pow_n x k) (a k)) (n-1)%nat)))).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx Hn Ha.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: n Hn => [ | n] Hn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply lt_irrefl in Hn.
(* Goal: @is_pseries K V (PS_decr_n a (S n)) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) y (S n)) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (Init.Nat.sub (S n) (S O)))))) *)
  clear Hn ; simpl ; rewrite -minus_n_O /PS_decr_n /=.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n => /= [ | n IH].
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_O scal_one mult_one_r.
(* Goal: @is_pseries K V (fun k : nat => a (S k)) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (a O)))) *)
(* Goal: @is_pseries K V (fun k : nat => a (S (S (Init.Nat.add n k)))) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n))) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))))) *)
  now apply is_pseries_decr_1.
  set (ln := (scal (mult y (pow_n y n))
          (plus l (opp (sum_n (fun k : nat => scal (pow_n x k) (a k)) n))))) in IH.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite !sum_Sn /=.
  replace (scal (mult y (mult y (pow_n y n)))
     (plus l
        (opp
           (plus (sum_n (fun k : nat => scal (pow_n x k) (a k)) n)
              (scal (mult x (pow_n x n)) (a (S n)))))))
  with (scal y (plus ln (opp (a (S (n + 0)))))).
(* Goal: @is_pseries K V (fun k : nat => a (S (S (Init.Nat.add n k)))) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) *)
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n))) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)) (a (S n))))))) *)
  assert (Y:is_pseries (fun k : nat => a (S (n + k))) x ln).
(* Goal: @is_pseries K V (fun k : nat => a (S (Init.Nat.add n k))) x ln *)
(* Goal: @is_pseries K V (fun k : nat => a (S (S (Init.Nat.add n k)))) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) *)
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n))) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)) (a (S n))))))) *)
  apply IH.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (is_pseries_decr_1 (fun k : nat => a (S (n + k))) x y ln Hx Y).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_decr_1 /=.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply is_pseries_ext => k.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  apply f_equal ; ring.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -scal_assoc.
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)) (a (S n)))))))) *)
  apply f_equal; unfold ln.
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)))) (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O))))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)) (a (S n))))))) *)
  repeat rewrite (scal_distr_l _ l).
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  rewrite -plus_assoc; apply f_equal.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  rewrite opp_plus scal_distr_l; apply f_equal.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite plus_0_r -scal_opp_l scal_assoc.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  apply trans_eq with (scal (opp (one : K)) (a (S n))).
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite scal_opp_l scal_one.
(* Goal: @eq R (Rmult (Rmult (@pow_n (AbsRing.Ring R_AbsRing) (Ropp x) n) (pow (IZR (Zneg xH)) n)) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) *)
(* Goal: @locally R_UniformSpace (Ropp (IZR Z0)) (fun y : R => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: forall (n : nat) (x : R) (_ : Rlt (Rabs x) r), and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Derive_n (fun x0 : R => f (Ropp x0)) n x)) M) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  apply f_equal2; try reflexivity.
(* Goal: @eq (NormedModule.sort K V) (a (Init.Nat.sub k n)) (a (Init.Nat.sub (S k) (S n))) *)
(* Goal: le n k *)
(* Goal: @eq (NormedModule.sort K V) (PS_incr_n a n k) (@zero (NormedModule.AbelianGroup K V)) *)
  rewrite <- opp_mult_r; apply f_equal.
(* Goal: @eq (AbelianGroup.sort (AbsRing.AbelianGroup K)) (@one (AbsRing.Ring K)) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n))) *)
  clear -Hx.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -?/(pow_n _ (S _)).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: (S n) => {n} /= [ | n IH].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite mult_one_l.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(pow_n_comm_1 x) mult_assoc.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(mult_assoc y (pow_n y n) (pow_n x n)).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite -IH mult_one_r.
Qed.

Lemma ex_pseries_decr_n (a : nat -> V) (n : nat) (x : K) :
  (x = zero \/ exists y, mult y x = one) -> ex_pseries a x -> ex_pseries (PS_decr_n a n) x.
Proof.
(* Goal: forall (_ : or (@eq (AbsRing.sort K) x (@zero (AbsRing.AbelianGroup K))) (@ex (Ring.sort (AbsRing.Ring K)) (fun y : Ring.sort (AbsRing.Ring K) => @eq (Ring.sort (AbsRing.Ring K)) (@mult (AbsRing.Ring K) y x) (@one (AbsRing.Ring K))))) (_ : @ex_pseries K V a x), @ex_pseries K V (PS_decr_n a n) x *)
  intros Hx H.
(* Goal: @ex_pseries K V (PS_decr_n a n) x *)
  induction n.
(* Goal: @ex_pseries K V (PS_decr_n a O) x *)
(* Goal: @ex_pseries K V (PS_decr_n a (S n)) x *)
  unfold PS_decr_n; now simpl.
(* Goal: @ex_pseries K V (PS_decr_n a (S n)) x *)
  apply ex_pseries_ext with ((PS_decr_1 (PS_decr_n a n))).
(* Goal: forall n0 : nat, @eq (NormedModule.sort K V) (PS_decr_1 (PS_decr_n a n) n0) (PS_decr_n a (S n) n0) *)
(* Goal: @ex_pseries K V (PS_decr_1 (PS_decr_n a n)) x *)
  intros m; unfold PS_decr_1, PS_decr_n.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  apply f_equal; ring.
(* Goal: @ex_pseries K V (PS_decr_1 (PS_decr_n a n)) x *)
  apply ex_pseries_decr_1.
(* Goal: or (@eq (AbsRing.sort K) x (@zero (AbsRing.AbelianGroup K))) (@ex (Ring.sort (AbsRing.Ring K)) (fun y : Ring.sort (AbsRing.Ring K) => @eq (Ring.sort (AbsRing.Ring K)) (@mult (AbsRing.Ring K) y x) (@one (AbsRing.Ring K)))) *)
(* Goal: @ex_pseries K V (PS_decr_n a n) x *)
  apply Hx.
(* Goal: @ex_pseries K V (PS_decr_n a n) x *)
  now apply IHn.
Qed.

End PS_incr.

Lemma PSeries_incr_1 a x :
  PSeries (PS_incr_1 a) x = x * PSeries a x.
Proof.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Series_scal_l.
(* Goal: @eq R (PSeries (@PS_incr_1 R_AbsRing R_NormedModule a) x) (Series (fun n : nat => Rmult x (Rmult (a n) (pow x n)))) *)
  unfold PSeries, Series.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(Lim_seq_incr_1 (sum_n (fun k : nat => PS_incr_1 a k * x ^ k))) /=.
(* Goal: @eq R (real (Lim_seq (fun n : nat => @sum_n R_AbelianGroup (fun k : nat => Rmult (@PS_incr_1 R_AbsRing R_NormedModule a k) (pow x k)) (S n)))) (real (Lim_seq (@sum_n R_AbelianGroup (fun n : nat => Rmult x (Rmult (a n) (pow x n)))))) *)
  apply f_equal, Lim_seq_ext.
(* Goal: forall n : nat, @eq R (@sum_n R_AbelianGroup (fun k : nat => Rmult (@PS_incr_1 R_AbsRing R_NormedModule a k) (pow x k)) (S n)) (@sum_n R_AbelianGroup (fun n0 : nat => Rmult x (Rmult (a n0) (pow x n0))) n) *)
  case.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_Sn !sum_O /= /plus /zero /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  ring.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => /= [ | n IH].
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite !sum_Sn !sum_O /= /plus /zero /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  ring.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_Sn IH !sum_Sn /= /plus /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  ring.
Qed.

Lemma PSeries_incr_n (a : nat -> R) (n : nat) (x : R) :
  PSeries (PS_incr_n a n) x = x^n * PSeries a x.
Proof.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n => /= [ | n IH].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Rmult_1_l.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rmult_assoc.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite PSeries_incr_1 IH.
Qed.

Lemma PSeries_decr_1 (a : nat -> R) (x : R) :
  ex_pseries a x -> PSeries a x = a O + x * PSeries (PS_decr_1 a) x.
Proof.
(* Goal: forall _ : @ex_pseries R_AbsRing R_NormedModule a x, @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (pow x (S n)) (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x))) *)
  intros Ha.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Req_dec x 0) => Hx.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite Hx PSeries_0 ; ring.
  move: (is_pseries_decr_1 a x (/x) (PSeries a x) (Rinv_l _ Hx)
    (PSeries_correct _ _ Ha)) => Hb.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (is_pseries_unique _ _ _ Hb).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /plus /opp /scal /= /mult /=.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  now field.
Qed.

Lemma PSeries_decr_1_aux (a : nat -> R) (x : R) :
  a O = 0 -> (PSeries a x) = x * PSeries (PS_decr_1 a) x.
Proof.
(* Goal: forall _ : @eq R (a O) (IZR Z0), @eq R (PSeries a x) (Rmult x (PSeries (@PS_decr_1 R_AbsRing R_NormedModule a) x)) *)
  intros Ha0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -PSeries_incr_1.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_incr_1 /PS_decr_1 /=.
(* Goal: @eq R (PSeries a x) (PSeries (fun n : nat => match n with | O => @zero (NormedModule.AbelianGroup R_AbsRing R_NormedModule) | S n0 => a (S n0) end) x) *)
  apply Series_ext.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case => //=.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Ha0.
Qed.

Lemma PSeries_decr_n (a : nat -> R) (n : nat) (x : R) :
  ex_pseries a x
    -> PSeries a x = sum_f_R0 (fun k => a k * x^k) n + x^(S n) * PSeries (PS_decr_n a (S n)) x.
Proof.
(* Goal: forall _ : @ex_pseries R_AbsRing R_NormedModule a x, @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (pow x (S n)) (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x))) *)
  intros Ha.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Req_dec x 0) => Hx.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (pow x (S n)) (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x))) *)
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (pow x (S n)) (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x))) *)
  rewrite Hx PSeries_0 ; simpl ; ring_simplify.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n => /= [ | n IH].
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  ring.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite -IH ; ring.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (pow x (S n)) (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x))) *)
  assert (V:(pow_n x (S n) <> 0)).
(* Goal: not (@eq (Ring.sort R_Ring) (@pow_n R_Ring x (S n)) (IZR Z0)) *)
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (pow x (S n)) (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x))) *)
  rewrite pow_n_pow; now apply pow_nonzero.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (is_pseries_decr_n a (S n) x (/x) (PSeries a x) (Rinv_l x Hx) (lt_0_Sn _) (PSeries_correct _ _ Ha)) => Hb.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (is_pseries_unique _ _ _ Hb).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (sum_n_ext _ (fun k : nat => a k * x ^ k)).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_n_Reals.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (pow x (S n)) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) (Rinv x) (S n)) (@plus (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (PSeries a x) (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule)) (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) (Init.Nat.sub (S n) (S O)))))))) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  replace (S n -1)%nat with n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /scal /plus /opp /= /mult /=.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (@pow_n (AbsRing.Ring R_AbsRing) (Rinv x) n)) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  rewrite pow_n_pow -Rinv_pow ; try assumption.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
(* Goal: and (not (@eq R (pow x n) (IZR Z0))) (not (@eq R x (IZR Z0))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  split; try assumption.
(* Goal: not (@eq R (pow x n) (IZR Z0)) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  now apply pow_nonzero.
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  now apply plus_minus.
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  intros m; rewrite pow_n_pow.
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
  apply Rmult_comm.
Qed.

Lemma PSeries_decr_n_aux (a : nat -> R) (n : nat) (x : R) :
  (forall k : nat, (k < n)%nat -> a k = 0)
    -> PSeries a x = x^n * PSeries (PS_decr_n a n) x.
Proof.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n => /= [ | n IH] Ha.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rmult_1_l.
(* Goal: @is_pseries R_AbsRing R_NormedModule (PS_mult a b) x (Rmult (PSeries a x) (PSeries b x)) *)
  apply PSeries_ext => n ; by intuition.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite IH.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite PSeries_decr_1_aux.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (Rmult_comm _ (x^n)) Rmult_assoc.
(* Goal: @eq R (Rmult (pow x n) (Rmult x (PSeries (@PS_decr_1 R_AbsRing R_NormedModule (@PS_decr_n R_AbsRing R_NormedModule a n)) x))) (Rmult (pow x n) (Rmult x (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x))) *)
(* Goal: @eq R (@PS_decr_n R_AbsRing R_NormedModule a n O) (IZR Z0) *)
(* Goal: forall (k : nat) (_ : lt k n), @eq R (a k) (IZR Z0) *)
  repeat apply Rmult_eq_compat_l.
(* Goal: @eq R (PSeries (@PS_decr_1 R_AbsRing R_NormedModule (@PS_decr_n R_AbsRing R_NormedModule a n)) x) (PSeries (@PS_decr_n R_AbsRing R_NormedModule a (S n)) x) *)
(* Goal: @eq R (@PS_decr_n R_AbsRing R_NormedModule a n O) (IZR Z0) *)
(* Goal: forall (k : nat) (_ : lt k n), @eq R (a k) (IZR Z0) *)
  apply PSeries_ext => k ; rewrite /PS_decr_1 /PS_decr_n ; by intuition.
(* Goal: @eq R (a k) (IZR Z0) *)
  apply Ha ; by intuition.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => k Hk.
(* Goal: @eq R (a k) (IZR Z0) *)
  apply Ha ; by intuition.
Qed.

Lemma CV_radius_incr_1 (a : nat -> R) :
  CV_radius (PS_incr_1 a) = CV_radius a.
Proof.
(* Goal: @eq Rbar (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) (CV_radius a) *)
  assert (Ha := CV_radius_bounded a).
(* Goal: @eq Rbar (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) (CV_radius a) *)
  assert (Ha' := CV_radius_bounded (PS_incr_1 a)).
(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
  apply Rbar_le_antisym.
(* Goal: Rbar_le (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) (CV_radius a) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  apply Ha' => x [M Hx] ; apply Ha.
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (a n) (pow x n))) M) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  move: (fun n => Hx (S n)) => {Hx} Hx ; simpl in Hx.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Req_dec x 0) => Hx0.
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (a n) (pow x n))) M) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (a n) (pow x n))) M) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  rewrite Hx0 ; exists (Rabs (a O)) ; case => /= [ | n].
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite Rmult_1_r ; by right.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rmult_0_l Rmult_0_r Rabs_R0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (M / Rabs x) => n.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rdiv M (Rabs x)) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  apply Rle_div_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos_lt.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite -Rabs_mult Rmult_assoc (Rmult_comm _ x).
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  apply Ha => x [M Hx] ; apply Ha'.
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (@PS_incr_1 R_AbsRing R_NormedModule a n) (pow x n))) M) *)
  exists (M * Rabs x) ; case => [ | n] /=.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rmult_0_l Rabs_R0.
(* Goal: Rle (IZR Z0) (Rmult (INR n) (pos eps)) *)
(* Goal: Rlt (IZR Z0) (Rplus (pos eps) (IZR (Zpos xH))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply Rmult_le_pos.
(* Goal: Rle (IZR Z0) M *)
(* Goal: Rle (IZR Z0) (Rabs x) *)
(* Goal: Rle (Rabs (Rmult (a n) (Rmult x (pow x n)))) (Rmult M (Rabs x)) *)
  eapply Rle_trans, (Hx O).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (Rmult_comm x) -Rmult_assoc Rabs_mult.
(* Goal: Rle (Rmult (Rabs (Rmult (a n) (pow x n))) (Rabs x)) (Rmult M (Rabs x)) *)
  apply Rmult_le_compat_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
Qed.
Lemma CV_radius_decr_1 (a : nat -> R) :
  CV_radius (PS_decr_1 a) = CV_radius a.
Proof.
(* Goal: @eq Rbar (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) (CV_radius a) *)
  assert (Ha := CV_radius_bounded a).
  assert (Ha' := CV_radius_bounded (PS_decr_1 a)).
(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
  apply Rbar_le_antisym.
(* Goal: Rbar_le (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) (CV_radius a) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  apply Ha' => x [M Hx] ; apply Ha.
  eexists ; case => [ | n] ; simpl.
  eapply Rle_trans, Rmax_l.
  rewrite Rmult_1_r ; apply Rle_refl.
  eapply Rle_trans, Rmax_r.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (Rmult_comm x) -Rmult_assoc Rabs_mult.
(* Goal: Rle (Rmult (Rabs (Rmult (a n) (pow x n))) (Rabs x)) (Rmult M (Rabs x)) *)
  apply Rmult_le_compat_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hx.
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  apply Ha => x [M Hx] ; apply Ha'.
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (a n) (pow x n))) M) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  move: (fun n => Hx (S n)) => {Hx} Hx ; simpl in Hx.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Req_dec x 0) => Hx0.
  rewrite Hx0 ; exists (Rabs (a 1%nat)) ; case => /= [ | n].
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite Rmult_1_r ; by right.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rmult_0_l Rmult_0_r Rabs_R0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (M / Rabs x) => n.
(* Goal: Rle (Rabs (Rmult (a n) (pow x n))) (Rdiv M (Rabs x)) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (@PS_incr_1 R_AbsRing R_NormedModule a)) *)
  apply Rle_div_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos_lt.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Rabs_mult Rmult_assoc (Rmult_comm _ x).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hx.
Qed.

Definition PS_mult (a b : nat -> R) n :=
  sum_f_R0 (fun k => a k * b (n - k)%nat) n.

Lemma is_pseries_mult (a b : nat -> R) (x la lb : R) :
  is_pseries a x la -> is_pseries b x lb
  -> Rbar_lt (Rabs x) (CV_radius a) -> Rbar_lt (Rabs x) (CV_radius b)
  -> is_pseries (PS_mult a b) x (la * lb).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hla Hlb Ha Hb.
(* Goal: @is_pseries R_AbsRing R_NormedModule (PS_mult a b) x (Rmult la lb) *)
  apply is_series_ext with (fun n => sum_f_R0 (fun k => (fun l => a l * x ^ l) k * (fun l => b l * x ^ l) (n - k)%nat) n).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_mult /scal /= /mult /= scal_sum.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply sum_eq => i Hi.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -{4}(MyNat.sub_add _ _ Hi).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite pow_n_pow pow_add.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  ring.
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  apply (is_series_mult (fun l => a l * x ^ l) (fun l => b l * x ^ l)).
(* Goal: @is_series R_AbsRing R_NormedModule (fun l : nat => Rmult (a l) (pow x l)) la *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun l : nat => Rmult (b l) (pow x l)) lb *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (b n) (pow x n))) *)
  now apply (is_pseries_R a x la).
(* Goal: @is_series R_AbsRing R_NormedModule (fun l : nat => Rmult (b l) (pow x l)) lb *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (a n) (pow x n))) *)
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (b n) (pow x n))) *)
  now apply (is_pseries_R b x lb).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_disk_inside.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_disk_inside.
Qed.
Lemma ex_pseries_mult (a b : nat -> R) (x : R) :
  Rbar_lt (Rabs x) (CV_radius a) -> Rbar_lt (Rabs x) (CV_radius b)
  -> ex_pseries (PS_mult a b) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb.
(* Goal: @ex_pseries R_AbsRing R_NormedModule (PS_mult a b) x *)
  exists ((PSeries a x) * (PSeries b x)).
(* Goal: @is_pseries R_AbsRing R_NormedModule (PS_mult a b) x (Rmult (PSeries a x) (PSeries b x)) *)
  apply is_pseries_mult => // ; by apply PSeries_correct, CV_radius_inside.
Qed.
Lemma PSeries_mult (a b : nat -> R) (x : R) :
  Rbar_lt (Rabs x) (CV_radius a) -> Rbar_lt (Rabs x) (CV_radius b)
  -> PSeries (PS_mult a b) x = PSeries a x * PSeries b x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb.
(* Goal: @eq R (PSeries (PS_mult a b) x) (Rmult (PSeries a x) (PSeries b x)) *)
  apply is_pseries_unique.
(* Goal: @is_pseries R_AbsRing R_NormedModule (PS_mult a b) x (Rmult (PSeries a x) (PSeries b x)) *)
  apply is_pseries_mult => // ; by apply PSeries_correct, CV_radius_inside.
Qed.

(** Sums on even and odd *)

Lemma is_pseries_odd_even (a : nat -> R) (x l1 l2 : R) :
  is_pseries (fun n => a (2*n)%nat) (x^2) l1 -> is_pseries (fun n => a (2*n+1)%nat) (x^2) l2
    -> is_pseries a x (l1 + x * l2).
Proof.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite 3!is_pseries_R.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => H1 H2.
  apply filterlim_ext with (fun n =>
    (sum_n (fun k : nat => a (2 * k)%nat * (x ^ 2) ^ k) (div2 n)) +
    x * match n with | O => 0
    | S n => (sum_n (fun k : nat => a (2 * k + 1)%nat * (x ^ 2) ^ k) (div2 n)) end).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case => [ | n].
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite /= !sum_O /= ; ring.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (even_odd_dec n) => Hn.
(* even n *)
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite 3!sum_n_Reals.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(even_div2 _ Hn) {3}(even_double _ Hn).
  elim: (div2 n) => {n Hn} [ | n] ;
  rewrite ?double_S /sum_f_R0 -/sum_f_R0.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite /double /= ; ring.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -pow_mult.
  replace (2 * S n)%nat with (S (S (double n)))
    by (rewrite -double_S /double ; ring).
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  replace (S (S (double n)) + 1)%nat with (S (S (S (double n)))) by ring.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  move => <- ; simpl ; ring.
(* odd n *)
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite 3!sum_n_Reals.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(odd_div2 _ Hn) {3}(odd_double _ Hn).
  elim: (div2 n) => {n Hn} [ | n] ;
  rewrite ?double_S /sum_f_R0 -/sum_f_R0.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite /double /= ; ring.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -?pow_mult.
  replace (2 * S n)%nat with (S (S (double n)))
    by (rewrite -double_S /double ; ring).
  replace (2 * S (S n))%nat with (S (S (S (S (double n)))))
    by (rewrite -double_S /double ; ring).
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  replace (S (S (double n)) + 1)%nat with (S (S (S (double n)))) by ring.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  move => <- ; simpl ; ring.
(* Goal: @filterlim nat R (fun n : nat => Rplus (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.mul (S (S O)) k)) (pow (pow x (S (S O))) k)) (Nat.div2 n)) (Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end)) eventually (@locally (NormedModule.UniformSpace R_AbsRing R_NormedModule) (Rplus l1 (Rmult x l2))) *)
  apply (is_lim_seq_plus' _ _ l1 (x*l2)).
(* a(2k)x^(2k) *)
(* Goal: is_lim_seq (fun n : nat => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.mul (S (S O)) k)) (pow (pow x (S (S O))) k)) (Nat.div2 n)) (Finite l1) *)
(* Goal: is_lim_seq (fun n : nat => Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end) (Finite (Rmult x l2)) *)
  apply filterlim_comp with (2:=H1).
(* Goal: @filterlim nat nat (fun x : nat => Nat.div2 (Init.Nat.pred x)) eventually eventually *)
  intros P [N HN].
(* Goal: @filtermap nat nat Nat.div2 eventually P *)
(* Goal: is_lim_seq (fun n : nat => Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end) (Finite (Rmult x l2)) *)
  exists (2*N+1)%nat.
(* Goal: forall (n : nat) (_ : le (Init.Nat.add (Init.Nat.mul (S (S O)) N) (S (S O))) n), P (Nat.div2 (Init.Nat.pred n)) *)
  intros n Hn; apply HN.
(* Goal: le N (Nat.div2 (Init.Nat.pred n)) *)
  apply le_double.
(* Goal: le (Init.Nat.mul (S (S O)) N) (Init.Nat.mul (S (S O)) (Nat.div2 n)) *)
(* Goal: is_lim_seq (fun n : nat => Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end) (Finite (Rmult x l2)) *)
  apply plus_le_reg_l with 1%nat.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Plus.plus_comm.
(* Goal: le (Nat.add (Init.Nat.mul (S (S O)) N) (S (S O))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  apply le_trans with (1:=Hn).
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.mul (S (S O)) (Nat.div2 n))) *)
(* Goal: is_lim_seq (fun n : nat => Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end) (Finite (Rmult x l2)) *)
  apply le_trans with (1+double (div2 n))%nat.
(* Goal: le n (Init.Nat.add (S O) (Nat.double (Nat.div2 n))) *)
(* Goal: le (Init.Nat.add (S O) (Nat.double (Nat.div2 n))) (Init.Nat.add (S O) (Init.Nat.mul (S (S O)) (Nat.div2 n))) *)
(* Goal: is_lim_seq (fun n : nat => Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end) (Finite (Rmult x l2)) *)
  case (even_or_odd n); intros J.
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  rewrite <- even_double; try exact J.
(* Goal: le O (S O) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  now apply le_S.
(* Goal: le n (Init.Nat.add (S O) (Nat.double (Nat.div2 n))) *)
(* Goal: le (Init.Nat.add (S O) (Nat.double (Nat.div2 n))) (Init.Nat.add (S O) (Init.Nat.mul (S (S O)) (Nat.div2 n))) *)
(* Goal: is_lim_seq (fun n : nat => Rmult x match n with | O => IZR Z0 | S n0 => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n0) end) (Finite (Rmult x l2)) *)
  rewrite <- odd_double; easy.
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  simpl; now rewrite plus_0_r.
(* a(2k+1)x^(2k+1) *)
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply (is_lim_seq_scal_l _ x l2) => //.
  apply filterlim_ext_loc with
    (fun n => sum_n (fun k : nat => a (2 * k + 1)%nat * (x ^ 2) ^ k)
      (div2 (pred n))).
(* Goal: eventually (fun x0 : nat => @eq (AbelianGroup.sort R_AbelianGroup) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred x0))) match x0 with | O => IZR Z0 | S n => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n) end) *)
(* Goal: @filterlim nat (AbelianGroup.sort R_AbelianGroup) (fun n : nat => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred n))) eventually (Rbar_locally (Finite l2)) *)
  exists 1%nat; intros y; case y.
(* Goal: forall _ : le (S O) O, @eq (AbelianGroup.sort R_AbelianGroup) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred O))) (IZR Z0) *)
(* Goal: forall (n : nat) (_ : le (S O) (S n)), @eq (AbelianGroup.sort R_AbelianGroup) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred (S n)))) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n)) *)
(* Goal: @filterlim nat (AbelianGroup.sort R_AbelianGroup) (fun n : nat => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred n))) eventually (Rbar_locally (Finite l2)) *)
  easy.
(* Goal: forall (n : nat) (_ : le (S O) (S n)), @eq (AbelianGroup.sort R_AbelianGroup) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred (S n)))) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n)) *)
(* Goal: @filterlim nat (AbelianGroup.sort R_AbelianGroup) (fun n : nat => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred n))) eventually (Rbar_locally (Finite l2)) *)
  intros n _; reflexivity.
(* Goal: @filterlim nat (AbelianGroup.sort R_AbelianGroup) (fun n : nat => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred n))) eventually (Rbar_locally (Finite l2)) *)
  apply filterlim_comp with (2:=H2).
(* Goal: @filterlim nat nat (fun x : nat => Nat.div2 (Init.Nat.pred x)) eventually eventually *)
  intros P [N HN].
(* Goal: @filtermap nat nat (fun x : nat => Nat.div2 (Init.Nat.pred x)) eventually P *)
  exists (2*N+2)%nat.
(* Goal: forall (n : nat) (_ : le (Init.Nat.add (Init.Nat.mul (S (S O)) N) (S (S O))) n), P (Nat.div2 (Init.Nat.pred n)) *)
  intros n Hn; apply HN.
(* Goal: le N (Nat.div2 (Init.Nat.pred n)) *)
  apply le_double.
(* Goal: le (Init.Nat.mul (S (S O)) N) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n))) *)
  apply plus_le_reg_l with 2%nat.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Plus.plus_comm.
(* Goal: le (Nat.add (Init.Nat.mul (S (S O)) N) (S (S O))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  apply le_trans with (1:=Hn).
(* Goal: le n (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  apply le_trans with (1+(1+double (div2 (pred n))))%nat.
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  case (even_or_odd (pred n)); intros J.
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  rewrite <- even_double; try exact J.
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Init.Nat.pred n))) *)
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  case n.
(* Goal: le O (Init.Nat.add (S O) (Init.Nat.add (S O) (Init.Nat.pred O))) *)
(* Goal: forall n : nat, le (S n) (Init.Nat.add (S O) (Init.Nat.add (S O) (Init.Nat.pred (S n)))) *)
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  simpl; now apply le_S, le_S.
(* Goal: le O (S O) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  intros m; simpl; now apply le_S.
(* Goal: le n (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  rewrite <- odd_double; try exact J.
(* Goal: forall _ : le (S O) O, @eq (AbelianGroup.sort R_AbelianGroup) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred O))) (IZR Z0) *)
(* Goal: forall (n : nat) (_ : le (S O) (S n)), @eq (AbelianGroup.sort R_AbelianGroup) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred (S n)))) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 n)) *)
(* Goal: @filterlim nat (AbelianGroup.sort R_AbelianGroup) (fun n : nat => @sum_n R_AbelianGroup (fun k : nat => Rmult (a (Init.Nat.add (Init.Nat.mul (S (S O)) k) (S O))) (pow (pow x (S (S O))) k)) (Nat.div2 (Init.Nat.pred n))) eventually (Rbar_locally (Finite l2)) *)
  case n; simpl; try easy.
(* Goal: le O (S O) *)
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  now apply le_S.
(* Goal: le (Init.Nat.add (S O) (Init.Nat.add (S O) (Nat.double (Nat.div2 (Init.Nat.pred n))))) (Init.Nat.add (S (S O)) (Init.Nat.mul (S (S O)) (Nat.div2 (Init.Nat.pred n)))) *)
  simpl; now rewrite plus_0_r.
Qed.
Lemma ex_pseries_odd_even (a : nat -> R) (x : R) :
  ex_pseries (fun n => a (2*n)%nat) (x^2) -> ex_pseries (fun n => a (2*n+1)%nat) (x^2)
    -> ex_pseries a x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => [l1 H1] [l2 H2].
(* Goal: @ex_pseries R_AbsRing R_NormedModule a x *)
  exists (l1 + x * l2).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_pseries_odd_even.
Qed.
Lemma PSeries_odd_even (a : nat -> R) (x : R) :
  ex_pseries (fun n => a (2*n)%nat) (x^2) -> ex_pseries (fun n => a (2*n+1)%nat) (x^2)
    -> PSeries a x = PSeries (fun n => a (2*n)%nat) (x^2) + x * PSeries (fun n => a (2*n+1)%nat) (x^2).
Proof.
  move => H1 H2 ;
(* Goal: @eq R (PSeries (PS_mult a b) x) (Rmult (PSeries a x) (PSeries b x)) *)
  apply is_pseries_unique.
(* Goal: @is_pseries R_AbsRing R_NormedModule a x (Rplus (PSeries (fun n : nat => a (Init.Nat.mul (S (S O)) n)) (pow x (S (S O)))) (Rmult x (PSeries (fun n : nat => a (Init.Nat.add (Init.Nat.mul (S (S O)) n) (S O))) (pow x (S (S O)))))) *)
  apply (is_pseries_odd_even a x); by apply PSeries_correct.
Qed.

Lemma PSeries_const_0 : forall x, PSeries (fun _ => 0) x = 0.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => x.
(* Goal: @eq R (PSeries (fun _ : nat => IZR Z0) x) (IZR Z0) *)
  replace 0 with (real 0) by auto.
(* Goal: @eq R (PSeries (fun _ : nat => real (Finite (IZR Z0))) x) (real (Finite (IZR Z0))) *)
  apply (f_equal real).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -{2}(Lim_seq_const 0) /=.
(* Goal: @eq Rbar (Lim_seq (@sum_n R_AbelianGroup (fun k : nat => Rmult (IZR Z0) (pow x k)))) (Lim_seq (fun _ : nat => IZR Z0)) *)
  apply Lim_seq_ext.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => /= [ | n IH].
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite sum_O ; ring.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite sum_Sn /= /plus /= IH ; ring.
Qed.

Lemma CV_radius_const_0 : CV_radius (fun _ => 0) = p_infty.
Proof.
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  suff : forall x, Rbar_le (Rabs x) (CV_radius (fun _ : nat => 0)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case H : (CV_radius (fun _ : nat => 0)) => [cv | | ] //= H0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Rle_lt_dec 0 cv) => Hcv.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (H0 (cv + 1)) => {H0} H0.
(* Goal: @eq Rbar (Finite cv) p_infty *)
(* Goal: @eq Rbar (Finite cv) p_infty *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
  contradict H0 ; apply Rlt_not_le => /=.
(* Goal: Rlt cv (Rabs (Rplus cv (IZR (Zpos xH)))) *)
(* Goal: @eq Rbar (Finite cv) p_infty *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
  apply Rlt_le_trans with (2 := Rle_abs _).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rminus_lt_0 ; ring_simplify ; by apply Rlt_0_1.
(* Goal: @eq Rbar (Finite cv) p_infty *)
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
  contradict Hcv ; apply (Rbar_le_not_lt cv 0).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Rabs_R0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H0.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (H0 0) => {H0} H0.
(* Goal: @eq Rbar m_infty p_infty *)
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
  contradict H0 ; by apply Rbar_lt_not_le.
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
  move => x ; apply Rbar_not_lt_le => Hx.
(* Goal: False *)
  apply CV_disk_outside in Hx.
(* Goal: False *)
  apply: Hx.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) (IZR Z0)) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply is_lim_seq_ext with (fun _ => 0).
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  move => n ; ring.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_lim_seq_const.
Qed.

Section PS_opp.

Context {K : AbsRing} {V : NormedModule K}.

Definition PS_opp (a : nat -> V) (n : nat) : V := opp (a n).

Lemma is_pseries_opp (a : nat -> V) (x :K) (l : V) :
  is_pseries a x l -> is_pseries (PS_opp a) x (opp l).
Proof.
  intros H.
  replace (opp l) with (scal (opp (one : K)) l).
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  2: now rewrite scal_opp_l scal_one.
  apply is_pseries_ext with (PS_scal (opp one) a).
  intros n; unfold PS_scal, PS_opp.
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@opp (NormedModule.AbelianGroup K V) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) *)
(* Goal: @eq (AbelianGroup.sort (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@opp (AbsRing.AbelianGroup K) (@one (AbsRing.Ring K))) (a (S n))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n)) (@opp (Ring.AbelianGroup (AbsRing.Ring K)) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)))) (a (S n))) *)
  now rewrite scal_opp_l scal_one.
  apply is_pseries_scal.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -opp_mult_l -opp_mult_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite mult_one_l mult_one_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply H.
Qed.

Lemma ex_pseries_opp (a : nat -> V) (x : K) :
  ex_pseries a x -> ex_pseries (PS_opp a) x.
Proof.
(* Goal: forall _ : @ex_pseries K V a x, @ex_pseries K V (PS_opp a) x *)
  intros [l Hl].
(* Goal: @ex_pseries K V (PS_opp a) x *)
  exists (opp l).
(* Goal: @is_series K V (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_opp a k)) (@opp (NormedModule.AbelianGroup K V) l) *)
  now apply is_pseries_opp.
Qed.

End PS_opp.

Lemma PSeries_opp (a : nat -> R) (x : R) :
  PSeries (PS_opp a) x = - PSeries a x.
Proof.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  replace (- PSeries a x) with ((-1) * PSeries a x) by ring.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -PSeries_scal.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply PSeries_ext => n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite /PS_scal /PS_opp scal_opp_one.
Qed.

Lemma CV_radius_opp (a : nat -> R) :
  (CV_radius (PS_opp a)) = (CV_radius a).
Proof.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(CV_radius_scal (-1)).
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply CV_radius_ext => n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite /PS_scal /PS_opp scal_opp_l scal_opp_r opp_opp scal_one.
(* Goal: not (@eq R (IZR (Zneg xH)) (IZR Z0)) *)
  rewrite -Ropp_0 ; apply Rlt_not_eq, Ropp_lt_contravar, Rlt_0_1.
Qed.

Section PS_minus.

Context {K : AbsRing} {V : NormedModule K}.

Definition PS_minus (a b : nat -> V) (n : nat) : V := plus (a n) (opp (b n)).

Lemma is_pseries_minus (a b : nat -> V) (x:K) (la lb : V) :
  is_pseries a x la -> is_pseries b x lb
  -> is_pseries (PS_minus a b) x (plus la (opp lb)).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb.
(* Goal: @is_pseries K V (PS_minus a b) x (@plus (NormedModule.AbelianGroup K V) la (@opp (NormedModule.AbelianGroup K V) lb)) *)
  apply is_pseries_plus.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  exact: Ha.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_pseries_opp.
Qed.

Lemma ex_pseries_minus (a b : nat -> V) (x : K) :
  ex_pseries a x -> ex_pseries b x
  -> ex_pseries (PS_minus a b) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb.
(* Goal: @ex_pseries K V (PS_minus a b) x *)
  apply ex_pseries_plus.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  exact: Ha.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply ex_pseries_opp.
Qed.

End PS_minus.

Lemma PSeries_minus (a b : nat -> R) (x : R) :
  ex_pseries a x -> ex_pseries b x
  -> PSeries (PS_minus a b) x = PSeries a x - PSeries b x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite PSeries_plus.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite PSeries_opp.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  exact: Ha.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply ex_pseries_opp.
Qed.

(** ** Abel's theorem for power series *)

Lemma Abel (a : nat -> R) :
  Rbar_lt 0 (CV_radius a) -> Rbar_lt (CV_radius a) p_infty
  -> ex_pseries a (CV_radius a)
  -> filterlim (PSeries a) (at_left (CV_radius a)) (locally (PSeries a (CV_radius a))).
Proof.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case Hcv : (CV_radius a) => [cv | | ] //= Hcv0 _ Ha1.

(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  wlog: cv a Hcv Hcv0 Ha1 / (cv = 1) => Hw.
    apply filterlim_ext with
      (fun x => PSeries (fun n => a n * cv ^ n) (x / cv)).
    intros x.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Series_ext => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rmult_assoc -Rpow_mult_distr.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply f_equal, f_equal2 => //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    field ; by apply Rgt_not_eq.
    apply filterlim_comp with (at_left 1).
    intros P [d Hd].
    unfold filtermap.
    eapply filter_imp.
    intros x Hx ; apply Hd.
    apply @norm_compat1.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /minus /plus /opp /=.
    replace (x / cv + _) with ((x - cv) / cv)
      by (field ; exact: Rgt_not_eq).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /norm /= /abs /= Rabs_div ; try by apply Rgt_not_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite (Rabs_pos_eq cv) ; try by apply Rlt_le.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rlt_div_l => //.
    eapply (proj1 Hx).
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rlt_div_l => //.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rmult_1_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply (proj2 Hx).
    assert (Hd' : 0 < d * cv).
(* Goal: Rlt (IZR Z0) (Rmult (pow r n) M) *)
(* Goal: Rlt (IZR Z0) (INR (fact n)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      apply Rmult_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by apply d.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by [].
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    exists (mkposreal _ Hd') => /= y Hy Hy0 ; by split.
    replace (PSeries a cv) with (PSeries (fun n : nat => a n * cv ^ n) 1).
    apply (Hw 1 (fun n : nat => a n * cv ^ n)) ; clear Hw.
(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
    apply Rbar_le_antisym.
(* Goal: forall n : nat, @eq R (Rdiv r (INR (S n))) (Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    move: Hcv ; rewrite /CV_radius /Lub.Lub_Rbar /CV_disk.
    case: Lub.ex_lub_Rbar => l /= Hl Hl1 ;
    case: Lub.ex_lub_Rbar => l' /= Hl'.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    rewrite Hl1 in Hl => {l Hl1}.
    apply Hl'.
    intros x Hx.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply (Rmult_le_reg_l cv) => //.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rmult_1_r.
    apply Hl.
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
    move: Hx ; apply ex_series_ext => n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite Rpow_mult_distr Rmult_assoc.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite -Rabs_R1.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rbar_not_lt_le => Hcv'.
    apply CV_disk_outside in Hcv'.
(* Goal: False *)
    apply: Hcv'.
    apply ex_series_lim_0 ; move: Ha1 ;
    apply ex_series_ext => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite pow_n_pow pow1 Rmult_1_r.
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
    apply Rmult_comm.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_0_1.
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
    move: Ha1 ; apply ex_series_ext => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite !pow_n_pow pow1 scal_one.
(* Goal: @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (pow x m) (a m)) (Rmult (a m) (pow x m)) *)
    apply Rmult_comm.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Series_ext => n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite pow1 Rmult_1_r.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  rewrite Hw in Hcv Ha1 |- * => {cv Hw Hcv0}.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  wlog: a Hcv Ha1 / (PSeries a 1 = 0) => Hw.
    set b := fun n => match n with
      | O => a O - PSeries a 1
      | S n => a (S n)
      end.
    assert (CV_radius b = Finite 1).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      rewrite -Hcv.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      rewrite -(CV_radius_decr_1 a) -(CV_radius_decr_1 b).
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      apply CV_radius_ext => n.
      reflexivity.
    assert (ex_pseries b 1).
      apply ex_series_incr_1.
      apply ex_series_incr_1 in Ha1.
(* Goal: forall x : R, Rbar_le (Finite (Rabs x)) (CV_radius (fun _ : nat => IZR Z0)) *)
      move: Ha1 ; apply ex_series_ext => n.
      reflexivity.
    assert (PSeries b 1 = 0).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      rewrite PSeries_decr_1 //.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      rewrite /b PSeries_decr_1 /PS_decr_1 //.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
      ring.
    specialize (Hw b H H0 H1).
    apply filterlim_ext_loc with (fun x => PSeries b x + PSeries a 1).
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (mkposreal _ Rlt_0_1) => x Hx0 Hx.
    apply (Rabs_lt_between' x 1 1) in Hx0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rminus_eq_0 in Hx0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite PSeries_decr_1.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /b (PSeries_decr_1 a x) /PS_decr_1.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
    ring.
    apply CV_radius_inside.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Hcv Rabs_pos_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le, Hx0.
    apply CV_radius_inside.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite H Rabs_pos_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le, Hx0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite -{2}(Rplus_0_l (PSeries a 1)).
    eapply filterlim_comp_2.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hw.
(* Goal: @filterlim nat (NormedModule.sort K V) (fun _ : nat => @opp (NormedModule.AbelianGroup K V) (a O)) eventually (@locally (NormedModule.UniformSpace K V) (@opp (NormedModule.AbelianGroup K V) (a O))) *)
    by apply filterlim_const.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite H1.
    apply @filterlim_plus.
  apply PSeries_correct in Ha1.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  rewrite Hw in Ha1 |- * => {Hw}.

(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  set Sa := sum_n a.
  assert (forall n x, sum_n (fun k => scal (pow_n x k) (a k)) n = (1 - x) * sum_n (fun k => scal (pow_n x k) (Sa k)) n + scal (pow_n x (S n)) (Sa n)).
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
    elim => /= [ | n IH] x.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /Sa !sum_O scal_one mult_one_r /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
    rewrite /scal /= /mult /= ; ring.
    rewrite !sum_Sn IH ; clear IH.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /Sa /= !sum_Sn -/(Sa n).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /plus /scal /= /mult /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
    ring.
  assert (forall x, Rabs x < 1 -> is_pseries Sa x (PSeries a x / (1 - x))).
    intros x Hx.
    destruct (CV_radius_inside a x) as [l Hl].
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Hcv.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hx.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite (is_pseries_unique _ _ _ Hl).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /is_pseries /is_series.
    replace (@locally R_NormedModule (l / (1 - x)))
      with (Rbar_locally (Rbar_mult (l - ((Rbar_mult x 0) * 0)) (/ (1 - x)))).
    apply (is_lim_seq_ext
      (fun n => (sum_n (fun k : nat => scal (pow_n (K := R_AbsRing) x k) (a k)) n
                     - scal (pow_n (K := R_AbsRing) x (S n)) (Sa n)) / (1 - x))
       (sum_n (fun k : nat => scal (pow_n (K := R_AbsRing) x k) (Sa k)))).
       intros n ; rewrite H.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
       field.
       apply Rgt_not_eq ; apply -> Rminus_lt_0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
       by apply Rabs_lt_between, Hx.
    apply is_lim_seq_scal_r.
    apply is_lim_seq_minus'.
    apply Hl.
    apply is_lim_seq_mult'.
    apply is_lim_seq_mult'.
(* Goal: is_lim_seq (fun _ : nat => Rabs (a O)) (Finite (Rabs (a O))) *)
(* Goal: CV_disk a x *)
    apply is_lim_seq_const.
    eapply is_lim_seq_ext.
    intros n ; by apply sym_eq, pow_n_pow.
    apply is_lim_seq_geom.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hx.
    move: Ha1 ; apply (is_lim_seq_ext _ _ 0).
    intros n ; apply sum_n_ext => k.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite pow_n_pow pow1 scal_one.
    by replace (Rbar_mult (l - Rbar_mult x 0 * 0) (/ (1 - x)))
      with (Finite (l / (1 - x)))
      by (simpl ; apply f_equal ; unfold Rdiv ; ring).
  apply filterlim_ext_loc with (fun x => (1-x) * PSeries Sa x).
  exists (mkposreal _ Rlt_0_1) ; simpl ; intros x Hx Hx1.
  apply (Rabs_lt_between' x 1 1) in Hx.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rminus_eq_0 in Hx.
  assert (Rabs x < 1).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rabs_pos_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hx1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le, Hx.
  specialize (H0 x H1).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (is_pseries_unique _ _ _ H0).
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
  by apply Rgt_not_eq ; apply -> Rminus_lt_0.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply filterlim_locally => eps.
  destruct (Ha1 (ball 0 (pos_div_2 eps))) as [N HN].
  apply locally_ball.

  eapply filter_imp.
  intros x Hx.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (PSeries_decr_n _ N).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (double_var eps) Rmult_plus_distr_l.
  eapply Rle_lt_trans.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /minus opp_zero plus_zero_r.
  apply @abs_triangle.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /abs /= 3!Rabs_mult.
  apply Rplus_lt_le_compat.
  eapply Rle_lt_trans.
(* Goal: Rle (Rmult M (IZR (Zpos xH))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
  eapply Rle_trans.
  apply Rsum_abs.
  apply sum_growing.
(* Goal: forall n : nat, @eq R (Rmult (a n) (pow x n)) (@scal R_Ring R_ModuleSpace (@pow_n R_Ring x n) (a n)) *)
  intros n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rabs_mult.
(* Goal: Rle (Rmult M (IZR (Zpos xH))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -RPow_abs.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  apply pow_incr ; split.
(* Goal: Rle (IZR Z0) (Rabs x) *)
(* Goal: Rle (Rabs x) r *)
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rabs_pos.
  apply Rlt_le.
  instantiate (1 := 1).
  eapply (proj1 Hx).
  destruct Hx as [Hx1 Hx].
  eapply Rle_lt_trans.
(* Goal: Rle (Rmult M (IZR (Zpos xH))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
  apply (Rmax_r 1).
(* Goal: Rlt (Rminus (IZR (Zpos xH)) (pos eps)) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply Rlt_div_r.
  eapply Rlt_le_trans, Rmax_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_0_1.
  eapply (proj1 Hx).
  destruct Hx as [Hx1 [Hx2 Hx]].
  eapply Rle_trans.
(* Goal: Rle (Rmult M (IZR (Zpos xH))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rmult_le_compat ; try by apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -/(pow _ (S N)) -RPow_abs.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  apply pow_incr ; split.
(* Goal: Rle (IZR Z0) (Rabs x) *)
(* Goal: Rle (Rabs x) r *)
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rabs_pos.
  apply Rlt_le, Hx1.
  eapply Rle_trans.
  apply Series_Rabs.
  eapply @ex_series_le.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  intros n ; rewrite /norm /= /abs /= Rabs_Rabsolu.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rabs_mult.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -RPow_abs.
(* Goal: Rle (Rmult (Rabs (Rmult (a n) (pow x n))) (Rabs x)) (Rmult M (Rabs x)) *)
  apply Rmult_le_compat_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite RPow_abs ; by apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_decr_n.
  eapply Rle_trans, Rlt_le, HN.
  apply Req_le, f_equal.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /minus opp_zero plus_zero_r.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply sum_n_ext => k.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite pow_n_pow pow1 scal_one.
  apply le_trans with (1 := le_n_Sn _).
  apply le_plus_l.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rmult (Rabs c) (Rabs (Rmult (a n) (pow x n)))) *)
  apply @ex_series_scal.
  apply ex_series_geom.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Rabs_Rabsolu.
  apply Series_le.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  intros n ; split.
(* Goal: Rle (IZR Z0) (Rabs x) *)
(* Goal: Rle (Rabs x) r *)
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rabs_mult.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -RPow_abs.
(* Goal: Rle (Rmult (Rabs (Rmult (a n) (pow x n))) (Rabs x)) (Rmult M (Rabs x)) *)
  apply Rmult_le_compat_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite RPow_abs ; by apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_decr_n.
  eapply Rle_trans, Rlt_le, HN.
  apply Req_le, f_equal.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /minus opp_zero plus_zero_r.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply sum_n_ext => k.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite pow_n_pow pow1 scal_one.
  apply le_trans with (1 := le_n_Sn _).
  apply le_plus_l.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rmult (Rabs c) (Rabs (Rmult (a n) (pow x n)))) *)
  apply @ex_series_scal.
  apply ex_series_geom.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Rabs_Rabsolu.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Series_scal_l Series_geom.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite pow1 Rmult_1_l !Rabs_pos_eq.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  apply Req_le ; simpl ; field.
  apply Rgt_not_eq ; apply -> Rminus_lt_0.
  eapply Rle_lt_trans, Hx1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rle_abs.
(* Goal: or (@eq (AbsRing.sort K) x (@zero (AbsRing.AbelianGroup K))) (@ex (Ring.sort (AbsRing.Ring K)) (fun y : Ring.sort (AbsRing.Ring K) => @eq (Ring.sort (AbsRing.Ring K)) (@mult (AbsRing.Ring K) y x) (@one (AbsRing.Ring K)))) *)
(* Goal: @ex_pseries K V (PS_decr_n a n) x *)
  apply Hx.
  apply -> Rminus_le_0.
  eapply Rle_trans, Rlt_le, Hx1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rle_abs.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Rabs_Rabsolu.
  eexists ; apply H0, Hx.
  assert (0 < Rmin (eps / 2 / Rmax 1 (sum_f_R0 (fun n : nat => Rabs (Sa n) * 1 ^ n) N)) 1).
    apply Rmin_case.
(* Goal: Rlt (IZR Z0) (Rdiv (Rmult (pow r n) M) (INR (fact n))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rdiv_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply is_pos_div_2.
    eapply Rlt_le_trans, Rmax_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_0_1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_0_1.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (mkposreal _ H1) => /= y Hy Hy1.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  split.
  apply (Rabs_lt_between'
    y 1 (Rmin (eps / 2 / Rmax 1 (sum_f_R0 (fun n : nat => Rabs (Sa n) * 1 ^ n) N))
    1)) in Hy.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite {1}/Rminus -Rmax_opp_Rmin Rplus_max_distr_l Rplus_min_distr_l in Hy.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -!/(Rminus _ _) Rminus_eq_0 in Hy.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rabs_pos_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by [].
  apply Rlt_le.
  eapply Rle_lt_trans, Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rmax_r.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  split.
  eapply Rlt_le_trans.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Rabs_Ropp Ropp_minus_distr'.
  apply Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rmin_l.
  apply (Rabs_lt_between'
    y 1 (Rmin (eps / 2 / Rmax 1 (sum_f_R0 (fun n : nat => Rabs (Sa n) * 1 ^ n) N))
    1)) in Hy.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite {1}/Rminus -Rmax_opp_Rmin Rplus_max_distr_l Rplus_min_distr_l in Hy.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -!/(Rminus _ _) Rminus_eq_0 in Hy.
  eapply Rle_trans, Rlt_le, Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rmax_r.
Qed.


(** * Analysis *)

(** ** Continuity *)

Lemma PSeries_continuity (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> continuity_pt (PSeries a) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (CV_radius_Reals_2 a x H) => r H0.
  apply (CVU_continuity
    (fun (n : nat) (x : R) => sum_f_R0 (fun k : nat => a k * x ^ k) n)
    (PSeries a) x r H0).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => n y Hy.
(* Goal: continuity_pt (fun x : R => sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) y *)
(* Goal: Boule x r x *)
  apply continuity_pt_finite_SF.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => k Hk.
(* Goal: continuity_pt (fun y : R => Rmult (a k) (pow y k)) y *)
(* Goal: Boule x r x *)
  apply continuity_pt_scal.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: k {Hk} => /= [ | k IH].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply continuity_pt_const => d f.
(* Goal: continuity_pt (fun y : R => Rmult y (pow y k)) y *)
(* Goal: Boule x r x *)
  apply continuity_pt_mult.
(* Goal: continuity_pt (fun y : R => y) y *)
(* Goal: continuity_pt (fun y : R => pow y k) y *)
(* Goal: Boule x r x *)
  apply derivable_continuous_pt, derivable_pt_id.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply IH.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite /Boule Rminus_eq_0 Rabs_R0 ; by apply r.
Qed.

(** ** Differentiability *)

Definition PS_derive (a : nat -> R) (n : nat) :=
  INR (S n) * a (S n).
Lemma CV_radius_derive (a : nat -> R) :
  CV_radius (PS_derive a) = CV_radius a.
Proof.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H := (CV_radius_bounded a).
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H0 := (CV_radius_bounded (PS_derive a)).

(* Goal: @eq Rbar (CV_radius (PS_derive a)) (CV_radius a) *)
  apply Rbar_le_antisym.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply is_lub_Rbar_subset with (2 := H) (3 := H0) => x [M Ha].
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (a n) (pow x n))) M) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  exists (Rmax (Rabs (a O)) (Rabs x * M)) ; case => /= [ | n].
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
  rewrite Rmult_1_r ; by apply Rmax_l.
(* Goal: Rle (Rabs (Rmult (a (S n)) (Rmult x (pow x n)))) (Rmax (Rabs (a O)) (Rmult (Rabs x) M)) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rle_trans with (2 := Rmax_r _ _).
  replace (a (S n) * (x * x ^ n))
    with (x  * ((PS_derive a n * x ^ n) / INR (S n)))
    by (rewrite /PS_derive ; field ; apply not_0_INR, sym_not_eq, O_S).
(* Goal: Rle (Rmult M (IZR (Zpos xH))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  rewrite Rabs_mult ; apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rle (Rabs (Rdiv (Rmult (PS_derive a n) (pow x n)) (INR (S n)))) M *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  rewrite Rabs_div ; [ | by apply not_0_INR, sym_not_eq, O_S].
(* Goal: Rle (Rdiv (Rabs (Rmult (PS_derive a n) (pow x n))) (Rabs (INR (S n)))) M *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rle_div_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos_lt, not_0_INR, sym_not_eq, O_S.
(* Goal: Rle (Rabs (Rmult (PS_derive a n) (pow x n))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rle_trans with (1 := Ha n).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -{1}(Rmult_1_r M).
(* Goal: Rle (Rmult M (IZR (Zpos xH))) (Rmult M (Rabs (INR (S n)))) *)
(* Goal: Rbar_le (CV_radius a) (CV_radius (PS_derive a)) *)
  apply Rmult_le_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rle_trans with (2 := Ha O), Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rle_trans with (2 := Rle_abs _), (le_INR 1), le_n_S, le_O_n.

(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply H => x [M Hx].

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H1 : Rbar_le (Finite 0) (CV_radius (PS_derive a)).
(* Goal: Rbar_le (Finite (IZR Z0)) (CV_radius (PS_derive a)) *)
(* Goal: Rbar_le (Finite x) (CV_radius (PS_derive a)) *)
    apply H0 ; exists (Rabs (PS_derive a O)) ; case => /= [ | n].
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    rewrite Rmult_1_r ; by apply Rle_refl.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rmult_0_l Rmult_0_r Rabs_R0 ; by apply Rabs_pos.
  wlog: x Hx / (0 < x) => [Hw |  Hx0].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (Rle_lt_dec x 0) => Hx0.
(* Goal: Rbar_le (Finite x) (CV_radius (PS_derive a)) *)
(* Goal: Rbar_le (Finite x) (CV_radius (PS_derive a)) *)
(* Goal: Rbar_le (Finite x) (CV_radius (PS_derive a)) *)
    apply Rbar_le_trans with (Finite 0).
(* Goal: Rbar_le (Finite x) (Finite (IZR Z0)) *)
(* Goal: Rbar_le (Finite (IZR Z0)) (CV_radius (PS_derive a)) *)
(* Goal: Rbar_le (Finite x) (CV_radius (PS_derive a)) *)
(* Goal: Rbar_le (Finite x) (CV_radius (PS_derive a)) *)
    exact Hx0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply H1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hw.

(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  suff : forall y, 0 < y < x -> Rbar_le (Finite y) (CV_radius (PS_derive a)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (CV_radius (PS_derive a)) H1 => [l | | ] //= H1 H2.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rnot_lt_le => /= H3.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H4 : (0 < (x+l)/2 < x).
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
      split.
(* Goal: Rlt (IZR Z0) (Rdiv (Rmult (pow r n) M) (INR (fact n))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      apply Rdiv_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by apply Rplus_lt_le_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by apply Rlt_R0_R2.
(* Goal: Rlt l (Rdiv (Rplus x l) (IZR (Zpos (xO xH)))) *)
(* Goal: forall (y : R) (_ : and (Rlt (IZR Z0) y) (Rlt y x)), Rbar_le (Finite y) (CV_radius (PS_derive a)) *)
      apply Rminus_lt, Ropp_lt_cancel ; field_simplify.
(* Goal: Rlt (IZR Z0) (Rdiv (Rmult (pow r n) M) (INR (fact n))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      rewrite Rdiv_1 ; apply Rdiv_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by apply -> Rminus_lt_0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      by apply Rlt_R0_R2.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move: (H2 _ H4).
(* Goal: forall _ : Rle (Rdiv (Rplus x l) (IZR (Zpos (xO xH)))) l, False *)
(* Goal: forall (y : R) (_ : and (Rlt (IZR Z0) y) (Rlt y x)), Rbar_le (Finite y) (CV_radius (PS_derive a)) *)
    apply Rlt_not_le.
(* Goal: Rlt l (Rdiv (Rplus x l) (IZR (Zpos (xO xH)))) *)
(* Goal: forall (y : R) (_ : and (Rlt (IZR Z0) y) (Rlt y x)), Rbar_le (Finite y) (CV_radius (PS_derive a)) *)
    apply Rminus_lt, Ropp_lt_cancel ; field_simplify.
(* Goal: Rlt (IZR Z0) (Rdiv (Rmult (pow r n) M) (INR (fact n))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    rewrite Rdiv_1 ; apply Rdiv_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rplus_comm ; by apply -> Rminus_lt_0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_R0_R2.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => y Hy.
(* Goal: Rbar_le (Finite y) (CV_radius (PS_derive a)) *)
  apply H0 ; rewrite /PS_derive.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H2 : is_lim_seq (fun n => INR (S n) / x * (y/x) ^ n) 0.
(* Goal: is_lim_seq (fun n : nat => Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n)) (Finite (IZR Z0)) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply ex_series_lim_0.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n)) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply ex_series_Rabs.
(* Goal: @ex_series R_AbsRing R_NormedModule (fun n : nat => Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply CV_disk_DAlembert with 1.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => n.
(* Goal: not (@eq R (Rdiv (INR (S n)) x) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rdiv (INR (S (S n))) x) (Rdiv (INR (S n)) x))) (Finite (IZR (Zpos xH))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rgt_not_eq, Rdiv_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply lt_0_INR, lt_O_Sn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Rlt_trans with y ; by apply Hy.
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rdiv (INR (S (S n))) x) (Rdiv (INR (S n)) x))) (Finite (IZR (Zpos xH))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply is_lim_seq_spec.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => eps.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (nfloor_ex (/eps)) => [ | N HN].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le, Rinv_0_lt_compat, eps.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (S N) => n Hn.
(* Goal: Rlt (Rabs (Rminus (Rabs (Rdiv (Rdiv (INR (S (S n))) x) (Rdiv (INR (S n)) x))) (IZR (Zpos xH)))) (pos eps) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rabs_lt_between'.
    replace (INR (S (S n)) / x / (INR (S n) / x))
      with (INR (S (S n)) / (INR (S n)))
      by (field ; split ; [apply Rgt_not_eq, Rlt_trans with y ; by apply Hy |
       by apply Rgt_not_eq, lt_0_INR, lt_O_Sn]).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rabs_pos_eq.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    split.
(* Goal: Rlt (Rminus (IZR (Zpos xH)) (pos eps)) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rlt_div_r.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply lt_0_INR, lt_O_Sn.
(* Goal: Rlt (INR (S (S n))) (Rmult (Rplus (IZR (Zpos xH)) (pos eps)) (INR (S n))) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    rewrite ?S_INR Rminus_lt_0 ; ring_simplify.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rplus_assoc.
(* Goal: Rlt (IZR Z0) (Rplus (Rmult (INR n) (pos eps)) (Rplus (pos eps) (IZR (Zpos xH)))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rplus_le_lt_0_compat.
(* Goal: Rle (IZR Z0) (Rmult (INR n) (pos eps)) *)
(* Goal: Rlt (IZR Z0) (Rplus (pos eps) (IZR (Zpos xH))) *)
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rmult_le_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply (le_INR O), le_O_n.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le, eps.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rle_lt_0_plus_1, Rlt_le, eps.
(* Goal: Rlt (Rdiv (INR (S (S n))) (INR (S n))) (Rplus (IZR (Zpos xH)) (pos eps)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rlt_div_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply lt_0_INR, lt_O_Sn.
(* Goal: Rlt (INR (S (S n))) (Rmult (Rplus (IZR (Zpos xH)) (pos eps)) (INR (S n))) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    rewrite ?S_INR Rminus_lt_0 ; ring_simplify.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /Rminus Rplus_assoc -/(Rminus eps 1).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite -(Ropp_involutive (eps-1)) -Rminus_lt_0 Ropp_minus_distr'.
(* Goal: Rlt (Rminus (IZR (Zpos xH)) (pos eps)) (Rmult (pos eps) (INR n)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rlt_trans with 1.
(* Goal: Rlt (Rminus (IZR (Zpos xH)) (pos eps)) (IZR (Zpos xH)) *)
(* Goal: Rlt (IZR (Zpos xH)) (Rmult (pos eps) (INR n)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rminus_lt_0 ; ring_simplify ; by apply eps.
(* Goal: Rlt (IZR (Zpos xH)) (Rmult (pos eps) (INR n)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    replace 1 with (eps*/eps) by (field ; apply Rgt_not_eq, eps).
(* Goal: Rlt (Rmult (pos eps) (Rinv (pos eps))) (Rmult (pos eps) (INR n)) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rmult_lt_compat_l.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply eps.
(* Goal: Rlt (Rinv (pos eps)) (INR n) *)
(* Goal: Rle (IZR Z0) (Rdiv (INR (S (S n))) (INR (S n))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rlt_le_trans with (1 := proj2 HN).
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    rewrite -S_INR ; by apply le_INR.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Rlt_le, Rdiv_lt_0_compat ; by apply lt_0_INR, lt_O_Sn.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    right ; split.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rgt_not_eq, Rlt_0_1.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rinv_1 Rabs_pos_eq.
(* Goal: Rlt (Rdiv y x) (IZR (Zpos xH)) *)
(* Goal: Rle (IZR Z0) (Rdiv y x) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply -> Rdiv_lt_1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Rlt_trans with y ; by apply Hy.
(* Goal: Rle (IZR Z0) (Rdiv y x) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply Rlt_le, Rdiv_lt_0_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Rlt_trans with y ; by apply Hy.
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
    apply is_lim_seq_spec in H2.
    case: (H2 (mkposreal _ (Rlt_0_1))) ;
    simpl pos => {H2} N HN.
    set My := fix f n := match n with
      | O => 1
      | S n => Rmax (Rabs (INR (S n) / x * (y / x) ^ n)) (f n)
    end.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (M * My N) => n.
    replace (INR (S n) * a (S n) * y ^ n)
      with ((a (S n) * x ^ (S n)) * (INR (S n) /x * (y / x) ^ n))
      by (rewrite /pow -/pow ; apply Rminus_diag_uniq ; field_simplify ;
      [rewrite ?Rdiv_1 | apply Rgt_not_eq, Rlt_trans with y ; by apply Hy ] ;
      rewrite ?Rmult_assoc -(Rmult_minus_distr_l (a (S n))) ;
      apply Rmult_eq_0_compat_l ;
      rewrite Rmult_comm Rmult_assoc -(Rmult_minus_distr_l (INR (S n))) ;
      apply Rmult_eq_0_compat_l, Rminus_diag_eq ;
      elim: n => /= [ | n IH] ; [ring
      | rewrite -IH ; field ; apply Rgt_not_eq, Rlt_trans with y ; by apply Hy]).
(* Goal: Rle (Rabs (Rmult (Rmult (a (S n)) (pow x (S n))) (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n)))) (Rmult M (My N)) *)
    rewrite Rabs_mult ; apply Rmult_le_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hx.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (le_lt_dec N n) => Hn.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My N) *)
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My N) *)
    apply Rle_trans with 1.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    move: (HN n Hn) ; rewrite Rminus_0_r ; by apply Rlt_le.
    move: (HN n Hn) => {HN Hn} ;
    elim: N => [ | N IH] H2.
(* Goal: Rle (IZR (Zpos xH)) (My O) *)
(* Goal: Rle (IZR (Zpos xH)) (My (S N)) *)
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My N) *)
    simpl ; by apply Rle_refl.
    apply Rle_trans with (1 := IH H2) ;
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /My -/My ; by apply Rmax_r.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
    elim: N n Hn {HN} => [ | N IH] n Hn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply lt_n_O in Hn.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    apply le_S_n in Hn ; case: (le_lt_eq_dec _ _ Hn) => {Hn} Hn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Rle_trans with (2 := Rmax_r _ (My N)) ; by apply IH.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    rewrite Hn ; by apply (Rmax_l _ (My N)).
Qed.

Lemma is_derive_PSeries (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> is_derive (PSeries a) x (PSeries (PS_derive a) x).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx.

  case: (CV_radius_Reals_2 _ _ Hx) => r0 Hr0 ;
  rewrite -CV_radius_derive in Hx ;
  case: (CV_radius_Reals_2 _ _ Hx) => r1 Hr1 ;
  rewrite CV_radius_derive in Hx.
  apply CVU_dom_Reals in Hr0 ;
  apply CVU_dom_Reals in Hr1.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Hr : 0 < (Rmin r0 r1).
    apply Rmin_case.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply r0.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply r1.

(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  set D := (Boule x (mkposreal _ Hr)).

  assert (Ho : open D).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => y Hy.
    apply Rabs_lt_between' in Hy ; simpl in Hy.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H : 0 < Rmin ((x+Rmin r0 r1)-y) (y-(x-Rmin r0 r1)).
    apply Rmin_case.
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My (S N)) *)
    rewrite -(Rminus_eq_0 y) ; by apply Rplus_lt_compat_r, Hy.
    rewrite -(Rminus_eq_0 ((x-Rmin r0 r1))) /Rminus ;
    by apply Rplus_lt_compat_r , Hy.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (mkposreal _ H) => /= z Hz.
    apply Rabs_lt_between' ; split ; apply (Rplus_lt_reg_l (-y)) ; simpl.
    apply Ropp_lt_cancel.
    apply Rle_lt_trans with (1 := Rabs_maj2 _).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Ropp_plus_distr ?Ropp_involutive (Rplus_comm (-y)).
    apply Rlt_le_trans with (1 := Hz).
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Rmin_r.
    apply Rle_lt_trans with (1 := Rle_abs _).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite ?(Rplus_comm (-y)).
    apply Rlt_le_trans with (1 := Hz).
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Rmin_l.

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Hc : is_connected D.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => x0 y z Hx0 Hy Hx0yz.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /D.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: Hx0yz => H1 H2.
    apply (Rplus_le_compat_r (-x)) in H1.
    apply (Rplus_le_compat_r (-x)) in H2.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move: (conj H1 H2) => {H1 H2} Hxyz.
    apply Rabs_le_between_Rmax in Hxyz.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rle_lt_trans with (1 := Hxyz) => /=.
(* Goal: forall n : nat, @eq R (@sum_n R_AbelianGroup (fun k : nat => Rmult (@PS_incr_1 R_AbsRing R_NormedModule a k) (pow x k)) (S n)) (@sum_n R_AbelianGroup (fun n0 : nat => Rmult x (Rmult (a n0) (pow x n0))) n) *)
    apply Rmax_case.
    apply Rle_lt_trans with (1 := Rle_abs _).
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Hy.
    apply Rle_lt_trans with (1 := Rabs_maj2 _).
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Hx0.

  have Hfn : CVU_dom
    (fun (n : nat) (y : R) => sum_f_R0 (fun k : nat => a k * y ^ k) n) D.
    apply CVU_dom_include with (Boule x r0).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => y Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le_trans with (1 := Hy), Rmin_l.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Hr0.

  have Idn : (forall (n : nat) (x : R), (0 < n)%nat ->
    is_derive (fun (y : R) =>
      sum_f_R0 (fun k : nat => a k * y ^ k) n) x
      (sum_f_R0 (fun k : nat => (PS_derive a) k * x ^ k) (pred n))).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case => [ y Hn | n y _ ].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply lt_irrefl in Hn.
    elim: n => [ | n] ; simpl pred ; rewrite /sum_f_R0 -/sum_f_R0.
    replace (PS_derive a 0 * y ^ 0)
      with (0 + a 1%nat * (1 * 1))
      by (rewrite /PS_derive /= ; ring).
(* Goal: False *)
    apply: is_derive_plus.
(* Goal: ex_derive_n (PSeries a) (S n) x *)
    simpl.
(* Goal: False *)
    apply: is_derive_const.
    apply is_derive_scal.
(* Goal: False *)
    apply: is_derive_scal_l.
(* Goal: False *)
    apply: is_derive_id.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => IH.
(* Goal: False *)
    apply: is_derive_plus.
(* Goal: @is_pseries K V (fun k : nat => a (S (Init.Nat.add n k))) x ln *)
(* Goal: @is_pseries K V (fun k : nat => a (S (S (Init.Nat.add n k)))) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) *)
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n))) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)) (a (S n))))))) *)
    apply IH.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /PS_derive.
    replace (INR (S (S n)) * a (S (S n)) * y ^ S n)
      with (a (S (S n)) * (INR (S (S n)) * y^S n))
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
      by ring.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply is_derive_Reals, derivable_pt_lim_scal, derivable_pt_lim_pow.

  have Edn : (forall (n : nat) (x : R), D x ->
    ex_derive (fun (y : R) =>
      sum_f_R0 (fun k : nat => a k * y ^ k) n) x).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case => [ | n] y Hy.
(* Goal: ex_derive_n (PSeries a) (S n) x *)
    simpl.
(* Goal: False *)
    apply: ex_derive_const.
    exists (sum_f_R0 (fun k : nat => PS_derive a k * y ^ k) (pred (S n))).
    apply (Idn (S n) y).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply lt_O_Sn.

  have Cdn : (forall (n : nat) (x : R), D x ->
    continuity_pt
      (Derive ((fun (n0 : nat) (y : R) =>
        sum_f_R0 (fun k : nat => a k * y ^ k) n0) n)) x).
    have Cdn : (forall (n : nat) (x : R), D x ->
      continuity_pt (fun x => sum_f_R0 (fun k : nat => PS_derive a k * x ^ k) n) x).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
      move => n y Hy.
      apply derivable_continuous_pt.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
      elim: n => [ /= | n IH].
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      exact: derivable_pt_const.
      apply derivable_pt_plus ; rewrite -/sum_f_R0.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      exact: IH.
      apply derivable_pt_scal, derivable_pt_pow.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case => [ | n] y Hy.
(* Goal: Rle (IZR (Zpos xH)) (My O) *)
(* Goal: Rle (IZR (Zpos xH)) (My (S N)) *)
(* Goal: Rle (Rabs (Rmult (Rdiv (INR (S n)) x) (pow (Rdiv y x) n))) (My N) *)
    simpl ; by apply continuity_pt_const => z.
    move => e He ; case: (Cdn n y Hy e He) => {Cdn} d [Hd Cdn].
    destruct (Ho y Hy) as [d0 Hd0].
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have Hd1 : 0 < Rmin d d0.
      apply Rmin_case ; [exact: Hd | by apply d0].
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    exists (mkposreal _ Hd1) ; split.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Hd1.
    move => z Hz ; simpl in Hz.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite (is_derive_unique _ _ _ (Idn (S n) z (lt_O_Sn _))).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite (is_derive_unique _ _ _ (Idn (S n) y (lt_O_Sn _))).
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply (Cdn z) ; split.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hz.
    apply Rlt_le_trans with (1 := proj2 Hz), Rmin_l.

  have Hdn : CVU_dom (fun (n : nat) (x : R) =>
          Derive
            ((fun (n0 : nat) (y : R) =>
              sum_f_R0 (fun k : nat => a k * y ^ k) n0) n) x) D.
    apply CVU_dom_include with (Boule x r1).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => y Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rlt_le_trans with (1 := Hy), Rmin_r.
    apply CVU_dom_cauchy ; apply CVU_dom_cauchy in Hr1.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => eps.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (Hr1 eps) => {Hr1} N Hr1.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (S N) => n m y Hy Hn Hm.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: n Hn => [ | n] Hn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply le_Sn_O in Hn.
    apply le_S_n in Hn.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: m Hm => [ | m] Hm.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply le_Sn_O in Hm.
    apply le_S_n in Hm.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite (is_derive_unique _ _ _ (Idn (S n) y (lt_O_Sn _))).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite (is_derive_unique _ _ _ (Idn (S m) y (lt_O_Sn _))).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hr1.

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Hx' : D x.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite /D /Boule /= Rminus_eq_0 Rabs_R0.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H := (CVU_Derive (fun n y => (sum_f_R0 (fun k : nat => a k * y ^ k)) n) D Ho Hc Hfn Edn Cdn Hdn x Hx').
  replace (PSeries (PS_derive a) x)
    with (real (Lim_seq
         (fun n : nat =>
          Derive (fun y : R => sum_f_R0 (fun k : nat => a k * y ^ k) n) x))).
(* Goal: False *)
  apply: is_derive_ext H.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  simpl => t.
  apply (f_equal real), Lim_seq_ext.
  intros n; apply sym_eq, sum_n_Reals.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Lim_seq_incr_1.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply (f_equal real), Lim_seq_ext => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_n_Reals.
  apply is_derive_unique, Idn.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply lt_O_Sn.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => y Hy.
  apply sym_eq.
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rdiv (INR (S (S n))) x) (Rdiv (INR (S n)) x))) (Finite (IZR (Zpos xH))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply is_lim_seq_spec.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => eps.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Hr1 eps (cond_pos eps)) => {Hr1} N Hr1.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists N => n Hn.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Rabs_Ropp Ropp_minus_distr'.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hr1.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => y Hy.
  apply sym_eq.
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rdiv (INR (S (S n))) x) (Rdiv (INR (S n)) x))) (Finite (IZR (Zpos xH))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply is_lim_seq_spec.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => eps.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Hr0 eps (cond_pos eps)) => {Hr0} N Hr0.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists N => n Hn.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Rabs_Ropp Ropp_minus_distr'.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hr0.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => y Hy.
  apply sym_eq.
  apply is_lim_seq_unique.
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rdiv (INR (S (S n))) x) (Rdiv (INR (S n)) x))) (Finite (IZR (Zpos xH))) *)
(* Goal: or (@eq R (IZR (Zpos xH)) (IZR Z0)) (and (not (@eq R (IZR (Zpos xH)) (IZR Z0))) (Rlt (Rabs (Rdiv y x)) (Rinv (IZR (Zpos xH))))) *)
(* Goal: @ex R (fun M : R => forall n : nat, Rle (Rabs (Rmult (Rmult (INR (S n)) (a (S n))) (pow y n))) M) *)
  apply is_lim_seq_spec.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => eps.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Hr1 eps (cond_pos eps)) => {Hr1} N Hr1.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists N => n Hn.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -Rabs_Ropp Ropp_minus_distr'.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hr1.
Qed.
Lemma ex_derive_PSeries (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> ex_derive (PSeries a) x.
Proof.
(* Goal: forall _ : Rbar_lt (Finite (Rabs x)) (CV_radius a), @ex_derive R_AbsRing R_NormedModule (PSeries a) x *)
  move => Hx ; exists (PSeries (PS_derive a) x).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_derive_PSeries.
Qed.
Lemma Derive_PSeries (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> Derive (PSeries a) x = PSeries (PS_derive a) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => H.
(* Goal: @eq R (Derive (PSeries a) x) (PSeries (PS_derive a) x) *)
  apply is_derive_unique.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_derive_PSeries.
Qed.

Lemma is_pseries_derive (a : nat -> R) x :
  Rbar_lt (Rabs x) (CV_radius a)
    -> is_pseries (PS_derive a) x (Derive (PSeries a) x).
Proof.
(* Goal: forall _ : Rbar_lt (Finite (Rabs x)) (CV_radius a), @is_pseries R_AbsRing R_NormedModule (PS_derive a) x (Derive (PSeries a) x) *)
  intros Hx.
(* Goal: @is_pseries R_AbsRing R_NormedModule (PS_derive a) x (Derive (PSeries a) x) *)
  assert (Ha := is_derive_PSeries _ _ Hx).
(* Goal: @is_pseries R_AbsRing R_NormedModule (PS_derive a) x (Derive (PSeries a) x) *)
  apply is_derive_unique in Ha.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Ha.
(* Goal: @is_pseries R_AbsRing R_NormedModule (PS_derive a) x (PSeries (PS_derive a) x) *)
  apply PSeries_correct.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply CV_radius_inside ; rewrite CV_radius_derive.
Qed.
Lemma ex_pseries_derive (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> ex_pseries (PS_derive a) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hx.
  eexists.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_pseries_derive.
Qed.

Definition PS_derive_n (n : nat) (a : nat -> R) :=
  (fun k => (INR (fact (k + n)%nat) / INR (fact k)) * a (k + n)%nat).

Lemma is_derive_n_PSeries (n : nat) (a : nat -> R) :
  forall x, Rbar_lt (Rabs x) (CV_radius a)
    -> is_derive_n (PSeries a) n x (PSeries (PS_derive_n n a) x).
Proof.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n => [ | n IH] x Hx.
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  simpl ; rewrite /PS_derive_n /=.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply PSeries_ext => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -plus_n_O.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
  apply Rgt_not_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply INR_fact_lt_0.
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) (S n))) (@sum_n (NormedModule.AbelianGroup K V) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (PS_scal c a k)) (S n)) *)
(* Goal: @filterlim nat (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun n : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n)) eventually (@locally (NormedModule.UniformSpace K V) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) c l)) *)
  simpl ; rewrite /PS_derive_n /=.
  apply is_derive_ext_loc
    with (PSeries (fun k : nat => INR (fact (k + n)) / INR (fact k) * a (k + n)%nat)).
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case Ha : (CV_radius a) => [cva | | ].
  move: (Hx) ; rewrite Ha ; move/Rminus_lt_0 => Hx0.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (mkposreal _ Hx0) => /= y Hy.
  apply sym_eq.
(* Goal: @eq R (Derive_n (PSeries a) n x) (PSeries (PS_derive_n n a) x) *)
  apply is_derive_n_unique.
(* Goal: @is_pseries K V (fun k : nat => a (S (Init.Nat.add n k))) x ln *)
(* Goal: @is_pseries K V (fun k : nat => a (S (S (Init.Nat.add n k)))) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) *)
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n))) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)) (a (S n))))))) *)
  apply IH.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Ha /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  replace y with ((y-x) + x) by ring.
  apply Rle_lt_trans with (1 := Rabs_triang _ _).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_minus_r.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (mkposreal _ Rlt_0_1) => /= y Hy.
  apply sym_eq.
(* Goal: @eq R (Derive_n (PSeries a) n x) (PSeries (PS_derive_n n a) x) *)
  apply is_derive_n_unique.
(* Goal: @is_pseries K V (fun k : nat => a (S (Init.Nat.add n k))) x ln *)
(* Goal: @is_pseries K V (fun k : nat => a (S (S (Init.Nat.add n k)))) x (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) *)
(* Goal: @eq (ModuleSpace.sort (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) y (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) ln (@opp (NormedModule.AbelianGroup K V) (a (S (Init.Nat.add n O)))))) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) y (@mult (AbsRing.Ring K) y (@pow_n (AbsRing.Ring K) y n))) (@plus (NormedModule.AbelianGroup K V) l (@opp (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@plus (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (@sum_n (ModuleSpace.AbelianGroup (AbsRing.Ring K) (NormedModule.ModuleSpace K V)) (fun k : nat => @scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@pow_n (AbsRing.Ring K) x k) (a k)) n) (@scal (AbsRing.Ring K) (NormedModule.ModuleSpace K V) (@mult (AbsRing.Ring K) x (@pow_n (AbsRing.Ring K) x n)) (a (S n))))))) *)
  apply IH.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Ha /=.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Ha in Hx.
  evar (l : R).
  replace (PSeries _ x) with l.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /l {l}.
  apply is_derive_PSeries.
  replace (CV_radius (fun k : nat => INR (fact (k + n)) / INR (fact k) * a (k + n)%nat))
    with (CV_radius a).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hx.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n {IH} => [ | n IH].
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply CV_radius_ext => n.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -plus_n_O.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
  apply Rgt_not_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply INR_fact_lt_0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite IH.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -CV_radius_derive.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  apply CV_radius_ext => k.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /PS_derive.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -plus_n_Sm plus_Sn_m /fact -/fact ?mult_INR ?S_INR.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
  rewrite -S_INR ; split ; apply Rgt_not_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply INR_fact_lt_0.
  apply (lt_INR O), lt_O_Sn.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /l {l}.
  apply PSeries_ext.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  move => k ; rewrite /PS_derive.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -plus_n_Sm plus_Sn_m /fact -/fact ?mult_INR ?S_INR.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  field.
  rewrite -S_INR ; split ; apply Rgt_not_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply INR_fact_lt_0.
  apply (lt_INR O), lt_O_Sn.
Qed.
Lemma ex_derive_n_PSeries (n : nat) (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> ex_derive_n (PSeries a) n x.
Proof.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n a x => [ | n IH] a x Hx.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by simpl.
(* Goal: ex_derive_n (PSeries a) (S n) x *)
  simpl.
(* Goal: @ex_derive R_AbsRing R_NormedModule (Derive_n (PSeries a) n) x *)
  exists (PSeries (PS_derive_n (S n) a) x).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply (is_derive_n_PSeries (S n)).
Qed.

Lemma Derive_n_PSeries (n : nat) (a : nat -> R) (x : R) :
  Rbar_lt (Finite (Rabs x)) (CV_radius a)
    -> Derive_n (PSeries a) n x = PSeries (PS_derive_n n a) x.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => H.
(* Goal: @eq R (Derive_n (PSeries a) n x) (PSeries (PS_derive_n n a) x) *)
  apply is_derive_n_unique.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply is_derive_n_PSeries.
Qed.

Lemma CV_radius_derive_n (n : nat) (a : nat -> R) :
  CV_radius (PS_derive_n n a) = CV_radius a.
Proof.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n a => [ | n IH] /= a.
(* Goal: @eq Rbar (CV_radius (PS_derive_n (S n) a)) (CV_radius (PS_derive_n n (PS_derive a))) *)
  apply CV_radius_ext.
(* Goal: forall n : nat, @eq R (Rdiv r (INR (S n))) (Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  move => k ; rewrite /PS_derive_n /=.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  rewrite plus_0_r ; field.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply INR_fact_neq_0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(CV_radius_derive a).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -(IH (PS_derive a)).
(* Goal: @eq Rbar (CV_radius (PS_derive_n (S n) a)) (CV_radius (PS_derive_n n (PS_derive a))) *)
  apply CV_radius_ext.
(* Goal: forall n : nat, @eq R (Rdiv r (INR (S n))) (Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  move => k ; rewrite /PS_derive_n /PS_derive.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
  rewrite -plus_n_Sm /fact -/fact mult_INR ; field.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply INR_fact_neq_0.
Qed.

(** Coefficients *)

Lemma Derive_n_coef (a : nat -> R) (n : nat) :
  Rbar_lt (Finite 0) (CV_radius a)
    -> Derive_n (PSeries a) n 0 = a n * (INR (fact n)).
Proof.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim: n a => [ | n IH] a Ha.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rmult_1_r.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite /= /PSeries /Series -(Lim_seq_ext (fun _ => a O)).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite Lim_seq_const.
(* Goal: forall n : nat, @eq R (a O) (@sum_n R_AbelianGroup (fun k : nat => Rmult (a k) (pow (IZR Z0) k)) n) *)
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  elim => /= [ | n IH].
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite sum_O ; ring.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite sum_Sn -IH /plus /= ; ring.
(* Goal: @eq R (Derive_n (PSeries a) (S n) (IZR Z0)) (Rmult (a (S n)) (INR (fact (S n)))) *)
  simpl Derive_n.
  replace (Derive (Derive_n (PSeries a) n) 0)
    with (Derive_n (PSeries (PS_derive a)) n 0).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite IH.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite /fact -/fact mult_INR /PS_derive ; ring.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite CV_radius_derive.
(* Goal: @eq R (Derive_n (PSeries (PS_derive a)) n (IZR Z0)) (Derive (Derive_n (PSeries a) n) (IZR Z0)) *)
  transitivity (Derive_n (Derive (PSeries a)) n 0).
(* Goal: @eq R (Derive_n (PSeries (PS_derive a)) n (IZR Z0)) (Derive_n (Derive (PSeries a)) n (IZR Z0)) *)
(* Goal: @eq R (Derive_n (Derive (PSeries a)) n (IZR Z0)) (Derive (Derive_n (PSeries a) n) (IZR Z0)) *)
  apply Derive_n_ext_loc.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Rbar_eq_dec (CV_radius a) p_infty) => H.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (mkposreal _ Rlt_0_1) => /= x Hx.
(* Goal: @eq R (PSeries (PS_derive a) x) (Derive (PSeries a) x) *)
(* Goal: @eq R (Derive_n (Derive (PSeries a)) n (IZR Z0)) (Derive (Derive_n (PSeries a) n) (IZR Z0)) *)
  apply sym_eq ; apply Derive_PSeries.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite H.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have Hc : 0 < real (CV_radius a).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    case: (CV_radius a) Ha H => /= [c | | ] Ha H ; by [].
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists (mkposreal _ Hc) => /= x Hx.
(* Goal: @eq R (PSeries (PS_derive a) x) (Derive (PSeries a) x) *)
(* Goal: @eq R (Derive_n (Derive (PSeries a)) n (IZR Z0)) (Derive (Derive_n (PSeries a) n) (IZR Z0)) *)
  apply sym_eq ; apply Derive_PSeries.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (CV_radius a) Hx Ha => /= [c | | ] Hx Ha //.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by rewrite /ball /= /AbsRing_ball /= /minus /plus /opp /= -/(Rminus _ _) Rminus_0_r in Hx.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move: (Derive_n_comp (PSeries a) n 1%nat 0) => /= ->.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  by replace (n+1)%nat with (S n) by ring.
Qed.

Lemma PSeries_ext_recip (a b : nat -> R) (n : nat) :
  Rbar_lt (Finite 0) (CV_radius a) -> Rbar_lt (Finite 0) (CV_radius b)
  -> locally 0 (fun x => PSeries a x = PSeries b x)
    -> a n = b n.
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Ha Hb Hab.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have H : a n * (INR (fact n)) = b n * (INR (fact n)).
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  rewrite -?Derive_n_coef => //.
(* Goal: @eq R (Derive_n (PSeries (PS_derive a)) n (IZR Z0)) (Derive_n (Derive (PSeries a)) n (IZR Z0)) *)
(* Goal: @eq R (Derive_n (Derive (PSeries a)) n (IZR Z0)) (Derive (Derive_n (PSeries a) n) (IZR Z0)) *)
  by apply Derive_n_ext_loc.
(* Goal: @eq R (a n) (b n) *)
  replace (a n) with ((a n * INR (fact n)) / (INR (fact n))).
(* Goal: @eq R (Rdiv (Rmult (a n) (INR (fact n))) (INR (fact n))) (b n) *)
(* Goal: @eq R (Rdiv (Rmult (a n) (INR (fact n))) (INR (fact n))) (a n) *)
  rewrite H ; field ; exact: INR_fact_neq_0.
(* Goal: @eq R (Rdiv (Rmult (a n) (INR (fact n))) (INR (fact n))) (a n) *)
  field ; exact: INR_fact_neq_0.
Qed.

Lemma mk_pseries (f : R -> R) (M : R) (r : Rbar) :
  (forall n x, Rbar_lt (Finite (Rabs x)) r
    -> (ex_derive_n f n x) /\ Rabs (Derive_n f n x) <= M)
  -> forall x, Rbar_lt (Finite (Rabs x)) r
    -> is_pseries (fun n => Derive_n f n 0 / INR (fact n))  x (f x).
Proof.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => Hd x Hx.

(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  wlog: r Hx Hd /(Finite (real r) = r) => [Hw | Hr].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: r Hx Hd => /= [r | | ] Hx Hd.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply (Hw (Finite r)).
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply (Hw (Finite (Rabs x+1))).
(* Goal: Rbar_lt (Finite (Rabs x)) (Finite (Rplus (Rabs x) (IZR (Zpos xH)))) *)
(* Goal: forall (n : nat) (x0 : R) (_ : Rbar_lt (Finite (Rabs x0)) (Finite (Rplus (Rabs x) (IZR (Zpos xH))))), and (ex_derive_n f n x0) (Rle (Rabs (Derive_n f n x0)) M) *)
(* Goal: @eq Rbar (Finite (real (Finite (Rplus (Rabs x) (IZR (Zpos xH)))))) (Finite (Rplus (Rabs x) (IZR (Zpos xH)))) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    simpl ; exact: Rlt_plus_1.
(* Goal: forall (n : nat) (x0 : R) (_ : Rbar_lt (Finite (Rabs x0)) (Finite (Rplus (Rabs x) (IZR (Zpos xH))))), and (ex_derive_n f n x0) (Rle (Rabs (Derive_n f n x0)) M) *)
(* Goal: @eq Rbar (Finite (real (Finite (Rplus (Rabs x) (IZR (Zpos xH)))))) (Finite (Rplus (Rabs x) (IZR (Zpos xH)))) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    move => n y Hy ; by apply Hd.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite -Hr in Hx Hd.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move: (real r) Hx Hd => /= {r Hr} r Hx Hd.

(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  wlog: x Hx f Hd / (0 < x) => [Hw | Hx'].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (total_order_T 0 x) => Hx'.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: Hx' => Hx'.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hw.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite -Hx'.
    replace (f 0) with (Derive_n f O 0 / INR (fact O))
      by (simpl ; field).
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) (IZR Z0) (Rdiv (Derive_n f O (IZR Z0)) (INR (fact O))) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply @is_pseries_0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite -Rabs_Ropp in Hx.
    suff Hf : (forall (n : nat) (x : R),
      ((Rabs x)) < r ->
      ex_derive_n (fun x0 : R => f (- x0)) n x /\
      Rabs (Derive_n (fun x0 : R => f (- x0)) n x) <= M).

(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
   move: (Hw _ Hx (fun x => f (-x)) Hf (Ropp_0_gt_lt_contravar _ Hx')) => {Hw} Hw.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
   rewrite Ropp_involutive in Hw.

(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
(* Goal: forall (n : nat) (x : R) (_ : Rlt (Rabs x) r), and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Derive_n (fun x0 : R => f (Ropp x0)) n x)) M) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
   apply is_series_ext with (2:=Hw).
(* Goal: ex_derive_n (PSeries a) (S n) x *)
   intros n; rewrite Derive_n_comp_opp; simpl.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
   rewrite /scal /= /mult /=.
   apply trans_eq with ((pow_n (K := R_AbsRing) (- x) n * (-1) ^ n) *
     (Derive_n f n (- 0) / INR (fact n)));[unfold Rdiv; ring|idtac].
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
   rewrite Ropp_0.
(* Goal: @eq R (Rmult (Rmult (@pow_n (AbsRing.Ring R_AbsRing) (Ropp x) n) (pow (IZR (Zneg xH)) n)) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) *)
(* Goal: @locally R_UniformSpace (Ropp (IZR Z0)) (fun y : R => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: forall (n : nat) (x : R) (_ : Rlt (Rabs x) r), and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Derive_n (fun x0 : R => f (Ropp x0)) n x)) M) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
   apply f_equal2; try reflexivity.
(* Goal: ex_derive_n (PSeries a) (S n) x *)
   clear; induction n; simpl.
(* Goal: @eq R (Rmult (@one (AbsRing.Ring R_AbsRing)) (IZR (Zpos xH))) (@one (AbsRing.Ring R_AbsRing)) *)
(* Goal: @eq R (Rmult (@mult (AbsRing.Ring R_AbsRing) (Ropp x) (@pow_n (AbsRing.Ring R_AbsRing) (Ropp x) n)) (Rmult (IZR (Zneg xH)) (pow (IZR (Zneg xH)) n))) (@mult (AbsRing.Ring R_AbsRing) x (@pow_n (AbsRing.Ring R_AbsRing) x n)) *)
(* Goal: @locally R_UniformSpace (Ropp (IZR Z0)) (fun y : R => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: forall (n : nat) (x : R) (_ : Rlt (Rabs x) r), and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Derive_n (fun x0 : R => f (Ropp x0)) n x)) M) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
   apply Rmult_1_l.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
   rewrite /mult /=.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
   rewrite <- IHn; ring.
   rewrite Ropp_0 ;
    exists (mkposreal r (Rle_lt_trans _ _ _ (Rabs_pos _) Hx)) => /= y Hy k Hk.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
   rewrite /ball /= /AbsRing_ball /= /minus /plus /opp /= -/(Rminus _ _) Rminus_0_r in Hy.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
   by apply (Hd k).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
   move => {x Hx Hx'} n x Hx.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
   rewrite Derive_n_comp_opp.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
   split.
(* Goal: ex_derive_n (fun x0 : R => f (Ropp x0)) n x *)
(* Goal: Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
   apply ex_derive_n_comp_opp.

(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rabs_lt_between in Hx.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: Hx => Hx1 Hx2.
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rminus_lt_0 in Hx1.
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rminus_lt_0 in Hx2.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have Hx := Rmin_pos _ _ Hx1 Hx2 => {Hx1 Hx2}.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (mkposreal _ Hx) => /= y Hy k Hk.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /ball /= /AbsRing_ball /= in Hy.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rabs_lt_between' in Hy.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /Rminus -Rmax_opp_Rmin Rplus_max_distr_l Rplus_min_distr_l in Hy.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: Hy => Hy1 Hy2.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rle_lt_trans with (1 := Rmax_r _ _) in Hy1.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    ring_simplify in Hy1.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rlt_le_trans with (2 := Rmin_l _ _) in Hy2.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    ring_simplify in Hy2.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply (Hd k y).
(* Goal: Rlt (Rabs y) r *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rabs_lt_between.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    by split.

(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rabs_mult -RPow_abs Rabs_Ropp Rabs_R1 pow1 Rmult_1_l.
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Hd.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by rewrite Rabs_Ropp.

(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rabs_lt_between in Hx.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: Hx => Hx1 Hx2.
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rminus_lt_0 in Hx1.
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rminus_lt_0 in Hx2.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have Hx := Rmin_pos _ _ Hx1 Hx2 => {Hx1 Hx2}.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists (mkposreal _ Hx) => /= y Hy k Hk.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /ball /= /AbsRing_ball /= in Hy.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rabs_lt_between' in Hy.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite /Rminus -Rmax_opp_Rmin Rplus_max_distr_l Rplus_min_distr_l in Hy.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: Hy => Hy1 Hy2.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rle_lt_trans with (1 := Rmax_r _ _) in Hy1.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    ring_simplify in Hy1.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rlt_le_trans with (2 := Rmin_l _ _) in Hy2.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    ring_simplify in Hy2.
(* Goal: ex_derive_n f k y *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply (Hd k y).
(* Goal: Rlt (Rabs y) r *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    apply Rabs_lt_between.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
    by split.

(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => P [eps Heps].
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  have : exists N, forall n, (N <= n)%nat -> r ^ (S n) * M / INR (fact (S n)) < eps.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H : is_lim_seq (fun n => r ^ n * M / INR (fact n)) 0.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (Rlt_dec 0 M) => H.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    have H0 : forall n : nat, 0 < r ^ n * M / INR (fact n).
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
      move => n.
(* Goal: Rlt (IZR Z0) (Rdiv (Rmult (pow r n) M) (INR (fact n))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      apply Rdiv_lt_0_compat.
(* Goal: Rlt (IZR Z0) (Rmult (pow r n) M) *)
(* Goal: Rlt (IZR Z0) (INR (fact n)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      apply Rmult_lt_0_compat.
(* Goal: Rlt (IZR Z0) (pow r n) *)
(* Goal: Rlt (IZR Z0) M *)
(* Goal: Rlt (IZR Z0) (INR (fact n)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      apply pow_lt.
(* Goal: Rlt (IZR Z0) r *)
(* Goal: Rlt (IZR Z0) M *)
(* Goal: Rlt (IZR Z0) (INR (fact n)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
      apply Rle_lt_trans with (2 := Hx), Rabs_pos.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      exact: H.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
      exact: INR_fact_lt_0.

(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply ex_series_lim_0, ex_series_Rabs, ex_series_DAlembert with 0.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Rlt_0_1.
(* Goal: forall n : nat, not (@eq R (Rdiv (Rmult (pow r n) M) (INR (fact n))) (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    move => n ; apply Rgt_not_eq, Rlt_gt, H0.

(* Goal: is_lim_seq (fun n : nat => Rabs (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n))))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply is_lim_seq_ext with (fun n => r / INR (S n)).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    move => n ; rewrite Rabs_pos_eq.
(* Goal: @eq R (PSeries a x) (Rplus (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n) (Rmult (Rmult x (pow x n)) (Rmult (Rmult (Rinv x) (Rinv (pow x n))) (Rplus (PSeries a x) (Ropp (sum_f_R0 (fun k : nat => Rmult (a k) (pow x k)) n)))))) *)
(* Goal: @eq nat n (Init.Nat.sub (S n) (S O)) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (a n)) (Rmult (a n) (pow x n)) *)
    rewrite /fact -/fact /pow -/pow ?mult_INR ; field.
(* Goal: and (not (@eq R (INR (fact n)) (IZR Z0))) (and (not (@eq R (INR (S n)) (IZR Z0))) (and (not (@eq R M (IZR Z0))) (not (@eq R (pow r n) (IZR Z0))))) *)
(* Goal: Rle (IZR Z0) (Rdiv (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (Rdiv (Rmult (pow r n) M) (INR (fact n)))) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    repeat split ; apply Rgt_not_eq, Rlt_gt.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: INR_fact_lt_0.
    by apply (lt_INR O), lt_O_Sn.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: H.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply pow_lt, Rle_lt_trans with (Rabs x), Hx ; by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Rlt_le, Rdiv_lt_0_compat ; by apply H0.
(* Goal: is_lim_seq (fun n : nat => Rdiv r (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    rewrite -(Rmult_0_r r) ; apply (is_lim_seq_scal_l _ _ 0) => //.
(* Goal: is_lim_seq (fun n : nat => Rinv (INR (S n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply (is_lim_seq_incr_1 (fun n => / INR n)).
(* Goal: is_lim_seq (fun n : nat => Rinv (INR n)) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    replace (Finite 0) with (Rbar_inv p_infty) by auto.
(* Goal: is_lim_seq (fun n : nat => Rinv (INR n)) (Rbar_inv p_infty) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply is_lim_seq_inv.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply is_lim_seq_INR.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by [].
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    apply Rnot_lt_le in H ; case: H => H.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    contradict H.
(* Goal: not (Rlt M (IZR Z0)) *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rle_not_lt.
(* Goal: Rle (IZR Z0) M *)
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) M) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rle_trans with (Rabs (Derive_n f O x)).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rabs_pos.
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hd.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite H.
(* Goal: is_lim_seq (fun n : nat => Rdiv (Rmult (pow r n) (IZR Z0)) (INR (fact n))) (Finite (IZR Z0)) *)
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply is_lim_seq_ext with (fun _ => 0).
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
    move => n ; rewrite /Rdiv ; ring.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: is_lim_seq_const.
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply is_lim_seq_incr_1 in H.
(* Goal: @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply is_lim_seq_spec in H.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    case: (H eps) => {H} N H.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    exists N => n Hn.
(* Goal: Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps) *)
(* Goal: forall _ : @ex nat (fun N : nat => forall (n : nat) (_ : le N n), Rlt (Rdiv (Rmult (pow r (S n)) M) (INR (fact (S n)))) (pos eps)), @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
    apply Rle_lt_trans with (2 := H n Hn).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rminus_0_r.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    exact: Rle_abs.

(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case => N HN.
(* Goal: @filtermap nat (AbelianGroup.sort (NormedModule.AbelianGroup R_AbsRing R_NormedModule)) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k))))) eventually P *)
  exists N => n Hn.
(* Goal: P (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  apply Heps.

(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  case: (Taylor_Lagrange f n 0 x).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Hx'.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    move => t Ht k Hk.
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    apply Hd.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    rewrite Rabs_right.
(* Goal: Rlt t r *)
(* Goal: Rge t (IZR Z0) *)
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
    apply Rle_lt_trans with (1 := proj2 Ht).
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rle_lt_trans with (1 := Rle_abs _), Hx.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
    by apply Rle_ge, Ht.
(* Goal: forall (x0 : R) (_ : and (and (Rlt (IZR Z0) x0) (Rlt x0 x)) (@eq R (f x) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow (Rminus x (IZR Z0)) m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow (Rminus x (IZR Z0)) (S n)) (INR (fact (S n)))) (Derive_n f (S n) x0))))), @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (f x) (pos eps) (@sum_n (NormedModule.AbelianGroup R_AbsRing R_NormedModule) (fun k : nat => @scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x k) (Rdiv (Derive_n f k (IZR Z0)) (INR (fact k)))) n) *)
  move => y [Hy ->].
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rminus_0_r.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite (sum_n_ext _ (fun m : nat => x ^ m / INR (fact m) * Derive_n f m 0)).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite sum_n_Reals.
(* Goal: @ball (NormedModule.UniformSpace R_AbsRing R_NormedModule) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow x m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow x (S n)) (INR (fact (S n)))) (Derive_n f (S n) y))) (pos eps) (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow x m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rle_lt_trans with (2 := HN n Hn).
  replace (r ^ S n * M / INR (fact (S n)))
    with ((r^S n / INR (fact (S n))) * M)
    by (rewrite /Rdiv ; ring).
(* Goal: Rle (@abs R_AbsRing (@minus (AbsRing.AbelianGroup R_AbsRing) (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow x m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rplus (sum_f_R0 (fun m : nat => Rmult (Rdiv (pow x m) (INR (fact m))) (Derive_n f m (IZR Z0))) n) (Rmult (Rdiv (pow x (S n)) (INR (fact (S n)))) (Derive_n f (S n) y))))) (Rmult (Rdiv (pow r (S n)) (INR (fact (S n)))) M) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  change minus with Rminus.
  ring_simplify (sum_f_R0 (fun m : nat => x ^ m / INR (fact m) * Derive_n f m 0) n
    - (sum_f_R0 (fun m : nat => x ^ m / INR (fact m) * Derive_n f m 0) n +
    x ^ S n / INR (fact (S n)) * Derive_n f (S n) y)).
(* Goal: Rle (@abs R_AbsRing (Rmult (Ropp (Rdiv (pow x (S n)) (INR (fact (S n))))) (Derive_n f (S n) y))) (Rmult (Rdiv (pow r (S n)) (INR (fact (S n)))) M) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  change abs with Rabs.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rabs_mult Rabs_Ropp.
(* Goal: Rle (Rdiv (Rabs (pow x (S n))) (Rabs (INR (fact (S n))))) (Rdiv (pow r (S n)) (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rmult_le_compat.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rabs_pos.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite Rabs_div.
(* Goal: Rle (Rdiv (Rabs (pow x (S n))) (Rabs (INR (fact (S n))))) (Rdiv (pow r (S n)) (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rmult_le_compat.
(* Goal: Rle (IZR Z0) (Rabs x) *)
(* Goal: Rle (Rabs x) r *)
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rabs_pos.
(* Goal: Rle (IZR Z0) (Rinv (Rabs (INR (fact (S n))))) *)
(* Goal: Rle (Rabs (pow x (S n))) (pow r (S n)) *)
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rlt_le, Rinv_0_lt_compat.
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (Rabs (pow x (S n))) (pow r (S n)) *)
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rabs_pos_lt.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  exact: INR_fact_neq_0.
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite -RPow_abs.
(* Goal: and (ex_derive_n (fun x0 : R => f (Ropp x0)) n x) (Rle (Rabs (Rmult (pow (IZR (Zneg xH)) n) (Derive_n f n (Ropp x)))) M) *)
(* Goal: @locally R_UniformSpace (Ropp x) (fun y : UniformSpace.sort R_UniformSpace => forall (k : nat) (_ : le k n), ex_derive_n f k y) *)
(* Goal: @is_pseries R_AbsRing R_NormedModule (fun n : nat => Rdiv (Derive_n f n (IZR Z0)) (INR (fact n))) x (f x) *)
  apply pow_incr ; split.
(* Goal: Rle (IZR Z0) (Rabs x) *)
(* Goal: Rle (Rabs x) r *)
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rabs_pos.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Rlt_le.
(* Goal: Rle (Rinv (Rabs (INR (fact (S n))))) (Rinv (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rle_Rinv.
(* Goal: Rlt (IZR Z0) (INR (fact (S n))) *)
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  exact: (INR_fact_lt_0 (S n)).
(* Goal: Rlt (IZR Z0) (Rabs (INR (fact (S n)))) *)
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rabs_pos_lt, INR_fact_neq_0.
(* Goal: Rle (INR (fact (S n))) (Rabs (INR (fact (S n)))) *)
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rle_abs.
(* Goal: not (@eq R (INR (fact (S n))) (IZR Z0)) *)
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply INR_fact_neq_0.
(* Goal: Rle (Rabs (Derive_n f (S n) y)) M *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Hd.
(* Goal: Rlt (Rabs y) r *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rlt_trans with (2 := Hx).
(* Goal: Rlt (Rabs y) (Rabs x) *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  rewrite ?Rabs_pos_eq.
(* Goal: Rlt y x *)
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  by apply Hy.
(* Goal: Rle (IZR Z0) x *)
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rlt_le, Hx'.
(* Goal: Rle (IZR Z0) y *)
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  apply Rlt_le, Hy.
(* Goal: forall n : nat, @eq (AbelianGroup.sort R_AbelianGroup) (@scal (AbsRing.Ring R_AbsRing) (NormedModule.ModuleSpace R_AbsRing R_NormedModule) (@pow_n (AbsRing.Ring R_AbsRing) x n) (Rdiv (Derive_n f n (IZR Z0)) (INR (fact n)))) (Rmult (Rdiv (pow x n) (INR (fact n))) (Derive_n f n (IZR Z0))) *)
  intros m; rewrite pow_n_pow.
(* Goal: @eq R (Rmult (Rmult (a i) (pow x i)) (Rmult (b (Init.Nat.sub n i)) (pow x (Init.Nat.sub n i)))) (Rmult (Rmult (a i) (b (Init.Nat.sub n i))) (Rmult (pow x (Init.Nat.sub n i)) (pow x i))) *)
(* Goal: @is_series R_AbsRing R_NormedModule (fun n : nat => sum_f_R0 (fun k : nat => Rmult (Rmult (a k) (pow x k)) (Rmult (b (Init.Nat.sub n k)) (pow x (Init.Nat.sub n k)))) n) (Rmult la lb) *)
  rewrite /scal /= /mult /= /Rdiv ; ring.
Qed.
