Debian Codegraph @

reals/stdlib/CMTIntegrableFunctions.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
13 (* We complete an integration space IS by countable limits of L-functions.
14 Those limit functions are called integrable functions and the integral I
15 extends to them. Hence we obtain a bigger integration space IScomplete,
16 which L-functions are the integrable functions of IS.
17
18 IScomplete is complete, in the sense that its integrable functions are
19 already integrable functions of IS : no new functions are added. *)
20
21 From Coq Require Import ZArith.
22 From Coq Require Import QArith.
23 From Coq Require Import ConstructiveReals.
24 From Coq Require Import ConstructiveAbs.
25 From Coq Require Import ConstructiveMinMax.
26 From Coq Require Import ConstructiveSum.
27 From Coq Require Import ConstructiveLimits.
28 Require Import ConstructivePartialFunctions.
29 Require Import CMTbase.
30
31 Local Open Scope ConstructiveReals.
32
33
34 (* A function f is integrable iif it is the pointwise limit
35 almost everywhere of a sequence of L-functions, which integrals converge.
36 Keep the convergence proof in sort Prop at the moment, so that
37 it is unique. *)
38
39 (* A series of elementary integrals, that converges absolutely. *)
40 Record IntegralRepresentation {IS : IntegrationSpace} : Type
41 := {
42 IntFn : nat -> PartialFunction (X (ElemFunc IS));
43 IntFnL : forall n:nat, L (ElemFunc IS) (IntFn n);
44 IntAbsSum : CRcarrier (RealT (ElemFunc IS));
45 (* Convergence with computable modulus, we want to extract it. *)
46 IntAbsSumCv : series_cv (fun k:nat => Iabs (IntFn k) (IntFnL k)) IntAbsSum
47 }.
48
49 (* A function f is integrable when it is the limit almost everywhere of
50 the L-series fn. Here "almost everywhere" is encoded as where
51 the series fn converges absolutely. It is equivalent to Daniell's
52 definition of null sets. *)
53
54 Lemma IntAbsSumPos : forall {IS : IntegrationSpace}
55 (fInt : @IntegralRepresentation IS),
56 0 <= IntAbsSum fInt.
57 Proof.
58 intros. destruct fInt; simpl.
59 apply (series_cv_nonneg ((fun k : nat => Iabs (IntFn0 k) (IntFnL0 k)))).
60 intros. apply integralPositive. intros. intros x xdf.
61 rewrite applyXabs.
62 apply CRabs_pos. assumption.
63 Qed.
64
65 Lemma represApply : forall {IS : IntegrationSpace}
66 (f : PartialFunction (X (ElemFunc IS)))
67 (fInt : IntegralRepresentation)
68 (isFInt : PartialRestriction (XinfiniteSumAbs (IntFn fInt)) f)
69 (x : X (ElemFunc IS))
70 (xS : Domain (XinfiniteSumAbs (IntFn fInt)) x)
71 (y : Domain f x),
72 series_cv
73 (fun n : nat => partialApply (IntFn fInt n) x
74 (domainInfiniteSumAbsIncReverse
75 (IntFn fInt) x xS n))
76 (partialApply f x y).
77 Proof.
78 intros. destruct isFInt as [i appX].
79 specialize (appX x xS y).
80 apply (CR_cv_proper _ (partialApply (XinfiniteSumAbs (IntFn fInt)) x xS)).
81 2: exact appX. clear appX.
82 simpl. destruct xS; simpl.
83 destruct (series_cv_abs (fun n : nat => partialApply (IntFn fInt n) x (x0 n))).
84 exact s.
85 Qed.
86
87 Definition IntegrableFunction {IS : IntegrationSpace}
88 (f : PartialFunction (X (ElemFunc IS))) : Type
89 := { fInt : IntegralRepresentation
90 & PartialRestriction (XinfiniteSumAbs (IntFn fInt)) f }.
91
92 (* As proven by INonDecreasing, L-functions on X are defined
93 almost everywhere on X. So the previous definition can be
94 summarized : the infinite sum of fn converges almost everywhere to f
95 and the integral of f is the infinite sum of the integrals of fn. *)
96
97 Definition IntegrableFunctionExtensional
98 {IS : IntegrationSpace}
99 (f g : PartialFunction (X (ElemFunc IS)))
100 : PartialRestriction f g
101 -> IntegrableFunction f
102 -> IntegrableFunction g.
103 Proof.
104 intros [inj restr] [rep [injF isrep]]. exists rep.
105 split.
106 - exact (fun x xS => inj x (injF x xS)).
107 - intros. rewrite (isrep x _ (injF x xD)).
108 apply restr.
109 Defined.
110
111 (* This will be redefined shortly after as the integral of
112 XinfiniteSumAbs (IntFn fInt).
113 This definition is rarely used directly. *)
114 Definition IntegralSeries {IS : IntegrationSpace}
115 (fInt : @IntegralRepresentation IS) : CRcarrier (RealT (ElemFunc IS)).
116 Proof.
117 destruct fInt; simpl.
118 destruct (series_cv_maj (fun n : nat => I IS (IntFn0 n) (IntFnL0 n))
119 (fun k : nat => Iabs (IntFn0 k) (IntFnL0 k)) IntAbsSum0).
120 intro n. apply integralAbsMaj.
121 assumption. exact x.
122 Defined.
123
124 Definition Integral {IS : IntegrationSpace}
125 {f : PartialFunction (X (ElemFunc IS))}
126 (fInt : IntegrableFunction f)
127 := IntegralSeries (let (i,_) := fInt in i).
128
129 Definition IntegralCv {IS : IntegrationSpace}
130 (fInt : IntegralRepresentation)
131 : series_cv (fun n : nat => (I IS (IntFn fInt n)
132 (IntFnL fInt n)))
133 (IntegralSeries fInt).
134 Proof.
135 destruct fInt; simpl.
136 destruct (series_cv_maj (fun n : nat => I IS (IntFn0 n) (IntFnL0 n))
137 (fun k : nat => Iabs (IntFn0 k) (IntFnL0 k)) IntAbsSum0).
138 apply p.
139 Qed.
140
141 (*
142 An extension of an integrable function has the same integral.
143 In particular, if the domain of an L-function g is included
144 in the domain of a function f, and if f equals zero on the
145 domain of g, then f is integrable with integral 0.
146 Multiply g by 0 and apply this lemma to demonstrate it.
147 In other words, L-functions are defined almost everywhere.
148 *)
149 Lemma IntegralRestrict : forall {IS : IntegrationSpace}
150 (f g : PartialFunction (X (ElemFunc IS)))
151 (fInt : IntegrableFunction f)
152 (restrict : PartialRestriction f g),
153 Integral (IntegrableFunctionExtensional f g restrict fInt)
154 = Integral fInt.
155 Proof.
156 intros.
157 destruct fInt, restrict, p; simpl.
158 reflexivity.
159 Qed.
160
161 (* We now prove that the integral of f does not depend on the representation fn.
162 If gn is another representation of f, we will prove that the sequence
163 f0, -g0, f1, -g1, f2, -g2, ...
164 is a representation of the zero function, with integral 0. Note that the
165 sequence f0-g0, f1-g1, ... does not work, because the convergence of
166 Sum_n |fn - gn| does not imply the convergence of Sum_n |fn|.
167
168 So we first need to combine two sequences into one. Of course, we can
169 iterate this to combine any finite number of sequences into one. *)
170
171 Definition weaveSequences (X : Type) (fn gn : nat -> X)
172 : nat -> X
173 := fun n => if Nat.even n then fn (n / 2)%nat else gn (n / 2)%nat.
174
175 Definition weaveSequencesL
176 (E : FunctionRieszSpace)
177 (fn : nat -> PartialFunction (X E))
178 (fnL : forall n:nat, L E (fn n))
179 (gn : nat -> PartialFunction (X E))
180 (gnL : forall n:nat, L E (gn n))
181 : forall n:nat, L E (weaveSequences (PartialFunction (X E))
182 fn gn n).
183 Proof.
184 intros. unfold weaveSequences. destruct (Nat.even n). apply fnL. apply gnL.
185 Defined.
186
187 Lemma evenSuccessor : forall n:nat, Nat.even (S n) = negb (Nat.even n).
188 Proof.
189 induction n. reflexivity. rewrite IHn. simpl.
190 destruct (Nat.even n); reflexivity.
191 Qed.
192
193 Lemma weaveSequencesEven : forall (X : Set) (fn gn : nat -> X) (n : nat),
194 weaveSequences X fn gn (n*2) = fn n.
195 Proof.
196 intros. unfold weaveSequences. destruct (Nat.even (n * 2)) eqn:even.
197 rewrite Nat.div_mul. reflexivity. discriminate.
198 exfalso. assert (Nat.even (n * 2) = true).
199 apply Nat.even_spec. exists n. rewrite Nat.mul_comm. reflexivity.
200 rewrite even in H. discriminate.
201 Qed.
202
203 Lemma weaveSequencesOdd : forall (X : Set) (fn gn : nat -> X) (n : nat),
204 weaveSequences X fn gn (1 + n*2) = gn n.
205 Proof.
206 intros. unfold weaveSequences. destruct (Nat.even (1 + n * 2)) eqn:even.
207 exfalso. rewrite evenSuccessor in even. assert (Nat.even (n * 2) = true).
208 apply Nat.even_spec. exists n. rewrite Nat.mul_comm. reflexivity.
209 rewrite H in even. discriminate. rewrite Nat.div_add. simpl.
210 reflexivity. auto.
211 Qed.
212
213 Lemma divModSucc : forall n p q : nat,
214 fst (Nat.divmod n 1 (S q) p) = S (fst (Nat.divmod n 1 q p)).
215 Proof.
216 induction n.
217 - intros. reflexivity.
218 - intros. simpl. destruct p. rewrite IHn. reflexivity.
219 rewrite IHn. reflexivity.
220 Qed.
221
222 Lemma weaveSequencesSum : forall {R : ConstructiveReals}
223 (fn gn : nat -> CRcarrier R) (n : nat),
224 CRsum (fun k:nat => (weaveSequences (CRcarrier R) fn gn k)) n
225 == CRsum fn (n / 2)
226 + match n with
227 | O => 0
228 | _ => CRsum gn (if Nat.even n then pred (n / 2) else n / 2)
229 end.
230 Proof.
231 induction n.
232 - unfold weaveSequences. simpl. rewrite CRplus_0_r. reflexivity.
233 - simpl. rewrite IHn. clear IHn. destruct n. unfold weaveSequences. simpl.
234 rewrite CRplus_0_r. reflexivity.
235 assert (fst (Nat.divmod n 1 0 1) = n/2 )%nat. { reflexivity. }
236 assert (fst (Nat.divmod n 1 0 0) = (1+n)/2 )%nat. { reflexivity. }
237
238 unfold weaveSequences. simpl. destruct (Nat.even n) eqn:nEven.
239 + destruct n. simpl.
240 rewrite CRplus_assoc, (CRplus_comm (gn 0%nat)).
241 rewrite <- CRplus_assoc. reflexivity.
242 destruct (Nat.even n) eqn:snEven.
243 rewrite evenSuccessor in nEven. rewrite snEven in nEven. inversion nEven.
244 rewrite divModSucc. rewrite H. rewrite H0.
245 pose proof (Nat.even_spec (S n)) as [H1 _].
246 destruct (H1 nEven). rewrite Nat.mul_comm in H2.
247 rewrite H2. rewrite Nat.div_add. rewrite Nat.div_mul.
248 simpl. do 2 rewrite CRplus_assoc. apply CRplus_morph. reflexivity.
249 apply CRplus_comm. auto. auto.
250 + destruct n. exfalso. inversion nEven. destruct (Nat.even n) eqn:snEven.
251 rewrite divModSucc. rewrite H. rewrite H0.
252 pose proof (Nat.odd_spec (S n)) as [H1 _]. destruct H1. unfold Nat.odd.
253 rewrite nEven. trivial. rewrite Nat.mul_comm in H1. rewrite Nat.add_comm in H1.
254 rewrite H1. rewrite Nat.div_add.
255 assert ((1 + (1 + x * 2)) / 2 = (2 + x * 2) / 2)%nat. reflexivity.
256 rewrite H2. rewrite Nat.div_add. simpl.
257 do 2 rewrite CRplus_assoc. apply CRplus_morph. reflexivity.
258 apply CRplus_morph. reflexivity. reflexivity.
259 auto. auto.
260 exfalso. rewrite <- nEven in snEven.
261 rewrite evenSuccessor in snEven. destruct (Nat.even n); discriminate.
262 Qed.
263
264 Lemma partialApplyWeave
265 : forall {R : ConstructiveReals} (X : Set)
266 (fn gn : nat -> @PartialFunction R X)
267 (n : nat)
268 (x : X)
269 (xH : Domain (fn (n/2)%nat) x)
270 (y : Domain (gn (n/2)%nat) x)
271 (z : Domain (weaveSequences (PartialFunction X) fn gn n) x),
272 partialApply (weaveSequences (PartialFunction X) fn gn n) x z
273 == if Nat.even n then partialApply (fn (n/2)%nat) x xH
274 else partialApply (gn (n/2)%nat) x y.
275 Proof.
276 intros. unfold weaveSequences. unfold weaveSequences in z.
277 unfold weaveSequences in xH.
278 destruct (Nat.even n); apply DomainProp.
279 Qed.
280
281 Definition domainWeaveEvenInc {R : ConstructiveReals} (X : Set)
282 (fn gn : nat -> @PartialFunction R X)
283 (n : nat)
284 (x : X)
285 (xD : Domain (weaveSequences _ fn gn (n*2)) x)
286 : Domain (fn n) x.
287 Proof.
288 unfold weaveSequences. unfold weaveSequences in xD.
289 destruct (Nat.even (n*2)) eqn:des.
290 - remember (n*2/2)%nat. rewrite Nat.div_mul in Heqn0. subst n0.
291 exact xD. auto.
292 - exfalso. assert (Nat.even (n * 2) = true).
293 apply Nat.even_spec. exists n. rewrite Nat.mul_comm. reflexivity.
294 rewrite des in H. discriminate.
295 Qed.
296
297 Lemma partialApplyWeaveEven
298 : forall {R : ConstructiveReals} (X : Set)
299 (fn gn : nat -> @PartialFunction R X)
300 (n : nat)
301 (x : X)
302 (xD : Domain (fn n) x)
303 (y : Domain (weaveSequences (PartialFunction X) fn gn (n*2)) x),
304 partialApply (fn n) x xD
305 == partialApply (weaveSequences (PartialFunction X) fn gn (n * 2)) x y.
306 Proof.
307 intros. unfold weaveSequences. unfold weaveSequences in y.
308 destruct (Nat.even (n * 2)) eqn:des.
309 (* Hide 2 * n / 2 in a single variable, to substitute it *)
310 remember ((n * 2) / 2)%nat as doubleN. rewrite Nat.div_mul in HeqdoubleN.
311 subst doubleN. apply DomainProp. auto.
312 exfalso. assert (Nat.even (n * 2) = true).
313 apply Nat.even_spec. exists n. rewrite Nat.mul_comm. reflexivity. rewrite des in H.
314 discriminate.
315 Qed.
316
317 Definition domainWeaveOddInc {R : ConstructiveReals} (X : Set)
318 (fn gn : nat -> @PartialFunction R X)
319 (n : nat)
320 (x : X)
321 (xD : Domain (weaveSequences _ fn gn (1+n*2)) x)
322 : Domain (gn n) x.
323 Proof.
324 unfold weaveSequences. unfold weaveSequences in xD.
325 destruct (Nat.even (1+n*2)) eqn:des.
326 - exfalso. assert (Nat.odd (1+ n * 2) = true).
327 apply Nat.odd_spec. exists n. rewrite Nat.mul_comm.
328 rewrite Nat.add_comm. reflexivity.
329 unfold Nat.odd in H. rewrite des in H. discriminate.
330 - remember ((1+n*2)/2)%nat. rewrite Nat.div_add in Heqn0. subst n0.
331 exact xD. auto.
332 Qed.
333
334 Lemma partialApplyWeaveOdd
335 : forall {R : ConstructiveReals} (X : Set)
336 (fn gn : nat -> @PartialFunction R X)
337 (n : nat)
338 (x : X)
339 (xD : Domain (gn n) x)
340 (y : Domain (weaveSequences (PartialFunction X) fn gn (1 + (n*2))) x),
341 partialApply (gn n) x xD
342 == partialApply (weaveSequences (PartialFunction X) fn gn (1 + (n * 2))) x y.
343 Proof.
344 intros. unfold weaveSequences. unfold weaveSequences in y.
345 destruct (Nat.even (1+(n * 2))) eqn:even.
346 exfalso. assert (Nat.even (n * 2) = true).
347 apply Nat.even_spec. exists n. rewrite Nat.mul_comm. reflexivity.
348 rewrite evenSuccessor in even.
349 rewrite H in even. discriminate.
350 (* Hide 2 * n / 2 in a single variable, to substitute it *)
351 remember ((1 + (n * 2)) / 2)%nat as doubleN.
352 rewrite Nat.div_add in HeqdoubleN. simpl in HeqdoubleN. subst doubleN.
353 apply DomainProp. auto.
354 Qed.
355
356 Lemma halfWeavedSumEven : forall {R : ConstructiveReals}
357 (fn gn : nat -> CRcarrier R) (a : CRcarrier R),
358 (forall k:nat, 0 <= fn k)
359 -> (forall k:nat, 0 <= gn k)
360 -> series_cv (weaveSequences (CRcarrier R) fn gn) a
361 -> { l : CRcarrier R & series_cv fn l }.
362 Proof.
363 intros.
364 destruct (series_cv_maj (weaveSequences (CRcarrier R) fn (fun n => 0))
365 (weaveSequences (CRcarrier R) fn gn) a) as [l [cv _]].
366 - intro n. unfold weaveSequences. destruct (Nat.even n).
367 rewrite CRabs_right. apply CRle_refl. apply H.
368 rewrite CRabs_right. apply H0. apply CRle_refl.
369 - assumption.
370 - exists l. intros n.
371 specialize (cv n) as [N cv].
372 exists N. intros. specialize (cv (i*2)%nat).
373 rewrite weaveSequencesSum in cv. rewrite Nat.div_mul in cv.
374 setoid_replace (match (i * 2)%nat with
375 | 0%nat => CR_of_Q R 0
376 | S _ =>
377 CRsum (fun _ : nat => 0)
378 (if Nat.even (i * 2) then Init.Nat.pred i else i)
379 end) with (CR_of_Q R 0) in cv.
380 rewrite CRplus_0_r in cv. apply cv. apply (Nat.le_trans _ i).
381 assumption. rewrite Nat.mul_comm. simpl. rewrite <- (Nat.add_0_r i).
382 rewrite <- Nat.add_assoc. apply Nat.add_le_mono_l. apply Nat.le_0_l.
383 destruct (i*2)%nat eqn:des. reflexivity.
384 rewrite sum_const. rewrite CRmult_0_l. reflexivity. auto.
385 Qed.
386
387 Lemma halfWeavedSumOdd : forall {R : ConstructiveReals}
388 (fn gn : nat -> CRcarrier R) (a : CRcarrier R),
389 (forall k:nat, 0 <= fn k)
390 -> (forall k:nat, 0 <= gn k)
391 -> series_cv (weaveSequences (CRcarrier R) fn gn) a
392 -> { l : CRcarrier R & series_cv gn l }.
393 Proof.
394 intros.
395 destruct (series_cv_maj (weaveSequences (CRcarrier R) (fun n => 0) gn)
396 (weaveSequences (CRcarrier R) fn gn) a) as [l [cv _]].
397 - intro n. unfold weaveSequences. destruct (Nat.even n).
398 rewrite CRabs_right. apply H. apply CRle_refl.
399 rewrite CRabs_right. apply CRle_refl. apply H0.
400 - assumption.
401 - exists l. intros p. specialize (cv p) as [N cv].
402 exists N. intros n H2. specialize (cv (1+n*2)%nat).
403 rewrite weaveSequencesSum in cv. rewrite Nat.div_add in cv.
404 rewrite sum_const in cv. rewrite CRmult_0_l in cv. rewrite CRplus_0_l in cv.
405 destruct (1 + n*2)%nat eqn:des.
406 + exfalso. inversion des.
407 + rewrite <- des in cv. clear des. destruct (Nat.even (1+n*2)) eqn:des.
408 exfalso. assert (Nat.Odd (1+n*2)). exists n. rewrite Nat.add_comm.
409 rewrite Nat.mul_comm. reflexivity. apply Nat.odd_spec in H3.
410 unfold Nat.odd in H3. rewrite des in H3. inversion H3.
411 apply cv. apply (Nat.le_trans N n). assumption.
412 apply (Nat.le_trans n (n*2)). rewrite <- (Nat.mul_1_r n).
413 rewrite <- Nat.mul_assoc. apply Nat.mul_le_mono_nonneg_l.
414 apply Nat.le_0_l. apply le_S. apply Nat.le_refl.
415 rewrite <- (Nat.add_0_l (n*2)). rewrite Nat.add_assoc.
416 apply Nat.add_le_mono_r. auto.
417 + auto.
418 Qed.
419
420 Lemma weaveInfiniteSums
421 : forall {R : ConstructiveReals} (u v : nat -> CRcarrier R) (su sv : CRcarrier R),
422 series_cv u su
423 -> series_cv v sv
424 -> series_cv (weaveSequences (CRcarrier R) u v) (su + sv).
425 Proof.
426 intros. intros n.
427 specialize (H (2*n)%positive). specialize (H0 (2*n)%positive).
428 destruct H as [N H], H0 as [N0 H0].
429 exists (S(N*2 + (S N0)*2)). intros.
430 rewrite weaveSequencesSum. destruct i. exfalso; inversion H1.
431 destruct (Nat.even (S i)) eqn:snEven.
432 + setoid_replace (CRsum u (S i / 2)
433 + CRsum v (Init.Nat.pred (S i / 2)) - (su + sv))
434 with (CRsum u (S i / 2) - su + (CRsum v (Init.Nat.pred (S i / 2)) - sv)).
435 apply (CRle_trans _ _ _ (CRabs_triang _ _)).
436 setoid_replace (1 # n)%Q with ((1 # (2*n)) + (1 # (2*n)))%Q.
437 apply le_S_n in H1. rewrite CR_of_Q_plus. apply CRplus_le_compat.
438 apply H. rewrite <- (Nat.div_mul N 2). apply Nat.div_le_mono.
439 auto. apply (Nat.le_trans (N*2) (N*2 + (S N0)*2)). apply Nat.le_add_r.
440 apply (Nat.le_trans _ i). assumption.
441 apply le_S. apply Nat.le_refl. auto.
442 apply H0. assert (N0 = pred (S N0)). reflexivity.
443 rewrite H2. apply Nat.pred_le_mono. rewrite <- (Nat.div_mul (S N0) 2).
444 apply Nat.div_le_mono. auto.
445 apply (Nat.le_trans _ (N*2 + (S N0)*2)).
446 rewrite Nat.add_comm. apply Nat.le_add_r.
447 apply (Nat.le_trans (N*2 + (S N0)*2) i). assumption. apply le_S. apply Nat.le_refl. auto.
448 rewrite Qinv_plus_distr. reflexivity.
449 unfold CRminus. do 2 rewrite CRplus_assoc.
450 apply CRplus_morph. reflexivity. rewrite CRopp_plus_distr, CRplus_comm.
451 rewrite CRplus_assoc. apply CRplus_morph. reflexivity. apply CRplus_comm.
452 + setoid_replace (CRsum u (S i / 2) + CRsum v (S i / 2) - (su + sv))
453 with (CRsum u (S i / 2) - su + (CRsum v (S i / 2) - sv)).
454 apply (CRle_trans _ _ _ (CRabs_triang _ _)).
455 setoid_replace (1 # n)%Q with ((1 # (2*n)) + (1 # (2*n)))%Q.
456 apply le_S_n in H1. rewrite CR_of_Q_plus. apply CRplus_le_compat.
457 apply H. rewrite <- (Nat.div_mul N 2). apply Nat.div_le_mono.
458 auto. apply (Nat.le_trans (N*2) (N*2 + (S N0)*2)). apply Nat.le_add_r.
459 apply (Nat.le_trans _ i). assumption. apply le_S. apply Nat.le_refl. auto.
460 apply H0. rewrite <- (Nat.div_mul N0 2).
461 apply Nat.div_le_mono. auto.
462 apply (Nat.le_trans (N0*2) (N*2 + (S N0)*2)). rewrite Nat.add_comm.
463 apply (Nat.le_trans (N0 * 2) (S N0 * 2)).
464 apply Nat.mul_le_mono_r. apply le_S. apply Nat.le_refl.
465 apply Nat.le_add_r.
466 apply (Nat.le_trans _ i). assumption. apply le_S. apply Nat.le_refl. auto.
467 rewrite Qinv_plus_distr. reflexivity.
468 unfold CRminus. do 2 rewrite CRplus_assoc.
469 apply CRplus_morph. reflexivity. rewrite CRopp_plus_distr, CRplus_comm.
470 rewrite CRplus_assoc. apply CRplus_morph. reflexivity. apply CRplus_comm.
471 Qed.
472
473 Lemma sum_truncate_above : forall {R : ConstructiveReals} (u : nat -> CRcarrier R) (N n : nat),
474 le N n -> CRsum (fun n0 : nat => if le_dec n0 N then u n0 else 0) n
475 == CRsum u N.
476 Proof.
477 intros. destruct (Nat.eq_dec N n).
478 - subst N. apply CRsum_eq. intros. destruct (le_dec i n).
479 reflexivity. contradiction.
480 - (* N < n so we can split the sum in 2 and use sum_assoc. *)
481 destruct (Nat.le_exists_sub (S N) n) as [p [H0 _]].
482 + pose proof (Nat.lt_ge_cases N n) as [H0|H1]. apply H0. exfalso.
483 exact (n0 (Nat.le_antisymm N n H H1)).
484 + subst n. rewrite Nat.add_comm. rewrite sum_assoc.
485 assert (CRsum (fun k : nat => if le_dec (S N + k) N then u (S N + k)%nat else 0) p == 0).
486 { rewrite <- (CRsum_eq (fun k => 0)). rewrite sum_const.
487 apply CRmult_0_l. intros.
488 destruct (le_dec (S N + i)). exfalso. assert (S N <= N)%nat.
489 apply (Nat.le_trans (S N) (S N + i)). apply Nat.le_add_r. assumption.
490 exact (Nat.nle_succ_diag_l N H1). reflexivity. }
491 rewrite H0. rewrite CRplus_0_r.
492 rewrite (CRsum_eq u (fun n1 : nat => if le_dec n1 N then u n1 else 0)).
493 reflexivity. intros. destruct (le_dec i N). reflexivity. contradiction.
494 Qed.
495
496 Lemma infinite_sum_truncate_below
497 : forall {R : ConstructiveReals} (u : nat -> CRcarrier R) (s : CRcarrier R) (N : nat),
498 series_cv u s
499 -> series_cv (fun n : nat => if le_dec n N then 0 else u n)
500 (s - CRsum u N).
501 Proof.
502 intros.
503 apply (series_cv_eq
504 (fun n : nat => u n + (if le_dec n N then (-u n) else 0))).
505 intros. destruct (le_dec n N). rewrite CRplus_opp_r. reflexivity.
506 rewrite CRplus_0_r. reflexivity.
507 apply series_cv_plus. assumption. intros n. exists N. intros.
508 rewrite sum_truncate_above.
509 rewrite <- (CRsum_eq (fun n0 : nat => u n0 * (CRopp R 1))).
510 rewrite sum_scale, CRmult_comm.
511 rewrite <- (CRopp_mult_distr_l 1). unfold CRminus.
512 rewrite <- CRopp_plus_distr.
513 rewrite CRabs_opp. rewrite CRmult_1_l.
514 rewrite CRplus_opp_r. rewrite CRabs_right.
515 apply CR_of_Q_le. discriminate. apply CRle_refl.
516 intros. rewrite <- CRopp_mult_distr_r, CRmult_1_r.
517 reflexivity. assumption.
518 Qed.
519
520 Lemma partialApplyWeaveInfiniteSum
521 : forall {R : ConstructiveReals} (X : Set)
522 (fn gn : nat -> @PartialFunction R X)
523 (x : X)
524 (xD : Domain (XinfiniteSumAbs fn) x)
525 (y : Domain (XinfiniteSumAbs gn) x)
526 (pxDn : forall n:nat, Domain (weaveSequences (PartialFunction X) fn gn n) x),
527 series_cv
528 (fun n : nat =>
529 partialApply (weaveSequences (PartialFunction X) fn gn n) x
530 (pxDn n))
531 (partialApply (XinfiniteSumAbs fn) x xD
532 + partialApply (XinfiniteSumAbs gn) x y).
533 Proof.
534 intros.
535 apply (series_cv_eq
536 (weaveSequences
537 (CRcarrier R) (fun n => partialApply
538 (fn n) x (domainInfiniteSumAbsIncReverse _ x xD n))
539 (fun n => partialApply
540 (gn n) x (domainInfiniteSumAbsIncReverse _ x y n)))).
541 intro n. destruct (Nat.even n) eqn:nEven.
542 - pose proof (Nat.even_spec n) as [H2 _]. destruct (H2 nEven) as [m H3]. subst n.
543 rewrite Nat.mul_comm.
544 rewrite <- (partialApplyWeaveEven
545 X fn gn m x (domainInfiniteSumAbsIncReverse _ x xD m)).
546 + rewrite weaveSequencesEven. reflexivity.
547 - pose proof (Nat.odd_spec n) as [H2 _]. destruct H2 as [m H3]. unfold Nat.odd.
548 rewrite nEven. trivial. subst n. rewrite Nat.add_comm. rewrite Nat.mul_comm.
549 rewrite <- (partialApplyWeaveOdd
550 X fn gn m x (domainInfiniteSumAbsIncReverse _ x y m)).
551 + rewrite weaveSequencesOdd. reflexivity.
552 - apply weaveInfiniteSums.
553 apply applyInfiniteSumAbs. reflexivity.
554 apply applyInfiniteSumAbs. reflexivity.
555 Qed.
556
557 (* The Prop part, hidden behind a Qed.
558 The exposed part in sort Type comes right after. *)
559 Definition IntegralRepresentationZero {IS : IntegrationSpace}
560 : @IntegralRepresentation IS.
561 Proof.
562 apply (Build_IntegralRepresentation IS
563 (fun _ : nat => Izero IS)
564 (fun _ : nat => Izero_is_L IS)
565 0).
566 apply (series_cv_eq (fun n => 0)). intro n.
567 unfold Iabs. rewrite <- (Izero_is_zero IS).
568 apply IExtensional. intros. unfold Izero.
569 rewrite applyXscale. rewrite CRmult_0_l.
570 rewrite applyXabs. rewrite applyXscale. rewrite CRmult_0_l.
571 rewrite CRabs_right. reflexivity. apply CRle_refl.
572 intros n. exists O. intros.
573 rewrite sum_const. rewrite CRmult_0_l. unfold CRminus.
574 rewrite CRplus_0_l, CRopp_0.
575 rewrite CRabs_right. apply CR_of_Q_le. discriminate.
576 apply CRle_refl.
577 Defined.
578
579 Lemma IntegrableZeroMaj : forall {IS : IntegrationSpace},
580 PartialRestriction (XinfiniteSumAbs (IntFn (IntegralRepresentationZero)))
581 (Xconst (X (ElemFunc IS)) 0).
582 Proof.
583 split.
584 - intros x [xn cv]. simpl. trivial.
585 - intros. destruct xD as [xn cv]. transitivity (CR_of_Q (RealT (ElemFunc IS)) 0).
586 apply applyInfiniteSumAbs.
587 apply (series_cv_eq (fun _ => 0)).
588 intro n. unfold IntegralRepresentationZero, IntFn.
589 rewrite applyIzero. reflexivity.
590 intros p. exists O. intros. rewrite sum_const.
591 rewrite CRmult_0_l. unfold CRminus.
592 rewrite CRplus_opp_r, CRabs_right.
593 apply CR_of_Q_le.
594 discriminate. apply CRle_refl. reflexivity.
595 Qed.
596
597 Definition IntegrableZero {IS : IntegrationSpace}
598 : IntegrableFunction (Xconst (X (ElemFunc IS)) 0).
599 Proof.
600 exists (IntegralRepresentationZero). apply IntegrableZeroMaj.
601 Defined.
602
603 Lemma IntegralZeroIsZero : forall {IS : IntegrationSpace},
604 Integral (@IntegrableZero IS) == 0.
605 Proof.
606 intros IS; unfold Integral.
607 pose proof (IntegralCv (@IntegralRepresentationZero IS)).
608 apply (series_cv_unique (fun _ : nat => I IS (Izero IS) (Izero_is_L IS))).
609 assumption.
610 apply (CR_cv_eq _ (fun _ => 0)). 2: apply CR_cv_const.
611 intros. rewrite sum_const. unfold Izero. unfold Izero_is_L.
612 rewrite Ihomogeneous. rewrite CRmult_0_l.
613 rewrite CRmult_0_l. reflexivity.
614 Qed.
615
616 Definition domainInfinSumWeaveL {R : ConstructiveReals} (X : Set)
617 (fn gn : nat -> @PartialFunction R X)
618 (x : X)
619 (xD : Domain (XinfiniteSumAbs (weaveSequences _ fn gn)) x)
620 : Domain (@XinfiniteSumAbs R _ fn) x.
621 Proof.
622 pose (fun n => domainWeaveEvenInc
623 X fn gn n x (domainInfiniteSumAbsIncReverse _ x xD (n*2)))
624 as pxDFn.
625 pose (fun n => domainWeaveOddInc
626 X fn gn n x (domainInfiniteSumAbsIncReverse _ x xD (1+n*2)))
627 as pxDGn.
628 destruct xD as [xn cv]; simpl in pxDFn, pxDGn.
629 pose proof (CR_complete R _ cv) as [lim cv2].
630 destruct (halfWeavedSumEven
631 (fun n => CRabs _ (partialApply (fn n) x (pxDFn n)))
632 (fun n => CRabs _ (partialApply (gn n) x (pxDGn n)))
633 lim) as [l cvl].
634 intro k. apply CRabs_pos. intro k. apply CRabs_pos.
635 apply (CR_cv_eq _ (CRsum
636 (fun k : nat =>
637 CRabs _
638 (partialApply (weaveSequences (PartialFunction X) fn gn k) x (xn k))))).
639 2: apply cv2.
640 intro n. apply CRsum_eq. intros.
641 rewrite (partialApplyWeave X fn gn i x (pxDFn (i/2)%nat) (pxDGn (i/2)%nat)).
642 - unfold weaveSequences. destruct (Nat.even i); reflexivity.
643 - exists pxDFn. exact (Rcv_cauchy_mod _ l cvl).
644 Qed.
645
646 Definition domainInfinSumWeaveR {R : ConstructiveReals} (X : Set)
647 (fn gn : nat -> PartialFunction X)
648 (x : X)
649 (xD : Domain (XinfiniteSumAbs (weaveSequences _ fn gn)) x)
650 : Domain (@XinfiniteSumAbs R _ gn) x.
651 Proof.
652 pose (fun n => domainWeaveEvenInc
653 X fn gn n x (domainInfiniteSumAbsIncReverse _ x xD (n*2)))
654 as pxDFn.
655 pose (fun n => domainWeaveOddInc
656 X fn gn n x (domainInfiniteSumAbsIncReverse _ x xD (1+n*2)))
657 as pxDGn.
658 destruct xD as [xn cv]; simpl in pxDFn, pxDGn.
659 pose proof (CR_complete R _ cv) as [lim cv2].
660 destruct (halfWeavedSumOdd
661 (fun n => CRabs _ (partialApply (fn n) x (pxDFn n)))
662 (fun n => CRabs _ (partialApply (gn n) x (pxDGn n)))
663 lim) as [l cvl].
664 intro k. apply CRabs_pos. intro k. apply CRabs_pos.
665 apply (CR_cv_eq _ (CRsum
666 (fun k : nat =>
667 CRabs _
668 (partialApply (weaveSequences (PartialFunction X) fn gn k) x (xn k))))).
669 2: apply cv2.
670 intro n. apply CRsum_eq. intros.
671 rewrite (partialApplyWeave X fn gn i x (pxDFn (i/2)%nat) (pxDGn (i/2)%nat)).
672 - unfold weaveSequences. destruct (Nat.even i); reflexivity.
673 - exists pxDGn. exact (Rcv_cauchy_mod _ l cvl).
674 Qed.
675
676 Definition IntegralRepresentationPlus
677 {IS : IntegrationSpace}
678 (f : PartialFunction (X (ElemFunc IS)))
679 (fInt : IntegrableFunction f)
680 (g : PartialFunction (X (ElemFunc IS)))
681 (gInt : IntegrableFunction g)
682 : @IntegralRepresentation IS.
683 Proof.
684 destruct fInt as [fInt injF], gInt as [gInt injG].
685 apply (Build_IntegralRepresentation
686 IS _
687 (weaveSequencesL (ElemFunc IS) (IntFn fInt) (IntFnL fInt)
688 (IntFn gInt) (IntFnL gInt))
689 (IntAbsSum fInt + IntAbsSum gInt)).
690 (* Limit of sum of integrals of absolute values *)
691 destruct fInt, gInt; simpl.
692 apply (series_cv_eq (weaveSequences (CRcarrier (RealT (ElemFunc IS)))
693 (fun n => Iabs (IntFn0 n) (IntFnL0 n))
694 (fun n => Iabs (IntFn1 n) (IntFnL1 n)))).
695 intro n. unfold weaveSequences. unfold weaveSequencesL.
696 destruct (Nat.even n); reflexivity.
697 apply weaveInfiniteSums; assumption.
698 Defined.
699
700 Definition IntegralRepresentationPlusInj
701 {IS : IntegrationSpace}
702 (f : PartialFunction (X (ElemFunc IS)))
703 (fInt : IntegrableFunction f)
704 (g : PartialFunction (X (ElemFunc IS)))
705 (gInt : IntegrableFunction g)
706 (x : X (ElemFunc IS))
707 (xD : Domain (XinfiniteSumAbs
708 (IntFn (IntegralRepresentationPlus f fInt g gInt))) x)
709 : Domain (Xplus f g) x.
710 Proof.
711 destruct fInt as [[fn fnL] [fInj resF]].
712 destruct gInt as [[gn gnL] [gInj resG]].
713 unfold IntegralRepresentationPlus, IntFn in x.
714 pose proof (domainInfinSumWeaveL _ fn gn x) as ixf.
715 pose proof (domainInfinSumWeaveR _ fn gn x) as ixg.
716 simpl in resF.
717 pose proof (resF x (ixf xD)) as yf.
718 exact (pair (fInj x (ixf xD)) (gInj x (ixg xD))).
719 Qed.
720
721 Lemma IntegrablePlusMaj
722 : forall {IS : IntegrationSpace}
723 (f : PartialFunction (X (ElemFunc IS)))
724 (fInt : IntegrableFunction f)
725 (g : PartialFunction (X (ElemFunc IS)))
726 (gInt : IntegrableFunction g),
727 PartialRestriction (XinfiniteSumAbs
728 (IntFn (IntegralRepresentationPlus f fInt g gInt)))
729 (Xplus f g).
730 Proof.
731 (* The weaved absolute convergence implies both that of fn and of gn. *)
732 split.
733 - intros x xd.
734 exact (IntegralRepresentationPlusInj f fInt g gInt x xd).
735 - intros. apply applyInfiniteSumAbs.
736 destruct fInt as [[fn fnL] [fInj resF]];
737 destruct gInt as [[gn gnL] [gInj resG]];
738 unfold IntegralRepresentationPlus, IntFn.
739 unfold IntegralRepresentationPlus, IntFn in xD.
740 pose proof (domainInfinSumWeaveL _ fn gn x xD) as ixf.
741 pose proof (domainInfinSumWeaveR _ fn gn x xD) as ixg.
742 specialize (resF x ixf) as appF.
743 specialize (resG x ixg) as appG. simpl in appG, appF.
744 destruct xG. rewrite (applyXplus f g).
745 rewrite <- appG. rewrite <- appF.
746 apply partialApplyWeaveInfiniteSum.
747 Qed.
748
749 Definition IntegrablePlus {IS : IntegrationSpace}
750 (f : PartialFunction (X (ElemFunc IS)))
751 (g : PartialFunction (X (ElemFunc IS)))
752 : IntegrableFunction f
753 -> IntegrableFunction g
754 -> IntegrableFunction (Xplus f g).
755 Proof.
756 intros fInt gInt.
757 exists (IntegralRepresentationPlus f fInt g gInt).
758 apply IntegrablePlusMaj.
759 Defined.
760
761 Definition domainInfiniteSumAbsScaleInc
762 {R : ConstructiveReals} (X : Set)
763 (fn : nat -> @PartialFunction R X)
764 (a : CRcarrier R)
765 (x : X)
766 (xD : Domain (XinfiniteSumAbs fn) x)
767 : { y : Domain (XinfiniteSumAbs (fun n : nat => Xscale a (fn n))) x
768 | partialApply _ x y == (partialApply _ x xD) * a }.
769 Proof.
770 destruct xD as [xn cv]; simpl.
771 pose proof (CR_complete R _ cv) as [l cvl].
772 destruct (domainInfiniteSumAbsInc
773 (fun n => Xscale a (fn n)) x
774 xn (l * CRabs _ a))
775 as [y e].
776 - apply (series_cv_eq
777 (fun n : nat => CRabs _ (partialApply (fn n) x (xn n)) * CRabs _ a)).
778 intro n. rewrite applyXscale. rewrite CRabs_mult.
779 apply CRmult_comm. apply series_cv_scale. apply cvl.
780 - exists (existT _ y e).
781 destruct (series_cv_abs (fun n : nat => a * partialApply (fn n) x (y n)) e).
782 destruct (series_cv_abs (fun n : nat => partialApply (fn n) x (xn n)) cv).
783 apply (series_cv_unique
784 (fun n : nat => (a * partialApply (fn n) x (y n))) _ _ s).
785 apply (series_cv_eq (fun n : nat => (partialApply (fn n) x (xn n)) * a)).
786 intro n. rewrite CRmult_comm. apply CRmult_morph.
787 reflexivity. apply DomainProp. apply series_cv_scale.
788 exact s0.
789 Qed.
790
791 Definition domainInfiniteSumAbsScaleIncReverse
792 {R : ConstructiveReals} (X : Set)
793 (fn : nat -> @PartialFunction R X)
794 (a : CRcarrier R)
795 (x : X)
796 (xD : Domain (XinfiniteSumAbs (fun n : nat => Xscale a (fn n))) x)
797 (aNZ : CRapart R a 0)
798 : { y : Domain (XinfiniteSumAbs fn) x
799 | partialApply _ x y == (partialApply _ x xD) * (CRinv R a aNZ) }.
800 Proof.
801 intros.
802 destruct xD as [xn cv]; simpl.
803 pose proof (CR_complete R _ cv) as [l cvl].
804 destruct (domainInfiniteSumAbsInc
805 fn x xn
806 (l * CRabs _ (CRinv R a aNZ))) as [y e].
807 - apply (series_cv_eq
808 (fun n : nat => (CRabs _ (partialApply (Xscale a (fn n)) x
809 (xn n)) * CRabs _ (CRinv R a aNZ)))).
810 intro n. rewrite applyXscale. rewrite CRabs_mult.
811 rewrite CRmult_comm, <- CRmult_assoc, <- CRabs_mult, CRinv_l.
812 rewrite CRabs_right. rewrite CRmult_1_l. reflexivity.
813 apply CRlt_asym, CRzero_lt_one.
814 apply series_cv_scale. apply cvl.
815 - exists (existT _ y e).
816 apply (applyInfiniteSumAbs _ fn x (existT _ y e)).
817 apply (series_cv_eq
818 (fun n : nat => partialApply (Xscale a (fn n)) x (xn n) * CRinv R a aNZ)).
819 intro n. rewrite CRmult_comm. rewrite applyXscale.
820 rewrite <- CRmult_assoc. rewrite CRinv_l. rewrite CRmult_1_l.
821 apply DomainProp. apply series_cv_scale.
822 destruct (series_cv_abs (fun n : nat => a * partialApply (fn n) x (xn n)) cv).
823 exact s.
824 Qed.
825
826 Definition IntegralRepresentationWeave {IS : IntegrationSpace}
827 (a b : @IntegralRepresentation IS) : @IntegralRepresentation IS.
828 Proof.
829 apply (Build_IntegralRepresentation
830 IS
831 (weaveSequences _ (IntFn a) (IntFn b))
832 (weaveSequencesL (ElemFunc IS) _ (IntFnL a) _ (IntFnL b))
833 (IntAbsSum a + IntAbsSum b)).
834 apply (series_cv_eq
835 (weaveSequences (CRcarrier (RealT (ElemFunc IS)))
836 (fun k => (Iabs (IntFn a k) (IntFnL a k)))
837 (fun k => (Iabs (IntFn b k) (IntFnL b k))))).
838 - intro n. unfold weaveSequences, weaveSequencesL.
839 destruct (Nat.even n). reflexivity. reflexivity.
840 - apply weaveInfiniteSums; apply IntAbsSumCv.
841 Defined.
842
843 Lemma IntegralRepresentationWeaveSum
844 : forall {IS : IntegrationSpace}
845 (a b : @IntegralRepresentation IS),
846 IntegralSeries (IntegralRepresentationWeave a b)
847 == IntegralSeries a + IntegralSeries b.
848 Proof.
849 intros.
850 apply (series_cv_unique
851 (fun n => I IS (IntFn (IntegralRepresentationWeave a b) n)
852 (IntFnL (IntegralRepresentationWeave a b) n) )).
853 apply IntegralCv. simpl.
854 apply (series_cv_eq
855 (weaveSequences (CRcarrier (RealT (ElemFunc IS)))
856 (fun n => I IS (IntFn a n) (IntFnL a n))
857 (fun n => I IS (IntFn b n) (IntFnL b n)))).
858 intro n. unfold weaveSequences, weaveSequencesL.
859 destruct (Nat.even n); reflexivity.
860 apply weaveInfiniteSums; apply IntegralCv.
861 Qed.
862
863 Definition IntegralRepresentationScaleHalf
864 {IS : IntegrationSpace}
865 (f : PartialFunction (X (ElemFunc IS)))
866 (a : CRcarrier (RealT (ElemFunc IS)))
867 : IntegrableFunction f
868 -> @IntegralRepresentation IS.
869 Proof.
870 intros. destruct X.
871 apply (Build_IntegralRepresentation
872 IS (fun n:nat => Xscale a (IntFn x n))
873 (fun n:nat => LscaleStable _ a (IntFn x n) (IntFnL x n))
874 (IntAbsSum x * CRabs _ a)).
875 apply (series_cv_eq
876 (fun n => (Iabs (IntFn x n) (IntFnL x n)) * CRabs _ a)).
877 intro n. rewrite IabsHomogeneous. apply CRmult_comm.
878 apply series_cv_scale. apply x.
879 Defined.
880
881 (* If f : X -> R is integrable with representation fn, then
882 a*f is integrable with representation a*fn.
883 This works even if a is zero, but in this case we must restrict
884 the domain of the representation, so that it is that of f :
885 we weave fn, -fn with the scaled representation. *)
886 Definition IntegralRepresentationScale
887 {IS : IntegrationSpace}
888 (f : PartialFunction (X (ElemFunc IS)))
889 (a : CRcarrier (RealT (ElemFunc IS)))
890 : IntegrableFunction f
891 -> @IntegralRepresentation IS
892 := fun X => IntegralRepresentationWeave
893 (IntegralRepresentationScaleHalf f a X)
894 (IntegralRepresentationWeave
895 (let (x,_) := X in x)
896 (IntegralRepresentationScaleHalf f (-(1)) X)).
897
898 Definition IntegralRepresentationScaleInj
899 {IS : IntegrationSpace}
900 (f : PartialFunction (X (ElemFunc IS)))
901 (a : CRcarrier (RealT (ElemFunc IS)))
902 (fInt : IntegrableFunction f)
903 : PartialRestriction
904 (XinfiniteSumAbs (IntFn (IntegralRepresentationScale f a fInt)))
905 (Xscale a f).
906 Proof.
907 split.
908 - (* Domain inclusion *)
909 intros x xd.
910 destruct fInt as [[fn fnL] [injF resF]];
911 unfold IntegralRepresentationScale, IntFn in x;
912 unfold IntegralRepresentationScale, IntFn;
913 simpl in injF, resF.
914 (* By subsequence, x is in the domain of abs fn. *)
915 pose proof (domainInfinSumWeaveR _ _ _ x xd) as y.
916 pose proof (domainInfinSumWeaveL _ _ _ x y) as z.
917 exact (injF x z).
918 - intros.
919 apply (applyInfiniteSumAbs _ _ x).
920 destruct fInt as [[fn fnL] [injF resF]];
921 unfold IntegralRepresentationScale, IntFn in x;
922 unfold IntegralRepresentationScale, IntFn;
923 simpl in injF, resF.
924 pose proof (domainInfinSumWeaveR _ _ _ x xD) as y.
925 pose proof (domainInfinSumWeaveL _ _ _ x y) as z.
926 apply (series_cv_eq
927 (weaveSequences
928 _
929 (fun n : nat => (partialApply (fn n) x
930 (domainInfiniteSumAbsIncReverse _ x z n))
931 * a)
932 (weaveSequences
933 _ (fun n : nat => partialApply (fn n) x
934 (domainInfiniteSumAbsIncReverse _ x z n))
935 (fun n : nat => CRopp _ (partialApply (fn n) x
936 (domainInfiniteSumAbsIncReverse _ x z n)))))).
937 + intro n.
938 pose proof (domainInfinSumWeaveL _ _ _ x xD) as t.
939 rewrite (partialApplyWeave
940 _ _ _ n x
941 (domainInfiniteSumAbsIncReverse _ x t (n/2))
942 (domainInfiniteSumAbsIncReverse _ x y (n/2))).
943 unfold weaveSequences. destruct (Nat.even n).
944 rewrite CRmult_comm. rewrite <- applyXscale. apply DomainProp.
945 pose proof (partialApplyWeave _ fn (fun n => Xscale (CRopp _ 1) (fn n)) (n/2) x
946 (domainInfiniteSumAbsIncReverse fn x z (n / 2 / 2))
947 (domainInfiniteSumAbsIncReverse
948 fn x z (n / 2 / 2))).
949 rewrite H. destruct (Nat.even (n / 2)). reflexivity.
950 rewrite applyXscale. rewrite <- CRopp_mult_distr_l.
951 rewrite CRmult_1_l. unfold IntFn. reflexivity.
952 + rewrite <- (CRplus_0_r (partialApply (Xscale a f) x xG)).
953 rewrite <- (CRplus_opp_r (partialApply (XinfiniteSumAbs fn) x z)).
954 apply weaveInfiniteSums. rewrite applyXscale.
955 rewrite CRmult_comm. apply series_cv_scale.
956 apply applyInfiniteSumAbs. apply resF.
957 apply weaveInfiniteSums.
958 apply applyInfiniteSumAbs. reflexivity.
959 apply series_cv_opp. apply applyInfiniteSumAbs. reflexivity.
960 Qed.
961
962 Definition IntegrableScale {IS : IntegrationSpace}
963 (f : PartialFunction (X (ElemFunc IS)))
964 (a : CRcarrier (RealT (ElemFunc IS)))
965 : IntegrableFunction f
966 -> IntegrableFunction (Xscale a f).
967 Proof.
968 intros fInt.
969 exists (IntegralRepresentationScale f a fInt).
970 exact (IntegralRepresentationScaleInj f a fInt).
971 Defined.
972
973 Lemma minusOneNotZero : forall {R : ConstructiveReals}, CRopp R 1 <> 0.
974 Proof.
975 intros R absurd. pose proof (CRzero_lt_one R).
976 apply (CRplus_lt_compat_l _ (CRopp R 1)) in H.
977 rewrite CRplus_opp_l, CRplus_0_r in H.
978 rewrite absurd in H. exact (CRlt_asym _ _ H H).
979 Qed.
980
981 Definition IntegrableMinus
982 {IS : IntegrationSpace}
983 {f : PartialFunction (X (ElemFunc IS))}
984 {g : PartialFunction (X (ElemFunc IS))}
985 : IntegrableFunction f
986 -> IntegrableFunction g
987 -> IntegrableFunction (Xminus f g).
988 Proof.
989 intros fInt gInt.
990 exact (IntegrablePlus f (Xscale (-(1)) g) fInt
991 (IntegrableScale g (-(1)) gInt)).
992 Defined.
993
994 Lemma splitInfiniteSumMaj
995 : forall {R : ConstructiveReals} (u : nat -> CRcarrier R)
996 (a s : CRcarrier R),
997 series_cv u s
998 -> a < s
999 -> { N : nat | CRltProp R (a + s - CRsum u N) (CRsum u N) }.
1000 Proof.
1001 intros.
1002 destruct (Un_cv_nat_real _ s H ((s - a) * CR_of_Q R (1 # 2))) as [N H1].
1003 + apply CRmult_lt_0_compat. rewrite <- (CRplus_opp_r a).
1004 apply CRplus_lt_compat_r. exact H0.
1005 apply CR_of_Q_lt. reflexivity.
1006 + exists N. specialize (H1 N (Nat.le_refl N)).
1007 rewrite CRabs_minus_sym in H1.
1008 apply (CRle_lt_trans (s - CRsum u N)) in H1.
1009 apply (CRmult_lt_compat_r (CR_of_Q R 2)) in H1.
1010 rewrite CRmult_assoc in H1.
1011 rewrite <- CR_of_Q_mult in H1.
1012 setoid_replace ((1 # 2) * 2)%Q with 1%Q in H1. 2: reflexivity.
1013 rewrite CRmult_1_r in H1.
1014 assert ((s - CRsum u N) * CR_of_Q R 2 == s + s - CRsum u N -CRsum u N).
1015 { rewrite (CR_of_Q_plus R 1 1), CRmult_plus_distr_l.
1016 rewrite CRmult_1_r. unfold CRminus. do 3 rewrite CRplus_assoc.
1017 apply CRplus_morph. reflexivity. rewrite CRplus_comm, CRplus_assoc.
1018 reflexivity. }
1019 rewrite H2 in H1. unfold CRminus in H1. apply (CRplus_lt_compat_l _ (-s)) in H1.
1020 rewrite <- CRplus_assoc, <- CRplus_assoc in H1. rewrite <- CRplus_assoc in H1.
1021 rewrite CRplus_opp_l in H1. rewrite CRplus_0_l in H1.
1022 rewrite <- CRplus_assoc in H1. rewrite CRplus_opp_l in H1. rewrite CRplus_0_l in H1.
1023 apply (CRplus_lt_compat_l _ a) in H1. rewrite CRplus_opp_r in H1.
1024 apply (CRplus_lt_compat_r (CRsum u N)) in H1. rewrite CRplus_assoc in H1.
1025 rewrite CRplus_assoc in H1. rewrite CRplus_opp_l in H1. rewrite CRplus_0_r in H1.
1026 rewrite CRplus_0_l in H1. rewrite <- CRplus_assoc in H1.
1027 apply CRltForget. assumption.
1028 apply CR_of_Q_lt. reflexivity. apply CRle_abs.
1029 Qed.
1030
1031 Lemma sumPosNegPart : forall {R : ConstructiveReals} (x : CRcarrier R),
1032 CRabs _ x == (CRmax 0 x) + CRmax 0 (-x).
1033 Proof.
1034 split.
1035 - apply (CRplus_le_reg_l (-CRmax 0 x)).
1036 rewrite <- CRplus_assoc, CRplus_opp_l, CRplus_0_l.
1037 apply CRmax_lub. apply (CRplus_le_reg_l (CRmax 0 x)).
1038 rewrite CRplus_0_r, <- CRplus_assoc, CRplus_opp_r, CRplus_0_l.
1039 apply CRmax_lub. apply CRabs_pos. apply CRle_abs.
1040 apply (CRplus_le_reg_l (CRmax 0 x + x)).
1041 rewrite CRplus_assoc, CRplus_opp_r, CRplus_0_r.
1042 rewrite (CRplus_comm (CRmax 0 x)), CRplus_assoc.
1043 rewrite <- (CRplus_assoc (CRmax 0 x)), CRplus_opp_r, CRplus_0_l.
1044 apply CRmax_lub. apply (CRplus_le_reg_l (-x)).
1045 rewrite CRplus_0_r, <- CRplus_assoc, CRplus_opp_l, CRplus_0_l.
1046 rewrite <- CRabs_opp. apply CRle_abs.
1047 rewrite <- (CRplus_0_r x). rewrite CRplus_assoc.
1048 apply CRplus_le_compat_l. rewrite CRplus_0_l. apply CRabs_pos.
1049 - apply CRabs_le. split.
1050 + apply (CRplus_le_reg_l (CRmax 0 (-x) - x)).
1051 unfold CRminus. rewrite CRplus_assoc, CRplus_assoc, CRplus_opp_l.
1052 rewrite CRplus_0_r. rewrite <- CRplus_assoc, (CRplus_comm), CRopp_plus_distr.
1053 rewrite CRplus_assoc, <- (CRplus_assoc (-CRmax 0 (-x))).
1054 rewrite CRplus_opp_l, CRplus_0_l.
1055 apply (CRle_trans _ (-x)). 2: apply CRmax_r.
1056 apply (CRplus_le_reg_l (CRmax 0 x)).
1057 rewrite <- CRplus_assoc, CRplus_opp_r, CRplus_0_l.
1058 rewrite <- (CRplus_0_l (-x)), <- CRplus_assoc. apply CRplus_le_compat_r.
1059 rewrite CRplus_0_r. apply CRmax_l.
1060 + apply (CRle_trans _ (x + CRmax 0 (-x))).
1061 rewrite <- (CRplus_0_r x). rewrite CRplus_assoc.
1062 apply CRplus_le_compat_l. rewrite CRplus_0_l.
1063 apply CRmax_l. apply CRplus_le_compat. apply CRmax_r.
1064 apply CRle_refl.
1065 Qed.
1066
1067 Lemma minusPosNegPart : forall {R : ConstructiveReals} (x : CRcarrier R),
1068 x == (CRmax 0 x) - (CRmax 0 (-x)).
1069 Proof.
1070 split.
1071 - apply (CRplus_le_reg_l (CRmax 0 (-x))).
1072 rewrite CRplus_comm. unfold CRminus.
1073 rewrite CRplus_assoc, CRplus_opp_l, CRplus_0_r.
1074 apply CRmax_lub. apply (CRplus_le_reg_l (-x)).
1075 rewrite CRplus_0_r, CRplus_comm, CRplus_assoc, CRplus_opp_r, CRplus_0_r.
1076 apply CRmax_r. apply (CRplus_le_reg_l (-x)).
1077 rewrite CRplus_opp_l, CRplus_comm, CRplus_assoc, CRplus_opp_r, CRplus_0_r.
1078 apply CRmax_l.
1079 - apply (CRplus_le_reg_l (CRmax 0 (-x) - x)).
1080 unfold CRminus. rewrite CRplus_assoc, CRplus_opp_l, CRplus_0_r.
1081 rewrite CRplus_comm, CRplus_assoc, <- (CRplus_assoc (-CRmax 0 (-x))).
1082 rewrite CRplus_opp_l, CRplus_0_l.
1083 apply CRmax_lub. apply (CRplus_le_reg_l x).
1084 rewrite CRplus_0_r, CRplus_comm, CRplus_assoc, CRplus_opp_l, CRplus_0_r.
1085 apply CRmax_r.
1086 rewrite <- (CRplus_0_l (-x)). rewrite <- CRplus_assoc.
1087 apply CRplus_le_compat_r. rewrite CRplus_0_r. apply CRmax_l.
1088 Qed.
1089
1090 Lemma infiniteSumPosNegParts
1091 : forall {R : ConstructiveReals} (X : Set)
1092 (fn : nat -> PartialFunction X)
1093 (x : X)
1094 (xn : forall n:nat, Domain (fn n) x)
1095 (pos neg : CRcarrier R),
1096 series_cv (fun n => CRmax 0 (partialApply (fn n) x (xn n))) pos
1097 -> series_cv (fun n => CRmax 0 (- partialApply (fn n) x (xn n))) neg
1098 -> series_cv (fun n => partialApply (fn n) x (xn n)) (pos - neg).
1099 Proof.
1100 intros. apply (series_cv_scale (-(1)) neg) in H0.
1101 apply (series_cv_plus (fun n : nat => CRmax 0 (partialApply (fn n) x (xn n)))
1102 (fun n : nat =>
1103 (CRmax 0 (- partialApply (fn n) x (xn n)) * -(1)))
1104 pos (neg * -(1)) H) in H0. assert (pos + neg * -(1) == pos - neg).
1105 rewrite <- CRopp_mult_distr_r, CRmult_1_r. reflexivity.
1106 rewrite H1 in H0. apply (series_cv_eq (fun n : nat =>
1107 (CRmax 0 (partialApply (fn n) x (xn n)) +
1108 CRmax 0 (- partialApply (fn n) x (xn n)) * -(1)))
1109 (fun n : nat => partialApply (fn n) x (xn n))).
1110 intro n. rewrite <- (CRopp_mult_distr_r _ 1). rewrite CRmult_1_r.
1111 symmetry. apply minusPosNegPart. apply H0.
1112 Qed.
1113
1114 Lemma splitSumAbsPosNeg
1115 : forall {R : ConstructiveReals} (X : Set)
1116 (fn : nat -> PartialFunction X)
1117 (x : X)
1118 (xn : forall n:nat, Domain (fn n) x)
1119 (A : CRcarrier R),
1120 series_cv (fun n => CRabs _ (partialApply (fn n) x (xn n))) A
1121 -> prod { pos : CRcarrier R &
1122 prod (pos <= A)
1123 (series_cv (fun n => CRmax 0 (partialApply (fn n) x (xn n))) pos) }
1124 { neg : CRcarrier R &
1125 prod (neg <= A)
1126 (series_cv (fun n => CRmax 0 (- partialApply (fn n) x (xn n))) neg) }.
1127 Proof.
1128 intros. split.
1129 - destruct (series_cv_maj
1130 (fun n => CRmax 0 (partialApply (fn n) x (xn n)))
1131 (fun n : nat => CRabs _ (partialApply (fn n) x (xn n)))
1132 A) as [l cvl].
1133 intro n. simpl. rewrite CRabs_right.
1134 apply CRmax_lub. apply CRabs_pos.
1135 apply CRle_abs. apply CRmax_l.
1136 assumption. exists l. split; apply cvl.
1137 - destruct (series_cv_maj
1138 (fun n => CRmax 0 (- partialApply (fn n) x (xn n)))
1139 (fun n : nat => CRabs _ (partialApply (fn n) x (xn n)))
1140 A) as [l cvl].
1141 intro n. simpl.
1142 rewrite CRabs_right. apply CRmax_lub. apply CRabs_pos.
1143 rewrite <- CRabs_opp. apply CRle_abs. apply CRmax_l.
1144 assumption. exists l. split; apply cvl.
1145 Qed.
1146
1147 Lemma applyPlusTruncated
1148 : forall {IS : IntegrationSpace}
1149 (f : PartialFunction (X (ElemFunc IS)))
1150 (n M : nat)
1151 (x : X (ElemFunc IS))
1152 (pF : Domain f x)
1153 (pS : Domain (Xplus (XposPart f)
1154 (if le_dec n M then Izero IS
1155 else XnegPart f)) x),
1156 partialApply _ x pS
1157 == (CRmax 0 (partialApply f x pF)
1158 + (if le_dec n M then 0
1159 else CRmax 0 (- partialApply f x pF))).
1160 Proof.
1161 intros. destruct (le_dec n M).
1162 - rewrite CRplus_0_r. destruct pS.
1163 rewrite (applyXplus (XposPart f) (Izero IS)).
1164 unfold Izero. rewrite applyXscale, CRmult_0_l.
1165 rewrite <- (DomainProp (XposPart f) x (pF, pF)).
1166 rewrite applyXposPart. rewrite CRplus_0_r. reflexivity.
1167 - destruct pS. rewrite (applyXplus (XposPart f) (XnegPart f)).
1168 apply CRplus_morph.
1169 rewrite <- (DomainProp (XposPart f) x (pF, pF)).
1170 rewrite applyXposPart. reflexivity.
1171 rewrite <- (DomainProp (XnegPart f) x (pF, pF)).
1172 rewrite applyXnegPart. reflexivity.
1173 Qed.
1174
1175 Lemma splitIntegralPosNeg
1176 : forall {IS : IntegrationSpace}
1177 (f : PartialFunction (X (ElemFunc IS)))
1178 (fL : L (ElemFunc IS) f),
1179 I IS f fL
1180 == (I IS (XposPart f) (LposPartStable f fL))
1181 - (I IS (XnegPart f) (LnegPartStable f fL)).
1182 Proof.
1183 intros. rewrite <- (CRmult_1_l (I IS (XnegPart f) (LnegPartStable f fL))).
1184 unfold CRminus. rewrite CRopp_mult_distr_l. rewrite <- Ihomogeneous.
1185 rewrite <- Iadditive. apply IExtensional. intros.
1186 destruct y.
1187 rewrite (applyXplus (XposPart f) (Xscale (- (1)) (XnegPart f))).
1188 rewrite applyXscale.
1189 unfold XposPart, XnegPart. do 2 rewrite applyXscale.
1190 destruct d. rewrite (applyXplus f (Xabs f) x).
1191 destruct d0. rewrite (applyXminus (Xabs f) f).
1192 do 2 rewrite applyXabs.
1193 rewrite (DomainProp f x d1 d), (DomainProp f x d2 d),
1194 (DomainProp f x d0 d), (DomainProp f x xF d).
1195 generalize (partialApply f x d). intros.
1196 rewrite <- CRopp_mult_distr_l, CRmult_1_l.
1197 rewrite CRopp_mult_distr_r, <- CRmult_plus_distr_l.
1198 setoid_replace (c + CRabs _ c + - (CRabs _ c + - c))
1199 with (CR_of_Q _ 2 * c).
1200 rewrite <- CRmult_assoc, <- CR_of_Q_mult.
1201 setoid_replace ((1 # 2) * 2)%Q with 1%Q.
1202 rewrite CRmult_1_l. reflexivity. reflexivity.
1203 rewrite (CR_of_Q_plus _ 1 1), CRmult_plus_distr_r.
1204 rewrite CRmult_1_l, CRplus_assoc. apply CRplus_morph. reflexivity.
1205 rewrite CRopp_plus_distr, <- CRplus_assoc, CRplus_opp_r.
1206 rewrite CRplus_0_l, CRopp_involutive. reflexivity.
1207 Qed.
1208
1209 Lemma splitIntegralSumPosNeg
1210 : forall {IS : IntegrationSpace}
1211 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1212 (fnL : forall n:nat, L (ElemFunc IS) (fn n))
1213 (sumAbsIFn : CRcarrier (RealT (ElemFunc IS))),
1214 (series_cv (fun n => Iabs (fn n) (fnL n)) sumAbsIFn)
1215 -> { sumIPosFn : CRcarrier _ & { sumINegFn : CRcarrier _ &
1216 series_cv (fun n0 : nat =>
1217 I IS (XposPart (fn n0))
1218 (LposPartStable (fn n0) (fnL n0))) sumIPosFn
1219 * series_cv (fun n0 : nat =>
1220 I IS (XnegPart (fn n0))
1221 (LnegPartStable (fn n0) (fnL n0))) sumINegFn
1222 * series_cv (fun n => I IS (fn n) (fnL n)) (sumIPosFn - sumINegFn) }}%type.
1223 Proof.
1224 intros. (* The sum of I fn+ converges *)
1225 destruct (series_cv_maj
1226 (fun n0 : nat =>
1227 I IS (XposPart (fn n0))
1228 (LposPartStable (fn n0) (fnL n0)))
1229 (fun n0 : nat => Iabs (fn n0) (fnL n0))
1230 sumAbsIFn) as [sumIPosFn [limPos _]].
1231 { intro n.
1232 apply (CRle_trans _ (Iabs (XposPart (fn n)) (LposPartStable (fn n) (fnL n)))).
1233 apply integralAbsMaj. apply INonDecreasing. intros.
1234 rewrite applyXabs, CRabs_right.
1235 2: apply applyXposPartNonNeg.
1236 rewrite <- (DomainProp (XposPart (fn n)) x (y, y)).
1237 rewrite (applyXposPart (fn n)). rewrite applyXabs.
1238 apply CRmax_lub. apply CRabs_pos. apply CRle_abs. }
1239 assumption.
1240
1241 (* The sum of I fn- converges *)
1242 destruct (series_cv_maj
1243 (fun n0 : nat =>
1244 I IS (XnegPart (fn n0))
1245 (LnegPartStable (fn n0) (fnL n0)))
1246 (fun n0 : nat => Iabs (fn n0) (fnL n0))
1247 sumAbsIFn) as [sumINegFn [limNeg _]].
1248 { intro n.
1249 apply (CRle_trans _ (Iabs (XnegPart (fn n)) (LnegPartStable (fn n) (fnL n)))).
1250 apply integralAbsMaj. apply INonDecreasing. intros.
1251 rewrite applyXabs, CRabs_right.
1252 2: apply XnegPartNonNeg.
1253 rewrite <- (DomainProp (XnegPart (fn n)) x (y,y)).
1254 rewrite (applyXnegPart (fn n)). rewrite applyXabs.
1255 apply CRmax_lub. apply CRabs_pos.
1256 rewrite <- CRabs_opp. apply CRle_abs. }
1257 apply H.
1258
1259 exists sumIPosFn. exists sumINegFn. repeat split. assumption. assumption.
1260 apply (series_cv_scale (-(1)) sumINegFn) in limNeg.
1261 apply (series_cv_plus (fun n0 : nat =>
1262 I IS (XposPart (fn n0))
1263 (LposPartStable (fn n0) (fnL n0)))
1264 (fun n : nat =>
1265 (I IS (XnegPart (fn n))
1266 (LnegPartStable (fn n) (fnL n)) * -(1)))
1267 sumIPosFn (sumINegFn * -(1)) limPos)
1268 in limNeg.
1269 apply (series_cv_eq (fun n : nat =>
1270 (I IS (XposPart (fn n))
1271 (LposPartStable (fn n) (fnL n)) +
1272 I IS (XnegPart (fn n))
1273 (LnegPartStable (fn n) (fnL n)) * -(1)))
1274 (fun n : nat => I IS (fn n) (fnL n)))
1275 in limNeg.
1276 apply (CR_cv_proper _ (sumIPosFn + sumINegFn * - (1))).
1277 exact limNeg. rewrite <- CRopp_mult_distr_r, CRmult_1_r. reflexivity.
1278 intro n.
1279 assert ((I IS (XposPart (fn n))
1280 (LposPartStable (fn n) (fnL n)) +
1281 I IS (XnegPart (fn n))
1282 (LnegPartStable (fn n) (fnL n)) * -(1))
1283 == (I IS (XposPart (fn n))
1284 (LposPartStable (fn n) (fnL n)) -
1285 I IS (XnegPart (fn n))
1286 (LnegPartStable (fn n) (fnL n)))).
1287 rewrite <- CRopp_mult_distr_r, CRmult_1_r. reflexivity.
1288 rewrite H0. clear H0. rewrite <- splitIntegralPosNeg. reflexivity.
1289 Qed.
1290
1291 Definition domainPlusPosPartInc {R : ConstructiveReals} (X : Set)
1292 (f g : @PartialFunction R X)
1293 (x : X)
1294 (xD : Domain (Xplus (XposPart f) g) x)
1295 : Domain f x.
1296 Proof.
1297 destruct f,g,xD; simpl. exact (fst d).
1298 Qed.
1299
1300 (* Workaround destruct that no longer works *)
1301 Lemma series_cv_abs_le
1302 : forall {R : ConstructiveReals} (un : nat -> CRcarrier R) (a : CRcarrier R)
1303 (cau : CR_cauchy R (CRsum (fun n => CRabs R (un n)))),
1304 CRle R a (let (c,_) := series_cv_abs un cau in c)
1305 -> { l : CRcarrier R & prod (CRle R a l) (series_cv un l) }.
1306 Proof.
1307 intros. destruct (series_cv_abs un cau). exists x.
1308 split; assumption.
1309 Qed.
1310
1311 (* This is the generalization of INonDecreasing
1312 from L-functions to integrable functions. *)
1313 Lemma representationPositive
1314 : forall {IS : IntegrationSpace}
1315 (fInt : @IntegralRepresentation IS),
1316 nonNegFunc (XinfiniteSumAbs (IntFn fInt))
1317 -> 0 <= IntegralSeries fInt.
1318 Proof.
1319 (* To use Icontinuity, we fallback to positive functions
1320 by taking XposParts and XnegParts. *)
1321 intros IS [fn fnL sumAbsIFn H] H0.
1322 destruct (splitIntegralSumPosNeg fn fnL sumAbsIFn H)
1323 as [sumIPosFn [sumINegFn [[limPos limNeg] splitIntegral]]].
1324 setoid_replace (IntegralSeries {| IntFn := fn; IntFnL := fnL; IntAbsSum := sumAbsIFn; IntAbsSumCv := H |})
1325 with (sumIPosFn - sumINegFn).
1326
1327 rewrite <- (CRplus_opp_r sumINegFn).
1328 apply CRplus_le_compat. 2: apply CRle_refl. intro absurd.
1329
1330 (* Truncate XinfiniteSumAbs _ (fun n:nat => XnegPart _ (fn n))
1331 to a finite sum, to keep an L-function. *)
1332 destruct (splitInfiniteSumMaj (fun n : nat =>
1333 I IS (XnegPart (fn n))
1334 (LnegPartStable (fn n) (fnL n)))
1335 sumIPosFn sumINegFn limNeg)
1336 as [M H1].
1337 assumption.
1338
1339 destruct
1340 (Icontinuous IS
1341 (Xsum (fun n:nat => XnegPart (fn n)) M)
1342 (fun n:nat => Xplus (XposPart (fn n))
1343 match le_dec n M with
1344 | left _ => Izero IS
1345 | _ => XnegPart (fn n)
1346 end)
1347 (LsumStable (fun n : nat => XnegPart (fn n))
1348 (fun n => LnegPartStable (fn n) (fnL n))
1349 M)
1350 (fun n:nat => LplusStable (ElemFunc IS)
1351 (XposPart (fn n))
1352 (match le_dec n M with
1353 | left _ => Izero IS
1354 | _ => XnegPart (fn n)
1355 end)
1356 (LposPartStable (fn n) (fnL n))
1357 (if le_dec n M as s return (L (ElemFunc IS) (if s then Izero IS else XnegPart (fn n)))
1358 then
1359 Izero_is_L IS
1360 else LnegPartStable (fn n) (fnL n)))
1361 )
1362 as [[x xS xdfn] [sumPosNegFX [H2 H3]]].
1363 - (* non neg func *)
1364 intros. intros z xdf.
1365 destruct (le_dec n M). destruct xdf.
1366 rewrite (applyXplus (XposPart (fn n)) (Izero IS)), <- (CRplus_0_r 0).
1367 apply CRplus_le_compat. apply applyXposPartNonNeg.
1368 rewrite applyIzero. apply CRle_refl. destruct xdf.
1369 rewrite (applyXplus (XposPart (fn n)) (XnegPart (fn n))), <- (CRplus_0_r 0).
1370 apply CRplus_le_compat. apply applyXposPartNonNeg.
1371 apply XnegPartNonNeg.
1372 - (* limit lt *)
1373 exists (sumIPosFn + (sumINegFn
1374 - CRsum
1375 (fun n : nat =>
1376 I IS (XnegPart (fn n))
1377 (LnegPartStable (fn n) (fnL n))) M)).
1378 split.
1379 + apply (series_cv_eq
1380 (fun n : nat => I IS (XposPart (fn n))
1381 (LposPartStable (fn n) (fnL n))
1382 + (I IS (if le_dec n M then Izero IS else XnegPart (fn n))
1383 (if le_dec n M as s
1384 return (L (ElemFunc IS) (if s then Izero IS else XnegPart (fn n)))
1385 then Izero_is_L IS
1386 else LnegPartStable (fn n) (fnL n))))).
1387 intros. rewrite Iadditive. reflexivity.
1388 apply series_cv_plus. assumption.
1389 apply (series_cv_eq (fun n : nat =>
1390 if le_dec n M then 0
1391 else I IS (XnegPart (fn n))
1392 (LnegPartStable (fn n) (fnL n)))).
1393 intros. destruct (le_dec n M). rewrite Izero_is_zero. reflexivity. reflexivity.
1394 apply infinite_sum_truncate_below. assumption.
1395 + rewrite IadditiveIterate. unfold CRminus.
1396 rewrite <- CRplus_assoc. apply CRltEpsilon. assumption.
1397 - (* Now we have x, prove that sum |fn x| converges. *)
1398 pose proof (fun n:nat => domainPlusPosPartInc _ _ _ x (xdfn n)) as pxn.
1399
1400 (* Simplify H2 *)
1401 apply (series_cv_eq (fun n : nat =>
1402 partialApply
1403 (Xplus (XposPart (fn n))
1404 (if le_dec n M then Izero IS else XnegPart (fn n))) x
1405 (xdfn n))
1406 (fun n : nat =>
1407 CRmax 0 (partialApply (fn n) x (pxn n))
1408 + (if le_dec n M then 0
1409 else CRmax 0 (- partialApply (fn n) x (pxn n)))))
1410 in H2.
1411 assert (series_cv (fun n : nat =>
1412 (if le_dec n M then CRmax 0 (- partialApply (fn n) x (pxn n))
1413 else 0))
1414 (CRsum (fun k => CRmax 0 (- partialApply (fn k) x (pxn k))) M)).
1415 { intros eps. exists M. intros. rewrite sum_truncate_above.
1416 unfold CRminus. rewrite CRplus_opp_r.
1417 rewrite CRabs_right. apply CR_of_Q_le.
1418 discriminate. apply CRle_refl. exact H4. }
1419 apply (series_cv_plus (fun n : nat =>
1420 (CRmax 0 (partialApply (fn n) x (pxn n)) +
1421 (if le_dec n M then 0 else CRmax 0 (- partialApply (fn n) x (pxn n)))))
1422 (fun n : nat =>
1423 if le_dec n M then CRmax 0 (- partialApply (fn n) x (pxn n)) else 0)
1424 sumPosNegFX (CRsum (fun k => CRmax 0 (- partialApply (fn k) x (pxn k))) M)
1425 H2)
1426 in H4.
1427 apply (series_cv_eq (fun n : nat =>
1428 (CRmax 0 (partialApply (fn n) x (pxn n)) +
1429 (if le_dec n M then 0 else CRmax 0 (- partialApply (fn n) x (pxn n))) +
1430 (if le_dec n M then CRmax 0 (- partialApply (fn n) x (pxn n)) else 0)))
1431 (fun n : nat => CRabs _ (partialApply (fn n) x (pxn n))))
1432 in H4.
1433
1434 (* Deduce that sum fn x >= 0 *)
1435 unfold nonNegFunc in H0.
1436 pose proof (domainInfiniteSumAbsInc fn x pxn
1437 (sumPosNegFX +
1438 CRsum (fun k : nat => CRmax 0 (- partialApply (fn k) x (pxn k))) M)
1439 H4)
1440 as y.
1441 specialize (H0 x y). destruct y as [yn ycv]; simpl in H0.
1442 apply series_cv_abs_le in H0. destruct H0 as [sumFX [H0 i]].
1443
1444 destruct (splitSumAbsPosNeg _ fn x pxn
1445 (sumPosNegFX +
1446 CRsum (fun k : nat => CRmax 0 (- partialApply (fn k) x (pxn k))) M)
1447 H4) as [H6 H7].
1448 destruct H6 as [sumPosFnX [H6 limPosX]].
1449 destruct H7 as [sumNegFnX [H7 limNegX]].
1450
1451 assert (sumPosFnX < sumNegFnX).
1452 { apply (CRle_lt_trans sumPosFnX sumPosNegFX).
1453 apply (series_cv_scale (-(1)) sumPosFnX) in limPosX.
1454 apply (series_cv_plus (fun n : nat =>
1455 (CRmax 0 (partialApply (fn n) x (pxn n)) +
1456 (if le_dec n M then 0 else CRmax 0 (- partialApply (fn n) x (pxn n)))))
1457 (fun n : nat => (CRmax 0 (partialApply (fn n) x (pxn n)) * -(1)))
1458 sumPosNegFX (sumPosFnX * -(1)))
1459 in limPosX.
1460 apply series_cv_nonneg in limPosX.
1461 assert (sumPosFnX * (-(1)) == - sumPosFnX) as H8.
1462 rewrite <- CRopp_mult_distr_r, CRmult_1_r. reflexivity.
1463 rewrite H8 in limPosX. apply (CRplus_le_compat_l sumPosFnX) in limPosX.
1464 simpl in limPosX. unfold CRminus in limPosX.
1465 rewrite CRplus_0_r, CRplus_comm, CRplus_assoc, CRplus_opp_l, CRplus_0_r
1466 in limPosX.
1467 exact limPosX.
1468 intro n. assert (CRmax 0 (partialApply (fn n) x (pxn n)) +
1469 (if le_dec n M then 0 else CRmax 0 (- partialApply (fn n) x (pxn n))) +
1470 CRmax 0 (partialApply (fn n) x (pxn n)) * -(1)
1471 == (if le_dec n M then 0 else CRmax 0 (- partialApply (fn n) x (pxn n)))) as H8.
1472 rewrite <- CRopp_mult_distr_r, CRmult_1_r, CRplus_comm, <- CRplus_assoc.
1473 rewrite CRplus_opp_l, CRplus_0_l. reflexivity.
1474 rewrite H8. destruct (le_dec n M). apply CRle_refl.
1475 apply CRmax_l. assumption.
1476 apply (CRlt_le_trans sumPosNegFX (partialApply
1477 (Xsum (fun n : nat => XnegPart (fn n)) M) x xS)).
1478 assumption.
1479
1480 pose proof (fun n:nat => pair (pxn n) (pxn n)) as pxnn.
1481 rewrite (applyXsum (fun n : nat => XnegPart (fn n)) M x _ pxnn).
1482 rewrite <- (CRsum_eq (fun n:nat => CRmax 0 (- partialApply (fn n) x (pxn n)))).
1483 apply growing_ineq. intros p. simpl.
1484 rewrite <- CRplus_0_r, CRplus_assoc. apply CRplus_le_compat_l.
1485 rewrite CRplus_0_l.
1486 apply CRmax_l. assumption. intros.
1487 rewrite <- (applyXnegPart (fn i0)). apply DomainProp. }
1488
1489 assert (sumFX == sumPosFnX - sumNegFnX).
1490 { apply (CR_cv_unique (CRsum (fun k : nat => partialApply (fn k) x (pxn k)))).
1491 apply (series_cv_eq (fun k : nat => partialApply (fn k) x (yn k))).
1492 intro n. apply DomainProp. apply i.
1493 apply infiniteSumPosNegParts. assumption. assumption. }
1494 rewrite H8 in H0.
1495 apply (CRplus_le_compat_l sumNegFnX) in H0.
1496 unfold CRminus in H0.
1497 rewrite CRplus_0_r, CRplus_comm, CRplus_assoc, CRplus_opp_l, CRplus_0_r in H0.
1498 apply H0. assumption.
1499
1500 intros. destruct (le_dec n M). rewrite sumPosNegPart.
1501 rewrite CRplus_0_r. reflexivity.
1502 rewrite sumPosNegPart. rewrite CRplus_0_r.
1503 reflexivity. intro n. apply applyPlusTruncated.
1504 - apply (CR_cv_unique (CRsum (fun n : nat => I IS (fn n) (fnL n)))).
1505 simpl.
1506 destruct (series_cv_maj (fun n : nat => I IS (fn n) (fnL n)) (fun k : nat => Iabs (fn k) (fnL k))
1507 sumAbsIFn (fun n : nat => integralAbsMaj (fn n) (fnL n)) H).
1508 apply p. assumption.
1509 Qed.
1510
1511 Lemma IntegralNonNeg : forall {IS : IntegrationSpace}
1512 (f : PartialFunction (X (ElemFunc IS)))
1513 (fInt : IntegrableFunction f),
1514 nonNegFunc f
1515 -> 0 <= Integral fInt.
1516 Proof.
1517 intros. apply representationPositive.
1518 destruct fInt, p. intros y ydf.
1519 rewrite (c y ydf (d y ydf)). apply H.
1520 Qed.
1521
1522 Lemma IntegralHomogeneousHalf
1523 : forall {IS : IntegrationSpace}
1524 (f : PartialFunction (X (ElemFunc IS)))
1525 (fInt : IntegrableFunction f)
1526 (a : CRcarrier (RealT (ElemFunc IS))),
1527 IntegralSeries (IntegralRepresentationScaleHalf f a fInt)
1528 == (Integral fInt) * a.
1529 Proof.
1530 intros. destruct fInt.
1531 apply (series_cv_unique (fun n0 : nat => (I IS (IntFn x n0) (IntFnL x n0)) * a)).
1532 - apply (series_cv_eq (fun n:nat => I IS (Xscale a (IntFn x n))
1533 (LscaleStable _ a _ (IntFnL x n)))).
1534 intro n. rewrite Ihomogeneous. apply CRmult_comm.
1535 apply (IntegralCv (IntegralRepresentationScaleHalf f a
1536 (existT
1537 (fun fInt : IntegralRepresentation =>
1538 PartialRestriction (XinfiniteSumAbs (IntFn fInt)) f) x p))).
1539 - apply series_cv_scale. simpl. apply (IntegralCv x).
1540 Qed.
1541
1542 Lemma IntegralScale
1543 : forall {IS : IntegrationSpace}
1544 (f : PartialFunction (X (ElemFunc IS)))
1545 (fInt : IntegrableFunction f)
1546 (a : CRcarrier (RealT (ElemFunc IS))),
1547 Integral (IntegrableScale f a fInt)
1548 == (Integral fInt) * a.
1549 Proof.
1550 intros.
1551 unfold IntegrableScale, IntegralRepresentationScale, Integral.
1552 do 2 rewrite IntegralRepresentationWeaveSum.
1553 do 2 rewrite IntegralHomogeneousHalf. unfold Integral.
1554 rewrite <- CRopp_mult_distr_r, CRmult_1_r, CRplus_opp_r.
1555 rewrite CRplus_0_r. reflexivity.
1556 Qed.
1557
1558 (* Base result to prove that integral is extensional *)
1559 Lemma IntegralRepresentationInvariantZero
1560 : forall {IS : IntegrationSpace}
1561 (f : PartialFunction (X (ElemFunc IS)))
1562 (fInt : IntegrableFunction f),
1563 (forall (x : X (ElemFunc IS)) (xD : Domain f x),
1564 partialApply f x xD == 0)
1565 -> Integral fInt == 0.
1566 Proof.
1567 intros. split.
1568 - apply representationPositive.
1569 intros x xdf. destruct fInt,p. rewrite (c x _ (d x xdf)).
1570 rewrite H. apply CRle_refl.
1571 - setoid_replace (Integral fInt)
1572 with (CRopp _ (IntegralSeries (IntegralRepresentationScale _ (-(1)) fInt))).
1573 rewrite <- CRopp_0. apply CRopp_ge_le_contravar.
1574 apply representationPositive.
1575 intros x xdf.
1576 destruct (IntegralRepresentationScaleInj f (-(1)) fInt).
1577 rewrite (c x xdf (d x xdf)).
1578 rewrite applyXscale, H. rewrite CRmult_0_r. apply CRle_refl.
1579 pose proof (IntegralScale f fInt (-(1))).
1580 rewrite H0. rewrite <- CRopp_mult_distr_r, CRmult_1_r, CRopp_involutive.
1581 reflexivity.
1582 Qed.
1583
1584 Lemma IntegralOpp
1585 : forall {IS : IntegrationSpace}
1586 (f : PartialFunction (X (ElemFunc IS)))
1587 (fInt : IntegrableFunction f),
1588 Integral (IntegrableScale f (-(1)) fInt)
1589 == - Integral fInt.
1590 Proof.
1591 intros. rewrite IntegralScale.
1592 rewrite <- CRopp_mult_distr_r, CRmult_1_r. reflexivity.
1593 Qed.
1594
1595 Lemma IntegralPlus
1596 : forall {IS : IntegrationSpace}
1597 (f g : PartialFunction (X (ElemFunc IS)))
1598 (fInt : IntegrableFunction f)
1599 (gInt : IntegrableFunction g),
1600 Integral (IntegrablePlus f g fInt gInt)
1601 == Integral fInt + Integral gInt.
1602 Proof.
1603 intros.
1604 destruct (IntegrablePlus f g fInt gInt)
1605 as [[pn pnL IsumP majP] restrictP] eqn:desP.
1606 destruct fInt as [[fn fnL IsumF majF] restrictF].
1607 destruct gInt as [[gn gnL IsumG majG] restrictG].
1608 simpl.
1609 apply (series_cv_unique
1610 (weaveSequences _ (fun n0 : nat => I IS (fn n0) (fnL n0))
1611 (fun n0 : nat => I IS (gn n0) (gnL n0)))).
1612 simpl in desP.
1613 - (* Prove that weaved sequences converges to IntegrablePlus *)
1614 apply (series_cv_eq (fun n : nat => I IS (pn n) (pnL n))).
1615 + intro n. unfold IntegrablePlus in desP; simpl in desP.
1616 inversion desP. inversion H1. unfold weaveSequences, weaveSequencesL.
1617 destruct (Nat.even n); reflexivity.
1618 + pose proof (IntegralCv
1619 {| IntFn := pn; IntFnL := pnL; IntAbsSum := IsumP; IntAbsSumCv := majP |}).
1620 assumption.
1621 - apply weaveInfiniteSums.
1622 + pose proof (IntegralCv
1623 {| IntFn := fn; IntFnL := fnL; IntAbsSum := IsumF; IntAbsSumCv := majF |}).
1624 assumption.
1625 + pose proof (IntegralCv
1626 {| IntFn := gn; IntFnL := gnL; IntAbsSum := IsumG; IntAbsSumCv := majG |}).
1627 assumption.
1628 Qed.
1629
1630 Lemma IntegralMinus
1631 : forall {IS : IntegrationSpace}
1632 (f g : PartialFunction (X (ElemFunc IS)))
1633 (fInt : IntegrableFunction f)
1634 (gInt : IntegrableFunction g),
1635 Integral (IntegrableMinus fInt gInt)
1636 == Integral fInt - Integral gInt.
1637 Proof.
1638 intros. unfold Xminus. unfold IntegrableMinus.
1639 rewrite IntegralPlus. rewrite IntegralScale.
1640 apply CRplus_morph. reflexivity.
1641 rewrite <- CRopp_mult_distr_r, CRmult_1_r. reflexivity.
1642 Qed.
1643
1644
1645 (* We now come to the invariance of the integral with respect to
1646 the representation of a function f.
1647
1648 In addition, this shows that a countable intersection of
1649 L-functions is also defined almost everywhere : otherwise another
1650 representation defined at more points could change the integral. *)
1651
1652 Lemma IntegralRepresentationInvariant
1653 : forall {IS : IntegrationSpace}
1654 (f : PartialFunction (X (ElemFunc IS)))
1655 (fnInt gnInt : IntegrableFunction f),
1656 Integral fnInt == Integral gnInt.
1657 Proof.
1658 intros.
1659 assert (forall (x : X (ElemFunc IS)) (xD : Domain (Xplus f (Xscale (-(1)) f)) x),
1660 partialApply (Xplus f (Xscale (-(1)) f)) x xD == 0).
1661 { intros. destruct xD.
1662 rewrite (applyXplus f (Xscale (- (1)) f)), applyXscale.
1663 rewrite (DomainProp f x d d0), <- CRopp_mult_distr_l, CRmult_1_l.
1664 apply CRplus_opp_r. }
1665 pose proof (IntegralRepresentationInvariantZero
1666 (Xminus f f)
1667 (IntegrableMinus fnInt gnInt)
1668 H)
1669 as invZero.
1670 rewrite IntegralMinus in invZero.
1671 apply (CRplus_eq_reg_l (-Integral gnInt)).
1672 rewrite CRplus_opp_l, CRplus_comm. exact invZero.
1673 Qed.
1674
1675 Lemma IntegrableMinusMaj
1676 : forall {IS : IntegrationSpace}
1677 (f : PartialFunction (X (ElemFunc IS)))
1678 (fInt : IntegrableFunction f)
1679 (g : PartialFunction (X (ElemFunc IS)))
1680 (gInt : IntegrableFunction g),
1681 PartialRestriction (XinfiniteSumAbs
1682 (IntFn (let (i,_) := IntegrableMinus fInt gInt in i)))
1683 (Xminus f g).
1684 Proof.
1685 intros. apply IntegrablePlusMaj.
1686 Qed.
1687
1688 Lemma IntegralNonDecreasing
1689 : forall {IS : IntegrationSpace}
1690 (f g : PartialFunction (X (ElemFunc IS)))
1691 (fInt : IntegrableFunction f)
1692 (gInt : IntegrableFunction g),
1693 partialFuncLe f g
1694 -> Integral fInt <= Integral gInt.
1695 Proof.
1696 intros.
1697 pose proof (IntegralMinus g f gInt fInt) as intAdd.
1698 apply (CRplus_le_reg_r (- Integral fInt)).
1699 rewrite CRplus_opp_r, <- intAdd.
1700 clear intAdd. apply representationPositive.
1701 intros x xdf.
1702 destruct (IntegrableMinusMaj g gInt f fInt).
1703 rewrite (c x xdf (d x xdf)).
1704 destruct (d x xdf). rewrite (applyXminus g f).
1705 rewrite <- (CRplus_opp_r (partialApply f x d1)).
1706 apply CRplus_le_compat. apply H. apply CRle_refl.
1707 Qed.
1708
1709 Lemma IntegralExtensional
1710 : forall {IS : IntegrationSpace}
1711 (f g : PartialFunction (X (ElemFunc IS)))
1712 (fInt : IntegrableFunction f)
1713 (gInt : IntegrableFunction g),
1714 (forall (x : X (ElemFunc IS)) (xdf : Domain f x) (xdg : Domain g x),
1715 partialApply f x xdf == partialApply g x xdg)
1716 -> Integral fInt == Integral gInt.
1717 Proof.
1718 split.
1719 - apply IntegralNonDecreasing. intros x xdf xdg.
1720 rewrite (H x xdg xdf). apply CRle_refl.
1721 - apply IntegralNonDecreasing. intros x xdf xdg.
1722 rewrite (H x xdf xdg). apply CRle_refl.
1723 Qed.
1724
1725 Definition telescopicOp {R : ConstructiveReals} (X : Set)
1726 (fn : nat -> PartialFunction X)
1727 (op : CRcarrier R -> CRcarrier R)
1728 (opEq : forall x y : CRcarrier R, x == y -> op x == op y)
1729 := fun n:nat => match n with
1730 | O => Xop X (fn O) op opEq
1731 | S p => Xminus (Xop X (Xsum fn n) op opEq)
1732 (Xop X (Xsum fn p) op opEq)
1733 end.
1734
1735 Lemma telescopicOpL : forall {IS : IntegrationSpace}
1736 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1737 (fnL : forall n:nat, L (ElemFunc IS) (fn n))
1738 (op : CRcarrier (RealT (ElemFunc IS))
1739 -> CRcarrier (RealT (ElemFunc IS)))
1740 (opEq : forall x y : CRcarrier (RealT (ElemFunc IS)),
1741 x == y -> op x == op y)
1742 (opL : forall f : PartialFunction (X (ElemFunc IS)),
1743 L (ElemFunc IS) f -> L (ElemFunc IS) (Xop _ f op opEq))
1744 (n : nat),
1745 L (ElemFunc IS) (telescopicOp (X (ElemFunc IS)) fn op opEq n).
1746 Proof.
1747 intros. unfold telescopicOp. destruct n. apply (*LabsStable*) opL. apply fnL.
1748 unfold Xminus. apply LplusStable. apply opL. apply LsumStable. apply fnL.
1749 apply LscaleStable. apply opL. apply LsumStable. apply fnL.
1750 Defined.
1751
1752 Lemma applyTelescopicOpMaj
1753 : forall {R : ConstructiveReals} (X : Set)
1754 (fn : nat -> PartialFunction X)
1755 (op : CRcarrier R -> CRcarrier R)
1756 (opEq : forall x y : CRcarrier R, x == y -> op x == op y)
1757 (contract : forall x y : CRcarrier R,
1758 (CRabs _ (op x - op y)) <= (CRabs _ (x - y)))
1759 (zeroFix : op 0 == 0)
1760 (n : nat)
1761 (x : X)
1762 (pF : Domain (fn n) x)
1763 (pXT : Domain (telescopicOp X fn op opEq n) x),
1764 CRabs _ (partialApply (telescopicOp X fn op opEq n) x pXT)
1765 <= CRabs _ (partialApply (fn n) x pF).
1766 Proof.
1767 intros. unfold telescopicOp. unfold telescopicOp in pXT. destruct n.
1768 - destruct (fn O); simpl.
1769 rewrite <- (CRplus_0_r (partialApply x pF)).
1770 rewrite <- CRopp_0.
1771 rewrite <- (DomainProp x pXT pF).
1772 setoid_replace (op (partialApply x pXT)) with (op (partialApply x pXT) - op 0).
1773 apply contract. rewrite zeroFix. unfold CRminus.
1774 rewrite CRopp_0, CRplus_0_r. reflexivity.
1775 - simpl in pXT. destruct pXT.
1776 rewrite (applyXminus (Xop X (Xsum fn (S n)) op opEq)
1777 (Xop X (Xsum fn n) op opEq)).
1778 simpl.
1779 apply (CRle_trans _ _ _ (contract _ _)).
1780 destruct p. simpl.
1781 destruct (Xsum fn n), (fn (S n)); simpl.
1782 rewrite (DomainProp x d0 d), (DomainProp0 x pF d1).
1783 apply (CRle_trans
1784 _ (CRabs _ ((partialApply x d + partialApply0 x d1) - partialApply x d))).
1785 apply CRle_refl.
1786 rewrite CRplus_comm. unfold CRminus. rewrite CRplus_assoc.
1787 rewrite CRplus_opp_r. rewrite CRplus_0_r. apply CRle_refl.
1788 Qed.
1789
1790 Lemma applyTelescopicOp : forall {R : ConstructiveReals} (X : Set)
1791 (fn : nat -> PartialFunction X)
1792 (op : CRcarrier R -> CRcarrier R)
1793 (opEq : forall x y : CRcarrier R, x == y -> op x == op y)
1794 (n : nat)
1795 (x : X)
1796 (pF : forall n:nat, Domain (fn n) x)
1797 (pXT : forall n:nat, Domain (telescopicOp X fn op opEq n) x),
1798 partialApply (telescopicOp X fn op opEq (S n)) x (pXT (S n))
1799 == op (CRsum (fun n=> partialApply (fn n) x (pF n)) (S n))
1800 - op (CRsum (fun n=> partialApply (fn n) x (pF n)) n).
1801 Proof.
1802 intros. unfold telescopicOp. destruct (pXT (S n)).
1803 rewrite (applyXminus (Xop X (Xsum fn (S n)) op opEq) (Xop X (Xsum fn n) op opEq)).
1804 destruct d; simpl.
1805 apply CRplus_morph. apply opEq.
1806 rewrite (applyXsum fn n x _ pF).
1807 rewrite (DomainProp _ x (pF (S n)) d1). reflexivity.
1808 apply CRopp_morph, opEq. rewrite (applyXsum fn n x _ pF).
1809 reflexivity.
1810 Qed.
1811
1812 Lemma applyTelescopicOpInfSum
1813 : forall {R : ConstructiveReals} (X : Set)
1814 (fn : nat -> PartialFunction X)
1815 (op : CRcarrier R -> CRcarrier R)
1816 (opEq : forall x y : CRcarrier R, x == y -> op x == op y)
1817 (contract : forall x y : CRcarrier R,
1818 CRabs _ (op x - op y) <= CRabs _ (x - y))
1819 (x : X)
1820 (pF : forall n:nat, Domain (fn n) x)
1821 (pXT : forall n:nat, Domain (telescopicOp X fn op opEq n) x)
1822 (s : CRcarrier R),
1823 series_cv (fun n : nat => partialApply (fn n) x (pF n)) s
1824 -> series_cv
1825 (fun n : nat => partialApply (telescopicOp X fn op opEq n) x (pXT n))
1826 (op s).
1827 Proof.
1828 intros. intros p. specialize (H p) as [N H0].
1829 exists N. intros n H. specialize (H0 n H).
1830
1831 assert (forall (p:nat) (u : nat -> CRcarrier R),
1832 CRsum u (S p) == CRsum u p + u (S p)) as sum_shift.
1833 { intros. reflexivity. }
1834 assert (forall p0:nat,
1835 CRsum (fun k : nat => partialApply (telescopicOp X fn op opEq k) x (pXT k)) p0
1836 == op (CRsum (fun k : nat => partialApply (fn k) x (pF k)) p0)).
1837 { induction p0.
1838 - simpl. apply opEq. apply DomainProp.
1839 - rewrite sum_shift. rewrite IHp0.
1840 rewrite (applyTelescopicOp X fn op opEq p0 x pF).
1841 unfold CRminus. rewrite CRplus_comm, CRplus_assoc, CRplus_opp_l.
1842 rewrite CRplus_0_r. reflexivity. }
1843 rewrite H1.
1844 apply (CRle_trans
1845 _ (CRabs _ (CRsum (fun n : nat => partialApply (fn n) x (pF n)) n - s))).
1846 apply contract. assumption.
1847 Qed.
1848
1849 Definition IabsOpContract {IS : IntegrationSpace}
1850 (fn : nat -> PartialFunction (X (ElemFunc IS)))
1851 (fnL : forall n:nat, L (ElemFunc IS) (fn n))
1852 (op : CRcarrier (RealT (ElemFunc IS))
1853 -> CRcarrier (RealT (ElemFunc IS)))
1854 (opEq : forall x y : CRcarrier (RealT (ElemFunc IS)),
1855 x == y -> op x == op y)
1856 (opL : forall f : PartialFunction (X (ElemFunc IS)),
1857 L (ElemFunc IS) f -> L (ElemFunc IS) (Xop (X (ElemFunc IS)) f op opEq))
1858 (contract : forall x y : CRcarrier (RealT (ElemFunc IS)),
1859 CRabs _ (op x - op y) <= CRabs _ (x - y))
1860 (zeroFix : op 0 == 0)
1861 (sumIAbsFn : CRcarrier (RealT (ElemFunc IS)))
1862 : series_cv (fun k : nat => Iabs (fn k) (fnL k)) sumIAbsFn
1863 -> { l : CRcarrier (RealT (ElemFunc IS))
1864 & series_cv (fun k => Iabs (telescopicOp _ fn op opEq k)
1865 (telescopicOpL fn fnL op opEq opL k)) l }.
1866 Proof.
1867 intros.
1868 destruct (series_cv_maj (fun k => Iabs (telescopicOp _ fn op opEq k)
1869 (telescopicOpL fn fnL op opEq opL k))
1870 (fun k => Iabs (fn k) (fnL k)) sumIAbsFn) as [sumOps cvOps].
1871 intro n. rewrite CRabs_right. apply INonDecreasing. intros.
1872 rewrite applyXabs. rewrite applyXabs. apply applyTelescopicOpMaj.
1873 assumption. assumption.
1874 apply (CRle_trans _ (CRabs _ (I IS (telescopicOp (X (ElemFunc IS)) fn op opEq n)
1875 (telescopicOpL fn fnL op opEq opL n)))).
1876 apply CRabs_pos. apply integralAbsMaj. assumption.
1877 exists sumOps. apply cvOps.
1878 Qed.
1879
1880 Definition IntegralRepresentationOpContract
1881 {IS : IntegrationSpace}
1882 (f : PartialFunction (X (ElemFunc IS)))
1883 (op : CRcarrier (RealT (ElemFunc IS))
1884 -> CRcarrier (RealT (ElemFunc IS)))
1885 (opEq : forall x y : CRcarrier (RealT (ElemFunc IS)),
1886 x == y -> op x == op y)
1887 (opL : forall f : PartialFunction (X (ElemFunc IS)),
1888 L (ElemFunc IS) f -> L (ElemFunc IS) (Xop (X (ElemFunc IS)) f op opEq))
1889 (contract : forall x y : CRcarrier (RealT (ElemFunc IS)),
1890 CRabs _ (op x - op y) <= CRabs _ (x - y))
1891 (zeroFix : op 0 == 0)
1892 : IntegrableFunction f
1893 -> @IntegralRepresentation IS.
1894 Proof.
1895 intros. destruct X.
1896 destruct (IabsOpContract _ _ op opEq opL contract zeroFix
1897 (IntAbsSum x) (IntAbsSumCv x))
1898 as [sumOp cvOps].
1899 (* Weave the telescopic abs with the representation itself, to stay in
1900 the domain of f. *)
1901 exact (IntegralRepresentationWeave
1902 (Build_IntegralRepresentation
1903 IS
1904 (telescopicOp _ (IntFn x) op opEq)
1905 (telescopicOpL (IntFn x) (IntFnL x) op opEq opL)
1906 sumOp cvOps)
1907 (IntegralRepresentationWeave
1908 x (IntegralRepresentationScaleHalf f (-(1)) (existT _ x p)))).
1909 Defined.
1910
1911 Definition IntegrableOpContract {IS : IntegrationSpace}
1912 (f : PartialFunction (X (ElemFunc IS)))
1913 (op : CRcarrier (RealT (ElemFunc IS))
1914 -> CRcarrier (RealT (ElemFunc IS)))
1915 (opEq : forall x y : CRcarrier (RealT (ElemFunc IS)),
1916 x == y -> op x == op y)
1917 (opL : forall f : PartialFunction (X (ElemFunc IS)),
1918 L (ElemFunc IS) f -> L (ElemFunc IS) (Xop (X (ElemFunc IS)) f op opEq))
1919 (contract : forall x y : CRcarrier (RealT (ElemFunc IS)),
1920 CRabs _ (op x - op y) <= CRabs _ (x - y))
1921 (zeroFix : op 0 == 0)
1922 : IntegrableFunction f
1923 -> IntegrableFunction (Xop (X (ElemFunc IS)) f op opEq).
1924 Proof.
1925 intros.
1926 exists (IntegralRepresentationOpContract f op opEq opL contract zeroFix X).
1927 (* Prove partial restriction *)
1928 split.
1929 - (* Domain inclusion *)
1930 intros x xdf. simpl.
1931 unfold IntegralRepresentationOpContract in xdf;
1932 destruct X;
1933 destruct (IabsOpContract (IntFn x0) (IntFnL x0) op opEq opL contract zeroFix
1934 (IntAbsSum x0) (IntAbsSumCv x0)).
1935 unfold IntegralRepresentationWeave, IntFn in xdf.
1936 pose proof (domainInfinSumWeaveR _ _ _ x xdf) as d0.
1937 pose proof (domainInfinSumWeaveL _ _ _ x d0) as pxDFn.
1938 destruct p. exact (d x pxDFn).
1939 - intros.
1940 unfold IntegralRepresentationOpContract, IntegralRepresentationWeave,
1941 IntFn, IntFnL, IntAbsSum, IntAbsSumCv in xD;
1942 unfold IntegralRepresentationOpContract, IntegralRepresentationWeave,
1943 IntFn, IntFnL, IntAbsSum, IntAbsSumCv ;
1944 destruct X as [[fn fnL sumIAbsFn H] [injF restr]];
1945 destruct (IabsOpContract _ _ op opEq opL contract zeroFix sumIAbsFn H)
1946 as [sumOp cvOps].
1947 pose proof (domainInfinSumWeaveL _ _ _ x xD) as pxDTn.
1948 pose proof (domainInfinSumWeaveR _ _ _ x xD) as x0.
1949 pose proof (domainInfinSumWeaveL _ _ _ x x0) as pxDFn.
1950 unfold IntFn in restr.
1951 apply applyInfiniteSumAbs.
1952 simpl (partialApply (Xop (X (ElemFunc IS)) f op opEq) x xG).
1953 apply (series_cv_eq
1954 (weaveSequences _
1955 (fun n : nat => partialApply (telescopicOp _ fn op opEq n) x
1956 (domainInfiniteSumAbsIncReverse _ x pxDTn n))
1957 (weaveSequences
1958 _ (fun n : nat => partialApply (fn n) x
1959 (domainInfiniteSumAbsIncReverse _ x pxDFn n))
1960 (fun n : nat => CRopp _ (partialApply (fn n) x
1961 (domainInfiniteSumAbsIncReverse _ x pxDFn n)))))).
1962 + intro n.
1963 rewrite (partialApplyWeave
1964 _ _ _ n x
1965 (domainInfiniteSumAbsIncReverse _ x pxDTn (n/2))
1966 (domainInfiniteSumAbsIncReverse _ x x0 (n/2))).
1967 unfold weaveSequences. destruct (Nat.even n). reflexivity.
1968 pose proof (partialApplyWeave _ fn (fun n => Xscale (-(1)) (fn n)) (n/2) x
1969 (domainInfiniteSumAbsIncReverse fn x pxDFn (n / 2 / 2))
1970 (domainInfiniteSumAbsIncReverse fn x pxDFn (n / 2 / 2))).
1971 rewrite H0.
1972 destruct (Nat.even (n/2)). reflexivity.
1973 rewrite applyXscale. rewrite <- CRopp_mult_distr_l.
1974 rewrite CRmult_1_l. reflexivity.
1975 + rewrite <- CRplus_0_r.
1976 rewrite <- (CRplus_opp_r (partialApply (XinfiniteSumAbs fn) x pxDFn)).
1977 apply weaveInfiniteSums.
1978 apply (applyTelescopicOpInfSum
1979 _ _ _ _ contract x (domainInfiniteSumAbsIncReverse _ x pxDFn)).
1980 apply applyInfiniteSumAbs. apply restr.
1981 apply weaveInfiniteSums.
1982 apply applyInfiniteSumAbs. reflexivity.
1983 apply series_cv_opp. apply applyInfiniteSumAbs. reflexivity.
1984 Defined.
1985
1986 (* Like the Lebesgue integral, a function f is integrable
1987 when its absolute value is. *)
1988 Definition IntegrableAbs {IS : IntegrationSpace}
1989 {f : PartialFunction (X (ElemFunc IS))}
1990 : IntegrableFunction f
1991 -> IntegrableFunction (Xabs f)
1992 := fun fInt => IntegrableOpContract
1993 f (CRabs _) (CRabs_morph_prop _)
1994 (LabsStable (ElemFunc IS))
1995 CRabs_triang_inv2
1996 (CRabs_right 0 (CRle_refl 0)) fInt.
1997
1998 (* The triangular inequality for integrals. *)
1999 Lemma IntegralTriangle
2000 : forall {IS : IntegrationSpace}
2001 (f : PartialFunction (X (ElemFunc IS)))
2002 (fInt : IntegrableFunction f),
2003 CRabs _ (Integral fInt)
2004 <= Integral (IntegrableAbs fInt).
2005 Proof.
2006 intros. apply CRabs_le. split.
2007 - rewrite <- IntegralOpp. apply IntegralNonDecreasing.
2008 intros x xdf xdg.
2009 rewrite applyXscale, applyXabs.
2010 rewrite (DomainProp f x xdf xdg).
2011 rewrite <- CRopp_mult_distr_l, CRmult_1_l.
2012 rewrite <- (CRopp_involutive (partialApply f x xdg)).
2013 apply CRopp_ge_le_contravar. rewrite CRopp_involutive.
2014 rewrite <- CRabs_opp. apply CRle_abs.
2015 - apply IntegralNonDecreasing. intros x xdf xdg.
2016 rewrite applyXabs.
2017 rewrite (DomainProp f x xdg xdf).
2018 apply CRle_abs.
2019 Qed.
2020
2021
2022 (* The integral of the absolute value of the function difference
2023 is a distance on the integrable functions. It is symmetric,
2024 satisfies the triangular inequality, but not exactly separated.
2025 When the integral distance between f and g is 0, then f and g
2026 are equal almost-everywhere, as defined in CMTFullSets. *)
2027 Definition IntegralDistance {IS : IntegrationSpace}
2028 {f g : PartialFunction (X (ElemFunc IS))}
2029 (fInt : IntegrableFunction f)
2030 (gInt : IntegrableFunction g) : CRcarrier _
2031 := Integral (IntegrableAbs (IntegrableMinus fInt gInt)).
2032
2033 Lemma IntegralDistance_sym
2034 : forall { IS : IntegrationSpace }
2035 (f g : PartialFunction (X (ElemFunc IS)))
2036 (fInt : IntegrableFunction f)
2037 (gInt : IntegrableFunction g),
2038 IntegralDistance fInt gInt == IntegralDistance gInt fInt.
2039 Proof.
2040 intros. apply IntegralExtensional. intros.
2041 do 2 rewrite applyXabs.
2042 destruct xdf, xdg.
2043 rewrite (applyXminus f g), (applyXminus g f).
2044 rewrite CRabs_minus_sym. apply CRabs_morph, CRplus_morph.
2045 apply DomainProp. apply CRopp_morph. apply DomainProp.
2046 Qed.
2047
2048 Lemma IntegralDistance_triang
2049 : forall { IS : IntegrationSpace }
2050 (f g h : PartialFunction (X (ElemFunc IS)))
2051 (fInt : IntegrableFunction f)
2052 (gInt : IntegrableFunction g)
2053 (hInt : IntegrableFunction h),
2054 IntegralDistance fInt hInt
2055 <= IntegralDistance gInt fInt + IntegralDistance gInt hInt.
2056 Proof.
2057 intros. unfold IntegralDistance.
2058 rewrite <- IntegralPlus. apply IntegralNonDecreasing.
2059 intros x xdf xdg. destruct xdf, xdg.
2060 rewrite applyXabs, (applyXplus _ _ x d1 d2).
2061 rewrite (applyXminus f h x d d0).
2062 setoid_replace (partialApply f x d - partialApply h x d0)
2063 with (partialApply f x d - partialApply g x (fst d2)
2064 + (partialApply g x (fst d2) - partialApply h x d0)).
2065 apply (CRle_trans _ _ _ (CRabs_triang _ _)).
2066 apply CRplus_le_compat. rewrite CRabs_minus_sym.
2067 rewrite applyXabs. destruct d1.
2068 rewrite (applyXminus g f x d1 d3), (DomainProp g x (fst d2) d1).
2069 rewrite (DomainProp f x d3 d). apply CRle_refl.
2070 rewrite applyXabs. destruct d2.
2071 rewrite (applyXminus g h x d2 d3), (DomainProp h x d3 d0).
2072 apply CRle_refl. unfold CRminus. rewrite CRplus_assoc.
2073 apply CRplus_morph. reflexivity.
2074 rewrite <- CRplus_assoc, CRplus_opp_l, CRplus_0_l. reflexivity.
2075 Qed.
2076
2077 Definition Un_integral_cv { IS : IntegrationSpace }
2078 (fn : nat -> PartialFunction (X (ElemFunc IS)))
2079 (f : PartialFunction (X (ElemFunc IS)))
2080 (fnInt : forall n:nat, IntegrableFunction (fn n))
2081 (fInt : IntegrableFunction f)
2082 := forall p : positive,
2083 { n : nat
2084 | forall i:nat, le n i -> IntegralDistance (fnInt i) fInt <= CR_of_Q _ (1#p) }.
2085
2086 Definition IntegrableMinOne {IS : IntegrationSpace}
2087 (f : PartialFunction (X (ElemFunc IS)))
2088 : IntegrableFunction f
2089 -> IntegrableFunction (XminConst f 1).
2090 Proof.
2091 intros fInt. apply IntegrableOpContract.
2092 intros g gL. apply LminConstStable. exact (CRzero_lt_one _). exact gL.
2093 intros. apply CRmin_contract.
2094 apply CRmin_left. apply CRlt_asym, CRzero_lt_one. exact fInt.
2095 Defined.
2096
2097 Definition FunctionRieszSpaceCompletion (IS : IntegrationSpace)
2098 : FunctionRieszSpace.
2099 Proof.
2100 apply (Build_FunctionRieszSpace
2101 (X (ElemFunc IS)) (RealT (ElemFunc IS))
2102 IntegrableFunction).
2103 - intros f g H fInt. apply (IntegrableFunctionExtensional f g).
2104 destruct H. split. apply p. apply c. exact fInt.
2105 - exact IntegrablePlus.
2106 - intros f fInt. apply (IntegrableAbs fInt).
2107 - intros. exact (IntegrableMinOne f X).
2108 - intros a f fInt. exact (IntegrableScale f a fInt).
2109 Defined.
2110
2111 Definition IntegrableMinConst {IS : IntegrationSpace}
2112 (f : PartialFunction (X (ElemFunc IS)))
2113 (a : CRcarrier _)
2114 : IntegrableFunction f
2115 -> 0 < a
2116 -> IntegrableFunction (XminConst f a)
2117 := fun fInt aPos => @LminConstStable (FunctionRieszSpaceCompletion IS)
2118 a f aPos fInt.
2119
2120 Definition IntegrableMaxConst {IS : IntegrationSpace}
2121 (f : PartialFunction (X (ElemFunc IS)))
2122 (a : CRcarrier _)
2123 : IntegrableFunction f
2124 -> a < 0
2125 -> IntegrableFunction (XmaxConst f a).
2126 Proof.
2127 intros fInt aPos. apply IntegrableOpContract.
2128 intros g gL. apply (Lext _ (Xscale (CRopp _ 1) (XminConst (Xscale (CRopp _ 1) g) ((CRopp _ 1)*a)))).
2129 split. split. intros x xdg. exact xdg.
2130 intros x xdg. exact xdg. intros. simpl.
2131 rewrite CRmin_max_mult_neg. do 2 rewrite <- CRopp_mult_distr_l.
2132 rewrite CRmult_1_l, CRmult_1_l, CRopp_involutive. apply CRmax_morph.
2133 apply DomainProp. reflexivity. apply (CRplus_le_reg_l 1).
2134 rewrite CRplus_opp_r, CRplus_0_r. apply CRlt_asym, CRzero_lt_one.
2135 apply LscaleStable. apply LminConstStable.
2136 rewrite <- CRopp_mult_distr_l, CRmult_1_l. apply (CRplus_lt_reg_l _ a).
2137 rewrite CRplus_opp_r, CRplus_0_r. exact aPos. apply LscaleStable, gL.
2138 intros. apply CRmax_contract.
2139 apply CRmax_left. apply CRlt_asym, aPos. exact fInt.
2140 Defined.
2141
2142 Definition IntegrablePosPart {IS : IntegrationSpace}
2143 (f : PartialFunction (X (ElemFunc IS)))
2144 : IntegrableFunction f
2145 -> IntegrableFunction (XposPart f).
2146 Proof.
2147 intros fInt.
2148 exact (IntegrableScale
2149 (Xplus f (Xabs f))
2150 (CR_of_Q _ (1#2))
2151 (IntegrablePlus f (Xabs f) fInt
2152 (IntegrableAbs fInt))).
2153 Defined.
2154
2155 Definition IntegrableNegPart {IS : IntegrationSpace}
2156 (f : PartialFunction (X (ElemFunc IS)))
2157 : IntegrableFunction f
2158 -> IntegrableFunction (XnegPart f).
2159 Proof.
2160 intros fInt.
2161 exact (IntegrableScale
2162 (Xminus (Xabs f) f)
2163 (CR_of_Q _ (1#2))
2164 (IntegrableMinus (IntegrableAbs fInt) fInt)).
2165 Defined.
2166
2167 Definition IntegrableMinInt {IS : IntegrationSpace}
2168 (f : PartialFunction (X (ElemFunc IS)))
2169 (n : nat)
2170 : IntegrableFunction f
2171 -> IntegrableFunction (XminConst f (INR n))
2172 := fun fInt => @LminIntStable (FunctionRieszSpaceCompletion IS)
2173 n f fInt.
2174
2175 Definition IntegrableMin {IS : IntegrationSpace}
2176 (f g : PartialFunction (X (ElemFunc IS)))
2177 : IntegrableFunction f
2178 -> IntegrableFunction g
2179 -> IntegrableFunction (Xmin f g).
2180 Proof.
2181 intros fInt gInt.
2182 apply IntegrableMinus. assumption. apply IntegrableNegPart.
2183 apply IntegrableMinus; assumption.
2184 Defined.
2185
2186 Definition IntegrableMax {IS : IntegrationSpace}
2187 (f g : PartialFunction (X (ElemFunc IS)))
2188 : IntegrableFunction f
2189 -> IntegrableFunction g
2190 -> IntegrableFunction (Xmax f g).
2191 Proof.
2192 intros fInt gInt.
2193 apply IntegrablePlus. assumption. apply IntegrablePosPart.
2194 apply IntegrableMinus; assumption.
2195 Defined.
2196
2197 Lemma intTelescopicAbs : forall {IS : IntegrationSpace}
2198 (fn : nat -> PartialFunction (X (ElemFunc IS)))
2199 (fnL : forall n:nat, L (ElemFunc IS) (fn n))
2200 (n : nat),
2201 CRsum
2202 (fun n : nat =>
2203 I IS (telescopicOp (X (ElemFunc IS)) fn (CRabs _)
2204 (CRabs_morph_prop _) n)
2205 (telescopicOpL fn fnL (CRabs _)
2206 (CRabs_morph_prop _)
2207 (fun f => LabsStable (ElemFunc IS) f) n)) n
2208 == Iabs (Xsum fn n) (LsumStable fn fnL n).
2209 Proof.
2210 induction n.
2211 - reflexivity.
2212 - unfold CRsum. rewrite IHn. clear IHn.
2213 unfold telescopicOp, telescopicOpL, Xminus. rewrite Iadditive.
2214 rewrite Ihomogeneous.
2215 rewrite <- (CRopp_mult_distr_l 1), CRmult_1_l.
2216 unfold Iabs, Xabs. rewrite <- CRplus_assoc, CRplus_comm, <- CRplus_assoc.
2217 rewrite CRplus_opp_l, CRplus_0_l. reflexivity.
2218 Qed.
2219
2220 (* If function f is the limit of the series fn,
2221 then the integral of |f| is the limit of
2222 the integrals of the partial sums |f1 + ... + fn| *)
2223 Lemma IntegralAbsLimit : forall {IS : IntegrationSpace}
2224 (f : PartialFunction (X (ElemFunc IS)))
2225 (fInt : IntegrableFunction f),
2226 CR_cv _
2227 (fun n : nat =>
2228 (Iabs _ (LsumStable (IntFn (let (i,_) := fInt in i))
2229 (IntFnL (let (i,_) := fInt in i)) n)))
2230 (Integral (IntegrableAbs fInt)).
2231 Proof.
2232 intros IS. assert (CRabs (RealT (ElemFunc IS)) 0 == 0) as CReal_abs_R0.
2233 { rewrite CRabs_right. reflexivity. apply CRle_refl. }
2234 intros.
2235 unfold Integral, IntegrableAbs,
2236 IntegrableOpContract, IntegralRepresentationOpContract.
2237 destruct fInt as [x p],
2238 (IabsOpContract (IntFn x) (IntFnL x) (CRabs _)
2239 (CRabs_morph_prop _)
2240 (LabsStable (ElemFunc IS)) CRabs_triang_inv2 (CRabs_right 0 (CRle_refl 0))
2241 (IntAbsSum x) (IntAbsSumCv x)).
2242 do 2 rewrite IntegralRepresentationWeaveSum.
2243 rewrite IntegralHomogeneousHalf, <- CRopp_mult_distr_r,
2244 CRmult_1_r, CRplus_opp_r, CRplus_0_r.
2245 destruct x as [fn fnL sumIAbsFn H]; unfold IntFn, IntFnL.
2246 apply (CR_cv_eq _ (CRsum (fun n : nat =>
2247 I IS (telescopicOp (X (ElemFunc IS)) fn (CRabs _)
2248 (CRabs_morph_prop _) n)
2249 (telescopicOpL fn fnL (CRabs _) (CRabs_morph_prop _)
2250 (fun (g : PartialFunction (X (ElemFunc IS))) (gL : L (ElemFunc IS) g) =>
2251 LabsStable (ElemFunc IS) g gL) n)))).
2252 2: apply (IntegralCv {|
2253 IntFn := telescopicOp (X (ElemFunc IS)) fn (CRabs _)
2254 (CRabs_morph_prop _);
2255 IntFnL := telescopicOpL fn fnL (CRabs _) (CRabs_morph_prop _)
2256 (fun (g : PartialFunction (X (ElemFunc IS))) (gL : L (ElemFunc IS) g) =>
2257 LabsStable (ElemFunc IS) g gL);
2258 IntAbsSum := x0;
2259 IntAbsSumCv := s |}).
2260 intro n. rewrite intTelescopicAbs. reflexivity.
2261 Qed.
2262
2263 Definition IntegralRepresentationL {IS : IntegrationSpace}
2264 (f : PartialFunction (X (ElemFunc IS)))
2265 (fL : L (ElemFunc IS) f)
2266 : @IntegralRepresentation IS.
2267 Proof.
2268 pose (fun n:nat => match n with
2269 | O => f
2270 | _ => Izero IS
2271 end) as fn.
2272 assert (forall n:nat, L (ElemFunc IS) (fn n)) as fnL.
2273 { intro n. unfold fn. destruct n. exact fL.
2274 apply Izero_is_L. }
2275 apply (Build_IntegralRepresentation
2276 IS fn fnL (Iabs f fL)).
2277 apply (CR_cv_eq _ (fun _:nat => Iabs f fL)).
2278 2: apply CR_cv_const. intro n. destruct n.
2279 apply IExtensional. intros. apply DomainProp.
2280 rewrite <- CRplus_0_r, decomp_sum. apply CRplus_morph.
2281 apply IExtensional. intros. apply DomainProp.
2282 rewrite (CRsum_eq _ (fun _ => 0)).
2283 rewrite sum_eq_R0. reflexivity. intros _. reflexivity.
2284 intros. unfold fn, Iabs.
2285 rewrite (IExtensional _ (Izero IS) _ (Izero_is_L IS)).
2286 apply Izero_is_zero. intros.
2287 rewrite applyXabs, applyIzero, applyIzero, CRabs_right.
2288 reflexivity. apply CRle_refl. apply le_n_S, Nat.le_0_l.
2289 Defined.
2290
2291 Definition IntegrableL {IS : IntegrationSpace}
2292 (f : PartialFunction (X (ElemFunc IS)))
2293 (fL : L (ElemFunc IS) f)
2294 : IntegrableFunction f.
2295 Proof.
2296 exists (IntegralRepresentationL f fL).
2297 split.
2298 - intros x xd. destruct xd as [xn lim]. exact (xn O).
2299 - intros. apply applyInfiniteSumAbs.
2300 apply (CR_cv_eq _ (fun _:nat => partialApply f x xG)).
2301 2: apply CR_cv_const. intro n. destruct n. apply DomainProp.
2302 rewrite <- CRplus_0_r, decomp_sum. apply CRplus_morph.
2303 apply DomainProp. rewrite (CRsum_eq _ (fun _ => 0)).
2304 rewrite sum_eq_R0. reflexivity. intros _. reflexivity.
2305 intros. unfold IntegralRepresentationL, IntFn.
2306 apply applyIzero. apply le_n_S, Nat.le_0_l.
2307 Defined.
2308
2309 Lemma IntegralLstable : forall {IS : IntegrationSpace}
2310 (f : PartialFunction (X (ElemFunc IS)))
2311 (fL : L (ElemFunc IS) f),
2312 Integral (IntegrableL f fL) == I IS f fL.
2313 Proof.
2314 intros. unfold IntegrableL.
2315 pose proof (IntegralCv (IntegralRepresentationL f fL)).
2316 apply (CR_cv_unique (fun n => I IS f fL)).
2317 2: apply CR_cv_const.
2318 apply (CR_cv_eq _ (CRsum (fun n : nat =>
2319 I IS (IntFn (IntegralRepresentationL f fL) n) (IntFnL (IntegralRepresentationL f fL) n)))).
2320 2: exact H. intro n. destruct n. reflexivity.
2321 symmetry.
2322 rewrite <- CRplus_0_r, decomp_sum. apply CRplus_morph.
2323 apply IExtensional. intros. apply DomainProp.
2324 rewrite (CRsum_eq _ (fun _ => 0)).
2325 rewrite sum_eq_R0. reflexivity. intros _. reflexivity.
2326 intros. simpl. apply Izero_is_zero.
2327 apply le_n_S, Nat.le_0_l.
2328 Qed.
2329
2330 Fixpoint IntegrableSum {IS : IntegrationSpace}
2331 (fn : nat -> PartialFunction (X (ElemFunc IS)))
2332 (fnInt : forall n:nat, IntegrableFunction (fn n))
2333 (n : nat)
2334 : IntegrableFunction (Xsum fn n).
2335 Proof.
2336 destruct n.
2337 - apply fnInt.
2338 - simpl. apply IntegrablePlus. apply IntegrableSum. exact fnInt. apply fnInt.
2339 Defined.
2340
2341 Definition IntegralRepresentationAbs { IS : IntegrationSpace }
2342 : @IntegralRepresentation IS -> @IntegralRepresentation IS.
2343 Proof.
2344 intro fInt.
2345 pose (fun n:nat => Xabs (IntFn fInt n)) as fn.
2346 assert (forall n:nat, L (ElemFunc IS) (fn n)) as fnL.
2347 { intro n. unfold fn. apply (LabsStable (ElemFunc IS)), IntFnL. }
2348 apply (Build_IntegralRepresentation
2349 IS fn fnL (IntAbsSum fInt)).
2350 apply (series_cv_eq (fun n : nat => Iabs (IntFn fInt n) (IntFnL fInt n))).
2351 2: apply fInt. intro n. apply IExtensional.
2352 intros. unfold fn.
2353 rewrite (applyXabs (Xabs (IntFn fInt n))), CRabs_right.
2354 apply DomainProp. rewrite applyXabs. apply CRabs_pos.
2355 Defined.
2356
2357 Lemma IntegralRepresentationAbsVal
2358 : forall {IS : IntegrationSpace}
2359 (fInt : @IntegralRepresentation IS),
2360 IntegralSeries (IntegralRepresentationAbs fInt) == IntAbsSum fInt.
2361 Proof.
2362 intros.
2363 apply (CR_cv_unique (CRsum (fun n => Iabs (IntFn fInt n) (IntFnL fInt n)))).
2364 exact (IntegralCv (IntegralRepresentationAbs fInt)).
2365 apply fInt.
2366 Qed.
2367
2368 Definition IntegrableSelf { IS : IntegrationSpace }
2369 (fInt : @IntegralRepresentation IS)
2370 : IntegrableFunction (XinfiniteSumAbs (IntFn fInt)).
2371 Proof.
2372 exists fInt. apply PartialRestriction_refl.
2373 Defined.