Debian Codegraph @

reals/stdlib/CMTPositivity.v

raw
1 (*
2 Copyright © 2020 Vincent Semeria
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
6 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
8 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 *)
10
11
12 (* A lemma to simplify the proofs of Icontinuous in integration spaces.
13 It looks classical because it does not need to give a convergence modulus. *)
14
15 From Coq Require Import ZArith.
16 From Coq Require Import QArith.
17 From Coq Require Import ConstructiveReals.
18 From Coq Require Import ConstructiveAbs.
19 From Coq Require Import ConstructiveSum.
20 From Coq Require Import ConstructivePower.
21 From Coq Require Import ConstructiveLimits.
22 Require Import ConstructiveDiagonal.
23 Require Import ConstructivePartialFunctions.
24 Require Import CMTbase.
25 Require Import CMTIntegrableFunctions.
26
27 Local Open Scope ConstructiveReals.
28
29
30 Lemma Rmult_continuous_zero {R : ConstructiveReals} (x eps : CRcarrier R)
31 : 0 < eps -> { alpha : CRcarrier R & prod (0 < alpha) (alpha * x < eps) }.
32 Proof.
33 intros. destruct (CRltLinear R).
34 destruct (s 0 x 1 (CRzero_lt_one R)).
35 - assert (0 < x + 1).
36 { apply (CRlt_trans _ (0 + 1)). rewrite CRplus_0_l.
37 exact (CRzero_lt_one R). apply CRplus_lt_compat_r. exact c. }
38 exists (eps * CRinv R (x+1) (inr H0)). split.
39 apply CRmult_lt_0_compat. exact H. apply CRinv_0_lt_compat.
40 exact H0.
41 rewrite <- (CRmult_1_r eps). do 2 rewrite CRmult_assoc.
42 apply CRmult_lt_compat_l. exact H.
43 rewrite CRmult_1_l.
44 apply (CRmult_lt_reg_l (x+1)). exact H0.
45 rewrite <- CRmult_assoc, CRinv_r.
46 rewrite CRmult_1_l, CRmult_1_r.
47 rewrite <- (CRplus_0_r x), CRplus_assoc. apply CRplus_lt_compat_l.
48 rewrite CRplus_0_l. exact (CRzero_lt_one R).
49 - exists eps. split. exact H. rewrite <- (CRmult_1_r eps).
50 rewrite CRmult_assoc. rewrite CRmult_1_l.
51 exact (CRmult_lt_compat_l _ _ _ H c).
52 Qed.
53
54 (* Build an increasing sequence that respects sequence bound *)
55 Fixpoint ControlSubSeqCv {R : ConstructiveReals}
56 (un : nat -> CRcarrier R) (l : CRcarrier R) (bound : nat -> CRcarrier R)
57 (_ : CR_cv _ un l)
58 (_ : forall k:nat, 0 < bound k)
59 (n : nat) { struct n }
60 : { p : nat & CRabs _ (un p - l) < bound n }.
61 Proof.
62 destruct n.
63 - intros.
64 pose proof (Un_cv_nat_real _ l H (bound O) (H0 O)) as [p pmaj].
65 exists p. apply pmaj, Nat.le_refl.
66 - intros.
67 pose proof (Un_cv_nat_real _ l H (bound (S n)) (H0 (S n))) as [p pmaj].
68 exists (max p (S (let (k,_) := ControlSubSeqCv R un l bound H H0 n in k))).
69 apply pmaj, Nat.le_max_l.
70 Defined.
71
72 Lemma ControlSubSeqCvInc
73 : forall {R : ConstructiveReals}
74 (un : nat -> CRcarrier R) (l : CRcarrier R) (bound : nat -> CRcarrier R)
75 (cv : CR_cv _ un l)
76 (boundPos : forall k:nat, 0 < bound k)
77 (n : nat),
78 lt (let (k,_) := ControlSubSeqCv un l bound cv boundPos n in k)
79 (let (k,_) := ControlSubSeqCv un l bound cv boundPos (S n) in k).
80 Proof.
81 intros. simpl.
82 destruct (Un_cv_nat_real un l cv (bound (S n)) (boundPos (S n))),
83 (ControlSubSeqCv un l bound cv boundPos n).
84 apply (Nat.lt_le_trans _ (S x0)). apply le_n_S, Nat.le_refl.
85 apply Nat.le_max_r.
86 Qed.
87
88 Definition PrependSeq {X : Type} (x : X) (un : nat -> X) (n : nat)
89 := match n with
90 | O => x
91 | S p => un p
92 end.
93
94 Lemma PrependSeqL : forall (E : FunctionRieszSpace)
95 (f : PartialFunction (X E))
96 (un : nat -> PartialFunction (X E)),
97 L E f
98 -> (forall n:nat, L E (un n))
99 -> forall n:nat, L E (PrependSeq f un n).
100 Proof.
101 intros E f un H H0 n. unfold PrependSeq. destruct n.
102 exact H. apply H0.
103 Defined.
104
105 Lemma PrependSeqSeries
106 : forall {R : ConstructiveReals} (x : CRcarrier R)
107 (un : nat -> CRcarrier R) (l : CRcarrier R),
108 series_cv un l
109 -> series_cv (PrependSeq x un) (x + l).
110 Proof.
111 intros. intros n. specialize (H n) as [p pmaj].
112 exists (S p). intros.
113 destruct i. exfalso; inversion H. apply le_S_n in H.
114 rewrite decomp_sum. simpl.
115 setoid_replace (x + CRsum (fun i0 : nat => un i0) i - (x + l))
116 with (CRsum (fun i0 : nat => un i0) i - l).
117 apply pmaj. exact H. 2: apply le_n_S, Nat.le_0_l.
118 unfold CRminus. rewrite (CRplus_comm x).
119 rewrite CRplus_assoc. apply CRplus_morph.
120 reflexivity. rewrite CRopp_plus_distr, <- CRplus_assoc.
121 rewrite CRplus_opp_r, CRplus_0_l. reflexivity.
122 Qed.
123
124 Lemma PosSumMaj : forall {R : ConstructiveReals} (un : nat -> CRcarrier R)
125 (a : CRcarrier R) (k : nat),
126 (forall n:nat, 0 <= un n)
127 -> CRsum un k <= a
128 -> un k <= a.
129 Proof.
130 destruct k.
131 - intros. exact H0.
132 - intros. simpl in H0. rewrite <- (CRplus_0_l (un (S k))).
133 apply (CRle_trans _ (CRsum un k + un (S k))).
134 apply CRplus_le_compat. apply cond_pos_sum. exact H.
135 apply CRle_refl. exact H0.
136 Qed.
137
138 Lemma CRplus_eq_compat_l : forall {R : ConstructiveReals} (a b c : CRcarrier R),
139 b == c
140 -> a + b == a + c.
141 Proof.
142 intros. rewrite H. reflexivity.
143 Qed.
144
145 Lemma pow2inv : forall {R : ConstructiveReals} (n p:nat),
146 CRpow (CR_of_Q R 2) n * CRpow (CR_of_Q R (1 # 2)) (n + p)
147 == CRpow (CR_of_Q R (1 # 2)) p.
148 Proof.
149 induction p.
150 - simpl. rewrite Nat.add_0_r, CRpow_mult.
151 rewrite (CRpow_proper (CR_of_Q R 2 * CR_of_Q R (1 # 2)) 1).
152 apply CRpow_one. rewrite <- CR_of_Q_mult.
153 setoid_replace (2 * (1 # 2))%Q with 1%Q. reflexivity. reflexivity.
154 - rewrite Nat.add_succ_r.
155 transitivity (CRpow (CR_of_Q R 2) n * (CR_of_Q R (1 # 2) * CRpow (CR_of_Q R (1 # 2)) (n + p))).
156 reflexivity. rewrite <- CRmult_assoc.
157 rewrite (CRmult_comm (CRpow (CR_of_Q R 2) n)).
158 rewrite CRmult_assoc, IHp. reflexivity.
159 Qed.
160
161 Lemma seq_cv_le : forall {R : ConstructiveReals} (un : nat -> CRcarrier R) (l a : CRcarrier R),
162 CR_cv R un l
163 -> (forall n:nat, un n <= a)
164 -> l <= a.
165 Proof.
166 intros. apply (CR_cv_bound_up un a l O).
167 intros. apply H0. apply H.
168 Qed.
169
170 Lemma IcontinuousClassic
171 : forall (E : FunctionRieszSpace)
172 (I : forall f : PartialFunction (X E), (L E) f -> CRcarrier _)
173 (Ihomogeneous : forall (a : CRcarrier _)
174 (f : PartialFunction (X E))
175 (fL : L E f),
176 I (Xscale a f) (LscaleStable E a f fL)
177 == a * (I f fL))
178 (IadditiveIterate : forall (fn : nat -> PartialFunction (X E))
179 (fnL : forall n:nat, L E (fn n))
180 (N : nat),
181 I (Xsum fn N) (LsumStable fn fnL N)
182 == CRsum (fun n : nat => I (fn n) (fnL n)) N),
183 (forall (f : PartialFunction (X E)) (fL : (L E) f),
184 (* Usually the function Z is a plateau at 1 that contains
185 the support of f. *)
186 { ZL : { Z : PartialFunction (X E) & prod ((L E) Z) (nonNegFunc Z) }
187 & forall (fn : nat -> PartialFunction (X E))
188 (fnL : forall n:nat, (L E) (fn n)),
189 (forall n:nat, nonNegFunc (fn n))
190 -> series_cv_lim_lt (fun n => I (fn n) (fnL n))
191 (I f fL)
192 -> { x : CommonPointFunSeq _ f fn
193 | (let (Z,_) := ZL in exists xz : Domain Z (cpx _ _ _ x),
194 partialApply Z (cpx _ _ _ x) xz == 1)
195 /\ forall k:nat, CRsum (fun n => partialApply (fn n) (cpx _ _ _ x) (cpxFn _ _ _ x n)) k
196 <= partialApply f (cpx _ _ _ x) (cpxF _ _ _ x) } })
197 -> ElemIntegralContinuous I.
198 Proof.
199 intros E I Ihomogeneous Iadd cont f fn fL fnL nonneg intMaj.
200 rename cont into cont0; specialize (cont0 f); edestruct cont0 as [[Z [ZL Zpos]] cont]; clear cont0.
201 destruct intMaj as [l [lcv lmaj]].
202 destruct (Rmult_continuous_zero (I Z ZL + 1) (I f fL - l))
203 as [alpha [alphapos alphamaj]].
204 rewrite <- (CRplus_opp_r l).
205 apply CRplus_lt_compat_r, lmaj.
206 assert (forall k : nat, (0 < (fun k0 : nat => CRpow (CR_of_Q _ (1#2)) (2 * k0 + 2)%nat * alpha) k))
207 as boundPos.
208 { intro k. apply CRmult_lt_0_compat.
209 apply CRpow_gt_zero. exact Rlt_0_half. exact alphapos. }
210 pose (PrependSeq O (fun i => S ( let (k,_) := ControlSubSeqCv
211 (CRsum (fun n : nat => I (fn n) (fnL n))) l
212 (fun k => (CRpow (CR_of_Q _ (1#2)) (2*k + 2) * alpha )) lcv boundPos i
213 in k))) as n.
214 assert (forall k:nat, lt (n k) (n (S k))) as ninc.
215 { intro k. unfold n, PrependSeq. destruct k.
216 unfold ControlSubSeqCv.
217 destruct (Un_cv_nat_real (CRsum (fun n0 : nat => I (fn n0) (fnL n0))) l lcv).
218 apply le_n_S, Nat.le_0_l. apply le_n_S.
219 apply (ControlSubSeqCvInc
220 (CRsum (fun n0 : nat => I (fn n0) (fnL n0))) l
221 (fun k0 : nat => CRpow (CR_of_Q _ (1#2)) (2 * k0 + 2) * alpha)). }
222 (* Avoid the main mass of the series lcv, to focus on
223 its convergence speed. Therefore seq starts at n 1. *)
224 pose (PrependSeq (Xscale alpha Z)
225 (weaveSequences
226 _ fn (fun i => Xscale (CRpow (CR_of_Q _ 2) i) (Xsum (fun k => fn (n (S i) + k)%nat)
227 (pred (n (S (S i)) - n (S i)))))))
228 as seq.
229 pose (PrependSeqL E (Xscale alpha Z)
230 (weaveSequences
231 _ fn (fun i => Xscale (CRpow (CR_of_Q _ 2) i) (Xsum (fun k => fn (n (S i) + k)%nat)
232 (pred (n (S (S i)) - n (S i))))))
233 (LscaleStable E alpha Z ZL)
234 (weaveSequencesL E fn fnL _
235 (fun n0 => LscaleStable E (CRpow (CR_of_Q _ 2) n0) _ (LsumStable _ (fun i => fnL _) _))))
236 as seqL.
237 assert (forall k:nat, nonNegFunc (seq k)) as seqPos.
238 { intros k x xdf.
239 unfold seq, PrependSeq in xdf; unfold seq, PrependSeq; destruct k.
240 rewrite applyXscale. rewrite <- (CRmult_0_r alpha).
241 apply CRmult_le_compat_l. apply CRlt_asym, alphapos.
242 apply Zpos. unfold weaveSequences. unfold weaveSequences in xdf.
243 destruct (Nat.even k). apply nonneg.
244 rewrite applyXscale. rewrite <- (CRmult_0_r (CRpow (CR_of_Q _ 2) (k/2))).
245 apply CRmult_le_compat_l.
246 apply CRlt_asym, CRpow_gt_zero. simpl.
247 apply CR_of_Q_lt. reflexivity.
248 apply nonNegSumFunc. intros. apply nonneg. }
249 destruct (cont seq seqL seqPos) as [x xgood].
250 - destruct (series_cv_maj
251 (fun i : nat => CRpow (CR_of_Q _ 2) i * (CRsum (fun k => I (fn (n (S i) + k)%nat)
252 (fnL (n (S i) + k)%nat))
253 (pred (n (S (S i)) - n (S i)))))
254 (fun i => CRpow (CR_of_Q _ (1#2)) (S i) * alpha)
255 alpha).
256 + intros. rewrite CRabs_mult. rewrite CRabs_right.
257 destruct (n (S n0)) eqn:des.
258 exfalso; pose proof (ninc n0); rewrite des in H; inversion H.
259 pose proof (sum_assoc (fun k => I (fn k) (fnL k))
260 n1 (Init.Nat.pred (n (S (S n0)) - S n1))).
261 apply (CRplus_eq_compat_l (-CRsum (fun k : nat => I (fn k) (fnL k)) n1)) in H.
262 rewrite <- CRplus_assoc, CRplus_opp_l, CRplus_0_l in H.
263 rewrite <- H. clear H.
264 replace (S n1 + pred (n (S (S n0)) - S n1))%nat
265 with (pred (n (S (S n0)))).
266 setoid_replace (- CRsum (fun k : nat => I (fn k) (fnL k)) n1 +
267 CRsum (fun k : nat => I (fn k) (fnL k)) (pred (n (S (S n0)))))
268 with (l - CRsum (fun k : nat => I (fn k) (fnL k)) n1 +
269 (CRsum (fun k : nat => I (fn k) (fnL k)) (pred (n (S (S n0)))) - l)).
270 apply (CRle_trans _ (CRpow (CR_of_Q _ 2) n0 *
271 (CRabs _ (l - CRsum (fun k : nat => I (fn k) (fnL k)) n1)
272 + CRabs _ (CRsum (fun k : nat => I (fn k) (fnL k))
273 (pred (n (S (S n0)))) - l)))).
274 apply CRmult_le_compat_l.
275 apply CRlt_asym, CRpow_gt_zero. simpl.
276 apply CR_of_Q_lt. reflexivity.
277 apply CRabs_triang. rewrite CRmult_plus_distr_l.
278 apply (CRle_trans
279 _ ((CRpow (CR_of_Q _ 2) n0) * CRpow (CR_of_Q _ (1#2)) (2 * n0 + 2) * alpha
280 + (CRpow (CR_of_Q _ 2) n0) * CRpow (CR_of_Q _ (1#2)) (2 * (S n0) + 2) * alpha)).
281 apply CRplus_le_compat.
282 rewrite CRmult_assoc. apply CRmult_le_compat_l.
283 apply CRlt_asym, CRpow_gt_zero. simpl.
284 apply CR_of_Q_lt. reflexivity.
285 replace n1 with (pred (n (S n0))). 2: rewrite des; reflexivity.
286 unfold n, PrependSeq, proj1_sig, pred.
287 destruct (ControlSubSeqCv (CRsum (fun n2 : nat => I (fn n2) (fnL n2))) l
288 (fun k : nat => CRpow (CR_of_Q _ (1#2)) (2 * k + 2) * alpha)
289 lcv boundPos n0).
290 apply CRlt_asym. rewrite CRabs_minus_sym. exact c.
291 rewrite CRmult_assoc. apply CRmult_le_compat_l.
292 apply CRlt_asym, CRpow_gt_zero. simpl.
293 apply CR_of_Q_lt. reflexivity.
294 unfold n, PrependSeq, proj1_sig, pred.
295 destruct (ControlSubSeqCv (CRsum (fun n2 : nat => I (fn n2) (fnL n2))) l
296 (fun k : nat => CRpow (CR_of_Q _ (1#2)) (2 * k + 2) * alpha)
297 lcv boundPos (S n0)).
298 apply CRlt_asym, c.
299 rewrite <- CRmult_plus_distr_r. apply CRmult_le_compat_r.
300 apply CRlt_asym, alphapos.
301 replace (2 * n0 + 2)%nat with (n0 + (1 + S n0))%nat.
302 rewrite pow2inv.
303 replace (2 * S n0 + 2)%nat with (n0 + (3 + S n0))%nat.
304 rewrite pow2inv.
305 rewrite <- (CRmult_1_l (CRpow (CR_of_Q _ (1 # 2)) (S n0))).
306 apply (CRle_trans
307 _ (CR_of_Q _ (1 # 2) * CRpow (CR_of_Q _ (1 # 2)) (S n0)
308 + CR_of_Q _ (1 # 2) * (CR_of_Q _ (1 # 2) * (CR_of_Q _ (1 # 2) * CRpow (CR_of_Q _ (1 # 2)) (S n0))))).
309 apply CRle_refl.
310 do 2 rewrite <- CRmult_assoc.
311 rewrite <- CRmult_plus_distr_r. apply CRmult_le_compat_r.
312 apply CRlt_asym, CRpow_gt_zero. simpl.
313 apply CR_of_Q_lt. reflexivity.
314 rewrite <- CR_of_Q_mult, <- CR_of_Q_mult, <- CR_of_Q_plus.
315 apply CR_of_Q_le. discriminate.
316 rewrite Nat.add_comm. simpl. apply f_equal.
317 rewrite <- (Nat.add_comm (S (n0 + 0))). simpl. apply f_equal.
318 rewrite Nat.add_0_r. rewrite <- (Nat.add_comm 2). reflexivity.
319 simpl. rewrite <- Nat.add_assoc. apply f_equal2. reflexivity.
320 rewrite Nat.add_0_r, Nat.add_comm. reflexivity.
321 unfold CRminus. rewrite (CRplus_comm l), CRplus_assoc.
322 apply CRplus_morph. reflexivity.
323 rewrite CRplus_comm, CRplus_assoc, CRplus_opp_l, CRplus_0_r.
324 reflexivity. do 2 rewrite <- Nat.sub_1_r.
325 rewrite Nat.add_sub_assoc.
326 rewrite Nat.add_comm, Nat.sub_add. reflexivity.
327 rewrite <- des. apply (Nat.le_trans _ (S (n (S n0)))).
328 apply le_S, Nat.le_refl. exact (ninc (S n0)).
329 rewrite <- des. apply Nat.le_add_le_sub_r. apply ninc.
330 apply CRlt_asym, CRpow_gt_zero. simpl.
331 apply CR_of_Q_lt. reflexivity.
332 + apply (CR_cv_proper _ (1*alpha)).
333 apply series_cv_scale.
334 apply (series_cv_eq (fun n0 : nat => CRpow (CR_of_Q _ (1 # 2)) n0 * CR_of_Q _ (1#2))).
335 intros. apply CRmult_comm.
336 apply (CR_cv_proper _ (CR_of_Q _ 2 * CR_of_Q _ (1#2))).
337 apply series_cv_scale, GeoHalfTwo.
338 rewrite <- CR_of_Q_mult. setoid_replace (2 * (1 # 2))%Q with 1%Q.
339 reflexivity. reflexivity. apply CRmult_1_l.
340 + clear cont. exists (alpha * I Z ZL + (l + x)). destruct p. split.
341 apply (series_cv_eq
342 (PrependSeq (alpha * (I Z ZL))
343 (weaveSequences (CRcarrier _) (fun k => I (fn k) (fnL k))
344 (fun i => CRpow (CR_of_Q _ 2) i * (CRsum (fun k => I (fn (n (S i) + k)%nat) (fnL (n (S i) + k)%nat))
345 (pred (n (S (S i)) - n (S i)))))))).
346 intros. unfold seq, PrependSeq. destruct n0.
347 simpl. rewrite Ihomogeneous. reflexivity.
348 unfold seqL, weaveSequences, weaveSequencesL, PrependSeqL.
349 clear seqL seqPos seq.
350 destruct (Nat.even n0). reflexivity.
351 rewrite Ihomogeneous, Iadd. reflexivity.
352 apply PrependSeqSeries.
353 apply weaveInfiniteSums. exact lcv. exact s.
354 apply (CRplus_lt_reg_l _ (-l)).
355 rewrite (CRplus_comm (alpha*I Z ZL)), <- CRplus_assoc, <- CRplus_assoc.
356 rewrite CRplus_opp_l, CRplus_0_l.
357 apply (CRle_lt_trans _ (alpha * I Z ZL + alpha)).
358 rewrite CRplus_comm.
359 apply CRplus_le_compat_l. exact c.
360 rewrite CRmult_plus_distr_l, CRmult_1_r in alphamaj.
361 rewrite (CRplus_comm (-l)). exact alphamaj.
362 - destruct x as [x xf xseqn].
363 assert (forall n : nat, Domain (fn n) x) as xfn.
364 { intro k.
365 exact (domainWeaveEvenInc _ _ _ k x (xseqn (S (k * 2)))). }
366 exists (Build_CommonPointFunSeq _ (X E) f fn x xf xfn).
367 unfold cpx, cpxFn, cpxF.
368 unfold cpx, cpxF, cpxFn in xgood. destruct xgood.
369 (* Get the initial mass back *)
370 destruct (series_cv_maj
371 (fun i : nat => CRsum (fun k : nat => partialApply (fn (k + n i)%nat) x (xfn (k + n i)%nat))
372 (n (S i) - n i - 1))
373 (PrependSeq (CRsum (fun k:nat => partialApply (fn (k + n 0)%nat) x (xfn (k + n 0)%nat)) (n 1 - 1)%nat)
374 (fun j => CRpow (CR_of_Q _ (1#2)) j * (partialApply f x xf)))
375 (CRsum (fun k:nat => partialApply (fn (k + n 0)%nat) x (xfn (k + n 0)%nat)) (n 1 - 1)%nat
376 + CR_of_Q _ 2 * partialApply f x xf)).
377 + clear seqL. intros.
378 rewrite CRabs_right.
379 2: apply cond_pos_sum; intros; apply nonneg. unfold PrependSeq.
380 destruct n0. apply CRle_refl.
381 apply (PosSumMaj _ (partialApply f x xf) (S (S (2*n0)))) in H0.
382 2: intros; apply seqPos.
383 unfold pred, seq, PrependSeq in H0.
384 rewrite Nat.mul_comm in H0.
385 rewrite <- (partialApplyWeaveOdd
386 (X E) fn _ _ x
387 (domainWeaveOddInc (X E) fn _ n0 x (xseqn (S (S (n0 * 2)))))) in H0.
388 rewrite applyXscale in H0.
389 rewrite (applyXsum _ _ _ _ (fun k => xfn (n (S n0) + k)%nat)) in H0.
390 intro abs. rewrite <- (Nat.add_0_r n0) in abs.
391 apply (CRmult_lt_compat_l (CRpow (CR_of_Q _ 2) n0)) in abs.
392 rewrite <- CRmult_assoc, pow2inv in abs. apply H0.
393 apply (CRle_lt_trans _ (CRpow (CR_of_Q _ (1 # 2)) 0 * partialApply f x xf)).
394 unfold CRpow. rewrite CRmult_1_l. apply CRle_refl.
395 apply (CRlt_le_trans _ _ _ abs). apply CRmult_le_compat_l.
396 apply CRlt_asym, CRpow_gt_zero. simpl.
397 apply CR_of_Q_lt; reflexivity.
398 rewrite <- Nat.sub_1_r. rewrite Nat.add_0_r. apply sum_Rle. intros.
399 rewrite Nat.add_comm. apply CRle_refl.
400 apply CRpow_gt_zero. apply CR_of_Q_lt. reflexivity.
401 + apply PrependSeqSeries, series_cv_scale, GeoHalfTwo.
402 + clear seqL. destruct p as [i _].
403 pose proof (infinite_sum_assoc
404 _ n x0 ninc
405 (fun k => nonneg k x (xfn k)) (eq_refl _) i).
406 exists x0. split. exact H1.
407 apply (CRle_lt_trans _ (partialApply f x xf - alpha)).
408 apply (CRplus_le_reg_l alpha).
409 rewrite <- (CRplus_comm (partialApply f x xf - alpha)).
410 unfold CRminus. rewrite CRplus_assoc, CRplus_opp_l, CRplus_0_r.
411 apply (seq_cv_le (CRsum (PrependSeq alpha (fun k => partialApply (fn k) x (xfn k))))).
412 apply PrependSeqSeries. exact H1.
413 intros.
414 specialize (H0 (2*n0)%nat).
415 apply (CRle_trans
416 _ (CRsum (fun n : nat => partialApply (seq n) x (xseqn n)) (2 * n0))).
417 2: exact H0.
418 destruct n0. unfold CRsum. simpl.
419 destruct H. rewrite (DomainProp Z x _ x1), H, CRmult_1_r.
420 apply CRle_refl. rewrite decomp_sum.
421 rewrite (decomp_sum (fun n1 : nat => partialApply (seq n1) x (xseqn n1))).
422 unfold seq, PrependSeq.
423 apply CRplus_le_compat.
424 destruct H. rewrite applyXscale, (DomainProp Z x _ x1), H, CRmult_1_r.
425 apply CRle_refl. simpl (pred (S n0)).
426 replace (pred (2 * S n0)) with (S (2*n0)).
427 2: simpl; rewrite Nat.add_succ_r; reflexivity.
428 rewrite (CRsum_eq _ (weaveSequences
429 (CRcarrier _) (fun i => partialApply (fn i) x (xfn i))
430 (fun i => CRpow (CR_of_Q _ 2) i * (CRsum (fun k => partialApply (fn (n (S i) + k)%nat) x (xfn (n (S i) + k)%nat))
431 (pred (n (S (S i)) - n (S i))) )))
432 (S (2 * n0))).
433 rewrite weaveSequencesSum.
434 rewrite <- (CRplus_0_r
435 (CRsum (fun i0 : nat => partialApply (fn i0) x (xfn i0)) n0)).
436 apply CRplus_le_compat.
437 rewrite <- (Nat.mul_comm n0). pose proof (Nat.div_add 1 n0 2).
438 simpl in H2. simpl. rewrite H2. apply CRle_refl. auto.
439 apply cond_pos_sum. intros.
440 rewrite <- (CRmult_0_r (CRpow (CR_of_Q _ 2) k)). apply CRmult_le_compat_l.
441 apply CRlt_asym, CRpow_gt_zero. simpl.
442 apply CR_of_Q_lt; reflexivity. apply cond_pos_sum.
443 intros. apply nonneg.
444 intros.
445 rewrite (partialApplyWeave (X E) fn _ i0 x (xfn (i0/2)%nat)
446 (domainWeaveOddInc (X E) fn _ (i0/2) x (xseqn (S (S ((i0/2) * 2)))))
447 (xseqn (S i0))).
448 unfold weaveSequences. destruct (Nat.even i0). reflexivity.
449 rewrite applyXscale. apply CRmult_morph. reflexivity.
450 apply applyXsum. apply le_n_S, Nat.le_0_l.
451 apply le_n_S, Nat.le_0_l.
452 rewrite <- (CRplus_0_r (partialApply f x xf)).
453 unfold CRminus. rewrite CRplus_assoc. apply CRplus_lt_compat_l.
454 apply (CRplus_lt_reg_l _ alpha).
455 rewrite CRplus_0_l, CRplus_opp_r, CRplus_0_r. exact alphapos.
456 Qed.