Debian Codegraph @

reals/stdlib/CMTFullSets.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 (* Following the invariance of the integral with respect to the representation,
13 we now precisely define full sets, and prove that 2 functions equal on a
14 full set have the same integral. *)
15
16 From Coq Require Import ZArith.
17 From Coq Require Import QArith.
18 From Coq Require Import ConstructiveReals.
19 From Coq Require Import ConstructiveAbs.
20 From Coq Require Import ConstructiveMinMax.
21 From Coq Require Import ConstructiveCauchyAbs.
22 From Coq Require Import ConstructiveSum.
23 From Coq Require Import ConstructivePower.
24 From Coq Require Import ConstructiveLimits.
25
26 Require Import ConstructiveDiagonal.
27 Require Import ConstructivePartialFunctions.
28
29 Require Import CMTbase.
30 Require Import CMTIntegrableFunctions.
31
32 Local Open Scope ConstructiveReals.
33
34
35 (* A full set of the integration space IS is a subset of X (ElemFunc IS)
36 that contains the domain of an integrable function.
37
38 In other words, a property P of an integration space IS
39 holds almost everywhere when there is an integrable function h
40 on which domain P holds. *)
41 Definition almost_everywhere {IS : IntegrationSpace}
42 (P : X (ElemFunc IS) -> Type) : Type
43 := { h : PartialFunction (X (ElemFunc IS))
44 & prod (IntegrableFunction h)
45 (forall (x:X (ElemFunc IS)),
46 Domain h x -> P x) }.
47
48
49 (* We start with a lemma to help prove that sets are full : it suffices
50 that they contain a countable intersection of domains of integrable functions.
51
52 This is the complement of the usual property about Lebesgue null sets :
53 a countable union of null sets is null. *)
54
55
56 Definition diagSeqL : forall (IS : IntegrationSpace)
57 (fnk : nat -> nat -> PartialFunction (X (ElemFunc IS)))
58 (fnkL : forall n k: nat, L (ElemFunc IS) (fnk n k))
59 (p : nat),
60 L (ElemFunc IS) (diagSeq fnk p).
61 Proof.
62 intros. unfold diagSeq. destruct (diagPlaneInv p). apply fnkL.
63 Defined.
64
65 Definition diagSeqDomain {R : ConstructiveReals} (X : Set)
66 (fnk : nat -> nat -> @PartialFunction R X)
67 (x : X)
68 (xn : forall p:nat, Domain (diagSeq fnk p) x)
69 (n k : nat)
70 : Domain (fnk n k) x.
71 Proof.
72 unfold diagSeq in xn. pose (xn (diagPlane n k)).
73 rewrite diagPlaneInject in d. exact d.
74 Defined.
75
76 Definition countable_representation
77 (IS : IntegrationSpace)
78 (f : PartialFunction (X (ElemFunc IS)))
79 (fInt : IntegrableFunction f)
80 (n : nat)
81 : { intRepres : IntegralRepresentation
82 & prod (DomainInclusion
83 (XinfiniteSumAbs (IntFn intRepres)) f)
84 (IntAbsSum intRepres <= CRpow (CR_of_Q _ (1#2)) n) }.
85 Proof.
86 destruct fInt as [[fnk fnkL sumAbsIFnk] [injF restrict]].
87 unfold IntFn in restrict, injF.
88 assert (0 < (1 + sumAbsIFnk)) as denomPos.
89 { apply (CRlt_le_trans 0 (1+0)). rewrite CRplus_0_r.
90 apply CRzero_lt_one. apply CRplus_le_compat_l.
91 apply (series_cv_nonneg (fun k : nat => Iabs (fnk k) (fnkL k))).
92 intro n0. apply integralPositive. intros x xdf. rewrite applyXabs.
93 apply CRabs_pos. assumption. }
94 assert (series_cv
95 (fun k : nat =>
96 Iabs (Xscale (CRpow (CR_of_Q _ (1#2)) n * CRinv _ (1 + sumAbsIFnk) (inr denomPos)) (fnk k))
97 (LscaleStable (ElemFunc IS) _ (fnk k) (fnkL k)))
98 (sumAbsIFnk * (CRpow (CR_of_Q _ (1#2)) n * CRinv _ (1 + sumAbsIFnk) (inr denomPos)))) as H.
99 { apply (series_cv_eq
100 (fun b : nat =>
101 Iabs (fnk b) (fnkL b) *
102 (CRpow (CR_of_Q _ (1#2)) n * CRinv _ (1 + sumAbsIFnk) (inr denomPos)))).
103 intro k. rewrite IabsHomogeneous. rewrite CRmult_comm.
104 apply CRmult_morph. 2: reflexivity.
105 rewrite CRabs_right. reflexivity. apply CRlt_asym.
106 apply CRmult_lt_0_compat. apply CRpow_gt_zero.
107 simpl. apply CR_of_Q_lt. reflexivity.
108 apply CRinv_0_lt_compat. exact denomPos.
109 apply series_cv_scale. assumption. }
110 exists (Build_IntegralRepresentation
111 IS
112 (fun k : nat => Xscale (CRpow (CR_of_Q _ (1#2)) n * CRinv _ (1 + sumAbsIFnk) (inr denomPos)) (fnk k))
113 (fun k => LscaleStable _ _ (fnk k) (fnkL k))
114 (sumAbsIFnk * (CRpow (CR_of_Q _ (1#2)) n * CRinv _ (1 + sumAbsIFnk) (inr denomPos)))
115 H).
116 assert (CRapart _ (1 + sumAbsIFnk) 0) as denomNonZero.
117 { right. exact denomPos. }
118 split.
119 - (* Inclusion of domains *)
120 intros x xdf. unfold IntFn in xdf.
121 assert (CRapart _ (CRpow (CR_of_Q _ (1#2)) n * CRinv _ (1 + sumAbsIFnk) (inr denomPos)) 0)
122 as ddenomNonZero.
123 { right. apply CRmult_lt_0_compat.
124 apply CRpow_gt_zero. simpl. apply CR_of_Q_lt. reflexivity.
125 apply CRinv_0_lt_compat. exact denomPos. }
126 destruct (domainInfiniteSumAbsScaleIncReverse _ _ _ x xdf ddenomNonZero) as [y _].
127 exact (injF x y).
128 - (* Majoration of the abs integral *)
129 unfold IntAbsSum.
130 rewrite CRmult_comm. rewrite <- (CRmult_1_r (CRpow (CR_of_Q _ (1 # 2)) n)).
131 do 2 rewrite CRmult_assoc.
132 apply CRmult_le_compat_l. apply CRlt_asym, CRpow_gt_zero.
133 simpl. apply CR_of_Q_lt. reflexivity.
134 rewrite CRmult_1_l. apply CRlt_asym.
135 apply (CRmult_lt_reg_l (1+sumAbsIFnk)). assumption.
136 rewrite <- CRmult_assoc. rewrite CRinv_r.
137 rewrite CRmult_1_r. rewrite CRmult_1_l.
138 rewrite <- (CRplus_0_l sumAbsIFnk).
139 rewrite <- CRplus_assoc. apply CRplus_lt_compat_r.
140 rewrite CRplus_0_r. apply CRzero_lt_one.
141 Qed.
142
143 Lemma partialApplyEq
144 : forall {R : ConstructiveReals} (X : Set)
145 (f g : @PartialFunction R X)
146 (x : X) (xD : Domain f x) (xG : Domain g x),
147 f = g
148 -> (partialApply f x xD == partialApply g x xG).
149 Proof.
150 intros. subst g. apply DomainProp.
151 Qed.
152
153 Definition domainInfiniteSumAbsDiag
154 {R : ConstructiveReals } (X : Set)
155 (fnk : nat -> nat -> @PartialFunction R X)
156 (n : nat)
157 : DomainInclusion (XinfiniteSumAbs (diagSeq fnk))
158 (XinfiniteSumAbs (fnk n)).
159 Proof.
160 intros x xdf.
161 assert (forall k, (let (n, k) := diagPlaneInv (diagPlane n k) in fnk n k)
162 = (fnk n k)) as H.
163 { intro k. rewrite diagPlaneInject. reflexivity. }
164 assert (forall k:nat, Domain (fnk n k) x) as xLine.
165 { intro k. destruct xdf as [xn _].
166 unfold diagSeq in xn. specialize (H k).
167 specialize (xn (diagPlane n k)). rewrite H in xn. exact xn. }
168 destruct xdf as [xnDiag cvDiag].
169 assert (forall a b:nat, lt a b -> lt (diagPlane n a) (diagPlane n b)).
170 { intros. unfold diagPlane. apply Nat.add_lt_le_mono. assumption.
171 apply Nat.div_le_mono. auto. apply Nat.mul_le_mono.
172 apply Nat.add_le_mono. apply Nat.le_refl. unfold lt in H0.
173 apply (Nat.le_trans _ (S a)). apply le_S. apply Nat.le_refl. assumption.
174 apply le_n_S. apply Nat.add_le_mono. apply Nat.le_refl. unfold lt in H0.
175 apply (Nat.le_trans _ (S a)). apply le_S. apply Nat.le_refl. assumption. }
176 pose proof (CR_complete R _ cvDiag) as [lim cvlim].
177 destruct (SubSeriesCv (fun k : nat =>
178 CRabs _ (partialApply (diagSeq fnk k) x (xnDiag k)))
179 (exist _ (fun k => diagPlane n k) H0) lim)
180 as [y i].
181 apply cvlim. intros. apply CRabs_pos.
182 simpl in i.
183 apply (domainInfiniteSumAbsInc _ x xLine y).
184 apply (series_cv_eq (fun n0 : nat =>
185 CRabs _
186 (partialApply (diagSeq fnk (diagPlane n n0)) x
187 (xnDiag (diagPlane n n0))))).
188 - intros. apply CRabs_morph. apply partialApplyEq.
189 unfold diagSeq. rewrite (diagPlaneInject n n0). reflexivity.
190 - exact i.
191 Qed.
192
193 Lemma InfiniteDiagApply
194 : forall {R : ConstructiveReals } (X : Set)
195 (fnk : nat -> nat -> @PartialFunction R X)
196 (x : X)
197 (xD : Domain (XinfiniteSumAbs (diagSeq fnk)) x),
198 series_cv
199 (diagSeq (fun n k : nat => CRabs _ (partialApply (fnk n k) x
200 (domainInfiniteSumAbsIncReverse
201 (fnk n) x
202 (domainInfiniteSumAbsDiag
203 X fnk n x xD) k))))
204 (let (xn,a) := xD in
205 let (lim,_) := CR_complete R _ a in lim).
206 Proof.
207 intros. destruct xD as [xn cv].
208 destruct (CR_complete R
209 (CRsum
210 (fun k : nat =>
211 CRabs _ (partialApply (diagSeq fnk k) x (xn k)))) cv).
212 apply (series_cv_eq (fun k : nat =>
213 CRabs _ (partialApply (diagSeq fnk k)
214 x (xn k)))).
215 2: apply c.
216 intro n.
217 transitivity (let (n0,k) := diagPlaneInv n in
218 CRabs _ (partialApply (diagSeq fnk (diagPlane n0 k)) x (xn (diagPlane n0 k)))).
219 - destruct (diagPlaneInv n) eqn:desN.
220 apply CRabs_morph. apply partialApplyEq. unfold diagSeq. rewrite diagPlaneInject.
221 rewrite desN. reflexivity.
222 - assert (forall unk vnk : nat -> nat -> CRcarrier R,
223 (forall n k : nat, unk n k == vnk n k)
224 -> forall n:nat, diagSeq unk n == diagSeq vnk n).
225 { intros. unfold diagSeq. destruct (diagPlaneInv n0). apply H. }
226 apply H. clear n. intros. apply CRabs_morph.
227 apply partialApplyEq. unfold diagSeq. rewrite diagPlaneInject. reflexivity.
228 Qed.
229
230 (* The infinite sum of lines is equal to
231 the infinite diagonal sum *)
232 Lemma applyInfiniteSumAbsDiag
233 : forall {R : ConstructiveReals } (X : Set)
234 (fnk : nat -> nat -> @PartialFunction R X)
235 (x : X)
236 (xD : Domain (XinfiniteSumAbs (diagSeq fnk)) x),
237 series_cv (fun n:nat => let (ln,a) := domainInfiniteSumAbsDiag X fnk n x xD in
238 let (lim,_) := CR_complete R _ a in
239 lim)
240 (let (xn,a) := xD in
241 let (lim,_) := CR_complete R _ a in lim).
242 Proof.
243 intros.
244 destruct (DiagSeqInfiniteSum
245 (fun n k => CRabs _ (partialApply (fnk n k) x
246 (domainInfiniteSumAbsIncReverse
247 _ x (domainInfiniteSumAbsDiag
248 X fnk n x xD) k)))
249 (fun n : nat =>
250 let (ln, a) := domainInfiniteSumAbsDiag X fnk n x xD in
251 let (lim, _) :=
252 CR_complete R (CRsum (fun n0 : nat => CRabs _ (partialApply (fnk n n0) x (ln n0)))) a in
253 lim)
254 (let (xn,a) := xD in
255 let (lim,_) := CR_complete R _ a in lim)).
256 - apply (series_cv_eq (diagSeq (fun n k : nat => CRabs _
257 (partialApply (fnk n k) x
258 (domainInfiniteSumAbsIncReverse (fnk n) x
259 (domainInfiniteSumAbsDiag X fnk n x xD) k))))).
260 intro n. unfold diagSeq. destruct (diagPlaneInv n).
261 symmetry. rewrite CRabs_right. reflexivity. apply CRabs_pos.
262 apply InfiniteDiagApply.
263 - (* The sum on each line *)
264 intro n. destruct (domainInfiniteSumAbsDiag X fnk n); simpl.
265 destruct (CR_complete R (CRsum (fun k : nat => CRabs _ (partialApply (fnk n k) x (x0 k)))) c).
266 exact c0.
267 - destruct p, p.
268 apply (CR_cv_proper _ _ _ s). symmetry.
269 apply (series_cv_unique _ _ _ (InfiniteDiagApply _ _ x xD) s0).
270 Qed.
271
272 (* If a subset A contains a countable intersection of domains
273 of integrable functions, then it is full. *)
274 Lemma CountableIntersectionIsFull
275 : forall {IS : IntegrationSpace}
276 (fn : nat -> PartialFunction (X (ElemFunc IS)))
277 (fnInt : forall n:nat, IntegrableFunction (fn n))
278 (A : X (ElemFunc IS) -> Type),
279 (forall x : X (ElemFunc IS),
280 (forall n:nat, Domain (fn n) x) -> A x)
281 -> almost_everywhere A.
282 Proof.
283 intros IS fn fnInt A inc.
284 pose (fun n => IntFn (let (df,_) := countable_representation IS (fn n) (fnInt n) n in df))
285 as fnk.
286 exists (XinfiniteSumAbs (diagSeq fnk)).
287 split.
288 - pose (fun n => IntFnL (let (df,_) := countable_representation IS (fn n) (fnInt n) n in df))
289 as fnkL.
290 destruct (series_cv_maj (fun n => IntAbsSum (let (df,_) :=
291 countable_representation
292 IS (fn n) (fnInt n) n in df))
293 (fun n => (CRpow (CR_of_Q _ (1#2)) n)) (CR_of_Q _ 2)) as [sumI cvI].
294 + intro n. destruct (countable_representation IS (fn n) (fnInt n) n). simpl.
295 destruct p. rewrite CRabs_right. assumption. destruct x.
296 simpl. apply (series_cv_nonneg (fun k : nat => Iabs (IntFn k) (IntFnL k))).
297 intros. apply integralPositive. intros x xdf.
298 rewrite applyXabs. apply CRabs_pos.
299 assumption.
300 + apply GeoHalfTwo.
301 + assert (series_cv (fun k : nat =>
302 Iabs (diagSeq fnk k) (diagSeqL IS fnk fnkL k)) sumI) as H.
303 apply (series_cv_eq (diagSeq (fun n k =>
304 let (fInt,g) := countable_representation
305 IS (fn n) (fnInt n) n in
306 Iabs (IntFn fInt k) (IntFnL fInt k)))).
307 intro n. unfold diagSeq, diagSeqL. destruct (diagPlaneInv n).
308 unfold fnk, fnkL.
309 destruct (countable_representation IS (fn n0) (fnInt n0) n0).
310 reflexivity.
311 apply (DiagSeqInfiniteSumColPos
312 _ (fun n => IntAbsSum (let (df,_) := countable_representation
313 IS (fn n) (fnInt n) n in df))).
314 intros. destruct (countable_representation IS (fn n) (fnInt n) n).
315 apply integralPositive. intros y ydf. rewrite applyXabs.
316 apply CRabs_pos. intro n.
317 destruct (countable_representation IS (fn n) (fnInt n) n).
318 destruct x. assumption. apply cvI.
319 exists (Build_IntegralRepresentation
320 IS
321 (diagSeq fnk)
322 (diagSeqL IS fnk fnkL)
323 sumI H).
324 apply PartialRestriction_refl.
325 - (* Inclusion of domains *)
326 intros xDiag xdf. apply inc.
327 clear inc. intro n. simpl.
328 pose proof (domainInfiniteSumAbsDiag _ fnk n xDiag xdf) as H.
329 unfold fnk in H.
330 destruct (countable_representation IS (fn n) (fnInt n) n) as [[fnn] [i _]].
331 unfold IntFn in i. apply i, H.
332 Qed.
333
334 Lemma IntegralNonDecreasingAE
335 : forall {IS : IntegrationSpace}
336 (f g : PartialFunction (X (ElemFunc IS)))
337 (fInt : IntegrableFunction f)
338 (gInt : IntegrableFunction g),
339 almost_everywhere
340 (fun x : X (ElemFunc IS)
341 => forall (dF : Domain f x) (dG : Domain g x),
342 partialApply _ _ dF <= partialApply _ _ dG)
343 -> Integral fInt <= Integral gInt.
344 Proof.
345 intros. destruct X as [h [hInt inc]].
346 pose proof (IntegralNonDecreasing
347 (Xplus f (Xminus h h))
348 (Xplus g (Xminus h h))
349 (IntegrablePlus f (Xminus h h) fInt
350 (IntegrableMinus hInt hInt))
351 (IntegrablePlus g (Xminus h h) gInt
352 (IntegrableMinus hInt hInt))).
353 rewrite IntegralPlus in H. rewrite IntegralPlus in H.
354 rewrite IntegralMinus in H. unfold CRminus in H.
355 rewrite CRplus_opp_r, CRplus_0_r, CRplus_0_r in H. apply H.
356 intros x xdf xdg. destruct xdf, xdg.
357 rewrite (applyXplus f (Xminus h h)), (applyXplus g (Xminus h h)).
358 destruct d0, d2.
359 rewrite (applyXminus h h), (applyXminus h h).
360 destruct f,g,h; simpl; clear H gInt fInt. simpl in inc.
361 rewrite (DomainProp1 _ d3 d0), (DomainProp1 _ d2 d0), (DomainProp1 _ d4 d0).
362 unfold CRminus. rewrite CRplus_opp_r, CRplus_0_r, CRplus_0_r.
363 apply inc. apply d2.
364 Qed.
365
366 Lemma IntegrableExtensionalAE
367 : forall {IS : IntegrationSpace}
368 (f g : PartialFunction (X (ElemFunc IS))),
369 almost_everywhere (Domain g)
370 -> almost_everywhere
371 (fun x : X (ElemFunc IS) => forall (dF : Domain f x) (dG : Domain g x),
372 partialApply _ _ dF == partialApply _ _ dG)
373 -> IntegrableFunction f
374 -> IntegrableFunction g.
375 Proof.
376 intros. destruct X as [h [i c]]. destruct X0 as [k [H H0]].
377 apply (IntegrableFunctionExtensional
378 (Xplus f (Xplus (Xscale 0 h) (Xscale 0 k)))).
379 - split.
380 + intros x xD. apply c. apply xD.
381 + intros. simpl. destruct xD, d0.
382 rewrite CRmult_0_l, CRmult_0_l, CRplus_0_l, CRplus_0_r.
383 exact (H0 x d1 d xG).
384 - apply (IntegrablePlus _ _ X1). apply IntegrablePlus.
385 apply IntegrableScale, i. apply IntegrableScale, H.
386 Qed.
387
388 Lemma IntegralExtensionalAE
389 : forall {IS : IntegrationSpace}
390 (f g : PartialFunction (X (ElemFunc IS)))
391 (fInt : IntegrableFunction f)
392 (gInt : IntegrableFunction g),
393 almost_everywhere
394 (fun x : X (ElemFunc IS)
395 => forall (dF : Domain f x) (dG : Domain g x),
396 partialApply _ _ dF == partialApply _ _ dG)
397 -> Integral fInt == Integral gInt.
398 Proof.
399 intros. split.
400 - apply IntegralNonDecreasingAE. destruct X as [h [hInt p]].
401 exists h. split. exact hInt.
402 intros x dfull dG dF.
403 rewrite (p x dfull dF dG). apply CRle_refl.
404 - apply IntegralNonDecreasingAE. destruct X as [h [hInt p]].
405 exists h. split. exact hInt.
406 intros x dfull dF dG. rewrite (p x dfull dF dG).
407 apply CRle_refl.
408 Qed.
409
410 Definition PackFirstFunctions {R : ConstructiveReals } (X : Set)
411 (fn : nat -> @PartialFunction R X)
412 (n p : nat) : PartialFunction X
413 := match p with
414 | O => Xsum fn n
415 | _ => fn (n + p)%nat
416 end.
417
418 Lemma PackFirstFunctionsL : forall (IS : IntegrationSpace)
419 (fn : nat -> PartialFunction (X (ElemFunc IS)))
420 (fnL : forall n:nat, L (ElemFunc IS) (fn n))
421 (n p : nat),
422 L (ElemFunc IS) (PackFirstFunctions (X (ElemFunc IS)) fn n p).
423 Proof.
424 intros. unfold PackFirstFunctions. destruct p.
425 - apply LsumStable. apply fnL.
426 - apply fnL.
427 Defined.
428
429 Lemma applyPackFirstSum : forall {R : ConstructiveReals} (X : Set)
430 (fn : nat -> @PartialFunction R X)
431 (n N : nat)
432 (x : X)
433 (pxDn : forall n:nat, Domain (fn n) x)
434 (pxDnP : forall n:nat, Domain (PackFirstFunctions X fn N n) x),
435 (CRsum (fun k => partialApply (PackFirstFunctions X fn N k) x (pxDnP k)) n
436 == CRsum (fun k => partialApply (fn k) x (pxDn k)) (n+N)).
437 Proof.
438 induction n.
439 - intros. simpl. rewrite (applyXsum _ _ _ (pxDnP O) pxDn). reflexivity.
440 - intros. simpl. rewrite (IHn N x pxDn). clear IHn. apply CRplus_morph.
441 reflexivity. replace (S (n + N)) with (N + S n)%nat.
442 apply DomainProp. rewrite Nat.add_comm. reflexivity.
443 Qed.
444
445 Lemma IabsMinusMaj : forall (IS : IntegrationSpace)
446 (f g : PartialFunction (X (ElemFunc IS)))
447 (fL : L (ElemFunc IS) f)
448 (gL : L (ElemFunc IS) g),
449 - Iabs f fL + Iabs g gL
450 <= Iabs (Xminus f g) (LminusStable f g fL gL).
451 Proof.
452 intros. rewrite CRplus_comm. unfold Iabs.
453 pose proof (@Iminus IS).
454 unfold CRminus in H. rewrite <- H. clear H.
455 apply INonDecreasing. intros. destruct y.
456 rewrite applyXabs. rewrite (applyXminus f g).
457 destruct xF. rewrite (applyXminus (Xabs g) (Xabs f)).
458 unfold Xabs, Xop, partialApply.
459 destruct f,g.
460 rewrite (DomainProp0 x d0 d1), (DomainProp x d2 d).
461 rewrite CRabs_minus_sym.
462 apply CRabs_triang_inv.
463 Qed.
464
465 Lemma PackSeriesCV : forall {R : ConstructiveReals}
466 (un : nat -> CRcarrier R) (N : nat) (a s : CRcarrier R),
467 series_cv un s
468 -> series_cv (fun n => match n with
469 | O => a
470 | _ => un (N + n)%nat
471 end) (s - CRsum un N + a).
472 Proof.
473 intros. intros n. specialize (H n) as [k maj].
474 exists k. (* same modulus of convergence *)
475 intros i H. destruct i.
476 - inversion H. subst k. simpl. clear H.
477 rewrite <- (CRplus_comm a). unfold CRminus.
478 rewrite CRopp_plus_distr. rewrite <- CRplus_assoc. rewrite CRplus_opp_r.
479 rewrite CRplus_0_l. rewrite CRabs_opp.
480 specialize (maj N (Nat.le_0_l N)).
481 rewrite CRabs_minus_sym in maj. exact maj.
482 - rewrite decomp_sum. simpl. unfold CRminus.
483 rewrite CRplus_comm. rewrite CRopp_plus_distr.
484 rewrite CRplus_assoc.
485 rewrite <- (CRplus_assoc (-a)). rewrite CRplus_opp_l.
486 rewrite CRplus_0_l.
487 rewrite CRopp_plus_distr. rewrite CRopp_involutive.
488 rewrite (CRsum_eq (fun i : nat => un (N + S i)%nat) (fun i : nat => un (S N + i)%nat)).
489 rewrite CRplus_assoc.
490 rewrite <- sum_assoc. rewrite CRplus_comm. simpl in maj. apply maj.
491 apply (Nat.le_trans k (S i)). assumption. simpl.
492 apply le_n_S. rewrite Nat.add_comm. rewrite <- (Nat.add_0_r i). rewrite <- Nat.add_assoc.
493 apply Nat.add_le_mono_l. apply Nat.le_0_l.
494 intros. rewrite Nat.add_succ_r. reflexivity. apply le_n_S.
495 apply Nat.le_0_l.
496 Qed.
497
498 Lemma PackSeriesCVReverse
499 : forall {R : ConstructiveReals} (un : nat -> CRcarrier R)
500 (N : nat) (a s : CRcarrier R),
501 series_cv (fun n => match n with
502 | O => a
503 | _ => un (N + n)%nat
504 end) s
505 -> series_cv un (s - a + CRsum un N).
506 Proof.
507 intros. intros eps. specialize (H eps) as [k maj].
508 exists (S N + k)%nat. (* translated same modulus of convergence *)
509 intros n kLen.
510 destruct (Nat.le_exists_sub (S N) n) as [m [inf _]].
511 apply (Nat.le_trans _ (S N + k)). rewrite <- (Nat.add_0_r (S N)).
512 rewrite <- Nat.add_assoc. apply Nat.add_le_mono_l. apply Nat.le_0_l.
513 assumption.
514 subst n. replace (m + S N)%nat with (S N + m)%nat. rewrite sum_assoc.
515 specialize (maj (S m)). rewrite decomp_sum in maj.
516 simpl in maj. unfold CRminus. simpl.
517 rewrite CRplus_comm.
518 rewrite CRopp_plus_distr, CRplus_assoc. simpl.
519 rewrite <- (CRplus_assoc (-CRsum un N)).
520 rewrite CRplus_opp_l. rewrite CRplus_0_l.
521 rewrite (CRplus_comm s). rewrite CRopp_plus_distr.
522 rewrite CRopp_involutive. rewrite CRplus_assoc.
523 rewrite (CRplus_comm (-s)). rewrite <- CRplus_assoc.
524 rewrite (CRsum_eq _ (fun i : nat => un (N + S i)%nat)). apply maj.
525 rewrite Nat.add_comm in kLen. apply Nat.add_le_mono_r in kLen.
526 apply (Nat.le_trans k m). assumption. apply le_S. apply Nat.le_refl.
527 intros. rewrite Nat.add_succ_r. reflexivity. apply le_n_S.
528 apply Nat.le_0_l. rewrite Nat.add_comm. reflexivity.
529 Qed.
530
531 Definition domainSumPackIncReverse
532 {R : ConstructiveReals} (X : Set)
533 (fn : nat -> @PartialFunction R X)
534 (N : nat)
535 (x : X)
536 (xn : forall n:nat, Domain (PackFirstFunctions X fn N n) x)
537 : forall n:nat, Domain (fn n) x.
538 Proof.
539 intros. destruct (le_lt_dec n N).
540 - exact (domainXsumIncReverse fn n N x (xn O) l).
541 - pose (xn (n - N)%nat). unfold PackFirstFunctions in d.
542 destruct (n - N)%nat eqn:des. exfalso. apply (Nat.sub_gt n N); assumption.
543 rewrite <- (Nat.sub_add N n). rewrite des. rewrite Nat.add_comm.
544 exact d. subst d.
545 apply (Nat.le_trans N (S N)). apply le_S. apply Nat.le_refl. assumption.
546 Qed.
547
548 Definition domainInfiniteSumPackInc
549 {R : ConstructiveReals} (X : Set)
550 (fn : nat -> @PartialFunction R X)
551 (N : nat)
552 : PartialRestriction (XinfiniteSumAbs (PackFirstFunctions X fn N))
553 (XinfiniteSumAbs fn).
554 Proof.
555 split.
556 - intros x xD.
557 (* The absolute convergence, to the adjusted limit *)
558 apply (domainInfiniteSumAbsInc
559 fn x
560 (fun k => domainSumPackIncReverse
561 X fn N x (fun n => domainInfiniteSumAbsIncReverse _ x xD n) k)
562 (let (xn,a) := xD in
563 let (lim,_) := CR_complete R _ a in
564 lim
565 - CRabs _ (partialApply _ x (domainInfiniteSumAbsIncReverse _ x xD 0))
566 + CRsum (fun k => CRabs _ (partialApply _ x (domainSumPackIncReverse X fn N x (fun n => domainInfiniteSumAbsIncReverse _ x xD n) k))) N
567 )).
568 destruct xD as [xn cv2]; simpl.
569 destruct (CR_complete R
570 (CRsum
571 (fun n : nat =>
572 CRabs _ (partialApply (PackFirstFunctions X fn N n) x (xn n)))) cv2)
573 as [sumAbsXn cv].
574 apply PackSeriesCVReverse.
575 apply (series_cv_eq (fun n : nat => CRabs _ (partialApply _ x (xn n)))).
576 2: apply cv.
577 intro n. unfold PackFirstFunctions.
578 destruct n. reflexivity.
579 apply CRabs_morph. apply DomainProp.
580 - intros. (* The direct convergence, to the same limit *)
581 destruct xD,xG; simpl.
582 destruct (series_cv_abs (fun n : nat => partialApply (PackFirstFunctions X fn N n) x (x0 n)) c).
583 destruct (series_cv_abs (fun n : nat => partialApply (fn n) x (x1 n)) c0).
584 apply (series_cv_unique (fun k : nat => partialApply (fn k) x (x1 k))).
585 2: apply s0.
586 intros eps.
587 specialize (s eps) as [k maj].
588 exists (S N + k)%nat. (* translated modulus of convergence *)
589 intros n H0. destruct (Nat.le_exists_sub N n) as [m [inf _]].
590 apply (Nat.le_trans _ (S N + k)).
591 simpl. apply le_S. rewrite <- (Nat.add_0_r N).
592 rewrite <- Nat.add_assoc. apply Nat.add_le_mono_l.
593 apply Nat.le_0_l. assumption. subst n.
594 rewrite <- (applyPackFirstSum X fn m N x x1 x0).
595 apply maj. apply (Nat.add_le_mono_l k m (S N)).
596 apply (Nat.le_trans _ (m + N)). assumption. rewrite Nat.add_comm.
597 apply Nat.add_le_mono_r. apply le_S. apply Nat.le_refl.
598 Qed.
599
600 (* Lemma 1.15 in Bishop's article, a representation
601 that fits the absolute integral better. *)
602 Lemma AbsRepresentation : forall (IS : IntegrationSpace)
603 (f : PartialFunction (X (ElemFunc IS)))
604 (eps : CRcarrier (RealT (ElemFunc IS)))
605 (fInt : IntegrableFunction f),
606 0 < eps
607 -> { intRepres : IntegralRepresentation
608 & prod (PartialRestriction (XinfiniteSumAbs (IntFn intRepres)) f)
609 (IntAbsSum intRepres
610 <= Integral (IntegrableAbs fInt) + eps) }.
611 Proof.
612 intros.
613 pose proof (IntegralAbsLimit f fInt) as IabsLimit.
614 destruct fInt as [[fn fnL sumIAbsFn lim] [inj restr]] eqn:desFint.
615 unfold IntFn, IntFnL in IabsLimit. unfold IntFn in inj, restr.
616 assert (forall N:nat, series_cv
617 (fun k : nat =>
618 Iabs (PackFirstFunctions (X (ElemFunc IS)) fn N k)
619 (PackFirstFunctionsL IS fn fnL N k))
620 (sumIAbsFn - CRsum (fun n : nat => Iabs (fn n) (fnL n)) N +
621 Iabs (Xsum fn N) (LsumStable fn fnL N)))
622 as limPack.
623 { intro N.
624 apply (series_cv_eq
625 (fun n => match n with
626 | O => Iabs (Xsum fn N) (LsumStable fn fnL N)
627 | _ => Iabs (fn (N+n)%nat) (fnL (N+n)%nat)
628 end)).
629 intro n. destruct n; reflexivity.
630 apply (PackSeriesCV (fun n : nat => Iabs (fn n) (fnL n))).
631 assumption. }
632 pose (fun N:nat => Build_IntegralRepresentation
633 IS
634 (PackFirstFunctions (X (ElemFunc IS)) fn N)
635 (PackFirstFunctionsL IS fn fnL N)
636 (sumIAbsFn
637 - CRsum (fun n => Iabs (fn n) (fnL n)) N
638 + Iabs (Xsum fn N) (LsumStable fn fnL N))
639 (limPack N))
640 as represPack.
641 assert (forall N:nat, PartialRestriction (XinfiniteSumAbs (IntFn (represPack N))) f)
642 as IsRepresPack.
643 { intro N. unfold represPack, IntFn.
644 destruct (domainInfiniteSumPackInc (X (ElemFunc IS)) fn N) as [inc app].
645 split. intros x xdf.
646 apply inj, inc. exact xdf.
647 intros. specialize (app x xD (inc x xD)). rewrite app.
648 apply restr. }
649
650 destruct (CRup_nat (CR_of_Q _ 2 * CRinv _ eps (inr H))) as [epsN majEpsN].
651 pose proof (lim (Pos.of_nat epsN)) as [N limN].
652 exists (represPack N). split. apply IsRepresPack.
653
654 (* Prove the epsilon majoration *)
655 apply (CRle_trans _ (Iabs (Xsum fn N) (LsumStable fn fnL N)
656 + eps * CR_of_Q _ (1#2))).
657 - simpl. specialize (limN N (Nat.le_refl N)).
658 rewrite <- (CRplus_comm (eps * CR_of_Q _ (1#2))).
659 apply CRplus_le_compat. 2: apply CRle_refl.
660 rewrite CRabs_minus_sym in limN.
661 apply (CRle_trans
662 _ (CRabs _ (sumIAbsFn - CRsum (fun k : nat => Iabs (fn k) (fnL k)) N))).
663 apply CRle_abs. apply (CRle_trans _ (CR_of_Q _ (1# Pos.of_nat epsN))).
664 assumption. apply (CRmult_lt_compat_r eps) in majEpsN.
665 rewrite CRmult_assoc, CRinv_l, CRmult_1_r in majEpsN.
666 2: exact H. apply CRlt_asym.
667 apply (CRmult_lt_reg_r (CR_of_Q _ 2)).
668 apply CR_of_Q_lt; reflexivity.
669 rewrite CRmult_assoc, <- (CR_of_Q_mult _ (1#2)).
670 setoid_replace ((1 # 2) * 2)%Q with 1%Q.
671 2: reflexivity. rewrite CRmult_1_r.
672 apply (CRmult_lt_reg_l (CR_of_Q _ (Z.pos (Pos.of_nat epsN) #1))).
673 apply CR_of_Q_lt; reflexivity.
674 rewrite <- CRmult_assoc, <- CR_of_Q_mult.
675 setoid_replace ((Z.pos (Pos.of_nat epsN) # 1) * (1 # Pos.of_nat epsN))%Q with 1%Q.
676 rewrite CRmult_1_l. apply (CRlt_le_trans _ _ _ majEpsN).
677 apply CRmult_le_compat_r. apply CRlt_asym, H.
678 apply CR_of_Q_le. unfold Qle, Qnum, Qden.
679 do 2 rewrite Z.mul_1_r. destruct epsN. discriminate.
680 apply Pos2Z.pos_le_pos. apply Pos2Nat.inj_le.
681 rewrite SuccNat2Pos.id_succ, Nat2Pos.id. apply Nat.le_refl. discriminate.
682 unfold Qmult, Qeq, Qnum, Qden. do 2 rewrite Z.mul_1_r. reflexivity.
683 - (* Replace the limit at infinity by a finite m > N *)
684 apply (CR_cv_bound_down
685 (fun m => Iabs (Xsum fn m) (LsumStable fn fnL m) + eps) _ _ (S N)).
686 intros m maj.
687 apply (CRplus_le_reg_l (- Iabs (Xsum fn m) (LsumStable fn fnL m))).
688 rewrite <- CRplus_assoc. rewrite <- CRplus_assoc. rewrite CRplus_opp_l.
689 rewrite CRplus_0_l. apply (CRplus_le_reg_r (- (eps * CR_of_Q _ (1#2)))).
690 rewrite CRplus_assoc. rewrite CRplus_opp_r. rewrite CRplus_0_r.
691 apply (CRle_trans _ (Iabs (Xminus (Xsum fn m) (Xsum fn N))
692 (LminusStable _ _ (LsumStable fn fnL m)
693 (LsumStable fn fnL N)))).
694 apply IabsMinusMaj.
695 destruct (Nat.le_exists_sub N m) as [k [add _]]. apply le_S in maj.
696 apply le_S_n in maj. assumption. subst m. destruct k.
697 exfalso. exact (Nat.lt_irrefl N maj).
698 apply (CRle_trans
699 _ (Iabs (Xsum (fun a => fn (S N + a)%nat) k)
700 (LsumStable (fun a => fn (S N + a)%nat)
701 (fun a => fnL (S N + a)%nat) k))).
702 apply INonDecreasing.
703 intros. rewrite applyXabs. rewrite applyXabs.
704 remember (S k + N)%nat. rewrite Nat.add_comm in Heqn.
705 replace (N + S k)%nat with (S N + k)%nat in Heqn. subst n.
706 rewrite (Xsum_assocMinus fn N k x _ y).
707 apply CRle_refl. rewrite Nat.add_succ_r. reflexivity.
708 apply (CRle_trans
709 _ (I IS (Xsum (fun a : nat => Xabs (fn (S N + a)%nat)) k)
710 (LsumStable _ (fun a => LabsStable (ElemFunc IS) (fn (S N + a)%nat)
711 (fnL (S N + a)%nat)) k))).
712 apply INonDecreasing. intros.
713 apply XmultiTriangleIneg. rewrite IadditiveIterate.
714 rewrite <- (CRsum_eq (fun n0 : nat =>
715 I IS (Xabs (fn (N + S n0)%nat))
716 (LabsStable (ElemFunc IS) (fn (N + S n0)%nat) (fnL (N + S n0)%nat)))).
717 apply (series_cv_remainder_maj (fun n0 : nat =>
718 I IS (Xabs (fn n0))
719 (LabsStable (ElemFunc IS) (fn n0) (fnL n0))) sumIAbsFn).
720 apply lim.
721 rewrite <- (CRplus_opp_r (eps * CR_of_Q _ (1 # 2))).
722 apply CRplus_lt_compat_r.
723 rewrite <- (CRmult_1_r eps).
724 rewrite CRmult_assoc. apply CRmult_lt_compat_l.
725 assumption. rewrite CRmult_1_l. apply (CRmult_lt_reg_l (CR_of_Q _ 2)).
726 apply CR_of_Q_lt; reflexivity. rewrite <- CR_of_Q_mult.
727 rewrite CRmult_1_r. apply CR_of_Q_lt. reflexivity.
728 intro n. apply integralPositive. intros x xdf. rewrite applyXabs.
729 apply CRabs_pos. apply CRlt_asym.
730 setoid_replace (eps + - (eps * CR_of_Q _ (1 # 2)))
731 with (eps * CR_of_Q _ (1 # 2)).
732 apply (CRmult_lt_compat_r eps) in majEpsN.
733 rewrite CRmult_assoc, CRinv_l, CRmult_1_r in majEpsN.
734 2: exact H.
735 apply (CRle_lt_trans _ (CR_of_Q _ (1 # Pos.of_nat epsN))).
736 apply limN. apply Nat.le_refl.
737 apply (CRmult_lt_reg_r (CR_of_Q _ 2)).
738 apply CR_of_Q_lt; reflexivity.
739 rewrite CRmult_assoc, <- (CR_of_Q_mult _ (1#2)).
740 setoid_replace ((1 # 2) * 2)%Q with 1%Q.
741 2: reflexivity. rewrite CRmult_1_r.
742 apply (CRmult_lt_reg_l (CR_of_Q _ (Z.pos (Pos.of_nat epsN) #1))).
743 apply CR_of_Q_lt; reflexivity.
744 rewrite <- CRmult_assoc, <- CR_of_Q_mult.
745 setoid_replace ((Z.pos (Pos.of_nat epsN) # 1) * (1 # Pos.of_nat epsN))%Q with 1%Q.
746 rewrite CRmult_1_l. apply (CRlt_le_trans _ _ _ majEpsN).
747 apply CRmult_le_compat_r. apply CRlt_asym, H.
748 apply CR_of_Q_le. unfold Qle, Qnum, Qden.
749 do 2 rewrite Z.mul_1_r. destruct epsN. discriminate.
750 apply Pos2Z.pos_le_pos. apply Pos2Nat.inj_le.
751 rewrite SuccNat2Pos.id_succ, Nat2Pos.id. apply Nat.le_refl. discriminate.
752 unfold Qmult, Qeq, Qnum, Qden. do 2 rewrite Z.mul_1_r. reflexivity.
753 rewrite <- (CRmult_1_r eps), CRopp_mult_distr_r.
754 rewrite CRmult_assoc, <- CRmult_plus_distr_l.
755 apply CRmult_morph. rewrite CRmult_1_r. reflexivity. rewrite CRmult_1_l.
756 rewrite <- CR_of_Q_opp, <- CR_of_Q_plus.
757 apply CR_of_Q_morph. reflexivity.
758 intros. rewrite Nat.add_succ_r. reflexivity.
759 apply CR_cv_plus. assumption. apply CR_cv_const.
760 Qed.
761
762 (* We now state the completeness theorem of integrable functions of an integration
763 space IS : they behave as the L-functions of a bigger integration space,
764 which integrable functions are already integrable in IS. *)
765
766 Definition CompleteRepresentation
767 (IS : IntegrationSpace)
768 (fn : nat -> PartialFunction (X (ElemFunc IS)))
769 (fnInt : forall n:nat, IntegrableFunction (fn n))
770 : { intRepresN : nat -> IntegralRepresentation
771 & forall n:nat, prod (PartialRestriction
772 (XinfiniteSumAbs (IntFn (intRepresN n))) (fn n))
773 (IntAbsSum (intRepresN n)
774 <= Integral (IntegrableAbs (fnInt n))
775 + CRpow (CR_of_Q _ (1#2)) n) }.
776 Proof.
777 assert (0 < CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) as halfPos.
778 { apply CR_of_Q_lt. reflexivity. }
779 exists (fun n:nat => let (df,_) := AbsRepresentation
780 IS (fn n) (CRpow (CR_of_Q _ (1#2)) n) (fnInt n)
781 (CRpow_gt_zero (CR_of_Q _ (1 # 2)) n halfPos) in df).
782 intro n. destruct (AbsRepresentation
783 IS (fn n) _ (fnInt n)
784 (CRpow_gt_zero (CR_of_Q _ (1 # 2)) n halfPos)).
785 simpl. split; apply p.
786 Qed.
787
788 Lemma CompleteRepresentationDoubleSum
789 : forall (IS : IntegrationSpace)
790 (fn : nat -> PartialFunction (X (ElemFunc IS)))
791 (fnInt : forall n:nat, IntegrableFunction (fn n)),
792 let (intRepresN, _) := CompleteRepresentation IS fn fnInt in
793 forall (x : X (ElemFunc IS)) (xD : Domain
794 (XinfiniteSumAbs
795 (diagSeq
796 (fun n k : nat => IntFn (intRepresN n) k))) x)
797 (pxF : forall n : nat, Domain (fn n) x),
798 series_cv
799 (fun n : nat => partialApply (fn n) x (pxF n))
800 (partialApply (XinfiniteSumAbs (diagSeq
801 (fun n k : nat => IntFn (intRepresN n) k))) x xD).
802 Proof.
803 intros. destruct (CompleteRepresentation IS fn fnInt) as [cfnInt represN].
804 intros.
805 destruct (DiagSeqInfiniteSum
806 (fun n k => partialApply _ _
807 (domainInfiniteSumAbsIncReverse
808 _ x (domainInfiniteSumAbsDiag _ _ n x xD) k))
809 (fun n : nat => partialApply (fn n) x (pxF n))
810 (let (xn,a) := xD in
811 let (l,_) := CR_complete _ _ a in l)).
812 - apply InfiniteDiagApply.
813 - (* The limit on each line *)
814 intro n. apply represApply. apply represN.
815 - setoid_replace (partialApply
816 (XinfiniteSumAbs
817 (diagSeq (fun n k : nat => IntFn (cfnInt n) k))) x xD)
818 with x0.
819 apply p. destruct p,p.
820 apply (series_cv_unique (diagSeq
821 (fun n k : nat =>
822 partialApply (IntFn (cfnInt n) k) x
823 (domainInfiniteSumAbsIncReverse (fun k0 : nat => IntFn (cfnInt n) k0) x
824 (domainInfiniteSumAbsDiag (X (ElemFunc IS))
825 (fun n0 k0 : nat => IntFn (cfnInt n0) k0) n x xD) k)))).
826 2: exact s0.
827 apply (series_cv_eq (fun k : nat =>
828 partialApply
829 (diagSeq (fun n k0 : nat => IntFn (cfnInt n) k0) k) x
830 (let (xn,_) := xD in xn k))).
831 + intro n.
832 transitivity (let (n0,k) := diagPlaneInv n in
833 partialApply (IntFn (cfnInt n0) k) x
834 (domainInfiniteSumAbsIncReverse (fun k0 : nat => IntFn (cfnInt n0) k0) x
835 (domainInfiniteSumAbsDiag (X (ElemFunc IS)) (fun n1 k0 : nat => IntFn (cfnInt n1) k0)
836 n0 x xD) k)).
837 2: reflexivity. destruct (diagPlaneInv n) eqn:desN.
838 apply partialApplyEq. unfold diagSeq. rewrite desN. reflexivity.
839 + destruct xD as [xn cv]; simpl. apply series_cv_abs_cv.
840 Qed.
841
842 Lemma partialInfiniteTriangle
843 : forall {R : ConstructiveReals} (X : Set)
844 (fn : nat -> @PartialFunction R X) (x : X)
845 (xD : Domain (XinfiniteSumAbs fn) x),
846 CRle _ (CRabs _ (partialApply _ x xD))
847 (let (xn, cv) := xD in
848 let (l,_) := CR_complete R _ cv in l).
849 Proof.
850 intros. destruct xD as [xn limAbs]; simpl.
851 destruct (series_cv_abs (fun n : nat => partialApply (fn n) x (xn n)) limAbs).
852 apply (series_cv_triangle (fun k : nat => partialApply (fn k) x (xn k))).
853 exact s.
854 destruct (CR_complete R
855 (CRsum (fun n : nat => CRabs _ (partialApply (fn n) x (xn n)))) limAbs).
856 exact c.
857 Qed.
858
859 Lemma CompleteRepresentationRestrict
860 : forall (IS : IntegrationSpace)
861 (fn : nat -> PartialFunction (X (ElemFunc IS)))
862 (fnInt : forall n:nat, IntegrableFunction (fn n)),
863 let (intRepresN, _) := CompleteRepresentation IS fn fnInt in
864 PartialRestriction
865 (XinfiniteSumAbs
866 (diagSeq (fun n k => IntFn (intRepresN n) k)))
867 (XinfiniteSumAbs fn).
868 Proof.
869 intros. pose proof (CompleteRepresentationDoubleSum IS fn fnInt) as dsum.
870 destruct (CompleteRepresentation IS fn fnInt) as [intRepresN restrN].
871 split. intros x xdf.
872 pose (domainInfiniteSumAbsDiag
873 _ (fun n k => IntFn (intRepresN n) k))
874 as lineInj.
875
876 destruct (series_cv_maj
877 (fun n : nat =>
878 CRabs _ (partialApply (XinfiniteSumAbs (fun k : nat => IntFn (intRepresN n) k)) x (lineInj n x xdf)))
879 (fun n => let (_,a) := lineInj n x xdf in
880 let (l,_) := CR_complete _ _ a in
881 l)
882 (let (_,a) := xdf in
883 let (l,_) := CR_complete _ _ a in
884 l)).
885 - intro n. simpl. rewrite CRabs_right.
886 apply partialInfiniteTriangle. apply CRabs_pos.
887 - apply applyInfiniteSumAbsDiag.
888 - destruct p.
889 apply (domainInfiniteSumAbsInc
890 fn x (fun n:nat => fst (fst (restrN n)) x (lineInj n x xdf)) x0).
891 + apply (series_cv_eq (fun n : nat =>
892 CRabs _
893 (partialApply
894 (XinfiniteSumAbs (fun k : nat => IntFn (intRepresN n) k)) x
895 (lineInj n x xdf)))).
896 2: exact s. intro n. destruct (restrN n) as [[j a0] maj].
897 unfold fst.
898 specialize (a0 x (lineInj n x xdf)). apply CRabs_morph.
899 apply a0.
900 - intros. symmetry. apply applyInfiniteSumAbs. apply dsum.
901 Qed.
902
903 (* Theorem 1.16 of Bishop *)
904 Lemma IntegrableFunctionsComplete
905 : forall (IS : IntegrationSpace)
906 (fn : nat -> PartialFunction (X (ElemFunc IS)))
907 (fnInt : forall n:nat, IntegrableFunction (fn n))
908 (sumIAbsFn : CRcarrier (RealT (ElemFunc IS))),
909 (series_cv
910 (fun k:nat => Integral (IntegrableAbs (fnInt k)))
911 sumIAbsFn)
912 -> { represInt : IntegralRepresentation
913 & prod (PartialRestriction (XinfiniteSumAbs (IntFn represInt))
914 (XinfiniteSumAbs fn))
915 (series_cv (fun n => Integral (fnInt n))
916 (IntegralSeries represInt)) }.
917 Proof.
918 intros. pose proof (CompleteRepresentationRestrict IS fn fnInt) as complRestrict.
919 destruct (CompleteRepresentation IS fn fnInt) as [intRepresN restrN].
920 destruct (series_cv_maj (fun n => IntAbsSum (intRepresN n))
921 (fun n => Integral (IntegrableAbs (fnInt n))
922 + CRpow (CR_of_Q _ (1#2)) n)
923 (sumIAbsFn + CR_of_Q _ 2)) as [s [cvs majS]].
924 - intro n. rewrite CRabs_right. apply (restrN n).
925 destruct (intRepresN n); simpl.
926 apply (series_cv_nonneg (fun k : nat => Iabs (IntFn k) (IntFnL k))).
927 intro n0. apply integralPositive. intros x xdf. rewrite applyXabs.
928 apply CRabs_pos. assumption.
929 - apply series_cv_plus. apply H. apply GeoHalfTwo.
930 - assert (series_cv (fun k : nat => Iabs
931 (diagSeq (fun n k0 : nat => IntFn (intRepresN n) k0) k)
932 (diagSeqL IS (fun n k0 : nat => IntFn (intRepresN n) k0)
933 (fun n k0 : nat => IntFnL (intRepresN n) k0) k)) s).
934 { apply (series_cv_eq (diagSeq (fun n k => Iabs
935 (IntFn (intRepresN n) k)
936 (IntFnL (intRepresN n) k)))).
937 intro n. unfold diagSeq, diagSeqL. destruct (diagPlaneInv n). reflexivity.
938 apply (DiagSeqInfiniteSumColPos _ (fun n : nat => IntAbsSum (intRepresN n))).
939 intros n k. apply integralPositive. intros x xdf.
940 rewrite applyXabs.
941 apply CRabs_pos. intro n. apply (intRepresN n). assumption. }
942 exists (Build_IntegralRepresentation
943 IS
944 (diagSeq (fun n k => IntFn (intRepresN n) k))
945 (diagSeqL IS _ (fun n k => IntFnL (intRepresN n) k))
946 s H0).
947 split.
948 + exact complRestrict.
949 + pose proof (IntegralCv {| IntFn := diagSeq
950 (fun n k : nat => IntFn (intRepresN n) k);
951 IntFnL := diagSeqL IS (fun n k : nat => IntFn (intRepresN n) k)
952 (fun n k : nat => IntFnL (intRepresN n) k);
953 IntAbsSum := s;
954 IntAbsSumCv := H0 |}); simpl.
955 simpl in H1.
956 destruct (series_cv_maj
957 (diagSeq (fun n k : nat => CRabs _ (I IS _ (IntFnL (intRepresN n) k))))
958 (fun k : nat => Iabs _
959 (diagSeqL IS (fun n k0 : nat => IntFn (intRepresN n) k0)
960 (fun n k0 : nat => IntFnL (intRepresN n) k0) k)) s).
961 intro n. rewrite CRabs_right.
962 unfold diagSeq, diagSeqL. destruct (diagPlaneInv n).
963 apply integralAbsMaj. unfold diagSeq. destruct (diagPlaneInv n).
964 apply CRabs_pos. assumption.
965
966 destruct (DiagSeqInfiniteSum
967 (fun n k => I IS _ (IntFnL (intRepresN n) k))
968 (fun n : nat => Integral (fnInt n)) x).
969 apply p.
970 (* Limit on each line *)
971 intro n. clear p. clear x.
972 pose proof (IntegralRepresentationInvariant
973 (fn n) (existT _ (intRepresN n) (fst (restrN n))) (fnInt n)).
974 rewrite <- H2.
975 apply (IntegralCv (intRepresN n)).
976
977 destruct (series_cv_maj
978 (fun n : nat =>
979 I IS _
980 (diagSeqL IS (fun n0 k : nat => IntFn (intRepresN n0) k)
981 (fun n0 k : nat => IntFnL (intRepresN n0) k) n))
982 (fun k : nat =>
983 Iabs _
984 (diagSeqL IS (fun n k0 : nat => IntFn (intRepresN n) k0)
985 (fun n k0 : nat => IntFnL (intRepresN n) k0) k)) s
986 (fun n : nat =>
987 integralAbsMaj _
988 (diagSeqL IS (fun n0 k : nat => IntFn (intRepresN n0) k)
989 (fun n0 k : nat => IntFnL (intRepresN n0) k) n)) H0).
990 setoid_replace x1 with x0. apply p0.
991 apply (series_cv_unique
992 (diagSeq (fun n k : nat => I IS (IntFn (intRepresN n) k) (IntFnL (intRepresN n) k)))).
993 2: apply p0.
994
995 apply (series_cv_eq (fun n : nat => I IS _
996 (diagSeqL IS (fun n0 k : nat => IntFn (intRepresN n0) k)
997 (fun n0 k : nat => IntFnL (intRepresN n0) k) n))).
998 intro n. unfold diagSeq, diagSeqL. destruct (diagPlaneInv n). reflexivity.
999 assumption.
1000 Qed.
1001
1002 (* Now that we have proved the completeness theorem, we can forget
1003 L-functions and use integrable functions everywhere instead. *)
1004
1005
1006 Definition DiscrDeriv {R : ConstructiveReals} (X : Set)
1007 (fn : nat -> @PartialFunction R X) (n : nat)
1008 := match n with
1009 | O => fn O
1010 | S p => Xminus (fn n) (fn p)
1011 end.
1012
1013 Lemma DiscrDerivDomainIncReverse
1014 : forall {R : ConstructiveReals} (X : Set) (fn : nat -> @PartialFunction R X)
1015 (x : X)
1016 (xn : forall n : nat, Domain (DiscrDeriv X fn n) x)
1017 (n : nat),
1018 Domain (fn n) x.
1019 Proof.
1020 intros. pose (xn n). unfold DiscrDeriv in d.
1021 destruct n. exact d.
1022 unfold Xminus, Xplus in d.
1023 exact (fst d).
1024 Qed.
1025
1026 Lemma DiscrDerivApply
1027 : forall {R : ConstructiveReals} (X : Set)
1028 (fn : nat -> @PartialFunction R X)
1029 (x : X)
1030 (pxn : forall n: nat, Domain (DiscrDeriv X fn n) x)
1031 (n : nat)
1032 (px : Domain (fn n) x),
1033 (CRsum (fun k : nat => partialApply (DiscrDeriv X fn k) x (pxn k)) n
1034 == partialApply (fn n) x px).
1035 Proof.
1036 induction n.
1037 - intros. simpl. apply DomainProp.
1038 - intros.
1039 transitivity (CRsum (fun k : nat => partialApply (DiscrDeriv X fn k) x (pxn k)) n
1040 + partialApply (DiscrDeriv X fn (S n)) x (pxn (S n))).
1041 reflexivity.
1042 pose proof (DiscrDerivDomainIncReverse X fn x pxn n) as H.
1043 specialize (IHn H). rewrite IHn. clear IHn.
1044 unfold DiscrDeriv. destruct (pxn (S n)).
1045 rewrite (applyXminus (fn (S n)) (fn n)).
1046 rewrite (DomainProp (fn (S n)) x d px).
1047 rewrite (DomainProp (fn n) x d0 H).
1048 rewrite CRplus_comm. unfold CRminus. rewrite CRplus_assoc, CRplus_opp_l.
1049 rewrite CRplus_0_r. reflexivity.
1050 Qed.
1051
1052 Definition IntegrableDiscrDeriv (IS : IntegrationSpace)
1053 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1054 (fnInt : forall n:nat, IntegrableFunction (fn n))
1055 (n : nat)
1056 : IntegrableFunction (DiscrDeriv (X (ElemFunc IS)) fn n).
1057 Proof.
1058 intros. destruct n. apply fnInt. apply IntegrableMinus; apply fnInt.
1059 Defined.
1060
1061 (* The converse is not true : it is harder for series to converge absolutely. *)
1062 Lemma DiscrDerivInfiniteSum
1063 : forall {R : ConstructiveReals} (X : Set) (fn : nat -> @PartialFunction R X),
1064 PartialRestriction (XinfiniteSumAbs (DiscrDeriv X fn))
1065 (XpointwiseLimit fn).
1066 Proof.
1067 split.
1068 - intros x H. simpl. destruct H as [xn xcv].
1069 exists (DiscrDerivDomainIncReverse X fn x xn).
1070 (* An absolutely convergent series converges without the absolute values. *)
1071 assert (CR_cauchy _
1072 (CRsum
1073 (fun n : nat => CRabs _ (partialApply (DiscrDeriv X fn n) x (xn n))))).
1074 { intro p. specialize (xcv p) as [n nmaj]. exists n.
1075 simpl. exact nmaj. }
1076 clear xcv. apply series_cv_abs in H. destruct H as [l xcv].
1077 apply (Rcv_cauchy_mod _ l).
1078 apply (CR_cv_eq
1079 _ (CRsum (fun n : nat => partialApply (DiscrDeriv X fn n) x (xn n)))).
1080 2: exact xcv. intro n. apply DiscrDerivApply.
1081 - intros. apply applyInfiniteSumAbs.
1082 destruct xG as [xn xcv].
1083 apply (CR_cv_eq _ (fun n : nat => partialApply (fn n) x (xn n))).
1084 intro n. symmetry. apply DiscrDerivApply.
1085 clear xD. simpl.
1086 destruct (CR_complete R (fun n : nat => partialApply (fn n) x (xn n)) xcv).
1087 exact c.
1088 Qed.
1089
1090 Lemma IntegrableXpointwiseLimit
1091 : forall {IS : IntegrationSpace}
1092 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1093 (fnInt : forall n:nat, IntegrableFunction (fn n))
1094 (sumAbsInt : CRcarrier (RealT (ElemFunc IS))),
1095 series_cv (fun n:nat => Integral (IntegrableAbs (IntegrableMinus (fnInt (S n)) (fnInt n))))
1096 sumAbsInt
1097 -> { i : IntegrableFunction (XpointwiseLimit fn)
1098 & CR_cv _ (fun n => Integral (fnInt n)) (Integral i) }.
1099 Proof.
1100 intros.
1101 destruct (IntegrableFunctionsComplete
1102 IS _ (IntegrableDiscrDeriv IS fn fnInt)
1103 (sumAbsInt + Integral (IntegrableAbs (IntegrableDiscrDeriv IS fn fnInt O))))
1104 as [rep repcv].
1105 - apply (series_cv_shift
1106 (fun k : nat => Integral (IntegrableAbs (IntegrableDiscrDeriv IS fn fnInt k)))
1107 O sumAbsInt).
1108 simpl.
1109 apply (series_cv_eq
1110 (fun n : nat => Integral
1111 (IntegrableAbs
1112 (IntegrableMinus (fnInt (S n)) (fnInt n))))).
1113 2: exact H. intro n. apply IntegralExtensional. intros.
1114 apply DomainProp.
1115 - destruct repcv.
1116 assert (PartialRestriction (XinfiniteSumAbs (IntFn rep)) (XpointwiseLimit fn))
1117 as res.
1118 { apply (PartialRestriction_trans _ _ _ _ p).
1119 apply DiscrDerivInfiniteSum. }
1120 exists (IntegrableFunctionExtensional
1121 _ _ res
1122 (existT _ rep (PartialRestriction_refl _ _))).
1123 apply (CR_cv_eq (fun n : nat => Integral (fnInt n))) in s.
1124 + apply (CR_cv_proper _ _ _ s). clear s.
1125 rewrite IntegralRestrict. reflexivity.
1126 + induction n. apply IntegralExtensional.
1127 intros. apply DomainProp. simpl. rewrite IHn. clear IHn.
1128 rewrite <- (CRplus_0_l (Integral (fnInt (S n)))).
1129 rewrite <- (CRplus_opp_r (Integral (fnInt n))), CRplus_assoc.
1130 apply CRplus_morph. reflexivity. rewrite CRplus_comm.
1131 pose proof (IntegralMinus (fn (S n))). unfold CRminus in H0.
1132 rewrite <- H0. clear H0. apply IntegralExtensional.
1133 intros. apply DomainProp.
1134 Qed.
1135
1136
1137 (* Now the famous monotone convergence theorem for integrals.
1138 Unlike the classical Beppo Levi's formulation, this theorem
1139 requires a convergence, to avoid infinite integrals. Also,
1140 constructively the convergence of non-decreasing sequences
1141 is not automatic ; this theorem proves that the restriction
1142 to the domain of convergence does not lose integral mass. *)
1143 Definition IntegralMonotoneConvergence
1144 (IS : IntegrationSpace)
1145 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1146 (fnInt : forall n:nat, IntegrableFunction (fn n))
1147 (a : CRcarrier (RealT (ElemFunc IS)))
1148 : (forall n:nat, partialFuncLe (fn n) (fn (S n)))
1149 -> CR_cv _ (fun n:nat => Integral (fnInt n)) a
1150 -> { limInt : IntegrableFunction (XpointwiseLimit fn)
1151 | Integral limInt == a }.
1152 Proof.
1153 intros.
1154 destruct (IntegrableXpointwiseLimit fn fnInt (a - Integral (fnInt O))).
1155 - apply (CR_cv_eq _ (fun n => Integral (fnInt (S n)) - Integral (fnInt O))).
1156 induction n. simpl. rewrite <- IntegralMinus.
1157 apply IntegralExtensional. intros.
1158 rewrite applyXabs, CRabs_right. apply DomainProp.
1159 destruct xdg. rewrite (applyXminus (fn 1%nat) (fn O)).
1160 rewrite <- (CRplus_opp_r (partialApply (fn O) x d0)).
1161 apply CRplus_le_compat_r. apply H.
1162 simpl. rewrite <- IHn. unfold CRminus. rewrite CRplus_comm.
1163 rewrite (CRplus_comm (Integral (fnInt (S n)))), CRplus_assoc.
1164 apply CRplus_morph. reflexivity.
1165 rewrite <- CRplus_0_l, <- (CRplus_opp_r (Integral (fnInt (S n)))).
1166 rewrite CRplus_assoc. apply CRplus_morph. reflexivity.
1167 rewrite CRplus_comm.
1168 pose proof (IntegralMinus (fn (S (S n)))). unfold CRminus in H1.
1169 rewrite <- H1. apply IntegralExtensional. intros.
1170 rewrite applyXabs, CRabs_right. apply DomainProp.
1171 destruct xdg. rewrite (applyXminus (fn (S (S n))) (fn (S n))).
1172 rewrite <- (CRplus_opp_r (partialApply (fn (S n)) x d0)).
1173 apply CRplus_le_compat_r. apply H.
1174 apply CR_cv_minus. 2: apply CR_cv_const.
1175 apply (CR_cv_shift' _ 1) in H0.
1176 apply (CR_cv_eq _ (fun n : nat => Integral (fnInt (n + 1)%nat))).
1177 2: exact H0. intro n. rewrite Nat.add_comm. reflexivity.
1178 - exists x. exact (CR_cv_unique _ _ _ c H0).
1179 Qed.
1180
1181 Lemma IntegralMonotoneConvergenceDecr
1182 (IS : IntegrationSpace)
1183 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1184 (fnInt : forall n:nat, IntegrableFunction (fn n))
1185 (a : CRcarrier (RealT (ElemFunc IS)))
1186 : (forall n:nat, partialFuncLe (fn (S n)) (fn n))
1187 -> CR_cv _ (fun n:nat => Integral (fnInt n)) a
1188 -> { limInt : IntegrableFunction (XpointwiseLimit fn)
1189 | Integral limInt == a }.
1190 Proof.
1191 intros.
1192 destruct (IntegrableXpointwiseLimit fn fnInt (Integral (fnInt O) - a)).
1193 - apply (CR_cv_eq _ (fun n => Integral (fnInt O) - Integral (fnInt (S n)))).
1194 induction n. simpl. rewrite <- IntegralMinus.
1195 apply IntegralExtensional. intros.
1196 rewrite applyXabs, CRabs_left. simpl.
1197 destruct xdf, xdg. rewrite CRopp_plus_distr.
1198 rewrite <- CRopp_mult_distr_l, <- CRopp_mult_distr_l.
1199 rewrite CRmult_1_l, CRmult_1_l, CRopp_involutive, CRplus_comm.
1200 rewrite (DomainProp _ x d1 d0), (DomainProp _ x d d2). reflexivity.
1201 destruct xdg. rewrite (applyXminus (fn 1%nat) (fn O)).
1202 rewrite <- (CRplus_opp_r (partialApply (fn O) x d0)).
1203 apply CRplus_le_compat_r. apply H.
1204 simpl. rewrite <- IHn. unfold CRminus. rewrite CRplus_assoc.
1205 apply CRplus_morph. reflexivity.
1206 rewrite <- CRplus_0_l, <- (CRplus_opp_l (Integral (fnInt (S n)))).
1207 rewrite CRplus_assoc. apply CRplus_morph. reflexivity.
1208 pose proof (IntegralMinus (fn (S n))). unfold CRminus in H1.
1209 rewrite <- H1. apply IntegralExtensional. intros.
1210 rewrite applyXabs, CRabs_left.
1211 simpl. destruct xdf, xdg. rewrite CRopp_plus_distr.
1212 rewrite <- CRopp_mult_distr_l, <- CRopp_mult_distr_l.
1213 rewrite CRmult_1_l, CRmult_1_l, CRopp_involutive, CRplus_comm.
1214 rewrite (DomainProp _ x d1 d0), (DomainProp _ x d d2). reflexivity.
1215 destruct xdg. rewrite (applyXminus (fn (S (S n))) (fn (S n))).
1216 rewrite <- (CRplus_opp_r (partialApply (fn (S n)) x d0)).
1217 apply CRplus_le_compat_r. apply H.
1218 apply CR_cv_minus. apply CR_cv_const.
1219 apply (CR_cv_shift' _ 1) in H0.
1220 apply (CR_cv_eq _ (fun n : nat => Integral (fnInt (n + 1)%nat))).
1221 2: exact H0. intro n. rewrite Nat.add_comm. reflexivity.
1222 - exists x. exact (CR_cv_unique _ _ _ c H0).
1223 Qed.
1224
1225 Definition IntegralRepresentationShift
1226 {IS : IntegrationSpace}
1227 (fInt : @IntegralRepresentation IS) (n : nat) : @IntegralRepresentation IS.
1228 Proof.
1229 apply (Build_IntegralRepresentation
1230 IS (fun k => IntFn fInt (S n + k))
1231 (fun k => IntFnL fInt (S n + k))
1232 (IntAbsSum fInt - CRsum (fun k => Iabs _ (IntFnL fInt k)) n)).
1233 apply (CR_cv_eq _ (fun i => CRsum (fun k : nat => Iabs _ (IntFnL fInt k)) (S n+i)
1234 - CRsum (fun k : nat => Iabs _ (IntFnL fInt k)) n)).
1235 intros i. rewrite sum_assoc. simpl.
1236 unfold CRminus. rewrite CRplus_comm, <- CRplus_assoc, CRplus_opp_l.
1237 rewrite CRplus_0_l. reflexivity.
1238 apply CR_cv_plus. 2: apply CR_cv_const.
1239 intro p. destruct fInt; unfold CMTIntegrableFunctions.IntFn,
1240 CMTIntegrableFunctions.IntAbsSum,
1241 CMTIntegrableFunctions.IntFnL.
1242 specialize (IntAbsSumCv p) as [j jmaj].
1243 exists j. intros. apply jmaj.
1244 apply (Nat.le_trans _ (0+i) _ H). apply Nat.add_le_mono_r, Nat.le_0_l.
1245 Defined.
1246
1247 Lemma IntegralRepresentationShiftVal
1248 : forall {IS : IntegrationSpace}
1249 (fInt : @IntegralRepresentation IS) (n : nat),
1250 IntegralSeries (IntegralRepresentationShift fInt n)
1251 == IntegralSeries fInt - CRsum (fun k => I IS _ (IntFnL fInt k)) n.
1252 Proof.
1253 intros.
1254 apply (series_cv_unique (fun n0 : nat =>
1255 I IS (IntFn (IntegralRepresentationShift fInt n) n0)
1256 (IntFnL (IntegralRepresentationShift fInt n) n0))).
1257 exact (IntegralCv (IntegralRepresentationShift fInt n)).
1258 simpl.
1259 apply (CR_cv_eq
1260 _ (fun k => CRsum (fun n0 : nat => I IS _ (IntFnL fInt n0)) (S n + k)
1261 - CRsum (fun k : nat => I IS (IntFn fInt k) (IntFnL fInt k)) n)).
1262 intros. rewrite sum_assoc. simpl.
1263 unfold CRminus. rewrite CRplus_comm, <- CRplus_assoc, CRplus_opp_l, CRplus_0_l.
1264 reflexivity.
1265 apply CR_cv_minus. 2: apply CR_cv_const.
1266 intro p.
1267 pose proof (IntegralCv fInt p) as [k kmaj]. exists k.
1268 intros. apply kmaj. apply (Nat.le_trans _ (0+i) _ H).
1269 apply Nat.add_le_mono_r, Nat.le_0_l.
1270 Qed.
1271
1272
1273 (* The integrable functions were defined as pointwise limits of L-functions,
1274 which is already a notion of density. Here we prove that integrable functions
1275 are also limits for the integral distance.
1276 This is corollary 1.17 of Bishop. *)
1277 Lemma IntegralDense : forall {IS : IntegrationSpace}
1278 (f : PartialFunction (X (ElemFunc IS)))
1279 (fInt : IntegrableFunction f),
1280 Un_integral_cv _ f
1281 (IntegrableSum _ (fun n => IntegrableL _ (IntFnL (let (intRepres,_) := fInt in intRepres) n)))
1282 fInt.
1283 Proof.
1284 intros. destruct fInt as [intRepres lim]. intro p.
1285 pose proof (IntAbsSumCv intRepres p) as [n nmaj]. exists n.
1286 intros i H.
1287 apply (CRle_trans
1288 _ (Integral (IntegrableSelf (IntegralRepresentationShift
1289 (IntegralRepresentationAbs intRepres) i)))).
1290 - apply IntegralNonDecreasing.
1291 intros x xdf [xnlim cau]. destruct xdf.
1292 rewrite applyXabs, (applyXminus (Xsum (IntFn intRepres) i) f).
1293 simpl.
1294 assert (forall n0:nat, Domain (IntFn intRepres n0) x) as xdn.
1295 { intro j. destruct (le_lt_dec j i).
1296 exact (domainXsumIncReverse (IntFn intRepres) j i _ d l).
1297 unfold lt in l. simpl in xnlim.
1298 pose proof (xnlim (j - S i)%nat) as H0.
1299 replace (S (i + (j - S i)))%nat with j in H0. exact H0.
1300 symmetry. rewrite Nat.add_comm. rewrite <- Nat.add_succ_r. exact (Nat.sub_add (S i) j l). }
1301 destruct (series_cv_abs
1302 (fun n0 : nat => CRabs _ (partialApply (IntFn intRepres (S (i + n0))) x (xnlim n0)))
1303 cau) as [x0 s].
1304 apply (series_cv_eq
1305 _ (fun n0 => CRabs _ (partialApply (IntFn intRepres (S (i + n0))) x (xdn (S i + n0)%nat)))) in s.
1306 apply (series_cv_shift (fun n0 : nat =>
1307 CRabs _ (partialApply (IntFn intRepres n0) x (xdn n0))) i x0) in s.
1308 rewrite (applyXsum _ _ x _ xdn).
1309 rewrite <- (CRplus_0_r x0),
1310 <- (CRplus_opp_r
1311 (CRsum (fun n0 : nat => CRabs _ (partialApply (IntFn intRepres n0) x (xdn n0))) i)),
1312 <- CRplus_assoc.
1313 apply (series_cv_abs_remainder
1314 (fun n0 : nat => (partialApply (IntFn intRepres n0) x (xdn n0)))
1315 (partialApply f x d0)
1316 (x0 +
1317 CRsum
1318 (fun n0 : nat =>
1319 CRabs _ (partialApply (IntFn intRepres n0) x (xdn n0))) i) i).
1320 2: exact s.
1321 destruct lim.
1322 assert (Domain (XinfiniteSumAbs (IntFn intRepres)) x) as H0.
1323 { exists xdn. apply Rcv_cauchy_mod in s. exact s. }
1324 rewrite <- (c x H0).
1325 apply (series_cv_eq (fun n : nat =>
1326 partialApply (IntFn intRepres n) x
1327 (domainInfiniteSumAbsIncReverse (IntFn intRepres) x H0 n))).
1328 2: apply applyInfiniteSumAbs; reflexivity.
1329 intros. apply DomainProp.
1330 intros. apply CRabs_morph, DomainProp.
1331 - unfold Integral, IntegrableSelf.
1332 rewrite IntegralRepresentationShiftVal.
1333 rewrite IntegralRepresentationAbsVal. simpl.
1334 specialize (nmaj i H). rewrite CRabs_minus_sym in nmaj.
1335 apply (CRle_trans _ _ _ (CRle_abs _) nmaj).
1336 Qed.
1337
1338 Lemma CR_cv_growing : forall {R : ConstructiveReals}
1339 (un : nat -> CRcarrier R) (l : CRcarrier R),
1340 (forall n:nat, un n <= un (S n))
1341 -> (forall n:nat, un n <= l)
1342 -> (forall p : positive, { n : nat | l - un n <= CR_of_Q R (1#p) })
1343 -> CR_cv R un l.
1344 Proof.
1345 intros. intro p.
1346 specialize (H1 p) as [n nmaj]. exists n.
1347 intros. rewrite CRabs_minus_sym, CRabs_right.
1348 apply (CRle_trans _ (l - un n)). apply CRplus_le_compat_l.
1349 apply CRopp_ge_le_contravar.
1350 exact (growing_transit _ H n i H1). exact nmaj.
1351 rewrite <- (CRplus_opp_r (un i)). apply CRplus_le_compat.
1352 apply H0. apply CRle_refl.
1353 Qed.
1354
1355 Lemma IntegralTruncateLimit
1356 : forall {IS : IntegrationSpace}
1357 (f : PartialFunction (X (ElemFunc IS)))
1358 (fInt : IntegrableFunction f),
1359 CR_cv _
1360 (fun n : nat => Integral (IntegrableMinInt f n fInt))
1361 (Integral fInt).
1362 Proof.
1363 (* Fallback to the L-version of this theorem via
1364 the L-representation fn of f. *)
1365 intros IS f fInt. apply CR_cv_growing.
1366 - intro n. apply IntegralNonDecreasing.
1367 intros x xdf xdg.
1368 assert (Domain f x).
1369 { destruct f; exact xdf. }
1370 apply CRmin_glb.
1371 unfold XminConst, Xop, partialApply.
1372 rewrite (DomainProp f x xdf xdg). apply CRmin_l.
1373 apply (CRle_trans _ _ _ (CRmin_r _ _)).
1374 apply CR_of_Q_le.
1375 unfold Qle, Qnum, Qden. do 2 rewrite Z.mul_1_r.
1376 apply Nat2Z.inj_le, le_S, Nat.le_refl.
1377 - intro n. apply IntegralNonDecreasing.
1378 intros x xdf xdg. unfold XminConst, Xop, partialApply.
1379 rewrite (DomainProp f x xdf xdg). apply CRmin_l.
1380 - intro p.
1381 assert ({ g : PartialFunction (X (ElemFunc IS))
1382 & { gL : L (ElemFunc IS) g
1383 | IntegralDistance fInt (IntegrableL g gL) <= CR_of_Q _ (1#3*p) } }).
1384 { pose proof (IntegralDense f fInt (3*p)%positive) as [n nmaj].
1385 specialize (nmaj n (Nat.le_refl n)).
1386 exists (Xsum (IntFn (let (intRepres, _) := fInt in intRepres)) n).
1387 exists (LsumStable _ (IntFnL (let (intRepres, _) := fInt in intRepres)) n).
1388 rewrite IntegralDistance_sym.
1389 apply (CRle_trans _ (IntegralDistance
1390 (IntegrableSum (IntFn (let (intRepres, _) := fInt in intRepres))
1391 (fun n : nat =>
1392 IntegrableL (IntFn (let (intRepres, _) := fInt in intRepres) n)
1393 (IntFnL (let (intRepres, _) := fInt in intRepres) n)) n) fInt)).
1394 2: exact nmaj. clear nmaj.
1395 apply IntegralNonDecreasing. intros x xdf xdg.
1396 rewrite (DomainProp _ _ xdf xdg). apply CRle_refl. }
1397 destruct X as [g [gL gdist]].
1398 pose proof (Ilimit IS g gL) as [glim _].
1399 specialize (glim (3*p)%positive) as [n nmaj]. exists n.
1400 apply (CRle_trans
1401 _ (I IS g gL + CR_of_Q _ (1#3*p)
1402 - Integral (IntegrableMinInt f n fInt))).
1403 apply CRplus_le_compat. 2: apply CRle_refl.
1404 apply (CRplus_le_reg_l (-I IS g gL)).
1405 rewrite <- CRplus_assoc, CRplus_opp_l, CRplus_0_l.
1406 rewrite CRplus_comm.
1407 apply (CRle_trans _ _ _ (CRle_abs _)).
1408 fold (Integral fInt - I IS g gL).
1409 rewrite <- IntegralLstable. rewrite <- IntegralMinus.
1410 exact (CRle_trans _ _ _ (IntegralTriangle _ _) gdist).
1411 apply (CRle_trans _ (I IS g gL + CR_of_Q _ (1 # 3 * p)
1412 - I IS _ (LminIntStable n g gL)
1413 + CR_of_Q _ (1#3*p))).
1414 unfold CRminus. rewrite (CRplus_assoc (I IS g gL + CR_of_Q _ (1 # 3 * p))).
1415 apply CRplus_le_compat. apply CRle_refl.
1416 apply (CRplus_le_reg_l (I IS _ (LminIntStable n g gL))).
1417 rewrite <- CRplus_assoc, CRplus_opp_r, CRplus_0_l.
1418 fold (I IS _ (LminIntStable n g gL)
1419 - Integral (IntegrableMinInt f n fInt)).
1420 rewrite <- IntegralLstable, <- IntegralMinus.
1421 apply (CRle_trans _ _ _ (CRle_abs _)).
1422 apply (CRle_trans _ _ _ (IntegralTriangle _ _)).
1423 apply (CRle_trans _ (IntegralDistance fInt (IntegrableL g gL))).
1424 2: exact gdist. rewrite IntegralDistance_sym.
1425 apply IntegralNonDecreasing. intros x xdf xdg. destruct xdf, xdg.
1426 rewrite applyXabs, applyXabs,
1427 (applyXminus (XminConst g (INR n)) (XminConst f (INR n))),
1428 (applyXminus g f), applyXminConst, applyXminConst.
1429 assert (0 <= @INR (RealT (ElemFunc IS)) n) as nPos.
1430 { apply CR_of_Q_le. unfold Qle, Qnum, Qden.
1431 do 2 rewrite Z.mul_1_r. apply Nat2Z.is_nonneg. }
1432 apply (CRle_trans _ _ _ (CRmin_contract _ _ _)).
1433 rewrite (DomainProp g x d d1).
1434 rewrite (DomainProp f x d0 d2).
1435 apply CRle_refl.
1436 apply (CRle_trans
1437 _ (CR_of_Q _ (1 # 3 * p) + CR_of_Q _ (1 # 3 * p) + CR_of_Q _ (1 # 3 * p))).
1438 apply CRplus_le_compat. 2: apply CRle_refl.
1439 unfold CRminus. rewrite (CRplus_comm (I IS g gL)), CRplus_assoc.
1440 apply CRplus_le_compat_l.
1441 specialize (nmaj n (Nat.le_refl n)). rewrite CRabs_minus_sym in nmaj.
1442 exact (CRle_trans _ _ _ (CRle_abs _) nmaj).
1443 rewrite <- CR_of_Q_plus, <- CR_of_Q_plus. apply CR_of_Q_le.
1444 rewrite Qinv_plus_distr, Qinv_plus_distr.
1445 unfold Qle, Qnum, Qden. rewrite Z.mul_1_l.
1446 rewrite Pos2Z.inj_mul. reflexivity.
1447 Qed.
1448
1449
1450
1451 Lemma Break_lt_3_eps :
1452 forall {R : ConstructiveReals} (a b : CRcarrier R),
1453 a < b
1454 -> { eps : CRcarrier R
1455 & prod (0 < eps) (a + CR_of_Q R 3 * eps < b) }.
1456 Proof.
1457 intros. exists ((b-a) * CR_of_Q R (1#4)). split.
1458 - rewrite <- (CRmult_0_l (CR_of_Q R (1#4))).
1459 apply CRmult_lt_compat_r. apply CR_of_Q_lt. reflexivity.
1460 rewrite <- (CRplus_opp_r a). apply CRplus_lt_compat_r. exact H.
1461 - rewrite (CRmult_comm (b-a)), <- CRmult_assoc, <- CR_of_Q_mult.
1462 apply (CRplus_lt_reg_l _ (-a)). rewrite <- CRplus_assoc.
1463 rewrite CRplus_opp_l, CRplus_0_l, (CRplus_comm (-a)).
1464 rewrite <- (CRmult_1_l (b + - a)).
1465 apply CRmult_lt_compat_r.
1466 rewrite <- (CRplus_opp_r a). apply CRplus_lt_compat_r. exact H.
1467 apply CR_of_Q_lt. reflexivity.
1468 Qed.
1469
1470 Lemma DiagNonNeg
1471 : forall {R : ConstructiveReals} {X : Set}
1472 (fnk : nat -> nat -> @PartialFunction R X),
1473 (forall n k:nat, nonNegFunc (fnk n k))
1474 -> forall n:nat, nonNegFunc (diagSeq fnk n).
1475 Proof.
1476 intros. intros x xdf. unfold diagSeq. unfold diagSeq in xdf.
1477 destruct (diagPlaneInv n). apply H.
1478 Qed.
1479
1480 Lemma applyDiagAbs
1481 : forall {R : ConstructiveReals} {X : Set} (fnk : nat -> nat -> PartialFunction X)
1482 (x : X)
1483 (cpxDdiag : forall k : nat,
1484 Domain
1485 (diagSeq (fun n k0 : nat => Xabs (fnk n k0)) k) x)
1486 (cpxDdiagBis : forall k : nat,
1487 Domain (diagSeq fnk k) x)
1488 (k : nat),
1489 partialApply _ x (cpxDdiag k)
1490 == CRabs R (partialApply _ x (cpxDdiagBis k)).
1491 Proof.
1492 intros. unfold diagSeq.
1493 generalize (cpxDdiag k). intro d. generalize (cpxDdiagBis k). intro d0.
1494 clear cpxDdiagBis cpxDdiag. unfold diagSeq in d, d0.
1495 destruct (diagPlaneInv k).
1496 apply CRabs_morph. apply DomainProp.
1497 Qed.
1498
1499 Definition series_cv_two_lim_lt
1500 {R : ConstructiveReals} (un vn : nat -> CRcarrier R) (a : CRcarrier R) : Set
1501 := { xy : CRcarrier R * CRcarrier R & (series_cv un (fst xy))
1502 * (series_cv vn (snd xy))
1503 * (fst xy + snd xy < a)%ConstructiveReals }%type.
1504
1505 Record CommonPointFunTwoSeq {R : ConstructiveReals} {X : Set}
1506 {f : @PartialFunction R X}
1507 {fn : nat -> @PartialFunction R X}
1508 {gn : nat -> @PartialFunction R X} : Set
1509 := {
1510 cpx2 : X;
1511 cpxF2 : Domain f cpx2;
1512 cpxFn2 : forall n:nat, Domain (fn n) cpx2;
1513 cpxGn2 : forall n:nat, Domain (gn n) cpx2;
1514 }.
1515
1516 (* Icontinuous with 2 approching sequences, instead of 1. *)
1517 Lemma IcontinuousWeave
1518 : forall {IS : IntegrationSpace}
1519 (f : PartialFunction (X (ElemFunc IS)))
1520 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1521 (gn : nat -> PartialFunction (X (ElemFunc IS)))
1522 (fL : (L (ElemFunc IS)) f)
1523 (fnL : forall n:nat, (L (ElemFunc IS)) (fn n))
1524 (gnL : forall n:nat, (L (ElemFunc IS)) (gn n)),
1525 (forall n:nat, nonNegFunc (fn n))
1526 -> (forall n:nat, nonNegFunc (gn n))
1527 -> series_cv_two_lim_lt (fun n => I IS (fn n) (fnL n))
1528 (fun n => I IS (gn n) (gnL n))
1529 (I IS f fL)
1530 -> { x : @CommonPointFunTwoSeq _ _ f fn gn
1531 & series_cv_two_lim_lt (fun n => partialApply (fn n) _ (cpxFn2 x n))
1532 (fun n => partialApply (gn n) _ (cpxGn2 x n))
1533 (partialApply f _ (cpxF2 x)) }.
1534 Proof.
1535 intros.
1536 assert (forall n:nat, L (ElemFunc IS) (weaveSequences _ fn gn n)) as wL.
1537 { apply weaveSequencesL; assumption. }
1538 destruct (Icontinuous IS f
1539 (weaveSequences _ fn gn)
1540 fL wL).
1541 - intro n. unfold weaveSequences.
1542 destruct (Nat.even n). apply H. apply H0.
1543 - destruct H1, x. simpl in p. destruct p, p.
1544 exists (c+c0). split. 2: exact c1.
1545 apply (series_cv_eq
1546 (weaveSequences _
1547 (fun n => I IS (fn n) (fnL n))
1548 (fun n => I IS (gn n) (gnL n)))).
1549 intro n. unfold weaveSequences.
1550 generalize (wL n). intros. unfold weaveSequences in l.
1551 destruct (Nat.even n).
1552 apply IExtensional. intros. apply DomainProp.
1553 apply IExtensional. intros. apply DomainProp.
1554 apply weaveInfiniteSums; assumption.
1555 - destruct x; simpl in s. destruct s, p.
1556 assert (forall k:nat, Domain (fn k) cpx) as cpxDf.
1557 { intro k. exact (domainWeaveEvenInc _ _ _ k cpx (cpxFn (k*2)%nat)). }
1558 assert (forall k:nat, Domain (gn k) cpx) as cpxDg.
1559 { intro k. exact (domainWeaveOddInc _ _ _ k cpx (cpxFn (1+k*2)%nat)). }
1560 apply (series_cv_eq
1561 _ (weaveSequences
1562 _
1563 (fun n => partialApply _ cpx (cpxDf n))
1564 (fun n => partialApply _ cpx (cpxDg n))))
1565 in s.
1566
1567 assert ({ l : CRcarrier _
1568 & series_cv (fun n => partialApply _ cpx (cpxDg n)) l}).
1569 { apply (halfWeavedSumOdd
1570 (fun n => partialApply _ cpx (cpxDf n)) _ x).
1571 intro k. apply H.
1572 intro k. apply H0. exact s. }
1573 destruct H2.
1574 assert ({ l : CRcarrier _
1575 & series_cv (fun k => partialApply _ cpx (cpxDf k)) l}).
1576 { apply (halfWeavedSumEven
1577 _ (fun k => partialApply _ cpx (cpxDg k)) x).
1578 intro k. apply H.
1579 intro k. apply H0. exact s. }
1580 destruct H2.
1581 exists (Build_CommonPointFunTwoSeq _
1582 _ _ _ _ cpx cpxF cpxDf cpxDg). simpl.
1583 exists (x1,x0). split. split. exact s1. exact s0. simpl.
1584 setoid_replace (x1+x0) with x. exact c.
1585 apply (series_cv_unique
1586 (weaveSequences _ (fun n : nat => partialApply (fn n) cpx (cpxDf n))
1587 (fun n : nat => partialApply (gn n) cpx (cpxDg n)))).
1588 2: exact s.
1589 apply weaveInfiniteSums; assumption.
1590 intro k.
1591 rewrite (partialApplyWeave
1592 _ fn gn
1593 k cpx (cpxDf (k/2)%nat) (cpxDg (k/2)%nat) (cpxFn k)).
1594 unfold weaveSequences. destruct (Nat.even k); reflexivity.
1595 Qed.
1596
1597 Lemma series_cv_remainder_cv
1598 : forall {R : ConstructiveReals} (un : nat -> CRcarrier R) (l eps : CRcarrier R),
1599 series_cv un l
1600 -> 0 < eps
1601 -> { k : nat & forall i:nat, le k i -> series_cv_lim_lt (fun n => un (n + i)%nat) eps }.
1602 Proof.
1603 intros.
1604 destruct (Un_cv_nat_real (CRsum un) l H eps H0) as [k kmaj].
1605 exists (S k). intros.
1606 pose proof (series_cv_shift' un l i H).
1607 destruct i. exfalso; inversion H1.
1608 exists (l - CRsum un i). split. exact H2.
1609 apply le_S_n in H1. specialize (kmaj i H1).
1610 rewrite CRabs_minus_sym in kmaj.
1611 exact (CRle_lt_trans _ _ _ (CRle_abs _) kmaj).
1612 Qed.
1613
1614 (* The completed space of integrable function is an integration space. *)
1615 Lemma IntegrableContinuous
1616 : forall {IS : IntegrationSpace}
1617 (h : PartialFunction (X (ElemFunc IS)))
1618 (hn : nat -> PartialFunction (X (ElemFunc IS)))
1619 (hL : IntegrableFunction h)
1620 (hnL : forall n:nat, IntegrableFunction (hn n)),
1621 (forall n:nat, nonNegFunc (hn n))
1622 -> series_cv_lim_lt (fun n => Integral (hnL n)) (Integral hL)
1623 -> { x : CommonPointFunSeq _ h hn
1624 & series_cv_lim_lt (fun n => partialApply (hn n) _ (cpxFn _ _ _ x n))
1625 (partialApply h _ (cpxF _ _ _ x)) }.
1626 Proof.
1627 intros. destruct H0, p.
1628 destruct (Break_lt_3_eps _ _ c) as [eps [epsPos epsMaj]].
1629 assert (forall n:nat, 0 < eps * CR_of_Q _ (1#2) * CRpow (CR_of_Q _ (1#2)) n).
1630 { intro n. rewrite <- (CRmult_0_r eps).
1631 rewrite CRmult_assoc.
1632 apply CRmult_lt_compat_l. exact epsPos.
1633 rewrite <- (CRmult_0_r (CR_of_Q _ (1#2))).
1634 apply CRmult_lt_compat_l. apply CR_of_Q_lt. reflexivity.
1635 apply CRpow_gt_zero. apply CR_of_Q_lt. reflexivity. }
1636 pose (fun n => IntFn (let (r,_)
1637 := AbsRepresentation
1638 IS (hn n) (eps*CR_of_Q _ (1#2)*CRpow (CR_of_Q _ (1#2)) n)
1639 (hnL n) (H0 n) in r))
1640 as phink.
1641 pose ( fun n k : nat =>
1642 let s1 :=
1643 AbsRepresentation IS (hn n) (eps * CR_of_Q _ (1#2) * CRpow (CR_of_Q _ (1 # 2)) n)
1644 (hnL n) (H0 n) in
1645 let (x0, _) as s2 return (L (ElemFunc IS) (IntFn (let (r, _) := s2 in r) k)) :=
1646 s1 in
1647 let X := IntFnL x0 in X k) as phinkL.
1648 assert (forall n:nat, { l : CRcarrier _
1649 & (series_cv (fun k => I IS (Xabs (phink n k))
1650 (LabsStable _ _ (phinkL n k))) l)
1651 * (l <= Integral (hnL n) + eps * CR_of_Q _ (1#2)* CRpow (CR_of_Q _ (1#2)) n)%ConstructiveReals }%type)
1652 as phinkAbsCv.
1653 { intro n. unfold phink, phinkL.
1654 destruct (AbsRepresentation IS (hn n) (eps * CR_of_Q _ (1#2) * CRpow (CR_of_Q _ (1 # 2)) n)
1655 (hnL n) (H0 n)).
1656 exists (IntAbsSum x0). split. exact (IntAbsSumCv x0). destruct p.
1657 setoid_replace (Integral (hnL n))
1658 with (Integral (IntegrableAbs (hnL n))). exact c0.
1659 apply IntegralExtensional. intros. simpl.
1660 rewrite CRabs_right. apply DomainProp. apply H. }
1661 assert (forall n:nat, PartialRestriction (XinfiniteSumAbs (phink n)) (hn n)) as phinkRes.
1662 { intros n. unfold phink.
1663 destruct (AbsRepresentation
1664 IS (hn n) (eps * CR_of_Q _ (1#2)*CRpow (CR_of_Q _ (1 # 2)) n) (hnL n) (H0 n)).
1665 apply p. }
1666 destruct hL as [x0 psiRes], x0 as [psik psikL IntAbsSum IntAbsSumCv].
1667 unfold Integral in epsMaj, c. unfold IntFn in psiRes.
1668 assert (CR_cv _ (fun K => I IS (Xsum psik K) (LsumStable psik psikL K))
1669 (IntegralSeries {|
1670 IntFn := psik;
1671 IntFnL := psikL;
1672 IntAbsSum := IntAbsSum;
1673 IntAbsSumCv := IntAbsSumCv |})) as psiInt.
1674 { apply (CR_cv_eq _ (CRsum (fun K => I IS (psik K) (psikL K)))).
1675 intro n. rewrite IadditiveIterate. reflexivity.
1676 unfold IntegralSeries.
1677 destruct (
1678 series_cv_maj (fun n : nat => I IS (psik n) (psikL n))
1679 (fun k : nat => Iabs (psik k) (psikL k)) IntAbsSum
1680 (fun n : nat => integralAbsMaj (psik n) (psikL n)) IntAbsSumCv).
1681 destruct p. exact s0. }
1682 assert ({K : nat & prod (IntegralSeries {|
1683 IntFn := psik;
1684 IntFnL := psikL;
1685 IntAbsSum := IntAbsSum;
1686 IntAbsSumCv := IntAbsSumCv |}
1687 < I IS (Xsum psik K) (LsumStable psik psikL K) + eps)
1688 (series_cv_lim_lt (fun k => I IS (Xabs (psik (k+S K)%nat))
1689 (LabsStable _ _ (psikL _)))
1690 eps) }).
1691 { pose proof (Un_cv_nat_real _ _ psiInt eps epsPos) as [i imaj].
1692 destruct (series_cv_remainder_cv
1693 _ _ eps IntAbsSumCv epsPos) as [j jmaj].
1694 exists (max i j). split.
1695 specialize (imaj (max i j) (Nat.le_max_l _ _)).
1696 rewrite CRabs_minus_sym in imaj.
1697 apply (CRplus_lt_reg_l _
1698 (- I IS (Xsum psik (Init.Nat.max i j)) (LsumStable psik psikL (Init.Nat.max i j)))).
1699 rewrite <- CRplus_assoc, CRplus_opp_l, CRplus_0_l, CRplus_comm.
1700 apply (CRle_lt_trans _ _ _ (CRle_abs _)). exact imaj.
1701 apply jmaj. apply le_S, Nat.le_max_r. }
1702 destruct H1 as [K kmaj].
1703 assert (forall n:nat, L (ElemFunc IS) (diagSeq (fun n k => Xabs (phink n k)) n)) as L1.
1704 { apply diagSeqL. intros n k. apply LabsStable. apply phinkL. }
1705 assert (forall k:nat, L (ElemFunc IS) (Xabs (psik (k+S K)%nat))) as L2.
1706 { intro k. apply LabsStable. apply psikL. }
1707 destruct (IcontinuousWeave
1708 (Xsum psik K)
1709 (diagSeq (fun n k => Xabs (phink n k)))
1710 (fun k => Xabs (psik (k+S K)%nat))
1711 (LsumStable psik psikL K) L1 L2)
1712 as [x0 xcv].
1713 - intro n.
1714 unfold diagSeq. destruct (diagPlaneInv n).
1715 intros y ydf. apply CRabs_pos.
1716 - intros n y ydf. apply CRabs_pos.
1717 - destruct kmaj, s0, p.
1718 destruct (series_cv_maj
1719 (fun n => let (l,_):=phinkAbsCv n in l)
1720 (fun n => Integral (hnL n) + eps * CR_of_Q _ (1#2) * CRpow (CR_of_Q _ (1 # 2)) n)
1721 (x + eps)).
1722 intro n. destruct (phinkAbsCv n). simpl. destruct p.
1723 rewrite CRabs_right. exact c2.
1724 apply (series_cv_nonneg
1725 (fun k : nat => I IS (Xabs (phink n k))
1726 (LabsStable _ _ (phinkL n k)))).
1727 intros. apply integralPositive. intros y ydf. apply CRabs_pos.
1728 exact s1. apply series_cv_plus. exact s.
1729 apply (series_cv_eq
1730 (fun n : nat => CRpow (CR_of_Q _ (1 # 2)) n * (eps*CR_of_Q _ (1#2)))).
1731 intro n. apply CRmult_comm.
1732 apply (CR_cv_proper _ (CR_of_Q _ 2*(eps*CR_of_Q _ (1#2)))).
1733 apply series_cv_scale. apply GeoHalfTwo.
1734 rewrite CRmult_comm, CRmult_assoc, <- CR_of_Q_mult.
1735 setoid_replace ((1#2) * 2)%Q with 1%Q. rewrite CRmult_1_r.
1736 reflexivity. reflexivity. destruct p.
1737 exists (x1, x0). unfold fst, snd. split. split.
1738 apply (series_cv_eq
1739 (diagSeq (fun n k : nat => I IS (Xabs (phink n k))
1740 (LabsStable _ _ (phinkL n k))))).
1741 intro n. unfold diagSeq. generalize (L1 n). intros.
1742 unfold diagSeq in l. destruct (diagPlaneInv n).
1743 apply IExtensional. intros. apply DomainProp.
1744 apply (DiagSeqInfiniteSumColPos
1745 _ (fun n : nat => let (l, _) := phinkAbsCv n in l)).
1746 intros n k. apply integralPositive. intros y ydf. apply CRabs_pos.
1747 intro n. destruct (phinkAbsCv n). apply p.
1748 exact s1.
1749 apply (series_cv_eq
1750 (fun k : nat =>
1751 I IS (Xabs (psik (k + S K)%nat))
1752 (LabsStable (ElemFunc IS) (psik (k + S K)%nat) (psikL (k + S K)%nat)))).
1753 intro n. apply IExtensional. intros. apply DomainProp.
1754 exact s0.
1755 apply (CRplus_le_compat_l (eps+eps)) in c2.
1756 do 2 rewrite (CRplus_comm (eps+eps)) in c2.
1757 rewrite CRplus_assoc in c2.
1758 setoid_replace (eps + (eps+eps)) with (CR_of_Q _ 3 * eps) in c2.
1759 pose proof (CRle_lt_trans _ _ _ c2 epsMaj). clear c2.
1760 pose proof (CRlt_trans _ _ _ H1 c0). clear H1.
1761 rewrite <- CRplus_assoc in H2. apply CRplus_lt_reg_r in H2.
1762 apply (CRlt_trans _ (x1 + eps)).
1763 apply CRplus_lt_compat_l. exact c1. exact H2.
1764 setoid_replace (CR_of_Q (RealT (ElemFunc IS)) 3)
1765 with (1+1+CR_of_Q (RealT (ElemFunc IS)) 1).
1766 do 2 rewrite CRmult_plus_distr_r. rewrite CRmult_1_l, CRplus_assoc.
1767 reflexivity.
1768 do 2 rewrite <- CR_of_Q_plus. reflexivity.
1769 - destruct x0 as [cpx cpxF cpxFn cpxGn].
1770 simpl in xcv. destruct xcv, p, x0. simpl in p. destruct p.
1771 simpl in c0.
1772 (* Prove that cpx is in Domain h,
1773 because it is in Domain (XinfinitesumAbs psik) *)
1774 assert (forall k:nat, Domain (psik k) cpx) as cpxDpsik.
1775 { intro k. destruct (le_lt_dec k K).
1776 apply (domainXsumIncReverse _ _ K). exact cpxF. exact l.
1777 rewrite <- (Nat.sub_add (S K) k).
1778 apply cpxGn. exact l. }
1779 assert (forall k:nat, Domain (diagSeq phink k) cpx) as cpxDdiagBis.
1780 { intro k. unfold diagSeq. destruct (diagPlaneInv k).
1781 apply (diagSeqDomain _ (fun n k => Xabs (phink n k)) _ cpxFn). }
1782
1783 assert (Domain (XinfiniteSumAbs psik) cpx).
1784 { exists cpxDpsik.
1785 apply (Rcv_cauchy_mod
1786 _ (c2 + CRsum (fun k => partialApply
1787 (Xabs (psik k)) cpx (cpxDpsik k)) K)).
1788 apply series_cv_shift.
1789 apply (series_cv_eq
1790 (fun n : nat => CRabs _ (partialApply (psik (n + S K)%nat) cpx (cpxGn n)))).
1791 intros. apply CRabs_morph.
1792 rewrite (Nat.add_comm (S K)). apply DomainProp. exact s1. }
1793 assert (forall n:nat, Domain (XinfiniteSumAbs (phink n)) cpx).
1794 { intro n.
1795 apply (domainInfiniteSumAbsDiag
1796 _ (fun n0 k : nat => phink n0 k) n).
1797 exists cpxDdiagBis. apply (Rcv_cauchy_mod _ c1).
1798 apply (series_cv_eq
1799 (fun n : nat =>
1800 partialApply
1801 (diagSeq
1802 (fun n0 k : nat => Xabs (phink n0 k)) n) cpx
1803 (cpxFn n))).
1804 2: exact s0. apply applyDiagAbs. }
1805 assert (forall n:nat, Domain (hn n) cpx) as cpxDhn.
1806 { intro n. apply phinkRes. apply H2. }
1807 destruct psiRes.
1808 exists (Build_CommonPointFunSeq _ _ _ _ cpx (d _ H1) cpxDhn).
1809 simpl.
1810 assert ({ l : CRcarrier _
1811 & prod (series_cv (fun n => partialApply _ cpx (cpxDhn n)) l)
1812 (l <= c1) }).
1813 { destruct (DiagSeqInfiniteSum
1814 (fun n k => partialApply (phink n k) cpx
1815 (diagSeqDomain _ phink cpx cpxDdiagBis n k))
1816 (fun n => partialApply (hn n) cpx (cpxDhn n)) c1).
1817 apply (series_cv_eq
1818 (fun n : nat =>
1819 partialApply
1820 (diagSeq (fun n0 k : nat => Xabs (phink n0 k)) n) cpx
1821 (cpxFn n))).
1822 intro n. rewrite (applyDiagAbs phink cpx cpxFn cpxDdiagBis).
1823 unfold diagSeq. generalize (cpxDdiagBis n).
1824 intros. unfold diagSeq in d0. destruct (diagPlaneInv n).
1825 apply CRabs_morph. apply DomainProp.
1826 exact s0. intro n.
1827 apply (series_cv_eq
1828 (fun k => partialApply (phink n k) cpx
1829 (domainInfiniteSumAbsIncReverse
1830 (phink n) cpx (H2 n) k))).
1831 intro i. apply DomainProp. apply applyInfiniteSumAbs.
1832 apply phinkRes.
1833 exists x0. split; apply p. }
1834 destruct H3, p.
1835 assert ({ l : CRcarrier _
1836 & prod (series_cv (fun n => partialApply _ cpx (cpxDpsik (n+S K)%nat)) l)
1837 (CRabs _ l <= c2) }).
1838 { destruct (series_cv_abs
1839 (fun n => partialApply _ cpx (cpxDpsik (n+S K)%nat))).
1840 apply (Rcv_cauchy_mod _ c2).
1841 apply (series_cv_eq
1842 (fun n : nat => CRabs _ (partialApply (psik (n + S K)%nat) cpx (cpxGn n)))).
1843 intro n. apply CRabs_morph. apply DomainProp.
1844 exact s1.
1845 exists x1. split. exact s3.
1846 apply (series_cv_triangle
1847 (fun n => partialApply _ cpx (cpxDpsik (n+S K)%nat))).
1848 exact s3.
1849 apply (series_cv_eq
1850 (fun n : nat => CRabs _ (partialApply (psik (n + S K)%nat) cpx (cpxGn n)))).
1851 intro n. apply CRabs_morph. apply DomainProp. exact s1. }
1852 destruct H3.
1853 assert (x0 - x1 < partialApply (Xsum psik K) cpx cpxF).
1854 { apply (CRle_lt_trans _ (c1 + c2)).
1855 2: exact c0. apply CRplus_le_compat. exact c4.
1856 apply (CRle_trans _ (CRabs _ x1)).
1857 rewrite <- CRabs_opp. apply CRle_abs. apply p. }
1858 destruct p.
1859 clear c1 s0 c0 c4. clear c2 s1 c5.
1860 apply (CRplus_lt_compat_r x1) in H3.
1861 unfold CRminus in H3.
1862 rewrite CRplus_assoc, CRplus_opp_l, CRplus_0_r in H3.
1863 exists x0. split. exact s2.
1864 rewrite (applyXsum _ K cpx _ cpxDpsik), CRplus_comm in H3.
1865 rewrite <- (c3 cpx H1).
1866 setoid_replace (partialApply (XinfiniteSumAbs psik) cpx H1)
1867 with (x1 + CRsum (fun k : nat => partialApply (psik k) cpx (cpxDpsik k)) K).
1868 exact H3. apply applyInfiniteSumAbs.
1869 apply (series_cv_eq (fun n : nat => partialApply (psik n) cpx (cpxDpsik n))).
1870 intro n. apply DomainProp.
1871 apply series_cv_shift.
1872 apply (series_cv_eq (fun n : nat =>
1873 partialApply (psik (n + S K)%nat) cpx (cpxDpsik (n + S K)%nat))).
1874 intro n. rewrite Nat.add_comm. reflexivity.
1875 exact s3.
1876 Qed.
1877
1878 Lemma IntegralTruncateLimitZero
1879 : forall {IS : IntegrationSpace}
1880 (f : PartialFunction (X (ElemFunc IS)))
1881 (fInt : IntegrableFunction f),
1882 CR_cv _
1883 (fun n : nat =>
1884 Integral
1885 (IntegrableMinConst
1886 (Xabs f) (CR_of_Q _ (1 # Pos.of_nat (S n)))
1887 (IntegrableAbs fInt) (invSuccRealPositive n))) 0.
1888 Proof.
1889 intros. intro p. destruct (IntegralDense f fInt (2*p)%positive) as [n nmaj].
1890 destruct (Ilimit IS (Xsum (IntFn (let (intRepres, _) := fInt in intRepres)) n)
1891 (LsumStable
1892 (IntFn (let (intRepres, _) := fInt in intRepres))
1893 (IntFnL (let (intRepres, _) := fInt in intRepres)) n))
1894 as [_ cv].
1895 specialize (cv (2*p)%positive) as [k kmaj].
1896 exists (max n k). intros. unfold CRminus.
1897 rewrite CRopp_0, CRplus_0_r, CRabs_right.
1898 apply (CRle_trans _ (Integral
1899 (IntegrableMinConst (Xabs f)
1900 (CR_of_Q (RealT (ElemFunc IS)) (1 # Pos.of_nat (S (max n k))))
1901 (IntegrableAbs fInt) (invSuccRealPositive (max n k))))).
1902 - apply IntegralNonDecreasing. intros y ydf ydg.
1903 apply CRmin_glb. rewrite applyXminConst, (DomainProp _ y ydf ydg).
1904 apply CRmin_l.
1905 apply (CRle_trans _ (CR_of_Q _ (1 # Pos.of_nat (S i)))).
1906 apply CRmin_r. apply CR_of_Q_le. unfold Qle, Qnum, Qden.
1907 do 2 rewrite Z.mul_1_l. apply Pos2Z.pos_le_pos.
1908 apply Pos2Nat.inj_le. rewrite Nat2Pos.id, Nat2Pos.id.
1909 apply le_n_S, H. discriminate. discriminate.
1910 - clear H i.
1911 specialize (nmaj n (Nat.le_refl n)).
1912 specialize (kmaj (max n k) (Nat.le_max_r _ _)).
1913 unfold IntegralDistance in nmaj.
1914 rewrite <- CRplus_0_r.
1915 rewrite <- (CRplus_opp_l
1916 (CRabs (RealT (ElemFunc IS))
1917 (I IS _
1918 (LminConstStable
1919 (CR_of_Q (RealT (ElemFunc IS))
1920 (1 # Pos.of_nat (S (Init.Nat.max n k))))
1921 (Xabs (Xsum (IntFn (let (intRepres, _) := fInt in intRepres)) n))
1922 (invSuccRealPositive (Init.Nat.max n k))
1923 (LabsStable (ElemFunc IS)
1924 (Xsum (IntFn (let (intRepres, _) := fInt in intRepres)) n)
1925 (LsumStable (IntFn (let (intRepres, _) := fInt in intRepres))
1926 (IntFnL (let (intRepres, _) := fInt in intRepres)) n))) - 0))).
1927 rewrite <- CRplus_assoc.
1928 setoid_replace (CR_of_Q (RealT (ElemFunc IS)) (1 # p))
1929 with (CR_of_Q (RealT (ElemFunc IS)) (1 # (2*p)) + CR_of_Q _ (1 # (2*p))).
1930 apply CRplus_le_compat. 2: exact kmaj. clear kmaj.
1931 unfold CRminus. rewrite CRopp_0, CRplus_0_r, CRabs_right.
1932 rewrite <- IntegralLstable. pose proof (@IntegralMinus IS).
1933 unfold CRminus in H. rewrite <- H. clear H.
1934 refine (CRle_trans _ _ _ _ nmaj). clear nmaj.
1935 apply IntegralNonDecreasing.
1936 intros y ydf ydg. destruct ydf, ydg.
1937 rewrite applyXabs. rewrite (applyXminus _ f y d1 d2), CRabs_minus_sym.
1938 rewrite (applyXminus _ (XminConst (Xabs (Xsum (IntFn (let (intRepres, _) := fInt in intRepres)) n))
1939 (CR_of_Q (RealT (ElemFunc IS)) (1 # Pos.of_nat (S (Init.Nat.max n k))))) y d d0).
1940 rewrite applyXminConst, applyXminConst.
1941 apply (CRle_trans _ _ _ (CRle_abs _)).
1942 apply (CRle_trans _ _ _ (CRmin_contract _ _ _)).
1943 rewrite (DomainProp f y d2 d), applyXabs.
1944 rewrite (DomainProp _ y d1 d0), applyXabs.
1945 apply CRabs_triang_inv2.
1946 apply integralPositive. intros y ydf. apply CRmin_glb.
1947 apply CRabs_pos. apply CR_of_Q_le. discriminate.
1948 rewrite <- CR_of_Q_plus. apply CR_of_Q_morph. rewrite Qinv_plus_distr.
1949 reflexivity.
1950 - apply IntegralNonNeg. intros y ydf. apply CRmin_glb.
1951 apply CRabs_pos. apply CR_of_Q_le. discriminate.
1952 Qed.
1953
1954 (* Theorem 1.18 of Bishop *)
1955 Definition IntegrationSpaceCompletion (IS : IntegrationSpace)
1956 : IntegrationSpace
1957 := Build_IntegrationSpace
1958 (FunctionRieszSpaceCompletion IS)
1959 (fun f fInt => Integral fInt)
1960 IntegralPlus
1961 (fun a f fInt => CReq_trans _ ((Integral fInt) * a) _
1962 (IntegralScale f fInt a) (CRmult_comm _ _))
1963 (Ione IS) (IntegrableL (Ione IS) (IoneL IS))
1964 (CReq_trans _ (I IS (Ione IS) (IoneL IS)) _
1965 (IntegralLstable _ _) (IoneInt IS))
1966 IntegrableContinuous
1967 (fun f fL => pair (IntegralTruncateLimit f fL)
1968 (IntegralTruncateLimitZero f fL)).
1969
1970 (* There is no need to consider integrable functions on
1971 IntegrationSpaceCompletion, it is only its L functions. *)
1972 Lemma IntegrationSpaceComplete
1973 : forall (IS : IntegrationSpace) (f : PartialFunction (X (ElemFunc IS))),
1974 @IntegrableFunction (IntegrationSpaceCompletion IS) f
1975 -> L (ElemFunc (IntegrationSpaceCompletion IS)) f.
1976 Proof.
1977 intros IS f fInt. simpl. destruct fInt, x.
1978 destruct (IntegrableFunctionsComplete IS IntFn IntFnL IntAbsSum IntAbsSumCv).
1979 exists x. destruct x. simpl. simpl in p0.
1980 apply (PartialRestriction_trans _ _ (XinfiniteSumAbs IntFn)).
1981 apply p0. exact p.
1982 Qed.