Require Import Coquelicot.Coquelicot.
Set Bullet Behavior "
Strict Subproofs".
Require Import Morphisms.
Require Import Program.
Require Import Coq.Reals.Rbase.
Require Import Coq.Reals.Rfunctions.
Require Import List.
Require Import EquivDec Nat Lia Lra.
Require Import Reals.R_sqrt.
Require Import PushNeg.
Require Import Reals.Sqrt_reg.
Require FinFun.
Require Import LibUtils ListAdd RealAdd.
Import ListNotations.
Local Open Scope R.
Section sum'.
Fixpoint sum_f_R0' (
f :
nat ->
R) (
N :
nat) {
struct N} :
R :=
match N with
| 0%
nat => 0%
R
|
S i =>
sum_f_R0'
f i +
f i
end.
Lemma sum_f_R0_sum_f_R0'
f N :
sum_f_R0 f N =
sum_f_R0'
f (
S N).
Proof.
induction N; simpl.
- lra.
- rewrite IHN.
simpl; trivial.
Qed.
Lemma sum_f_R0'
_ext (
f1 f2:
nat->
R)
n :
(
forall x, (
x <
n)%
nat ->
f1 x =
f2 x) ->
sum_f_R0'
f1 n =
sum_f_R0'
f2 n.
Proof.
intros eqq.
induction n; simpl.
- trivial.
- rewrite eqq by lia.
rewrite IHn; trivial.
intros; apply eqq.
lia.
Qed.
Lemma sum_f_R0'
_split f n m :
(
m <=
n)%
nat ->
sum_f_R0'
f n =
sum_f_R0'
f m +
sum_f_R0' (
fun x =>
f (
x+
m)%
nat) (
n-
m).
Proof.
intros lem.
induction n;
simpl.
-
assert (
m = 0)%
nat by lia.
subst;
simpl;
lra.
-
destruct (
m ==
S n);
unfold equiv,
complement in *.
+
subst.
simpl.
rewrite Rplus_assoc.
f_equal.
replace (
n -
n)%
nat with 0%
nat by lia.
simpl.
lra.
+
rewrite IHn by lia.
rewrite Rplus_assoc.
f_equal.
destruct m;
simpl.
*
replace (
n-0)%
nat with n by lia.
replace (
n+0)%
nat with n by lia.
trivial.
*
replace (
n -
m)%
nat with (
S (
n -
S m))%
nat by lia.
simpl.
f_equal.
f_equal.
lia.
Qed.
Lemma sum_f_R0'
_split_on f n m :
(
m <
n)%
nat ->
sum_f_R0'
f n =
sum_f_R0'
f m +
f m +
sum_f_R0' (
fun x =>
f (
x+
S m)%
nat) (
n-
S m).
Proof.
intros ltm.
rewrite (
sum_f_R0'
_split f n (
S m)
ltm).
simpl;
trivial.
Qed.
Lemma sum_f_R0_peel f n :
sum_f_R0 f (
S n) =
sum_f_R0 f n +
f (
S n).
Proof.
simpl; trivial.
Qed.
Lemma sum_f_R0_ext (
f1 f2:
nat->
R)
n :
(
forall x, (
x <=
n)%
nat ->
f1 x =
f2 x) ->
sum_f_R0 f1 n =
sum_f_R0 f2 n.
Proof.
intros eqq.
induction n; simpl.
- apply eqq; lia.
- rewrite eqq by lia.
rewrite IHn; trivial.
intros; apply eqq.
lia.
Qed.
Lemma sum_f_R0_split f n m:
(
m <
n)%
nat ->
sum_f_R0 f n =
sum_f_R0 f m +
sum_f_R0 (
fun x =>
f (
x+
S m))%
nat (
n-
S m).
Proof.
intros ltm.
induction n;
simpl.
-
lia.
-
destruct (
m ==
n);
unfold equiv,
complement in *.
+
subst.
rewrite Nat.sub_diag;
simpl;
trivial.
+
rewrite IHn by lia.
rewrite Rplus_assoc.
f_equal.
replace (
n -
m)%
nat with (
S (
n -
S m))%
nat by lia.
simpl.
f_equal.
f_equal.
lia.
Qed.
Lemma sum_f_R0_le (
f g :
nat ->
R)
n :
(
forall (
i:
nat), (
i<=
n)%
nat -> (
f i) <= (
g i)) ->
sum_f_R0 f n <=
sum_f_R0 g n.
Proof.
Lemma sum_f_R0_nneg f N :
(
forall n, (
n<=
N)%
nat -> 0 <=
f n) ->
0 <=
sum_f_R0 f N.
Proof.
Lemma sum_f_R0_pos_incr f :
(
forall i, 0 <=
f i) ->
forall n :
nat,
sum_f_R0 f n <=
sum_f_R0 f (
S n).
Proof.
Lemma sum_f_R0_split_on f n m:
(
S m <
n)%
nat ->
sum_f_R0 f n =
sum_f_R0 f m +
f (
S m) +
sum_f_R0 (
fun x =>
f (
x+
S (
S m)))%
nat (
n-
S (
S m)).
Proof.
Lemma sum_f_R0'
_chisel f N n :
(
n <
N)%
nat ->
sum_f_R0'
f N =
sum_f_R0' (
fun x :
nat =>
if equiv_dec x n then 0
else f x)
N + (
f n).
Proof.
intros ltm.
repeat rewrite (
sum_f_R0'
_split_on _ N n ltm).
destruct (
n ==
n);
unfold equiv,
complement in *;
subst; [|
intuition].
rewrite Rplus_0_r.
rewrite Rplus_comm.
repeat rewrite <-
Rplus_assoc.
f_equal.
rewrite Rplus_comm.
f_equal.
+
apply sum_f_R0'
_ext;
intros.
destruct (
x ==
n);
unfold equiv,
complement in *;
subst; [|
intuition].
lia.
+
apply sum_f_R0'
_ext;
intros.
destruct (
x +
S n ==
n)%
nat;
unfold equiv,
complement in *;
subst; [|
intuition].
lia.
Qed.
Lemma sum_f_R0'
_const c n:
sum_f_R0' (
fun _ :
nat =>
c)
n = (
c *
INR n)%
R.
Proof.
induction n; simpl.
- lra.
- rewrite IHn.
destruct n; simpl; lra.
Qed.
Lemma sum_f'
_as_fold_right f (
n:
nat)
s :
sum_f_R0' (
fun x :
nat =>
f (
x +
s)%
nat)
n =
fold_right (
fun a b =>
f a +
b) 0 (
seq s n).
Proof.
revert s.
induction n;
simpl;
trivial.
intros.
rewrite (
IHn s).
destruct n; [
simpl;
lra | ].
replace (
seq s (
S n))
with ([
s]++
seq (
S s)
n)
by (
simpl;
trivial).
rewrite seq_Sn.
repeat rewrite fold_right_app.
simpl.
rewrite (
fold_right_plus_acc _ (
f (
S (
s +
n)) + 0)).
rewrite Rplus_assoc.
f_equal.
f_equal.
rewrite Rplus_0_r.
f_equal.
lia.
Qed.
Lemma sum_f_R0'
_as_fold_right f (
n:
nat) :
sum_f_R0'
f n =
fold_right (
fun a b =>
f a +
b) 0 (
seq 0
n).
Proof.
generalize (sum_f'_as_fold_right f n 0); simpl; intros HH.
rewrite <- HH.
apply sum_f_R0'_ext.
intros.
f_equal.
lia.
Qed.
Lemma sum_f_R0'
_plus f1 f2 n :
sum_f_R0' (
fun x =>
f1 x +
f2 x)
n =
sum_f_R0'
f1 n +
sum_f_R0'
f2 n.
Proof.
induction n; simpl; [lra | ].
rewrite IHn.
lra.
Qed.
Lemma sum_f_R0'
_mult_const f1 n c :
sum_f_R0' (
fun x =>
c *
f1 x)
n =
c *
sum_f_R0'
f1 n.
Proof.
induction n; simpl; [lra | ].
rewrite IHn.
lra.
Qed.
Lemma sum_f_R0_mult_const f1 n c :
sum_f_R0 (
fun x =>
c *
f1 x)
n =
c *
sum_f_R0 f1 n.
Proof.
induction n; simpl; [lra | ].
rewrite IHn.
lra.
Qed.
Lemma sum_f_R0'
_le f n :
(
forall n, (0 <=
f n)) ->
0 <=
sum_f_R0'
f n.
Proof.
intros fpos.
induction n; simpl.
- lra.
- specialize (fpos n).
lra.
Qed.
Lemma sum_f_R0'
_plus_n f n1 n2 :
sum_f_R0'
f (
n1 +
n2) =
sum_f_R0'
f n1 +
sum_f_R0' (
fun x =>
f (
n1+
x))%
nat n2.
Proof.
Lemma sum_f_R0'
_le_f (
f g:
nat->
R)
n :
(
forall i, (
i <
n)%
nat ->
f i <=
g i) ->
sum_f_R0'
f n <=
sum_f_R0'
g n.
Proof.
End sum'.
Section inf_sum'.
Definition infinite_sum' (
s :
nat ->
R) (
l :
R) :
Prop
:=
forall eps :
R,
eps > 0 ->
exists N :
nat,
forall n :
nat,
(
n >=
N)%
nat ->
R_dist (
sum_f_R0'
s n)
l <
eps.
Theorem infinite_sum_infinite_sum' (
s :
nat ->
R) (
l :
R) :
infinite_sum s l <->
infinite_sum'
s l.
Proof.
unfold infinite_sum,
infinite_sum'.
split;
intros H.
-
intros eps epsgt.
destruct (
H eps epsgt)
as [
N Nconv].
exists (
S N);
intros n ngt.
destruct n.
+
lia.
+
rewrite <-
sum_f_R0_sum_f_R0'.
apply Nconv.
lia.
-
intros eps epsgt.
destruct (
H eps epsgt)
as [
N Nconv].
exists N;
intros n ngt.
rewrite sum_f_R0_sum_f_R0'.
apply Nconv.
lia.
Qed.
Lemma infinite_sum'
_ext (
s1 s2 :
nat ->
R) (
l :
R) :
(
forall x,
s1 x =
s2 x) ->
infinite_sum'
s1 l <->
infinite_sum'
s2 l.
Proof.
intros eqq.
unfold infinite_sum'.
split; intros H eps eps_gt
; destruct (H eps eps_gt) as [N Nconv]
; exists N; intros n0 n0_ge
; specialize (Nconv n0 n0_ge)
; erewrite sum_f_R0'_ext; eauto.
Qed.
Lemma infinite_sum'
_prefix s l n :
infinite_sum'
s (
l + (
sum_f_R0'
s n)) <->
infinite_sum' (
fun x =>
s (
x +
n))%
nat l.
Proof.
unfold infinite_sum'.
split;
intros H
;
intros eps eps_gt
;
specialize (
H eps eps_gt)
;
destruct H as [
N Nconv].
-
exists N
;
intros n0 n0_ge.
specialize (
Nconv (
n +
n0)%
nat).
cut_to Nconv; [ |
lia].
replace (
R_dist (
sum_f_R0' (
fun x :
nat =>
s (
x +
n)%
nat)
n0)
l)
with
(
R_dist (
sum_f_R0'
s (
n +
n0)) (
l +
sum_f_R0'
s n));
trivial.
unfold R_dist.
rewrite (
sum_f_R0'
_split s (
n+
n0)
n)
by lia.
replace ((
n +
n0 -
n)%
nat)
with n0 by lia.
f_equal.
lra.
-
exists (
N+
n)%
nat
;
intros n0 n0_ge.
specialize (
Nconv (
n0-
n)%
nat).
cut_to Nconv; [ |
lia].
replace (
R_dist (
sum_f_R0'
s n0) (
l +
sum_f_R0'
s n))
with (
R_dist (
sum_f_R0' (
fun x :
nat =>
s (
x +
n)%
nat) (
n0 -
n))
l);
trivial.
unfold R_dist.
rewrite (
sum_f_R0'
_split s n0 n)
by lia.
f_equal.
lra.
Qed.
Lemma infinite_sum'
_split n s l :
infinite_sum'
s l <->
infinite_sum' (
fun x =>
s (
x +
n))%
nat (
l - (
sum_f_R0'
s n)).
Proof.
rewrite <- (infinite_sum'_prefix s (l - (sum_f_R0' s n)) n).
replace (l - sum_f_R0' s n + sum_f_R0' s n) with l by lra.
tauto.
Qed.
Lemma R_dist_too_small_impossible_lt r l1 l2 :
l1 <
l2 ->
R_dist r l1 <
R_dist l1 l2 / 2 ->
R_dist r l2 <
R_dist l1 l2 / 2 ->
False.
Proof.
Lemma R_dist_too_small_impossible_neq r l1 l2 :
l1 <>
l2 ->
R_dist r l1 <
R_dist l1 l2 / 2 ->
R_dist r l2 <
R_dist l1 l2 / 2 ->
False.
Proof.
Lemma infinite_sum'
_unique {
f l1 l2} :
infinite_sum'
f l1 ->
infinite_sum'
f l2 ->
l1 =
l2.
Proof.
unfold infinite_sum';
intros inf1 inf2.
destruct (
Req_dec (
l1 -
l2) 0); [
lra | ].
generalize (
Rabs_pos_lt _ H);
intros gt0.
apply Rlt_gt in gt0.
assert (
gt02:
R_dist l1 l2 / 2 > 0)
by (
unfold R_dist;
lra).
specialize (
inf1 _ gt02).
specialize (
inf2 _ gt02).
destruct inf1 as [
N1 inf1].
destruct inf2 as [
N2 inf2].
specialize (
inf1 (
max N1 N2)).
specialize (
inf2 (
max N1 N2)).
cut_to inf1; [ |
apply Nat.le_max_l].
cut_to inf2; [ |
apply Nat.le_max_r].
revert inf1 inf2.
generalize (
sum_f_R0'
f (
max N1 N2));
intros.
eelim R_dist_too_small_impossible_neq;
try eapply inf1;
eauto.
lra.
Qed.
Lemma infinite_sum'
_const_shift {
c d} :
infinite_sum' (
fun _ =>
c)
d ->
(
infinite_sum' (
fun _ =>
c) (
d+
c)).
Proof.
intros.
apply (infinite_sum'_split 1 (fun _ => c) (d+c)).
simpl.
replace (d + c - (0 + c)) with d; trivial.
lra.
Qed.
Lemma infinite_sum'
_const0 {
d} :
infinite_sum' (
fun _ :
nat => 0)
d ->
d = 0.
Proof.
unfold infinite_sum';
intros HH.
destruct (
Req_dec d 0);
trivial.
assert (
gt0:
Rabs d/2>0).
{
generalize (
Rabs_pos_lt d H).
lra.
}
specialize (
HH _ gt0).
destruct HH as [
N Nconv].
specialize (
Nconv N).
cut_to Nconv; [ |
left;
trivial].
rewrite sum_f_R0'
_const in Nconv.
unfold R_dist in Nconv.
replace (0 *
INR N -
d)
with (-
d)
in Nconv by lra.
rewrite Rabs_Ropp in Nconv.
lra.
Qed.
Lemma infinite_sum'
_const1 {
c d} :
infinite_sum' (
fun _ =>
c)
d ->
c = 0.
Proof.
intros inf1.
generalize (infinite_sum'_const_shift inf1); intros inf2.
generalize (infinite_sum'_unique inf1 inf2); intros eqq.
lra.
Qed.
Lemma infinite_sum'
_const {
c d} :
infinite_sum' (
fun _ =>
c)
d ->
c = 0 /\
d = 0.
Proof.
intros inf1.
generalize (infinite_sum'_const1 inf1); intros; subst.
generalize (infinite_sum'_const0 inf1); intros; subst.
tauto.
Qed.
Lemma infinite_sum'
_const2 {
c d} :
infinite_sum' (
fun _ =>
c)
d ->
d = 0.
Proof.
intros inf1.
generalize (infinite_sum'_const inf1); tauto.
Qed.
Hint Resolve Nat.le_max_l Nat.le_max_r :
arith.
Lemma infinite_sum'
_plus {
f1 f2} {
sum1 sum2} :
infinite_sum'
f1 sum1 ->
infinite_sum'
f2 sum2 ->
infinite_sum' (
fun x =>
f1 x +
f2 x) (
sum1 +
sum2).
Proof.
intros inf1 inf2 ε ε
pos.
destruct (
inf1 (ε/2))
as [
N1 H1]
; [
lra | ].
destruct (
inf2 (ε/2))
as [
N2 H2]
; [
lra | ].
exists (
max N1 N2).
intros n ngt.
specialize (
H1 n).
cut_to H1; [ |
apply (
le_trans _ (
max N1 N2));
auto with arith].
specialize (
H2 n).
cut_to H2; [ |
apply (
le_trans _ (
max N1 N2));
auto with arith].
rewrite sum_f_R0'
_plus.
generalize (
R_dist_plus (
sum_f_R0'
f1 n)
sum1 (
sum_f_R0'
f2 n)
sum2);
intros.
lra.
Qed.
Lemma infinite_sum'0 :
infinite_sum' (
fun _ :
nat => 0) 0.
Proof.
intros ε ε
gt.
exists 0%
nat.
intros.
rewrite sum_f_R0'
_const.
replace (0 *
INR n)
with 0
by lra.
rewrite R_dist_eq.
lra.
Qed.
Lemma infinite_sum'
_mult_const {
f1} {
sum1}
c :
infinite_sum'
f1 sum1 ->
infinite_sum' (
fun x =>
c *
f1 x) (
c *
sum1).
Proof.
Lemma Rabs_pos_plus_lt x y :
x > 0 ->
y > 0 ->
y <
Rabs (
x +
y).
Proof.
Lemma infinite_sum'
_pos f sum :
infinite_sum'
f sum ->
(
forall n, (0 <=
f n)) ->
0 <=
sum.
Proof.
intros inf fpos.
destruct (
Rge_dec sum 0); [
lra | ].
red in inf.
apply Rnot_ge_lt in n.
destruct (
inf (-
sum)); [
lra | ].
specialize (
H x).
cut_to H; [ |
lia].
unfold R_dist in H.
destruct (
Req_dec (
sum_f_R0'
f x) 0).
-
rewrite H0 in H.
replace (0 -
sum)
with (-
sum)
in H by lra.
rewrite Rabs_right in H by lra.
lra.
-
generalize (
Rabs_pos_plus_lt (
sum_f_R0'
f x ) (-
sum));
intros HH.
cut_to HH.
+
eelim Rlt_irrefl.
eapply Rlt_trans;
eauto.
+
generalize (
sum_f_R0'
_le f x fpos);
intros HH2.
lra.
+
lra.
Qed.
Lemma infinite_sum'
_le f1 f2 sum1 sum2 :
infinite_sum'
f1 sum1 ->
infinite_sum'
f2 sum2 ->
(
forall n, (
f1 n <=
f2 n)) ->
sum1 <=
sum2.
Proof.
intros inf1 inf2 fle.
generalize (infinite_sum'_mult_const (-1)%R inf1); intros ninf1.
generalize (infinite_sum'_plus inf2 ninf1); intros infm.
apply infinite_sum'_pos in infm.
- lra.
- intros.
specialize (fle n).
lra.
Qed.
End inf_sum'.
Section harmonic.
Lemma pow_le1 n : (1 <= 2 ^
n)%
nat.
Proof.
induction n; simpl; lia.
Qed.
Lemma Sle_mult_gt1 a n :
(
n > 0)%
nat ->
(
a > 1)%
nat ->
(
S n <=
a *
n)%
nat.
Proof.
destruct a; lia.
Qed.
Lemma pow_exp_gt a b :
(
a > 1)%
nat ->
(
a ^
b >
b)%
nat.
Proof.
Lemma sum_f_R0'
_eq2 n :
sum_f_R0' (
fun _:
nat => 1 /
INR (2^(
S n))) (2^
n)%
nat = 1/2.
Proof.
Lemma sum_f_R0'
_bound2 (
n:
nat) :
sum_f_R0' (
fun i:
nat => 1 /
INR (
S i)) (2^
n)%
nat >= 1+(
INR n)/2.
Proof.
Lemma harmonic_diverges'
l : ~
infinite_sum' (
fun i:
nat => 1 /
INR (
S i))
l.
Proof.
Definition diverges (
f:
nat->
R)
:=
forall l, ~
infinite_sum f l.
Theorem harmonic_diverges :
diverges (
fun i:
nat => 1 /
INR (
S i)).
Proof.
intros l inf.
apply infinite_sum_infinite_sum' in inf.
eapply harmonic_diverges'; eauto.
Qed.
End harmonic.
Section coquelicot.
Lemma infinite_sum_is_lim_seq (
f:
nat->
R) (
l:
R) :
is_lim_seq (
fun i =>
sum_f_R0 f i)
l <->
infinite_sum f l.
Proof.
Lemma is_lim_seq_list_sum (
l:
list (
nat->
R)) (
l2:
list R) :
Forall2 is_lim_seq l (
map Finite l2) ->
is_lim_seq (
fun n =>
list_sum (
map (
fun x =>
x n)
l)) (
list_sum l2).
Proof.
intros F2.
dependent induction F2.
-
destruct l2;
simpl in x;
try congruence.
simpl.
apply is_lim_seq_const.
-
destruct l2;
simpl in x;
try congruence.
invcs x.
specialize (
IHF2 l2 (
eq_refl _)).
simpl.
eapply is_lim_seq_plus;
eauto.
reflexivity.
Qed.
End coquelicot.
Lemma infinite_sum'
_one f n l :
(
forall n',
n' <>
n ->
f n' = 0%
R) ->
infinite_sum'
f l <->
l =
f n.
Proof.
intros.
rewrite (
infinite_sum'
_split (
S n)
f l).
split;
intros.
-
erewrite infinite_sum'
_ext in H0.
+
apply infinite_sum'
_const0 in H0.
simpl in H0.
erewrite sum_f_R0'
_ext in H0.
*
rewrite (
sum_f_R0'
_const 0)
in H0.
lra.
*
intros;
simpl.
apply H;
lia.
+
intros;
simpl.
apply H;
lia.
-
subst.
apply infinite_sum'
_ext with (
s1:=
fun _ => 0%
R).
+
intros;
simpl.
symmetry;
apply H;
lia.
+
replace (
f n -
sum_f_R0'
f (
S n))%
R with 0%
R.
*
apply infinite_sum'0.
*
simpl.
erewrite sum_f_R0'
_ext.
rewrite (
sum_f_R0'
_const 0).
--
lra.
--
intros;
simpl.
apply H;
lia.
Qed.
Lemma infinite_sum'
_pos_prefix_le f l n:
infinite_sum'
f l ->
(
forall n, 0 <=
f n) ->
sum_f_R0'
f n <=
l.
Proof.
intros.
apply (infinite_sum'_split n f l) in H.
apply infinite_sum'_pos in H.
- lra.
- auto.
Qed.
Lemma infinite_sum'
_pos_one_le f l n:
infinite_sum'
f l ->
(
forall n, 0 <=
f n) ->
f n <=
l.
Proof.
intros.
apply (
infinite_sum'
_pos_prefix_le _ _ (
S n))
in H;
trivial.
simpl in H.
generalize (
sum_f_R0'
_le f n H0).
lra.
Qed.
Lemma sum_f_R0'
_list_sum f n :
sum_f_R0'
f n =
list_sum (
map f (
seq 0
n)).
Proof.
Lemma list_sum_pos_sublist_le l1 l2 :
(
forall x,
In x l2 -> 0 <=
x) ->
sublist l1 l2 ->
list_sum l1 <=
list_sum l2.
Proof.
intros pos subl.
induction subl.
-
lra.
-
simpl.
apply Rplus_le_compat_l.
apply IHsubl.
simpl in *;
eauto.
-
simpl.
replace (
list_sum l1)
with (0 +
list_sum l1)
by lra.
apply Rplus_le_compat.
+
simpl in *.
eauto.
+
eapply IHsubl.
simpl in *;
eauto.
Qed.
Lemma list_sum_Rabs_triangle l :
Rabs (
list_sum l) <=
list_sum (
map Rabs l).
Proof.
Lemma bijective_injective {
B C} (
f:
B->
C) :
FinFun.Bijective f ->
FinFun.Injective f.
Proof.
intros [
g [??]] ??
eqq.
generalize (
f_equal g eqq);
intros eqq2.
now repeat rewrite H in eqq2.
Qed.
Theorem infinite_sum'
_perm (
g:
nat->
nat) (
f:
nat ->
R)
l:
FinFun.Bijective g ->
(
exists l2,
infinite_sum' (
fun x =>
Rabs (
f x))
l2) ->
infinite_sum'
f l ->
infinite_sum' (
fun n =>
f (
g n))
l.
Proof.
Corollary infinite_sum'
_pos_perm (
g:
nat->
nat) (
f:
nat ->
R)
l:
FinFun.Bijective g ->
(
forall x, 0 <=
f x) ->
infinite_sum'
f l ->
infinite_sum' (
fun n =>
f (
g n))
l.
Proof.
intros.
eapply infinite_sum'
_perm;
eauto.
eexists.
eapply infinite_sum'
_ext;
try eapply H1.
intros.
rewrite Rabs_pos_eq;
auto.
Qed.
Lemma sum_f_R0_0_inv (
a:
nat->
R) :
(
forall n :
nat,
sum_f_R0 a n = 0) ->
forall n,
a n = 0.
Proof.
intros eqq.
destruct n.
-
now specialize (
eqq 0)%
nat;
simpl in eqq.
-
generalize (
eqq n);
intros eqq1.
generalize (
eqq (
S n));
simpl;
intros eqq2.
lra.
Qed.
Section sum_n.
Lemma sum_n_le_loc (
a b :
nat ->
R) (
k :
nat) :
(
forall n :
nat, (
n <=
k)%
nat ->
a n <=
b n) ->
sum_n a k <=
sum_n b k.
Proof.
intros.
induction k.
-
rewrite sum_O.
rewrite sum_O.
apply H;
lia.
-
rewrite sum_Sn.
rewrite sum_Sn.
assert (
forall n :
nat, (
n <=
k)%
nat ->
a n <=
b n).
intros.
apply H;
lia.
specialize (
IHk H0).
apply Rplus_le_compat;
trivial;
apply H;
lia.
Qed.
Lemma sum_n_m_le_loc_alt (
a b :
nat ->
R) (
j k :
nat) :
(
forall n :
nat, (
j <=
n <=
j +
k)%
nat ->
a n <=
b n) ->
sum_n_m a j (
j +
k)%
nat <=
sum_n_m b j (
j +
k)%
nat.
Proof.
intros.
induction k.
-
replace (
j + 0)%
nat with (
j)
by lia.
do 2
rewrite sum_n_n.
apply H;
lia.
-
replace (
j +
S k)%
nat with (
S (
j +
k))%
nat by lia.
rewrite sum_n_Sm;
try lia.
rewrite sum_n_Sm;
try lia.
assert (
forall n :
nat, (
j <=
n <=
j +
k)%
nat ->
a n <=
b n).
+
intros.
apply H;
lia.
+
specialize (
IHk H0).
apply Rplus_le_compat;
trivial.
apply H;
lia.
Qed.
Lemma sum_n_m_le_loc (
a b :
nat ->
R) (
j k :
nat) :
(
j <=
k)%
nat ->
(
forall n :
nat, (
j <=
n <=
k)%
nat ->
a n <=
b n) ->
sum_n_m a j k <=
sum_n_m b j k.
Proof.
intros.
pose (
h := (
k -
j)%
nat).
replace (
k)
with (
j +
h)%
nat by lia.
apply sum_n_m_le_loc_alt.
intros.
apply H0.
unfold h in H1.
lia.
Qed.
Lemma sum_n_m_fold_right_seq (
f:
nat->
R)
n m:
sum_n_m (
fun n0 :
nat =>
f n0)
m n =
fold_right Rplus 0 (
map f (
List.seq m (
S n -
m))).
Proof.
Lemma sum_n_fold_right_seq (
f:
nat->
R)
n :
sum_n (
fun n0 :
nat =>
f n0)
n =
fold_right Rplus 0 (
map f (
seq 0 (
S n))).
Proof.
Lemma list_sum_sum_n (
l:
list R) :
list_sum l =
@
Hierarchy.sum_n Hierarchy.R_AbelianGroup (
fun i:
nat =>
match nth_error l i with
|
Some x =>
x
|
None => 0%
R
end) (
length l).
Proof.
Lemma sum_n_m_shift (α :
nat ->
R) (
k n0 :
nat) :
sum_n_m α
k (
n0 +
k)%
nat =
sum_n (
fun n1 :
nat => α (
n1 +
k)%
nat)
n0.
Proof.
unfold sum_n.
induction n0.
-
replace (0 +
k)%
nat with (
k)
by lia.
do 2
rewrite sum_n_n.
f_equal;
lia.
-
replace (
S n0 +
k)%
nat with (
S (
n0 +
k)%
nat)
by lia.
rewrite sum_n_Sm;
try lia.
rewrite sum_n_Sm;
try lia.
replace (
S n0 +
k)%
nat with (
S (
n0 +
k)%
nat)
by lia.
now rewrite IHn0.
Qed.
Lemma sum_n_m_pos a n1 n2 :
(
forall n, (
n1 <=
n <=
n2)%
nat -> 0 <=
a n) ->
0 <= (
sum_n_m a n1 n2).
Proof.
Lemma sum_n_pos_incr a n1 n2 : (
forall n, (
n1 <
n <=
n2)%
nat -> 0 <=
a n) ->
(
n1 <=
n2)%
nat ->
sum_n a n1 <=
sum_n a n2.
Proof.
End sum_n.
Section Sequences.
Global Instance is_lim_seq_proper:
Proper (
pointwise_relation _ eq ==>
eq ==>
iff) (
is_lim_seq).
Proof.
Global Instance Lim_seq_proper:
Proper (
pointwise_relation _ eq ==>
eq) (
Lim_seq).
Proof.
Global Instance ex_lim_seq_proper:
Proper (
pointwise_relation _ eq ==>
iff) (
ex_lim_seq).
Proof.
Lemma sup_seq_pos (
f :
nat ->
R) :
(
forall n, 0 <=
f n) ->
Rbar_le 0 (
Sup_seq f).
Proof.
Lemma ex_finite_lim_seq_bounded (
f :
nat ->
R) :
ex_finite_lim_seq f ->
exists (
M:
R),
forall n,
Rabs (
f n) <=
M.
Proof.
Lemma ex_finite_lim_seq_plus (
f g :
nat ->
R) :
ex_finite_lim_seq f ->
ex_finite_lim_seq g ->
ex_finite_lim_seq (
fun n =>
f n +
g n).
Proof.
intros.
destruct H.
destruct H0.
exists (x + x0).
now apply is_lim_seq_plus'.
Qed.
Lemma ex_finite_lim_seq_ext (
f g :
nat ->
R) :
(
forall n,
f n =
g n) ->
ex_finite_lim_seq f <->
ex_finite_lim_seq g.
Proof.
Lemma ex_finite_lim_seq_S (
f :
nat ->
R) :
ex_finite_lim_seq f <->
ex_finite_lim_seq (
fun n =>
f (
S n)).
Proof.
Lemma ex_finite_lim_seq_incr_n (
f :
nat ->
R) (
N :
nat) :
ex_finite_lim_seq f <->
ex_finite_lim_seq (
fun n =>
f (
N +
n)%
nat).
Proof.
Lemma is_lim_seq_max (
f g :
nat ->
R) (
l :
Rbar) :
is_lim_seq f l ->
is_lim_seq g l ->
is_lim_seq (
fun n =>
Rmax (
f n) (
g n))
l.
Proof.
intros.
apply is_lim_seq_spec.
apply is_lim_seq_spec in H.
apply is_lim_seq_spec in H0.
unfold is_lim_seq'
in *;
intros.
destruct l;
intros.
-
destruct (
H eps);
destruct (
H0 eps).
exists (
max x x0);
intros.
specialize (
H1 n);
specialize (
H2 n).
cut_to H1;
try lia.
cut_to H2;
try lia.
unfold Rmax;
match_destr.
-
destruct (
H M);
destruct (
H0 M).
exists (
max x x0);
intros.
specialize (
H1 n);
specialize (
H2 n).
cut_to H1;
try lia.
cut_to H2;
try lia.
unfold Rmax;
match_destr.
-
destruct (
H M);
destruct (
H0 M).
exists (
max x x0);
intros.
specialize (
H1 n);
specialize (
H2 n).
cut_to H1;
try lia.
cut_to H2;
try lia.
unfold Rmax;
match_destr.
Qed.
End Sequences.
Section Series.
Global Instance Series_proper :
Proper (
pointwise_relation _ eq ==>
eq) (
Series).
Proof.
Global Instance ex_series_proper (
K :
AbsRing) (
V :
NormedModule K):
Proper (
pointwise_relation _ eq ==>
iff) (@
ex_series K V).
Proof.
Lemma sum_f_R0_nonneg_le_Series {
x :
nat ->
R}(
hx1 :
ex_series x) (
hx2 :
forall n, 0 <=
x n) :
forall N,
sum_f_R0 x N <=
Series x.
Proof.
Lemma lim_0_nneg (
a :
nat ->
R) :
is_series a 0 ->
(
forall n, 0 <=
a n) ->
forall n,
a n = 0.
Proof.
Lemma ex_series_nneg_bounded (
f g :
nat ->
R) :
(
forall n, 0 <=
f n) ->
(
forall n,
f n <=
g n) ->
ex_series g ->
ex_series f.
Proof.
Lemma ex_series_bounded (
f :
nat ->
R) :
ex_series f ->
exists (
M:
R),
forall n,
Rabs (
sum_n f n) <=
M.
Proof.
Lemma ex_series_pos_bounded (
f :
nat ->
R) (
B:
R) :
(
forall n, 0 <=
f n) ->
(
forall n,
sum_n f n <=
B) ->
ex_series f.
Proof.
Lemma Abel_descending_convergence (
a b :
nat ->
R) :
ex_series b ->
(
forall n,
a n >=
a (
S n)) ->
(
exists M,
forall n,
a n >=
M) ->
ex_series (
fun n =>
a n *
b n).
Proof.
intros.
pose (
B :=
sum_n b).
assert (
forall n,
sum_n (
fun j =>
a j *
b j) (
S n) =
(
a (
S n))*(
B (
S n)) +
sum_n (
fun j => (
B j) * (
a j - (
a (
S j))))
n).
{
intros.
do 2
rewrite sum_n_Reals.
induction n.
-
unfold B.
rewrite sum_n_Reals.
simpl.
rewrite sum_O.
ring_simplify;
lra.
-
replace (
S (
S n))
with (
S (
n+1))
by lia.
simpl.
replace (
n+1)%
nat with (
S n)
by lia.
rewrite IHn.
apply Rplus_eq_reg_r with (
r :=
sum_f_R0 (
fun j :
nat =>
B j * (
a (
j) -
a (
S j)))
n).
ring_simplify.
apply Rplus_eq_reg_r with (
r := - (
a (
S n) *
B (
S n))).
ring_simplify.
unfold B.
do 2
rewrite sum_n_Reals.
replace (
S n)
with (
n+1)%
nat by lia.
simpl.
now ring_simplify.
}
rewrite <-
ex_finite_lim_series.
rewrite ex_finite_lim_seq_S.
apply (
ex_finite_lim_seq_ext _ _ H2).
generalize (
ex_series_bounded _ H);
intros.
rewrite <-
ex_finite_lim_series in H.
destruct H.
assert (
ex_finite_lim_seq a).
{
destruct H1.
apply ex_finite_lim_seq_decr with (
M :=
x0).
-
intros.
specialize (
H0 n).
lra.
-
intros.
specialize (
H1 n).
lra.
}
destruct H4.
apply ex_finite_lim_seq_plus.
-
unfold ex_finite_lim_seq.
exists (
x0 *
x).
apply is_lim_seq_mult'.
+
now apply is_lim_seq_incr_1 in H4.
+
now apply is_lim_seq_incr_1 in H.
-
destruct H3.
unfold B.
assert (
forall n,
(
sum_n (
fun j :
nat =>
Rabs (
sum_n b j * (
a j -
a (
S j))))
n) <=
(
sum_n (
fun j :
nat =>
scal x1 (
Rabs (
a j -
a (
S j))))
n)).
{
intros.
apply sum_n_le_loc;
intros.
rewrite Rabs_mult.
apply Rmult_le_compat_r;
trivial.
apply Rabs_pos.
}
assert (
forall i h,
a i >=
a (
i +
h)%
nat).
{
induction h.
-
replace (
i + 0)%
nat with i by lia;
lra.
-
eapply Rge_trans.
apply IHh.
now replace (
i +
S h)%
nat with (
S (
i +
h))%
nat by lia.
}
assert (
forall i j, (
i<=
j)%
nat ->
a i >=
a j).
{
intros.
specialize (
H6 i (
j -
i)%
nat).
now replace (
i + (
j -
i))%
nat with j in H6 by lia.
}
assert (
forall n,
sum_n (
fun j =>
Rabs (
a j -
a (
S j)))
n =
Rabs(
a (0%
nat) -
a (
S n))).
{
induction n.
-
now rewrite sum_O.
-
rewrite sum_Sn.
rewrite IHn.
unfold plus;
simpl.
rewrite Rabs_right,
Rabs_right,
Rabs_right.
+
ring.
+
specialize (
H7 (0%
nat) (
S (
S n))).
cut_to H7;
try lia.
lra.
+
specialize (
H0 (
S n));
lra.
+
specialize (
H7 (0%
nat) (
S n)).
cut_to H7;
try lia.
lra.
}
assert (
forall n,
(
sum_n (
fun j :
nat =>
Rabs (
sum_n b j * (
a j -
a (
S j))))
n) <=
x1 *
Rabs((
a 0%
nat) -
a (
S n))).
{
intros.
specialize (
H5 n).
rewrite sum_n_scal_l in H5.
unfold scal in H5;
simpl in H5.
unfold mult in H5;
simpl in H5.
now rewrite H8 in H5.
}
rewrite ex_finite_lim_series.
apply ex_series_Rabs.
destruct H1.
assert (
forall n,
Rabs (
a n) <=
Rmax (
a 0%
nat) (-
x2)).
{
intros.
apply Rabs_le_between_Rmax.
split;
apply Rge_le;
trivial.
apply H7;
lia.
}
assert (
forall n,
Rabs (
a 0%
nat -
a (
S n)) <=
Rabs(
a 0%
nat) +
Rmax (
a 0%
nat) (-
x2)).
{
intros.
unfold Rminus.
generalize (
Rabs_triang (
a 0%
nat) (-
a (
S n)));
intros.
eapply Rle_trans.
apply H11.
apply Rplus_le_compat_l.
now rewrite Rabs_Ropp.
}
apply ex_series_pos_bounded with (
B :=
x1 * (
Rabs (
a 0%
nat) +
Rmax (
a 0%
nat) (-
x2))).
+
intros.
apply Rabs_pos.
+
intros.
eapply Rle_trans.
apply H9.
apply Rmult_le_compat_l.
*
specialize (
H3 0%
nat).
apply Rle_trans with (
r2 :=
Rabs (
sum_n b 0%
nat));
trivial.
apply Rabs_pos.
*
apply H11.
Qed.
Lemma Abel_ascending_convergence (
a b :
nat ->
R) :
ex_series b ->
(
forall n,
a n <=
a (
S n)) ->
(
exists M,
forall n,
a n <=
M) ->
ex_series (
fun n =>
a n *
b n).
Proof.
intros.
pose (
B :=
sum_n b).
assert (
forall n,
sum_n (
fun j =>
a j *
b j) (
S n) =
(
a (
S n))*(
B (
S n)) +
sum_n (
fun j => (
B j) * (
a j - (
a (
S j))))
n).
{
intros.
do 2
rewrite sum_n_Reals.
induction n.
-
unfold B.
rewrite sum_n_Reals.
simpl.
rewrite sum_O.
ring_simplify;
lra.
-
replace (
S (
S n))
with (
S (
n+1))
by lia.
simpl.
replace (
n+1)%
nat with (
S n)
by lia.
rewrite IHn.
apply Rplus_eq_reg_r with (
r :=
sum_f_R0 (
fun j :
nat =>
B j * (
a (
j) -
a (
S j)))
n).
ring_simplify.
apply Rplus_eq_reg_r with (
r := - (
a (
S n) *
B (
S n))).
ring_simplify.
unfold B.
do 2
rewrite sum_n_Reals.
replace (
S n)
with (
n+1)%
nat by lia.
simpl.
now ring_simplify.
}
rewrite <-
ex_finite_lim_series.
rewrite ex_finite_lim_seq_S.
apply (
ex_finite_lim_seq_ext _ _ H2).
generalize (
ex_series_bounded _ H);
intros.
rewrite <-
ex_finite_lim_series in H.
destruct H.
assert (
ex_finite_lim_seq a).
{
destruct H1.
apply ex_finite_lim_seq_incr with (
M :=
x0).
-
intros.
specialize (
H0 n).
lra.
-
intros.
specialize (
H1 n).
lra.
}
destruct H4.
apply ex_finite_lim_seq_plus.
-
unfold ex_finite_lim_seq.
exists (
x0 *
x).
apply is_lim_seq_mult'.
+
now apply is_lim_seq_incr_1 in H4.
+
now apply is_lim_seq_incr_1 in H.
-
destruct H3.
unfold B.
assert (
forall n,
(
sum_n (
fun j :
nat =>
Rabs (
sum_n b j * (
a j -
a (
S j))))
n) <=
(
sum_n (
fun j :
nat =>
scal x1 (
Rabs (
a j -
a (
S j))))
n)).
{
intros.
apply sum_n_le_loc;
intros.
rewrite Rabs_mult.
apply Rmult_le_compat_r;
trivial.
apply Rabs_pos.
}
assert (
forall i h,
a i <=
a (
i +
h)%
nat).
{
induction h.
-
replace (
i + 0)%
nat with i by lia;
lra.
-
eapply Rle_trans.
apply IHh.
now replace (
i +
S h)%
nat with (
S (
i +
h))%
nat by lia.
}
assert (
forall i j, (
i<=
j)%
nat ->
a i <=
a j).
{
intros.
specialize (
H6 i (
j -
i)%
nat).
now replace (
i + (
j -
i))%
nat with j in H6 by lia.
}
assert (
forall n,
sum_n (
fun j =>
Rabs (
a j -
a (
S j)))
n =
Rabs(
a (0%
nat) -
a (
S n))).
{
induction n.
-
now rewrite sum_O.
-
rewrite sum_Sn.
rewrite IHn.
unfold plus;
simpl.
rewrite Rabs_left1,
Rabs_left1,
Rabs_left1.
+
ring.
+
specialize (
H7 (0%
nat) (
S (
S n))).
cut_to H7;
try lia.
lra.
+
specialize (
H0 (
S n));
lra.
+
specialize (
H7 (0%
nat) (
S n)).
cut_to H7;
try lia.
lra.
}
assert (
forall n,
(
sum_n (
fun j :
nat =>
Rabs (
sum_n b j * (
a j -
a (
S j))))
n) <=
x1 *
Rabs((
a 0%
nat) -
a (
S n))).
{
intros.
specialize (
H5 n).
rewrite sum_n_scal_l in H5.
unfold scal in H5;
simpl in H5.
unfold mult in H5;
simpl in H5.
now rewrite H8 in H5.
}
rewrite ex_finite_lim_series.
apply ex_series_Rabs.
destruct H1.
assert (
forall n,
Rabs (
a n) <=
Rmax (
x2) (- (
a 0%
nat))).
{
intros.
apply Rabs_le_between_Rmax.
split;
trivial.
apply H7;
lia.
}
assert (
forall n,
Rabs (-
a 0%
nat +
a (
S n)) <=
Rmax (
x2) (-
a 0%
nat) +
Rabs (
a (
S n)) ).
{
intros.
unfold Rminus.
generalize (
Rabs_triang (-
a 0%
nat) (
a (
S n)));
intros.
eapply Rle_trans.
apply H11.
apply Rplus_le_compat_r.
now rewrite Rabs_Ropp.
}
apply ex_series_pos_bounded with (
B :=
x1 * (2*
Rmax x2 (-
a 0%
nat))).
+
intros.
apply Rabs_pos.
+
intros.
eapply Rle_trans.
apply H9.
apply Rmult_le_compat_l.
*
specialize (
H3 0%
nat).
apply Rle_trans with (
r2 :=
Rabs (
sum_n b 0%
nat));
trivial.
apply Rabs_pos.
*
rewrite <-
Rabs_Ropp.
rewrite Ropp_minus_distr.
unfold Rminus.
rewrite Rplus_comm.
eapply Rle_trans.
apply H11.
specialize (
H10 (
S n)).
lra.
Qed.
Lemma sum_n_m_Series_alt (
f :
nat ->
R) (
n m :
nat) :
(
n <=
m)%
nat ->
ex_series f ->
sum_n_m f n m =
Series (
fun i =>
f (
n +
i)%
nat) -
Series (
fun i =>
f (
S m +
i)%
nat).
Proof.
intros.
destruct (
n == 0%
nat).
+
setoid_rewrite e.
clear H.
induction m.
--
cbn.
rewrite (
Series_incr_1); [
lra |
assumption].
--
simpl.
rewrite sum_n_Sm;[|
lia].
rewrite IHm.
cbn.
rewrite (
Series_incr_1 (
fun i =>
f (
S(
m +
i)))).
setoid_rewrite <-
Nat.add_succ_l.
replace (
S m + 0)%
nat with (
S m)
by lia.
ring_simplify.
now setoid_rewrite plus_n_Sm at 2.
setoid_rewrite <-
plus_Sn_m.
now rewrite <-
ex_series_incr_n.
+
assert (
Hn : (0 <
n)%
nat).
{
destruct n.
+
intuition.
+
lia.
}
assert (
Hm : (0 <
S m)%
nat)
by lia.
generalize (
Series_incr_n f n Hn H0);
intros.
generalize (
Series_incr_n f _ Hm H0);
intros.
rewrite H1 in H2.
rewrite Radd_radd_minus in H2.
rewrite <-
H2.
simpl.
do 2
rewrite <-
sum_n_Reals.
replace n with (
S (
pred n))
by lia.
rewrite sum_n_m_sum_n;
try lia.
reflexivity.
Qed.
Lemma sum_n_m_Series1 (
f :
nat ->
R) (
n m :
nat) :
(0 <
n <=
m)%
nat ->
ex_series f ->
sum_n_m f n m =
Series (
fun i =>
f (
n +
i)%
nat) -
Series (
fun i =>
f (
S m +
i)%
nat).
Proof.
intros.
assert (
Hn : (0 <
n)%
nat)
by (
now destruct H).
assert (
Hm : (0 <
S m)%
nat)
by lia.
generalize (
Series_incr_n f n Hn H0);
intros.
generalize (
Series_incr_n f _ Hm H0);
intros.
rewrite H1 in H2.
rewrite Radd_radd_minus in H2.
rewrite <-
H2.
simpl.
do 2
rewrite <-
sum_n_Reals.
replace n with (
S (
pred n))
by lia.
rewrite sum_n_m_sum_n;
try lia.
reflexivity.
Qed.
Lemma sum_n_m_Series (
f :
nat ->
R) (
n m :
nat) :
(
n <=
m)%
nat ->
ex_series f ->
sum_n_m f n m =
Series (
fun i =>
f (
n +
i)%
nat) -
Series (
fun i =>
f (
S m +
i)%
nat).
Proof.
Lemma Rmax_list_sum_series_eps (
f :
nat ->
R) :
ex_series f ->
forall (
eps :
posreal),
exists (
NN :
nat),
forall (
n N :
nat),
(
N >=
NN)%
nat ->
(
n >=
N)%
nat ->
Rmax_list
(
map
(
fun k :
nat =>
Rabs (
sum_n_m f k n))
(
seq N (
S (
n -
N)))) <
eps.
Proof.
Lemma Rmax_list_sum_series_eps2(
f :
nat ->
R) :
ex_series f ->
forall (
eps :
posreal),
exists (
NN :
nat),
forall (
n N :
nat),
(
N >=
NN)%
nat ->
(
n > (
S N))%
nat ->
Rmax_list
(
map
(
fun k :
nat =>
Rabs (
sum_n_m f (
S k) (
n-1)%
nat))
(
seq N (
S ((
n-1) -
N)))) <
eps.
Proof.
End Series.
Section tails.
Definition tail_series (
a :
nat ->
R) :=
fun n =>
Series(
fun k =>
a((
n+
k)%
nat)).
Lemma tail_succ_sub {
a :
nat ->
R} (
ha :
ex_series a) :
forall n,
a n =
tail_series a n -
tail_series a (
S n).
Proof.
Lemma tail_series_nonneg_le {
a :
nat ->
R}(
ha :
ex_series a)(
ha' :
forall n, 0 <=
a n):
forall n, 0 <=
tail_series a (
S n) <=
tail_series a n.
Proof.
Lemma tail_series_pos_lt {
a :
nat ->
R}(
ha :
ex_series a)(
ha' :
forall n, 0 <
a n):
forall n, 0 <
tail_series a (
S n) <
tail_series a n.
Proof.
Lemma tail_series_nonneg_eventually_pos (
a :
nat ->
R) :
(
forall n, 0 <=
a n) ->
(
forall n,
exists h, 0 <
a (
n +
h)%
nat) ->
ex_series a ->
forall n, 0 <
tail_series a n.
Proof.
Lemma rudin_12_b_aux1_nonneg {
a :
nat ->
R} (
ha :
ex_series a)(
ha' :
forall n, 0 <=
a n)
(
ha'' :
forall n,
exists h, 0 <
a (
n +
h)%
nat):
forall n,
R_sqrt.sqrt(
tail_series a n) +
R_sqrt.sqrt(
tail_series a (
S n)) <= 2*
R_sqrt.sqrt(
tail_series a n).
Proof.
Lemma rudin_12_b_aux2_nonneg {
a :
nat ->
R} (
ha :
ex_series a)(
ha' :
forall n, 0 <=
a n):
forall n,
a n = (
sqrt(
tail_series a n) +
sqrt(
tail_series a (
S n)))*(
sqrt(
tail_series a n) -
sqrt(
tail_series a (
S n))).
Proof.
Lemma rudin_12_b_aux3_nonneg {
a :
nat ->
R}(
ha :
ex_series a) (
ha' :
forall n, 0 <=
a n)
(
ha'' :
forall n,
exists h, 0 <
a (
n +
h)%
nat) :
forall n,
a n*/
sqrt(
tail_series a n) <= 2*(
sqrt(
tail_series a n) -
sqrt(
tail_series a (
S n))).
Proof.
Lemma rudin_12_b_aux4_nonneg {
a :
nat ->
R}(
ha :
ex_series a) (
ha' :
forall n, 0 <=
a n)
(
ha'' :
forall n,
exists h, 0 <
a (
n +
h)%
nat):
forall m,
sum_f_R0 (
fun n =>
a n */
sqrt(
tail_series a n))
m <= 2*(
sqrt(
tail_series a 0%
nat) -
sqrt(
tail_series a(
S m))).
Proof.
Lemma is_lim_seq_inv_pos_p_infty {
a :
nat ->
R}(
ha:
is_lim_seq a 0) (
ha' :
forall n, 0 <
a n):
is_lim_seq (
fun n => /
a n)
p_infty.
Proof.
Lemma no_worst_converge_nonneg (
a:
nat ->
R) :
(
forall n, 0 <=
a n) ->
(
forall n,
exists h, 0 <
a (
n +
h)%
nat) ->
ex_series a ->
exists (
b :
nat ->
R),
(
forall n, 0 <
b n) /\
is_lim_seq b p_infty /\
ex_series (
fun n =>
a n *
b n).
Proof.
Lemma no_worst_converge_pos (
a:
nat ->
R) :
(
forall n, 0 <
a n) ->
ex_series a ->
exists (
b :
nat ->
R),
(
forall n, 0 <
b n) /\
is_lim_seq b p_infty /\
ex_series (
fun n =>
a n *
b n).
Proof.
intros.
assert (
Ha :
forall n, 0 <=
a n)
by (
intros n ;
left;
auto).
generalize (
no_worst_converge_nonneg a Ha);
intros Hn.
apply Hn;
auto.
intros.
exists 0%
nat.
apply H.
Qed.
Definition eventually_pos_dec (
a :
nat ->
R) :
{
forall n :
nat,
exists h :
nat, 0 <
a (
n +
h)%
nat} +{~(
forall n :
nat,
exists h :
nat, 0 <
a (
n +
h)%
nat)}.
Proof.
Theorem no_worst_converge_iff (
a :
nat ->
R):
(
forall n, 0 <=
a n) ->
ex_series a <->
exists (
b :
nat ->
R),
(
forall n, 0 <
b n) /\
is_lim_seq b p_infty /\
ex_series (
fun n =>
a n *
b n).
Proof.
Lemma no_best_diverge_pos (
gamma :
nat ->
R) :
0 <
gamma 0%
nat ->
(
forall n, 0 <=
gamma n) ->
is_lim_seq (
sum_n gamma)
p_infty ->
exists (
rho :
nat ->
posreal),
is_lim_seq rho 0 /\
is_lim_seq (
sum_n (
fun n =>
rho n *
gamma n))
p_infty.
Proof.
Lemma sum_shift_diff (
X :
nat ->
R) (
m a :
nat) :
sum_n X (
a +
S m) -
sum_n X m =
sum_n (
fun n0 :
nat =>
X (
n0 +
S m)%
nat)
a.
Proof.
Lemma is_lim_seq_sum_shift_inf1 (
f :
nat ->
R) (
N :
nat) :
is_lim_seq (
sum_n f)
p_infty <->
is_lim_seq (
sum_n (
fun n =>
f (
n + (
S N))%
nat))
p_infty.
Proof.
Lemma is_lim_seq_sum_shift_inf (
f :
nat ->
R) (
N :
nat) :
is_lim_seq (
sum_n f)
p_infty <->
is_lim_seq (
sum_n (
fun n =>
f (
n +
N)%
nat))
p_infty.
Proof.
Lemma no_best_diverge (
gamma :
nat ->
R) :
(
forall n, 0 <=
gamma n) ->
is_lim_seq (
sum_n gamma)
p_infty ->
exists (
rho :
nat ->
posreal),
is_lim_seq rho 0 /\
is_lim_seq (
sum_n (
fun n =>
rho n *
gamma n))
p_infty.
Proof.
intros.
assert (
exists N, 0 <
gamma N).
{
apply is_lim_seq_spec in H0.
unfold is_lim_seq'
in H0.
specialize (
H0 0).
destruct H0 as [
N ?].
specialize (
H0 N).
cut_to H0;
try lia.
now apply pos_ind_sum with (
N :=
N).
}
destruct H1 as [
N ?].
generalize (
no_best_diverge_pos (
fun n =>
gamma (
n +
N)%
nat));
intros.
cut_to H2;
trivial.
-
destruct H2 as [
rho [? ?]].
assert (0 < 1)
by lra.
exists (
fun n =>
if (
lt_dec n N)
then (
mkposreal _ H4)
else rho (
n -
N)%
nat).
split.
+
apply is_lim_seq_incr_n with (
N :=
N).
apply is_lim_seq_ext with (
u :=
rho);
trivial.
intros.
match_destr;
try lia.
now replace (
n +
N -
N)%
nat with (
n)
by lia.
+
rewrite is_lim_seq_sum_shift_inf with (
N :=
N).
apply is_lim_seq_ext with (
u :=
sum_n (
fun n =>
rho n *
gamma (
n +
N)%
nat));
trivial.
intros.
apply sum_n_ext;
intros.
match_destr;
try lia.
now replace (
n0 +
N -
N)%
nat with (
n0)
by lia.
-
now rewrite <-
is_lim_seq_sum_shift_inf.
Qed.
Theorem no_best_diverge_iff (
gamma :
nat ->
R) :
(
forall n, 0 <=
gamma n) ->
is_lim_seq (
sum_n gamma)
p_infty <->
exists (
rho :
nat ->
posreal),
is_lim_seq rho 0 /\
is_lim_seq (
sum_n (
fun n =>
rho n *
gamma n))
p_infty.
Proof.
Lemma no_worst_converge_div (
a :
nat ->
R) :
(
forall n, 0 <=
a n) ->
ex_series a ->
exists (
b :
nat ->
R),
(
forall n, 0 <
b n) /\
is_lim_seq b 0 /\
ex_series (
fun n =>
a n /
Rsqr (
b n)).
Proof.
End tails.