probability.kernel.measurable_integralMathlib.Probability.Kernel.MeasurableIntegral

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -51,7 +51,7 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
     simp only [preimage_empty, measure_empty, measurable_const]
   · -- case of a box: `t = t₁ ×ˢ t₂` for measurable sets `t₁` and `t₂`
     intro t' ht'
-    simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht' 
+    simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht'
     obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht'
     classical
     simp_rw [mk_preimage_prod_right_eq_if]
@@ -164,7 +164,7 @@ theorem Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (h
   by
   let F : ℕ → simple_func (α × β) ℝ≥0∞ := simple_func.eapprox (uncurry f)
   have h : ∀ a, (⨆ n, F n a) = uncurry f a := simple_func.supr_eapprox_apply (uncurry f) hf
-  simp only [Prod.forall, uncurry_apply_pair] at h 
+  simp only [Prod.forall, uncurry_apply_pair] at h
   simp_rw [← h]
   have : ∀ a, ∫⁻ b, ⨆ n, F n (a, b) ∂κ a = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a :=
     by
@@ -327,7 +327,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
 
 #print MeasureTheory.StronglyMeasurable.integral_kernel_prod_right' /-
 theorem StronglyMeasurable.integral_kernel_prod_right' ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) :
-    StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x := by rw [← uncurry_curry f] at hf ;
+    StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x := by rw [← uncurry_curry f] at hf;
   exact hf.integral_kernel_prod_right
 #align measure_theory.strongly_measurable.integral_kernel_prod_right' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right'
 -/
Diff
@@ -54,6 +54,14 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
     simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht' 
     obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht'
     classical
+    simp_rw [mk_preimage_prod_right_eq_if]
+    have h_eq_ite : (fun a => κ a (ite (a ∈ t₁) t₂ ∅)) = fun a => ite (a ∈ t₁) (κ a t₂) 0 :=
+      by
+      ext1 a
+      split_ifs
+      exacts [rfl, measure_empty]
+    rw [h_eq_ite]
+    exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const
   · -- we assume that the result is true for `t` and we prove it for `tᶜ`
     intro t' ht' h_meas
     have h_eq_sdiff : ∀ a, Prod.mk a ⁻¹' t'ᶜ = Set.univ \ Prod.mk a ⁻¹' t' :=
@@ -274,6 +282,46 @@ variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace
 theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by
   classical
+  borelize E
+  haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) :=
+    hf.separable_space_range_union_singleton
+  let s : ℕ → simple_func (α × β) E :=
+    simple_func.approx_on _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp)
+  let s' : ℕ → α → simple_func β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left
+  let f' : ℕ → α → E := fun n =>
+    {x | integrable (f x) (κ x)}.indicator fun x => (s' n x).integral (κ x)
+  have hf' : ∀ n, strongly_measurable (f' n) :=
+    by
+    intro n; refine' strongly_measurable.indicator _ (measurable_set_kernel_integrable hf)
+    have : ∀ x, ((s' n x).range.filterₓ fun x => x ≠ 0) ⊆ (s n).range :=
+      by
+      intro x; refine' Finset.Subset.trans (Finset.filter_subset _ _) _; intro y
+      simp_rw [simple_func.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩
+    simp only [simple_func.integral_eq_sum_of_subset (this _)]
+    refine' Finset.stronglyMeasurable_sum _ fun x _ => _
+    refine' (Measurable.ennreal_toReal _).StronglyMeasurable.smul_const _
+    simp (config := { singlePass := true }) only [simple_func.coe_comp, preimage_comp]
+    apply measurable_kernel_prod_mk_left
+    exact (s n).measurableSet_fiber x
+  have h2f' : tendsto f' at_top (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) :=
+    by
+    rw [tendsto_pi_nhds]; intro x
+    by_cases hfx : integrable (f x) (κ x)
+    · have : ∀ n, integrable (s' n x) (κ x) := by
+        intro n; apply (hfx.norm.add hfx.norm).mono' (s' n x).AEStronglyMeasurable
+        apply eventually_of_forall; intro y
+        simp_rw [s', simple_func.coe_comp]; exact simple_func.norm_approx_on_zero_le _ _ (x, y) n
+      simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,
+        mem_set_of_eq]
+      refine'
+        tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
+          (fun n => (s' n x).AEStronglyMeasurable) (hfx.norm.add hfx.norm) _ _
+      · exact fun n => eventually_of_forall fun y => simple_func.norm_approx_on_zero_le _ _ (x, y) n
+      · refine' eventually_of_forall fun y => simple_func.tendsto_approx_on _ _ _
+        apply subset_closure
+        simp [-uncurry_apply_pair]
+    · simp [f', hfx, integral_undef]
+  exact stronglyMeasurable_of_tendsto _ hf' h2f'
 #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
 -/
 
Diff
@@ -54,14 +54,6 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
     simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht' 
     obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht'
     classical
-    simp_rw [mk_preimage_prod_right_eq_if]
-    have h_eq_ite : (fun a => κ a (ite (a ∈ t₁) t₂ ∅)) = fun a => ite (a ∈ t₁) (κ a t₂) 0 :=
-      by
-      ext1 a
-      split_ifs
-      exacts [rfl, measure_empty]
-    rw [h_eq_ite]
-    exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const
   · -- we assume that the result is true for `t` and we prove it for `tᶜ`
     intro t' ht' h_meas
     have h_eq_sdiff : ∀ a, Prod.mk a ⁻¹' t'ᶜ = Set.univ \ Prod.mk a ⁻¹' t' :=
@@ -282,46 +274,6 @@ variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace
 theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by
   classical
-  borelize E
-  haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) :=
-    hf.separable_space_range_union_singleton
-  let s : ℕ → simple_func (α × β) E :=
-    simple_func.approx_on _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp)
-  let s' : ℕ → α → simple_func β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left
-  let f' : ℕ → α → E := fun n =>
-    {x | integrable (f x) (κ x)}.indicator fun x => (s' n x).integral (κ x)
-  have hf' : ∀ n, strongly_measurable (f' n) :=
-    by
-    intro n; refine' strongly_measurable.indicator _ (measurable_set_kernel_integrable hf)
-    have : ∀ x, ((s' n x).range.filterₓ fun x => x ≠ 0) ⊆ (s n).range :=
-      by
-      intro x; refine' Finset.Subset.trans (Finset.filter_subset _ _) _; intro y
-      simp_rw [simple_func.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩
-    simp only [simple_func.integral_eq_sum_of_subset (this _)]
-    refine' Finset.stronglyMeasurable_sum _ fun x _ => _
-    refine' (Measurable.ennreal_toReal _).StronglyMeasurable.smul_const _
-    simp (config := { singlePass := true }) only [simple_func.coe_comp, preimage_comp]
-    apply measurable_kernel_prod_mk_left
-    exact (s n).measurableSet_fiber x
-  have h2f' : tendsto f' at_top (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) :=
-    by
-    rw [tendsto_pi_nhds]; intro x
-    by_cases hfx : integrable (f x) (κ x)
-    · have : ∀ n, integrable (s' n x) (κ x) := by
-        intro n; apply (hfx.norm.add hfx.norm).mono' (s' n x).AEStronglyMeasurable
-        apply eventually_of_forall; intro y
-        simp_rw [s', simple_func.coe_comp]; exact simple_func.norm_approx_on_zero_le _ _ (x, y) n
-      simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,
-        mem_set_of_eq]
-      refine'
-        tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
-          (fun n => (s' n x).AEStronglyMeasurable) (hfx.norm.add hfx.norm) _ _
-      · exact fun n => eventually_of_forall fun y => simple_func.norm_approx_on_zero_le _ _ (x, y) n
-      · refine' eventually_of_forall fun y => simple_func.tendsto_approx_on _ _ _
-        apply subset_closure
-        simp [-uncurry_apply_pair]
-    · simp [f', hfx, integral_undef]
-  exact stronglyMeasurable_of_tendsto _ hf' h2f'
 #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
 -/
 
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2023 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 -/
-import Mathbin.Probability.Kernel.Basic
+import Probability.Kernel.Basic
 
 #align_import probability.kernel.measurable_integral from "leanprover-community/mathlib"@"8af7091a43227e179939ba132e54e54e9f3b089a"
 
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2023 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
-
-! This file was ported from Lean 3 source module probability.kernel.measurable_integral
-! leanprover-community/mathlib commit 8af7091a43227e179939ba132e54e54e9f3b089a
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Probability.Kernel.Basic
 
+#align_import probability.kernel.measurable_integral from "leanprover-community/mathlib"@"8af7091a43227e179939ba132e54e54e9f3b089a"
+
 /-!
 # Measurability of the integral against a kernel
 
Diff
@@ -42,7 +42,7 @@ namespace ProbabilityTheory
 
 namespace Kernel
 
-#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left_of_finite /-
+#print ProbabilityTheory.kernel.measurable_kernel_prod_mk_left_of_finite /-
 /-- This is an auxiliary lemma for `measurable_kernel_prod_mk_left`. -/
 theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : MeasurableSet t)
     (hκs : ∀ a, IsFiniteMeasure (κ a)) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
@@ -105,10 +105,10 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
       · exact fun i => (@measurable_prod_mk_left α β _ _ a) _ (hf_meas i)
     rw [h_tsum]
     exact Measurable.ennreal_tsum hf
-#align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left_of_finite
+#align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.kernel.measurable_kernel_prod_mk_left_of_finite
 -/
 
-#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left /-
+#print ProbabilityTheory.kernel.measurable_kernel_prod_mk_left /-
 theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
     (ht : MeasurableSet t) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
   by
@@ -118,10 +118,10 @@ theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
   simp_rw [this]
   refine' Measurable.ennreal_tsum fun n => _
   exact measurable_kernel_prod_mk_left_of_finite ht inferInstance
-#align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left
+#align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.kernel.measurable_kernel_prod_mk_left
 -/
 
-#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left' /-
+#print ProbabilityTheory.kernel.measurable_kernel_prod_mk_left' /-
 theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)} (hs : MeasurableSet s)
     (a : α) : Measurable fun b => η (a, b) (Prod.mk b ⁻¹' s) :=
   by
@@ -130,14 +130,14 @@ theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)
   simp_rw [this]
   refine' (measurable_kernel_prod_mk_left _).comp measurable_prod_mk_left
   exact (measurable_fst.snd.prod_mk measurable_snd) hs
-#align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left'
+#align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.kernel.measurable_kernel_prod_mk_left'
 -/
 
-#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_right /-
+#print ProbabilityTheory.kernel.measurable_kernel_prod_mk_right /-
 theorem measurable_kernel_prod_mk_right [IsSFiniteKernel κ] {s : Set (β × α)}
     (hs : MeasurableSet s) : Measurable fun y => κ y ((fun x => (x, y)) ⁻¹' s) :=
   measurable_kernel_prod_mk_left (measurableSet_swap_iff.mpr hs)
-#align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.Kernel.measurable_kernel_prod_mk_right
+#align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.kernel.measurable_kernel_prod_mk_right
 -/
 
 end Kernel
@@ -148,14 +148,14 @@ section Lintegral
 
 variable [IsSFiniteKernel κ] [IsSFiniteKernel η]
 
-#print ProbabilityTheory.Kernel.measurable_lintegral_indicator_const /-
+#print ProbabilityTheory.kernel.measurable_lintegral_indicator_const /-
 /-- Auxiliary lemma for `measurable.lintegral_kernel_prod_right`. -/
-theorem Kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
+theorem kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
     (c : ℝ≥0∞) : Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a :=
   by
   simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]
   exact Measurable.const_mul (measurable_kernel_prod_mk_left ht) c
-#align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.Kernel.measurable_lintegral_indicator_const
+#align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.kernel.measurable_lintegral_indicator_const
 -/
 
 #print Measurable.lintegral_kernel_prod_right /-
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 
 ! This file was ported from Lean 3 source module probability.kernel.measurable_integral
-! leanprover-community/mathlib commit 28b2a92f2996d28e580450863c130955de0ed398
+! leanprover-community/mathlib commit 8af7091a43227e179939ba132e54e54e9f3b089a
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.Probability.Kernel.Basic
 /-!
 # Measurability of the integral against a kernel
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 The Lebesgue integral of a measurable function against a kernel is measurable. The Bochner integral
 is strongly measurable.
 
Diff
@@ -39,6 +39,7 @@ namespace ProbabilityTheory
 
 namespace Kernel
 
+#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left_of_finite /-
 /-- This is an auxiliary lemma for `measurable_kernel_prod_mk_left`. -/
 theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : MeasurableSet t)
     (hκs : ∀ a, IsFiniteMeasure (κ a)) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
@@ -101,8 +102,10 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
       · exact fun i => (@measurable_prod_mk_left α β _ _ a) _ (hf_meas i)
     rw [h_tsum]
     exact Measurable.ennreal_tsum hf
-#align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.kernel.measurable_kernel_prod_mk_left_of_finite
+#align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left_of_finite
+-/
 
+#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left /-
 theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
     (ht : MeasurableSet t) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
   by
@@ -112,8 +115,10 @@ theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
   simp_rw [this]
   refine' Measurable.ennreal_tsum fun n => _
   exact measurable_kernel_prod_mk_left_of_finite ht inferInstance
-#align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.kernel.measurable_kernel_prod_mk_left
+#align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left
+-/
 
+#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left' /-
 theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)} (hs : MeasurableSet s)
     (a : α) : Measurable fun b => η (a, b) (Prod.mk b ⁻¹' s) :=
   by
@@ -122,12 +127,15 @@ theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)
   simp_rw [this]
   refine' (measurable_kernel_prod_mk_left _).comp measurable_prod_mk_left
   exact (measurable_fst.snd.prod_mk measurable_snd) hs
-#align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.kernel.measurable_kernel_prod_mk_left'
+#align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left'
+-/
 
+#print ProbabilityTheory.Kernel.measurable_kernel_prod_mk_right /-
 theorem measurable_kernel_prod_mk_right [IsSFiniteKernel κ] {s : Set (β × α)}
     (hs : MeasurableSet s) : Measurable fun y => κ y ((fun x => (x, y)) ⁻¹' s) :=
   measurable_kernel_prod_mk_left (measurableSet_swap_iff.mpr hs)
-#align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.kernel.measurable_kernel_prod_mk_right
+#align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.Kernel.measurable_kernel_prod_mk_right
+-/
 
 end Kernel
 
@@ -137,14 +145,17 @@ section Lintegral
 
 variable [IsSFiniteKernel κ] [IsSFiniteKernel η]
 
+#print ProbabilityTheory.Kernel.measurable_lintegral_indicator_const /-
 /-- Auxiliary lemma for `measurable.lintegral_kernel_prod_right`. -/
-theorem kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
+theorem Kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
     (c : ℝ≥0∞) : Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a :=
   by
   simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]
   exact Measurable.const_mul (measurable_kernel_prod_mk_left ht) c
-#align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.kernel.measurable_lintegral_indicator_const
+#align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.Kernel.measurable_lintegral_indicator_const
+-/
 
+#print Measurable.lintegral_kernel_prod_right /-
 /-- For an s-finite kernel `κ` and a function `f : α → β → ℝ≥0∞` which is measurable when seen as a
 map from `α × β` (hypothesis `measurable (uncurry f)`), the integral `a ↦ ∫⁻ b, f a b ∂(κ a)` is
 measurable. -/
@@ -178,7 +189,9 @@ theorem Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (h
     rw [h_add]
     exact Measurable.add hm₁ hm₂
 #align measurable.lintegral_kernel_prod_right Measurable.lintegral_kernel_prod_right
+-/
 
+#print Measurable.lintegral_kernel_prod_right' /-
 theorem Measurable.lintegral_kernel_prod_right' {f : α × β → ℝ≥0∞} (hf : Measurable f) :
     Measurable fun a => ∫⁻ b, f (a, b) ∂κ a :=
   by
@@ -187,7 +200,9 @@ theorem Measurable.lintegral_kernel_prod_right' {f : α × β → ℝ≥0∞} (h
     rw [← @Prod.mk.eta _ _ x, uncurry_apply_pair]
   rwa [this]
 #align measurable.lintegral_kernel_prod_right' Measurable.lintegral_kernel_prod_right'
+-/
 
+#print Measurable.lintegral_kernel_prod_right'' /-
 theorem Measurable.lintegral_kernel_prod_right'' {f : β × γ → ℝ≥0∞} (hf : Measurable f) :
     Measurable fun x => ∫⁻ y, f (x, y) ∂η (a, x) :=
   by
@@ -197,47 +212,62 @@ theorem Measurable.lintegral_kernel_prod_right'' {f : β × γ → ℝ≥0∞} (
   refine' (Measurable.lintegral_kernel_prod_right' _).comp measurable_prod_mk_left
   exact hf.comp (measurable_fst.snd.prod_mk measurable_snd)
 #align measurable.lintegral_kernel_prod_right'' Measurable.lintegral_kernel_prod_right''
+-/
 
+#print Measurable.set_lintegral_kernel_prod_right /-
 theorem Measurable.set_lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f))
     {s : Set β} (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f a b ∂κ a := by
   simp_rw [← lintegral_restrict κ hs]; exact hf.lintegral_kernel_prod_right
 #align measurable.set_lintegral_kernel_prod_right Measurable.set_lintegral_kernel_prod_right
+-/
 
+#print Measurable.lintegral_kernel_prod_left' /-
 theorem Measurable.lintegral_kernel_prod_left' {f : β × α → ℝ≥0∞} (hf : Measurable f) :
     Measurable fun y => ∫⁻ x, f (x, y) ∂κ y :=
   (measurable_swap_iff.mpr hf).lintegral_kernel_prod_right'
 #align measurable.lintegral_kernel_prod_left' Measurable.lintegral_kernel_prod_left'
+-/
 
+#print Measurable.lintegral_kernel_prod_left /-
 theorem Measurable.lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf : Measurable (uncurry f)) :
     Measurable fun y => ∫⁻ x, f x y ∂κ y :=
   hf.lintegral_kernel_prod_left'
 #align measurable.lintegral_kernel_prod_left Measurable.lintegral_kernel_prod_left
+-/
 
+#print Measurable.set_lintegral_kernel_prod_left /-
 theorem Measurable.set_lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf : Measurable (uncurry f))
     {s : Set β} (hs : MeasurableSet s) : Measurable fun b => ∫⁻ a in s, f a b ∂κ b := by
   simp_rw [← lintegral_restrict κ hs]; exact hf.lintegral_kernel_prod_left
 #align measurable.set_lintegral_kernel_prod_left Measurable.set_lintegral_kernel_prod_left
+-/
 
+#print Measurable.lintegral_kernel /-
 theorem Measurable.lintegral_kernel {f : β → ℝ≥0∞} (hf : Measurable f) :
     Measurable fun a => ∫⁻ b, f b ∂κ a :=
   Measurable.lintegral_kernel_prod_right (hf.comp measurable_snd)
 #align measurable.lintegral_kernel Measurable.lintegral_kernel
+-/
 
+#print Measurable.set_lintegral_kernel /-
 theorem Measurable.set_lintegral_kernel {f : β → ℝ≥0∞} (hf : Measurable f) {s : Set β}
     (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f b ∂κ a :=
   Measurable.set_lintegral_kernel_prod_right (hf.comp measurable_snd) hs
 #align measurable.set_lintegral_kernel Measurable.set_lintegral_kernel
+-/
 
 end Lintegral
 
 variable {E : Type _} [NormedAddCommGroup E] [IsSFiniteKernel κ] [IsSFiniteKernel η]
 
+#print ProbabilityTheory.measurableSet_kernel_integrable /-
 theorem measurableSet_kernel_integrable ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) :
     MeasurableSet {x | Integrable (f x) (κ x)} :=
   by
   simp_rw [integrable, hf.of_uncurry_left.ae_strongly_measurable, true_and_iff]
   exact measurableSet_lt (Measurable.lintegral_kernel_prod_right hf.ennnorm) measurable_const
 #align probability_theory.measurable_set_kernel_integrable ProbabilityTheory.measurableSet_kernel_integrable
+-/
 
 end ProbabilityTheory
 
@@ -248,6 +278,7 @@ namespace MeasureTheory
 variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [IsSFiniteKernel κ]
   [IsSFiniteKernel η]
 
+#print MeasureTheory.StronglyMeasurable.integral_kernel_prod_right /-
 theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by
   classical
@@ -292,12 +323,16 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     · simp [f', hfx, integral_undef]
   exact stronglyMeasurable_of_tendsto _ hf' h2f'
 #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
+-/
 
+#print MeasureTheory.StronglyMeasurable.integral_kernel_prod_right' /-
 theorem StronglyMeasurable.integral_kernel_prod_right' ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) :
     StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x := by rw [← uncurry_curry f] at hf ;
   exact hf.integral_kernel_prod_right
 #align measure_theory.strongly_measurable.integral_kernel_prod_right' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right'
+-/
 
+#print MeasureTheory.StronglyMeasurable.integral_kernel_prod_right'' /-
 theorem StronglyMeasurable.integral_kernel_prod_right'' {f : β × γ → E}
     (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ∫ y, f (x, y) ∂η (a, x) :=
   by
@@ -308,17 +343,23 @@ theorem StronglyMeasurable.integral_kernel_prod_right'' {f : β × γ → E}
   refine' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right' _
   exact hf.comp_measurable (measurable_fst.snd.prod_mk measurable_snd)
 #align measure_theory.strongly_measurable.integral_kernel_prod_right'' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right''
+-/
 
+#print MeasureTheory.StronglyMeasurable.integral_kernel_prod_left /-
 theorem StronglyMeasurable.integral_kernel_prod_left ⦃f : β → α → E⦄
     (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun y => ∫ x, f x y ∂κ y :=
   (hf.comp_measurable measurable_swap).integral_kernel_prod_right'
 #align measure_theory.strongly_measurable.integral_kernel_prod_left MeasureTheory.StronglyMeasurable.integral_kernel_prod_left
+-/
 
+#print MeasureTheory.StronglyMeasurable.integral_kernel_prod_left' /-
 theorem StronglyMeasurable.integral_kernel_prod_left' ⦃f : β × α → E⦄ (hf : StronglyMeasurable f) :
     StronglyMeasurable fun y => ∫ x, f (x, y) ∂κ y :=
   (hf.comp_measurable measurable_swap).integral_kernel_prod_right'
 #align measure_theory.strongly_measurable.integral_kernel_prod_left' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left'
+-/
 
+#print MeasureTheory.StronglyMeasurable.integral_kernel_prod_left'' /-
 theorem StronglyMeasurable.integral_kernel_prod_left'' {f : γ × β → E} (hf : StronglyMeasurable f) :
     StronglyMeasurable fun y => ∫ x, f (x, y) ∂η (a, y) :=
   by
@@ -329,6 +370,7 @@ theorem StronglyMeasurable.integral_kernel_prod_left'' {f : γ × β → E} (hf
   refine' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left' _
   exact hf.comp_measurable (measurable_fst.prod_mk measurable_snd.snd)
 #align measure_theory.strongly_measurable.integral_kernel_prod_left'' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left''
+-/
 
 end MeasureTheory
 
Diff
@@ -155,7 +155,7 @@ theorem Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (h
   have h : ∀ a, (⨆ n, F n a) = uncurry f a := simple_func.supr_eapprox_apply (uncurry f) hf
   simp only [Prod.forall, uncurry_apply_pair] at h 
   simp_rw [← h]
-  have : ∀ a, (∫⁻ b, ⨆ n, F n (a, b) ∂κ a) = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a :=
+  have : ∀ a, ∫⁻ b, ⨆ n, F n (a, b) ∂κ a = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a :=
     by
     intro a
     rw [lintegral_supr]
Diff
@@ -41,7 +41,7 @@ namespace Kernel
 
 /-- This is an auxiliary lemma for `measurable_kernel_prod_mk_left`. -/
 theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : MeasurableSet t)
-    (hκs : ∀ a, FiniteMeasure (κ a)) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
+    (hκs : ∀ a, IsFiniteMeasure (κ a)) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
   by
   -- `t` is a measurable set in the product `α × β`: we use that the product σ-algebra is generated
   -- by boxes to prove the result by induction.
@@ -53,14 +53,14 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
     simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht' 
     obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht'
     classical
-      simp_rw [mk_preimage_prod_right_eq_if]
-      have h_eq_ite : (fun a => κ a (ite (a ∈ t₁) t₂ ∅)) = fun a => ite (a ∈ t₁) (κ a t₂) 0 :=
-        by
-        ext1 a
-        split_ifs
-        exacts [rfl, measure_empty]
-      rw [h_eq_ite]
-      exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const
+    simp_rw [mk_preimage_prod_right_eq_if]
+    have h_eq_ite : (fun a => κ a (ite (a ∈ t₁) t₂ ∅)) = fun a => ite (a ∈ t₁) (κ a t₂) 0 :=
+      by
+      ext1 a
+      split_ifs
+      exacts [rfl, measure_empty]
+    rw [h_eq_ite]
+    exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const
   · -- we assume that the result is true for `t` and we prove it for `tᶜ`
     intro t' ht' h_meas
     have h_eq_sdiff : ∀ a, Prod.mk a ⁻¹' t'ᶜ = Set.univ \ Prod.mk a ⁻¹' t' :=
@@ -117,7 +117,7 @@ theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
 theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)} (hs : MeasurableSet s)
     (a : α) : Measurable fun b => η (a, b) (Prod.mk b ⁻¹' s) :=
   by
-  have : ∀ b, Prod.mk b ⁻¹' s = { c | ((a, b), c) ∈ { p : (α × β) × γ | (p.1.2, p.2) ∈ s } } := by
+  have : ∀ b, Prod.mk b ⁻¹' s = {c | ((a, b), c) ∈ {p : (α × β) × γ | (p.1.2, p.2) ∈ s}} := by
     intro b; rfl
   simp_rw [this]
   refine' (measurable_kernel_prod_mk_left _).comp measurable_prod_mk_left
@@ -233,7 +233,7 @@ end Lintegral
 variable {E : Type _} [NormedAddCommGroup E] [IsSFiniteKernel κ] [IsSFiniteKernel η]
 
 theorem measurableSet_kernel_integrable ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) :
-    MeasurableSet { x | Integrable (f x) (κ x) } :=
+    MeasurableSet {x | Integrable (f x) (κ x)} :=
   by
   simp_rw [integrable, hf.of_uncurry_left.ae_strongly_measurable, true_and_iff]
   exact measurableSet_lt (Measurable.lintegral_kernel_prod_right hf.ennnorm) measurable_const
@@ -251,48 +251,46 @@ variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace
 theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by
   classical
-    borelize E
-    haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) :=
-      hf.separable_space_range_union_singleton
-    let s : ℕ → simple_func (α × β) E :=
-      simple_func.approx_on _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp)
-    let s' : ℕ → α → simple_func β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left
-    let f' : ℕ → α → E := fun n =>
-      { x | integrable (f x) (κ x) }.indicator fun x => (s' n x).integral (κ x)
-    have hf' : ∀ n, strongly_measurable (f' n) :=
-      by
-      intro n; refine' strongly_measurable.indicator _ (measurable_set_kernel_integrable hf)
-      have : ∀ x, ((s' n x).range.filterₓ fun x => x ≠ 0) ⊆ (s n).range :=
-        by
-        intro x; refine' Finset.Subset.trans (Finset.filter_subset _ _) _; intro y
-        simp_rw [simple_func.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩
-      simp only [simple_func.integral_eq_sum_of_subset (this _)]
-      refine' Finset.stronglyMeasurable_sum _ fun x _ => _
-      refine' (Measurable.ennreal_toReal _).StronglyMeasurable.smul_const _
-      simp (config := { singlePass := true }) only [simple_func.coe_comp, preimage_comp]
-      apply measurable_kernel_prod_mk_left
-      exact (s n).measurableSet_fiber x
-    have h2f' : tendsto f' at_top (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) :=
+  borelize E
+  haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) :=
+    hf.separable_space_range_union_singleton
+  let s : ℕ → simple_func (α × β) E :=
+    simple_func.approx_on _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp)
+  let s' : ℕ → α → simple_func β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left
+  let f' : ℕ → α → E := fun n =>
+    {x | integrable (f x) (κ x)}.indicator fun x => (s' n x).integral (κ x)
+  have hf' : ∀ n, strongly_measurable (f' n) :=
+    by
+    intro n; refine' strongly_measurable.indicator _ (measurable_set_kernel_integrable hf)
+    have : ∀ x, ((s' n x).range.filterₓ fun x => x ≠ 0) ⊆ (s n).range :=
       by
-      rw [tendsto_pi_nhds]; intro x
-      by_cases hfx : integrable (f x) (κ x)
-      · have : ∀ n, integrable (s' n x) (κ x) := by
-          intro n; apply (hfx.norm.add hfx.norm).mono' (s' n x).AEStronglyMeasurable
-          apply eventually_of_forall; intro y
-          simp_rw [s', simple_func.coe_comp]; exact simple_func.norm_approx_on_zero_le _ _ (x, y) n
-        simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,
-          mem_set_of_eq]
-        refine'
-          tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
-            (fun n => (s' n x).AEStronglyMeasurable) (hfx.norm.add hfx.norm) _ _
-        ·
-          exact fun n =>
-            eventually_of_forall fun y => simple_func.norm_approx_on_zero_le _ _ (x, y) n
-        · refine' eventually_of_forall fun y => simple_func.tendsto_approx_on _ _ _
-          apply subset_closure
-          simp [-uncurry_apply_pair]
-      · simp [f', hfx, integral_undef]
-    exact stronglyMeasurable_of_tendsto _ hf' h2f'
+      intro x; refine' Finset.Subset.trans (Finset.filter_subset _ _) _; intro y
+      simp_rw [simple_func.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩
+    simp only [simple_func.integral_eq_sum_of_subset (this _)]
+    refine' Finset.stronglyMeasurable_sum _ fun x _ => _
+    refine' (Measurable.ennreal_toReal _).StronglyMeasurable.smul_const _
+    simp (config := { singlePass := true }) only [simple_func.coe_comp, preimage_comp]
+    apply measurable_kernel_prod_mk_left
+    exact (s n).measurableSet_fiber x
+  have h2f' : tendsto f' at_top (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) :=
+    by
+    rw [tendsto_pi_nhds]; intro x
+    by_cases hfx : integrable (f x) (κ x)
+    · have : ∀ n, integrable (s' n x) (κ x) := by
+        intro n; apply (hfx.norm.add hfx.norm).mono' (s' n x).AEStronglyMeasurable
+        apply eventually_of_forall; intro y
+        simp_rw [s', simple_func.coe_comp]; exact simple_func.norm_approx_on_zero_le _ _ (x, y) n
+      simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,
+        mem_set_of_eq]
+      refine'
+        tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
+          (fun n => (s' n x).AEStronglyMeasurable) (hfx.norm.add hfx.norm) _ _
+      · exact fun n => eventually_of_forall fun y => simple_func.norm_approx_on_zero_le _ _ (x, y) n
+      · refine' eventually_of_forall fun y => simple_func.tendsto_approx_on _ _ _
+        apply subset_closure
+        simp [-uncurry_apply_pair]
+    · simp [f', hfx, integral_undef]
+  exact stronglyMeasurable_of_tendsto _ hf' h2f'
 #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
 
 theorem StronglyMeasurable.integral_kernel_prod_right' ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) :
Diff
@@ -50,7 +50,7 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
     simp only [preimage_empty, measure_empty, measurable_const]
   · -- case of a box: `t = t₁ ×ˢ t₂` for measurable sets `t₁` and `t₂`
     intro t' ht'
-    simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht'
+    simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht' 
     obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht'
     classical
       simp_rw [mk_preimage_prod_right_eq_if]
@@ -58,7 +58,7 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
         by
         ext1 a
         split_ifs
-        exacts[rfl, measure_empty]
+        exacts [rfl, measure_empty]
       rw [h_eq_ite]
       exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const
   · -- we assume that the result is true for `t` and we prove it for `tᶜ`
@@ -153,7 +153,7 @@ theorem Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (h
   by
   let F : ℕ → simple_func (α × β) ℝ≥0∞ := simple_func.eapprox (uncurry f)
   have h : ∀ a, (⨆ n, F n a) = uncurry f a := simple_func.supr_eapprox_apply (uncurry f) hf
-  simp only [Prod.forall, uncurry_apply_pair] at h
+  simp only [Prod.forall, uncurry_apply_pair] at h 
   simp_rw [← h]
   have : ∀ a, (∫⁻ b, ⨆ n, F n (a, b) ∂κ a) = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a :=
     by
@@ -296,7 +296,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
 #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
 
 theorem StronglyMeasurable.integral_kernel_prod_right' ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) :
-    StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x := by rw [← uncurry_curry f] at hf;
+    StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x := by rw [← uncurry_curry f] at hf ;
   exact hf.integral_kernel_prod_right
 #align measure_theory.strongly_measurable.integral_kernel_prod_right' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right'
 
Diff
@@ -30,7 +30,7 @@ is strongly measurable.
 
 open MeasureTheory ProbabilityTheory Function Set Filter
 
-open MeasureTheory ENNReal Topology
+open scoped MeasureTheory ENNReal Topology
 
 variable {α β γ : Type _} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
   {κ : kernel α β} {η : kernel (α × β) γ} {a : α}
Diff
@@ -94,12 +94,8 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
       ext1 a
       rw [measure_Union]
       · intro i j hij s hsi hsj b hbs
-        have habi : {(a, b)} ⊆ f i := by
-          rw [Set.singleton_subset_iff]
-          exact hsi hbs
-        have habj : {(a, b)} ⊆ f j := by
-          rw [Set.singleton_subset_iff]
-          exact hsj hbs
+        have habi : {(a, b)} ⊆ f i := by rw [Set.singleton_subset_iff]; exact hsi hbs
+        have habj : {(a, b)} ⊆ f j := by rw [Set.singleton_subset_iff]; exact hsj hbs
         simpa only [Set.bot_eq_empty, Set.le_eq_subset, Set.singleton_subset_iff,
           Set.mem_empty_iff_false] using h_disj hij habi habj
       · exact fun i => (@measurable_prod_mk_left α β _ _ a) _ (hf_meas i)
@@ -121,10 +117,8 @@ theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
 theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)} (hs : MeasurableSet s)
     (a : α) : Measurable fun b => η (a, b) (Prod.mk b ⁻¹' s) :=
   by
-  have : ∀ b, Prod.mk b ⁻¹' s = { c | ((a, b), c) ∈ { p : (α × β) × γ | (p.1.2, p.2) ∈ s } } :=
-    by
-    intro b
-    rfl
+  have : ∀ b, Prod.mk b ⁻¹' s = { c | ((a, b), c) ∈ { p : (α × β) × γ | (p.1.2, p.2) ∈ s } } := by
+    intro b; rfl
   simp_rw [this]
   refine' (measurable_kernel_prod_mk_left _).comp measurable_prod_mk_left
   exact (measurable_fst.snd.prod_mk measurable_snd) hs
@@ -189,9 +183,7 @@ theorem Measurable.lintegral_kernel_prod_right' {f : α × β → ℝ≥0∞} (h
     Measurable fun a => ∫⁻ b, f (a, b) ∂κ a :=
   by
   refine' Measurable.lintegral_kernel_prod_right _
-  have : (uncurry fun (a : α) (b : β) => f (a, b)) = f :=
-    by
-    ext x
+  have : (uncurry fun (a : α) (b : β) => f (a, b)) = f := by ext x;
     rw [← @Prod.mk.eta _ _ x, uncurry_apply_pair]
   rwa [this]
 #align measurable.lintegral_kernel_prod_right' Measurable.lintegral_kernel_prod_right'
@@ -207,10 +199,8 @@ theorem Measurable.lintegral_kernel_prod_right'' {f : β × γ → ℝ≥0∞} (
 #align measurable.lintegral_kernel_prod_right'' Measurable.lintegral_kernel_prod_right''
 
 theorem Measurable.set_lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f))
-    {s : Set β} (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f a b ∂κ a :=
-  by
-  simp_rw [← lintegral_restrict κ hs]
-  exact hf.lintegral_kernel_prod_right
+    {s : Set β} (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f a b ∂κ a := by
+  simp_rw [← lintegral_restrict κ hs]; exact hf.lintegral_kernel_prod_right
 #align measurable.set_lintegral_kernel_prod_right Measurable.set_lintegral_kernel_prod_right
 
 theorem Measurable.lintegral_kernel_prod_left' {f : β × α → ℝ≥0∞} (hf : Measurable f) :
@@ -224,10 +214,8 @@ theorem Measurable.lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf
 #align measurable.lintegral_kernel_prod_left Measurable.lintegral_kernel_prod_left
 
 theorem Measurable.set_lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf : Measurable (uncurry f))
-    {s : Set β} (hs : MeasurableSet s) : Measurable fun b => ∫⁻ a in s, f a b ∂κ b :=
-  by
-  simp_rw [← lintegral_restrict κ hs]
-  exact hf.lintegral_kernel_prod_left
+    {s : Set β} (hs : MeasurableSet s) : Measurable fun b => ∫⁻ a in s, f a b ∂κ b := by
+  simp_rw [← lintegral_restrict κ hs]; exact hf.lintegral_kernel_prod_left
 #align measurable.set_lintegral_kernel_prod_left Measurable.set_lintegral_kernel_prod_left
 
 theorem Measurable.lintegral_kernel {f : β → ℝ≥0∞} (hf : Measurable f) :
@@ -273,16 +261,11 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
       { x | integrable (f x) (κ x) }.indicator fun x => (s' n x).integral (κ x)
     have hf' : ∀ n, strongly_measurable (f' n) :=
       by
-      intro n
-      refine' strongly_measurable.indicator _ (measurable_set_kernel_integrable hf)
+      intro n; refine' strongly_measurable.indicator _ (measurable_set_kernel_integrable hf)
       have : ∀ x, ((s' n x).range.filterₓ fun x => x ≠ 0) ⊆ (s n).range :=
         by
-        intro x
-        refine' Finset.Subset.trans (Finset.filter_subset _ _) _
-        intro y
-        simp_rw [simple_func.mem_range]
-        rintro ⟨z, rfl⟩
-        exact ⟨(x, z), rfl⟩
+        intro x; refine' Finset.Subset.trans (Finset.filter_subset _ _) _; intro y
+        simp_rw [simple_func.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩
       simp only [simple_func.integral_eq_sum_of_subset (this _)]
       refine' Finset.stronglyMeasurable_sum _ fun x _ => _
       refine' (Measurable.ennreal_toReal _).StronglyMeasurable.smul_const _
@@ -291,16 +274,12 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
       exact (s n).measurableSet_fiber x
     have h2f' : tendsto f' at_top (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) :=
       by
-      rw [tendsto_pi_nhds]
-      intro x
+      rw [tendsto_pi_nhds]; intro x
       by_cases hfx : integrable (f x) (κ x)
       · have : ∀ n, integrable (s' n x) (κ x) := by
-          intro n
-          apply (hfx.norm.add hfx.norm).mono' (s' n x).AEStronglyMeasurable
-          apply eventually_of_forall
-          intro y
-          simp_rw [s', simple_func.coe_comp]
-          exact simple_func.norm_approx_on_zero_le _ _ (x, y) n
+          intro n; apply (hfx.norm.add hfx.norm).mono' (s' n x).AEStronglyMeasurable
+          apply eventually_of_forall; intro y
+          simp_rw [s', simple_func.coe_comp]; exact simple_func.norm_approx_on_zero_le _ _ (x, y) n
         simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,
           mem_set_of_eq]
         refine'
@@ -317,9 +296,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
 #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
 
 theorem StronglyMeasurable.integral_kernel_prod_right' ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) :
-    StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x :=
-  by
-  rw [← uncurry_curry f] at hf
+    StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x := by rw [← uncurry_curry f] at hf;
   exact hf.integral_kernel_prod_right
 #align measure_theory.strongly_measurable.integral_kernel_prod_right' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right'
 
Diff
@@ -296,7 +296,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
       by_cases hfx : integrable (f x) (κ x)
       · have : ∀ n, integrable (s' n x) (κ x) := by
           intro n
-          apply (hfx.norm.add hfx.norm).mono' (s' n x).AeStronglyMeasurable
+          apply (hfx.norm.add hfx.norm).mono' (s' n x).AEStronglyMeasurable
           apply eventually_of_forall
           intro y
           simp_rw [s', simple_func.coe_comp]
@@ -305,7 +305,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
           mem_set_of_eq]
         refine'
           tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
-            (fun n => (s' n x).AeStronglyMeasurable) (hfx.norm.add hfx.norm) _ _
+            (fun n => (s' n x).AEStronglyMeasurable) (hfx.norm.add hfx.norm) _ _
         ·
           exact fun n =>
             eventually_of_forall fun y => simple_func.norm_approx_on_zero_le _ _ (x, y) n
Diff
@@ -104,7 +104,7 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
           Set.mem_empty_iff_false] using h_disj hij habi habj
       · exact fun i => (@measurable_prod_mk_left α β _ _ a) _ (hf_meas i)
     rw [h_tsum]
-    exact Measurable.eNNReal_tsum hf
+    exact Measurable.ennreal_tsum hf
 #align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.kernel.measurable_kernel_prod_mk_left_of_finite
 
 theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
@@ -114,7 +114,7 @@ theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
   have : ∀ a, kernel.sum (seq κ) a (Prod.mk a ⁻¹' t) = ∑' n, seq κ n a (Prod.mk a ⁻¹' t) := fun a =>
     kernel.sum_apply' _ _ (measurable_prod_mk_left ht)
   simp_rw [this]
-  refine' Measurable.eNNReal_tsum fun n => _
+  refine' Measurable.ennreal_tsum fun n => _
   exact measurable_kernel_prod_mk_left_of_finite ht inferInstance
 #align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.kernel.measurable_kernel_prod_mk_left
 
@@ -285,7 +285,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
         exact ⟨(x, z), rfl⟩
       simp only [simple_func.integral_eq_sum_of_subset (this _)]
       refine' Finset.stronglyMeasurable_sum _ fun x _ => _
-      refine' (Measurable.eNNReal_toReal _).StronglyMeasurable.smul_const _
+      refine' (Measurable.ennreal_toReal _).StronglyMeasurable.smul_const _
       simp (config := { singlePass := true }) only [simple_func.coe_comp, preimage_comp]
       apply measurable_kernel_prod_mk_left
       exact (s n).measurableSet_fiber x
Diff
@@ -168,7 +168,7 @@ theorem Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (h
     · exact fun n => (F n).Measurable.comp measurable_prod_mk_left
     · exact fun i j hij b => simple_func.monotone_eapprox (uncurry f) hij _
   simp_rw [this]
-  refine' measurable_supᵢ fun n => simple_func.induction _ _ (F n)
+  refine' measurable_iSup fun n => simple_func.induction _ _ (F n)
   · intro c t ht
     simp only [simple_func.const_zero, simple_func.coe_piecewise, simple_func.coe_const,
       simple_func.coe_zero, Set.piecewise_eq_indicator]
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 
 ! This file was ported from Lean 3 source module probability.kernel.measurable_integral
-! leanprover-community/mathlib commit 483dd86cfec4a1380d22b1f6acd4c3dc53f501ff
+! leanprover-community/mathlib commit 28b2a92f2996d28e580450863c130955de0ed398
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,68 +13,68 @@ import Mathbin.Probability.Kernel.Basic
 /-!
 # Measurability of the integral against a kernel
 
-The Lebesgue integral of a measurable function against a kernel is measurable.
+The Lebesgue integral of a measurable function against a kernel is measurable. The Bochner integral
+is strongly measurable.
 
 ## Main statements
 
-* `probability_theory.kernel.measurable_lintegral`: the function `a ↦ ∫⁻ b, f a b ∂(κ a)` is
-  measurable, for an s-finite kernel `κ : kernel α β` and a function `f : α → β → ℝ≥0∞` such that
-  `function.uncurry f` is measurable.
-
+* `measurable.lintegral_kernel_prod_right`: the function `a ↦ ∫⁻ b, f a b ∂(κ a)` is measurable,
+  for an s-finite kernel `κ : kernel α β` and a function `f : α → β → ℝ≥0∞` such that `uncurry f`
+  is measurable.
+* `measure_theory.strongly_measurable.integral_kernel_prod_right`: the function
+  `a ↦ ∫ b, f a b ∂(κ a)` is measurable, for an s-finite kernel `κ : kernel α β` and a function
+  `f : α → β → E` such that `uncurry f` is measurable.
 
 -/
 
 
-open MeasureTheory ProbabilityTheory
+open MeasureTheory ProbabilityTheory Function Set Filter
 
-open MeasureTheory ENNReal NNReal BigOperators
+open MeasureTheory ENNReal Topology
 
-namespace ProbabilityTheory.kernel
+variable {α β γ : Type _} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
+  {κ : kernel α β} {η : kernel (α × β) γ} {a : α}
 
-variable {α β ι : Type _} {mα : MeasurableSpace α} {mβ : MeasurableSpace β}
+namespace ProbabilityTheory
 
-include mα mβ
+namespace Kernel
 
-/-- This is an auxiliary lemma for `measurable_prod_mk_mem`. -/
-theorem measurable_prod_mk_mem_of_finite (κ : kernel α β) {t : Set (α × β)} (ht : MeasurableSet t)
-    (hκs : ∀ a, FiniteMeasure (κ a)) : Measurable fun a => κ a { b | (a, b) ∈ t } :=
+/-- This is an auxiliary lemma for `measurable_kernel_prod_mk_left`. -/
+theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : MeasurableSet t)
+    (hκs : ∀ a, FiniteMeasure (κ a)) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
   by
   -- `t` is a measurable set in the product `α × β`: we use that the product σ-algebra is generated
   -- by boxes to prove the result by induction.
   refine' MeasurableSpace.induction_on_inter generate_from_prod.symm isPiSystem_prod _ _ _ _ ht
   ·-- case `t = ∅`
-    simp only [Set.mem_empty_iff_false, Set.setOf_false, measure_empty, measurable_const]
+    simp only [preimage_empty, measure_empty, measurable_const]
   · -- case of a box: `t = t₁ ×ˢ t₂` for measurable sets `t₁` and `t₂`
     intro t' ht'
     simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht'
     obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht'
-    simp only [Set.prod_mk_mem_set_prod_eq]
     classical
-      have h_eq_ite :
-        (fun a => κ a { b : β | a ∈ t₁ ∧ b ∈ t₂ }) = fun a => ite (a ∈ t₁) (κ a t₂) 0 :=
+      simp_rw [mk_preimage_prod_right_eq_if]
+      have h_eq_ite : (fun a => κ a (ite (a ∈ t₁) t₂ ∅)) = fun a => ite (a ∈ t₁) (κ a t₂) 0 :=
         by
         ext1 a
         split_ifs
-        · simp only [h, true_and_iff]
-          rfl
-        · simp only [h, false_and_iff, Set.setOf_false, Set.inter_empty, measure_empty]
+        exacts[rfl, measure_empty]
       rw [h_eq_ite]
       exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const
   · -- we assume that the result is true for `t` and we prove it for `tᶜ`
     intro t' ht' h_meas
-    have h_eq_sdiff : ∀ a, { b : β | (a, b) ∈ t'ᶜ } = Set.univ \ { b : β | (a, b) ∈ t' } :=
+    have h_eq_sdiff : ∀ a, Prod.mk a ⁻¹' t'ᶜ = Set.univ \ Prod.mk a ⁻¹' t' :=
       by
       intro a
       ext1 b
-      simp only [Set.mem_compl_iff, Set.mem_setOf_eq, Set.mem_diff, Set.mem_univ, true_and_iff]
+      simp only [mem_compl_iff, mem_preimage, mem_diff, mem_univ, true_and_iff]
     simp_rw [h_eq_sdiff]
     have :
-      (fun a => κ a (Set.univ \ { b : β | (a, b) ∈ t' })) = fun a =>
-        κ a Set.univ - κ a { b : β | (a, b) ∈ t' } :=
+      (fun a => κ a (Set.univ \ Prod.mk a ⁻¹' t')) = fun a =>
+        κ a Set.univ - κ a (Prod.mk a ⁻¹' t') :=
       by
       ext1 a
-      rw [← Set.diff_inter_self_eq_diff, Set.inter_univ, measure_diff]
-      · exact Set.subset_univ _
+      rw [← Set.diff_inter_self_eq_diff, Set.inter_univ, measure_diff (Set.subset_univ _)]
       · exact (@measurable_prod_mk_left α β _ _ a) t' ht'
       · exact measure_ne_top _ _
     rw [this]
@@ -82,16 +82,14 @@ theorem measurable_prod_mk_mem_of_finite (κ : kernel α β) {t : Set (α × β)
   · -- we assume that the result is true for a family of disjoint sets and prove it for their union
     intro f h_disj hf_meas hf
     have h_Union :
-      (fun a => κ a { b : β | (a, b) ∈ ⋃ i, f i }) = fun a => κ a (⋃ i, { b : β | (a, b) ∈ f i }) :=
+      (fun a => κ a (Prod.mk a ⁻¹' ⋃ i, f i)) = fun a => κ a (⋃ i, Prod.mk a ⁻¹' f i) :=
       by
       ext1 a
       congr with b
-      simp only [Set.mem_unionᵢ, Set.supᵢ_eq_unionᵢ, Set.mem_setOf_eq]
-      rfl
+      simp only [mem_Union, mem_preimage]
     rw [h_Union]
     have h_tsum :
-      (fun a => κ a (⋃ i, { b : β | (a, b) ∈ f i })) = fun a =>
-        ∑' i, κ a { b : β | (a, b) ∈ f i } :=
+      (fun a => κ a (⋃ i, Prod.mk a ⁻¹' f i)) = fun a => ∑' i, κ a (Prod.mk a ⁻¹' f i) :=
       by
       ext1 a
       rw [measure_Union]
@@ -107,51 +105,74 @@ theorem measurable_prod_mk_mem_of_finite (κ : kernel α β) {t : Set (α × β)
       · exact fun i => (@measurable_prod_mk_left α β _ _ a) _ (hf_meas i)
     rw [h_tsum]
     exact Measurable.eNNReal_tsum hf
-#align probability_theory.kernel.measurable_prod_mk_mem_of_finite ProbabilityTheory.kernel.measurable_prod_mk_mem_of_finite
+#align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.kernel.measurable_kernel_prod_mk_left_of_finite
 
-theorem measurable_prod_mk_mem (κ : kernel α β) [IsSFiniteKernel κ] {t : Set (α × β)}
-    (ht : MeasurableSet t) : Measurable fun a => κ a { b | (a, b) ∈ t } :=
+theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
+    (ht : MeasurableSet t) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) :=
   by
   rw [← kernel_sum_seq κ]
-  have :
-    ∀ a, kernel.sum (seq κ) a { b : β | (a, b) ∈ t } = ∑' n, seq κ n a { b : β | (a, b) ∈ t } :=
-    fun a => kernel.sum_apply' _ _ (measurable_prod_mk_left ht)
+  have : ∀ a, kernel.sum (seq κ) a (Prod.mk a ⁻¹' t) = ∑' n, seq κ n a (Prod.mk a ⁻¹' t) := fun a =>
+    kernel.sum_apply' _ _ (measurable_prod_mk_left ht)
   simp_rw [this]
   refine' Measurable.eNNReal_tsum fun n => _
-  exact measurable_prod_mk_mem_of_finite (seq κ n) ht inferInstance
-#align probability_theory.kernel.measurable_prod_mk_mem ProbabilityTheory.kernel.measurable_prod_mk_mem
+  exact measurable_kernel_prod_mk_left_of_finite ht inferInstance
+#align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.kernel.measurable_kernel_prod_mk_left
+
+theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)} (hs : MeasurableSet s)
+    (a : α) : Measurable fun b => η (a, b) (Prod.mk b ⁻¹' s) :=
+  by
+  have : ∀ b, Prod.mk b ⁻¹' s = { c | ((a, b), c) ∈ { p : (α × β) × γ | (p.1.2, p.2) ∈ s } } :=
+    by
+    intro b
+    rfl
+  simp_rw [this]
+  refine' (measurable_kernel_prod_mk_left _).comp measurable_prod_mk_left
+  exact (measurable_fst.snd.prod_mk measurable_snd) hs
+#align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.kernel.measurable_kernel_prod_mk_left'
+
+theorem measurable_kernel_prod_mk_right [IsSFiniteKernel κ] {s : Set (β × α)}
+    (hs : MeasurableSet s) : Measurable fun y => κ y ((fun x => (x, y)) ⁻¹' s) :=
+  measurable_kernel_prod_mk_left (measurableSet_swap_iff.mpr hs)
+#align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.kernel.measurable_kernel_prod_mk_right
+
+end Kernel
+
+open ProbabilityTheory.kernel
+
+section Lintegral
+
+variable [IsSFiniteKernel κ] [IsSFiniteKernel η]
 
-theorem measurable_lintegral_indicator_const (κ : kernel α β) [IsSFiniteKernel κ] {t : Set (α × β)}
-    (ht : MeasurableSet t) (c : ℝ≥0∞) :
-    Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a :=
+/-- Auxiliary lemma for `measurable.lintegral_kernel_prod_right`. -/
+theorem kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
+    (c : ℝ≥0∞) : Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a :=
   by
   simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]
-  exact Measurable.const_mul (measurable_prod_mk_mem _ ht) c
+  exact Measurable.const_mul (measurable_kernel_prod_mk_left ht) c
 #align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.kernel.measurable_lintegral_indicator_const
 
 /-- For an s-finite kernel `κ` and a function `f : α → β → ℝ≥0∞` which is measurable when seen as a
-map from `α × β` (hypothesis `measurable (function.uncurry f)`), the integral
-`a ↦ ∫⁻ b, f a b ∂(κ a)` is measurable. -/
-theorem measurable_lintegral (κ : kernel α β) [IsSFiniteKernel κ] {f : α → β → ℝ≥0∞}
-    (hf : Measurable (Function.uncurry f)) : Measurable fun a => ∫⁻ b, f a b ∂κ a :=
+map from `α × β` (hypothesis `measurable (uncurry f)`), the integral `a ↦ ∫⁻ b, f a b ∂(κ a)` is
+measurable. -/
+theorem Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f)) :
+    Measurable fun a => ∫⁻ b, f a b ∂κ a :=
   by
-  let F : ℕ → simple_func (α × β) ℝ≥0∞ := simple_func.eapprox (Function.uncurry f)
-  have h : ∀ a, (⨆ n, F n a) = Function.uncurry f a :=
-    simple_func.supr_eapprox_apply (Function.uncurry f) hf
-  simp only [Prod.forall, Function.uncurry_apply_pair] at h
+  let F : ℕ → simple_func (α × β) ℝ≥0∞ := simple_func.eapprox (uncurry f)
+  have h : ∀ a, (⨆ n, F n a) = uncurry f a := simple_func.supr_eapprox_apply (uncurry f) hf
+  simp only [Prod.forall, uncurry_apply_pair] at h
   simp_rw [← h]
   have : ∀ a, (∫⁻ b, ⨆ n, F n (a, b) ∂κ a) = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a :=
     by
     intro a
     rw [lintegral_supr]
     · exact fun n => (F n).Measurable.comp measurable_prod_mk_left
-    · exact fun i j hij b => simple_func.monotone_eapprox (Function.uncurry f) hij _
+    · exact fun i j hij b => simple_func.monotone_eapprox (uncurry f) hij _
   simp_rw [this]
   refine' measurable_supᵢ fun n => simple_func.induction _ _ (F n)
   · intro c t ht
     simp only [simple_func.const_zero, simple_func.coe_piecewise, simple_func.coe_const,
       simple_func.coe_zero, Set.piecewise_eq_indicator]
-    exact measurable_lintegral_indicator_const κ ht c
+    exact kernel.measurable_lintegral_indicator_const ht c
   · intro g₁ g₂ h_disj hm₁ hm₂
     simp only [simple_func.coe_add, Pi.add_apply]
     have h_add :
@@ -162,26 +183,177 @@ theorem measurable_lintegral (κ : kernel α β) [IsSFiniteKernel κ] {f : α 
       rw [Pi.add_apply, lintegral_add_left (g₁.measurable.comp measurable_prod_mk_left)]
     rw [h_add]
     exact Measurable.add hm₁ hm₂
-#align probability_theory.kernel.measurable_lintegral ProbabilityTheory.kernel.measurable_lintegral
+#align measurable.lintegral_kernel_prod_right Measurable.lintegral_kernel_prod_right
 
-theorem measurable_lintegral' (κ : kernel α β) [IsSFiniteKernel κ] {f : β → ℝ≥0∞}
-    (hf : Measurable f) : Measurable fun a => ∫⁻ b, f b ∂κ a :=
-  measurable_lintegral κ (hf.comp measurable_snd)
-#align probability_theory.kernel.measurable_lintegral' ProbabilityTheory.kernel.measurable_lintegral'
+theorem Measurable.lintegral_kernel_prod_right' {f : α × β → ℝ≥0∞} (hf : Measurable f) :
+    Measurable fun a => ∫⁻ b, f (a, b) ∂κ a :=
+  by
+  refine' Measurable.lintegral_kernel_prod_right _
+  have : (uncurry fun (a : α) (b : β) => f (a, b)) = f :=
+    by
+    ext x
+    rw [← @Prod.mk.eta _ _ x, uncurry_apply_pair]
+  rwa [this]
+#align measurable.lintegral_kernel_prod_right' Measurable.lintegral_kernel_prod_right'
+
+theorem Measurable.lintegral_kernel_prod_right'' {f : β × γ → ℝ≥0∞} (hf : Measurable f) :
+    Measurable fun x => ∫⁻ y, f (x, y) ∂η (a, x) :=
+  by
+  change
+    Measurable
+      ((fun x => ∫⁻ y, (fun u : (α × β) × γ => f (u.1.2, u.2)) (x, y) ∂η x) ∘ fun x => (a, x))
+  refine' (Measurable.lintegral_kernel_prod_right' _).comp measurable_prod_mk_left
+  exact hf.comp (measurable_fst.snd.prod_mk measurable_snd)
+#align measurable.lintegral_kernel_prod_right'' Measurable.lintegral_kernel_prod_right''
+
+theorem Measurable.set_lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f))
+    {s : Set β} (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f a b ∂κ a :=
+  by
+  simp_rw [← lintegral_restrict κ hs]
+  exact hf.lintegral_kernel_prod_right
+#align measurable.set_lintegral_kernel_prod_right Measurable.set_lintegral_kernel_prod_right
+
+theorem Measurable.lintegral_kernel_prod_left' {f : β × α → ℝ≥0∞} (hf : Measurable f) :
+    Measurable fun y => ∫⁻ x, f (x, y) ∂κ y :=
+  (measurable_swap_iff.mpr hf).lintegral_kernel_prod_right'
+#align measurable.lintegral_kernel_prod_left' Measurable.lintegral_kernel_prod_left'
 
-theorem measurableSet_lintegral (κ : kernel α β) [IsSFiniteKernel κ] {f : α → β → ℝ≥0∞}
-    (hf : Measurable (Function.uncurry f)) {s : Set β} (hs : MeasurableSet s) :
-    Measurable fun a => ∫⁻ b in s, f a b ∂κ a :=
+theorem Measurable.lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf : Measurable (uncurry f)) :
+    Measurable fun y => ∫⁻ x, f x y ∂κ y :=
+  hf.lintegral_kernel_prod_left'
+#align measurable.lintegral_kernel_prod_left Measurable.lintegral_kernel_prod_left
+
+theorem Measurable.set_lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf : Measurable (uncurry f))
+    {s : Set β} (hs : MeasurableSet s) : Measurable fun b => ∫⁻ a in s, f a b ∂κ b :=
   by
   simp_rw [← lintegral_restrict κ hs]
-  exact measurable_lintegral _ hf
-#align probability_theory.kernel.measurable_set_lintegral ProbabilityTheory.kernel.measurableSet_lintegral
+  exact hf.lintegral_kernel_prod_left
+#align measurable.set_lintegral_kernel_prod_left Measurable.set_lintegral_kernel_prod_left
+
+theorem Measurable.lintegral_kernel {f : β → ℝ≥0∞} (hf : Measurable f) :
+    Measurable fun a => ∫⁻ b, f b ∂κ a :=
+  Measurable.lintegral_kernel_prod_right (hf.comp measurable_snd)
+#align measurable.lintegral_kernel Measurable.lintegral_kernel
 
-theorem measurableSet_lintegral' (κ : kernel α β) [IsSFiniteKernel κ] {f : β → ℝ≥0∞}
-    (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
-    Measurable fun a => ∫⁻ b in s, f b ∂κ a :=
-  measurableSet_lintegral κ (hf.comp measurable_snd) hs
-#align probability_theory.kernel.measurable_set_lintegral' ProbabilityTheory.kernel.measurableSet_lintegral'
+theorem Measurable.set_lintegral_kernel {f : β → ℝ≥0∞} (hf : Measurable f) {s : Set β}
+    (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f b ∂κ a :=
+  Measurable.set_lintegral_kernel_prod_right (hf.comp measurable_snd) hs
+#align measurable.set_lintegral_kernel Measurable.set_lintegral_kernel
+
+end Lintegral
+
+variable {E : Type _} [NormedAddCommGroup E] [IsSFiniteKernel κ] [IsSFiniteKernel η]
+
+theorem measurableSet_kernel_integrable ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) :
+    MeasurableSet { x | Integrable (f x) (κ x) } :=
+  by
+  simp_rw [integrable, hf.of_uncurry_left.ae_strongly_measurable, true_and_iff]
+  exact measurableSet_lt (Measurable.lintegral_kernel_prod_right hf.ennnorm) measurable_const
+#align probability_theory.measurable_set_kernel_integrable ProbabilityTheory.measurableSet_kernel_integrable
+
+end ProbabilityTheory
+
+open ProbabilityTheory ProbabilityTheory.kernel
+
+namespace MeasureTheory
+
+variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [IsSFiniteKernel κ]
+  [IsSFiniteKernel η]
+
+theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
+    (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by
+  classical
+    borelize E
+    haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) :=
+      hf.separable_space_range_union_singleton
+    let s : ℕ → simple_func (α × β) E :=
+      simple_func.approx_on _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp)
+    let s' : ℕ → α → simple_func β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left
+    let f' : ℕ → α → E := fun n =>
+      { x | integrable (f x) (κ x) }.indicator fun x => (s' n x).integral (κ x)
+    have hf' : ∀ n, strongly_measurable (f' n) :=
+      by
+      intro n
+      refine' strongly_measurable.indicator _ (measurable_set_kernel_integrable hf)
+      have : ∀ x, ((s' n x).range.filterₓ fun x => x ≠ 0) ⊆ (s n).range :=
+        by
+        intro x
+        refine' Finset.Subset.trans (Finset.filter_subset _ _) _
+        intro y
+        simp_rw [simple_func.mem_range]
+        rintro ⟨z, rfl⟩
+        exact ⟨(x, z), rfl⟩
+      simp only [simple_func.integral_eq_sum_of_subset (this _)]
+      refine' Finset.stronglyMeasurable_sum _ fun x _ => _
+      refine' (Measurable.eNNReal_toReal _).StronglyMeasurable.smul_const _
+      simp (config := { singlePass := true }) only [simple_func.coe_comp, preimage_comp]
+      apply measurable_kernel_prod_mk_left
+      exact (s n).measurableSet_fiber x
+    have h2f' : tendsto f' at_top (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) :=
+      by
+      rw [tendsto_pi_nhds]
+      intro x
+      by_cases hfx : integrable (f x) (κ x)
+      · have : ∀ n, integrable (s' n x) (κ x) := by
+          intro n
+          apply (hfx.norm.add hfx.norm).mono' (s' n x).AeStronglyMeasurable
+          apply eventually_of_forall
+          intro y
+          simp_rw [s', simple_func.coe_comp]
+          exact simple_func.norm_approx_on_zero_le _ _ (x, y) n
+        simp only [f', hfx, simple_func.integral_eq_integral _ (this _), indicator_of_mem,
+          mem_set_of_eq]
+        refine'
+          tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
+            (fun n => (s' n x).AeStronglyMeasurable) (hfx.norm.add hfx.norm) _ _
+        ·
+          exact fun n =>
+            eventually_of_forall fun y => simple_func.norm_approx_on_zero_le _ _ (x, y) n
+        · refine' eventually_of_forall fun y => simple_func.tendsto_approx_on _ _ _
+          apply subset_closure
+          simp [-uncurry_apply_pair]
+      · simp [f', hfx, integral_undef]
+    exact stronglyMeasurable_of_tendsto _ hf' h2f'
+#align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
+
+theorem StronglyMeasurable.integral_kernel_prod_right' ⦃f : α × β → E⦄ (hf : StronglyMeasurable f) :
+    StronglyMeasurable fun x => ∫ y, f (x, y) ∂κ x :=
+  by
+  rw [← uncurry_curry f] at hf
+  exact hf.integral_kernel_prod_right
+#align measure_theory.strongly_measurable.integral_kernel_prod_right' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right'
+
+theorem StronglyMeasurable.integral_kernel_prod_right'' {f : β × γ → E}
+    (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ∫ y, f (x, y) ∂η (a, x) :=
+  by
+  change
+    strongly_measurable
+      ((fun x => ∫ y, (fun u : (α × β) × γ => f (u.1.2, u.2)) (x, y) ∂η x) ∘ fun x => (a, x))
+  refine' strongly_measurable.comp_measurable _ measurable_prod_mk_left
+  refine' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right' _
+  exact hf.comp_measurable (measurable_fst.snd.prod_mk measurable_snd)
+#align measure_theory.strongly_measurable.integral_kernel_prod_right'' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right''
+
+theorem StronglyMeasurable.integral_kernel_prod_left ⦃f : β → α → E⦄
+    (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun y => ∫ x, f x y ∂κ y :=
+  (hf.comp_measurable measurable_swap).integral_kernel_prod_right'
+#align measure_theory.strongly_measurable.integral_kernel_prod_left MeasureTheory.StronglyMeasurable.integral_kernel_prod_left
+
+theorem StronglyMeasurable.integral_kernel_prod_left' ⦃f : β × α → E⦄ (hf : StronglyMeasurable f) :
+    StronglyMeasurable fun y => ∫ x, f (x, y) ∂κ y :=
+  (hf.comp_measurable measurable_swap).integral_kernel_prod_right'
+#align measure_theory.strongly_measurable.integral_kernel_prod_left' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left'
+
+theorem StronglyMeasurable.integral_kernel_prod_left'' {f : γ × β → E} (hf : StronglyMeasurable f) :
+    StronglyMeasurable fun y => ∫ x, f (x, y) ∂η (a, y) :=
+  by
+  change
+    strongly_measurable
+      ((fun y => ∫ x, (fun u : γ × α × β => f (u.1, u.2.2)) (x, y) ∂η y) ∘ fun x => (a, x))
+  refine' strongly_measurable.comp_measurable _ measurable_prod_mk_left
+  refine' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left' _
+  exact hf.comp_measurable (measurable_fst.prod_mk measurable_snd.snd)
+#align measure_theory.strongly_measurable.integral_kernel_prod_left'' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left''
 
-end ProbabilityTheory.kernel
+end MeasureTheory
 
Diff
@@ -37,7 +37,7 @@ include mα mβ
 
 /-- This is an auxiliary lemma for `measurable_prod_mk_mem`. -/
 theorem measurable_prod_mk_mem_of_finite (κ : kernel α β) {t : Set (α × β)} (ht : MeasurableSet t)
-    (hκs : ∀ a, IsFiniteMeasure (κ a)) : Measurable fun a => κ a { b | (a, b) ∈ t } :=
+    (hκs : ∀ a, FiniteMeasure (κ a)) : Measurable fun a => κ a { b | (a, b) ∈ t } :=
   by
   -- `t` is a measurable set in the product `α × β`: we use that the product σ-algebra is generated
   -- by boxes to prove the result by induction.

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 1 (#12338)

A PR accompanying #12339.

Zulip discussion

Diff
@@ -321,9 +321,9 @@ theorem StronglyMeasurable.integral_kernel_prod_right'' {f : β × γ → E}
   -- Porting note: was (`Function.comp` reducibility)
   -- refine' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right' _
   -- exact hf.comp_measurable (measurable_fst.snd.prod_mk measurable_snd)
-  have := MeasureTheory.StronglyMeasurable.integral_kernel_prod_right' (κ := η)
-    (hf.comp_measurable (measurable_fst.snd.prod_mk measurable_snd))
-  simpa using this
+  · have := MeasureTheory.StronglyMeasurable.integral_kernel_prod_right' (κ := η)
+      (hf.comp_measurable (measurable_fst.snd.prod_mk measurable_snd))
+    simpa using this
 #align measure_theory.strongly_measurable.integral_kernel_prod_right'' MeasureTheory.StronglyMeasurable.integral_kernel_prod_right''
 
 theorem StronglyMeasurable.integral_kernel_prod_left ⦃f : β → α → E⦄
@@ -345,9 +345,9 @@ theorem StronglyMeasurable.integral_kernel_prod_left'' {f : γ × β → E} (hf
   -- Porting note: was (`Function.comp` reducibility)
   -- refine' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left' _
   -- exact hf.comp_measurable (measurable_fst.prod_mk measurable_snd.snd)
-  have := MeasureTheory.StronglyMeasurable.integral_kernel_prod_left' (κ := η)
-    (hf.comp_measurable (measurable_fst.prod_mk measurable_snd.snd))
-  simpa using this
+  · have := MeasureTheory.StronglyMeasurable.integral_kernel_prod_left' (κ := η)
+      (hf.comp_measurable (measurable_fst.prod_mk measurable_snd.snd))
+    simpa using this
 #align measure_theory.strongly_measurable.integral_kernel_prod_left'' MeasureTheory.StronglyMeasurable.integral_kernel_prod_left''
 
 end MeasureTheory
feat(Probability/Kernel): disintegration of finite kernels (#10603)

Let κ : kernel α (β × Ω) be a finite kernel, where Ω is a standard Borel space. Then if α is countable or β has a countably generated σ-algebra (for example if it is standard Borel), then there exists a kernel (α × β) Ω called conditional kernel and denoted by condKernel κ such that κ = fst κ ⊗ₖ condKernel κ.

Properties of integrals involving condKernel are collated in the file Integral.lean. The conditional kernel is unique (almost everywhere w.r.t. fst κ): this is proved in the file Unique.lean.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Rémy Degenne <remydegenne@gmail.com>

Diff
@@ -253,12 +253,14 @@ open ProbabilityTheory ProbabilityTheory.kernel
 
 namespace MeasureTheory
 
-variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [IsSFiniteKernel κ]
+variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [IsSFiniteKernel κ]
   [IsSFiniteKernel η]
 
 theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by
   classical
+  by_cases hE : CompleteSpace E; swap
+  · simp [integral, hE, stronglyMeasurable_const]
   borelize E
   haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) :=
     hf.separableSpace_range_union_singleton
chore: superfluous parentheses part 2 (#12131)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -234,7 +234,7 @@ theorem _root_.Measurable.set_lintegral_kernel {f : β → ℝ≥0∞} (hf : Mea
     (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f b ∂κ a := by
   -- Porting note: was term mode proof (`Function.comp` reducibility)
   refine Measurable.set_lintegral_kernel_prod_right ?_ hs
-  convert (hf.comp measurable_snd)
+  convert hf.comp measurable_snd
 #align measurable.set_lintegral_kernel Measurable.set_lintegral_kernel
 
 end Lintegral
chore: golf using filter_upwards (#11208)

This is presumably not exhaustive, but covers about a hundred instances.

Style opinions (e.g., why a particular change is great/not a good idea) are very welcome; I'm still forming my own.

Diff
@@ -281,9 +281,9 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
   have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) := by
     rw [tendsto_pi_nhds]; intro x
     by_cases hfx : Integrable (f x) (κ x)
-    · have : ∀ n, Integrable (s' n x) (κ x) := by
-        intro n; apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable
-        apply eventually_of_forall; intro y
+    · have (n) : Integrable (s' n x) (κ x) := by
+        apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable
+        filter_upwards with y
         simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n
       simp only [f',  hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem,
         mem_setOf_eq]
chore: move Mathlib to v4.7.0-rc1 (#11162)

This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0 branch as we update to intermediate nightlies.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>

Diff
@@ -275,7 +275,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     simp only [SimpleFunc.integral_eq_sum_of_subset (this _)]
     refine' Finset.stronglyMeasurable_sum _ fun x _ => _
     refine' (Measurable.ennreal_toReal _).stronglyMeasurable.smul_const _
-    simp only [SimpleFunc.coe_comp, preimage_comp]
+    simp only [s', SimpleFunc.coe_comp, preimage_comp]
     apply kernel.measurable_kernel_prod_mk_left
     exact (s n).measurableSet_fiber x
   have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) := by
@@ -284,8 +284,8 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     · have : ∀ n, Integrable (s' n x) (κ x) := by
         intro n; apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable
         apply eventually_of_forall; intro y
-        simp_rw [SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n
-      simp only [ hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem,
+        simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n
+      simp only [f',  hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem,
         mem_setOf_eq]
       refine'
         tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
@@ -300,7 +300,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
         refine' eventually_of_forall fun y => SimpleFunc.tendsto_approxOn hf.measurable (by simp) _
         apply subset_closure
         simp [-uncurry_apply_pair]
-    · simp [hfx, integral_undef]
+    · simp [f', hfx, integral_undef]
   exact stronglyMeasurable_of_tendsto _ hf' h2f'
 #align measure_theory.strongly_measurable.integral_kernel_prod_right MeasureTheory.StronglyMeasurable.integral_kernel_prod_right
 
refactor: move material about the Dominated Convergence Theorem into one file (#11139)

Suggested by @loefflerd. Only code motion (and cosmetic adaptions, such as minimising import and open statements).

Pre-requisite for #11108 and (morally) #11110.

Diff
@@ -5,6 +5,7 @@ Authors: Rémy Degenne
 -/
 import Mathlib.Probability.Kernel.Basic
 import Mathlib.MeasureTheory.Constructions.Prod.Basic
+import Mathlib.MeasureTheory.Integral.DominatedConvergence
 
 #align_import probability.kernel.measurable_integral from "leanprover-community/mathlib"@"28b2a92f2996d28e580450863c130955de0ed398"
 
chore: classify was rw porting notes (#10692)

Classifies by adding issue number (#10691) to porting notes claiming was rw.

Diff
@@ -175,7 +175,7 @@ theorem _root_.Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0
         (fun a => ∫⁻ b, g₁ (a, b) ∂κ a) + fun a => ∫⁻ b, g₂ (a, b) ∂κ a := by
       ext1 a
       rw [Pi.add_apply]
-      -- Porting note: was `rw` (`Function.comp` reducibility)
+      -- Porting note (#10691): was `rw` (`Function.comp` reducibility)
       erw [lintegral_add_left (g₁.measurable.comp measurable_prod_mk_left)]
       simp_rw [Function.comp_apply]
     rw [h_add]
chore: cleanup use of simp singlePass option (#9928)

Of the 18 uses of singlePass, in 3 cases we can just use rw, in 4 cases it isn't needed at all.

In the other 11 cases we are always use it as simp (config := {singlePass := true}) only [X] (i.e. with just a single simp lemma), and that simp call would loop forever (usually failing with a maxRecDepth error, sometimes with heartbeats). I've left these as is.

There's also one case where there was a missing only.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -274,7 +274,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     simp only [SimpleFunc.integral_eq_sum_of_subset (this _)]
     refine' Finset.stronglyMeasurable_sum _ fun x _ => _
     refine' (Measurable.ennreal_toReal _).stronglyMeasurable.smul_const _
-    simp (config := { singlePass := true }) only [SimpleFunc.coe_comp, preimage_comp]
+    simp only [SimpleFunc.coe_comp, preimage_comp]
     apply kernel.measurable_kernel_prod_mk_left
     exact (s n).measurableSet_fiber x
   have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) := by
chore: reduce imports (#9830)

This uses the improved shake script from #9772 to reduce imports across mathlib. The corresponding noshake.json file has been added to #9772.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 -/
 import Mathlib.Probability.Kernel.Basic
+import Mathlib.MeasureTheory.Constructions.Prod.Basic
 
 #align_import probability.kernel.measurable_integral from "leanprover-community/mathlib"@"28b2a92f2996d28e580450863c130955de0ed398"
 
chore: cleanup Mathlib.Init.Data.Prod (#6972)

Removing from Mathlib.Init.Data.Prod from the early parts of the import hierarchy.

While at it, remove unnecessary uses of Prod.mk.eta across the library.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -185,7 +185,7 @@ theorem _root_.Measurable.lintegral_kernel_prod_right' {f : α × β → ℝ≥0
     Measurable fun a => ∫⁻ b, f (a, b) ∂κ a := by
   refine' Measurable.lintegral_kernel_prod_right _
   have : (uncurry fun (a : α) (b : β) => f (a, b)) = f := by
-    ext x; rw [← @Prod.mk.eta _ _ x, uncurry_apply_pair]
+    ext x; rw [uncurry_apply_pair]
   rwa [this]
 #align measurable.lintegral_kernel_prod_right' Measurable.lintegral_kernel_prod_right'
 
chore: remove unused simps (#6632)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -133,8 +133,9 @@ variable [IsSFiniteKernel κ] [IsSFiniteKernel η]
 /-- Auxiliary lemma for `Measurable.lintegral_kernel_prod_right`. -/
 theorem kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
     (c : ℝ≥0∞) : Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a := by
-  simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]
-  -- Porting note: `simp_rw` doesn't take, added the `conv` below
+  -- Porting note: was originally by
+  -- `simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]`
+  -- but this has no effect, so added the `conv` below
   conv =>
     congr
     ext
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -29,7 +29,7 @@ open MeasureTheory ProbabilityTheory Function Set Filter
 
 open scoped MeasureTheory ENNReal Topology
 
-variable {α β γ : Type _} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
+variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
   {κ : kernel α β} {η : kernel (α × β) γ} {a : α}
 
 namespace ProbabilityTheory
@@ -236,7 +236,7 @@ theorem _root_.Measurable.set_lintegral_kernel {f : β → ℝ≥0∞} (hf : Mea
 
 end Lintegral
 
-variable {E : Type _} [NormedAddCommGroup E] [IsSFiniteKernel κ] [IsSFiniteKernel η]
+variable {E : Type*} [NormedAddCommGroup E] [IsSFiniteKernel κ] [IsSFiniteKernel η]
 
 theorem measurableSet_kernel_integrable ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) :
     MeasurableSet {x | Integrable (f x) (κ x)} := by
@@ -250,7 +250,7 @@ open ProbabilityTheory ProbabilityTheory.kernel
 
 namespace MeasureTheory
 
-variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [IsSFiniteKernel κ]
+variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [IsSFiniteKernel κ]
   [IsSFiniteKernel η]
 
 theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2023 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
-
-! This file was ported from Lean 3 source module probability.kernel.measurable_integral
-! leanprover-community/mathlib commit 28b2a92f2996d28e580450863c130955de0ed398
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Probability.Kernel.Basic
 
+#align_import probability.kernel.measurable_integral from "leanprover-community/mathlib"@"28b2a92f2996d28e580450863c130955de0ed398"
+
 /-!
 # Measurability of the integral against a kernel
 
fix: precedences of ⨆⋃⋂⨅ (#5614)
Diff
@@ -151,7 +151,7 @@ measurable. -/
 theorem _root_.Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞}
     (hf : Measurable (uncurry f)) : Measurable fun a => ∫⁻ b, f a b ∂κ a := by
   let F : ℕ → SimpleFunc (α × β) ℝ≥0∞ := SimpleFunc.eapprox (uncurry f)
-  have h : ∀ a, (⨆ n, F n a) = uncurry f a := SimpleFunc.iSup_eapprox_apply (uncurry f) hf
+  have h : ∀ a, ⨆ n, F n a = uncurry f a := SimpleFunc.iSup_eapprox_apply (uncurry f) hf
   simp only [Prod.forall, uncurry_apply_pair] at h
   simp_rw [← h]
   have : ∀ a, (∫⁻ b, ⨆ n, F n (a, b) ∂κ a) = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a := by
feat: port Probability.Kernel.Composition (#5044)

Co-authored-by: int-y1 <jason_yuen2007@hotmail.com>

Diff
@@ -37,7 +37,7 @@ variable {α β γ : Type _} {mα : MeasurableSpace α} {mβ : MeasurableSpace 
 
 namespace ProbabilityTheory
 
-namespace Kernel
+namespace kernel
 
 /-- This is an auxiliary lemma for `measurable_kernel_prod_mk_left`. -/
 theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : MeasurableSet t)
@@ -98,7 +98,7 @@ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : Meas
       · exact fun i => (@measurable_prod_mk_left α β _ _ a) (hf_meas i)
     rw [h_tsum]
     exact Measurable.ennreal_tsum hf
-#align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left_of_finite
+#align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.kernel.measurable_kernel_prod_mk_left_of_finite
 
 theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
     (ht : MeasurableSet t) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) := by
@@ -109,7 +109,7 @@ theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)}
   simp_rw [this]
   refine' Measurable.ennreal_tsum fun n => _
   exact measurable_kernel_prod_mk_left_of_finite ht inferInstance
-#align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left
+#align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.kernel.measurable_kernel_prod_mk_left
 
 theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)} (hs : MeasurableSet s)
     (a : α) : Measurable fun b => η (a, b) (Prod.mk b ⁻¹' s) := by
@@ -118,14 +118,14 @@ theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)
   simp_rw [this]
   refine' (measurable_kernel_prod_mk_left _).comp measurable_prod_mk_left
   exact (measurable_fst.snd.prod_mk measurable_snd) hs
-#align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.Kernel.measurable_kernel_prod_mk_left'
+#align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.kernel.measurable_kernel_prod_mk_left'
 
 theorem measurable_kernel_prod_mk_right [IsSFiniteKernel κ] {s : Set (β × α)}
     (hs : MeasurableSet s) : Measurable fun y => κ y ((fun x => (x, y)) ⁻¹' s) :=
   measurable_kernel_prod_mk_left (measurableSet_swap_iff.mpr hs)
-#align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.Kernel.measurable_kernel_prod_mk_right
+#align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.kernel.measurable_kernel_prod_mk_right
 
-end Kernel
+end kernel
 
 open ProbabilityTheory.kernel
 
@@ -134,7 +134,7 @@ section Lintegral
 variable [IsSFiniteKernel κ] [IsSFiniteKernel η]
 
 /-- Auxiliary lemma for `Measurable.lintegral_kernel_prod_right`. -/
-theorem Kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
+theorem kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t)
     (c : ℝ≥0∞) : Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a := by
   simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]
   -- Porting note: `simp_rw` doesn't take, added the `conv` below
@@ -143,7 +143,7 @@ theorem Kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : M
     ext
     erw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]
   exact Measurable.const_mul (measurable_kernel_prod_mk_left ht) c
-#align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.Kernel.measurable_lintegral_indicator_const
+#align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.kernel.measurable_lintegral_indicator_const
 
 /-- For an s-finite kernel `κ` and a function `f : α → β → ℝ≥0∞` which is measurable when seen as a
 map from `α × β` (hypothesis `Measurable (uncurry f)`), the integral `a ↦ ∫⁻ b, f a b ∂(κ a)` is
@@ -168,7 +168,7 @@ theorem _root_.Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0
   · intro c t ht
     simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const,
       SimpleFunc.coe_zero, Set.piecewise_eq_indicator]
-    exact Kernel.measurable_lintegral_indicator_const (κ := κ) ht c
+    exact kernel.measurable_lintegral_indicator_const (κ := κ) ht c
   · intro g₁ g₂ _ hm₁ hm₂
     simp only [SimpleFunc.coe_add, Pi.add_apply]
     have h_add :
@@ -276,7 +276,7 @@ theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄
     refine' Finset.stronglyMeasurable_sum _ fun x _ => _
     refine' (Measurable.ennreal_toReal _).stronglyMeasurable.smul_const _
     simp (config := { singlePass := true }) only [SimpleFunc.coe_comp, preimage_comp]
-    apply Kernel.measurable_kernel_prod_mk_left
+    apply kernel.measurable_kernel_prod_mk_left
     exact (s n).measurableSet_fiber x
   have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) := by
     rw [tendsto_pi_nhds]; intro x
feat: port Probability.Kernel.MeasurableIntegral (#4884)

Co-authored-by: Moritz Firsching <firsching@google.com> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com>

Dependencies 12 + 939

940 files ported (98.7%)
430383 lines ported (98.7%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file