Debian Codegraph @

reals/stdlib/CMTMeasurableFunctions.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 From Coq Require Import ZArith QArith.
13 From Coq Require Import ConstructiveReals.
14 From Coq Require Import ConstructiveAbs.
15 From Coq Require Import ConstructiveMinMax.
16 From Coq Require Import ConstructiveSum.
17 From Coq Require Import ConstructivePower.
18 From Coq Require Import ConstructiveLimits.
19 Require Import ConstructivePartialFunctions.
20 Require Import CMTbase.
21 Require Import CMTIntegrableFunctions.
22 Require Import CMTFullSets.
23 Require Import CMTIntegrableSets.
24 Require Import CMTprofile.
25
26 Local Open Scope ConstructiveReals.
27
28
29 (* A function f is measurable when it is integrable on any
30 integrable rectangle A * [-k,k]. *)
31 Definition MeasurableFunction {IS : IntegrationSpace}
32 (f : PartialFunction (X (ElemFunc IS))) : Type
33 := forall (A : (X (ElemFunc IS)) -> Prop) (k : positive),
34 IntegrableSet A
35 -> IntegrableFunction (XmaxConst (XminConst (Xmult (CharacFunc A) f)
36 (CR_of_Q _ (Z.pos k # 1)))
37 (CR_of_Q _ (Z.neg k # 1))).
38
39 Lemma MeasurableFunctionExtensional
40 : forall {IS : IntegrationSpace}
41 (f g : PartialFunction (X (ElemFunc IS))),
42 PartialRestriction f g
43 -> MeasurableFunction f
44 -> MeasurableFunction g.
45 Proof.
46 intros IS f g [d c] fMes A k Aint.
47 apply (IntegrableFunctionExtensional
48 (XmaxConst (XminConst (Xmult (CharacFunc A) f)
49 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
50 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1)))).
51 2: exact (fMes A k Aint).
52 split.
53 - intros x xdf. simpl in xdf. destruct xdf.
54 split. exact s. exact (d x d0).
55 - intros. simpl. destruct xD, xG.
56 rewrite (c x d1 (d x d1)), (DomainProp g x (d x d1) d3).
57 destruct d0. destruct d2. reflexivity. contradiction.
58 destruct d2. contradiction. reflexivity.
59 Qed.
60
61 Lemma MeasurableFunctionFull
62 : forall {IS : IntegrationSpace}
63 (f : PartialFunction (X (ElemFunc IS))),
64 MeasurableFunction f
65 -> almost_everywhere (Domain f).
66 Proof.
67 intros IS f fMes.
68 destruct (@PositiveMeasureSubsetExists IS) as [A Aint Apos].
69 specialize (fMes A 1%positive Aint).
70 exists (XmaxConst (XminConst (Xmult (CharacFunc A) f) (CR_of_Q (RealT (ElemFunc IS)) 1))
71 (CR_of_Q (RealT (ElemFunc IS)) (-1))).
72 split. exact fMes.
73 intros x xD. apply xD.
74 Qed.
75
76 Lemma IntegrableMeasurable
77 : forall {IS : IntegrationSpace}
78 (f : PartialFunction (X (ElemFunc IS))),
79 IntegrableFunction f
80 -> MeasurableFunction f.
81 Proof.
82 intros IS f fInt A k Aint.
83 apply IntegrableMaxConst. apply IntegrableMinConst.
84 exact (RestrictedIntegrable fInt Aint).
85 apply CR_of_Q_pos. reflexivity.
86 apply (CRlt_le_trans _ (CR_of_Q _ 0)). apply CR_of_Q_lt. reflexivity.
87 apply CRle_refl.
88 Qed.
89
90 Lemma MeasurableConst
91 : forall {IS : IntegrationSpace}
92 (a : CRcarrier (RealT (ElemFunc IS))),
93 MeasurableFunction (Xconst (X (ElemFunc IS)) a).
94 Proof.
95 intros IS a A k Aint. apply IntegrableMaxConst.
96 apply IntegrableMinConst.
97 apply (IntegrableFunctionExtensional (Xscale a (CharacFunc A))).
98 - split. intros x xdf.
99 split. exact xdf. simpl. trivial. intros. simpl.
100 destruct xG. destruct xD. destruct d. apply CRmult_comm.
101 contradiction. destruct d. contradiction. apply CRmult_comm.
102 - apply IntegrableScale, Aint.
103 - apply CR_of_Q_lt. reflexivity.
104 - apply CR_of_Q_lt. reflexivity.
105 Qed.
106
107 Definition MeasurableSet {IS : IntegrationSpace}
108 (A : (X (ElemFunc IS)) -> Prop) : Type
109 := MeasurableFunction (CharacFunc A).
110
111 Lemma MeasurableSetEquiv
112 : forall {IS : IntegrationSpace}
113 (A : (X (ElemFunc IS)) -> Prop),
114 prod (MeasurableSet A
115 -> (forall B : (X (ElemFunc IS)) -> Prop,
116 IntegrableSet B -> IntegrableFunction (Xmult (CharacFunc A) (CharacFunc B))))
117 ((forall B : (X (ElemFunc IS)) -> Prop,
118 IntegrableSet B -> IntegrableFunction (Xmult (CharacFunc A) (CharacFunc B))) -> MeasurableSet A).
119 Proof.
120 intros IS A.
121 assert (forall B x xD xG k,
122 partialApply (Xmult (CharacFunc A) (CharacFunc B)) x xD ==
123 partialApply
124 (XmaxConst
125 (XminConst (Xmult (CharacFunc B) (CharacFunc A))
126 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
127 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1))) x xG).
128 { intros. rewrite applyXmaxConst, CRmax_left.
129 rewrite applyXminConst, CRmin_left. destruct xD, xG.
130 simpl. destruct d. destruct d2. 2: contradiction.
131 destruct d0. destruct d1. 2: contradiction. reflexivity.
132 destruct d1. contradiction. apply CRmult_comm.
133 rewrite CRmult_0_l. destruct d2. contradiction.
134 rewrite CRmult_0_r. reflexivity.
135 apply (CRle_trans _ 1). simpl. destruct xG.
136 destruct d. destruct d0. rewrite CRmult_1_l. apply CRle_refl.
137 rewrite CRmult_1_l. apply CRlt_asym, CRzero_lt_one. rewrite CRmult_0_l.
138 apply CRlt_asym, CRzero_lt_one.
139 apply CR_of_Q_le. unfold Qle, Qnum, Qden. rewrite Z.mul_1_l, Z.mul_1_r.
140 destruct k; discriminate.
141 apply (CRle_trans _ 0). apply CR_of_Q_le. discriminate.
142 apply CRmin_glb. simpl. destruct xG, d. rewrite CRmult_1_l.
143 destruct d0. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
144 rewrite CRmult_0_l. apply CRle_refl. apply CR_of_Q_le. discriminate. }
145 split.
146 - intros Ames B Bint. specialize (Ames B 1%positive Bint).
147 refine (IntegrableFunctionExtensional _ _ _ Ames). split.
148 + intros x xdf. destruct xdf. split. exact d0. exact d.
149 + intros x xD xG. symmetry. apply H.
150 - intros H0 B k Bint. specialize (H0 B Bint).
151 refine (IntegrableFunctionExtensional _ _ _ H0). split.
152 + intros x xdf. destruct xdf. split. exact d0. exact d.
153 + intros x xD xG. apply H.
154 Qed.
155
156
157 Lemma IntegrableMeasurableSet
158 : forall {IS : IntegrationSpace}
159 (A : X (ElemFunc IS) -> Prop),
160 IntegrableSet A -> MeasurableSet A.
161 Proof.
162 intros IS A Aint B k Bint.
163 apply IntegrableMaxConst. apply IntegrableMinConst.
164 apply (IntegrableExtensionalAE (CharacFunc (fun x => B x /\ A x))).
165 - exists (Xplus (CharacFunc A) (CharacFunc B)).
166 split. exact (IntegrablePlus _ _ Aint Bint).
167 intros. split. apply H. apply H.
168 - exists (CharacFunc A). split. exact Aint.
169 intros. simpl. destruct dG. clear H. destruct d0.
170 + (* In a *) rewrite CRmult_1_r.
171 destruct d, dF. reflexivity. contradict n. split; assumption.
172 destruct a0. contradiction. reflexivity.
173 + (* Not in a *) rewrite CRmult_0_r.
174 destruct dF. destruct a. contradiction. reflexivity.
175 - exact (IntegrableSetIntersect _ _ Bint Aint).
176 - apply CR_of_Q_pos. reflexivity.
177 - apply (CRlt_le_trans _ (CR_of_Q _ 0)).
178 apply CR_of_Q_lt. reflexivity. apply CRle_refl.
179 Qed.
180
181 (* In finite integration spaces, like probability spaces, measurable is
182 equivalent to integrable. *)
183 Lemma MeasurableIntegrableSubset
184 : forall {IS : IntegrationSpace}
185 (A B : X (ElemFunc IS) -> Prop),
186 IntegrableSet B
187 -> MeasurableSet A
188 -> (forall x : X (ElemFunc IS), A x -> B x)
189 -> IntegrableSet A.
190 Proof.
191 intros IS A B Bint Ames incl.
192 specialize (Ames B 1%positive Bint).
193 refine (IntegrableFunctionExtensional _ _ _ Ames). split.
194 - intros x xdf. exact (snd xdf).
195 - intros. destruct xG.
196 + (* in A *)
197 simpl. destruct xD. destruct d.
198 2: contradict n; exact (incl x a). destruct d0.
199 rewrite CRmult_1_l, CRmin_left, CRmax_left. reflexivity.
200 apply CR_of_Q_le. discriminate.
201 apply CRle_refl. contradiction.
202 + (* not in A *)
203 simpl. destruct xD. destruct d0. contradiction.
204 rewrite CRmult_0_r, CRmin_left, CRmax_left. reflexivity.
205 apply CR_of_Q_le. discriminate.
206 apply CR_of_Q_le. discriminate.
207 Qed.
208
209 Lemma TruncOpp : forall {R : ConstructiveReals} (x : CRcarrier R) (k : positive),
210 - CRmax (CRmin x (CR_of_Q _ (Z.pos k # 1)))
211 (CR_of_Q _ (Z.neg k # 1))
212 == CRmax (CRmin (-x) (CR_of_Q _ (Z.pos k # 1)))
213 (CR_of_Q _ (Z.neg k # 1)).
214 Proof.
215 intros. destruct (CRltLinear R).
216 setoid_replace (-x) with (-(1) * x).
217 destruct (s (CR_of_Q R (Z.neg k # 1)) x 0).
218 apply CR_of_Q_lt. reflexivity.
219 rewrite CRmax_left, (CRmin_left (- (1) * x)).
220 - setoid_replace (CR_of_Q R (Z.neg k # 1))
221 with (-(1) * CR_of_Q R (Z.pos k # 1)).
222 rewrite CRmax_min_mult_neg. rewrite <- CRopp_mult_distr_l.
223 rewrite CRmult_1_l. reflexivity.
224 apply (CRplus_le_reg_l 1). rewrite CRplus_opp_r, CRplus_0_r.
225 apply CRlt_asym, CRzero_lt_one.
226 rewrite <- CRopp_mult_distr_l, CRmult_1_l, <- CR_of_Q_opp.
227 apply CR_of_Q_morph. reflexivity.
228 - rewrite <- CRopp_mult_distr_l, CRmult_1_l.
229 rewrite <- (CRopp_involutive (CR_of_Q R (Z.pos k # 1))).
230 apply CRopp_ge_le_contravar. rewrite <- CR_of_Q_opp.
231 apply (CRle_trans _ (CR_of_Q R (Z.neg k # 1))).
232 apply CR_of_Q_le. apply Qle_refl. apply CRlt_asym, c.
233 - apply CRmin_glb. apply CRlt_asym, c. apply CR_of_Q_le. discriminate.
234 - rewrite CRmin_left, (CRmax_left (CRmin (- (1) * x) (CR_of_Q R (Z.pos k # 1)))).
235 setoid_replace (CR_of_Q R (Z.pos k # 1))
236 with (-(1) * CR_of_Q R (Z.neg k # 1)).
237 rewrite CRmin_max_mult_neg, <- CRopp_mult_distr_l, CRmult_1_l. reflexivity.
238 apply (CRplus_le_reg_l 1). rewrite CRplus_opp_r, CRplus_0_r.
239 apply CRlt_asym, CRzero_lt_one.
240 rewrite <- CRopp_mult_distr_l, CRmult_1_l, <- CR_of_Q_opp.
241 apply CR_of_Q_morph. reflexivity.
242 apply CRmin_glb. apply (CRle_trans _ 0).
243 apply CR_of_Q_le. discriminate.
244 rewrite <- CRopp_mult_distr_l, CRmult_1_l, <- CRopp_0.
245 apply CRopp_ge_le_contravar, CRlt_asym, c.
246 apply CR_of_Q_le. discriminate.
247 apply (CRle_trans _ 0). apply CRlt_asym, c.
248 apply CR_of_Q_le. discriminate.
249 - rewrite <- CRopp_mult_distr_l, CRmult_1_l. reflexivity.
250 Qed.
251
252 Lemma TruncPosNeg : forall {R : ConstructiveReals} (y : CRcarrier R) (k : positive),
253 CRmax (CRmin (CRmax 0 y) (CR_of_Q R (Z.pos k # 1)))
254 (CR_of_Q R (Z.neg k # 1)) +
255 CRmax (CRmin (CRmin 0 y) (CR_of_Q R (Z.pos k # 1)))
256 (CR_of_Q R (Z.neg k # 1)) ==
257 CRmax (CRmin y (CR_of_Q R (Z.pos k # 1)))
258 (CR_of_Q R (Z.neg k # 1)).
259 Proof.
260 intros.
261 rewrite (CRmax_left (CRmin (CRmax 0 y) (CR_of_Q R (Z.pos k # 1)))).
262 rewrite (CRmin_left (CRmin 0 y)).
263 - destruct (CRltLinear R).
264 destruct (s (CR_of_Q R (Z.neg k # 1)) y 0).
265 + apply CR_of_Q_lt. reflexivity.
266 + rewrite (CRmax_left (CRmin y (CR_of_Q R (Z.pos k # 1)))).
267 rewrite (CRmax_left (CRmin 0 y)).
268 destruct (s 0 y (CR_of_Q R (Z.pos k # 1))).
269 apply CR_of_Q_lt. reflexivity.
270 rewrite CRmax_right, (CRmin_left 0 y). rewrite CRplus_0_r. reflexivity.
271 apply CRlt_asym, c0. apply CRlt_asym, c0.
272 rewrite (CRmin_left y), CRmin_left.
273 unfold CRmax, CRmin.
274 rewrite CRplus_0_l, <- CRmult_plus_distr_r.
275 unfold CRminus. rewrite CRplus_assoc, <- (CRplus_comm (- CRabs R (y + - 0))).
276 rewrite <- (CRplus_assoc (CRabs R (y + - 0))), CRplus_opp_r, CRplus_0_l.
277 apply (CRmult_eq_reg_r (CR_of_Q R 2)).
278 left. apply CR_of_Q_lt. reflexivity.
279 rewrite CRmult_assoc, <- CR_of_Q_mult.
280 setoid_replace ((1 # 2) * 2)%Q with 1%Q. 2: reflexivity.
281 rewrite (CR_of_Q_plus R 1 1), CRmult_1_r, CRmult_plus_distr_l.
282 rewrite CRmult_1_r. reflexivity.
283 apply CRmax_lub. apply CR_of_Q_le. discriminate.
284 apply CRlt_asym, c0. apply CRlt_asym, c0.
285 apply CRmin_glb. apply CR_of_Q_le. discriminate.
286 apply CRlt_asym, c. apply CRmin_glb.
287 apply CRlt_asym, c. apply CR_of_Q_le. discriminate.
288 + rewrite (CRmax_left 0 y). rewrite (CRmin_right 0 y).
289 rewrite CRmin_left, CRplus_0_l. rewrite CRmin_left. reflexivity.
290 apply (CRle_trans _ 0). apply CRlt_asym, c.
291 apply CR_of_Q_le. discriminate.
292 apply CR_of_Q_le. discriminate.
293 apply CRlt_asym, c. apply CRlt_asym, c.
294 - apply (CRle_trans _ 0). apply CRmin_l.
295 apply CR_of_Q_le. discriminate.
296 - apply CRmin_glb. apply (CRle_trans _ 0).
297 apply CR_of_Q_le. discriminate. apply CRmax_l.
298 apply CR_of_Q_le. discriminate.
299 Qed.
300
301 Definition MeasurablePosNegParts {IS : IntegrationSpace}
302 (f : PartialFunction (X (ElemFunc IS)))
303 : MeasurableFunction (XposPart f)
304 -> MeasurableFunction (XnegPart f)
305 -> MeasurableFunction f.
306 Proof.
307 intros fMes gMes A k Aint.
308 apply (IntegrableFunctionExtensional
309 (Xminus
310 (XmaxConst (XminConst (Xmult (CharacFunc A) (XposPart f))
311 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
312 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1)))
313 (XmaxConst (XminConst (Xmult (CharacFunc A) (XnegPart f))
314 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
315 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1))))).
316 - split. intros x xdf. simpl. simpl in xdf. destruct xdf. split.
317 apply p. apply p. intros. simpl.
318 destruct xD, d, d0, d1, d2, xG.
319 setoid_replace (if d5 then CR_of_Q (RealT (ElemFunc IS)) 1 else 0)
320 with (if d then CR_of_Q (RealT (ElemFunc IS)) 1 else 0).
321 setoid_replace (if d0 then CR_of_Q (RealT (ElemFunc IS)) 1 else 0)
322 with (if d then CR_of_Q (RealT (ElemFunc IS)) 1 else 0).
323 destruct d.
324 + rewrite CRmult_1_l, CRmult_1_l, CRmult_1_l.
325 rewrite (DomainProp f x d6 d1), (DomainProp f x d4 d1),
326 (DomainProp f x d2 d1), (DomainProp f x d3 d1). clear d6 d4 d3 d2.
327 generalize (partialApply f x d1). intro y.
328 rewrite (CRmult_comm (CR_of_Q (RealT (ElemFunc IS)) (1 # 2))).
329 rewrite <- CRposPartAbsMax.
330 rewrite (CRmult_comm (CR_of_Q (RealT (ElemFunc IS)) (1 # 2))).
331 do 2 rewrite <- CRopp_mult_distr_l. do 2 rewrite CRmult_1_l.
332 rewrite TruncOpp, CRopp_mult_distr_l, CRopp_plus_distr.
333 rewrite CRopp_involutive, <- (CRplus_comm y).
334 pose proof (CRnegPartAbsMin y). unfold CRminus in H.
335 rewrite <- H. clear H. apply TruncPosNeg.
336 + rewrite CRmult_0_l, CRmult_0_l, CRmult_0_l.
337 rewrite CRmin_left, CRmax_left, CRplus_0_l, CRmult_0_r. reflexivity.
338 apply CR_of_Q_le. discriminate.
339 apply CR_of_Q_le. discriminate.
340 + destruct d0. destruct d. reflexivity. contradiction. destruct d.
341 contradiction. reflexivity.
342 + destruct d5. destruct d. reflexivity. contradiction. destruct d.
343 contradiction. reflexivity.
344 - apply IntegrableMinus. apply fMes, Aint. apply gMes, Aint.
345 Qed.
346
347 Lemma CR_cv_max : forall {R : ConstructiveReals} (un : nat -> CRcarrier R) (l a : CRcarrier R),
348 CR_cv R un l
349 -> CR_cv R (fun n : nat => CRmax (un n) a)
350 (CRmax l a).
351 Proof.
352 intros. intro p. specialize (H p) as [n H].
353 exists n. intros.
354 apply (CRle_trans _ _ _ (CRmax_contract _ _ a)).
355 exact (H i H0).
356 Qed.
357
358 Lemma CR_cv_min : forall {R : ConstructiveReals} (un : nat -> CRcarrier R) (l a : CRcarrier R),
359 CR_cv R un l
360 -> CR_cv R (fun n : nat => CRmin (un n) a)
361 (CRmin l a).
362 Proof.
363 intros. intro p. specialize (H p) as [n H].
364 exists n. intros.
365 apply (CRle_trans _ _ _ (CRmin_contract _ _ a)).
366 exact (H i H0).
367 Qed.
368
369 Lemma MeasurableSetCompl
370 : forall {IS : IntegrationSpace}
371 (A : (X (ElemFunc IS)) -> Prop),
372 MeasurableSet A -> MeasurableSet (fun x => ~A x).
373 Proof.
374 intros IS A Ameas. apply MeasurableSetEquiv. intros B Bint.
375 destruct (MeasurableSetEquiv A) as [H _]. specialize (H Ameas B Bint).
376 refine (IntegrableFunctionExtensional
377 _ _ _ (IntegrableMinus Bint H)).
378 split.
379 - intros x. simpl. intros. destruct H0, p. split.
380 destruct s0. right. intro abs. contradiction. left. exact n. exact s.
381 - intros. destruct xD, d.
382 + (* In B *)
383 simpl. destruct d0. destruct d0. 2: contradiction.
384 destruct xG. destruct d1. 2: contradiction.
385 destruct d. destruct d0. contradiction.
386 rewrite CRmult_1_r, CRmult_1_r, CRmult_1_r. apply CRplus_opp_r.
387 destruct d0. 2: contradiction. rewrite CRmult_0_l, CRmult_0_r.
388 rewrite CRmult_1_l, CRplus_0_r. reflexivity.
389 + (* Not in B *)
390 simpl. destruct xG. destruct d0. destruct d2. contradiction.
391 destruct d1. contradiction. rewrite CRmult_0_r, CRmult_0_r, CRmult_0_r.
392 apply CRplus_0_l.
393 Qed.
394
395 Lemma MeasurableIntersectIntegrable
396 : forall {IS : IntegrationSpace}
397 {A B : (X (ElemFunc IS)) -> Prop},
398 MeasurableSet A
399 -> IntegrableSet B
400 -> IntegrableSet (fun x => A x /\ B x).
401 Proof.
402 intros IS A B Ames Bint.
403 pose proof (MeasurableSetEquiv A) as [Aint _].
404 specialize (Aint Ames B Bint).
405 refine (IntegrableFunctionExtensional _ _ _ Aint). split.
406 - intros x [d d0]. destruct d, d0.
407 left. split; assumption.
408 right. intros [_ abs]. contradiction.
409 right. intros [abs _]. contradiction.
410 right. intros [abs _]. contradiction.
411 - intros. simpl. destruct xD. destruct d.
412 destruct xG. destruct d0. apply CRmult_1_r.
413 destruct a0; contradiction. destruct d0.
414 contradict n. split; assumption. apply CRmult_0_r.
415 rewrite CRmult_0_l. destruct xG. destruct a; contradiction. reflexivity.
416 Qed.
417
418 Lemma MeasurableSetUnion
419 : forall {IS : IntegrationSpace}
420 (A B : (X (ElemFunc IS)) -> Prop),
421 MeasurableSet A
422 -> MeasurableSet B
423 -> MeasurableSet (fun x => A x \/ B x).
424 Proof.
425 intros IS A B Ameas Bmeas. apply MeasurableSetEquiv.
426 intros C Cint.
427 pose proof (MeasurableSetEquiv A) as [Aint _].
428 pose proof (MeasurableSetEquiv B) as [Bint _].
429 apply (IntegrableFunctionExtensional
430 (Xminus
431 (Xplus (Xmult (CharacFunc A) (CharacFunc C))
432 (Xmult (CharacFunc B) (CharacFunc C)))
433 (Xmult (CharacFunc A) (CharacFunc (fun x => B x /\ C x))))).
434 - split.
435 + intros x. simpl. intros. destruct H, p, p. split. 2: exact s0.
436 destruct s. left. left. exact a. destruct p1, s.
437 left. right. exact b. right. intro abs. destruct abs; contradiction.
438 + intros. destruct xD.
439 rewrite (applyXminus (Xplus (Xmult (CharacFunc A) (CharacFunc C))
440 (Xmult (CharacFunc B) (CharacFunc C))) (Xmult (CharacFunc A) (CharacFunc (fun x0 : X (ElemFunc IS) => B x0 /\ C x0))) x d d0).
441 destruct d. rewrite (applyXplus _ _ x d d1).
442 destruct d. rewrite (applyXmult _ _ x d d2).
443 destruct d1. rewrite (applyXmult _ _ x d1 d3).
444 rewrite (DomainProp _ x d3 d2). clear d3.
445 destruct d0. rewrite (applyXmult _ _ x d0 d3).
446 rewrite (DomainProp _ x d0 d). clear d0.
447 destruct xG. rewrite (applyXmult _ _ x d0 d4).
448 rewrite (DomainProp _ x d4 d2). clear d4.
449 simpl. destruct d2. rewrite CRmult_1_r, CRmult_1_r, CRmult_1_r.
450 destruct d1. destruct d3.
451 destruct d. destruct d0. rewrite CRmult_1_r.
452 unfold CRminus. rewrite CRplus_assoc, CRplus_opp_r. apply CRplus_0_r.
453 contradict n. left. exact a0. destruct d0.
454 rewrite CRmult_0_l, CRplus_0_l. unfold CRminus.
455 rewrite CRopp_0, CRplus_0_r. reflexivity.
456 contradict n0. right. exact b.
457 contradict n. split; assumption.
458 destruct d3. destruct a; contradiction.
459 rewrite CRmult_0_r. destruct d. destruct d0.
460 rewrite CRplus_0_r. unfold CRminus.
461 rewrite CRopp_0, CRplus_0_r. reflexivity.
462 contradict n1. left. exact a. destruct d0. destruct o; contradiction.
463 rewrite CRplus_0_l. apply CRplus_opp_r.
464 destruct d3. destruct a. contradiction.
465 rewrite CRmult_0_r, CRmult_0_r, CRmult_0_r, CRplus_0_l.
466 apply CRplus_opp_r.
467 - apply IntegrableMinus. apply IntegrablePlus.
468 apply (Aint Ameas), Cint. apply (Bint Bmeas), Cint.
469 apply (Aint Ameas).
470 exact (MeasurableIntersectIntegrable Bmeas Cint).
471 Qed.
472
473 Definition MeasurableSetUnionIterate
474 {IS : IntegrationSpace}
475 (An : nat -> X (ElemFunc IS) -> Prop)
476 (aInt : forall n:nat, MeasurableSet (An n))
477 : forall n:nat, MeasurableSet (UnionIterate An n).
478 Proof.
479 induction n.
480 - apply aInt.
481 - simpl. apply MeasurableSetUnion. apply IHn. apply aInt.
482 Defined.
483
484 Lemma MeasurableSetIntersection
485 : forall {IS : IntegrationSpace}
486 (A B : (X (ElemFunc IS)) -> Prop),
487 MeasurableSet A
488 -> MeasurableSet B
489 -> MeasurableSet (fun x => A x /\ B x).
490 Proof.
491 intros IS A B Ameas Bmeas. apply MeasurableSetEquiv.
492 intros C Cint.
493 pose proof (MeasurableSetEquiv A) as [Aint _].
494 pose proof (MeasurableSetEquiv B) as [Bint _].
495 pose proof (MeasurableFunctionFull _ Bmeas) as Bfull.
496 specialize (Aint Ameas). specialize (Bint Bmeas).
497 apply (IntegrableExtensionalAE
498 (Xmult (CharacFunc A) (CharacFunc (fun x => B x /\ C x)))).
499 - destruct Bfull.
500 exists (Xplus x (Xmult (CharacFunc A) (CharacFunc C))). split.
501 apply IntegrablePlus. apply p. apply Aint. exact Cint.
502 intros. destruct p, H, d1. specialize (d x0 d0).
503 split. 2: exact d2. simpl. destruct d1. destruct d.
504 2: right; intros [H1 H0]; contradiction.
505 left. split; assumption. right.
506 intros [H H0]. contradiction.
507 - exists (CharacFunc C). split. exact Cint. intros. simpl.
508 destruct dF, dG. clear H. destruct d2. destruct d0.
509 destruct d1. destruct d. reflexivity. destruct a0; contradiction.
510 destruct d. contradict n. split. exact a0. apply a. reflexivity.
511 rewrite CRmult_0_r. destruct d1. contradict n.
512 split. apply a. exact c. rewrite CRmult_0_l. reflexivity.
513 rewrite CRmult_0_r. destruct d0. destruct a; contradiction.
514 apply CRmult_0_r.
515 - apply Aint.
516 apply (IntegrableFunctionExtensional
517 (Xmult (CharacFunc B) (CharacFunc C))).
518 split. intros x xdf. destruct xdf.
519 destruct d. destruct d0. left. split; assumption.
520 right. intro abs. destruct abs. contradiction.
521 right. intro abs. destruct abs. contradiction.
522 intros. 2: apply Bint; assumption.
523 simpl. destruct xD. destruct d. destruct d0.
524 destruct xG. apply CRmult_1_l. contradict n. split; assumption.
525 destruct xG. destruct a; contradiction. apply CRmult_0_r.
526 rewrite CRmult_0_l. destruct xG. destruct a; contradiction. reflexivity.
527 Qed.
528
529 Lemma Rcauchy_complete_cv
530 : forall {R : ConstructiveReals } (un : nat -> CRcarrier R)
531 (cau : CR_cauchy R un) (a : CRcarrier R),
532 CR_cv R un a
533 -> ((let (x,_) := CR_complete R un cau in x) == a)%ConstructiveReals.
534 Proof.
535 intros. destruct (CR_complete R un cau).
536 exact (CR_cv_unique un _ _ c H).
537 Qed.
538
539 Lemma SigmaFiniteLimit
540 : forall {R : ConstructiveReals} (A : CRcarrier R -> Prop),
541 @PartialRestriction R _
542 (XpointwiseLimit (fun n => CharacFunc (fun x => -CR_of_Q R (Z.of_nat n # 1) <= x
543 /\ x <= CR_of_Q R (Z.of_nat n # 1)
544 /\ A x)))
545 (CharacFunc A).
546 Proof.
547 split.
548 - intros x [xnD H]. destruct (CRup_nat (CRabs _ x)) as [n H0].
549 apply CRabs_lt in H0. destruct H0.
550 destruct (xnD n) as [isin|isout].
551 + left. apply isin.
552 + right. intro abs. apply isout. repeat split. 3: exact abs.
553 2: apply CRlt_asym, c.
554 rewrite <- (CRopp_involutive x).
555 apply CRopp_ge_le_contravar. apply CRlt_asym, c0.
556 - intros. simpl.
557 destruct (CRup_nat (CRabs _ x)) as [n nup].
558 apply CRabs_lt in nup. destruct nup.
559 destruct xD as [xnD H], xG.
560 + (* in A *)
561 unfold CharacFunc, Domain, inject_Z in xnD.
562 unfold CharacFunc, partialApply in H.
563 apply Rcauchy_complete_cv.
564 intro p. exists n. intros. destruct (xnD i).
565 unfold CRminus. rewrite CRplus_opp_r.
566 rewrite CRabs_right. apply CR_of_Q_le. discriminate.
567 apply CRle_refl. exfalso. apply n0. repeat split.
568 3: exact a.
569 rewrite <- (CRopp_involutive x).
570 apply CRopp_ge_le_contravar.
571 apply (CRle_trans _ (CR_of_Q R (Z.of_nat n # 1))).
572 apply CRlt_asym, c0. apply CR_of_Q_le. unfold Qle, Qnum, Qden.
573 do 2 rewrite Z.mul_1_r. apply Nat2Z.inj_le, H0.
574 apply (CRle_trans _ (CR_of_Q R (Z.of_nat n # 1))).
575 apply CRlt_asym, c. apply CR_of_Q_le. unfold Qle, Qnum, Qden.
576 do 2 rewrite Z.mul_1_r. apply Nat2Z.inj_le, H0.
577 + (* not in A, constant sequence at 0. *)
578 unfold CharacFunc, partialApply in H.
579 apply Rcauchy_complete_cv. intro p. exists O.
580 intros. destruct (xnD i). exfalso.
581 destruct a, H2. contradiction.
582 unfold CRminus. rewrite CRopp_0, CRplus_0_r.
583 rewrite CRabs_right.
584 apply CR_of_Q_le. discriminate. apply CRle_refl.
585 Qed.
586
587 Lemma SigmaFiniteMonotone
588 : forall {R : ConstructiveReals} (A : CRcarrier R -> Prop),
589 let fn := fun n => @CharacFunc R _ (fun x => -CR_of_Q R (Z.of_nat n # 1) <= x
590 /\ x <= CR_of_Q R (Z.of_nat n # 1)
591 /\ A x) in
592 forall n:nat, partialFuncLe (fn n) (fn (S n)).
593 Proof.
594 intros R A fn n x xdf xdg. simpl.
595 destruct xdf.
596 - destruct xdg. apply CRle_refl. exfalso.
597 apply n0. destruct a, H0. repeat split. 3: exact H1.
598 apply (CRle_trans _ (- CR_of_Q R (Z.of_nat n # 1))).
599 apply CRopp_ge_le_contravar. apply CR_of_Q_le.
600 unfold Qle, Qnum, Qden.
601 do 2 rewrite Z.mul_1_r. apply Nat2Z.inj_le, le_S, Nat.le_refl. exact H.
602 apply (CRle_trans _ (CR_of_Q R (Z.of_nat n # 1)) _ H0).
603 apply CR_of_Q_le. unfold Qle, Qnum, Qden.
604 do 2 rewrite Z.mul_1_r. apply Nat2Z.inj_le, le_S, Nat.le_refl.
605 - destruct xdg. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
606 Qed.
607
608 (* A classical hypothesis, to explain the relation with the
609 classical Lebesgue measure. *)
610 Definition IncrSeqCvT : Type
611 := forall (R : ConstructiveReals) (un : nat -> CRcarrier R) (a : CRcarrier R),
612 (forall n:nat, un n <= un (S n))
613 -> (forall n:nat, un n <= a)
614 -> CR_cauchy R un.
615
616 (* This proves that a Lebesgue-measurable function is Bishop-measurable,
617 when we assume the classical theorem IncrSeqCvT.
618 Because non-negative Lebesgue-measurable functions are non-decreasing
619 limits of simple functions, which are Bishop-measurable. *)
620 Definition MeasurableMonotoneConvergenceClassical
621 {IS : IntegrationSpace}
622 (fn : nat -> PartialFunction (X (ElemFunc IS)))
623 : (forall n:nat, MeasurableFunction (fn n))
624 -> (forall n:nat, partialFuncLe (fn n) (fn (S n)))
625 -> IncrSeqCvT
626 (* The sequence fn is assumed to converge everywhere,
627 because the sequence fn is derived from a hypothetical
628 Lebesgue-measurable function f, that we want to prove
629 is Bishop-integrable.
630
631 This hypothesis is necessary, to replace the convergence of
632 integrals in the constructive monotone convergence theorem.
633 For example, the sequence of constant measurable functions n
634 converges nowhere, so we cannot conclude that the empty
635 function is measurable. *)
636 -> (forall x : X (ElemFunc IS),
637 Domain (XpointwiseLimit fn) x)
638 -> MeasurableFunction (XpointwiseLimit fn).
639 Proof.
640 intros fnMes H cl cv A k Aint.
641 assert (forall n:nat, partialFuncLe
642 (XmaxConst (XminConst (Xmult (CharacFunc A) (fn n)) (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
643 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1)))
644 (XmaxConst
645 (XminConst (Xmult (CharacFunc A) (fn (S n))) (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
646 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1)))).
647 { intros n x xdf xdg.
648 simpl. destruct xdf, xdg. destruct d.
649 destruct d1. 2: contradiction. rewrite CRmult_1_l, CRmult_1_l.
650 apply CRmax_lub.
651 apply (CRle_trans _ (CRmin (partialApply (fn (S n)) x d2) (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))).
652 2: apply CRmax_l.
653 apply CRmin_glb. 2: apply CRmin_r.
654 apply (CRle_trans _ (partialApply (fn n) x d0)).
655 apply CRmin_l. apply H. apply CRmax_r.
656 destruct d1. contradiction. rewrite CRmult_0_l, CRmult_0_l. apply CRle_refl. }
657 assert (forall n : nat,
658 (fun n0 : nat => Integral (fnMes n0 A k Aint)) n <=
659 (fun n0 : nat => Integral (fnMes n0 A k Aint)) (S n)).
660 { intro n. apply IntegralNonDecreasing. apply H0. }
661 assert (forall n : nat,
662 (fun n0 : nat => Integral (fnMes n0 A k Aint)) n <=
663 MeasureSet Aint * CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)).
664 { intro n.
665 apply (CRle_trans _ (Integral (IntegrableScale (CharacFunc A)
666 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1))
667 Aint))).
668 apply IntegralNonDecreasing. intros x xdf xdg.
669 simpl. destruct xdf, xdg. destruct d. 2: contradiction.
670 rewrite CRmult_1_l, CRmult_1_r. apply CRmax_lub.
671 apply CRmin_r. apply CR_of_Q_le. discriminate.
672 destruct d. contradiction. rewrite CRmult_0_l, CRmult_0_r.
673 apply CRmax_lub. apply CRmin_l.
674 apply CR_of_Q_le. discriminate.
675 rewrite IntegralScale. apply CRle_refl. }
676 destruct (CR_complete _ _ (cl _ (fun n => Integral (fnMes n A k Aint))
677 (MeasureSet Aint * CR_of_Q _ (Z.pos k # 1))
678 H1 H2)) as [l lcv].
679 destruct (IntegralMonotoneConvergence
680 IS (fun n => XmaxConst
681 (XminConst (Xmult (CharacFunc A) (fn n))
682 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1))) (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1)))
683 (fun n => fnMes n A k Aint) l H0 lcv).
684 apply (IntegrableFunctionExtensional
685 (XpointwiseLimit
686 (fun n : nat =>
687 XmaxConst
688 (XminConst (Xmult (CharacFunc A) (fn n)) (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
689 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1))))).
690 2: exact x.
691 split. intros y ydf. simpl. simpl in ydf. destruct ydf.
692 split. exact (fst (x0 O)). exists (fun n => snd (x0 n)).
693 specialize (cv y). destruct cv.
694 apply (CR_cauchy_eq (fun n : nat => partialApply (fn n) y (x1 n))).
695 2: exact c1. intro n. apply DomainProp.
696 intros. apply applyPointwiseLimit. apply CR_cv_max.
697 apply CR_cv_min. destruct xD, xG. destruct d.
698 - setoid_replace (partialApply (Xmult (CharacFunc A) (XpointwiseLimit fn)) x0 (left a, d0))
699 with (partialApply (XpointwiseLimit fn) x0 d0).
700 2: simpl; rewrite CRmult_1_l; reflexivity.
701 pose proof (applyPointwiseLimit fn x0 d0
702 (partialApply (XpointwiseLimit fn) x0 d0)) as [H3 _].
703 apply (CR_cv_eq _ (fun n : nat => partialApply (fn n) x0 (let (xn, _) := d0 in xn n))).
704 intro n. simpl. destruct (x1 n), d. rewrite CRmult_1_l. apply DomainProp.
705 contradiction. apply H3. reflexivity.
706 - setoid_replace (partialApply (Xmult (CharacFunc A) (XpointwiseLimit fn)) x0 (right n, d0))
707 with (CR_of_Q (RealT (ElemFunc IS)) 0).
708 2: simpl; rewrite CRmult_0_l; reflexivity.
709 apply (CR_cv_eq _ (fun _ => 0)). intros.
710 simpl. destruct (x1 n0), d. contradiction. rewrite CRmult_0_l. reflexivity.
711 intro p. exists O. intros. unfold CRminus.
712 rewrite CRplus_opp_r, CRabs_right.
713 apply CR_of_Q_le. discriminate. apply CRle_refl.
714 Qed.
715
716 (*
717 Lemma MeasurableSetUnionCountable
718 : forall {IS : IntegrationSpace}
719 (An : nat -> ((X (ElemFunc IS)) -> Prop)),
720 (forall n:nat, MeasurableSet (An n))
721 -> IncrSeqCvT (* Maybe we can weaken this classical hypothesis *)
722 -> MeasurableSet (fun x => exists n:nat, An n x).
723 Proof.
724 intros IS An AnMeas IncrSeqCv.
725 apply MeasurableSetEquiv.
726 intros B Bint.
727 (* Integrate union intersected with B by the monotone convergence theorem.
728 The limit of the intersected integrals will come from majoration and
729 IncrSeqCv. *)
730 assert (forall n : nat, IntegrableFunction
731 (Xmult (CharacFunc (UnionIterate An n)) (CharacFunc B)))
732 as unionMes.
733 { intro n. pose proof (MeasurableSetUnionIterate An AnMeas).
734 pose proof (MeasurableSetEquiv (UnionIterate An n)) as [mes _].
735 exact (mes (X n) B Bint). }
736 assert (forall n : nat, @partialFuncLe (RealT (ElemFunc IS)) _
737 (Xmult (CharacFunc (UnionIterate An n)) (CharacFunc B))
738 (Xmult (CharacFunc (UnionIterate An (S n))) (CharacFunc B))).
739 { intros n x xdf xdg. simpl. destruct xdf, xdg.
740 destruct d0. destruct d2. 2: contradiction.
741 rewrite CRmult_1_r, CRmult_1_r. destruct d. destruct d1.
742 apply CRle_refl. contradict n0. left. exact u.
743 destruct d1. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
744 rewrite CRmult_0_r. destruct d2. contradiction.
745 rewrite CRmult_0_r. apply CRle_refl. }
746 assert (forall n : nat, Integral (unionMes n) <= Integral Bint).
747 { shelve. }
748 specialize (IncrSeqCv _ (fun n : nat => Integral (unionMes n))
749 (Integral Bint)
750 (fun n => IntegralNonDecreasing _ _ _ _ (H n)) H0).
751 apply CR_complete in IncrSeqCv. destruct IncrSeqCv as [l lcv].
752 destruct (IntegralMonotoneConvergence
753 IS (fun n => Xmult (CharacFunc (UnionIterate An n)) (CharacFunc B))
754 unionMes l H lcv) as [limInt _].
755 apply (IntegrableFunctionExtensional
756 (XpointwiseLimit
757 (fun n : nat => Xmult (CharacFunc (UnionIterate An n)) (CharacFunc B)))).
758 2: exact limInt. split.
759 - intros x [xn c]. split. 2: apply (xn O).
760 clear lcv l. apply CR_complete in c. destruct c as [l lcv].
761 split. 2: exact H1. destruct H2 as [xn c].
762
763 destruct H. simpl.
764 destruct H0.
765 left. destruct e. exists x0. apply H. right. intro abs.
766 contradict n. destruct abs. exists x0. split; assumption.
767 destruct H0. exfalso. destruct e, H. contradiction.
768 simpl. right. intro abs. destruct abs.
769 + intros x [H|H]. simpl. left. destruct H. split.
770 exists x0. apply H. apply H. right. intros [[n H0] H1].
771 apply H. exists n. split; assumption.
772 + intros. simpl. destruct xD, xG. reflexivity.
773 exfalso. apply n. destruct e. split. exists x0.
774 apply H. apply H.
775 exfalso. apply n. destruct a, H. exists x0. split; assumption.
776 reflexivity.
777 - assert (forall n:nat, IntegrableSet (fun x => An n x /\ B x)) as AnInt.
778 { intro n. apply AnMeas, Bint. }
779 specialize (IncrSeqCv _ (fun n : nat =>
780 MeasureSet
781 (IntegrableSetUnionIterate
782 (fun (n0 : nat) (x : X (ElemFunc IS)) => An n0 x /\ B x) AnInt n))
783 (MeasureSet Bint)).
784 apply CR_complete in IncrSeqCv.
785 destruct IncrSeqCv as [l lim].
786 + apply (IntegrableSetCountableUnion _ AnInt l lim).
787 + intros. apply IntegralNonDecreasing. intros x xdf xdg.
788 simpl. destruct xdf. destruct xdg. apply CRle_refl.
789 exfalso. apply n0. apply applyUnionIterate.
790 apply applyUnionIterate in u. destruct u. exists x0.
791 destruct H, H0. repeat split; try assumption.
792 apply (Nat.le_trans _ _ _ H), le_S, le_refl.
793 destruct xdg. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
794 + intros. apply IntegralNonDecreasing. intros x xdf xdg.
795 simpl. destruct xdf. destruct xdg. apply CRle_refl.
796 exfalso. apply applyUnionIterate in u. destruct u, H, H0.
797 contradiction.
798 destruct xdg. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
799 Qed.
800 *)
801
802 Definition IntegralSupport {IS : IntegrationSpace}
803 (f : PartialFunction (X (ElemFunc IS)))
804 (fInt : IntegrableFunction f)
805 (A : (X (ElemFunc IS)) -> Prop)
806 (eps : CRcarrier (RealT (ElemFunc IS))) : Type :=
807 { isupp_int : IntegrableSet A
808 & IntegralDistance
809 fInt (RestrictedIntegrable fInt isupp_int) < eps }.
810
811 Lemma IntegralSupportExists
812 : forall {IS : IntegrationSpace}
813 (f : PartialFunction (X (ElemFunc IS)))
814 (fInt : IntegrableFunction f)
815 (eps : CRcarrier (RealT (ElemFunc IS))),
816 0 < eps
817 -> { t : CRcarrier _
818 & prod (t < eps)
819 (IntegralSupport
820 f fInt
821 (fun x => exists xD:Domain (Xabs f) x,
822 t <= partialApply (Xabs f) x xD) eps) }.
823 Proof.
824 intros.
825 pose proof (InverseImageIntegrableAE (Xabs f) (IntegrableAbs fInt))
826 as [jumps invIm].
827 pose proof (Un_cv_nat_real _ _ (IntegralTruncateLimitZero f fInt)
828 eps H) as [n nmaj].
829 pose proof (CRuncountable jumps 0 _ (CRmin_lt _ _ _ (invSuccRealPositive n) H))
830 as [t [[tpos tmin] tcont]].
831 specialize (invIm t tpos tcont) as [invIm _].
832 exists t. split. apply (CRlt_le_trans _ _ _ tmin). apply CRmin_r.
833 exists invIm.
834 specialize (nmaj n (Nat.le_refl n)). refine (CRle_lt_trans _ _ _ _ nmaj).
835 unfold CRminus. rewrite CRopp_0, CRplus_0_r, CRabs_right.
836 apply IntegralNonDecreasing. intros x xdf xdg.
837 destruct xdf, d0, d0.
838 - (* t <= |f x| *)
839 apply (CRle_trans _ 0).
840 simpl. rewrite CRmult_1_l.
841 rewrite <- CRopp_mult_distr_l, CRmult_1_l, (DomainProp f x d1 d).
842 rewrite CRplus_opp_r, CRabs_right. apply CRle_refl. apply CRle_refl.
843 simpl. apply CRmin_glb. apply CRabs_pos.
844 apply CR_of_Q_le. discriminate.
845 - (* |f x| < t *)
846 apply (CRle_trans _ (CRabs _ (partialApply f x d))).
847 simpl. rewrite CRmult_0_l, CRmult_0_r, CRplus_0_r. apply CRle_refl.
848 assert (CRabs _ (partialApply f x d) <= t).
849 { intro abs. contradict n0. exists d. apply CRlt_asym, abs. }
850 clear n0. apply CRmin_glb.
851 rewrite applyXabs, (DomainProp f x xdg d). apply CRle_refl.
852 apply (CRle_trans _ _ _ H0). apply CRlt_asym.
853 apply (CRlt_le_trans _ _ _ tmin). apply CRmin_l.
854 - apply IntegralNonNeg. intros x xdf. apply CRmin_glb.
855 apply CRabs_pos. apply CR_of_Q_le. discriminate.
856 Qed.
857
858 Definition RestrictedMeasurable_pos
859 {IS : IntegrationSpace}
860 (f : PartialFunction (X (ElemFunc IS)))
861 (A : (X (ElemFunc IS)) -> Prop)
862 : IntegrableFunction f
863 -> MeasurableSet A
864 -> nonNegFunc f
865 -> IntegrableFunction (Xmult (CharacFunc A) f).
866 Proof.
867 intros fInt Ames fPos.
868 (* Make a sequence of supports converging to f's integral. *)
869 assert (forall n:nat, 0 < CRpow (CR_of_Q (RealT (ElemFunc IS)) (1#2)) n).
870 { intro n. apply CRpow_gt_zero, CR_of_Q_pos. reflexivity. }
871 pose proof (fun n:nat => IntegralSupportExists
872 f fInt _ (H n)) as Bn.
873 assert (forall n:nat, IntegrableFunction
874 (Xmult (CharacFunc (fun x => A x /\ let (t,_) := Bn n in
875 exists xD : Domain (Xabs f) x, t <= partialApply (Xabs f) x xD
876 )) f))
877 as fnInt.
878 { intro n. apply (RestrictedIntegrable fInt).
879 pose proof (MeasurableSetEquiv A) as [H0 _].
880 destruct (Bn n) as [t p], p, i as [i c0].
881 specialize (H0 Ames _ i).
882 refine (IntegrableFunctionExtensional _ _ _ H0).
883 split. intros x xdf. destruct xdf, d.
884 2: right; intro abs; destruct abs; contradiction.
885 destruct d0. left. split; assumption.
886 right; intro abs; destruct abs; contradiction.
887 intros. destruct xD. simpl. destruct d.
888 rewrite CRmult_1_l. destruct d0,xG. reflexivity.
889 contradict n0. split; assumption.
890 contradict n0. apply a0. reflexivity. rewrite CRmult_0_l.
891 destruct xG. contradict n0. apply a. reflexivity. }
892 assert (forall n:nat, IntegrableFunction
893 (Xmult (CharacFunc (fun x => let (t,_) := Bn n in
894 exists xD : Domain (Xabs f) x, t <= partialApply (Xabs f) x xD)) f))
895 as gnInt.
896 { intro n. apply (RestrictedIntegrable fInt).
897 destruct (Bn n) as [t p], p, i as [i c0]. exact i. }
898 destruct (series_cv_maj
899 (fun n : nat =>
900 Integral (IntegrableAbs (IntegrableMinus (fnInt (S n)) (fnInt n))))
901 (fun n:nat => CRpow (CR_of_Q (RealT (ElemFunc IS)) (1#2)) n
902 * CR_of_Q _ 2)
903 (CR_of_Q _ 2 * CR_of_Q _ 2)) as [l lcv].
904 - intro n. rewrite CRabs_right.
905 2: apply IntegralNonNeg; intros x xdf; apply CRabs_pos.
906 apply (CRle_trans _ (Integral (IntegrableAbs (IntegrableMinus (gnInt (S n)) (gnInt n))))).
907 apply IntegralNonDecreasingAE.
908 destruct (Bn n) as [t p], p, i as [i c0].
909 exists (Xmult (CharacFunc A) (CharacFunc (fun x =>
910 exists xD : Domain (Xabs f) x, t <= partialApply (Xabs f) x xD
911 ))).
912 split.
913 pose proof (MeasurableSetEquiv A) as [H0 _].
914 specialize (H0 Ames _ i). exact H0.
915 intros x xdA xdf xdg.
916 simpl. destruct xdf, xdg, d, d1, d0, d2. destruct xdA, d7.
917 + (* x in A *)
918 rewrite (DomainProp f x d6 d5). clear d6.
919 rewrite (DomainProp f x d4 d3). clear d4.
920 destruct d. destruct d1. 2: contradict n0; apply a0.
921 destruct d0. destruct d2. apply CRle_refl.
922 contradict n0. apply a1. destruct d2. 2: apply CRle_refl.
923 contradict n0. split. exact a. exact e.
924 destruct d1. contradict n0. split. exact a. apply y.
925 destruct d0. destruct d2. apply CRle_refl.
926 contradict n2. apply a0. destruct d2. 2: apply CRle_refl.
927 contradict n2. split. exact a. exact e.
928 + (* x not in A *)
929 destruct d. contradict n0. apply a. rewrite CRmult_0_l.
930 destruct d0. contradict n0. apply a. rewrite CRmult_0_l.
931 rewrite CRmult_0_r, CRplus_0_r, CRabs_right.
932 apply CRabs_pos. apply CRle_refl.
933 + apply (CRle_trans _ _ _ (IntegralDistance_triang _ _ _ _ fInt _)).
934 rewrite (CR_of_Q_plus _ 1 1), CRmult_plus_distr_l.
935 rewrite CRmult_1_r. apply CRplus_le_compat. generalize (gnInt (S n)).
936 intro i. simpl in i. destruct (Bn (S n)), p, i0.
937 apply CRlt_asym, (CRlt_trans _ (CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) (S n))).
938 refine (CRle_lt_trans _ _ _ _ c0).
939 apply IntegralNonDecreasing. intros y ydf ydg.
940 rewrite (DomainProp _ y ydf ydg). apply CRle_refl.
941 apply (CRlt_le_trans _ (CR_of_Q _ 1
942 * CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) n)).
943 apply CRmult_lt_compat_r. apply CRpow_gt_zero, CR_of_Q_pos. reflexivity.
944 apply CR_of_Q_lt. reflexivity.
945 rewrite CRmult_1_l. apply CRle_refl.
946 generalize (gnInt n).
947 intro i. simpl in i. destruct (Bn n), p, i0.
948 apply CRlt_asym. refine (CRle_lt_trans _ _ _ _ c0).
949 apply IntegralNonDecreasing. intros y ydf ydg.
950 rewrite (DomainProp _ y ydf ydg). apply CRle_refl.
951 - apply series_cv_scale. exact GeoHalfTwo.
952 - destruct (IntegrableXpointwiseLimit _ fnInt l (fst lcv)) as [limInt _].
953 pose proof (MeasurableFunctionFull _ Ames) as [h hint].
954 refine (IntegrableExtensionalAE _ _ _ _ limInt). destruct hint.
955 + exists (Xplus h f). split. exact (IntegrablePlus _ _ i fInt).
956 intros. destruct H0. split.
957 specialize (d x d0). exact d. exact d1.
958 + exists h. destruct hint. split. exact i. intros.
959 clear d H0 i h. destruct dG. apply applyPointwiseLimit.
960 intro p. destruct (CRltLinear (RealT (ElemFunc IS))) as [_ s].
961 assert (0 < CR_of_Q (RealT (ElemFunc IS)) (1 # (2*p))).
962 { apply CR_of_Q_pos. reflexivity. }
963 specialize (s 0 (partialApply f x d0) _ H0) as [c|c].
964 * (* 0 < f x. x will eventually be in the support,
965 then the left term becomes 0. *)
966 simpl in c.
967 apply (CR_cv_open_above _ _ _ (@GeoCvZero (RealT (ElemFunc IS)))) in c.
968 destruct c as [n nmaj]. exists n. intros i H1.
969 specialize (nmaj i H1). destruct dF.
970 generalize (x0 i). intros.
971 destruct (Bn i) as [t r], r, i0 as [j c1], d1.
972 simpl. rewrite (DomainProp f x d2 d0). clear d2.
973 destruct d. destruct d1. unfold CRminus.
974 rewrite CRplus_opp_r, CRabs_right.
975 apply CR_of_Q_le. discriminate. apply CRle_refl.
976 contradict n0. split. exact a. exists d0.
977 apply CRlt_asym, (CRlt_trans _ _ _ c0), (CRlt_le_trans _ _ _ nmaj).
978 apply CRle_abs. destruct d1. destruct a. contradiction.
979 unfold CRminus.
980 rewrite CRmult_0_l, CRplus_opp_r, CRabs_right.
981 apply CR_of_Q_le. discriminate. apply CRle_refl.
982 * (* f x < 1 / 2p *)
983 exists O. intros.
984 apply (CRle_trans _ _ _ (CRabs_triang _ _)).
985 setoid_replace (1#p) with ((1#(2*p)) + (1#(2*p)))%Q.
986 2: rewrite Qinv_plus_distr; reflexivity.
987 rewrite CR_of_Q_plus. apply CRplus_le_compat.
988 destruct dF, (x0 i). simpl. destruct d1.
989 rewrite CRmult_1_l, CRabs_right, (DomainProp f x d2 d0).
990 apply CRlt_asym, c. apply fPos. rewrite CRmult_0_l, CRabs_right.
991 apply CR_of_Q_le. discriminate. apply CRle_refl.
992 rewrite CRabs_opp. simpl. destruct d.
993 rewrite CRmult_1_l, CRabs_right. apply CRlt_asym, c.
994 apply fPos. rewrite CRmult_0_l, CRabs_right.
995 apply CR_of_Q_le. discriminate. apply CRle_refl.
996 Qed.
997
998 Definition RestrictedMeasurable
999 {IS : IntegrationSpace}
1000 {f : PartialFunction (X (ElemFunc IS))}
1001 {A : (X (ElemFunc IS)) -> Prop}
1002 : IntegrableFunction f
1003 -> MeasurableSet A
1004 -> IntegrableFunction (Xmult (CharacFunc A) f).
1005 Proof.
1006 intros fInt Ames.
1007 apply (IntegrableFunctionExtensional
1008 (Xminus (Xmult (CharacFunc A) (XposPart f))
1009 (Xmult (CharacFunc A) (XnegPart f)))).
1010 - split. intros x xdf. destruct xdf. split. apply d. apply d.
1011 intros. destruct xD, xG.
1012 rewrite (applyXmult _ _ x d1 d2).
1013 rewrite <- (SplitPosNegParts _ x _ (snd d) (snd d0)).
1014 rewrite (applyXminus (Xmult (CharacFunc A) (XposPart f))
1015 (Xmult (CharacFunc A) (XnegPart f)) x d d0).
1016 destruct d, d0.
1017 rewrite (applyXmult _ _ x d d3), (applyXmult _ _ x d0 d4).
1018 rewrite (DomainProp _ x d0 d), (DomainProp _ x d1 d).
1019 unfold CRminus. rewrite CRmult_plus_distr_l, CRopp_mult_distr_r.
1020 reflexivity.
1021 - apply IntegrableMinus. apply RestrictedMeasurable_pos.
1022 apply IntegrablePosPart, fInt. exact Ames.
1023 apply applyXposPartNonNeg.
1024 apply RestrictedMeasurable_pos.
1025 apply IntegrableNegPart, fInt. exact Ames.
1026 apply applyXnegPartNonNeg.
1027 Qed.
1028
1029
1030 (* IntegrableSet (fun x => A x /\ ~B x) is not enough,
1031 because it leads to ~~B. *)
1032 Record SetApprox {IS : IntegrationSpace}
1033 (A : (X (ElemFunc IS)) -> Prop) (Aint : IntegrableSet A)
1034 (eps : CRcarrier (RealT (ElemFunc IS))) : Type
1035 := { sa_approx : (X (ElemFunc IS)) -> Prop;
1036 sa_bint : IntegrableSet sa_approx;
1037 sa_mes : MeasureSet Aint - MeasureSet sa_bint < eps;
1038 sa_inc : forall x, sa_approx x -> A x; }.
1039
1040 (* Generators for integrable sets, akin to a basis for a topology. *)
1041 Definition IntegrableSetsGen (IS : IntegrationSpace) : Type
1042 := forall (A : (X (ElemFunc IS)) -> Prop) (Aint : IntegrableSet A)
1043 (eps : CRcarrier (RealT (ElemFunc IS))),
1044 0 < eps -> SetApprox A Aint eps.
1045
1046 (* Increasing sequence of subsets of A that converge towards A,
1047 and which disjoint increments are generators. *)
1048 Fixpoint IntegrableApproxSequence
1049 {IS : IntegrationSpace}
1050 (gen : IntegrableSetsGen IS)
1051 (A : (X (ElemFunc IS)) -> Prop) (Aint : IntegrableSet A)
1052 (n : nat) {struct n}
1053 : { U : X (ElemFunc IS) -> Prop & IntegrableSet U }.
1054 Proof.
1055 destruct n as [|p].
1056 - destruct (gen A Aint 1 (CRzero_lt_one _)).
1057 exists sa_approx0. exact sa_bint0.
1058 - destruct (IntegrableApproxSequence IS gen A Aint p) as [U Uint].
1059 exists (fun x => U x \/ (sa_approx _ _ _ (gen _ (IntegrableSetDifference A U Aint Uint)
1060 (CRpow (CR_of_Q _ (1#2)) (S p))
1061 (CRpow_gt_zero _ (S p) (CR_of_Q_pos (1#2) eq_refl))) x)).
1062 exact (IntegrableSetUnion _ _ Uint (sa_bint _ _ _ (gen _ (IntegrableSetDifference A U Aint Uint)
1063 (CRpow (CR_of_Q _ (1#2)) (S p))
1064 (CRpow_gt_zero _ (S p) (CR_of_Q_pos (1#2) eq_refl))))).
1065 Defined.
1066
1067 Lemma IntegrableApproxSequenceInc
1068 : forall {IS : IntegrationSpace}
1069 (gen : IntegrableSetsGen IS)
1070 (A : X (ElemFunc IS) -> Prop)
1071 (Aint : IntegrableSet A) (n : nat) (x : X (ElemFunc IS)),
1072 let (U,_) := IntegrableApproxSequence gen A Aint n in
1073 U x -> A x.
1074 Proof.
1075 induction n.
1076 - intros. simpl. destruct (gen A Aint 1 (CRzero_lt_one (RealT (ElemFunc IS)))).
1077 apply sa_inc0.
1078 - intros. simpl. destruct (IntegrableApproxSequence gen A Aint n).
1079 intros. destruct H. apply IHn, H.
1080 apply (sa_inc _ _ _ _ x H).
1081 Qed.
1082
1083 Lemma IntegrableApproxSequenceIncr
1084 : forall {IS : IntegrationSpace}
1085 (gen : IntegrableSetsGen IS)
1086 (A : X (ElemFunc IS) -> Prop)
1087 (Aint : IntegrableSet A) (i j : nat) (x : X (ElemFunc IS)),
1088 le i j
1089 -> (let (U,_) := IntegrableApproxSequence gen A Aint i in U x)
1090 -> (let (U,_) := IntegrableApproxSequence gen A Aint j in U x).
1091 Proof.
1092 induction j.
1093 - intros. inversion H. subst i. exact H0.
1094 - intros. apply Nat.le_succ_r in H. destruct H.
1095 specialize (IHj x H).
1096 simpl; destruct (IntegrableApproxSequence gen A Aint j).
1097 left. exact (IHj H0). subst i. exact H0.
1098 Qed.
1099
1100 Lemma IntegrableApproxSequenceBound
1101 : forall {IS : IntegrationSpace}
1102 (gen : IntegrableSetsGen IS)
1103 (A : X (ElemFunc IS) -> Prop)
1104 (Aint : IntegrableSet A) (n : nat)
1105 (Uint : IntegrableSet
1106 (let (U,_) := IntegrableApproxSequence gen A Aint n in U)),
1107 MeasureSet Aint - MeasureSet Uint
1108 < CRpow (CR_of_Q _ (1#2)) n.
1109 Proof.
1110 intros. destruct n.
1111 - simpl. simpl in Uint.
1112 destruct (gen A Aint 1 (CRzero_lt_one (RealT (ElemFunc IS)))).
1113 apply (CRle_lt_trans
1114 _ (MeasureSet Aint - MeasureSet sa_bint0)).
1115 apply CRplus_le_compat_l, CRopp_ge_le_contravar.
1116 apply MeasureNonDecreasing. intros. exact H.
1117 exact sa_mes0.
1118 - simpl.
1119 pose proof (IntegrableApproxSequenceInc gen A Aint n) as Uinc.
1120 simpl in Uint;
1121 destruct (IntegrableApproxSequence gen A Aint n) as [U Vint].
1122 apply (CRle_lt_trans _ (MeasureSet (IntegrableSetDifference A U Aint Vint)
1123 - MeasureSet (sa_bint _ _ _
1124 (gen (fun x0 : X (ElemFunc IS) => A x0 /\ ~ U x0)
1125 (IntegrableSetDifference A U Aint Vint)
1126 (CR_of_Q (RealT (ElemFunc IS)) (1 # 2) *
1127 CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) n)
1128 (CRpow_gt_zero (CR_of_Q (RealT (ElemFunc IS)) (1 # 2))
1129 (S n) (CR_of_Q_pos (1 # 2) eq_refl)))))).
1130 2: apply sa_mes.
1131 rewrite <- MeasureDifferenceIncluded, <- MeasureDifferenceIncluded.
1132 apply MeasureNonDecreasing. intros. destruct H.
1133 split. split. exact H. intro abs. apply H0. left. exact abs.
1134 intro abs. apply H0. right. exact abs. intros.
1135 exact (sa_inc _ _ _ _ x H). intros. destruct H.
1136 2: exact (proj1 (sa_inc _ _ _ _ x H)). apply Uinc, H.
1137 Qed.
1138
1139 Lemma IntegrableApproxSequenceLimit
1140 : forall {IS : IntegrationSpace}
1141 (gen : IntegrableSetsGen IS)
1142 (A : X (ElemFunc IS) -> Prop)
1143 (Aint : IntegrableSet A),
1144 { intUnion : IntegrableSet
1145 (fun x => exists n:nat, let (U,_) := IntegrableApproxSequence
1146 gen A Aint n in U x)
1147 | MeasureSet intUnion == MeasureSet Aint }.
1148 Proof.
1149 intros.
1150 assert (forall n:nat, IntegrableSet
1151 (fun x => let (U, _) := IntegrableApproxSequence gen A Aint n in U x))
1152 as seqInt.
1153 { intro n. destruct (IntegrableApproxSequence gen A Aint n). exact i. }
1154 apply (IntegrableSetCountableUnion
1155 (fun n x => let (U,_) := IntegrableApproxSequence gen A Aint n in U x)
1156 seqInt (MeasureSet Aint)).
1157 intro p. pose proof (@GeoCvZero (RealT (ElemFunc IS)) p) as [n ncv].
1158 exists n. intros i H.
1159 rewrite CRabs_minus_sym, CRabs_right.
1160 - apply (CRle_trans _ (MeasureSet Aint - MeasureSet (seqInt i))).
1161 apply CRplus_le_compat_l, CRopp_ge_le_contravar.
1162 apply MeasureNonDecreasing. intros.
1163 apply applyUnionIterate. exists i. exact (conj (Nat.le_refl i) H0).
1164 specialize (ncv i H).
1165 apply (CRle_trans _ (CRpow (CR_of_Q _ (1#2)) i)).
1166 generalize (seqInt i). intro iint.
1167 pose proof (IntegrableApproxSequenceBound gen A Aint i).
1168 destruct (IntegrableApproxSequence gen A Aint i).
1169 apply CRlt_asym, X.
1170 unfold CRminus in ncv. rewrite CRopp_0, CRplus_0_r, CRabs_right in ncv.
1171 exact ncv. apply CRpow_ge_zero. apply CR_of_Q_le. discriminate.
1172 - rewrite <- (CRplus_opp_r (MeasureSet Aint)).
1173 apply CRplus_le_compat_l, CRopp_ge_le_contravar.
1174 apply MeasureNonDecreasing. intros. apply applyUnionIterate in H0.
1175 destruct H0, H0.
1176 pose proof (IntegrableApproxSequenceInc gen A Aint x0 x).
1177 destruct (IntegrableApproxSequence gen A Aint x0). exact (H2 H1).
1178 Qed.
1179
1180 (* It is enough to truncate on generator sets to prove that
1181 a function is measurable. Bishop's lemma 4.9. *)
1182 Lemma MeasurableGen
1183 : forall {IS : IntegrationSpace}
1184 (h : PartialFunction (X (ElemFunc IS))),
1185 (forall (A : (X (ElemFunc IS)) -> Prop) (Aint : IntegrableSet A)
1186 (k : positive)
1187 (eps : CRcarrier (RealT (ElemFunc IS))) (epsPos : 0 < eps),
1188 { B : SetApprox A Aint eps &
1189 IntegrableFunction
1190 (XmaxConst (XminConst (Xmult (CharacFunc (sa_approx _ _ _ B)) h)
1191 (CR_of_Q _ (Z.pos k # 1)))
1192 (CR_of_Q _ (Z.neg k # 1))) })
1193 -> MeasurableFunction h.
1194 Proof.
1195 intros IS f fMes A n Aint.
1196 pose (fun S Sint eps epsPos => let (B,_) := fMes S Sint n eps epsPos in B) as gen.
1197 (* Make a disjoint sequence of subsets B_k that converges to A
1198 in measure. Bound h by n so that B_k h converges monotonically
1199 towards (union B_k) h. *)
1200 pose (fun k:nat => match k with
1201 | O => let (U,_):=IntegrableApproxSequence gen A Aint O in U
1202 | S i => let (U,Uint):=IntegrableApproxSequence gen A Aint i in
1203 sa_approx _ _ _
1204 (gen _ (IntegrableSetDifference A U Aint Uint)
1205 (CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) k)
1206 (CRpow_gt_zero (CR_of_Q (RealT (ElemFunc IS)) (1 # 2))
1207 k (CR_of_Q_pos (1 # 2) eq_refl)))
1208 end) as Bk.
1209 assert (forall k:nat, IntegrableSet (Bk k)) as BkInt.
1210 { intro k. unfold Bk. destruct k.
1211 - destruct (IntegrableApproxSequence gen A Aint 0). exact i.
1212 - destruct (IntegrableApproxSequence gen A Aint k). apply sa_bint. }
1213 assert (forall k:nat, Integral (BkInt (S k)) <= CRpow (CR_of_Q _ (1 # 2)) k) as BkMaj.
1214 { intro k. pose proof (IntegrableApproxSequenceBound gen A Aint k).
1215 pose proof (IntegrableApproxSequenceInc gen A Aint k).
1216 destruct (IntegrableApproxSequence gen A Aint k) as [U Uint] eqn:des.
1217 apply (CRle_trans _ (MeasureSet (IntegrableSetDifference A U Aint Uint))).
1218 apply IntegralNonDecreasing. intros x xdf xdg.
1219 simpl. simpl in xdf. destruct xdf. rewrite des in y.
1220 destruct xdg. apply CRle_refl. contradict n0.
1221 exact (sa_inc _ _ _ _ x y).
1222 destruct xdg. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
1223 rewrite MeasureDifferenceIncluded. apply CRlt_asym, X.
1224 intros. exact (H x H0). }
1225 pose (fun k:nat => (XmaxConst
1226 (XminConst
1227 (Xmult (CharacFunc (Bk k)) f)
1228 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos n # 1)))
1229 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg n # 1)))) as fk.
1230 assert (forall k:nat, IntegrableFunction (fk k)) as fkInt.
1231 { unfold fk, Bk. intro k. destruct k.
1232 - simpl. unfold gen.
1233 destruct (fMes A Aint n 1 (CRzero_lt_one (RealT (ElemFunc IS)))), x; apply i.
1234 - destruct (IntegrableApproxSequence gen A Aint k) as [U Uint].
1235 unfold gen.
1236 destruct (fMes (fun x : X (ElemFunc IS) => A x /\ ~ U x)
1237 (IntegrableSetDifference A U Aint Uint) n
1238 (CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) (S k))
1239 (CRpow_gt_zero (CR_of_Q (RealT (ElemFunc IS)) (1 # 2))
1240 (S k) (CR_of_Q_pos (1 # 2) eq_refl)))
1241 as [B Bint].
1242 refine (IntegrableFunctionExtensional _ _ _ Bint). split.
1243 + intros y yD. exact yD.
1244 + intros. rewrite (DomainProp _ x xD xG). reflexivity. }
1245 assert (forall (i : nat) x (xkD : forall k:nat, Domain (CharacFunc (Bk k)) x),
1246 (let (U, _) := IntegrableApproxSequence gen A Aint i in U x)
1247 -> @CRsum (RealT (ElemFunc IS))
1248 (fun k : nat => partialApply _ x (xkD k)) i == 1) as BkDisjoint.
1249 { induction i.
1250 - intros. simpl.
1251 destruct (xkD O). reflexivity. contradict n0.
1252 simpl. simpl in H.
1253 destruct (gen A Aint 1 (CRzero_lt_one (RealT (ElemFunc IS)))). exact H.
1254 - intros. specialize (IHi x xkD).
1255 simpl in H; destruct (IntegrableApproxSequence gen A Aint i) as [U Uint] eqn:des.
1256 destruct H.
1257 (* In U so last term is zero. *)
1258 specialize (IHi H). rewrite <- (CRplus_0_r 1). simpl.
1259 simpl in IHi. rewrite IHi. clear IHi. apply CRplus_morph. reflexivity.
1260 destruct (xkD (S i)). 2: reflexivity. exfalso.
1261 unfold Bk in b. rewrite des in b.
1262 pose proof (sa_inc _ _ _ _ x b). destruct H0. contradiction.
1263 (* Not in U x so all previous terms are 0 in the sum. *)
1264 clear IHi.
1265 rewrite <- (CRplus_0_l 1). simpl. apply CRplus_morph.
1266 pose proof (sa_inc _ _ _ _ x H). destruct H0. clear H.
1267 rewrite (CRsum_eq _ (fun k => 0)), sum_const, CRmult_0_l. reflexivity.
1268 intros. destruct (xkD i0). 2: reflexivity. contradict H1.
1269 pose proof (IntegrableApproxSequenceIncr
1270 gen A Aint i0 i x H). rewrite des in H1.
1271 apply H1. clear H1.
1272 unfold Bk in b. destruct i0.
1273 destruct (IntegrableApproxSequence gen A Aint 0); exact b.
1274 simpl; destruct (IntegrableApproxSequence gen A Aint i0).
1275 right. exact b.
1276 (* In last Bk so last term equals 1. *)
1277 destruct (xkD (S i)). reflexivity. contradict n0.
1278 simpl. rewrite des. exact H. }
1279 assert (forall (i j : nat) x (xkD : forall k:nat, Domain (fk k) x)
1280 (dG : Domain (Xmult (CharacFunc A) f) x),
1281 (let (U, _) := IntegrableApproxSequence gen A Aint j in U x)
1282 -> le j i
1283 -> CRsum (fun k : nat => partialApply (fk k) x (xkD k)) i
1284 == partialApply (XmaxConst
1285 (XminConst (Xmult (CharacFunc A) f)
1286 (CR_of_Q _ (Z.pos n # 1)))
1287 (CR_of_Q _ (Z.neg n # 1))) x dG) as fkDisjoint.
1288 { intros. unfold fk.
1289 rewrite (CRsum_eq _ (fun k:nat =>
1290 partialApply _ x (fst (xkD k))
1291 * partialApply (XmaxConst
1292 (XminConst f
1293 (CR_of_Q _ (Z.pos n # 1)))
1294 (CR_of_Q _ (Z.neg n # 1))) x
1295 (snd (xkD O)))).
1296 - rewrite sum_scale.
1297 rewrite (BkDisjoint i x (fun k => fst (xkD k))), CRmult_1_l.
1298 simpl. destruct dG, d. rewrite CRmult_1_l, (DomainProp f x _ d0).
1299 reflexivity. contradict n0.
1300 pose proof (IntegrableApproxSequenceInc gen A Aint j x).
1301 destruct (IntegrableApproxSequence gen A Aint j). exact (H1 H).
1302 exact (IntegrableApproxSequenceIncr
1303 gen A Aint j i x H0 H).
1304 - intros. simpl. destruct (xkD i0), d. simpl.
1305 do 2 rewrite CRmult_1_l. rewrite (DomainProp f x d0 (snd (xkD 0%nat))).
1306 reflexivity. simpl. rewrite CRmult_0_l, CRmult_0_l.
1307 rewrite CRmin_left, CRmax_left. reflexivity.
1308 apply CR_of_Q_le. discriminate.
1309 apply CR_of_Q_le. discriminate. }
1310 destruct (series_cv_maj (fun k : nat => Integral (IntegrableAbs (fkInt k)))
1311 (fun k => match k with
1312 | O => MeasureSet (BkInt O)
1313 | S i => (CRpow (CR_of_Q _ (1 # 2)) i) end
1314 * CR_of_Q _ (Z.pos n # 1))
1315 ((CR_of_Q _ 2 + MeasureSet (BkInt O))
1316 * CR_of_Q _ (Z.pos n # 1)))
1317 as [l lcv].
1318 - intro k. unfold fk. rewrite CRabs_right.
1319 apply (CRle_trans
1320 _ (Integral (IntegrableScale _ (CR_of_Q _ (Z.pos n # 1))
1321 (BkInt k)))).
1322 apply IntegralNonDecreasing. intros x xdf xdg.
1323 simpl. destruct xdf, xdg, d.
1324 rewrite CRmult_1_l, CRmult_1_r.
1325 apply CRabs_le. split. rewrite <- CR_of_Q_opp.
1326 setoid_replace (- (Z.pos n # 1))%Q with (Z.neg n # 1).
1327 apply CRmax_r. reflexivity. apply CRmax_lub.
1328 apply CRmin_r. apply CR_of_Q_le. discriminate.
1329 contradiction. contradiction.
1330 rewrite CRmult_0_l, CRmult_0_r. rewrite CRmin_left, CRmax_left, CRabs_right.
1331 apply CRle_refl. apply CRle_refl.
1332 apply CR_of_Q_le. discriminate.
1333 apply CR_of_Q_le. discriminate.
1334 rewrite IntegralScale, CRmult_comm.
1335 destruct k. rewrite CRmult_comm. apply CRle_refl.
1336 rewrite CRmult_comm. apply CRmult_le_compat_r.
1337 apply CR_of_Q_le. discriminate. exact (BkMaj k).
1338 apply IntegralNonNeg. intros x xdf. apply CRabs_pos.
1339 - apply series_cv_scale.
1340 apply (series_cv_shift (fun n0 : nat => match n0 with
1341 | 0%nat => MeasureSet (BkInt 0%nat)
1342 | S i => CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) i
1343 end) O); simpl. exact GeoHalfTwo.
1344 - destruct lcv.
1345 pose proof (IntegrableFunctionsComplete IS fk fkInt l s) as [rep repcv].
1346 apply (IntegrableExtensionalAE (XinfiniteSumAbs (IntFn rep))).
1347 + exists (Xplus (CharacFunc A) (XinfiniteSumAbs (IntFn rep))).
1348 split. apply IntegrablePlus. apply Aint.
1349 exists rep. apply PartialRestriction_refl. intros. split. exact (fst H).
1350 destruct repcv, p. clear c0. specialize (d x (snd H)).
1351 destruct d as [xn d]. pose proof (xn O). destruct H0. exact d1.
1352 + pose proof (IntegrableApproxSequenceLimit gen A Aint) as [Uint Umes].
1353 destruct (MeasureZeroAE _ (IntegrableSetDifference A _ Aint Uint)) as [h hInt].
1354 rewrite MeasureDifferenceIncluded.
1355 rewrite Umes. unfold CRminus. apply CRplus_opp_r.
1356 intros. destruct H.
1357 pose proof (IntegrableApproxSequenceInc gen A Aint x0 x).
1358 destruct (IntegrableApproxSequence gen A Aint x0). exact (H0 H).
1359 exists (Xplus (CharacFunc (fun x : X (ElemFunc IS) =>
1360 exists n : nat,
1361 let (U, _) := IntegrableApproxSequence gen A Aint n in U x))
1362 h).
1363 split. exact (IntegrablePlus _ _ Uint (fst hInt)).
1364 intros. destruct H, hInt. specialize (n0 x d0).
1365 destruct repcv, p. rewrite (c0 x dF (d1 x dF)). clear c0.
1366 destruct d.
1367 (* Inside union *)
1368 clear n0. destruct e. apply applyInfiniteSumAbs. intro p.
1369 exists x0. intros. rewrite (fkDisjoint i0 x0 x _ dG).
1370 unfold CRminus. rewrite CRplus_opp_r, CRabs_right.
1371 apply CR_of_Q_le. discriminate.
1372 apply CRle_refl. exact H. exact H0.
1373 (* Outside A *)
1374 assert (~ A x).
1375 { intro abs. apply n0. split; assumption. }
1376 clear n1 n0 i d0 h. transitivity (CR_of_Q (RealT (ElemFunc IS)) 0).
1377 apply applyInfiniteSumAbs.
1378 apply (CR_cv_eq _ (fun _ => 0)). 2: apply CR_cv_const.
1379 intros. rewrite <- (CRmult_0_l (INR (S n0))).
1380 rewrite (CRsum_eq _ (fun _ => 0)). symmetry. apply sum_const.
1381 intros. unfold fk. simpl.
1382 destruct (domainInfiniteSumAbsIncReverse
1383 (fun k : nat =>
1384 XmaxConst
1385 (XminConst (Xmult (CharacFunc (Bk k)) f)
1386 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos n # 1)))
1387 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg n # 1))) x
1388 (d1 x dF) i), d.
1389 contradict H. unfold Bk in b.
1390 destruct i.
1391 pose proof (IntegrableApproxSequenceInc gen A Aint O x).
1392 destruct (IntegrableApproxSequence gen A Aint 0). exact (H b).
1393 destruct (IntegrableApproxSequence gen A Aint i).
1394 exact (proj1 (sa_inc _ _ _ _ x b)).
1395 rewrite CRmult_0_l, CRmin_left, CRmax_left. reflexivity.
1396 apply CR_of_Q_le. discriminate.
1397 apply CR_of_Q_le. discriminate.
1398 simpl. destruct dG, d. contradiction.
1399 rewrite CRmult_0_l, CRmin_left, CRmax_left. reflexivity.
1400 apply CR_of_Q_le. discriminate.
1401 apply CR_of_Q_le. discriminate.
1402 + exists rep. apply PartialRestriction_refl.
1403 Qed.
1404
1405 Lemma CR_cv_maj : forall {R : ConstructiveReals}
1406 (un vn : nat -> CRcarrier R) (s : CRcarrier R),
1407 (forall n:nat, CRabs R (un (S n) - un n) <= vn n)
1408 -> series_cv vn s
1409 -> { l : CRcarrier R & prod (CR_cv _ un l) (l <= s + un O) }.
1410 Proof.
1411 intros.
1412 destruct (series_cv_maj (fun n => un (S n) - un n) vn s H H0) as [l [lcv lmaj]].
1413 apply (CR_cv_eq (fun n => un (S n) - un O)) in lcv.
1414 - exists (l + un O). split. apply (CR_cv_shift _ 1).
1415 apply (CR_cv_eq _ (fun n => un (S n) - un O + un O)).
1416 intros. unfold CRminus. rewrite CRplus_assoc, CRplus_opp_l, CRplus_0_r.
1417 rewrite Nat.add_comm. reflexivity. apply CR_cv_plus.
1418 exact lcv. apply CR_cv_const. unfold CRminus.
1419 apply CRplus_le_compat_r. exact lmaj.
1420 - induction n. reflexivity. simpl. rewrite IHn. clear IHn.
1421 rewrite CRplus_comm. unfold CRminus. rewrite CRplus_assoc.
1422 apply CRplus_morph. reflexivity.
1423 rewrite <- CRplus_assoc, CRplus_opp_l, CRplus_0_l. reflexivity.
1424 Qed.
1425
1426 (* Bishop's lemma 4.10. We strengthen the previous lemma by
1427 allowing the function to approximate within epsilon on each
1428 generator subset. This proves that continuous functions are
1429 measurable, because they are approximated by piecewise-constant functions. *)
1430 Lemma MeasurableGenApprox
1431 : forall {IS : IntegrationSpace}
1432 (h : PartialFunction (X (ElemFunc IS))),
1433 almost_everywhere (Domain h)
1434 -> (forall (A : (X (ElemFunc IS)) -> Prop) (Aint : IntegrableSet A)
1435 (n : positive)
1436 (eps : CRcarrier (RealT (ElemFunc IS))) (epsPos : 0 < eps),
1437 { fB : prod (PartialFunction (X (ElemFunc IS)))
1438 (SetApprox A Aint eps)
1439 & prod (IntegrableFunction (fst fB))
1440 (forall (x : X (ElemFunc IS)) (xdh : Domain h x)
1441 (xdf : Domain (fst fB) x),
1442 sa_approx _ _ _ (snd fB) x
1443 -> CRabs _ (partialApply (XmaxConst (XminConst h
1444 (CR_of_Q _ (Z.pos n # 1)))
1445 (CR_of_Q _ (Z.neg n # 1)))
1446 x xdh
1447 - partialApply _ x xdf) < eps) })
1448 -> MeasurableFunction h.
1449 Proof.
1450 intros IS h dom H. apply MeasurableGen.
1451 intros A Aint k eps epsPos. specialize (H A Aint k).
1452 (* We define another family of generator sets and call the previous lemma on it. *)
1453 assert (forall (i:nat), 0 < eps * CRpow (CR_of_Q _ (1 # 2)) i) as H0.
1454 { intros. apply (CRmult_lt_0_compat _ _ _ epsPos).
1455 apply CRpow_gt_zero, CR_of_Q_pos. reflexivity. }
1456 pose (fun (i:nat) => sa_approx
1457 _ _ _ (let (fB,_) := H (eps * CRpow (CR_of_Q _ (1#2)) (S i))
1458 (H0 (S i)) in
1459 snd fB))
1460 as Bi.
1461 assert ({ BI : IntegrableSet (fun x => forall i:nat, Bi i x)
1462 & MeasureSet Aint - MeasureSet BI < eps })
1463 as Bint.
1464 { destruct (CR_cv_maj
1465 (fun n => - MeasureSet (IntegrableSetIntersectIterate
1466 _ (fun i => sa_bint _ _ _ (let (fB,_) := H (eps * CRpow (CR_of_Q _ (1 # 2)) (S i)) (H0 (S i)) in snd fB)) n))
1467 (fun n => (CRpow (CR_of_Q _ (1 # 2)) (2 + n) * eps))
1468 (CR_of_Q _ (1 # 2) * eps)).
1469 intro n. unfold CRminus. rewrite CRopp_involutive, CRplus_comm.
1470 pose proof (@MeasureDifferenceIncluded IS). unfold CRminus in H1.
1471 rewrite <- H1, CRabs_right. clear H1.
1472 2: apply MeasureNonNeg.
1473 apply (CRle_trans _ (MeasureSet Aint
1474 - MeasureSet (sa_bint _ _ _
1475 (let (fB,_) := H (eps * CRpow (CR_of_Q _ (1 # 2)) (2 + n))
1476 (H0 (2 + n)%nat) in snd fB)))).
1477 rewrite <- MeasureDifferenceIncluded.
1478 apply MeasureNonDecreasing. intros. destruct H1. split.
1479 apply (sa_inc _ _ _ (let (fB,_) := H (eps * CRpow (CR_of_Q _ (1 # 2)) (S n))
1480 (H0 (S n)) in snd fB)).
1481 destruct n; apply H1. intro abs. contradict H2.
1482 split; assumption. apply sa_inc.
1483 rewrite <- (CRmult_comm eps). apply CRlt_asym. apply sa_mes.
1484 clear H1. intros. apply H1.
1485 apply (series_cv_eq (fun n : nat => CRpow (CR_of_Q _ (1 # 2)) n
1486 * ((CR_of_Q _ (1 # 2)) * (CR_of_Q _ (1 # 2)) * eps))).
1487 intros. simpl. rewrite <- CRmult_assoc.
1488 apply CRmult_morph. 2: reflexivity.
1489 rewrite (CRmult_comm (CRpow (CR_of_Q _ (1 # 2)) n)), <- CRmult_assoc.
1490 reflexivity.
1491 apply (CR_cv_proper _ (CR_of_Q _ 2 * (CR_of_Q _ (1 # 2) * CR_of_Q _ (1 # 2) * eps))).
1492 apply series_cv_scale. exact GeoHalfTwo.
1493 rewrite <- CRmult_assoc, <- CRmult_assoc, <- (CR_of_Q_mult _ 2).
1494 setoid_replace (2 * (1#2))%Q with 1%Q.
1495 rewrite CRmult_1_l. reflexivity. reflexivity.
1496 destruct p. simpl in c0. apply CR_cv_opp in c.
1497 apply (CR_cv_eq (fun n : nat => MeasureSet
1498 (IntegrableSetIntersectIterate
1499 _ (fun i : nat =>
1500 sa_bint A Aint
1501 (eps * CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) (S i))
1502 (let (fB, _) := H
1503 (eps * CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) (S i))
1504 (H0 (S i)) in snd fB)) n))) in c.
1505 destruct (IntegrableSetCountableIntersect _ _ _ c)
1506 as [intersectInt c1].
1507 exists intersectInt. clear c. rewrite <- CRopp_involutive, <- c1 in c0.
1508 clear c1 x. apply (CRplus_le_compat_l (MeasureSet Aint)) in c0.
1509 rewrite (CRplus_comm (CR_of_Q (RealT (ElemFunc IS)) (1 # 2) * eps)) in c0.
1510 rewrite <- CRplus_assoc in c0.
1511 apply (CRle_lt_trans _ _ _ c0). clear c0.
1512 apply (CRlt_le_trans _ (eps * (CR_of_Q (RealT (ElemFunc IS)) (1 # 2) * 1)
1513 + CR_of_Q (RealT (ElemFunc IS)) (1 # 2) * eps)).
1514 apply CRplus_lt_compat_r. apply sa_mes.
1515 rewrite CRmult_1_r, CRmult_comm, <- CRmult_plus_distr_r, <- CR_of_Q_plus.
1516 setoid_replace ((1 # 2) + (1 # 2))%Q with 1%Q.
1517 rewrite CRmult_1_l. apply CRle_refl. reflexivity.
1518 intro n. apply CRopp_involutive. }
1519 assert (forall (x : X (ElemFunc IS)), (forall i : nat, Bi i x) -> A x).
1520 { intros. unfold Bi in H1. exact (sa_inc _ _ _ _ x (H1 O)). }
1521 destruct Bint as [BI Bmaj].
1522 exists (Build_SetApprox IS A Aint eps _ BI Bmaj H1).
1523 pose (fun i:nat => let (fB,_) := H (eps * CRpow (CR_of_Q _ (1#2)) (S i))
1524 (H0 (S i)) in fst fB) as fi.
1525 assert (forall i:nat, IntegrableFunction
1526 (Xmult (CharacFunc (fun x => forall i : nat, Bi i x))
1527 (fi i))) as fiInt.
1528 { intro i. unfold fi.
1529 destruct (H (eps * CRpow (CR_of_Q _ (1 # 2)) (S i)) (H0 (S i))).
1530 exact (RestrictedIntegrable (fst p) BI). }
1531 destruct (series_cv_maj
1532 (fun n : nat => Integral (IntegrableAbs
1533 (IntegrableMinus (fiInt (S n)) (fiInt n))))
1534 (fun n:nat => CRpow (CR_of_Q _ (1#2)) n
1535 * (CR_of_Q _ 2 * eps * MeasureSet BI))
1536 (CR_of_Q _ 2 * (CR_of_Q _ 2 * eps * MeasureSet BI)))
1537 as [l lcv].
1538 - intro n. rewrite CRabs_right.
1539 destruct dom as [hdom [hdomInt dom]].
1540 apply (CRle_trans _ (Integral (IntegrablePlus _ _
1541 (IntegrableScale _ 0 hdomInt)
1542 (IntegrableScale _ (CR_of_Q _ 2 * (eps * CRpow (CR_of_Q _ (1 # 2)) n)) BI)))).
1543 apply IntegralNonDecreasing. intros x xdf xdg.
1544 unfold fi. unfold fi in xdf.
1545 destruct xdg as [d d0]. destruct d0.
1546 pose proof (b n) as bn. unfold Bi in bn.
1547 pose proof (b (S n)) as bSn. unfold Bi in bSn.
1548 destruct (H (eps * CRpow (CR_of_Q _ (1 # 2)) (S n)) (H0 (S n)))
1549 as [x0 p].
1550 destruct (H (eps * CRpow (CR_of_Q _ (1 # 2)) (S (S n))) (H0 (S (S n))))
1551 as [x1 p0].
1552 rewrite applyXabs.
1553 + setoid_replace (partialApply (Xminus
1554 (Xmult (CharacFunc (fun x2 : X (ElemFunc IS) => forall i : nat, Bi i x2)) (fst x1))
1555 (Xmult (CharacFunc (fun x2 : X (ElemFunc IS) => forall i : nat, Bi i x2)) (fst x0)))
1556 x xdf)
1557 with (partialApply _ x (fst xdf)
1558 - partialApply
1559 (XmaxConst (XminConst h (CR_of_Q _ (Z.pos k # 1)))
1560 (CR_of_Q _ (Z.neg k # 1))) x (dom x d)
1561 + (partialApply
1562 (XmaxConst (XminConst h (CR_of_Q _ (Z.pos k # 1)))
1563 (CR_of_Q _ (Z.neg k # 1))) x (dom x d)
1564 - partialApply (Xmult (CharacFunc (fun x2 : X (ElemFunc IS) => forall i : nat, Bi i x2))
1565 (fst x0)) x (snd xdf))).
1566 apply (CRle_trans _ _ _ (CRabs_triang _ _)).
1567 rewrite applyXplus, applyXscale, CRmult_0_l, CRplus_0_l.
1568 rewrite applyXscale, (CR_of_Q_plus _ 1 1).
1569 rewrite CRmult_plus_distr_r, CRmult_plus_distr_r, CRmult_1_l.
1570 apply CRplus_le_compat.
1571 destruct xdf, d1, d0, d0. simpl.
1572 rewrite CRmult_1_r, CRmult_1_l. apply CRlt_asym.
1573 destruct p0. specialize (c x (dom x d) d3).
1574 apply (CRle_lt_trans _ (CRabs (RealT (ElemFunc IS))
1575 (partialApply
1576 (XmaxConst (XminConst h (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
1577 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1))) x
1578 (dom x d) - partialApply (fst x1) x d3))).
1579 rewrite CRabs_minus_sym. apply CRle_refl.
1580 apply (CRlt_le_trans
1581 _ (eps * CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) (S (S n)))).
1582 apply c. exact bSn.
1583 simpl. rewrite <- CRmult_assoc.
1584 rewrite <- CRmult_assoc. apply CRmult_le_compat_r.
1585 apply CRpow_ge_zero. apply CR_of_Q_le. discriminate.
1586 rewrite <- (CRmult_1_r eps), CRmult_assoc, CRmult_assoc.
1587 apply CRmult_le_compat_l. apply CRlt_asym, epsPos.
1588 rewrite CRmult_1_l, <- CR_of_Q_mult.
1589 apply CR_of_Q_le. discriminate.
1590 contradiction.
1591 destruct xdf, d1, d1. simpl. rewrite CRmult_1_r, CRmult_1_l.
1592 apply CRlt_asym.
1593 apply (CRlt_le_trans _ (eps * CRpow (CR_of_Q _ (1 # 2)) (S n))).
1594 apply (snd p).
1595 exact bn. apply CRmult_le_compat_l. apply CRlt_asym, epsPos.
1596 rewrite <- (CRmult_1_l (CRpow (CR_of_Q (RealT (ElemFunc IS)) (1 # 2)) n)).
1597 apply CRmult_le_compat_r.
1598 apply CRpow_ge_zero. apply CR_of_Q_le. discriminate.
1599 apply CR_of_Q_le. discriminate. contradiction.
1600 unfold CRminus. rewrite CRplus_assoc.
1601 destruct xdf.
1602 rewrite (applyXminus (Xmult
1603 (CharacFunc
1604 (fun x2 : X (ElemFunc IS) => forall i : nat, Bi i x2)) (fst x1)) (Xmult
1605 (CharacFunc
1606 (fun x2 : X (ElemFunc IS) => forall i : nat, Bi i x2))
1607 (fst x0)) x d0 d1).
1608 apply CRplus_morph. reflexivity.
1609 rewrite <- CRplus_assoc, CRplus_opp_l, CRplus_0_l. reflexivity.
1610 + (* out of B *)
1611 simpl. rewrite CRmult_0_r, CRmult_0_l.
1612 destruct xdf, d0, d0. contradiction. rewrite CRmult_0_l.
1613 destruct d1, d0. contradiction. rewrite CRmult_0_l, CRmult_0_r.
1614 rewrite CRabs_right. apply CRle_refl. rewrite CRplus_0_r. apply CRle_refl.
1615 + (* Integral majoration *)
1616 rewrite IntegralPlus, IntegralScale, CRmult_0_r, CRplus_0_l.
1617 rewrite IntegralScale. rewrite CRmult_comm, <- CRmult_assoc, <- CRmult_assoc.
1618 rewrite (CRmult_comm (CR_of_Q (RealT (ElemFunc IS)) 2 * eps)).
1619 apply CRle_refl.
1620 + apply IntegralNonNeg. intros x xdf.
1621 rewrite applyXabs. apply CRabs_pos.
1622 - apply series_cv_scale. exact GeoHalfTwo.
1623 - destruct lcv.
1624 destruct (IntegrableXpointwiseLimit _ fiInt l s) as [limInt fcv]. clear s.
1625 refine (IntegrableExtensionalAE _ _ _ _ limInt).
1626 + destruct dom as [hdom [hdomInt dom]].
1627 exists (Xplus hdom (XpointwiseLimit
1628 (fun i : nat =>
1629 Xmult
1630 (CharacFunc (fun x : X (ElemFunc IS) => forall i0 : nat, Bi i0 x))
1631 (fi i)))). split.
1632 apply IntegrablePlus. exact hdomInt. exact limInt.
1633 intros x [xdf xdg]. split.
1634 2: exact (dom x xdf). simpl. destruct xdg as [xDn xdg].
1635 destruct (xDn O). exact d.
1636 + destruct dom as [hdom [hdomInt dom]]. exists hdom. split.
1637 exact hdomInt. intros. unfold sa_approx.
1638 apply applyPointwiseLimit. destruct dG, d. simpl in s.
1639 (* Inside the intersection, the fi converge towards h. *)
1640 apply (CR_cv_proper _ (partialApply (XmaxConst
1641 (XminConst h
1642 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos k # 1)))
1643 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg k # 1))) x d0)).
1644 2: simpl; rewrite CRmult_1_l; reflexivity.
1645 apply (CR_cv_eq _ (fun n : nat => partialApply (fi n) x
1646 (let (xn, _) := dF in snd (xn n)))).
1647 intro n. simpl. destruct dF, (x0 n), d.
1648 rewrite CRmult_1_l. reflexivity. contradiction.
1649 intro p.
1650 assert (CR_cv _ (fun i => CRpow (CR_of_Q _ (1 # 2)) i * eps) 0).
1651 { apply (CR_cv_proper _ (0 * eps)).
1652 apply CR_cv_scale. exact GeoCvZero. apply CRmult_0_l. }
1653 specialize (H3 p) as [j jmaj]. exists j. intros.
1654 specialize (jmaj j (Nat.le_refl j)).
1655 unfold fi. destruct dF. destruct (x0 i). unfold snd.
1656 unfold fi in d1. unfold Bi in s. specialize (s i).
1657 destruct (H (eps * CRpow (CR_of_Q _ (1 # 2)) (S i)) (H0 (S i))).
1658 destruct p0 as [i0 c1]. rewrite CRabs_minus_sym. specialize (c1 x).
1659 apply (CRle_trans _ (eps * CRpow (CR_of_Q _ (1 # 2)) (S i))).
1660 apply CRlt_asym, c1, s. clear c1.
1661 refine (CRle_trans _ _ _ _ jmaj).
1662 unfold CRminus. rewrite CRopp_0, CRplus_0_r.
1663 rewrite CRabs_right, CRmult_comm. apply CRmult_le_compat_r.
1664 apply CRlt_asym, epsPos.
1665 apply Nat.le_exists_sub in H3. destruct H3, H3. subst i.
1666 rewrite <- (CRmult_1_l (CRpow (CR_of_Q _ (1 # 2)) j)).
1667 replace (S (x2 + j)) with (S x2 + j)%nat. 2: reflexivity.
1668 rewrite <- CRpow_plus_distr. apply CRmult_le_compat_r.
1669 apply CRpow_ge_zero. apply CR_of_Q_le. discriminate.
1670 apply (CRmult_le_reg_l (CRpow (CR_of_Q _ 2) (S x2))).
1671 apply CRpow_gt_zero, CR_of_Q_pos. reflexivity. rewrite CRpow_mult.
1672 rewrite <- (CRpow_proper 1). rewrite CRpow_one, CRmult_1_r.
1673 apply CRpow_ge_one. apply CR_of_Q_le. discriminate.
1674 rewrite <- CR_of_Q_mult. apply CR_of_Q_morph. reflexivity.
1675 apply CRmult_le_0_compat.
1676 apply CRpow_ge_zero. apply CR_of_Q_le. discriminate.
1677 apply CRlt_asym, epsPos.
1678 (* Outside the intersection, 0 == 0. *)
1679 unfold sa_approx in n. apply (CR_cv_eq _ (fun _ => 0)).
1680 intros. simpl. destruct dF, (x0 n0), d.
1681 contradiction. rewrite CRmult_0_l. reflexivity.
1682 apply (CR_cv_proper _ 0). apply CR_cv_const.
1683 simpl. rewrite CRmult_0_l, CRmin_left, CRmax_left. reflexivity.
1684 apply CR_of_Q_le. discriminate.
1685 apply CR_of_Q_le. discriminate.
1686 Qed.
1687
1688 (* The convergence in measure of a series of functions.
1689 It is the constructive counterpart of the pointwise convergence,
1690 weaker than uniform convergence. It is designed so that
1691 when a sequence fn of measurable functions converges towards
1692 function f, then f is measurable also (as would happen classically
1693 with pointwise convergence).
1694
1695 For example the sequence of triangles (-1/n, 0), (0,n), (1/n,0)
1696 converges in measure towards 0. To prove that, take N an integer
1697 such as 2/N < eps. The SetApprox B simply removes the interval
1698 [-1/N, 1/N], where all the mass is.
1699
1700 However the integrals of the triangles are all 1, which does not
1701 converge towards 0. *)
1702 Definition CvMeasure {IS : IntegrationSpace}
1703 (fn : nat -> @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS)))
1704 (f : @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS))) : Type
1705 := forall (A : (X (ElemFunc IS)) -> Prop) (Aint : IntegrableSet A)
1706 (eps : CRcarrier (RealT (ElemFunc IS))),
1707 0 < eps
1708 -> { N : nat & forall n:nat, le N n
1709 -> { B : SetApprox A Aint eps
1710 & (forall x xdf xdfn, sa_approx _ _ _ B x
1711 -> CRabs _ (partialApply f x xdf - partialApply (fn n) x xdfn)
1712 < eps) } }.
1713
1714 Lemma CvMeasureMeasurable
1715 : forall {IS : IntegrationSpace}
1716 (fn : nat -> @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS)))
1717 (f : @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS))),
1718 almost_everywhere (Domain f)
1719 -> (forall n:nat, MeasurableFunction (fn n))
1720 -> CvMeasure fn f
1721 -> MeasurableFunction f.
1722 Proof.
1723 intros IS fn f fFull fnMes fnCv.
1724 apply (MeasurableGenApprox f fFull). intros.
1725 specialize (fnCv A Aint eps epsPos) as [N Ncv].
1726 specialize (Ncv N (Nat.le_refl N)) as [B Bcv].
1727 specialize (fnMes N A n Aint).
1728 exists (pair (XmaxConst
1729 (XminConst (Xmult (CharacFunc A) (fn N))
1730 (CR_of_Q (RealT (ElemFunc IS)) (Z.pos n # 1)))
1731 (CR_of_Q (RealT (ElemFunc IS)) (Z.neg n # 1))) B).
1732 split. exact fnMes. unfold fst, snd. intros.
1733 specialize (Bcv x xdh (snd xdf) H).
1734 refine (CRle_lt_trans _ _ _ _ Bcv). clear Bcv.
1735 rewrite applyXmaxConst, applyXmaxConst.
1736 apply (CRle_trans _ _ _ (CRmax_contract _ _ _)).
1737 rewrite applyXminConst, applyXminConst.
1738 apply (CRle_trans _ _ _ (CRmin_contract _ _ _)).
1739 simpl. destruct xdf, d. rewrite CRmult_1_l. apply CRle_refl.
1740 contradict n0. apply (sa_inc _ _ _ _ x H).
1741 Qed.
1742
1743 (* fn converging in measure towards 0 is not enough to guarantee
1744 that the limit of I(fn) converge towards 0. An extra hypothesis
1745 of domination suffices. *)
1746 Record IntegralDominated {IS : IntegrationSpace}
1747 (fn : nat -> @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS)))
1748 (fnInt : forall n:nat, IntegrableFunction (fn n))
1749 (eps : CRcarrier (RealT (ElemFunc IS))) : Type :=
1750 { idom_support : (X (ElemFunc IS)) -> Prop;
1751 idom_idx : nat;
1752 idom_delta : CRcarrier (RealT (ElemFunc IS));
1753 idom_delta_pos : 0 < idom_delta;
1754 idom_int : IntegrableSet idom_support;
1755 idom_dom : forall (B : X (ElemFunc IS) -> Prop) (Bmes : MeasurableSet B) (n:nat),
1756 le idom_idx n
1757 -> Integral (MeasurableIntersectIntegrable Bmes idom_int) < idom_delta
1758 -> Integral (RestrictedMeasurable (fnInt n) Bmes) < eps }.
1759
1760 (* Bishop's lemma 4.14. *)
1761 Lemma DominatedMeasureCvZero
1762 : forall {IS : IntegrationSpace}
1763 (fn : nat -> @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS)))
1764 (fnInt : forall n:nat, IntegrableFunction (fn n)),
1765 CvMeasure fn (Xconst _ 0)
1766 -> (forall n:nat, nonNegFunc (fn n))
1767 -> (forall (eps : CRcarrier (RealT (ElemFunc IS))) (epsPos : 0 < eps),
1768 IntegralDominated fn fnInt eps)
1769 -> CR_cv _ (fun n:nat => Integral (fnInt n)) 0.
1770 Proof.
1771 intros IS fn fnInt fnCvZero fnPos fnDominated.
1772 apply Un_cv_real_nat. intros eps epsPos.
1773 assert (0 < eps * CR_of_Q _ (1#2)) as halfEpsPos.
1774 { apply CRmult_lt_0_compat. exact epsPos.
1775 apply CR_of_Q_pos. reflexivity. }
1776 destruct (fnDominated _ halfEpsPos).
1777 assert (0 < MeasureSet idom_int0 + 1) as H.
1778 { apply (CRlt_le_trans _ 1). apply CRzero_lt_one.
1779 rewrite <- (CRplus_0_l 1), <- CRplus_assoc. apply CRplus_le_compat_r.
1780 rewrite CRplus_0_r. apply MeasureNonNeg. }
1781 assert (0 < CRmin (eps * CR_of_Q _ (1#2) * CRinv _ _ (inr H)) idom_delta0)
1782 as H0.
1783 { apply CRmin_lt. 2: exact idom_delta_pos0.
1784 apply CRmult_lt_0_compat. apply CRmult_lt_0_compat.
1785 exact epsPos. apply CR_of_Q_pos. reflexivity.
1786 apply CRinv_0_lt_compat, H. }
1787 specialize (fnCvZero idom_support0 idom_int0 _ H0) as [N Nmaj].
1788 exists (max N idom_idx0). intros.
1789 specialize (Nmaj i (Nat.le_trans _ _ _ (Nat.le_max_l _ _) H1)) as [[C Cint] Cmaj].
1790 unfold sa_approx in Cmaj.
1791 assert (Integral
1792 (MeasurableIntersectIntegrable
1793 (MeasurableSetCompl C (IntegrableMeasurable (CharacFunc C) Cint))
1794 idom_int0) < idom_delta0) as H2.
1795 { apply (CRlt_le_trans
1796 _ (CRmin (eps * CR_of_Q _ (1#2) * (/ (MeasureSet idom_int0 + 1)) (inr H)) idom_delta0)).
1797 2: apply CRmin_r.
1798 refine (CRle_lt_trans _ _ _ _ sa_mes0).
1799 rewrite <- MeasureDifferenceIncluded. 2: exact sa_inc0.
1800 apply IntegralNonDecreasing. intros x xdf xdg. simpl.
1801 destruct xdf. destruct xdg. apply CRle_refl.
1802 contradict n. split; apply a.
1803 destruct xdg. apply CRlt_asym, CRzero_lt_one. apply CRle_refl. }
1804 assert (le idom_idx0 i).
1805 { apply (Nat.le_trans _ (max N idom_idx0)). apply Nat.le_max_r. exact H1. }
1806 specialize (idom_dom0 _ _ _ H3 H2). clear H2 H3.
1807 apply (CRle_lt_trans
1808 _ (Integral
1809 (RestrictedMeasurable
1810 (fnInt i) (MeasurableSetCompl
1811 C (IntegrableMeasurable (CharacFunc C) Cint)))
1812 + Integral (RestrictedIntegrable (fnInt i) Cint))).
1813 unfold CRminus. rewrite CRopp_0, CRplus_0_r, CRabs_right.
1814 - rewrite <- IntegralPlus. apply IntegralNonDecreasing. intros x xdf xdg.
1815 simpl. destruct xdg, d, d0.
1816 rewrite (DomainProp _ x d2 xdf), (DomainProp _ x d1 xdf).
1817 destruct d, d0. contradiction.
1818 rewrite CRmult_0_l, CRmult_1_l, CRplus_0_r. apply CRle_refl.
1819 rewrite CRmult_0_l, CRmult_1_l, CRplus_0_l. apply CRle_refl.
1820 contradiction.
1821 - exact (IntegralNonNeg _ _ (fnPos i)).
1822 - apply (CRlt_le_trans _ (eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 2)
1823 + eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 2))).
1824 apply (CRplus_lt_le_compat _ _ _ _ idom_dom0). clear idom_dom0.
1825 apply (CRle_trans _ (MeasureSet Cint * (eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 2) *
1826 (/ (MeasureSet idom_int0 + 1)) (inr H)))).
1827 unfold MeasureSet. rewrite <- IntegralScale. apply IntegralNonDecreasing.
1828 + intros x xdf xdg. simpl. destruct xdf, d, xdg.
1829 rewrite CRmult_1_l, CRmult_1_r. clear c0.
1830 specialize (Cmaj x Logic.I d0 c). apply CRlt_asym in Cmaj.
1831 simpl in Cmaj. unfold CRminus in Cmaj.
1832 rewrite CRplus_0_l, CRabs_opp, CRabs_right in Cmaj.
1833 apply (CRle_trans _ _ _ Cmaj (CRmin_l _ _)).
1834 apply fnPos. contradiction. contradiction.
1835 rewrite CRmult_0_l, CRmult_0_r. apply CRle_refl.
1836 + rewrite CRmult_comm, CRmult_assoc.
1837 apply (CRle_trans _ (eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 2) * 1)).
1838 2: rewrite CRmult_1_r; apply CRle_refl.
1839 apply CRmult_le_compat_l. apply CRmult_le_0_compat.
1840 apply CRlt_asym, epsPos.
1841 apply CR_of_Q_le. discriminate.
1842 apply (CRmult_le_reg_l (MeasureSet idom_int0 + 1) _ _ H).
1843 rewrite CRmult_1_r, <- CRmult_assoc, CRinv_r, CRmult_1_l.
1844 apply (CRle_trans _ (MeasureSet idom_int0 + 0)).
1845 rewrite CRplus_0_r. exact (MeasureNonDecreasing _ _ _ _ sa_inc0).
1846 apply CRplus_le_compat_l. apply CRlt_asym, CRzero_lt_one.
1847 + rewrite <- CRmult_plus_distr_l, <- CR_of_Q_plus.
1848 setoid_replace ((1 # 2) + (1 # 2))%Q with 1%Q. 2: reflexivity.
1849 rewrite CRmult_1_r. apply CRle_refl.
1850 Qed.
1851
1852 Lemma DominatedConvergence
1853 : forall {IS : IntegrationSpace}
1854 (fn : nat -> @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS)))
1855 (fnInt : forall n:nat, IntegrableFunction (fn n))
1856 (f g : @PartialFunction (RealT (ElemFunc IS)) (X (ElemFunc IS)))
1857 (fInt : IntegrableFunction f),
1858 CvMeasure fn f
1859 -> IntegrableFunction g
1860 -> (forall n:nat, partialFuncLe (Xabs (fn n)) g)
1861 -> CR_cv _ (fun n:nat => Integral (fnInt n)) (Integral fInt).
1862 Proof.
1863 intros IS fn fnInt f g fInt cvfn gInt fnle.
1864 assert (CvMeasure (fun n : nat => Xabs (Xminus (fn n) f))
1865 (Xconst (X (ElemFunc IS)) 0))
1866 as cvZero.
1867 { intros A Aint eps epsPos. specialize (cvfn A Aint eps epsPos) as [N Nmaj].
1868 exists N. intros. specialize (Nmaj n H) as [B Bapprox].
1869 exists B. intros. destruct xdfn. specialize (Bapprox x d0 d H0).
1870 refine (CRle_lt_trans _ _ _ _ Bapprox).
1871 simpl. rewrite (CRabs_minus_sym (partialApply f x d0)).
1872 unfold CRminus. rewrite CRplus_0_l, CRabs_opp.
1873 rewrite CRabs_right. 2: apply CRabs_pos.
1874 rewrite <- CRopp_mult_distr_l, CRmult_1_l. apply CRle_refl. }
1875 assert (forall n : nat, nonNegFunc (Xabs (Xminus (fn n) f))).
1876 { intros n x xdf. apply CRabs_pos. }
1877 assert (forall (eps : CRcarrier (RealT (ElemFunc IS))) (p : positive),
1878 0 < eps -> 0 < eps * CR_of_Q _ (1#p)) as deltaPos.
1879 { intros. apply (CRmult_lt_0_compat _ _ _ H0).
1880 apply CR_of_Q_pos. reflexivity. }
1881 assert (forall eps : CRcarrier (RealT (ElemFunc IS)),
1882 0 < eps ->
1883 IntegralDominated
1884 (fun n : nat => Xabs (Xminus (fn n) f))
1885 (fun n : nat => IntegrableAbs (IntegrableMinus (fnInt n) fInt)) eps)
1886 as domin.
1887 { intros eps epsPos.
1888 destruct (IntegralSupportExists
1889 _ (IntegrablePlus _ _ gInt (IntegrableAbs fInt))
1890 _ (deltaPos eps 2%positive epsPos))
1891 as [t [_ [tsupp tdist]]].
1892 remember (fun x : X (ElemFunc IS) =>
1893 exists xD : Domain (Xabs (Xplus g (Xabs f))) x,
1894 t <= partialApply (Xabs (Xplus g (Xabs f))) x xD) as A.
1895 destruct (Un_cv_nat_real
1896 _ _ (IntegralTruncateLimit _ (IntegrablePlus _ _ gInt (IntegrableAbs fInt)))
1897 _ (deltaPos eps 4%positive epsPos)) as [n nmaj].
1898 apply (Build_IntegralDominated
1899 IS _ _ _ _
1900 O _ (deltaPos eps (4 * Pos.of_nat (S n))%positive epsPos) tsupp).
1901 intros B Bmes i _ H0.
1902 apply (CRle_lt_trans
1903 _ (Integral
1904 (RestrictedIntegrable (IntegrableAbs (IntegrableMinus (fnInt i) fInt)) (MeasurableIntersectIntegrable Bmes tsupp))
1905 + Integral
1906 (RestrictedMeasurable (IntegrableAbs (IntegrableMinus (fnInt i) fInt)) (MeasurableSetCompl _ (IntegrableMeasurable _ tsupp))))).
1907 - rewrite <- IntegralPlus; apply IntegralNonDecreasing.
1908 intros x xdf xdg. simpl. destruct xdf, xdg, d0, d1, d2, d4, d5.
1909 rewrite (DomainProp f x d7 d3); clear d7.
1910 rewrite (DomainProp f x d6 d3); clear d6.
1911 rewrite (DomainProp _ x d5 d0); clear d5.
1912 rewrite (DomainProp _ x d4 d0); clear d4.
1913 rewrite <- CRmult_plus_distr_r. apply CRmult_le_compat_r.
1914 apply CRabs_pos.
1915 destruct d. destruct d1. destruct d2.
1916 destruct a; contradiction. rewrite CRplus_0_r. apply CRle_refl.
1917 rewrite CRplus_0_l. destruct d2. apply CRle_refl.
1918 contradict n1. intro abs. contradict n0. split; assumption.
1919 destruct d1. destruct d2.
1920 destruct a; contradiction. rewrite CRplus_0_r. apply CRlt_asym, CRzero_lt_one.
1921 rewrite CRplus_0_l. destruct d2. apply CRlt_asym, CRzero_lt_one.
1922 apply CRle_refl.
1923 - apply (CRle_lt_trans
1924 _ (Integral
1925 (RestrictedIntegrable
1926 (IntegrablePlus _ _ gInt (IntegrableAbs fInt))
1927 (MeasurableIntersectIntegrable Bmes tsupp))
1928 + Integral
1929 (RestrictedMeasurable
1930 (IntegrablePlus _ _ gInt (IntegrableAbs fInt))
1931 (MeasurableSetCompl _ (IntegrableMeasurable _ tsupp))))).
1932 apply CRplus_le_compat.
1933 + apply IntegralNonDecreasing. intros x xdf xdg.
1934 destruct xdf, xdg. rewrite applyXmult, applyXmult.
1935 rewrite (DomainProp _ x d1 d). apply CRmult_le_compat_l.
1936 simpl. destruct d. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
1937 simpl. destruct d2, d0.
1938 apply (CRle_trans _ _ _ (CRabs_triang _ _)). apply CRplus_le_compat.
1939 apply fnle. rewrite <- CRopp_mult_distr_l, CRmult_1_l, CRabs_opp.
1940 rewrite (DomainProp f x d4 d3). apply CRle_refl.
1941 + apply IntegralNonDecreasing. intros x xdf xdg.
1942 destruct xdf, xdg. rewrite applyXmult, applyXmult.
1943 rewrite (DomainProp _ x d1 d). apply CRmult_le_compat_l.
1944 simpl. destruct d. apply CRlt_asym, CRzero_lt_one. apply CRle_refl.
1945 simpl. destruct d0, d2. rewrite <- CRopp_mult_distr_l, CRmult_1_l.
1946 apply (CRle_trans _ _ _ (CRabs_triang _ _)).
1947 apply CRplus_le_compat. apply fnle.
1948 rewrite CRabs_opp, (DomainProp f x d4 d3). apply CRle_refl.
1949 + apply (CRlt_le_trans _ (eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 2)
1950 + eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 2))).
1951 apply CRplus_le_lt_compat. specialize (nmaj (S n) (le_S _ _ (Nat.le_refl n))).
1952 apply CRlt_asym in nmaj. rewrite CRabs_minus_sym, CRabs_right in nmaj.
1953 apply (CRplus_le_reg_r
1954 (- (MeasureSet (MeasurableIntersectIntegrable Bmes tsupp)
1955 * CR_of_Q _ (Z.of_nat (S n) #1)))).
1956 apply (CRle_trans _ (eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 4))).
1957 apply (CRle_trans _ (Integral (RestrictedIntegrable (IntegrablePlus g (Xabs f) gInt (IntegrableAbs fInt)) (MeasurableIntersectIntegrable Bmes tsupp))
1958 - Integral (RestrictedIntegrable
1959 (IntegrableMinInt (Xplus g (Xabs f)) (S n)
1960 (IntegrablePlus g (Xabs f) gInt (IntegrableAbs fInt))) (MeasurableIntersectIntegrable Bmes tsupp)))).
1961 apply CRplus_le_compat_l. apply CRopp_ge_le_contravar.
1962 unfold MeasureSet.
1963 rewrite <- IntegralScale. apply IntegralNonDecreasing.
1964 intros x xdf xdg. simpl. destruct xdf, d0.
1965 destruct d. rewrite CRmult_1_l. destruct xdg.
1966 rewrite CRmult_1_r. apply CRmin_r. contradiction.
1967 rewrite CRmult_0_l. destruct xdg.
1968 rewrite CRmult_1_r. apply CR_of_Q_le.
1969 destruct n; discriminate. rewrite CRmult_0_r. apply CRle_refl.
1970 refine (CRle_trans _ _ _ _ nmaj).
1971 rewrite <- IntegralMinus, <- IntegralMinus. apply IntegralNonDecreasing.
1972 intros x xdf xdg. simpl.
1973 destruct xdf, d, d1, d0, d3, xdg, d5, d6.
1974 rewrite (DomainProp g x d3 d1), (DomainProp g x d6 d1),
1975 (DomainProp g x d5 d1), (DomainProp f x d8 d2), (DomainProp f x d7 d2),
1976 (DomainProp f x d4 d2).
1977 destruct d. destruct d0. 2: contradiction.
1978 rewrite CRmult_1_l, CRmult_1_l. apply CRle_refl.
1979 rewrite CRmult_0_l. destruct d0. contradiction.
1980 rewrite CRmult_0_l. rewrite CRmult_0_r, CRplus_0_l.
1981 rewrite <- CRopp_mult_distr_l, CRmult_1_l.
1982 rewrite <- (CRplus_opp_r (CRmin (partialApply g x d1 + CRabs (RealT (ElemFunc IS)) (partialApply f x d2)) (INR (S n)))).
1983 apply CRplus_le_compat_r. apply CRmin_l.
1984 rewrite <- CRplus_0_r.
1985 setoid_replace (eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 2))
1986 with (eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 4)
1987 + eps * CR_of_Q (RealT (ElemFunc IS)) (1 # 4)).
1988 rewrite CRplus_assoc. apply CRplus_le_compat_l.
1989 rewrite <- (CRplus_opp_r (MeasureSet (MeasurableIntersectIntegrable Bmes tsupp) *
1990 CR_of_Q (RealT (ElemFunc IS)) (Z.of_nat (S n) # 1))).
1991 apply CRplus_le_compat_r.
1992 apply (CRmult_le_reg_r (CR_of_Q (RealT (ElemFunc IS)) (1 # Pos.of_nat (S n)))).
1993 apply CR_of_Q_pos. reflexivity.
1994 rewrite CRmult_assoc, <- CR_of_Q_mult.
1995 setoid_replace ((Z.of_nat (S n) # 1) * (1 # Pos.of_nat (S n)))%Q with 1%Q.
1996 rewrite CRmult_1_r, CRmult_assoc, <- CR_of_Q_mult.
1997 setoid_replace ((1 # 4) * (1 # Pos.of_nat (S n)))%Q
1998 with (1 # 4 * Pos.of_nat (S n))%Q.
1999 apply CRlt_asym, H0. reflexivity.
2000 unfold Qeq, Qmult, Qnum, Qden.
2001 rewrite Z.mul_1_r, Z.mul_1_r, Z.mul_1_l, Pos.mul_1_l.
2002 unfold Z.of_nat. rewrite Pos.of_nat_succ. reflexivity.
2003 rewrite <- CRmult_plus_distr_l. apply CRmult_morph.
2004 reflexivity. rewrite <- CR_of_Q_plus. apply CR_of_Q_morph.
2005 reflexivity.
2006 rewrite <- IntegralMinus. apply IntegralNonNeg.
2007 intros x xdf. simpl. destruct xdf, d, d0.
2008 rewrite <- CRopp_mult_distr_l, CRmult_1_l.
2009 rewrite <- (CRplus_opp_r (CRmin (partialApply g x d0 + CRabs (RealT (ElemFunc IS)) (partialApply f x d2)) (INR (S n)))).
2010 apply CRplus_le_compat_r.
2011 rewrite (DomainProp g x d0 d), (DomainProp f x d2 d1). apply CRmin_l.
2012 refine (CRle_lt_trans _ _ _ _ tdist).
2013 apply IntegralNonDecreasing. intros x xdf xdg.
2014 simpl. destruct xdf, xdg, d0, d1, d2, d5.
2015 destruct d. 2: rewrite CRmult_0_l; apply CRabs_pos.
2016 rewrite CRmult_1_l. destruct d2. contradiction.
2017 rewrite CRmult_0_l, CRmult_0_r, CRplus_0_r.
2018 rewrite (DomainProp g x d1 d0), (DomainProp f x d4 d3).
2019 apply CRle_abs. rewrite <- CRmult_plus_distr_l, <- CR_of_Q_plus.
2020 setoid_replace ((1 # 2) + (1 # 2))%Q with 1%Q.
2021 rewrite CRmult_1_r. apply CRle_refl. reflexivity. }
2022 intro p.
2023 destruct (DominatedMeasureCvZero
2024 (fun n : nat => Xabs (Xminus (fn n) f))
2025 (fun n => IntegrableAbs (IntegrableMinus (fnInt n) fInt))
2026 cvZero H domin p) as [n nmaj].
2027 exists n. intros. specialize (nmaj i H0).
2028 unfold CRminus in nmaj. rewrite CRopp_0, CRplus_0_r, CRabs_right in nmaj.
2029 refine (CRle_trans _ _ _ _ nmaj). clear nmaj.
2030 refine (CRle_trans _ _ _ _ (IntegralTriangle _ _)).
2031 rewrite (CRabs_morph _ (Integral (IntegrableMinus (fnInt i) fInt))).
2032 apply CRle_refl. rewrite <- IntegralMinus. reflexivity.
2033 apply IntegralNonNeg. intros x xdf. apply CRabs_pos.
2034 Qed.