-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathSet.lean
More file actions
1192 lines (997 loc) · 58.6 KB
/
Set.lean
File metadata and controls
1192 lines (997 loc) · 58.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/-
Copyright (c) 2020 Zhouhang Zhou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov
-/
module
public import Mathlib.Combinatorics.Enumerative.InclusionExclusion
public import Mathlib.MeasureTheory.Function.LocallyIntegrable
public import Mathlib.MeasureTheory.Integral.Bochner.SumMeasure
public import Mathlib.Topology.ContinuousMap.Compact
public import Mathlib.Topology.MetricSpace.ThickenedIndicator
/-!
# Set integral
In this file we prove some properties of `∫ x in s, f x ∂μ`. Recall that this notation
is defined as `∫ x, f x ∂(μ.restrict s)`. In `integral_indicator` we prove that for a measurable
function `f` and a measurable set `s` this definition coincides with another natural definition:
`∫ x, indicator s f x ∂μ = ∫ x in s, f x ∂μ`, where `indicator s f x` is equal to `f x` for `x ∈ s`
and is zero otherwise.
Since `∫ x in s, f x ∂μ` is a notation, one can rewrite or apply any theorem about `∫ x, f x ∂μ`
directly. In this file we prove some theorems about dependence of `∫ x in s, f x ∂μ` on `s`, e.g.
`setIntegral_union`, `setIntegral_empty`, `setIntegral_univ`.
We use the property `IntegrableOn f s μ := Integrable f (μ.restrict s)`, defined in
`MeasureTheory.IntegrableOn`. We also defined in that same file a predicate
`IntegrableAtFilter (f : X → E) (l : Filter X) (μ : Measure X)` saying that `f` is integrable at
some set `s ∈ l`.
## Notation
We provide the following notations for expressing the integral of a function on a set :
* `∫ x in s, f x ∂μ` is `MeasureTheory.integral (μ.restrict s) f`
* `∫ x in s, f x` is `∫ x in s, f x ∂volume`
Note that the set notations are defined in the file
`Mathlib/MeasureTheory/Integral/Bochner/Basic.lean`,
but we reference them here because all theorems about set integrals are in this file.
-/
@[expose] public section
assert_not_exists InnerProductSpace
open Filter Function MeasureTheory RCLike Set TopologicalSpace Topology
open scoped ENNReal NNReal Finset
variable {X Y E F : Type*}
namespace MeasureTheory
variable {mX : MeasurableSpace X}
section NormedAddCommGroup
variable [NormedAddCommGroup E] [NormedSpace ℝ E]
{f g : X → E} {s t : Set X} {μ : Measure X}
theorem setIntegral_congr_ae₀ (hs : NullMeasurableSet s μ) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ :=
integral_congr_ae ((ae_restrict_iff'₀ hs).2 h)
theorem setIntegral_congr_ae (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ :=
integral_congr_ae ((ae_restrict_iff' hs).2 h)
theorem setIntegral_congr_fun₀ (hs : NullMeasurableSet s μ) (h : EqOn f g s) :
∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ :=
setIntegral_congr_ae₀ hs <| Eventually.of_forall h
theorem setIntegral_congr_fun (hs : MeasurableSet s) (h : EqOn f g s) :
∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ :=
setIntegral_congr_ae hs <| Eventually.of_forall h
theorem setIntegral_congr_set (hst : s =ᵐ[μ] t) : ∫ x in s, f x ∂μ = ∫ x in t, f x ∂μ := by
rw [Measure.restrict_congr_set hst]
theorem setIntegral_union₀ (hst : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
(hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ + ∫ x in t, f x ∂μ := by
simp only [Measure.restrict_union₀ hst ht, integral_add_measure hfs hft]
@[deprecated (since := "2026-03-04")] alias integral_union_ae := setIntegral_union₀
theorem setIntegral_union (hst : Disjoint s t) (ht : MeasurableSet t) (hfs : IntegrableOn f s μ)
(hft : IntegrableOn f t μ) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ + ∫ x in t, f x ∂μ :=
setIntegral_union₀ hst.aedisjoint ht.nullMeasurableSet hfs hft
theorem setIntegral_diff₀ (ht : NullMeasurableSet t μ) (hfs : IntegrableOn f s μ) (hts : t ⊆ s) :
∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ - ∫ x in t, f x ∂μ := by
rw [eq_sub_iff_add_eq, ← setIntegral_union₀, diff_union_of_subset hts]
exacts [disjoint_sdiff_self_left.aedisjoint, ht, hfs.mono_set diff_subset, hfs.mono_set hts]
theorem setIntegral_diff (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) (hts : t ⊆ s) :
∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ - ∫ x in t, f x ∂μ :=
setIntegral_diff₀ ht.nullMeasurableSet hfs hts
@[deprecated (since := "2026-03-04")] alias integral_diff := setIntegral_diff
theorem integral_inter_add_diff₀ (ht : NullMeasurableSet t μ) (hfs : IntegrableOn f s μ) :
∫ x in s ∩ t, f x ∂μ + ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ := by
rw [← Measure.restrict_inter_add_diff₀ s ht, integral_add_measure]
· exact Integrable.mono_measure hfs (Measure.restrict_mono inter_subset_left le_rfl)
· exact Integrable.mono_measure hfs (Measure.restrict_mono diff_subset le_rfl)
theorem integral_inter_add_diff (ht : MeasurableSet t) (hfs : IntegrableOn f s μ) :
∫ x in s ∩ t, f x ∂μ + ∫ x in s \ t, f x ∂μ = ∫ x in s, f x ∂μ :=
integral_inter_add_diff₀ ht.nullMeasurableSet hfs
theorem integral_biUnion_finset {ι : Type*} (t : Finset ι) {s : ι → Set X}
(hs : ∀ i ∈ t, MeasurableSet (s i)) (h's : Set.Pairwise (↑t) (Disjoint on s))
(hf : ∀ i ∈ t, IntegrableOn f (s i) μ) :
∫ x in ⋃ i ∈ t, s i, f x ∂μ = ∑ i ∈ t, ∫ x in s i, f x ∂μ := by
classical
induction t using Finset.induction_on with
| empty => simp
| insert _ _ hat IH =>
simp only [Finset.coe_insert, Finset.forall_mem_insert, Set.pairwise_insert,
Finset.set_biUnion_insert] at hs hf h's ⊢
rw [setIntegral_union _ _ hf.1 (integrableOn_finset_iUnion.2 hf.2)]
· rw [Finset.sum_insert hat, IH hs.2 h's.1 hf.2]
· simp only [disjoint_iUnion_right]
exact fun i hi => (h's.2 i hi (ne_of_mem_of_not_mem hi hat).symm).1
· exact Finset.measurableSet_biUnion _ hs.2
theorem integral_iUnion_fintype {ι : Type*} [Fintype ι] {s : ι → Set X}
(hs : ∀ i, MeasurableSet (s i)) (h's : Pairwise (Disjoint on s))
(hf : ∀ i, IntegrableOn f (s i) μ) : ∫ x in ⋃ i, s i, f x ∂μ = ∑ i, ∫ x in s i, f x ∂μ := by
convert integral_biUnion_finset Finset.univ (fun i _ => hs i) _ fun i _ => hf i
· simp
· simp [pairwise_univ, h's]
theorem setIntegral_empty : ∫ x in ∅, f x ∂μ = 0 := by
rw [Measure.restrict_empty, integral_zero_measure]
theorem setIntegral_univ : ∫ x in univ, f x ∂μ = ∫ x, f x ∂μ := by rw [Measure.restrict_univ]
lemma integral_eq_setIntegral (hs : ∀ᵐ x ∂μ, x ∈ s) (f : X → E) :
∫ x, f x ∂μ = ∫ x in s, f x ∂μ := by
rw [← setIntegral_univ, ← setIntegral_congr_set]; rwa [ae_eq_univ]
theorem integral_add_compl₀ (hs : NullMeasurableSet s μ) (hfi : Integrable f μ) :
∫ x in s, f x ∂μ + ∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ := by
have := setIntegral_union₀ disjoint_compl_right.aedisjoint
hs.compl hfi.integrableOn hfi.integrableOn
rw [← this, union_compl_self, setIntegral_univ]
theorem integral_add_compl (hs : MeasurableSet s) (hfi : Integrable f μ) :
∫ x in s, f x ∂μ + ∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ :=
integral_add_compl₀ hs.nullMeasurableSet hfi
theorem setIntegral_compl₀ (hs : NullMeasurableSet s μ) (hfi : Integrable f μ) :
∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ - ∫ x in s, f x ∂μ := by
rw [← integral_add_compl₀ (μ := μ) hs hfi, add_sub_cancel_left]
theorem setIntegral_compl (hs : MeasurableSet s) (hfi : Integrable f μ) :
∫ x in sᶜ, f x ∂μ = ∫ x, f x ∂μ - ∫ x in s, f x ∂μ :=
setIntegral_compl₀ hs.nullMeasurableSet hfi
/-- For a function `f` and a measurable set `s`, the integral of `indicator s f`
over the whole space is equal to `∫ x in s, f x ∂μ` defined as `∫ x, f x ∂(μ.restrict s)`. -/
theorem integral_indicator (hs : MeasurableSet s) :
∫ x, indicator s f x ∂μ = ∫ x in s, f x ∂μ := by
by_cases hfi : IntegrableOn f s μ; swap
· rw [integral_undef hfi, integral_undef]
rwa [integrable_indicator_iff hs]
calc
∫ x, indicator s f x ∂μ = ∫ x in s, indicator s f x ∂μ + ∫ x in sᶜ, indicator s f x ∂μ :=
(integral_add_compl hs (hfi.integrable_indicator hs)).symm
_ = ∫ x in s, f x ∂μ + ∫ x in sᶜ, 0 ∂μ :=
(congr_arg₂ (· + ·) (integral_congr_ae (indicator_ae_eq_restrict hs))
(integral_congr_ae (indicator_ae_eq_restrict_compl hs)))
_ = ∫ x in s, f x ∂μ := by simp
theorem integral_indicator₀ (hs : NullMeasurableSet s μ) :
∫ x, indicator s f x ∂μ = ∫ x in s, f x ∂μ := by
rw [← integral_congr_ae (indicator_ae_eq_of_ae_eq_set hs.toMeasurable_ae_eq),
integral_indicator (measurableSet_toMeasurable _ _),
Measure.restrict_congr_set hs.toMeasurable_ae_eq]
lemma integral_integral_indicator {mY : MeasurableSpace Y} {ν : Measure Y} (f : X → Y → E)
{s : Set X} (hs : MeasurableSet s) :
∫ x, ∫ y, s.indicator (f · y) x ∂ν ∂μ = ∫ x in s, ∫ y, f x y ∂ν ∂μ := by
simp_rw [← integral_indicator hs, integral_indicator₂]
theorem setIntegral_indicator (ht : MeasurableSet t) :
∫ x in s, t.indicator f x ∂μ = ∫ x in s ∩ t, f x ∂μ := by
rw [integral_indicator ht, Measure.restrict_restrict ht, Set.inter_comm]
/-- **Inclusion-exclusion principle** for the integral of a function over a union.
The integral of a function `f` over the union of the `s i` over `i ∈ t` is the alternating sum of
the integrals of `f` over the intersections of the `s i`. -/
theorem integral_biUnion_eq_sum_powerset {ι : Type*} {t : Finset ι} {s : ι → Set X}
(hs : ∀ i ∈ t, MeasurableSet (s i)) (hf : ∀ i ∈ t, IntegrableOn f (s i) μ) :
∫ x in ⋃ i ∈ t, s i, f x ∂μ = ∑ u ∈ t.powerset with u.Nonempty,
(-1 : ℝ) ^ (#u + 1) • ∫ x in ⋂ i ∈ u, s i, f x ∂μ := by
simp_rw [← integral_smul, ← integral_indicator (Finset.measurableSet_biUnion _ hs)]
have A (u) (hu : u ∈ t.powerset.filter (·.Nonempty)) : MeasurableSet (⋂ i ∈ u, s i) := by
refine u.measurableSet_biInter fun i hi ↦ hs i ?_
grind
have : ∑ x ∈ t.powerset with x.Nonempty, ∫ (a : X) in ⋂ i ∈ x, s i, (-1 : ℝ) ^ (#x + 1) • f a ∂μ
= ∑ x ∈ t.powerset with x.Nonempty, ∫ a, indicator (⋂ i ∈ x, s i)
(fun a ↦ (-1 : ℝ) ^ (#x + 1) • f a) a ∂μ := by
apply Finset.sum_congr rfl (fun x hx ↦ ?_)
rw [← integral_indicator (A x hx)]
rw [this, ← integral_finset_sum]; swap
· intro u hu
rw [integrable_indicator_iff (A u hu)]
apply Integrable.smul
simp only [Finset.mem_filter, Finset.mem_powerset] at hu
rcases hu.2 with ⟨i, hi⟩
exact (hf i (hu.1 hi)).mono (biInter_subset_of_mem hi) le_rfl
congr with x
convert Finset.indicator_biUnion_eq_sum_powerset t s f x with u hu
rw [indicator_smul_apply]
norm_cast
theorem ofReal_setIntegral_one_of_measure_ne_top {X : Type*} {m : MeasurableSpace X}
{μ : Measure X} {s : Set X} (hs : μ s ≠ ∞ := by finiteness) :
ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = μ s :=
calc
ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = ENNReal.ofReal (∫ _ in s, ‖(1 : ℝ)‖ ∂μ) := by
simp only [norm_one]
_ = ∫⁻ _ in s, 1 ∂μ := by simp [measureReal_def, hs]
_ = μ s := setLIntegral_one _
theorem ofReal_setIntegral_one {X : Type*} {_ : MeasurableSpace X} (μ : Measure X)
[IsFiniteMeasure μ] (s : Set X) : ENNReal.ofReal (∫ _ in s, (1 : ℝ) ∂μ) = μ s :=
ofReal_setIntegral_one_of_measure_ne_top
theorem setIntegral_one_eq_measureReal {X : Type*} {m : MeasurableSpace X}
{μ : Measure X} {s : Set X} :
∫ _ in s, (1 : ℝ) ∂μ = μ.real s := by simp
/-- **Inclusion-exclusion principle** for the measure of a union of sets of finite measure.
The measure of the union of the `s i` over `i ∈ t` is the alternating sum of the measures of the
intersections of the `s i`. -/
theorem measureReal_biUnion_eq_sum_powerset {ι : Type*} {t : Finset ι} {s : ι → Set X}
(hs : ∀ i ∈ t, MeasurableSet (s i)) (hf : ∀ i ∈ t, μ (s i) ≠ ∞ := by finiteness) :
μ.real (⋃ i ∈ t, s i) = ∑ u ∈ t.powerset with u.Nonempty,
(-1 : ℝ) ^ (#u + 1) * μ.real (⋂ i ∈ u, s i) := by
simp_rw [← setIntegral_one_eq_measureReal]
apply integral_biUnion_eq_sum_powerset hs
intro i hi
simpa using (hf i hi).lt_top
theorem integral_piecewise [DecidablePred (· ∈ s)] (hs : MeasurableSet s) (hf : IntegrableOn f s μ)
(hg : IntegrableOn g sᶜ μ) :
∫ x, s.piecewise f g x ∂μ = ∫ x in s, f x ∂μ + ∫ x in sᶜ, g x ∂μ := by
rw [← Set.indicator_add_compl_eq_piecewise,
integral_add' (hf.integrable_indicator hs) (hg.integrable_indicator hs.compl),
integral_indicator hs, integral_indicator hs.compl]
theorem tendsto_setIntegral_of_monotone₀
{ι : Type*} [Preorder ι] [(atTop : Filter ι).IsCountablyGenerated]
{s : ι → Set X} (hsm : ∀ i, NullMeasurableSet (s i) μ) (h_mono : Monotone s)
(hfi : IntegrableOn f (⋃ n, s n) μ) :
Tendsto (fun i => ∫ x in s i, f x ∂μ) atTop (𝓝 (∫ x in ⋃ n, s n, f x ∂μ)) := by
refine .of_neBot_imp fun hne ↦ ?_
have := (atTop_neBot_iff.mp hne).2
have hfi' : ∫⁻ x in ⋃ n, s n, ‖f x‖₊ ∂μ < ∞ := hfi.2
set S := ⋃ i, s i
have hSm : NullMeasurableSet S μ := MeasurableSet.iUnion_of_monotone h_mono hsm
have hsub {i} : s i ⊆ S := subset_iUnion s i
rw [← withDensity_apply₀ _ hSm] at hfi'
set ν := μ.withDensity (‖f ·‖ₑ) with hν
refine Metric.nhds_basis_closedBall.tendsto_right_iff.2 fun ε ε0 => ?_
lift ε to ℝ≥0 using ε0.le
have : ∀ᶠ i in atTop, ν (s i) ∈ Icc (ν S - ε) (ν S + ε) :=
tendsto_measure_iUnion_atTop h_mono (ENNReal.Icc_mem_nhds hfi'.ne (ENNReal.coe_pos.2 ε0).ne')
filter_upwards [this] with i hi
rw [mem_closedBall_iff_norm', ← setIntegral_diff₀ (hsm i) hfi hsub, ← coe_nnnorm,
NNReal.coe_le_coe, ← ENNReal.coe_le_coe]
refine (enorm_integral_le_lintegral_enorm _).trans ?_
have hsm' : NullMeasurableSet (s i) ν := (hsm i).mono_ac (withDensity_absolutelyContinuous ..)
rw [← withDensity_apply₀ _ (hSm.diff (hsm _)), ← hν, measure_diff hsub hsm']
exacts [tsub_le_iff_tsub_le.mp hi.1,
(hi.2.trans_lt <| ENNReal.add_lt_top.2 ⟨hfi', ENNReal.coe_lt_top⟩).ne]
theorem tendsto_setIntegral_of_monotone
{ι : Type*} [Preorder ι] [(atTop : Filter ι).IsCountablyGenerated]
{s : ι → Set X} (hsm : ∀ i, MeasurableSet (s i)) (h_mono : Monotone s)
(hfi : IntegrableOn f (⋃ n, s n) μ) :
Tendsto (fun i => ∫ x in s i, f x ∂μ) atTop (𝓝 (∫ x in ⋃ n, s n, f x ∂μ)) :=
tendsto_setIntegral_of_monotone₀ (hsm · |>.nullMeasurableSet) h_mono hfi
theorem tendsto_setIntegral_of_antitone
{ι : Type*} [Preorder ι] [(atTop : Filter ι).IsCountablyGenerated]
{s : ι → Set X} (hsm : ∀ i, MeasurableSet (s i)) (h_anti : Antitone s)
(hfi : ∃ i, IntegrableOn f (s i) μ) :
Tendsto (fun i ↦ ∫ x in s i, f x ∂μ) atTop (𝓝 (∫ x in ⋂ n, s n, f x ∂μ)) := by
refine .of_neBot_imp fun hne ↦ ?_
have := (atTop_neBot_iff.mp hne).2
rcases hfi with ⟨i₀, hi₀⟩
suffices Tendsto (∫ x in s i₀, f x ∂μ - ∫ x in s i₀ \ s ·, f x ∂μ) atTop
(𝓝 (∫ x in s i₀, f x ∂μ - ∫ x in ⋃ i, s i₀ \ s i, f x ∂μ)) by
convert this.congr' <| (eventually_ge_atTop i₀).mono fun i hi ↦ ?_
· rw [← diff_iInter, setIntegral_diff _ hi₀ (iInter_subset _ _), sub_sub_cancel]
exact .iInter_of_antitone h_anti hsm
· rw [setIntegral_diff (hsm i) hi₀ (h_anti hi), sub_sub_cancel]
apply tendsto_const_nhds.sub
refine tendsto_setIntegral_of_monotone (by measurability) ?_ ?_
· exact fun i j h ↦ diff_subset_diff_right (h_anti h)
· rw [← diff_iInter]
exact hi₀.mono_set diff_subset
theorem hasSum_integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set X}
(hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s))
(hfi : IntegrableOn f (⋃ i, s i) μ) :
HasSum (fun n => ∫ x in s n, f x ∂μ) (∫ x in ⋃ n, s n, f x ∂μ) := by
simp only [IntegrableOn, Measure.restrict_iUnion_ae hd hm] at hfi ⊢
exact hasSum_integral_measure hfi
theorem hasSum_integral_iUnion {ι : Type*} [Countable ι] {s : ι → Set X}
(hm : ∀ i, MeasurableSet (s i)) (hd : Pairwise (Disjoint on s))
(hfi : IntegrableOn f (⋃ i, s i) μ) :
HasSum (fun n => ∫ x in s n, f x ∂μ) (∫ x in ⋃ n, s n, f x ∂μ) :=
hasSum_integral_iUnion_ae (fun i => (hm i).nullMeasurableSet) (hd.mono fun _ _ h => h.aedisjoint)
hfi
theorem integral_iUnion {ι : Type*} [Countable ι] {s : ι → Set X} (hm : ∀ i, MeasurableSet (s i))
(hd : Pairwise (Disjoint on s)) (hfi : IntegrableOn f (⋃ i, s i) μ) :
∫ x in ⋃ n, s n, f x ∂μ = ∑' n, ∫ x in s n, f x ∂μ :=
(HasSum.tsum_eq (hasSum_integral_iUnion hm hd hfi)).symm
theorem integral_iUnion_ae {ι : Type*} [Countable ι] {s : ι → Set X}
(hm : ∀ i, NullMeasurableSet (s i) μ) (hd : Pairwise (AEDisjoint μ on s))
(hfi : IntegrableOn f (⋃ i, s i) μ) : ∫ x in ⋃ n, s n, f x ∂μ = ∑' n, ∫ x in s n, f x ∂μ :=
(HasSum.tsum_eq (hasSum_integral_iUnion_ae hm hd hfi)).symm
theorem setIntegral_eq_zero_of_ae_eq_zero (ht_eq : ∀ᵐ x ∂μ, x ∈ t → f x = 0) :
∫ x in t, f x ∂μ = 0 := by
by_cases hf : AEStronglyMeasurable f (μ.restrict t); swap
· rw [integral_undef]
contrapose! hf
exact hf.1
have : ∫ x in t, hf.mk f x ∂μ = 0 := by
refine integral_eq_zero_of_ae ?_
rw [EventuallyEq,
ae_restrict_iff (hf.stronglyMeasurable_mk.measurableSet_eq_fun stronglyMeasurable_zero)]
filter_upwards [ae_imp_of_ae_restrict hf.ae_eq_mk, ht_eq] with x hx h'x h''x
rw [← hx h''x]
exact h'x h''x
rw [← this]
exact integral_congr_ae hf.ae_eq_mk
theorem setIntegral_eq_zero_of_forall_eq_zero (ht_eq : ∀ x ∈ t, f x = 0) :
∫ x in t, f x ∂μ = 0 :=
setIntegral_eq_zero_of_ae_eq_zero (Eventually.of_forall ht_eq)
theorem exists_ne_zero_of_setIntegral_ne_zero (hU : ∫ x in t, f x ∂μ ≠ 0) :
∃ x, x ∈ t ∧ f x ≠ 0 := by
contrapose! hU
exact setIntegral_eq_zero_of_forall_eq_zero hU
theorem integral_union_eq_left_of_ae_aux (ht_eq : ∀ᵐ x ∂μ.restrict t, f x = 0)
(haux : StronglyMeasurable f) (H : IntegrableOn f (s ∪ t) μ) :
∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := by
let k := f ⁻¹' {0}
have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _)
have h's : IntegrableOn f s μ := H.mono subset_union_left le_rfl
have A : ∀ u : Set X, ∫ x in u ∩ k, f x ∂μ = 0 := fun u =>
setIntegral_eq_zero_of_forall_eq_zero fun x hx => hx.2
rw [← integral_inter_add_diff hk h's, ← integral_inter_add_diff hk H, A, A, zero_add, zero_add,
union_diff_distrib, union_comm]
apply setIntegral_congr_set
rw [union_ae_eq_right]
apply measure_mono_null diff_subset
rw [measure_eq_zero_iff_ae_notMem]
filter_upwards [ae_imp_of_ae_restrict ht_eq] with x hx h'x using h'x.2 (hx h'x.1)
theorem integral_union_eq_left_of_ae (ht_eq : ∀ᵐ x ∂μ.restrict t, f x = 0) :
∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ := by
have ht : IntegrableOn f t μ := by apply integrableOn_zero.congr_fun_ae; symm; exact ht_eq
by_cases H : IntegrableOn f (s ∪ t) μ; swap
· rw [integral_undef H, integral_undef]; simpa [integrableOn_union, ht] using H
let f' := H.1.mk f
calc
∫ x : X in s ∪ t, f x ∂μ = ∫ x : X in s ∪ t, f' x ∂μ := integral_congr_ae H.1.ae_eq_mk
_ = ∫ x in s, f' x ∂μ := by
apply
integral_union_eq_left_of_ae_aux _ H.1.stronglyMeasurable_mk (H.congr_fun_ae H.1.ae_eq_mk)
filter_upwards [ht_eq,
ae_mono (Measure.restrict_mono subset_union_right le_rfl) H.1.ae_eq_mk] with x hx h'x
rw [← h'x, hx]
_ = ∫ x in s, f x ∂μ :=
integral_congr_ae
(ae_mono (Measure.restrict_mono subset_union_left le_rfl) H.1.ae_eq_mk.symm)
theorem integral_union_eq_left_of_forall₀ {f : X → E} (ht : NullMeasurableSet t μ)
(ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ :=
integral_union_eq_left_of_ae ((ae_restrict_iff'₀ ht).2 (Eventually.of_forall ht_eq))
theorem integral_union_eq_left_of_forall {f : X → E} (ht : MeasurableSet t)
(ht_eq : ∀ x ∈ t, f x = 0) : ∫ x in s ∪ t, f x ∂μ = ∫ x in s, f x ∂μ :=
integral_union_eq_left_of_forall₀ ht.nullMeasurableSet ht_eq
theorem setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux (hts : s ⊆ t)
(h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) (haux : StronglyMeasurable f)
(h'aux : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
let k := f ⁻¹' {0}
have hk : MeasurableSet k := by borelize E; exact haux.measurable (measurableSet_singleton _)
calc
∫ x in t, f x ∂μ = ∫ x in t ∩ k, f x ∂μ + ∫ x in t \ k, f x ∂μ := by
rw [integral_inter_add_diff hk h'aux]
_ = ∫ x in t \ k, f x ∂μ := by
rw [setIntegral_eq_zero_of_forall_eq_zero fun x hx => ?_, zero_add]; exact hx.2
_ = ∫ x in s \ k, f x ∂μ := by
apply setIntegral_congr_set
filter_upwards [h't] with x hx
change (x ∈ t \ k) = (x ∈ s \ k)
simp only [eq_iff_iff, and_congr_left_iff, mem_diff]
intro h'x
by_cases xs : x ∈ s
· simp only [xs, hts xs]
· simp only [xs, iff_false]
intro xt
exact h'x (hx ⟨xt, xs⟩)
_ = ∫ x in s ∩ k, f x ∂μ + ∫ x in s \ k, f x ∂μ := by
have : ∀ x ∈ s ∩ k, f x = 0 := fun x hx => hx.2
rw [setIntegral_eq_zero_of_forall_eq_zero this, zero_add]
_ = ∫ x in s, f x ∂μ := by rw [integral_inter_add_diff hk (h'aux.mono hts le_rfl)]
/-- If a function vanishes almost everywhere on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is null-measurable. -/
theorem setIntegral_eq_of_subset_of_ae_diff_eq_zero (ht : NullMeasurableSet t μ) (hts : s ⊆ t)
(h't : ∀ᵐ x ∂μ, x ∈ t \ s → f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ := by
by_cases h : IntegrableOn f t μ; swap
· have : ¬IntegrableOn f s μ := fun H => h (H.of_ae_diff_eq_zero ht h't)
rw [integral_undef h, integral_undef this]
let f' := h.1.mk f
calc
∫ x in t, f x ∂μ = ∫ x in t, f' x ∂μ := integral_congr_ae h.1.ae_eq_mk
_ = ∫ x in s, f' x ∂μ := by
apply
setIntegral_eq_of_subset_of_ae_diff_eq_zero_aux hts _ h.1.stronglyMeasurable_mk
(h.congr h.1.ae_eq_mk)
filter_upwards [h't, ae_imp_of_ae_restrict h.1.ae_eq_mk] with x hx h'x h''x
rw [← h'x h''x.1, hx h''x]
_ = ∫ x in s, f x ∂μ := by
apply integral_congr_ae
apply ae_restrict_of_ae_restrict_of_subset hts
exact h.1.ae_eq_mk.symm
/-- If a function vanishes on `t \ s` with `s ⊆ t`, then its integrals on `s`
and `t` coincide if `t` is measurable. -/
theorem setIntegral_eq_of_subset_of_forall_diff_eq_zero (ht : MeasurableSet t) (hts : s ⊆ t)
(h't : ∀ x ∈ t \ s, f x = 0) : ∫ x in t, f x ∂μ = ∫ x in s, f x ∂μ :=
setIntegral_eq_of_subset_of_ae_diff_eq_zero ht.nullMeasurableSet hts
(Eventually.of_forall fun x hx => h't x hx)
/-- If a function vanishes almost everywhere on `sᶜ`, then its integral on `s`
coincides with its integral on the whole space. -/
theorem setIntegral_eq_integral_of_ae_compl_eq_zero (h : ∀ᵐ x ∂μ, x ∉ s → f x = 0) :
∫ x in s, f x ∂μ = ∫ x, f x ∂μ := by
symm
nth_rw 1 [← setIntegral_univ]
apply setIntegral_eq_of_subset_of_ae_diff_eq_zero nullMeasurableSet_univ (subset_univ _)
filter_upwards [h] with x hx h'x using hx h'x.2
/-- If a function vanishes on `sᶜ`, then its integral on `s` coincides with its integral on the
whole space. -/
theorem setIntegral_eq_integral_of_forall_compl_eq_zero (h : ∀ x, x ∉ s → f x = 0) :
∫ x in s, f x ∂μ = ∫ x, f x ∂μ :=
setIntegral_eq_integral_of_ae_compl_eq_zero (Eventually.of_forall h)
theorem setIntegral_neg_eq_setIntegral_nonpos [PartialOrder E] {f : X → E}
(hf : AEStronglyMeasurable f μ) :
∫ x in {x | f x < 0}, f x ∂μ = ∫ x in {x | f x ≤ 0}, f x ∂μ := by
have h_union : {x | f x ≤ 0} = {x | f x < 0} ∪ {x | f x = 0} := by
simp_rw [le_iff_lt_or_eq, setOf_or]
rw [h_union]
have B : NullMeasurableSet {x | f x = 0} μ :=
hf.nullMeasurableSet_eq_fun aestronglyMeasurable_zero
symm
refine integral_union_eq_left_of_ae ?_
filter_upwards [ae_restrict_mem₀ B] with x hx using hx
theorem integral_norm_eq_pos_sub_neg {f : X → ℝ} (hfi : Integrable f μ) :
∫ x, ‖f x‖ ∂μ = ∫ x in {x | 0 ≤ f x}, f x ∂μ - ∫ x in {x | f x ≤ 0}, f x ∂μ :=
have h_meas : NullMeasurableSet {x | 0 ≤ f x} μ :=
aestronglyMeasurable_const.nullMeasurableSet_le hfi.1
calc
∫ x, ‖f x‖ ∂μ = ∫ x in {x | 0 ≤ f x}, ‖f x‖ ∂μ + ∫ x in {x | 0 ≤ f x}ᶜ, ‖f x‖ ∂μ := by
rw [← integral_add_compl₀ h_meas hfi.norm]
_ = ∫ x in {x | 0 ≤ f x}, f x ∂μ + ∫ x in {x | 0 ≤ f x}ᶜ, ‖f x‖ ∂μ := by
congr 1
refine setIntegral_congr_fun₀ h_meas fun x hx => ?_
dsimp only
rw [Real.norm_eq_abs, abs_eq_self.mpr _]
exact hx
_ = ∫ x in {x | 0 ≤ f x}, f x ∂μ - ∫ x in {x | 0 ≤ f x}ᶜ, f x ∂μ := by
congr 1
rw [← integral_neg]
refine setIntegral_congr_fun₀ h_meas.compl fun x hx => ?_
dsimp only
rw [Real.norm_eq_abs, abs_eq_neg_self.mpr _]
rw [Set.mem_compl_iff, Set.notMem_setOf_iff] at hx
linarith
_ = ∫ x in {x | 0 ≤ f x}, f x ∂μ - ∫ x in {x | f x ≤ 0}, f x ∂μ := by
rw [← setIntegral_neg_eq_setIntegral_nonpos hfi.1, compl_setOf]; simp only [not_le]
theorem setIntegral_const [CompleteSpace E] (c : E) : ∫ _ in s, c ∂μ = μ.real s • c := by
rw [integral_const, measureReal_restrict_apply_univ]
@[simp]
theorem integral_indicator_const [CompleteSpace E] (e : E) ⦃s : Set X⦄ (s_meas : MeasurableSet s) :
∫ x : X, s.indicator (fun _ : X => e) x ∂μ = μ.real s • e := by
rw [integral_indicator s_meas, ← setIntegral_const]
@[simp]
theorem integral_indicator_one ⦃s : Set X⦄ (hs : MeasurableSet s) :
∫ x, s.indicator 1 x ∂μ = μ.real s :=
(integral_indicator_const 1 hs).trans ((smul_eq_mul ..).trans (mul_one _))
theorem setIntegral_indicatorConstLp [CompleteSpace E]
{p : ℝ≥0∞} (hs : MeasurableSet s) (ht : MeasurableSet t) (hμt : μ t ≠ ∞) (e : E) :
∫ x in s, indicatorConstLp p ht hμt e x ∂μ = μ.real (t ∩ s) • e :=
calc
∫ x in s, indicatorConstLp p ht hμt e x ∂μ = ∫ x in s, t.indicator (fun _ => e) x ∂μ := by
rw [setIntegral_congr_ae hs (indicatorConstLp_coeFn.mono fun x hx _ => hx)]
_ = (μ.real (t ∩ s)) • e := by rw [integral_indicator_const _ ht, measureReal_restrict_apply ht]
theorem integral_indicatorConstLp [CompleteSpace E]
{p : ℝ≥0∞} (ht : MeasurableSet t) (hμt : μ t ≠ ∞) (e : E) :
∫ x, indicatorConstLp p ht hμt e x ∂μ = μ.real t • e :=
calc
∫ x, indicatorConstLp p ht hμt e x ∂μ = ∫ x in univ, indicatorConstLp p ht hμt e x ∂μ := by
rw [setIntegral_univ]
_ = μ.real (t ∩ univ) • e := setIntegral_indicatorConstLp MeasurableSet.univ ht hμt e
_ = μ.real t • e := by rw [inter_univ]
theorem setIntegral_map {Y} [MeasurableSpace Y] {g : X → Y} {f : Y → E} {s : Set Y}
(hs : MeasurableSet s) (hf : AEStronglyMeasurable f (Measure.map g μ)) (hg : AEMeasurable g μ) :
∫ y in s, f y ∂Measure.map g μ = ∫ x in g ⁻¹' s, f (g x) ∂μ := by
rw [Measure.restrict_map_of_aemeasurable hg hs,
integral_map (hg.mono_measure Measure.restrict_le_self) (hf.mono_measure _)]
exact Measure.map_mono_of_aemeasurable Measure.restrict_le_self hg
theorem _root_.MeasurableEmbedding.setIntegral_map {Y} {_ : MeasurableSpace Y} {f : X → Y}
(hf : MeasurableEmbedding f) (g : Y → E) (s : Set Y) :
∫ y in s, g y ∂Measure.map f μ = ∫ x in f ⁻¹' s, g (f x) ∂μ := by
rw [hf.restrict_map, hf.integral_map]
theorem _root_.Topology.IsClosedEmbedding.setIntegral_map [TopologicalSpace X] [BorelSpace X] {Y}
[MeasurableSpace Y] [TopologicalSpace Y] [BorelSpace Y] {g : X → Y} {f : Y → E} (s : Set Y)
(hg : IsClosedEmbedding g) : ∫ y in s, f y ∂Measure.map g μ = ∫ x in g ⁻¹' s, f (g x) ∂μ :=
hg.measurableEmbedding.setIntegral_map _ _
theorem MeasurePreserving.setIntegral_preimage_emb {Y} {_ : MeasurableSpace Y} {f : X → Y} {ν}
(h₁ : MeasurePreserving f μ ν) (h₂ : MeasurableEmbedding f) (g : Y → E) (s : Set Y) :
∫ x in f ⁻¹' s, g (f x) ∂μ = ∫ y in s, g y ∂ν :=
(h₁.restrict_preimage_emb h₂ s).integral_comp h₂ _
theorem MeasurePreserving.setIntegral_image_emb {Y} {_ : MeasurableSpace Y} {f : X → Y} {ν}
(h₁ : MeasurePreserving f μ ν) (h₂ : MeasurableEmbedding f) (g : Y → E) (s : Set X) :
∫ y in f '' s, g y ∂ν = ∫ x in s, g (f x) ∂μ :=
Eq.symm <| (h₁.restrict_image_emb h₂ s).integral_comp h₂ _
theorem setIntegral_map_equiv {Y} [MeasurableSpace Y] (e : X ≃ᵐ Y) (f : Y → E) (s : Set Y) :
∫ y in s, f y ∂Measure.map e μ = ∫ x in e ⁻¹' s, f (e x) ∂μ :=
e.measurableEmbedding.setIntegral_map f s
theorem norm_setIntegral_le_of_norm_le_const_ae {C : ℝ} (hs : μ s < ∞)
(hC : ∀ᵐ x ∂μ.restrict s, ‖f x‖ ≤ C) : ‖∫ x in s, f x ∂μ‖ ≤ C * μ.real s := by
rw [← Measure.restrict_apply_univ] at *
haveI : IsFiniteMeasure (μ.restrict s) := ⟨hs⟩
simpa using norm_integral_le_of_norm_le_const hC
theorem norm_setIntegral_le_of_norm_le_const_ae' {C : ℝ} (hs : μ s < ∞)
(hC : ∀ᵐ x ∂μ, x ∈ s → ‖f x‖ ≤ C) : ‖∫ x in s, f x ∂μ‖ ≤ C * μ.real s := by
by_cases hfm : AEStronglyMeasurable f (μ.restrict s)
· apply norm_setIntegral_le_of_norm_le_const_ae hs
have A : ∀ᵐ x : X ∂μ, x ∈ s → ‖AEStronglyMeasurable.mk f hfm x‖ ≤ C := by
filter_upwards [hC, hfm.ae_mem_imp_eq_mk] with _ h1 h2 h3
rw [← h2 h3]
exact h1 h3
have B : MeasurableSet {x | ‖hfm.mk f x‖ ≤ C} :=
hfm.stronglyMeasurable_mk.norm.measurable measurableSet_Iic
filter_upwards [hfm.ae_eq_mk, (ae_restrict_iff B).2 A] with _ h1 _
rwa [h1]
· rw [integral_non_aestronglyMeasurable hfm]
have : ∃ᵐ (x : X) ∂μ, x ∈ s := by
apply frequently_ae_mem_iff.mpr
contrapose! hfm
simp [Measure.restrict_eq_zero.mpr hfm]
rcases (this.and_eventually hC).exists with ⟨x, hx, h'x⟩
have : 0 ≤ C := (norm_nonneg _).trans (h'x hx)
simp only [norm_zero, ge_iff_le]
positivity
theorem norm_setIntegral_le_of_norm_le_const {C : ℝ} (hs : μ s < ∞) (hC : ∀ x ∈ s, ‖f x‖ ≤ C) :
‖∫ x in s, f x ∂μ‖ ≤ C * μ.real s :=
norm_setIntegral_le_of_norm_le_const_ae' hs (Eventually.of_forall hC)
theorem norm_integral_sub_setIntegral_le [IsFiniteMeasure μ] {C : ℝ}
(hf : ∀ᵐ (x : X) ∂μ, ‖f x‖ ≤ C) {s : Set X} (hs : MeasurableSet s) (hf1 : Integrable f μ) :
‖∫ (x : X), f x ∂μ - ∫ x in s, f x ∂μ‖ ≤ μ.real sᶜ * C := by
have h0 : ∫ (x : X), f x ∂μ - ∫ x in s, f x ∂μ = ∫ x in sᶜ, f x ∂μ := by
rw [sub_eq_iff_eq_add, add_comm, integral_add_compl hs hf1]
have h1 : ∫ x in sᶜ, ‖f x‖ ∂μ ≤ ∫ _ in sᶜ, C ∂μ :=
integral_mono_ae hf1.norm.restrict (integrable_const C) (ae_restrict_of_ae hf)
have h2 : ∫ _ in sᶜ, C ∂μ = μ.real sᶜ * C := by
rw [setIntegral_const C, smul_eq_mul]
rw [h0, ← h2]
exact le_trans (norm_integral_le_integral_norm f) h1
theorem setIntegral_eq_zero_iff_of_nonneg_ae {f : X → ℝ} (hf : 0 ≤ᵐ[μ.restrict s] f)
(hfi : IntegrableOn f s μ) : ∫ x in s, f x ∂μ = 0 ↔ f =ᵐ[μ.restrict s] 0 :=
integral_eq_zero_iff_of_nonneg_ae hf hfi
theorem setIntegral_pos_iff_support_of_nonneg_ae {f : X → ℝ} (hf : 0 ≤ᵐ[μ.restrict s] f)
(hfi : IntegrableOn f s μ) : (0 < ∫ x in s, f x ∂μ) ↔ 0 < μ (support f ∩ s) := by
rw [integral_pos_iff_support_of_nonneg_ae hf hfi, Measure.restrict_apply₀]
rw [support_eq_preimage]
exact hfi.aestronglyMeasurable.aemeasurable.nullMeasurable (measurableSet_singleton 0).compl
theorem setIntegral_gt_gt {R : ℝ} {f : X → ℝ} (hR : 0 ≤ R)
(hfint : IntegrableOn f {x | ↑R < f x} μ) (hμ : μ {x | ↑R < f x} ≠ 0) :
μ.real {x | ↑R < f x} * R < ∫ x in {x | ↑R < f x}, f x ∂μ := by
have : IntegrableOn (fun _ => R) {x | ↑R < f x} μ := by
refine ⟨aestronglyMeasurable_const, lt_of_le_of_lt ?_ hfint.2⟩
refine setLIntegral_mono_ae hfint.1.enorm <| ae_of_all _ fun x hx => ?_
simp only [ENNReal.coe_le_coe, Real.nnnorm_of_nonneg hR, enorm_eq_nnnorm,
Real.nnnorm_of_nonneg (hR.trans <| le_of_lt hx)]
exact le_of_lt hx
rw [← sub_pos, ← smul_eq_mul, ← setIntegral_const, ← integral_sub hfint this,
setIntegral_pos_iff_support_of_nonneg_ae]
· rw [← pos_iff_ne_zero] at hμ
rwa [Set.inter_eq_self_of_subset_right]
exact fun x hx => Ne.symm (ne_of_lt <| sub_pos.2 hx)
· rw [Pi.zero_def, EventuallyLE, ae_restrict_iff₀]
· exact Eventually.of_forall fun x hx => sub_nonneg.2 <| le_of_lt hx
· exact nullMeasurableSet_le aemeasurable_zero (hfint.1.aemeasurable.sub aemeasurable_const)
· exact Integrable.sub hfint this
theorem setIntegral_trim {X} {m m0 : MeasurableSpace X} {μ : Measure X} (hm : m ≤ m0) {f : X → E}
(hf_meas : StronglyMeasurable[m] f) {s : Set X} (hs : MeasurableSet[m] s) :
∫ x in s, f x ∂μ = ∫ x in s, f x ∂μ.trim hm := by
rwa [integral_trim hm hf_meas, restrict_trim hm μ]
/-! ### Lemmas about adding and removing interval boundaries
The primed lemmas take explicit arguments about the endpoint having zero measure, while the
unprimed ones use `[NoAtoms μ]`.
-/
section PartialOrder
variable [PartialOrder X] {x y : X}
theorem integral_Icc_eq_integral_Ioc' (hx : μ {x} = 0) :
∫ t in Icc x y, f t ∂μ = ∫ t in Ioc x y, f t ∂μ :=
setIntegral_congr_set (Ioc_ae_eq_Icc' hx).symm
theorem integral_Icc_eq_integral_Ico' (hy : μ {y} = 0) :
∫ t in Icc x y, f t ∂μ = ∫ t in Ico x y, f t ∂μ :=
setIntegral_congr_set (Ico_ae_eq_Icc' hy).symm
theorem integral_Ioc_eq_integral_Ioo' (hy : μ {y} = 0) :
∫ t in Ioc x y, f t ∂μ = ∫ t in Ioo x y, f t ∂μ :=
setIntegral_congr_set (Ioo_ae_eq_Ioc' hy).symm
theorem integral_Ico_eq_integral_Ioo' (hx : μ {x} = 0) :
∫ t in Ico x y, f t ∂μ = ∫ t in Ioo x y, f t ∂μ :=
setIntegral_congr_set (Ioo_ae_eq_Ico' hx).symm
theorem integral_Icc_eq_integral_Ioo' (hx : μ {x} = 0) (hy : μ {y} = 0) :
∫ t in Icc x y, f t ∂μ = ∫ t in Ioo x y, f t ∂μ :=
setIntegral_congr_set (Ioo_ae_eq_Icc' hx hy).symm
theorem integral_Iic_eq_integral_Iio' (hx : μ {x} = 0) :
∫ t in Iic x, f t ∂μ = ∫ t in Iio x, f t ∂μ :=
setIntegral_congr_set (Iio_ae_eq_Iic' hx).symm
theorem integral_Ici_eq_integral_Ioi' (hx : μ {x} = 0) :
∫ t in Ici x, f t ∂μ = ∫ t in Ioi x, f t ∂μ :=
setIntegral_congr_set (Ioi_ae_eq_Ici' hx).symm
variable [NoAtoms μ]
theorem integral_Icc_eq_integral_Ioc : ∫ t in Icc x y, f t ∂μ = ∫ t in Ioc x y, f t ∂μ :=
integral_Icc_eq_integral_Ioc' <| measure_singleton x
theorem integral_Icc_eq_integral_Ico : ∫ t in Icc x y, f t ∂μ = ∫ t in Ico x y, f t ∂μ :=
integral_Icc_eq_integral_Ico' <| measure_singleton y
theorem integral_Ioc_eq_integral_Ioo : ∫ t in Ioc x y, f t ∂μ = ∫ t in Ioo x y, f t ∂μ :=
integral_Ioc_eq_integral_Ioo' <| measure_singleton y
theorem integral_Ico_eq_integral_Ioo : ∫ t in Ico x y, f t ∂μ = ∫ t in Ioo x y, f t ∂μ :=
integral_Ico_eq_integral_Ioo' <| measure_singleton x
theorem integral_Ico_eq_integral_Ioc : ∫ t in Ico x y, f t ∂μ = ∫ t in Ioc x y, f t ∂μ := by
rw [integral_Ico_eq_integral_Ioo, integral_Ioc_eq_integral_Ioo]
theorem integral_Icc_eq_integral_Ioo : ∫ t in Icc x y, f t ∂μ = ∫ t in Ioo x y, f t ∂μ := by
rw [integral_Icc_eq_integral_Ico, integral_Ico_eq_integral_Ioo]
theorem integral_Iic_eq_integral_Iio : ∫ t in Iic x, f t ∂μ = ∫ t in Iio x, f t ∂μ :=
integral_Iic_eq_integral_Iio' <| measure_singleton x
theorem integral_Ici_eq_integral_Ioi : ∫ t in Ici x, f t ∂μ = ∫ t in Ioi x, f t ∂μ :=
integral_Ici_eq_integral_Ioi' <| measure_singleton x
end PartialOrder
end NormedAddCommGroup
section Mono
variable [NormedAddCommGroup E] [NormedSpace ℝ E] [PartialOrder E]
[IsOrderedAddMonoid E] [IsOrderedModule ℝ E]
{μ : Measure X} {f g : X → E} {s t : Set X}
theorem setIntegral_mono_set [OrderClosedTopology E] (hfi : IntegrableOn f t μ)
(hf : 0 ≤ᵐ[μ.restrict t] f) (hst : s ≤ᵐ[μ] t) :
∫ x in s, f x ∂μ ≤ ∫ x in t, f x ∂μ :=
integral_mono_measure (Measure.restrict_mono_ae hst) hf hfi
theorem setIntegral_le_integral [OrderClosedTopology E] (hfi : Integrable f μ) (hf : 0 ≤ᵐ[μ] f) :
∫ x in s, f x ∂μ ≤ ∫ x, f x ∂μ :=
integral_mono_measure (Measure.restrict_le_self) hf hfi
variable [ClosedIciTopology E]
section
variable (hf : IntegrableOn f s μ) (hg : IntegrableOn g s μ)
include hf hg
theorem setIntegral_mono_ae_restrict (h : f ≤ᵐ[μ.restrict s] g) :
∫ x in s, f x ∂μ ≤ ∫ x in s, g x ∂μ := by
by_cases hE : CompleteSpace E
· exact integral_mono_ae hf hg h
· simp [integral, hE]
theorem setIntegral_mono_ae (h : f ≤ᵐ[μ] g) : ∫ x in s, f x ∂μ ≤ ∫ x in s, g x ∂μ :=
setIntegral_mono_ae_restrict hf hg (ae_restrict_of_ae h)
theorem setIntegral_mono_on (hs : MeasurableSet s) (h : ∀ x ∈ s, f x ≤ g x) :
∫ x in s, f x ∂μ ≤ ∫ x in s, g x ∂μ :=
setIntegral_mono_ae_restrict hf hg
(by simp [hs, EventuallyLE, eventually_inf_principal, ae_of_all _ h])
theorem setIntegral_mono_on_ae (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) :
∫ x in s, f x ∂μ ≤ ∫ x in s, g x ∂μ := by
refine setIntegral_mono_ae_restrict hf hg ?_; rwa [EventuallyLE, ae_restrict_iff' hs]
lemma setIntegral_mono_on_ae₀ (hs : NullMeasurableSet s μ) (h : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) :
∫ x in s, f x ∂μ ≤ ∫ x in s, g x ∂μ := by
rw [setIntegral_congr_set hs.toMeasurable_ae_eq.symm,
setIntegral_congr_set hs.toMeasurable_ae_eq.symm]
refine setIntegral_mono_on_ae ?_ ?_ ?_ ?_
· rwa [integrableOn_congr_set_ae hs.toMeasurable_ae_eq]
· rwa [integrableOn_congr_set_ae hs.toMeasurable_ae_eq]
· exact measurableSet_toMeasurable μ s
· filter_upwards [hs.toMeasurable_ae_eq.mem_iff, h] with x hx h
rwa [hx]
@[gcongr high] -- higher priority than `integral_mono`
-- this lemma is better because it also gives the `x ∈ s` hypothesis
lemma setIntegral_mono_on₀ (hs : NullMeasurableSet s μ) (h : ∀ x ∈ s, f x ≤ g x) :
∫ x in s, f x ∂μ ≤ ∫ x in s, g x ∂μ :=
setIntegral_mono_on_ae₀ hf hg hs (Eventually.of_forall h)
theorem setIntegral_mono (h : f ≤ g) : ∫ x in s, f x ∂μ ≤ ∫ x in s, g x ∂μ :=
integral_mono hf hg h
end
theorem setIntegral_ge_of_const_le [CompleteSpace E] {c : E} (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
(hf : ∀ x ∈ s, c ≤ f x) (hfint : IntegrableOn (fun x : X => f x) s μ) :
μ.real s • c ≤ ∫ x in s, f x ∂μ := by
rw [← setIntegral_const c]
exact setIntegral_mono_on (integrableOn_const hμs) hfint hs hf
theorem setIntegral_ge_of_const_le_real {f : X → ℝ} {c : ℝ} (hs : MeasurableSet s) (hμs : μ s ≠ ∞)
(hf : ∀ x ∈ s, c ≤ f x) (hfint : IntegrableOn (fun x : X => f x) s μ) :
c * μ.real s ≤ ∫ x in s, f x ∂μ := by
simpa [mul_comm] using setIntegral_ge_of_const_le hs hμs hf hfint
end Mono
section Nonneg
variable {μ : Measure X} {f : X → ℝ} {s : Set X}
theorem setIntegral_nonneg_of_ae_restrict (hf : 0 ≤ᵐ[μ.restrict s] f) : 0 ≤ ∫ x in s, f x ∂μ :=
integral_nonneg_of_ae hf
theorem setIntegral_nonneg_of_ae (hf : 0 ≤ᵐ[μ] f) : 0 ≤ ∫ x in s, f x ∂μ :=
setIntegral_nonneg_of_ae_restrict (ae_restrict_of_ae hf)
theorem setIntegral_nonneg (hs : MeasurableSet s) (hf : ∀ x, x ∈ s → 0 ≤ f x) :
0 ≤ ∫ x in s, f x ∂μ :=
setIntegral_nonneg_of_ae_restrict ((ae_restrict_iff' hs).mpr (ae_of_all μ hf))
theorem setIntegral_nonneg_ae (hs : MeasurableSet s) (hf : ∀ᵐ x ∂μ, x ∈ s → 0 ≤ f x) :
0 ≤ ∫ x in s, f x ∂μ :=
setIntegral_nonneg_of_ae_restrict <| by rwa [EventuallyLE, ae_restrict_iff' hs]
theorem setIntegral_le_nonneg {s : Set X} (hs : MeasurableSet s) (hf : StronglyMeasurable f)
(hfi : Integrable f μ) : ∫ x in s, f x ∂μ ≤ ∫ x in {y | 0 ≤ f y}, f x ∂μ := by
rw [← integral_indicator hs, ←
integral_indicator (stronglyMeasurable_const.measurableSet_le hf)]
exact
integral_mono (hfi.indicator hs)
(hfi.indicator (stronglyMeasurable_const.measurableSet_le hf))
(indicator_le_indicator_nonneg s f)
theorem setIntegral_nonpos_of_ae_restrict (hf : f ≤ᵐ[μ.restrict s] 0) : ∫ x in s, f x ∂μ ≤ 0 :=
integral_nonpos_of_ae hf
theorem setIntegral_nonpos_of_ae (hf : f ≤ᵐ[μ] 0) : ∫ x in s, f x ∂μ ≤ 0 :=
setIntegral_nonpos_of_ae_restrict (ae_restrict_of_ae hf)
theorem setIntegral_nonpos_ae (hs : MeasurableSet s) (hf : ∀ᵐ x ∂μ, x ∈ s → f x ≤ 0) :
∫ x in s, f x ∂μ ≤ 0 :=
setIntegral_nonpos_of_ae_restrict <| by rwa [EventuallyLE, ae_restrict_iff' hs]
theorem setIntegral_nonpos (hs : MeasurableSet s) (hf : ∀ x, x ∈ s → f x ≤ 0) :
∫ x in s, f x ∂μ ≤ 0 :=
setIntegral_nonpos_ae hs <| ae_of_all μ hf
theorem setIntegral_nonpos_le {s : Set X} (hs : MeasurableSet s) (hf : StronglyMeasurable f)
(hfi : Integrable f μ) : ∫ x in {y | f y ≤ 0}, f x ∂μ ≤ ∫ x in s, f x ∂μ := by
rw [← integral_indicator hs, ←
integral_indicator (hf.measurableSet_le stronglyMeasurable_const)]
exact
integral_mono (hfi.indicator (hf.measurableSet_le stronglyMeasurable_const))
(hfi.indicator hs) (indicator_nonpos_le_indicator s f)
lemma Integrable.measure_le_integral {f : X → ℝ} (f_int : Integrable f μ) (f_nonneg : 0 ≤ᵐ[μ] f)
{s : Set X} (hs : ∀ x ∈ s, 1 ≤ f x) :
μ s ≤ ENNReal.ofReal (∫ x, f x ∂μ) := by
rw [ofReal_integral_eq_lintegral_ofReal f_int f_nonneg]
apply meas_le_lintegral₀
· exact ENNReal.continuous_ofReal.measurable.comp_aemeasurable f_int.1.aemeasurable
· intro x hx
simpa using ENNReal.ofReal_le_ofReal (hs x hx)
lemma integral_le_measure {f : X → ℝ} {s : Set X}
(hs : ∀ x ∈ s, f x ≤ 1) (h's : ∀ x ∈ sᶜ, f x ≤ 0) :
ENNReal.ofReal (∫ x, f x ∂μ) ≤ μ s := by
by_cases H : Integrable f μ; swap
· simp [integral_undef H]
let g x := max (f x) 0
have g_int : Integrable g μ := H.pos_part
have : ENNReal.ofReal (∫ x, f x ∂μ) ≤ ENNReal.ofReal (∫ x, g x ∂μ) := by
apply ENNReal.ofReal_le_ofReal
exact integral_mono H g_int (fun x ↦ le_max_left _ _)
apply this.trans
rw [ofReal_integral_eq_lintegral_ofReal g_int (Eventually.of_forall (fun x ↦ le_max_right _ _))]
apply lintegral_le_meas
· intro x
apply ENNReal.ofReal_le_of_le_toReal
by_cases H : x ∈ s
· simpa [g] using hs x H
· apply le_trans _ zero_le_one
simpa [g] using h's x H
· intro x hx
simpa [g] using h's x hx
end Nonneg
section IntegrableUnion
variable {ι : Type*} [Countable ι] {μ : Measure X} [NormedAddCommGroup E]
set_option backward.isDefEq.respectTransparency false in
theorem integrableOn_iUnion_of_summable_integral_norm {f : X → E} {s : ι → Set X}
(hi : ∀ i : ι, IntegrableOn f (s i) μ)
(h : Summable fun i : ι => ∫ x : X in s i, ‖f x‖ ∂μ) : IntegrableOn f (iUnion s) μ := by
refine ⟨AEStronglyMeasurable.iUnion fun i => (hi i).1, (lintegral_iUnion_le _ _).trans_lt ?_⟩
have B := fun i => lintegral_coe_eq_integral (fun x : X => ‖f x‖₊) (hi i).norm
simp_rw [enorm_eq_nnnorm, tsum_congr B]
have S' :
Summable fun i : ι =>
(⟨∫ x : X in s i, ‖f x‖₊ ∂μ, integral_nonneg fun x => NNReal.coe_nonneg _⟩ :
NNReal) := by
rw [← NNReal.summable_coe]; exact h
have S'' := ENNReal.tsum_coe_eq S'.hasSum
simp_rw [ENNReal.coe_nnreal_eq, NNReal.coe_mk, coe_nnnorm] at S''
convert ENNReal.ofReal_lt_top
variable [TopologicalSpace X] [BorelSpace X] [T2Space X] [IsLocallyFiniteMeasure μ]
/-- If `s` is a countable family of compact sets, `f` is a continuous function, and the sequence
`‖f.restrict (s i)‖ * μ (s i)` is summable, then `f` is integrable on the union of the `s i`. -/
theorem integrableOn_iUnion_of_summable_norm_restrict {f : C(X, E)} {s : ι → Compacts X}
(hf : Summable fun i : ι => ‖f.restrict (s i)‖ * μ.real (s i)) :
IntegrableOn f (⋃ i : ι, s i) μ := by
refine
integrableOn_iUnion_of_summable_integral_norm
(fun i => (map_continuous f).continuousOn.integrableOn_compact (s i).isCompact)
(.of_nonneg_of_le (fun ι => integral_nonneg fun x => norm_nonneg _) (fun i => ?_) hf)
rw [← (Real.norm_of_nonneg (integral_nonneg fun x => norm_nonneg _) : ‖_‖ = ∫ x in s i, ‖f x‖ ∂μ)]
exact
norm_setIntegral_le_of_norm_le_const (s i).isCompact.measure_lt_top
fun x hx => (norm_norm (f x)).symm ▸ (f.restrict (s i : Set X)).norm_coe_le_norm ⟨x, hx⟩
/-- If `s` is a countable family of compact sets covering `X`, `f` is a continuous function, and
the sequence `‖f.restrict (s i)‖ * μ (s i)` is summable, then `f` is integrable. -/
theorem integrable_of_summable_norm_restrict {f : C(X, E)} {s : ι → Compacts X}
(hf : Summable fun i : ι => ‖f.restrict (s i)‖ * μ.real (s i))
(hs : ⋃ i : ι, ↑(s i) = (univ : Set X)) : Integrable f μ := by
simpa only [hs, integrableOn_univ] using integrableOn_iUnion_of_summable_norm_restrict hf
end IntegrableUnion
/-! ### Continuity of the set integral
We prove that for any set `s`, the function
`fun f : X →₁[μ] E => ∫ x in s, f x ∂μ` is continuous. -/
section ContinuousSetIntegral
variable [NormedAddCommGroup E]
{𝕜 : Type*} [NormedRing 𝕜] [NormedAddCommGroup F] [Module 𝕜 F] [IsBoundedSMul 𝕜 F]
{p : ℝ≥0∞} {μ : Measure X}
/-- For `f : Lp E p μ`, we can define an element of `Lp E p (μ.restrict s)` by
`(Lp.memLp f).restrict s).toLp f`. This map is additive. -/
theorem Lp_toLp_restrict_add (f g : Lp E p μ) (s : Set X) :
((Lp.memLp (f + g)).restrict s).toLp (⇑(f + g)) =
((Lp.memLp f).restrict s).toLp f + ((Lp.memLp g).restrict s).toLp g := by
ext1
refine (ae_restrict_of_ae (Lp.coeFn_add f g)).mp ?_
refine
(Lp.coeFn_add (MemLp.toLp f ((Lp.memLp f).restrict s))
(MemLp.toLp g ((Lp.memLp g).restrict s))).mp ?_
refine (MemLp.coeFn_toLp ((Lp.memLp f).restrict s)).mp ?_
refine (MemLp.coeFn_toLp ((Lp.memLp g).restrict s)).mp ?_
refine (MemLp.coeFn_toLp ((Lp.memLp (f + g)).restrict s)).mono fun x hx1 hx2 hx3 hx4 hx5 => ?_
rw [hx4, hx1, Pi.add_apply, hx2, hx3, hx5, Pi.add_apply]
/-- For `f : Lp E p μ`, we can define an element of `Lp E p (μ.restrict s)` by
`(Lp.memLp f).restrict s).toLp f`. This map commutes with scalar multiplication. -/
theorem Lp_toLp_restrict_smul (c : 𝕜) (f : Lp F p μ) (s : Set X) :
((Lp.memLp (c • f)).restrict s).toLp (⇑(c • f)) = c • ((Lp.memLp f).restrict s).toLp f := by
ext1
refine (ae_restrict_of_ae (Lp.coeFn_smul c f)).mp ?_
refine (MemLp.coeFn_toLp ((Lp.memLp f).restrict s)).mp ?_
refine (MemLp.coeFn_toLp ((Lp.memLp (c • f)).restrict s)).mp ?_
refine
(Lp.coeFn_smul c (MemLp.toLp f ((Lp.memLp f).restrict s))).mono fun x hx1 hx2 hx3 hx4 => ?_
simp only [hx2, hx1, hx3, hx4, Pi.smul_apply]
/-- For `f : Lp E p μ`, we can define an element of `Lp E p (μ.restrict s)` by
`(Lp.memLp f).restrict s).toLp f`. This map is non-expansive. -/
theorem norm_Lp_toLp_restrict_le (s : Set X) (f : Lp E p μ) :
‖((Lp.memLp f).restrict s).toLp f‖ ≤ ‖f‖ := by
rw [Lp.norm_def, Lp.norm_def, eLpNorm_congr_ae (MemLp.coeFn_toLp _)]
refine ENNReal.toReal_mono (Lp.eLpNorm_ne_top _) ?_
exact eLpNorm_mono_measure _ Measure.restrict_le_self
variable (X F 𝕜) in
/-- Continuous linear map sending a function of `Lp F p μ` to the same function in
`Lp F p (μ.restrict s)`. -/
noncomputable def LpToLpRestrictCLM (μ : Measure X) (p : ℝ≥0∞) [hp : Fact (1 ≤ p)] (s : Set X) :
Lp F p μ →L[𝕜] Lp F p (μ.restrict s) :=
@LinearMap.mkContinuous 𝕜 𝕜 (Lp F p μ) (Lp F p (μ.restrict s)) _ _ _ _ _ _ (RingHom.id 𝕜)
⟨⟨fun f => MemLp.toLp f ((Lp.memLp f).restrict s), fun f g => Lp_toLp_restrict_add f g s⟩,
fun c f => Lp_toLp_restrict_smul c f s⟩
1 (by intro f; rw [one_mul]; exact norm_Lp_toLp_restrict_le s f)
variable (𝕜) in
theorem LpToLpRestrictCLM_coeFn [Fact (1 ≤ p)] (s : Set X) (f : Lp F p μ) :
LpToLpRestrictCLM X F 𝕜 μ p s f =ᵐ[μ.restrict s] f :=
MemLp.coeFn_toLp ((Lp.memLp f).restrict s)
@[continuity]
theorem continuous_setIntegral [NormedSpace ℝ E] (s : Set X) :
Continuous fun f : X →₁[μ] E => ∫ x in s, f x ∂μ := by
haveI : Fact ((1 : ℝ≥0∞) ≤ 1) := ⟨le_rfl⟩
have h_comp :
(fun f : X →₁[μ] E => ∫ x in s, f x ∂μ) =
integral (μ.restrict s) ∘ fun f => LpToLpRestrictCLM X E ℝ μ 1 s f := by
ext1 f
rw [Function.comp_apply, integral_congr_ae (LpToLpRestrictCLM_coeFn ℝ s f)]
rw [h_comp]
exact continuous_integral.comp (LpToLpRestrictCLM X E ℝ μ 1 s).continuous
end ContinuousSetIntegral
end MeasureTheory
section OpenPos
open Measure
variable [MeasurableSpace X] [TopologicalSpace X] [OpensMeasurableSpace X]
{μ : Measure X} [IsOpenPosMeasure μ]