probability.kernel.disintegrationMathlib.Probability.Kernel.Disintegration

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)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -536,8 +536,8 @@ theorem MeasureTheory.Measure.integral_condKernel {ρ : Measure (α × Ω)} [IsF
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print MeasureTheory.Measure.set_integral_condKernel /-
-theorem MeasureTheory.Measure.set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
+#print MeasureTheory.Measure.setIntegral_condKernel /-
+theorem MeasureTheory.Measure.setIntegral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
     {f : α × Ω → E} {s : Set α} (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t)
     (hf : IntegrableOn f (s ×ˢ t) ρ) :
     ∫ a in s, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ t, f x ∂ρ :=
@@ -546,29 +546,29 @@ theorem MeasureTheory.Measure.set_integral_condKernel {ρ : Measure (α × Ω)}
   rw [set_integral_comp_prod hs ht]
   · simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
   · rwa [measure_eq_comp_prod ρ] at hf
-#align probability_theory.set_integral_cond_kernel MeasureTheory.Measure.set_integral_condKernel
+#align probability_theory.set_integral_cond_kernel MeasureTheory.Measure.setIntegral_condKernel
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print MeasureTheory.Measure.set_integral_condKernel_univ_right /-
-theorem MeasureTheory.Measure.set_integral_condKernel_univ_right {ρ : Measure (α × Ω)}
+#print MeasureTheory.Measure.setIntegral_condKernel_univ_right /-
+theorem MeasureTheory.Measure.setIntegral_condKernel_univ_right {ρ : Measure (α × Ω)}
     [IsFiniteMeasure ρ] {f : α × Ω → E} {s : Set α} (hs : MeasurableSet s)
     (hf : IntegrableOn f (s ×ˢ univ) ρ) :
     ∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]; simp_rw [measure.restrict_univ]
-#align probability_theory.set_integral_cond_kernel_univ_right MeasureTheory.Measure.set_integral_condKernel_univ_right
+#align probability_theory.set_integral_cond_kernel_univ_right MeasureTheory.Measure.setIntegral_condKernel_univ_right
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print MeasureTheory.Measure.set_integral_condKernel_univ_left /-
-theorem MeasureTheory.Measure.set_integral_condKernel_univ_left {ρ : Measure (α × Ω)}
+#print MeasureTheory.Measure.setIntegral_condKernel_univ_left /-
+theorem MeasureTheory.Measure.setIntegral_condKernel_univ_left {ρ : Measure (α × Ω)}
     [IsFiniteMeasure ρ] {f : α × Ω → E} {t : Set Ω} (ht : MeasurableSet t)
     (hf : IntegrableOn f (univ ×ˢ t) ρ) :
     ∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]; simp_rw [measure.restrict_univ]
-#align probability_theory.set_integral_cond_kernel_univ_left MeasureTheory.Measure.set_integral_condKernel_univ_left
+#align probability_theory.set_integral_cond_kernel_univ_left MeasureTheory.Measure.setIntegral_condKernel_univ_left
 -/
 
 end IntegralCondKernel
Diff
@@ -62,7 +62,6 @@ section Real
 /-! ### Disintegration of measures on `α × ℝ` -/
 
 
-#print ProbabilityTheory.condKernelReal /-
 /-- Conditional measure on the second space of the product given the value on the first, as a
 kernel. Use the more general `cond_kernel`. -/
 noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ
@@ -70,43 +69,34 @@ noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ
   val a := (condCDF ρ a).Measure
   property := measurable_measure_condCDF ρ
 #align probability_theory.cond_kernel_real ProbabilityTheory.condKernelReal
--/
 
 instance (ρ : Measure (α × ℝ)) : IsMarkovKernel (condKernelReal ρ) :=
   ⟨fun a => by rw [cond_kernel_real]; infer_instance⟩
 
-#print ProbabilityTheory.condKernelReal_Iic /-
 theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
     condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCDF ρ a x) :=
   measure_condCDF_Iic ρ a x
 #align probability_theory.cond_kernel_real_Iic ProbabilityTheory.condKernelReal_Iic
--/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_lintegral_condKernelReal_Iic /-
 theorem set_lintegral_condKernelReal_Iic (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] (x : ℝ)
     {s : Set α} (hs : MeasurableSet s) :
     ∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst = ρ (s ×ˢ Iic x) := by
   simp_rw [cond_kernel_real_Iic]; exact set_lintegral_cond_cdf ρ x hs
 #align probability_theory.set_lintegral_cond_kernel_real_Iic ProbabilityTheory.set_lintegral_condKernelReal_Iic
--/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_lintegral_condKernelReal_univ /-
 theorem set_lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) {s : Set α} (hs : MeasurableSet s) :
     ∫⁻ a in s, condKernelReal ρ a univ ∂ρ.fst = ρ (s ×ˢ univ) := by
   simp only [measure_univ, lintegral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
     one_mul, measure.fst_apply hs, ← prod_univ]
 #align probability_theory.set_lintegral_cond_kernel_real_univ ProbabilityTheory.set_lintegral_condKernelReal_univ
--/
 
-#print ProbabilityTheory.lintegral_condKernelReal_univ /-
 theorem lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) :
     ∫⁻ a, condKernelReal ρ a univ ∂ρ.fst = ρ univ := by
   rw [← set_lintegral_univ, set_lintegral_cond_kernel_real_univ ρ MeasurableSet.univ,
     univ_prod_univ]
 #align probability_theory.lintegral_cond_kernel_real_univ ProbabilityTheory.lintegral_condKernelReal_univ
--/
 
 variable (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
 
@@ -114,7 +104,6 @@ variable (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_lintegral_condKernelReal_prod /-
 theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t : Set ℝ}
     (ht : MeasurableSet t) : ∫⁻ a in s, condKernelReal ρ a t ∂ρ.fst = ρ (s ×ˢ t) :=
   by
@@ -154,13 +143,11 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
       exact Or.inr (hf_disj hij)
     · exact fun i => MeasurableSet.prod hs (hf_meas i)
 #align probability_theory.set_lintegral_cond_kernel_real_prod ProbabilityTheory.set_lintegral_condKernelReal_prod
--/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.lintegral_condKernelReal_mem /-
 theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s) :
     ∫⁻ a, condKernelReal ρ a {x | (a, x) ∈ s} ∂ρ.fst = ρ s :=
   by
@@ -251,9 +238,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       _ = ∑' i, ρ (f i) := by simp_rw [hf_eq]
       _ = ρ (Union f) := (measure_Union hf_disj hf_meas).symm
 #align probability_theory.lintegral_cond_kernel_real_mem ProbabilityTheory.lintegral_condKernelReal_mem
--/
 
-#print ProbabilityTheory.kernel.const_eq_compProd_real /-
 theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : Measure (α × ℝ))
     [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ (condKernelReal ρ) :=
@@ -263,16 +248,12 @@ theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : M
   simp_rw [kernel.prod_mk_left_apply]
   rw [lintegral_cond_kernel_real_mem ρ hs]
 #align probability_theory.kernel.const_eq_comp_prod_real ProbabilityTheory.kernel.const_eq_compProd_real
--/
 
-#print ProbabilityTheory.measure_eq_compProd_real /-
 theorem measure_eq_compProd_real :
     ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit (condKernelReal ρ)) () := by
   rw [← kernel.const_eq_comp_prod_real Unit ρ, kernel.const_apply]
 #align probability_theory.measure_eq_comp_prod_real ProbabilityTheory.measure_eq_compProd_real
--/
 
-#print ProbabilityTheory.lintegral_condKernelReal /-
 theorem lintegral_condKernelReal {f : α × ℝ → ℝ≥0∞} (hf : Measurable f) :
     ∫⁻ a, ∫⁻ y, f (a, y) ∂condKernelReal ρ a ∂ρ.fst = ∫⁻ x, f x ∂ρ :=
   by
@@ -280,9 +261,7 @@ theorem lintegral_condKernelReal {f : α × ℝ → ℝ≥0∞} (hf : Measurable
   rw [kernel.lintegral_comp_prod _ _ _ hf, kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.lintegral_cond_kernel_real ProbabilityTheory.lintegral_condKernelReal
--/
 
-#print ProbabilityTheory.ae_condKernelReal_eq_one /-
 theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ {x | x.snd ∈ sᶜ} = 0) :
     ∀ᵐ a ∂ρ.fst, condKernelReal ρ a s = 1 :=
   by
@@ -305,7 +284,6 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ
   rwa [prob_compl_eq_zero_iff hs] at ha
   infer_instance
 #align probability_theory.ae_cond_kernel_real_eq_one ProbabilityTheory.ae_condKernelReal_eq_one
--/
 
 end Real
 
@@ -320,7 +298,6 @@ property on `ℝ` to all these spaces. -/
 variable {Ω : Type _} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω]
   [Nonempty Ω] (ρ : Measure (α × Ω)) [IsFiniteMeasure ρ]
 
-#print ProbabilityTheory.exists_cond_kernel /-
 /-- Existence of a conditional kernel. Use the definition `cond_kernel` to get that kernel. -/
 theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     ∃ (η : kernel α Ω) (h : IsMarkovKernel η),
@@ -408,7 +385,6 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     rw [kernel.piecewise_apply, if_pos ha]
   rw [h1, h2]
 #align probability_theory.exists_cond_kernel ProbabilityTheory.exists_cond_kernel
--/
 
 #print MeasureTheory.Measure.condKernel /-
 /-- Conditional kernel of a measure on a product space: a Markov kernel such that
@@ -419,34 +395,29 @@ noncomputable irreducible_def MeasureTheory.Measure.condKernel : kernel α Ω :=
 #align measure_theory.measure.cond_kernel MeasureTheory.Measure.condKernel
 -/
 
-#print ProbabilityTheory.condKernel_def /-
 theorem condKernel_def : ρ.condKernel = (exists_cond_kernel ρ Unit).some := by
   rw [MeasureTheory.Measure.condKernel]
 #align probability_theory.cond_kernel_def ProbabilityTheory.condKernel_def
--/
 
 instance : IsMarkovKernel ρ.condKernel := by rw [cond_kernel_def];
   exact (exists_cond_kernel ρ Unit).choose_spec.some
 
-#print ProbabilityTheory.kernel.const_unit_eq_compProd /-
 theorem kernel.const_unit_eq_compProd :
     kernel.const Unit ρ = kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel := by
   simp_rw [cond_kernel_def]; exact (exists_cond_kernel ρ Unit).choose_spec.choose_spec
 #align probability_theory.kernel.const_unit_eq_comp_prod ProbabilityTheory.kernel.const_unit_eq_compProd
--/
 
-#print ProbabilityTheory.measure_eq_compProd /-
+#print MeasureTheory.Measure.compProd_fst_condKernel /-
 /-- **Disintegration** of finite product measures on `α × Ω`, where `Ω` is Polish Borel. Such a
 measure can be written as the composition-product of the constant kernel with value `ρ.fst`
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
 `probability_theory.cond_kernel ρ`. -/
-theorem measure_eq_compProd :
+theorem MeasureTheory.Measure.compProd_fst_condKernel :
     ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel) () := by
   rw [← kernel.const_unit_eq_comp_prod, kernel.const_apply]
-#align probability_theory.measure_eq_comp_prod ProbabilityTheory.measure_eq_compProd
+#align probability_theory.measure_eq_comp_prod MeasureTheory.Measure.compProd_fst_condKernel
 -/
 
-#print ProbabilityTheory.kernel.const_eq_compProd /-
 /-- **Disintegration** of constant kernels. A constant kernel on a product space `α × Ω`, where `Ω`
 is Polish Borel, can be written as the composition-product of the constant kernel with value `ρ.fst`
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
@@ -459,23 +430,23 @@ theorem kernel.const_eq_compProd (γ : Type _) [MeasurableSpace γ] (ρ : Measur
   simpa only [kernel.const_apply, kernel.comp_prod_apply _ _ _ hs, kernel.prod_mk_left_apply'] using
     kernel.ext_iff'.mp (kernel.const_unit_eq_comp_prod ρ) () s hs
 #align probability_theory.kernel.const_eq_comp_prod ProbabilityTheory.kernel.const_eq_compProd
--/
 
-#print ProbabilityTheory.lintegral_condKernel_mem /-
-theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
+#print MeasureTheory.Measure.lintegral_condKernel_mem /-
+theorem MeasureTheory.Measure.lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
     ∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst = ρ s :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   simp_rw [kernel.comp_prod_apply _ _ _ hs, kernel.const_apply, kernel.prod_mk_left_apply]
-#align probability_theory.lintegral_cond_kernel_mem ProbabilityTheory.lintegral_condKernel_mem
+#align probability_theory.lintegral_cond_kernel_mem MeasureTheory.Measure.lintegral_condKernel_mem
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod /-
-theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSet s) {t : Set Ω}
-    (ht : MeasurableSet t) : ∫⁻ a in s, ρ.condKernel a t ∂ρ.fst = ρ (s ×ˢ t) :=
+#print MeasureTheory.Measure.set_lintegral_condKernel_eq_measure_prod /-
+theorem MeasureTheory.Measure.set_lintegral_condKernel_eq_measure_prod {s : Set α}
+    (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) :
+    ∫⁻ a in s, ρ.condKernel a t ∂ρ.fst = ρ (s ×ˢ t) :=
   by
   have :
     ρ (s ×ˢ t) =
@@ -491,48 +462,48 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
   split_ifs with hx
   · simp only [hx, if_true, true_and_iff, set_of_mem_eq]
   · simp only [hx, if_false, false_and_iff, set_of_false, measure_empty]
-#align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
+#align probability_theory.set_lintegral_cond_kernel_eq_measure_prod MeasureTheory.Measure.set_lintegral_condKernel_eq_measure_prod
 -/
 
-#print ProbabilityTheory.lintegral_condKernel /-
-theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
+#print MeasureTheory.Measure.lintegral_condKernel /-
+theorem MeasureTheory.Measure.lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
     ∫⁻ a, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x, f x ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   rw [kernel.lintegral_comp_prod _ _ _ hf, kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
-#align probability_theory.lintegral_cond_kernel ProbabilityTheory.lintegral_condKernel
+#align probability_theory.lintegral_cond_kernel MeasureTheory.Measure.lintegral_condKernel
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_lintegral_condKernel /-
-theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
-    (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) :
+#print MeasureTheory.Measure.set_lintegral_condKernel /-
+theorem MeasureTheory.Measure.set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f)
+    {s : Set α} (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) :
     ∫⁻ a in s, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in s ×ˢ t, f x ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   simp_rw [← kernel.restrict_apply _ (hs.prod ht), ← kernel.comp_prod_restrict,
     kernel.lintegral_comp_prod _ _ _ hf, kernel.restrict_apply, kernel.const_apply,
     kernel.prod_mk_left_apply]
-#align probability_theory.set_lintegral_cond_kernel ProbabilityTheory.set_lintegral_condKernel
+#align probability_theory.set_lintegral_cond_kernel MeasureTheory.Measure.set_lintegral_condKernel
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_lintegral_condKernel_univ_right /-
-theorem set_lintegral_condKernel_univ_right {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
-    (hs : MeasurableSet s) :
+#print MeasureTheory.Measure.set_lintegral_condKernel_univ_right /-
+theorem MeasureTheory.Measure.set_lintegral_condKernel_univ_right {f : α × Ω → ℝ≥0∞}
+    (hf : Measurable f) {s : Set α} (hs : MeasurableSet s) :
     ∫⁻ a in s, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_lintegral_cond_kernel ρ hf hs MeasurableSet.univ]; simp_rw [measure.restrict_univ]
-#align probability_theory.set_lintegral_cond_kernel_univ_right ProbabilityTheory.set_lintegral_condKernel_univ_right
+#align probability_theory.set_lintegral_cond_kernel_univ_right MeasureTheory.Measure.set_lintegral_condKernel_univ_right
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_lintegral_condKernel_univ_left /-
-theorem set_lintegral_condKernel_univ_left {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {t : Set Ω}
-    (ht : MeasurableSet t) :
+#print MeasureTheory.Measure.set_lintegral_condKernel_univ_left /-
+theorem MeasureTheory.Measure.set_lintegral_condKernel_univ_left {f : α × Ω → ℝ≥0∞}
+    (hf : Measurable f) {t : Set Ω} (ht : MeasurableSet t) :
     ∫⁻ a, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_lintegral_cond_kernel ρ hf MeasurableSet.univ ht]; simp_rw [measure.restrict_univ]
-#align probability_theory.set_lintegral_cond_kernel_univ_left ProbabilityTheory.set_lintegral_condKernel_univ_left
+#align probability_theory.set_lintegral_cond_kernel_univ_left MeasureTheory.Measure.set_lintegral_condKernel_univ_left
 -/
 
 section IntegralCondKernel
@@ -549,9 +520,10 @@ theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α
 #align measure_theory.ae_strongly_measurable.integral_cond_kernel MeasureTheory.AEStronglyMeasurable.integral_condKernel
 -/
 
-#print ProbabilityTheory.integral_condKernel /-
-theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
-    (hf : Integrable f ρ) : ∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst = ∫ ω, f ω ∂ρ :=
+#print MeasureTheory.Measure.integral_condKernel /-
+theorem MeasureTheory.Measure.integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
+    {f : α × Ω → E} (hf : Integrable f ρ) :
+    ∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst = ∫ ω, f ω ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   have hf' :
@@ -559,14 +531,14 @@ theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f :
     rwa [measure_eq_comp_prod ρ] at hf
   rw [integral_comp_prod hf', kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
-#align probability_theory.integral_cond_kernel ProbabilityTheory.integral_condKernel
+#align probability_theory.integral_cond_kernel MeasureTheory.Measure.integral_condKernel
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_integral_condKernel /-
-theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
-    {s : Set α} (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t)
+#print MeasureTheory.Measure.set_integral_condKernel /-
+theorem MeasureTheory.Measure.set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
+    {f : α × Ω → E} {s : Set α} (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t)
     (hf : IntegrableOn f (s ×ˢ t) ρ) :
     ∫ a in s, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ t, f x ∂ρ :=
   by
@@ -574,27 +546,29 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {
   rw [set_integral_comp_prod hs ht]
   · simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
   · rwa [measure_eq_comp_prod ρ] at hf
-#align probability_theory.set_integral_cond_kernel ProbabilityTheory.set_integral_condKernel
+#align probability_theory.set_integral_cond_kernel MeasureTheory.Measure.set_integral_condKernel
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_integral_condKernel_univ_right /-
-theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
-    {s : Set α} (hs : MeasurableSet s) (hf : IntegrableOn f (s ×ˢ univ) ρ) :
+#print MeasureTheory.Measure.set_integral_condKernel_univ_right /-
+theorem MeasureTheory.Measure.set_integral_condKernel_univ_right {ρ : Measure (α × Ω)}
+    [IsFiniteMeasure ρ] {f : α × Ω → E} {s : Set α} (hs : MeasurableSet s)
+    (hf : IntegrableOn f (s ×ˢ univ) ρ) :
     ∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]; simp_rw [measure.restrict_univ]
-#align probability_theory.set_integral_cond_kernel_univ_right ProbabilityTheory.set_integral_condKernel_univ_right
+#align probability_theory.set_integral_cond_kernel_univ_right MeasureTheory.Measure.set_integral_condKernel_univ_right
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-#print ProbabilityTheory.set_integral_condKernel_univ_left /-
-theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
-    {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (univ ×ˢ t) ρ) :
+#print MeasureTheory.Measure.set_integral_condKernel_univ_left /-
+theorem MeasureTheory.Measure.set_integral_condKernel_univ_left {ρ : Measure (α × Ω)}
+    [IsFiniteMeasure ρ] {f : α × Ω → E} {t : Set Ω} (ht : MeasurableSet t)
+    (hf : IntegrableOn f (univ ×ˢ t) ρ) :
     ∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]; simp_rw [measure.restrict_univ]
-#align probability_theory.set_integral_cond_kernel_univ_left ProbabilityTheory.set_integral_condKernel_univ_left
+#align probability_theory.set_integral_cond_kernel_univ_left MeasureTheory.Measure.set_integral_condKernel_univ_left
 -/
 
 end IntegralCondKernel
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 Probability.Kernel.CondCdf
+import Probability.Kernel.Disintegration.CondCdf
 import MeasureTheory.Constructions.Polish
 import Probability.Kernel.IntegralCompProd
 
Diff
@@ -172,7 +172,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
     simp only [mem_empty_iff_false, set_of_false, measure_empty, lintegral_const,
       MulZeroClass.zero_mul]
   · intro t ht
-    rw [mem_image2] at ht 
+    rw [mem_image2] at ht
     obtain ⟨t₁, t₂, ht₁, ht₂, rfl⟩ := ht
     have h_prod_eq_snd : ∀ a ∈ t₁, {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = t₂ :=
       by
@@ -195,7 +195,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       · rw [set_lintegral_congr_fun ht₁.compl (eventually_of_forall h_eq_zero)]
         simp only [lintegral_const, MulZeroClass.zero_mul]
       intro a hat₁
-      rw [mem_compl_iff] at hat₁ 
+      rw [mem_compl_iff] at hat₁
       simp only [hat₁, prod_mk_mem_set_prod_eq, false_and_iff, set_of_false, measure_empty]
     rw [h_eq1, h_eq2, add_zero]
     exact set_lintegral_cond_kernel_real_prod ρ ht₁ ht₂
@@ -238,7 +238,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       ext1 x
       simp only [mem_inter_iff, mem_set_of_eq, mem_empty_iff_false, iff_false_iff]
       intro h_mem_both
-      suffices (a, x) ∈ ∅ by rwa [mem_empty_iff_false] at this 
+      suffices (a, x) ∈ ∅ by rwa [mem_empty_iff_false] at this
       rwa [← h_disj, mem_inter_iff]
     calc
       ∫⁻ a, cond_kernel_real ρ a (⋃ i, {x | (a, x) ∈ f i}) ∂ρ.fst =
@@ -291,18 +291,18 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ
       (kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit (cond_kernel_real ρ)) ()
         {x | x.snd ∈ sᶜ} :=
     by rw [← measure_eq_comp_prod_real]
-  rw [hρ, kernel.comp_prod_apply] at h 
+  rw [hρ, kernel.comp_prod_apply] at h
   swap; · exact measurable_snd hs.compl
-  rw [eq_comm, lintegral_eq_zero_iff] at h 
+  rw [eq_comm, lintegral_eq_zero_iff] at h
   swap
   · simp_rw [kernel.prod_mk_left_apply']
     simp only [mem_compl_iff, mem_set_of_eq]
     exact kernel.measurable_coe _ hs.compl
-  rw [kernel.const_apply] at h 
-  simp only [mem_compl_iff, mem_set_of_eq, kernel.prod_mk_left_apply'] at h 
+  rw [kernel.const_apply] at h
+  simp only [mem_compl_iff, mem_set_of_eq, kernel.prod_mk_left_apply'] at h
   filter_upwards [h] with a ha
-  change cond_kernel_real ρ a (sᶜ) = 0 at ha 
-  rwa [prob_compl_eq_zero_iff hs] at ha 
+  change cond_kernel_real ρ a (sᶜ) = 0 at ha
+  rwa [prob_compl_eq_zero_iff hs] at ha
   infer_instance
 #align probability_theory.ae_cond_kernel_real_eq_one ProbabilityTheory.ae_condKernelReal_eq_one
 -/
@@ -339,10 +339,10 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
   have h_eq_one_of_mem : ∀ a ∈ ρ_set, cond_kernel_real ρ' a (range f) = 1 :=
     by
     intro a ha
-    rw [mem_compl_iff] at ha 
+    rw [mem_compl_iff] at ha
     have h_ss := subset_to_measurable ρ.fst ({a : α | cond_kernel_real ρ' a (range f) = 1}ᶜ)
     suffices ha' : a ∉ {a : α | cond_kernel_real ρ' a (range f) = 1}ᶜ
-    · rwa [not_mem_compl_iff] at ha' 
+    · rwa [not_mem_compl_iff] at ha'
     exact not_mem_subset h_ss ha
   have h_prod_embed : MeasurableEmbedding (Prod.map (id : α → α) f) :=
     MeasurableEmbedding.id.prod_mk hf
@@ -384,7 +384,7 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     simp only [id.def, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
     refine' ⟨fun h => ⟨x.1, x.2, h, rfl, rfl⟩, _⟩
     rintro ⟨a, b, h_mem, rfl, hf_eq⟩
-    rwa [hf.injective hf_eq] at h_mem 
+    rwa [hf.injective hf_eq] at h_mem
   rw [this, kernel.const_eq_comp_prod_real _ ρ']
   ext c t ht : 2
   rw [kernel.comap_right_apply' _ _ _ ht,
@@ -544,7 +544,7 @@ theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α
     [IsFiniteMeasure ρ] {f : α × Ω → E} (hf : AEStronglyMeasurable f ρ) :
     AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ρ.condKernel x) ρ.fst :=
   by
-  rw [measure_eq_comp_prod ρ] at hf 
+  rw [measure_eq_comp_prod ρ] at hf
   exact ae_strongly_measurable.integral_kernel_comp_prod hf
 #align measure_theory.ae_strongly_measurable.integral_cond_kernel MeasureTheory.AEStronglyMeasurable.integral_condKernel
 -/
@@ -556,7 +556,7 @@ theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f :
   conv_rhs => rw [measure_eq_comp_prod ρ]
   have hf' :
     integrable f ((kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit ρ.cond_kernel) ()) := by
-    rwa [measure_eq_comp_prod ρ] at hf 
+    rwa [measure_eq_comp_prod ρ] at hf
   rw [integral_comp_prod hf', kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.integral_cond_kernel ProbabilityTheory.integral_condKernel
@@ -573,7 +573,7 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {
   conv_rhs => rw [measure_eq_comp_prod ρ]
   rw [set_integral_comp_prod hs ht]
   · simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
-  · rwa [measure_eq_comp_prod ρ] at hf 
+  · rwa [measure_eq_comp_prod ρ] at hf
 #align probability_theory.set_integral_cond_kernel ProbabilityTheory.set_integral_condKernel
 -/
 
@@ -623,7 +623,7 @@ theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
         Integrable (fun a => ∫ ω, ‖f (a, ω)‖ ∂ρ.condKernel a) ρ.fst ↔
       Integrable f ρ :=
   by
-  rw [measure_eq_comp_prod ρ] at hf 
+  rw [measure_eq_comp_prod ρ] at hf
   conv_rhs => rw [measure_eq_comp_prod ρ]
   rw [integrable_comp_prod_iff hf]
   simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
@@ -635,7 +635,7 @@ theorem Integrable.condKernel_ae {f : α × Ω → F} (hf_int : Integrable f ρ)
     ∀ᵐ a ∂ρ.fst, Integrable (fun ω => f (a, ω)) (ρ.condKernel a) :=
   by
   have hf_ae : ae_strongly_measurable f ρ := hf_int.1
-  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int 
+  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int
   exact hf_int.1
 #align measure_theory.integrable.cond_kernel_ae MeasureTheory.Integrable.condKernel_ae
 -/
@@ -645,7 +645,7 @@ theorem Integrable.integral_norm_condKernel {f : α × Ω → F} (hf_int : Integ
     Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ρ.condKernel x) ρ.fst :=
   by
   have hf_ae : ae_strongly_measurable f ρ := hf_int.1
-  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int 
+  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int
   exact hf_int.2
 #align measure_theory.integrable.integral_norm_cond_kernel MeasureTheory.Integrable.integral_norm_condKernel
 -/
Diff
@@ -364,11 +364,53 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     simp only [mem_compl_iff, mem_range, preimage_set_of_eq, Prod_map, mem_set_of_eq,
       mem_empty_iff_false, iff_false_iff, Classical.not_not, exists_apply_eq_apply]
   classical
+  obtain ⟨x₀, hx₀⟩ : ∃ x, x ∈ range f := range_nonempty _
+  let η' :=
+    kernel.piecewise hm (cond_kernel_real ρ') (kernel.deterministic (fun _ => x₀) measurable_const)
+  -- We show that `kernel.comap_right η' hf` is a suitable Markov kernel.
+  refine' ⟨kernel.comap_right η' hf, _, _⟩
+  · refine' kernel.is_markov_kernel.comap_right _ _ fun a => _
+    rw [kernel.piecewise_apply']
+    split_ifs with h_mem h_not_mem
+    · exact h_eq_one_of_mem _ h_mem
+    · rw [kernel.deterministic_apply' _ _ hf.measurable_set_range, Set.indicator_apply, if_pos hx₀]
+  have : kernel.const γ ρ = kernel.comap_right (kernel.const γ ρ') h_prod_embed :=
+    by
+    ext c t ht : 2
+    rw [kernel.const_apply, kernel.comap_right_apply' _ _ _ ht, kernel.const_apply,
+      measure.map_apply h_prod_embed.measurable (h_prod_embed.measurable_set_image.mpr ht)]
+    congr with x : 1
+    rw [← @Prod.mk.eta _ _ x]
+    simp only [id.def, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
+    refine' ⟨fun h => ⟨x.1, x.2, h, rfl, rfl⟩, _⟩
+    rintro ⟨a, b, h_mem, rfl, hf_eq⟩
+    rwa [hf.injective hf_eq] at h_mem 
+  rw [this, kernel.const_eq_comp_prod_real _ ρ']
+  ext c t ht : 2
+  rw [kernel.comap_right_apply' _ _ _ ht,
+    kernel.comp_prod_apply _ _ _ (h_prod_embed.measurable_set_image.mpr ht), kernel.const_apply,
+    h_fst, kernel.comp_prod_apply _ _ _ ht, kernel.const_apply]
+  refine' lintegral_congr_ae _
+  filter_upwards [h_ae] with a ha
+  rw [kernel.prod_mk_left_apply', kernel.prod_mk_left_apply', kernel.comap_right_apply']
+  swap
+  · exact measurable_prod_mk_left ht
+  have h1 : {c : ℝ | (a, c) ∈ Prod.map id f '' t} = f '' {c : Ω | (a, c) ∈ t} :=
+    by
+    ext1 x
+    simp only [Prod_map, id.def, mem_image, Prod.mk.inj_iff, Prod.exists, mem_set_of_eq]
+    constructor
+    · rintro ⟨a', b, h_mem, rfl, hf_eq⟩
+      exact ⟨b, h_mem, hf_eq⟩
+    · rintro ⟨b, h_mem, hf_eq⟩
+      exact ⟨a, b, h_mem, rfl, hf_eq⟩
+  have h2 : cond_kernel_real ρ' (c, a).snd = η' (c, a).snd := by
+    rw [kernel.piecewise_apply, if_pos ha]
+  rw [h1, h2]
 #align probability_theory.exists_cond_kernel ProbabilityTheory.exists_cond_kernel
 -/
 
 #print MeasureTheory.Measure.condKernel /-
--- We show that `kernel.comap_right η' hf` is a suitable Markov kernel.
 /-- Conditional kernel of a measure on a product space: a Markov kernel such that
 `ρ = ((kernel.const unit ρ.fst) ⊗ₖ (kernel.prod_mk_left unit ρ.cond_kernel)) ()`
 (see `probability_theory.measure_eq_comp_prod`). -/
@@ -445,6 +487,10 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
   congr
   ext1 x
   classical
+  rw [indicator_apply]
+  split_ifs with hx
+  · simp only [hx, if_true, true_and_iff, set_of_mem_eq]
+  · simp only [hx, if_false, false_and_iff, set_of_false, measure_empty]
 #align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
 -/
 
Diff
@@ -364,53 +364,11 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     simp only [mem_compl_iff, mem_range, preimage_set_of_eq, Prod_map, mem_set_of_eq,
       mem_empty_iff_false, iff_false_iff, Classical.not_not, exists_apply_eq_apply]
   classical
-  obtain ⟨x₀, hx₀⟩ : ∃ x, x ∈ range f := range_nonempty _
-  let η' :=
-    kernel.piecewise hm (cond_kernel_real ρ') (kernel.deterministic (fun _ => x₀) measurable_const)
-  -- We show that `kernel.comap_right η' hf` is a suitable Markov kernel.
-  refine' ⟨kernel.comap_right η' hf, _, _⟩
-  · refine' kernel.is_markov_kernel.comap_right _ _ fun a => _
-    rw [kernel.piecewise_apply']
-    split_ifs with h_mem h_not_mem
-    · exact h_eq_one_of_mem _ h_mem
-    · rw [kernel.deterministic_apply' _ _ hf.measurable_set_range, Set.indicator_apply, if_pos hx₀]
-  have : kernel.const γ ρ = kernel.comap_right (kernel.const γ ρ') h_prod_embed :=
-    by
-    ext c t ht : 2
-    rw [kernel.const_apply, kernel.comap_right_apply' _ _ _ ht, kernel.const_apply,
-      measure.map_apply h_prod_embed.measurable (h_prod_embed.measurable_set_image.mpr ht)]
-    congr with x : 1
-    rw [← @Prod.mk.eta _ _ x]
-    simp only [id.def, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
-    refine' ⟨fun h => ⟨x.1, x.2, h, rfl, rfl⟩, _⟩
-    rintro ⟨a, b, h_mem, rfl, hf_eq⟩
-    rwa [hf.injective hf_eq] at h_mem 
-  rw [this, kernel.const_eq_comp_prod_real _ ρ']
-  ext c t ht : 2
-  rw [kernel.comap_right_apply' _ _ _ ht,
-    kernel.comp_prod_apply _ _ _ (h_prod_embed.measurable_set_image.mpr ht), kernel.const_apply,
-    h_fst, kernel.comp_prod_apply _ _ _ ht, kernel.const_apply]
-  refine' lintegral_congr_ae _
-  filter_upwards [h_ae] with a ha
-  rw [kernel.prod_mk_left_apply', kernel.prod_mk_left_apply', kernel.comap_right_apply']
-  swap
-  · exact measurable_prod_mk_left ht
-  have h1 : {c : ℝ | (a, c) ∈ Prod.map id f '' t} = f '' {c : Ω | (a, c) ∈ t} :=
-    by
-    ext1 x
-    simp only [Prod_map, id.def, mem_image, Prod.mk.inj_iff, Prod.exists, mem_set_of_eq]
-    constructor
-    · rintro ⟨a', b, h_mem, rfl, hf_eq⟩
-      exact ⟨b, h_mem, hf_eq⟩
-    · rintro ⟨b, h_mem, hf_eq⟩
-      exact ⟨a, b, h_mem, rfl, hf_eq⟩
-  have h2 : cond_kernel_real ρ' (c, a).snd = η' (c, a).snd := by
-    rw [kernel.piecewise_apply, if_pos ha]
-  rw [h1, h2]
 #align probability_theory.exists_cond_kernel ProbabilityTheory.exists_cond_kernel
 -/
 
 #print MeasureTheory.Measure.condKernel /-
+-- We show that `kernel.comap_right η' hf` is a suitable Markov kernel.
 /-- Conditional kernel of a measure on a product space: a Markov kernel such that
 `ρ = ((kernel.const unit ρ.fst) ⊗ₖ (kernel.prod_mk_left unit ρ.cond_kernel)) ()`
 (see `probability_theory.measure_eq_comp_prod`). -/
@@ -487,10 +445,6 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
   congr
   ext1 x
   classical
-  rw [indicator_apply]
-  split_ifs with hx
-  · simp only [hx, if_true, true_and_iff, set_of_mem_eq]
-  · simp only [hx, if_false, false_and_iff, set_of_false, measure_empty]
 #align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
 -/
 
Diff
@@ -67,8 +67,8 @@ section Real
 kernel. Use the more general `cond_kernel`. -/
 noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ
     where
-  val a := (condCdf ρ a).Measure
-  property := measurable_measure_condCdf ρ
+  val a := (condCDF ρ a).Measure
+  property := measurable_measure_condCDF ρ
 #align probability_theory.cond_kernel_real ProbabilityTheory.condKernelReal
 -/
 
@@ -77,8 +77,8 @@ instance (ρ : Measure (α × ℝ)) : IsMarkovKernel (condKernelReal ρ) :=
 
 #print ProbabilityTheory.condKernelReal_Iic /-
 theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
-    condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCdf ρ a x) :=
-  measure_condCdf_Iic ρ a x
+    condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCDF ρ a x) :=
+  measure_condCDF_Iic ρ a x
 #align probability_theory.cond_kernel_real_Iic ProbabilityTheory.condKernelReal_Iic
 -/
 
Diff
@@ -3,9 +3,9 @@ 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.CondCdf
-import Mathbin.MeasureTheory.Constructions.Polish
-import Mathbin.Probability.Kernel.IntegralCompProd
+import Probability.Kernel.CondCdf
+import MeasureTheory.Constructions.Polish
+import Probability.Kernel.IntegralCompProd
 
 #align_import probability.kernel.disintegration from "leanprover-community/mathlib"@"e8e130de9dba4ed6897183c3193c752ffadbcc77"
 
Diff
@@ -2,16 +2,13 @@
 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.disintegration
-! leanprover-community/mathlib commit e8e130de9dba4ed6897183c3193c752ffadbcc77
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Probability.Kernel.CondCdf
 import Mathbin.MeasureTheory.Constructions.Polish
 import Mathbin.Probability.Kernel.IntegralCompProd
 
+#align_import probability.kernel.disintegration from "leanprover-community/mathlib"@"e8e130de9dba4ed6897183c3193c752ffadbcc77"
+
 /-!
 # Disintegration of measures on product spaces
 
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.disintegration
-! leanprover-community/mathlib commit 6315581f5650ffa2fbdbbbedc41243c8d7070981
+! leanprover-community/mathlib commit e8e130de9dba4ed6897183c3193c752ffadbcc77
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -15,6 +15,9 @@ import Mathbin.Probability.Kernel.IntegralCompProd
 /-!
 # Disintegration of measures on product spaces
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Let `ρ` be a finite measure on `α × Ω`, where `Ω` is a standard Borel space. In mathlib terms, `Ω`
 verifies `[nonempty Ω] [topological_space Ω] [polish_space Ω] [measurable_space Ω] [borel_space Ω]`.
 Then there exists a kernel `ρ.cond_kernel : kernel α Ω` such that for any measurable set
Diff
@@ -62,6 +62,7 @@ section Real
 /-! ### Disintegration of measures on `α × ℝ` -/
 
 
+#print ProbabilityTheory.condKernelReal /-
 /-- Conditional measure on the second space of the product given the value on the first, as a
 kernel. Use the more general `cond_kernel`. -/
 noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ
@@ -69,34 +70,43 @@ noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ
   val a := (condCdf ρ a).Measure
   property := measurable_measure_condCdf ρ
 #align probability_theory.cond_kernel_real ProbabilityTheory.condKernelReal
+-/
 
 instance (ρ : Measure (α × ℝ)) : IsMarkovKernel (condKernelReal ρ) :=
   ⟨fun a => by rw [cond_kernel_real]; infer_instance⟩
 
+#print ProbabilityTheory.condKernelReal_Iic /-
 theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
     condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCdf ρ a x) :=
   measure_condCdf_Iic ρ a x
 #align probability_theory.cond_kernel_real_Iic ProbabilityTheory.condKernelReal_Iic
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_lintegral_condKernelReal_Iic /-
 theorem set_lintegral_condKernelReal_Iic (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] (x : ℝ)
     {s : Set α} (hs : MeasurableSet s) :
     ∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst = ρ (s ×ˢ Iic x) := by
   simp_rw [cond_kernel_real_Iic]; exact set_lintegral_cond_cdf ρ x hs
 #align probability_theory.set_lintegral_cond_kernel_real_Iic ProbabilityTheory.set_lintegral_condKernelReal_Iic
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_lintegral_condKernelReal_univ /-
 theorem set_lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) {s : Set α} (hs : MeasurableSet s) :
     ∫⁻ a in s, condKernelReal ρ a univ ∂ρ.fst = ρ (s ×ˢ univ) := by
   simp only [measure_univ, lintegral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
     one_mul, measure.fst_apply hs, ← prod_univ]
 #align probability_theory.set_lintegral_cond_kernel_real_univ ProbabilityTheory.set_lintegral_condKernelReal_univ
+-/
 
+#print ProbabilityTheory.lintegral_condKernelReal_univ /-
 theorem lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) :
     ∫⁻ a, condKernelReal ρ a univ ∂ρ.fst = ρ univ := by
   rw [← set_lintegral_univ, set_lintegral_cond_kernel_real_univ ρ MeasurableSet.univ,
     univ_prod_univ]
 #align probability_theory.lintegral_cond_kernel_real_univ ProbabilityTheory.lintegral_condKernelReal_univ
+-/
 
 variable (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
 
@@ -104,6 +114,7 @@ variable (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_lintegral_condKernelReal_prod /-
 theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t : Set ℝ}
     (ht : MeasurableSet t) : ∫⁻ a in s, condKernelReal ρ a t ∂ρ.fst = ρ (s ×ˢ t) :=
   by
@@ -143,11 +154,13 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
       exact Or.inr (hf_disj hij)
     · exact fun i => MeasurableSet.prod hs (hf_meas i)
 #align probability_theory.set_lintegral_cond_kernel_real_prod ProbabilityTheory.set_lintegral_condKernelReal_prod
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.lintegral_condKernelReal_mem /-
 theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s) :
     ∫⁻ a, condKernelReal ρ a {x | (a, x) ∈ s} ∂ρ.fst = ρ s :=
   by
@@ -238,7 +251,9 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       _ = ∑' i, ρ (f i) := by simp_rw [hf_eq]
       _ = ρ (Union f) := (measure_Union hf_disj hf_meas).symm
 #align probability_theory.lintegral_cond_kernel_real_mem ProbabilityTheory.lintegral_condKernelReal_mem
+-/
 
+#print ProbabilityTheory.kernel.const_eq_compProd_real /-
 theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : Measure (α × ℝ))
     [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ (condKernelReal ρ) :=
@@ -248,12 +263,16 @@ theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : M
   simp_rw [kernel.prod_mk_left_apply]
   rw [lintegral_cond_kernel_real_mem ρ hs]
 #align probability_theory.kernel.const_eq_comp_prod_real ProbabilityTheory.kernel.const_eq_compProd_real
+-/
 
+#print ProbabilityTheory.measure_eq_compProd_real /-
 theorem measure_eq_compProd_real :
     ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit (condKernelReal ρ)) () := by
   rw [← kernel.const_eq_comp_prod_real Unit ρ, kernel.const_apply]
 #align probability_theory.measure_eq_comp_prod_real ProbabilityTheory.measure_eq_compProd_real
+-/
 
+#print ProbabilityTheory.lintegral_condKernelReal /-
 theorem lintegral_condKernelReal {f : α × ℝ → ℝ≥0∞} (hf : Measurable f) :
     ∫⁻ a, ∫⁻ y, f (a, y) ∂condKernelReal ρ a ∂ρ.fst = ∫⁻ x, f x ∂ρ :=
   by
@@ -261,7 +280,9 @@ theorem lintegral_condKernelReal {f : α × ℝ → ℝ≥0∞} (hf : Measurable
   rw [kernel.lintegral_comp_prod _ _ _ hf, kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.lintegral_cond_kernel_real ProbabilityTheory.lintegral_condKernelReal
+-/
 
+#print ProbabilityTheory.ae_condKernelReal_eq_one /-
 theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ {x | x.snd ∈ sᶜ} = 0) :
     ∀ᵐ a ∂ρ.fst, condKernelReal ρ a s = 1 :=
   by
@@ -284,6 +305,7 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ
   rwa [prob_compl_eq_zero_iff hs] at ha 
   infer_instance
 #align probability_theory.ae_cond_kernel_real_eq_one ProbabilityTheory.ae_condKernelReal_eq_one
+-/
 
 end Real
 
@@ -298,6 +320,7 @@ property on `ℝ` to all these spaces. -/
 variable {Ω : Type _} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω]
   [Nonempty Ω] (ρ : Measure (α × Ω)) [IsFiniteMeasure ρ]
 
+#print ProbabilityTheory.exists_cond_kernel /-
 /-- Existence of a conditional kernel. Use the definition `cond_kernel` to get that kernel. -/
 theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     ∃ (η : kernel α Ω) (h : IsMarkovKernel η),
@@ -385,26 +408,34 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     rw [kernel.piecewise_apply, if_pos ha]
   rw [h1, h2]
 #align probability_theory.exists_cond_kernel ProbabilityTheory.exists_cond_kernel
+-/
 
+#print MeasureTheory.Measure.condKernel /-
 /-- Conditional kernel of a measure on a product space: a Markov kernel such that
 `ρ = ((kernel.const unit ρ.fst) ⊗ₖ (kernel.prod_mk_left unit ρ.cond_kernel)) ()`
 (see `probability_theory.measure_eq_comp_prod`). -/
 noncomputable irreducible_def MeasureTheory.Measure.condKernel : kernel α Ω :=
   (exists_cond_kernel ρ Unit).some
 #align measure_theory.measure.cond_kernel MeasureTheory.Measure.condKernel
+-/
 
+#print ProbabilityTheory.condKernel_def /-
 theorem condKernel_def : ρ.condKernel = (exists_cond_kernel ρ Unit).some := by
   rw [MeasureTheory.Measure.condKernel]
 #align probability_theory.cond_kernel_def ProbabilityTheory.condKernel_def
+-/
 
 instance : IsMarkovKernel ρ.condKernel := by rw [cond_kernel_def];
   exact (exists_cond_kernel ρ Unit).choose_spec.some
 
+#print ProbabilityTheory.kernel.const_unit_eq_compProd /-
 theorem kernel.const_unit_eq_compProd :
     kernel.const Unit ρ = kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel := by
   simp_rw [cond_kernel_def]; exact (exists_cond_kernel ρ Unit).choose_spec.choose_spec
 #align probability_theory.kernel.const_unit_eq_comp_prod ProbabilityTheory.kernel.const_unit_eq_compProd
+-/
 
+#print ProbabilityTheory.measure_eq_compProd /-
 /-- **Disintegration** of finite product measures on `α × Ω`, where `Ω` is Polish Borel. Such a
 measure can be written as the composition-product of the constant kernel with value `ρ.fst`
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
@@ -413,7 +444,9 @@ theorem measure_eq_compProd :
     ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel) () := by
   rw [← kernel.const_unit_eq_comp_prod, kernel.const_apply]
 #align probability_theory.measure_eq_comp_prod ProbabilityTheory.measure_eq_compProd
+-/
 
+#print ProbabilityTheory.kernel.const_eq_compProd /-
 /-- **Disintegration** of constant kernels. A constant kernel on a product space `α × Ω`, where `Ω`
 is Polish Borel, can be written as the composition-product of the constant kernel with value `ρ.fst`
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
@@ -426,17 +459,21 @@ theorem kernel.const_eq_compProd (γ : Type _) [MeasurableSpace γ] (ρ : Measur
   simpa only [kernel.const_apply, kernel.comp_prod_apply _ _ _ hs, kernel.prod_mk_left_apply'] using
     kernel.ext_iff'.mp (kernel.const_unit_eq_comp_prod ρ) () s hs
 #align probability_theory.kernel.const_eq_comp_prod ProbabilityTheory.kernel.const_eq_compProd
+-/
 
+#print ProbabilityTheory.lintegral_condKernel_mem /-
 theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
     ∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst = ρ s :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   simp_rw [kernel.comp_prod_apply _ _ _ hs, kernel.const_apply, kernel.prod_mk_left_apply]
 #align probability_theory.lintegral_cond_kernel_mem ProbabilityTheory.lintegral_condKernel_mem
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod /-
 theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSet s) {t : Set Ω}
     (ht : MeasurableSet t) : ∫⁻ a in s, ρ.condKernel a t ∂ρ.fst = ρ (s ×ˢ t) :=
   by
@@ -455,7 +492,9 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
   · simp only [hx, if_true, true_and_iff, set_of_mem_eq]
   · simp only [hx, if_false, false_and_iff, set_of_false, measure_empty]
 #align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
+-/
 
+#print ProbabilityTheory.lintegral_condKernel /-
 theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
     ∫⁻ a, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x, f x ∂ρ :=
   by
@@ -463,8 +502,10 @@ theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
   rw [kernel.lintegral_comp_prod _ _ _ hf, kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.lintegral_cond_kernel ProbabilityTheory.lintegral_condKernel
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_lintegral_condKernel /-
 theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
     (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) :
     ∫⁻ a in s, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in s ×ˢ t, f x ∂ρ :=
@@ -474,25 +515,31 @@ theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable
     kernel.lintegral_comp_prod _ _ _ hf, kernel.restrict_apply, kernel.const_apply,
     kernel.prod_mk_left_apply]
 #align probability_theory.set_lintegral_cond_kernel ProbabilityTheory.set_lintegral_condKernel
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_lintegral_condKernel_univ_right /-
 theorem set_lintegral_condKernel_univ_right {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
     (hs : MeasurableSet s) :
     ∫⁻ a in s, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_lintegral_cond_kernel ρ hf hs MeasurableSet.univ]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_lintegral_cond_kernel_univ_right ProbabilityTheory.set_lintegral_condKernel_univ_right
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_lintegral_condKernel_univ_left /-
 theorem set_lintegral_condKernel_univ_left {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {t : Set Ω}
     (ht : MeasurableSet t) :
     ∫⁻ a, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_lintegral_cond_kernel ρ hf MeasurableSet.univ ht]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_lintegral_cond_kernel_univ_left ProbabilityTheory.set_lintegral_condKernel_univ_left
+-/
 
 section IntegralCondKernel
 
 variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
 
+#print MeasureTheory.AEStronglyMeasurable.integral_condKernel /-
 theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α × Ω)}
     [IsFiniteMeasure ρ] {f : α × Ω → E} (hf : AEStronglyMeasurable f ρ) :
     AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ρ.condKernel x) ρ.fst :=
@@ -500,7 +547,9 @@ theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α
   rw [measure_eq_comp_prod ρ] at hf 
   exact ae_strongly_measurable.integral_kernel_comp_prod hf
 #align measure_theory.ae_strongly_measurable.integral_cond_kernel MeasureTheory.AEStronglyMeasurable.integral_condKernel
+-/
 
+#print ProbabilityTheory.integral_condKernel /-
 theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     (hf : Integrable f ρ) : ∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst = ∫ ω, f ω ∂ρ :=
   by
@@ -511,9 +560,11 @@ theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f :
   rw [integral_comp_prod hf', kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.integral_cond_kernel ProbabilityTheory.integral_condKernel
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_integral_condKernel /-
 theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {s : Set α} (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t)
     (hf : IntegrableOn f (s ×ˢ t) ρ) :
@@ -524,22 +575,27 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {
   · simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
   · rwa [measure_eq_comp_prod ρ] at hf 
 #align probability_theory.set_integral_cond_kernel ProbabilityTheory.set_integral_condKernel
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_integral_condKernel_univ_right /-
 theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {s : Set α} (hs : MeasurableSet s) (hf : IntegrableOn f (s ×ˢ univ) ρ) :
     ∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_integral_cond_kernel_univ_right ProbabilityTheory.set_integral_condKernel_univ_right
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print ProbabilityTheory.set_integral_condKernel_univ_left /-
 theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (univ ×ˢ t) ρ) :
     ∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_integral_cond_kernel_univ_left ProbabilityTheory.set_integral_condKernel_univ_left
+-/
 
 end IntegralCondKernel
 
@@ -560,6 +616,7 @@ variable {α Ω E F : Type _} {mα : MeasurableSpace α} [MeasurableSpace Ω] [T
   [BorelSpace Ω] [PolishSpace Ω] [Nonempty Ω] [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
 
+#print MeasureTheory.AEStronglyMeasurable.ae_integrable_condKernel_iff /-
 theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
     (hf : AEStronglyMeasurable f ρ) :
     (∀ᵐ a ∂ρ.fst, Integrable (fun ω => f (a, ω)) (ρ.condKernel a)) ∧
@@ -571,7 +628,9 @@ theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
   rw [integrable_comp_prod_iff hf]
   simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
 #align measure_theory.ae_strongly_measurable.ae_integrable_cond_kernel_iff MeasureTheory.AEStronglyMeasurable.ae_integrable_condKernel_iff
+-/
 
+#print MeasureTheory.Integrable.condKernel_ae /-
 theorem Integrable.condKernel_ae {f : α × Ω → F} (hf_int : Integrable f ρ) :
     ∀ᵐ a ∂ρ.fst, Integrable (fun ω => f (a, ω)) (ρ.condKernel a) :=
   by
@@ -579,7 +638,9 @@ theorem Integrable.condKernel_ae {f : α × Ω → F} (hf_int : Integrable f ρ)
   rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int 
   exact hf_int.1
 #align measure_theory.integrable.cond_kernel_ae MeasureTheory.Integrable.condKernel_ae
+-/
 
+#print MeasureTheory.Integrable.integral_norm_condKernel /-
 theorem Integrable.integral_norm_condKernel {f : α × Ω → F} (hf_int : Integrable f ρ) :
     Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ρ.condKernel x) ρ.fst :=
   by
@@ -587,7 +648,9 @@ theorem Integrable.integral_norm_condKernel {f : α × Ω → F} (hf_int : Integ
   rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int 
   exact hf_int.2
 #align measure_theory.integrable.integral_norm_cond_kernel MeasureTheory.Integrable.integral_norm_condKernel
+-/
 
+#print MeasureTheory.Integrable.norm_integral_condKernel /-
 theorem Integrable.norm_integral_condKernel {f : α × Ω → E} (hf_int : Integrable f ρ) :
     Integrable (fun x => ‖∫ y, f (x, y) ∂ρ.condKernel x‖) ρ.fst :=
   by
@@ -597,11 +660,14 @@ theorem Integrable.norm_integral_condKernel {f : α × Ω → E} (hf_int : Integ
   refine' (norm_integral_le_integral_norm _).trans_eq (Real.norm_of_nonneg _).symm
   exact integral_nonneg_of_ae (eventually_of_forall fun y => norm_nonneg _)
 #align measure_theory.integrable.norm_integral_cond_kernel MeasureTheory.Integrable.norm_integral_condKernel
+-/
 
+#print MeasureTheory.Integrable.integral_condKernel /-
 theorem Integrable.integral_condKernel {f : α × Ω → E} (hf_int : Integrable f ρ) :
     Integrable (fun x => ∫ y, f (x, y) ∂ρ.condKernel x) ρ.fst :=
   (integrable_norm_iff hf_int.1.integral_condKernel).mp hf_int.norm_integral_condKernel
 #align measure_theory.integrable.integral_cond_kernel MeasureTheory.Integrable.integral_condKernel
+-/
 
 end MeasureTheory
 
Diff
@@ -243,7 +243,7 @@ theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : M
     [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ (condKernelReal ρ) :=
   by
-  ext (a s hs) : 2
+  ext a s hs : 2
   rw [kernel.comp_prod_apply _ _ _ hs, kernel.const_apply, kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
   rw [lintegral_cond_kernel_real_mem ρ hs]
@@ -353,7 +353,7 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     · rw [kernel.deterministic_apply' _ _ hf.measurable_set_range, Set.indicator_apply, if_pos hx₀]
   have : kernel.const γ ρ = kernel.comap_right (kernel.const γ ρ') h_prod_embed :=
     by
-    ext (c t ht) : 2
+    ext c t ht : 2
     rw [kernel.const_apply, kernel.comap_right_apply' _ _ _ ht, kernel.const_apply,
       measure.map_apply h_prod_embed.measurable (h_prod_embed.measurable_set_image.mpr ht)]
     congr with x : 1
@@ -363,7 +363,7 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     rintro ⟨a, b, h_mem, rfl, hf_eq⟩
     rwa [hf.injective hf_eq] at h_mem 
   rw [this, kernel.const_eq_comp_prod_real _ ρ']
-  ext (c t ht) : 2
+  ext c t ht : 2
   rw [kernel.comap_right_apply' _ _ _ ht,
     kernel.comp_prod_apply _ _ _ (h_prod_embed.measurable_set_image.mpr ht), kernel.const_apply,
     h_fst, kernel.comp_prod_apply _ _ _ ht, kernel.const_apply]
@@ -422,7 +422,7 @@ theorem kernel.const_eq_compProd (γ : Type _) [MeasurableSpace γ] (ρ : Measur
     [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ ρ.condKernel :=
   by
-  ext (a s hs) : 2
+  ext a s hs : 2
   simpa only [kernel.const_apply, kernel.comp_prod_apply _ _ _ hs, kernel.prod_mk_left_apply'] using
     kernel.ext_iff'.mp (kernel.const_unit_eq_comp_prod ρ) () s hs
 #align probability_theory.kernel.const_eq_comp_prod ProbabilityTheory.kernel.const_eq_compProd
Diff
@@ -57,8 +57,6 @@ namespace ProbabilityTheory
 
 variable {α : Type _} {mα : MeasurableSpace α}
 
-include mα
-
 section Real
 
 /-! ### Disintegration of measures on `α × ℝ` -/
@@ -562,8 +560,6 @@ variable {α Ω E F : Type _} {mα : MeasurableSpace α} [MeasurableSpace Ω] [T
   [BorelSpace Ω] [PolishSpace Ω] [Nonempty Ω] [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
 
-include mα
-
 theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
     (hf : AEStronglyMeasurable f ρ) :
     (∀ᵐ a ∂ρ.fst, Integrable (fun ω => f (a, ω)) (ρ.condKernel a)) ∧
Diff
@@ -83,19 +83,19 @@ theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernelReal_Iic (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] (x : ℝ)
     {s : Set α} (hs : MeasurableSet s) :
-    (∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst) = ρ (s ×ˢ Iic x) := by
+    ∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst = ρ (s ×ˢ Iic x) := by
   simp_rw [cond_kernel_real_Iic]; exact set_lintegral_cond_cdf ρ x hs
 #align probability_theory.set_lintegral_cond_kernel_real_Iic ProbabilityTheory.set_lintegral_condKernelReal_Iic
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) {s : Set α} (hs : MeasurableSet s) :
-    (∫⁻ a in s, condKernelReal ρ a univ ∂ρ.fst) = ρ (s ×ˢ univ) := by
+    ∫⁻ a in s, condKernelReal ρ a univ ∂ρ.fst = ρ (s ×ˢ univ) := by
   simp only [measure_univ, lintegral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
     one_mul, measure.fst_apply hs, ← prod_univ]
 #align probability_theory.set_lintegral_cond_kernel_real_univ ProbabilityTheory.set_lintegral_condKernelReal_univ
 
 theorem lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) :
-    (∫⁻ a, condKernelReal ρ a univ ∂ρ.fst) = ρ univ := by
+    ∫⁻ a, condKernelReal ρ a univ ∂ρ.fst = ρ univ := by
   rw [← set_lintegral_univ, set_lintegral_cond_kernel_real_univ ρ MeasurableSet.univ,
     univ_prod_univ]
 #align probability_theory.lintegral_cond_kernel_real_univ ProbabilityTheory.lintegral_condKernelReal_univ
@@ -107,7 +107,7 @@ variable (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t : Set ℝ}
-    (ht : MeasurableSet t) : (∫⁻ a in s, condKernelReal ρ a t ∂ρ.fst) = ρ (s ×ˢ t) :=
+    (ht : MeasurableSet t) : ∫⁻ a in s, condKernelReal ρ a t ∂ρ.fst = ρ (s ×ˢ t) :=
   by
   -- `set_lintegral_cond_kernel_real_Iic` gives the result for `t = Iic x`. These sets form a
   -- π-system that generate the borel σ-algebra, hence we can get the same equality for any
@@ -118,12 +118,10 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
     exact set_lintegral_cond_kernel_real_Iic ρ q hs
   · intro t ht ht_lintegral
     calc
-      (∫⁻ a in s, cond_kernel_real ρ a (tᶜ) ∂ρ.fst) =
+      ∫⁻ a in s, cond_kernel_real ρ a (tᶜ) ∂ρ.fst =
           ∫⁻ a in s, cond_kernel_real ρ a univ - cond_kernel_real ρ a t ∂ρ.fst :=
         by congr with a; rw [measure_compl ht (measure_ne_top (cond_kernel_real ρ a) _)]
-      _ =
-          (∫⁻ a in s, cond_kernel_real ρ a univ ∂ρ.fst) -
-            ∫⁻ a in s, cond_kernel_real ρ a t ∂ρ.fst :=
+      _ = ∫⁻ a in s, cond_kernel_real ρ a univ ∂ρ.fst - ∫⁻ a in s, cond_kernel_real ρ a t ∂ρ.fst :=
         by
         rw [lintegral_sub (kernel.measurable_coe (cond_kernel_real ρ) ht)]
         · rw [ht_lintegral]
@@ -153,7 +151,7 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s) :
-    (∫⁻ a, condKernelReal ρ a {x | (a, x) ∈ s} ∂ρ.fst) = ρ s :=
+    ∫⁻ a, condKernelReal ρ a {x | (a, x) ∈ s} ∂ρ.fst = ρ s :=
   by
   -- `set_lintegral_cond_kernel_real_prod` gives the result for sets of the form `t₁ × t₂`. These
   -- sets form a π-system that generate the product σ-algebra, hence we can get the same equality
@@ -175,12 +173,12 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
         MulZeroClass.zero_mul]
     rw [← lintegral_add_compl _ ht₁]
     have h_eq1 :
-      (∫⁻ a in t₁, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst) =
+      ∫⁻ a in t₁, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst =
         ∫⁻ a in t₁, cond_kernel_real ρ a t₂ ∂ρ.fst :=
       by
       refine' set_lintegral_congr_fun ht₁ (eventually_of_forall fun a ha => _)
       rw [h_prod_eq_snd a ha]
-    have h_eq2 : (∫⁻ a in t₁ᶜ, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst) = 0 :=
+    have h_eq2 : ∫⁻ a in t₁ᶜ, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst = 0 :=
       by
       suffices h_eq_zero : ∀ a ∈ t₁ᶜ, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = 0
       · rw [set_lintegral_congr_fun ht₁.compl (eventually_of_forall h_eq_zero)]
@@ -192,7 +190,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
     exact set_lintegral_cond_kernel_real_prod ρ ht₁ ht₂
   · intro t ht ht_eq
     calc
-      (∫⁻ a, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ tᶜ} ∂ρ.fst) =
+      ∫⁻ a, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ tᶜ} ∂ρ.fst =
           ∫⁻ a, cond_kernel_real ρ a ({x : ℝ | (a, x) ∈ t}ᶜ) ∂ρ.fst :=
         rfl
       _ = ∫⁻ a, cond_kernel_real ρ a univ - cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t} ∂ρ.fst :=
@@ -200,7 +198,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
         congr with a : 1
         exact measure_compl (measurable_prod_mk_left ht) (measure_ne_top (cond_kernel_real ρ a) _)
       _ =
-          (∫⁻ a, cond_kernel_real ρ a univ ∂ρ.fst) -
+          ∫⁻ a, cond_kernel_real ρ a univ ∂ρ.fst -
             ∫⁻ a, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t} ∂ρ.fst :=
         by
         have h_le :
@@ -232,7 +230,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       suffices (a, x) ∈ ∅ by rwa [mem_empty_iff_false] at this 
       rwa [← h_disj, mem_inter_iff]
     calc
-      (∫⁻ a, cond_kernel_real ρ a (⋃ i, {x | (a, x) ∈ f i}) ∂ρ.fst) =
+      ∫⁻ a, cond_kernel_real ρ a (⋃ i, {x | (a, x) ∈ f i}) ∂ρ.fst =
           ∫⁻ a, ∑' i, cond_kernel_real ρ a {x | (a, x) ∈ f i} ∂ρ.fst :=
         by
         congr with a : 1
@@ -259,7 +257,7 @@ theorem measure_eq_compProd_real :
 #align probability_theory.measure_eq_comp_prod_real ProbabilityTheory.measure_eq_compProd_real
 
 theorem lintegral_condKernelReal {f : α × ℝ → ℝ≥0∞} (hf : Measurable f) :
-    (∫⁻ a, ∫⁻ y, f (a, y) ∂condKernelReal ρ a ∂ρ.fst) = ∫⁻ x, f x ∂ρ :=
+    ∫⁻ a, ∫⁻ y, f (a, y) ∂condKernelReal ρ a ∂ρ.fst = ∫⁻ x, f x ∂ρ :=
   by
   nth_rw 2 [measure_eq_comp_prod_real ρ]
   rw [kernel.lintegral_comp_prod _ _ _ hf, kernel.const_apply]
@@ -432,7 +430,7 @@ theorem kernel.const_eq_compProd (γ : Type _) [MeasurableSpace γ] (ρ : Measur
 #align probability_theory.kernel.const_eq_comp_prod ProbabilityTheory.kernel.const_eq_compProd
 
 theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
-    (∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst) = ρ s :=
+    ∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst = ρ s :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   simp_rw [kernel.comp_prod_apply _ _ _ hs, kernel.const_apply, kernel.prod_mk_left_apply]
@@ -442,7 +440,7 @@ theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSet s) {t : Set Ω}
-    (ht : MeasurableSet t) : (∫⁻ a in s, ρ.condKernel a t ∂ρ.fst) = ρ (s ×ˢ t) :=
+    (ht : MeasurableSet t) : ∫⁻ a in s, ρ.condKernel a t ∂ρ.fst = ρ (s ×ˢ t) :=
   by
   have :
     ρ (s ×ˢ t) =
@@ -461,7 +459,7 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
 #align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
 
 theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
-    (∫⁻ a, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x, f x ∂ρ :=
+    ∫⁻ a, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x, f x ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   rw [kernel.lintegral_comp_prod _ _ _ hf, kernel.const_apply]
@@ -471,7 +469,7 @@ theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
     (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) :
-    (∫⁻ a in s, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in s ×ˢ t, f x ∂ρ :=
+    ∫⁻ a in s, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in s ×ˢ t, f x ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   simp_rw [← kernel.restrict_apply _ (hs.prod ht), ← kernel.comp_prod_restrict,
@@ -482,14 +480,14 @@ theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernel_univ_right {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
     (hs : MeasurableSet s) :
-    (∫⁻ a in s, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in s ×ˢ univ, f x ∂ρ := by
+    ∫⁻ a in s, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_lintegral_cond_kernel ρ hf hs MeasurableSet.univ]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_lintegral_cond_kernel_univ_right ProbabilityTheory.set_lintegral_condKernel_univ_right
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernel_univ_left {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {t : Set Ω}
     (ht : MeasurableSet t) :
-    (∫⁻ a, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in univ ×ˢ t, f x ∂ρ := by
+    ∫⁻ a, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_lintegral_cond_kernel ρ hf MeasurableSet.univ ht]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_lintegral_cond_kernel_univ_left ProbabilityTheory.set_lintegral_condKernel_univ_left
 
@@ -506,7 +504,7 @@ theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α
 #align measure_theory.ae_strongly_measurable.integral_cond_kernel MeasureTheory.AEStronglyMeasurable.integral_condKernel
 
 theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
-    (hf : Integrable f ρ) : (∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst) = ∫ ω, f ω ∂ρ :=
+    (hf : Integrable f ρ) : ∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst = ∫ ω, f ω ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   have hf' :
@@ -521,7 +519,7 @@ theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f :
 theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {s : Set α} (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t)
     (hf : IntegrableOn f (s ×ˢ t) ρ) :
-    (∫ a in s, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ t, f x ∂ρ :=
+    ∫ a in s, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ t, f x ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   rw [set_integral_comp_prod hs ht]
@@ -533,7 +531,7 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {s : Set α} (hs : MeasurableSet s) (hf : IntegrableOn f (s ×ˢ univ) ρ) :
-    (∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ univ, f x ∂ρ := by
+    ∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_integral_cond_kernel_univ_right ProbabilityTheory.set_integral_condKernel_univ_right
 
@@ -541,7 +539,7 @@ theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [IsFiniteMe
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (univ ×ˢ t) ρ) :
-    (∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in univ ×ˢ t, f x ∂ρ := by
+    ∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_integral_cond_kernel_univ_left ProbabilityTheory.set_integral_condKernel_univ_left
 
Diff
@@ -137,7 +137,6 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
           simp only [diff_self, empty_prod, union_empty]
         · rw [prod_subset_prod_iff]
           exact Or.inl ⟨subset_rfl, subset_univ t⟩
-      
   · intro f hf_disj hf_meas hf_eq
     simp_rw [measure_Union hf_disj hf_meas]
     rw [lintegral_tsum fun i => (kernel.measurable_coe _ (hf_meas i)).AEMeasurable.restrict,
@@ -215,7 +214,6 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
         exact measure_lt_top ρ univ
       _ = ρ univ - ρ t := by rw [ht_eq, lintegral_cond_kernel_real_univ]
       _ = ρ (tᶜ) := (measure_compl ht (measure_ne_top _ _)).symm
-      
   · intro f hf_disj hf_meas hf_eq
     have h_eq : ∀ a, {x | (a, x) ∈ ⋃ i, f i} = ⋃ i, {x | (a, x) ∈ f i} :=
       by
@@ -243,7 +241,6 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
         (lintegral_tsum fun i => (kernel.measurable_kernel_prod_mk_left (hf_meas i)).AEMeasurable)
       _ = ∑' i, ρ (f i) := by simp_rw [hf_eq]
       _ = ρ (Union f) := (measure_Union hf_disj hf_meas).symm
-      
 #align probability_theory.lintegral_cond_kernel_real_mem ProbabilityTheory.lintegral_condKernelReal_mem
 
 theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : Measure (α × ℝ))
Diff
@@ -81,8 +81,9 @@ theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
 #align probability_theory.cond_kernel_real_Iic ProbabilityTheory.condKernelReal_Iic
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem set_lintegral_condKernelReal_Iic (ρ : Measure (α × ℝ)) [FiniteMeasure ρ] (x : ℝ) {s : Set α}
-    (hs : MeasurableSet s) : (∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst) = ρ (s ×ˢ Iic x) := by
+theorem set_lintegral_condKernelReal_Iic (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] (x : ℝ)
+    {s : Set α} (hs : MeasurableSet s) :
+    (∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst) = ρ (s ×ˢ Iic x) := by
   simp_rw [cond_kernel_real_Iic]; exact set_lintegral_cond_cdf ρ x hs
 #align probability_theory.set_lintegral_cond_kernel_real_Iic ProbabilityTheory.set_lintegral_condKernelReal_Iic
 
@@ -99,7 +100,7 @@ theorem lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) :
     univ_prod_univ]
 #align probability_theory.lintegral_cond_kernel_real_univ ProbabilityTheory.lintegral_condKernelReal_univ
 
-variable (ρ : Measure (α × ℝ)) [FiniteMeasure ρ]
+variable (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -153,7 +154,7 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s) :
-    (∫⁻ a, condKernelReal ρ a { x | (a, x) ∈ s } ∂ρ.fst) = ρ s :=
+    (∫⁻ a, condKernelReal ρ a {x | (a, x) ∈ s} ∂ρ.fst) = ρ s :=
   by
   -- `set_lintegral_cond_kernel_real_prod` gives the result for sets of the form `t₁ × t₂`. These
   -- sets form a π-system that generate the product σ-algebra, hence we can get the same equality
@@ -165,7 +166,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
   · intro t ht
     rw [mem_image2] at ht 
     obtain ⟨t₁, t₂, ht₁, ht₂, rfl⟩ := ht
-    have h_prod_eq_snd : ∀ a ∈ t₁, { x : ℝ | (a, x) ∈ t₁ ×ˢ t₂ } = t₂ :=
+    have h_prod_eq_snd : ∀ a ∈ t₁, {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = t₂ :=
       by
       intro a ha
       simp only [ha, prod_mk_mem_set_prod_eq, true_and_iff, set_of_mem_eq]
@@ -175,14 +176,14 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
         MulZeroClass.zero_mul]
     rw [← lintegral_add_compl _ ht₁]
     have h_eq1 :
-      (∫⁻ a in t₁, cond_kernel_real ρ a { x : ℝ | (a, x) ∈ t₁ ×ˢ t₂ } ∂ρ.fst) =
+      (∫⁻ a in t₁, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst) =
         ∫⁻ a in t₁, cond_kernel_real ρ a t₂ ∂ρ.fst :=
       by
       refine' set_lintegral_congr_fun ht₁ (eventually_of_forall fun a ha => _)
       rw [h_prod_eq_snd a ha]
-    have h_eq2 : (∫⁻ a in t₁ᶜ, cond_kernel_real ρ a { x : ℝ | (a, x) ∈ t₁ ×ˢ t₂ } ∂ρ.fst) = 0 :=
+    have h_eq2 : (∫⁻ a in t₁ᶜ, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst) = 0 :=
       by
-      suffices h_eq_zero : ∀ a ∈ t₁ᶜ, cond_kernel_real ρ a { x : ℝ | (a, x) ∈ t₁ ×ˢ t₂ } = 0
+      suffices h_eq_zero : ∀ a ∈ t₁ᶜ, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = 0
       · rw [set_lintegral_congr_fun ht₁.compl (eventually_of_forall h_eq_zero)]
         simp only [lintegral_const, MulZeroClass.zero_mul]
       intro a hat₁
@@ -192,19 +193,19 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
     exact set_lintegral_cond_kernel_real_prod ρ ht₁ ht₂
   · intro t ht ht_eq
     calc
-      (∫⁻ a, cond_kernel_real ρ a { x : ℝ | (a, x) ∈ tᶜ } ∂ρ.fst) =
-          ∫⁻ a, cond_kernel_real ρ a ({ x : ℝ | (a, x) ∈ t }ᶜ) ∂ρ.fst :=
+      (∫⁻ a, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ tᶜ} ∂ρ.fst) =
+          ∫⁻ a, cond_kernel_real ρ a ({x : ℝ | (a, x) ∈ t}ᶜ) ∂ρ.fst :=
         rfl
-      _ = ∫⁻ a, cond_kernel_real ρ a univ - cond_kernel_real ρ a { x : ℝ | (a, x) ∈ t } ∂ρ.fst :=
+      _ = ∫⁻ a, cond_kernel_real ρ a univ - cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t} ∂ρ.fst :=
         by
         congr with a : 1
         exact measure_compl (measurable_prod_mk_left ht) (measure_ne_top (cond_kernel_real ρ a) _)
       _ =
           (∫⁻ a, cond_kernel_real ρ a univ ∂ρ.fst) -
-            ∫⁻ a, cond_kernel_real ρ a { x : ℝ | (a, x) ∈ t } ∂ρ.fst :=
+            ∫⁻ a, cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t} ∂ρ.fst :=
         by
         have h_le :
-          (fun a => cond_kernel_real ρ a { x : ℝ | (a, x) ∈ t }) ≤ᵐ[ρ.fst] fun a =>
+          (fun a => cond_kernel_real ρ a {x : ℝ | (a, x) ∈ t}) ≤ᵐ[ρ.fst] fun a =>
             cond_kernel_real ρ a univ :=
           eventually_of_forall fun a => measure_mono (subset_univ _)
         rw [lintegral_sub _ _ h_le]
@@ -216,13 +217,13 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       _ = ρ (tᶜ) := (measure_compl ht (measure_ne_top _ _)).symm
       
   · intro f hf_disj hf_meas hf_eq
-    have h_eq : ∀ a, { x | (a, x) ∈ ⋃ i, f i } = ⋃ i, { x | (a, x) ∈ f i } :=
+    have h_eq : ∀ a, {x | (a, x) ∈ ⋃ i, f i} = ⋃ i, {x | (a, x) ∈ f i} :=
       by
       intro a
       ext1 x
       simp only [mem_Union, mem_set_of_eq]
     simp_rw [h_eq]
-    have h_disj : ∀ a, Pairwise (Disjoint on fun i => { x | (a, x) ∈ f i }) :=
+    have h_disj : ∀ a, Pairwise (Disjoint on fun i => {x | (a, x) ∈ f i}) :=
       by
       intro a i j hij
       have h_disj := hf_disj hij
@@ -233,12 +234,12 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       suffices (a, x) ∈ ∅ by rwa [mem_empty_iff_false] at this 
       rwa [← h_disj, mem_inter_iff]
     calc
-      (∫⁻ a, cond_kernel_real ρ a (⋃ i, { x | (a, x) ∈ f i }) ∂ρ.fst) =
-          ∫⁻ a, ∑' i, cond_kernel_real ρ a { x | (a, x) ∈ f i } ∂ρ.fst :=
+      (∫⁻ a, cond_kernel_real ρ a (⋃ i, {x | (a, x) ∈ f i}) ∂ρ.fst) =
+          ∫⁻ a, ∑' i, cond_kernel_real ρ a {x | (a, x) ∈ f i} ∂ρ.fst :=
         by
         congr with a : 1
         rw [measure_Union (h_disj a) fun i => measurable_prod_mk_left (hf_meas i)]
-      _ = ∑' i, ∫⁻ a, cond_kernel_real ρ a { x | (a, x) ∈ f i } ∂ρ.fst :=
+      _ = ∑' i, ∫⁻ a, cond_kernel_real ρ a {x | (a, x) ∈ f i} ∂ρ.fst :=
         (lintegral_tsum fun i => (kernel.measurable_kernel_prod_mk_left (hf_meas i)).AEMeasurable)
       _ = ∑' i, ρ (f i) := by simp_rw [hf_eq]
       _ = ρ (Union f) := (measure_Union hf_disj hf_meas).symm
@@ -246,7 +247,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
 #align probability_theory.lintegral_cond_kernel_real_mem ProbabilityTheory.lintegral_condKernelReal_mem
 
 theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : Measure (α × ℝ))
-    [FiniteMeasure ρ] :
+    [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ (condKernelReal ρ) :=
   by
   ext (a s hs) : 2
@@ -268,13 +269,13 @@ theorem lintegral_condKernelReal {f : α × ℝ → ℝ≥0∞} (hf : Measurable
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.lintegral_cond_kernel_real ProbabilityTheory.lintegral_condKernelReal
 
-theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s)
-    (hρ : ρ { x | x.snd ∈ sᶜ } = 0) : ∀ᵐ a ∂ρ.fst, condKernelReal ρ a s = 1 :=
+theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ {x | x.snd ∈ sᶜ} = 0) :
+    ∀ᵐ a ∂ρ.fst, condKernelReal ρ a s = 1 :=
   by
   have h :
-    ρ { x | x.snd ∈ sᶜ } =
+    ρ {x | x.snd ∈ sᶜ} =
       (kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit (cond_kernel_real ρ)) ()
-        { x | x.snd ∈ sᶜ } :=
+        {x | x.snd ∈ sᶜ} :=
     by rw [← measure_eq_comp_prod_real]
   rw [hρ, kernel.comp_prod_apply] at h 
   swap; · exact measurable_snd hs.compl
@@ -285,7 +286,7 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s)
     exact kernel.measurable_coe _ hs.compl
   rw [kernel.const_apply] at h 
   simp only [mem_compl_iff, mem_set_of_eq, kernel.prod_mk_left_apply'] at h 
-  filter_upwards [h]with a ha
+  filter_upwards [h] with a ha
   change cond_kernel_real ρ a (sᶜ) = 0 at ha 
   rwa [prob_compl_eq_zero_iff hs] at ha 
   infer_instance
@@ -302,7 +303,7 @@ property on `ℝ` to all these spaces. -/
 
 
 variable {Ω : Type _} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω]
-  [Nonempty Ω] (ρ : Measure (α × Ω)) [FiniteMeasure ρ]
+  [Nonempty Ω] (ρ : Measure (α × Ω)) [IsFiniteMeasure ρ]
 
 /-- Existence of a conditional kernel. Use the definition `cond_kernel` to get that kernel. -/
 theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
@@ -317,14 +318,14 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
   -- however an issue: that `η` may not be a Markov kernel since its value is only a
   -- probability distribution almost everywhere with respect to `ρ.fst`, not everywhere.
   -- We modify it to obtain a Markov kernel which is almost everywhere equal.
-  let ρ_set := to_measurable ρ.fst ({ a | cond_kernel_real ρ' a (range f) = 1 }ᶜ)ᶜ
+  let ρ_set := to_measurable ρ.fst ({a | cond_kernel_real ρ' a (range f) = 1}ᶜ)ᶜ
   have hm : MeasurableSet ρ_set := (measurable_set_to_measurable _ _).compl
   have h_eq_one_of_mem : ∀ a ∈ ρ_set, cond_kernel_real ρ' a (range f) = 1 :=
     by
     intro a ha
     rw [mem_compl_iff] at ha 
-    have h_ss := subset_to_measurable ρ.fst ({ a : α | cond_kernel_real ρ' a (range f) = 1 }ᶜ)
-    suffices ha' : a ∉ { a : α | cond_kernel_real ρ' a (range f) = 1 }ᶜ
+    have h_ss := subset_to_measurable ρ.fst ({a : α | cond_kernel_real ρ' a (range f) = 1}ᶜ)
+    suffices ha' : a ∉ {a : α | cond_kernel_real ρ' a (range f) = 1}ᶜ
     · rwa [not_mem_compl_iff] at ha' 
     exact not_mem_subset h_ss ha
   have h_prod_embed : MeasurableEmbedding (Prod.map (id : α → α) f) :=
@@ -337,7 +338,7 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
   have h_ae : ∀ᵐ a ∂ρ.fst, a ∈ ρ_set := by
     rw [ae_iff]
     simp only [not_mem_compl_iff, set_of_mem_eq, measure_to_measurable]
-    change ρ.fst { a : α | a ∉ { a' : α | cond_kernel_real ρ' a' (range f) = 1 } } = 0
+    change ρ.fst {a : α | a ∉ {a' : α | cond_kernel_real ρ' a' (range f) = 1}} = 0
     rw [← ae_iff, ← h_fst]
     refine' ae_cond_kernel_real_eq_one ρ' hf.measurable_set_range _
     rw [measure.map_apply h_prod_embed.measurable]
@@ -347,52 +348,49 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     simp only [mem_compl_iff, mem_range, preimage_set_of_eq, Prod_map, mem_set_of_eq,
       mem_empty_iff_false, iff_false_iff, Classical.not_not, exists_apply_eq_apply]
   classical
-    obtain ⟨x₀, hx₀⟩ : ∃ x, x ∈ range f := range_nonempty _
-    let η' :=
-      kernel.piecewise hm (cond_kernel_real ρ')
-        (kernel.deterministic (fun _ => x₀) measurable_const)
-    -- We show that `kernel.comap_right η' hf` is a suitable Markov kernel.
-    refine' ⟨kernel.comap_right η' hf, _, _⟩
-    · refine' kernel.is_markov_kernel.comap_right _ _ fun a => _
-      rw [kernel.piecewise_apply']
-      split_ifs with h_mem h_not_mem
-      · exact h_eq_one_of_mem _ h_mem
-      ·
-        rw [kernel.deterministic_apply' _ _ hf.measurable_set_range, Set.indicator_apply,
-          if_pos hx₀]
-    have : kernel.const γ ρ = kernel.comap_right (kernel.const γ ρ') h_prod_embed :=
-      by
-      ext (c t ht) : 2
-      rw [kernel.const_apply, kernel.comap_right_apply' _ _ _ ht, kernel.const_apply,
-        measure.map_apply h_prod_embed.measurable (h_prod_embed.measurable_set_image.mpr ht)]
-      congr with x : 1
-      rw [← @Prod.mk.eta _ _ x]
-      simp only [id.def, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
-      refine' ⟨fun h => ⟨x.1, x.2, h, rfl, rfl⟩, _⟩
-      rintro ⟨a, b, h_mem, rfl, hf_eq⟩
-      rwa [hf.injective hf_eq] at h_mem 
-    rw [this, kernel.const_eq_comp_prod_real _ ρ']
+  obtain ⟨x₀, hx₀⟩ : ∃ x, x ∈ range f := range_nonempty _
+  let η' :=
+    kernel.piecewise hm (cond_kernel_real ρ') (kernel.deterministic (fun _ => x₀) measurable_const)
+  -- We show that `kernel.comap_right η' hf` is a suitable Markov kernel.
+  refine' ⟨kernel.comap_right η' hf, _, _⟩
+  · refine' kernel.is_markov_kernel.comap_right _ _ fun a => _
+    rw [kernel.piecewise_apply']
+    split_ifs with h_mem h_not_mem
+    · exact h_eq_one_of_mem _ h_mem
+    · rw [kernel.deterministic_apply' _ _ hf.measurable_set_range, Set.indicator_apply, if_pos hx₀]
+  have : kernel.const γ ρ = kernel.comap_right (kernel.const γ ρ') h_prod_embed :=
+    by
     ext (c t ht) : 2
-    rw [kernel.comap_right_apply' _ _ _ ht,
-      kernel.comp_prod_apply _ _ _ (h_prod_embed.measurable_set_image.mpr ht), kernel.const_apply,
-      h_fst, kernel.comp_prod_apply _ _ _ ht, kernel.const_apply]
-    refine' lintegral_congr_ae _
-    filter_upwards [h_ae]with a ha
-    rw [kernel.prod_mk_left_apply', kernel.prod_mk_left_apply', kernel.comap_right_apply']
-    swap
-    · exact measurable_prod_mk_left ht
-    have h1 : { c : ℝ | (a, c) ∈ Prod.map id f '' t } = f '' { c : Ω | (a, c) ∈ t } :=
-      by
-      ext1 x
-      simp only [Prod_map, id.def, mem_image, Prod.mk.inj_iff, Prod.exists, mem_set_of_eq]
-      constructor
-      · rintro ⟨a', b, h_mem, rfl, hf_eq⟩
-        exact ⟨b, h_mem, hf_eq⟩
-      · rintro ⟨b, h_mem, hf_eq⟩
-        exact ⟨a, b, h_mem, rfl, hf_eq⟩
-    have h2 : cond_kernel_real ρ' (c, a).snd = η' (c, a).snd := by
-      rw [kernel.piecewise_apply, if_pos ha]
-    rw [h1, h2]
+    rw [kernel.const_apply, kernel.comap_right_apply' _ _ _ ht, kernel.const_apply,
+      measure.map_apply h_prod_embed.measurable (h_prod_embed.measurable_set_image.mpr ht)]
+    congr with x : 1
+    rw [← @Prod.mk.eta _ _ x]
+    simp only [id.def, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
+    refine' ⟨fun h => ⟨x.1, x.2, h, rfl, rfl⟩, _⟩
+    rintro ⟨a, b, h_mem, rfl, hf_eq⟩
+    rwa [hf.injective hf_eq] at h_mem 
+  rw [this, kernel.const_eq_comp_prod_real _ ρ']
+  ext (c t ht) : 2
+  rw [kernel.comap_right_apply' _ _ _ ht,
+    kernel.comp_prod_apply _ _ _ (h_prod_embed.measurable_set_image.mpr ht), kernel.const_apply,
+    h_fst, kernel.comp_prod_apply _ _ _ ht, kernel.const_apply]
+  refine' lintegral_congr_ae _
+  filter_upwards [h_ae] with a ha
+  rw [kernel.prod_mk_left_apply', kernel.prod_mk_left_apply', kernel.comap_right_apply']
+  swap
+  · exact measurable_prod_mk_left ht
+  have h1 : {c : ℝ | (a, c) ∈ Prod.map id f '' t} = f '' {c : Ω | (a, c) ∈ t} :=
+    by
+    ext1 x
+    simp only [Prod_map, id.def, mem_image, Prod.mk.inj_iff, Prod.exists, mem_set_of_eq]
+    constructor
+    · rintro ⟨a', b, h_mem, rfl, hf_eq⟩
+      exact ⟨b, h_mem, hf_eq⟩
+    · rintro ⟨b, h_mem, hf_eq⟩
+      exact ⟨a, b, h_mem, rfl, hf_eq⟩
+  have h2 : cond_kernel_real ρ' (c, a).snd = η' (c, a).snd := by
+    rw [kernel.piecewise_apply, if_pos ha]
+  rw [h1, h2]
 #align probability_theory.exists_cond_kernel ProbabilityTheory.exists_cond_kernel
 
 /-- Conditional kernel of a measure on a product space: a Markov kernel such that
@@ -428,7 +426,7 @@ is Polish Borel, can be written as the composition-product of the constant kerne
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
 `probability_theory.cond_kernel ρ`. -/
 theorem kernel.const_eq_compProd (γ : Type _) [MeasurableSpace γ] (ρ : Measure (α × Ω))
-    [FiniteMeasure ρ] :
+    [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ ρ.condKernel :=
   by
   ext (a s hs) : 2
@@ -437,7 +435,7 @@ theorem kernel.const_eq_compProd (γ : Type _) [MeasurableSpace γ] (ρ : Measur
 #align probability_theory.kernel.const_eq_comp_prod ProbabilityTheory.kernel.const_eq_compProd
 
 theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
-    (∫⁻ a, ρ.condKernel a { x | (a, x) ∈ s } ∂ρ.fst) = ρ s :=
+    (∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst) = ρ s :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
   simp_rw [kernel.comp_prod_apply _ _ _ hs, kernel.const_apply, kernel.prod_mk_left_apply]
@@ -459,10 +457,10 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
   congr
   ext1 x
   classical
-    rw [indicator_apply]
-    split_ifs with hx
-    · simp only [hx, if_true, true_and_iff, set_of_mem_eq]
-    · simp only [hx, if_false, false_and_iff, set_of_false, measure_empty]
+  rw [indicator_apply]
+  split_ifs with hx
+  · simp only [hx, if_true, true_and_iff, set_of_mem_eq]
+  · simp only [hx, if_false, false_and_iff, set_of_false, measure_empty]
 #align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
 
 theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
@@ -503,14 +501,14 @@ section IntegralCondKernel
 variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
 
 theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α × Ω)}
-    [FiniteMeasure ρ] {f : α × Ω → E} (hf : AEStronglyMeasurable f ρ) :
+    [IsFiniteMeasure ρ] {f : α × Ω → E} (hf : AEStronglyMeasurable f ρ) :
     AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ρ.condKernel x) ρ.fst :=
   by
   rw [measure_eq_comp_prod ρ] at hf 
   exact ae_strongly_measurable.integral_kernel_comp_prod hf
 #align measure_theory.ae_strongly_measurable.integral_cond_kernel MeasureTheory.AEStronglyMeasurable.integral_condKernel
 
-theorem integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
+theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     (hf : Integrable f ρ) : (∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst) = ∫ ω, f ω ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
@@ -523,8 +521,9 @@ theorem integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem set_integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E} {s : Set α}
-    (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (s ×ˢ t) ρ) :
+theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
+    {s : Set α} (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t)
+    (hf : IntegrableOn f (s ×ˢ t) ρ) :
     (∫ a in s, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ t, f x ∂ρ :=
   by
   conv_rhs => rw [measure_eq_comp_prod ρ]
@@ -535,7 +534,7 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
+theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {s : Set α} (hs : MeasurableSet s) (hf : IntegrableOn f (s ×ˢ univ) ρ) :
     (∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ univ, f x ∂ρ := by
   rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]; simp_rw [measure.restrict_univ]
@@ -543,7 +542,7 @@ theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [FiniteMeas
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
+theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (univ ×ˢ t) ρ) :
     (∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in univ ×ˢ t, f x ∂ρ := by
   rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]; simp_rw [measure.restrict_univ]
@@ -566,7 +565,7 @@ open ProbabilityTheory
 
 variable {α Ω E F : Type _} {mα : MeasurableSpace α} [MeasurableSpace Ω] [TopologicalSpace Ω]
   [BorelSpace Ω] [PolishSpace Ω] [Nonempty Ω] [NormedAddCommGroup E] [NormedSpace ℝ E]
-  [CompleteSpace E] [NormedAddCommGroup F] {ρ : Measure (α × Ω)} [FiniteMeasure ρ]
+  [CompleteSpace E] [NormedAddCommGroup F] {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
 
 include mα
 
Diff
@@ -163,7 +163,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
     simp only [mem_empty_iff_false, set_of_false, measure_empty, lintegral_const,
       MulZeroClass.zero_mul]
   · intro t ht
-    rw [mem_image2] at ht
+    rw [mem_image2] at ht 
     obtain ⟨t₁, t₂, ht₁, ht₂, rfl⟩ := ht
     have h_prod_eq_snd : ∀ a ∈ t₁, { x : ℝ | (a, x) ∈ t₁ ×ˢ t₂ } = t₂ :=
       by
@@ -186,7 +186,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       · rw [set_lintegral_congr_fun ht₁.compl (eventually_of_forall h_eq_zero)]
         simp only [lintegral_const, MulZeroClass.zero_mul]
       intro a hat₁
-      rw [mem_compl_iff] at hat₁
+      rw [mem_compl_iff] at hat₁ 
       simp only [hat₁, prod_mk_mem_set_prod_eq, false_and_iff, set_of_false, measure_empty]
     rw [h_eq1, h_eq2, add_zero]
     exact set_lintegral_cond_kernel_real_prod ρ ht₁ ht₂
@@ -226,11 +226,11 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       by
       intro a i j hij
       have h_disj := hf_disj hij
-      rw [Function.onFun, disjoint_iff_inter_eq_empty] at h_disj⊢
+      rw [Function.onFun, disjoint_iff_inter_eq_empty] at h_disj ⊢
       ext1 x
       simp only [mem_inter_iff, mem_set_of_eq, mem_empty_iff_false, iff_false_iff]
       intro h_mem_both
-      suffices (a, x) ∈ ∅ by rwa [mem_empty_iff_false] at this
+      suffices (a, x) ∈ ∅ by rwa [mem_empty_iff_false] at this 
       rwa [← h_disj, mem_inter_iff]
     calc
       (∫⁻ a, cond_kernel_real ρ a (⋃ i, { x | (a, x) ∈ f i }) ∂ρ.fst) =
@@ -276,18 +276,18 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s)
       (kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit (cond_kernel_real ρ)) ()
         { x | x.snd ∈ sᶜ } :=
     by rw [← measure_eq_comp_prod_real]
-  rw [hρ, kernel.comp_prod_apply] at h
+  rw [hρ, kernel.comp_prod_apply] at h 
   swap; · exact measurable_snd hs.compl
-  rw [eq_comm, lintegral_eq_zero_iff] at h
+  rw [eq_comm, lintegral_eq_zero_iff] at h 
   swap
   · simp_rw [kernel.prod_mk_left_apply']
     simp only [mem_compl_iff, mem_set_of_eq]
     exact kernel.measurable_coe _ hs.compl
-  rw [kernel.const_apply] at h
-  simp only [mem_compl_iff, mem_set_of_eq, kernel.prod_mk_left_apply'] at h
+  rw [kernel.const_apply] at h 
+  simp only [mem_compl_iff, mem_set_of_eq, kernel.prod_mk_left_apply'] at h 
   filter_upwards [h]with a ha
-  change cond_kernel_real ρ a (sᶜ) = 0 at ha
-  rwa [prob_compl_eq_zero_iff hs] at ha
+  change cond_kernel_real ρ a (sᶜ) = 0 at ha 
+  rwa [prob_compl_eq_zero_iff hs] at ha 
   infer_instance
 #align probability_theory.ae_cond_kernel_real_eq_one ProbabilityTheory.ae_condKernelReal_eq_one
 
@@ -306,7 +306,7 @@ variable {Ω : Type _} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace 
 
 /-- Existence of a conditional kernel. Use the definition `cond_kernel` to get that kernel. -/
 theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
-    ∃ (η : kernel α Ω)(h : IsMarkovKernel η),
+    ∃ (η : kernel α Ω) (h : IsMarkovKernel η),
       kernel.const γ ρ =
         @kernel.compProd γ α _ _ Ω _ (kernel.const γ ρ.fst) _ (kernel.prodMkLeft γ η)
           (by haveI := h; infer_instance) :=
@@ -322,10 +322,10 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
   have h_eq_one_of_mem : ∀ a ∈ ρ_set, cond_kernel_real ρ' a (range f) = 1 :=
     by
     intro a ha
-    rw [mem_compl_iff] at ha
+    rw [mem_compl_iff] at ha 
     have h_ss := subset_to_measurable ρ.fst ({ a : α | cond_kernel_real ρ' a (range f) = 1 }ᶜ)
     suffices ha' : a ∉ { a : α | cond_kernel_real ρ' a (range f) = 1 }ᶜ
-    · rwa [not_mem_compl_iff] at ha'
+    · rwa [not_mem_compl_iff] at ha' 
     exact not_mem_subset h_ss ha
   have h_prod_embed : MeasurableEmbedding (Prod.map (id : α → α) f) :=
     MeasurableEmbedding.id.prod_mk hf
@@ -370,7 +370,7 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
       simp only [id.def, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
       refine' ⟨fun h => ⟨x.1, x.2, h, rfl, rfl⟩, _⟩
       rintro ⟨a, b, h_mem, rfl, hf_eq⟩
-      rwa [hf.injective hf_eq] at h_mem
+      rwa [hf.injective hf_eq] at h_mem 
     rw [this, kernel.const_eq_comp_prod_real _ ρ']
     ext (c t ht) : 2
     rw [kernel.comap_right_apply' _ _ _ ht,
@@ -452,7 +452,7 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
   have :
     ρ (s ×ˢ t) =
       ((kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit ρ.cond_kernel) ()) (s ×ˢ t) :=
-    by congr ; exact measure_eq_comp_prod ρ
+    by congr; exact measure_eq_comp_prod ρ
   rw [this, kernel.comp_prod_apply _ _ _ (hs.prod ht)]
   simp only [prod_mk_mem_set_prod_eq, kernel.lintegral_const, kernel.prod_mk_left_apply]
   rw [← lintegral_indicator _ hs]
@@ -506,7 +506,7 @@ theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α
     [FiniteMeasure ρ] {f : α × Ω → E} (hf : AEStronglyMeasurable f ρ) :
     AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ρ.condKernel x) ρ.fst :=
   by
-  rw [measure_eq_comp_prod ρ] at hf
+  rw [measure_eq_comp_prod ρ] at hf 
   exact ae_strongly_measurable.integral_kernel_comp_prod hf
 #align measure_theory.ae_strongly_measurable.integral_cond_kernel MeasureTheory.AEStronglyMeasurable.integral_condKernel
 
@@ -516,7 +516,7 @@ theorem integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α
   conv_rhs => rw [measure_eq_comp_prod ρ]
   have hf' :
     integrable f ((kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit ρ.cond_kernel) ()) := by
-    rwa [measure_eq_comp_prod ρ] at hf
+    rwa [measure_eq_comp_prod ρ] at hf 
   rw [integral_comp_prod hf', kernel.const_apply]
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.integral_cond_kernel ProbabilityTheory.integral_condKernel
@@ -530,7 +530,7 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f
   conv_rhs => rw [measure_eq_comp_prod ρ]
   rw [set_integral_comp_prod hs ht]
   · simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
-  · rwa [measure_eq_comp_prod ρ] at hf
+  · rwa [measure_eq_comp_prod ρ] at hf 
 #align probability_theory.set_integral_cond_kernel ProbabilityTheory.set_integral_condKernel
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -576,7 +576,7 @@ theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
         Integrable (fun a => ∫ ω, ‖f (a, ω)‖ ∂ρ.condKernel a) ρ.fst ↔
       Integrable f ρ :=
   by
-  rw [measure_eq_comp_prod ρ] at hf
+  rw [measure_eq_comp_prod ρ] at hf 
   conv_rhs => rw [measure_eq_comp_prod ρ]
   rw [integrable_comp_prod_iff hf]
   simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
@@ -586,7 +586,7 @@ theorem Integrable.condKernel_ae {f : α × Ω → F} (hf_int : Integrable f ρ)
     ∀ᵐ a ∂ρ.fst, Integrable (fun ω => f (a, ω)) (ρ.condKernel a) :=
   by
   have hf_ae : ae_strongly_measurable f ρ := hf_int.1
-  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int
+  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int 
   exact hf_int.1
 #align measure_theory.integrable.cond_kernel_ae MeasureTheory.Integrable.condKernel_ae
 
@@ -594,7 +594,7 @@ theorem Integrable.integral_norm_condKernel {f : α × Ω → F} (hf_int : Integ
     Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ρ.condKernel x) ρ.fst :=
   by
   have hf_ae : ae_strongly_measurable f ρ := hf_int.1
-  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int
+  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int 
   exact hf_int.2
 #align measure_theory.integrable.integral_norm_cond_kernel MeasureTheory.Integrable.integral_norm_condKernel
 
Diff
@@ -51,7 +51,7 @@ function `cond_cdf ρ a` (the conditional cumulative distribution function).
 
 open MeasureTheory Set Filter
 
-open ENNReal MeasureTheory Topology ProbabilityTheory
+open scoped ENNReal MeasureTheory Topology ProbabilityTheory
 
 namespace ProbabilityTheory
 
Diff
@@ -73,9 +73,7 @@ noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ
 #align probability_theory.cond_kernel_real ProbabilityTheory.condKernelReal
 
 instance (ρ : Measure (α × ℝ)) : IsMarkovKernel (condKernelReal ρ) :=
-  ⟨fun a => by
-    rw [cond_kernel_real]
-    infer_instance⟩
+  ⟨fun a => by rw [cond_kernel_real]; infer_instance⟩
 
 theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
     condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCdf ρ a x) :=
@@ -84,10 +82,8 @@ theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernelReal_Iic (ρ : Measure (α × ℝ)) [FiniteMeasure ρ] (x : ℝ) {s : Set α}
-    (hs : MeasurableSet s) : (∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst) = ρ (s ×ˢ Iic x) :=
-  by
-  simp_rw [cond_kernel_real_Iic]
-  exact set_lintegral_cond_cdf ρ x hs
+    (hs : MeasurableSet s) : (∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst) = ρ (s ×ˢ Iic x) := by
+  simp_rw [cond_kernel_real_Iic]; exact set_lintegral_cond_cdf ρ x hs
 #align probability_theory.set_lintegral_cond_kernel_real_Iic ProbabilityTheory.set_lintegral_condKernelReal_Iic
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -123,9 +119,7 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
     calc
       (∫⁻ a in s, cond_kernel_real ρ a (tᶜ) ∂ρ.fst) =
           ∫⁻ a in s, cond_kernel_real ρ a univ - cond_kernel_real ρ a t ∂ρ.fst :=
-        by
-        congr with a
-        rw [measure_compl ht (measure_ne_top (cond_kernel_real ρ a) _)]
+        by congr with a; rw [measure_compl ht (measure_ne_top (cond_kernel_real ρ a) _)]
       _ =
           (∫⁻ a in s, cond_kernel_real ρ a univ ∂ρ.fst) -
             ∫⁻ a in s, cond_kernel_real ρ a t ∂ρ.fst :=
@@ -283,8 +277,7 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s)
         { x | x.snd ∈ sᶜ } :=
     by rw [← measure_eq_comp_prod_real]
   rw [hρ, kernel.comp_prod_apply] at h
-  swap
-  · exact measurable_snd hs.compl
+  swap; · exact measurable_snd hs.compl
   rw [eq_comm, lintegral_eq_zero_iff] at h
   swap
   · simp_rw [kernel.prod_mk_left_apply']
@@ -316,9 +309,7 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     ∃ (η : kernel α Ω)(h : IsMarkovKernel η),
       kernel.const γ ρ =
         @kernel.compProd γ α _ _ Ω _ (kernel.const γ ρ.fst) _ (kernel.prodMkLeft γ η)
-          (by
-            haveI := h
-            infer_instance) :=
+          (by haveI := h; infer_instance) :=
   by
   obtain ⟨f, hf⟩ := exists_measurable_embedding_real Ω
   let ρ' : Measure (α × ℝ) := ρ.map (Prod.map id f)
@@ -350,8 +341,7 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
     rw [← ae_iff, ← h_fst]
     refine' ae_cond_kernel_real_eq_one ρ' hf.measurable_set_range _
     rw [measure.map_apply h_prod_embed.measurable]
-    swap
-    · exact measurable_snd hf.measurable_set_range.compl
+    swap; · exact measurable_snd hf.measurable_set_range.compl
     convert measure_empty
     ext1 x
     simp only [mem_compl_iff, mem_range, preimage_set_of_eq, Prod_map, mem_set_of_eq,
@@ -416,16 +406,12 @@ theorem condKernel_def : ρ.condKernel = (exists_cond_kernel ρ Unit).some := by
   rw [MeasureTheory.Measure.condKernel]
 #align probability_theory.cond_kernel_def ProbabilityTheory.condKernel_def
 
-instance : IsMarkovKernel ρ.condKernel :=
-  by
-  rw [cond_kernel_def]
+instance : IsMarkovKernel ρ.condKernel := by rw [cond_kernel_def];
   exact (exists_cond_kernel ρ Unit).choose_spec.some
 
 theorem kernel.const_unit_eq_compProd :
-    kernel.const Unit ρ = kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel :=
-  by
-  simp_rw [cond_kernel_def]
-  exact (exists_cond_kernel ρ Unit).choose_spec.choose_spec
+    kernel.const Unit ρ = kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel := by
+  simp_rw [cond_kernel_def]; exact (exists_cond_kernel ρ Unit).choose_spec.choose_spec
 #align probability_theory.kernel.const_unit_eq_comp_prod ProbabilityTheory.kernel.const_unit_eq_compProd
 
 /-- **Disintegration** of finite product measures on `α × Ω`, where `Ω` is Polish Borel. Such a
@@ -466,9 +452,7 @@ theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSe
   have :
     ρ (s ×ˢ t) =
       ((kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit ρ.cond_kernel) ()) (s ×ˢ t) :=
-    by
-    congr
-    exact measure_eq_comp_prod ρ
+    by congr ; exact measure_eq_comp_prod ρ
   rw [this, kernel.comp_prod_apply _ _ _ (hs.prod ht)]
   simp only [prod_mk_mem_set_prod_eq, kernel.lintegral_const, kernel.prod_mk_left_apply]
   rw [← lintegral_indicator _ hs]
@@ -503,19 +487,15 @@ theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernel_univ_right {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
     (hs : MeasurableSet s) :
-    (∫⁻ a in s, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in s ×ˢ univ, f x ∂ρ :=
-  by
-  rw [← set_lintegral_cond_kernel ρ hf hs MeasurableSet.univ]
-  simp_rw [measure.restrict_univ]
+    (∫⁻ a in s, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in s ×ˢ univ, f x ∂ρ := by
+  rw [← set_lintegral_cond_kernel ρ hf hs MeasurableSet.univ]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_lintegral_cond_kernel_univ_right ProbabilityTheory.set_lintegral_condKernel_univ_right
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_lintegral_condKernel_univ_left {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {t : Set Ω}
     (ht : MeasurableSet t) :
-    (∫⁻ a, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in univ ×ˢ t, f x ∂ρ :=
-  by
-  rw [← set_lintegral_cond_kernel ρ hf MeasurableSet.univ ht]
-  simp_rw [measure.restrict_univ]
+    (∫⁻ a, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in univ ×ˢ t, f x ∂ρ := by
+  rw [← set_lintegral_cond_kernel ρ hf MeasurableSet.univ ht]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_lintegral_cond_kernel_univ_left ProbabilityTheory.set_lintegral_condKernel_univ_left
 
 section IntegralCondKernel
@@ -557,20 +537,16 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
     {s : Set α} (hs : MeasurableSet s) (hf : IntegrableOn f (s ×ˢ univ) ρ) :
-    (∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ univ, f x ∂ρ :=
-  by
-  rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]
-  simp_rw [measure.restrict_univ]
+    (∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ univ, f x ∂ρ := by
+  rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_integral_cond_kernel_univ_right ProbabilityTheory.set_integral_condKernel_univ_right
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
     {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (univ ×ˢ t) ρ) :
-    (∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in univ ×ˢ t, f x ∂ρ :=
-  by
-  rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]
-  simp_rw [measure.restrict_univ]
+    (∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in univ ×ˢ t, f x ∂ρ := by
+  rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]; simp_rw [measure.restrict_univ]
 #align probability_theory.set_integral_cond_kernel_univ_left ProbabilityTheory.set_integral_condKernel_univ_left
 
 end IntegralCondKernel
Diff
@@ -4,12 +4,13 @@ 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.disintegration
-! leanprover-community/mathlib commit 3b88f4005dc2e28d42f974cc1ce838f0dafb39b8
+! leanprover-community/mathlib commit 6315581f5650ffa2fbdbbbedc41243c8d7070981
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.Probability.Kernel.CondCdf
 import Mathbin.MeasureTheory.Constructions.Polish
+import Mathbin.Probability.Kernel.IntegralCompProd
 
 /-!
 # Disintegration of measures on product spaces
@@ -456,6 +457,30 @@ theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
   simp_rw [kernel.comp_prod_apply _ _ _ hs, kernel.const_apply, kernel.prod_mk_left_apply]
 #align probability_theory.lintegral_cond_kernel_mem ProbabilityTheory.lintegral_condKernel_mem
 
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSet s) {t : Set Ω}
+    (ht : MeasurableSet t) : (∫⁻ a in s, ρ.condKernel a t ∂ρ.fst) = ρ (s ×ˢ t) :=
+  by
+  have :
+    ρ (s ×ˢ t) =
+      ((kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit ρ.cond_kernel) ()) (s ×ˢ t) :=
+    by
+    congr
+    exact measure_eq_comp_prod ρ
+  rw [this, kernel.comp_prod_apply _ _ _ (hs.prod ht)]
+  simp only [prod_mk_mem_set_prod_eq, kernel.lintegral_const, kernel.prod_mk_left_apply]
+  rw [← lintegral_indicator _ hs]
+  congr
+  ext1 x
+  classical
+    rw [indicator_apply]
+    split_ifs with hx
+    · simp only [hx, if_true, true_and_iff, set_of_mem_eq]
+    · simp only [hx, if_false, false_and_iff, set_of_false, measure_empty]
+#align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
+
 theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
     (∫⁻ a, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x, f x ∂ρ :=
   by
@@ -464,7 +489,153 @@ theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
   simp_rw [kernel.prod_mk_left_apply]
 #align probability_theory.lintegral_cond_kernel ProbabilityTheory.lintegral_condKernel
 
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
+    (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) :
+    (∫⁻ a in s, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in s ×ˢ t, f x ∂ρ :=
+  by
+  conv_rhs => rw [measure_eq_comp_prod ρ]
+  simp_rw [← kernel.restrict_apply _ (hs.prod ht), ← kernel.comp_prod_restrict,
+    kernel.lintegral_comp_prod _ _ _ hf, kernel.restrict_apply, kernel.const_apply,
+    kernel.prod_mk_left_apply]
+#align probability_theory.set_lintegral_cond_kernel ProbabilityTheory.set_lintegral_condKernel
+
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+theorem set_lintegral_condKernel_univ_right {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
+    (hs : MeasurableSet s) :
+    (∫⁻ a in s, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in s ×ˢ univ, f x ∂ρ :=
+  by
+  rw [← set_lintegral_cond_kernel ρ hf hs MeasurableSet.univ]
+  simp_rw [measure.restrict_univ]
+#align probability_theory.set_lintegral_cond_kernel_univ_right ProbabilityTheory.set_lintegral_condKernel_univ_right
+
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+theorem set_lintegral_condKernel_univ_left {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {t : Set Ω}
+    (ht : MeasurableSet t) :
+    (∫⁻ a, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫⁻ x in univ ×ˢ t, f x ∂ρ :=
+  by
+  rw [← set_lintegral_cond_kernel ρ hf MeasurableSet.univ ht]
+  simp_rw [measure.restrict_univ]
+#align probability_theory.set_lintegral_cond_kernel_univ_left ProbabilityTheory.set_lintegral_condKernel_univ_left
+
+section IntegralCondKernel
+
+variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+
+theorem MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α × Ω)}
+    [FiniteMeasure ρ] {f : α × Ω → E} (hf : AEStronglyMeasurable f ρ) :
+    AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ρ.condKernel x) ρ.fst :=
+  by
+  rw [measure_eq_comp_prod ρ] at hf
+  exact ae_strongly_measurable.integral_kernel_comp_prod hf
+#align measure_theory.ae_strongly_measurable.integral_cond_kernel MeasureTheory.AEStronglyMeasurable.integral_condKernel
+
+theorem integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
+    (hf : Integrable f ρ) : (∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst) = ∫ ω, f ω ∂ρ :=
+  by
+  conv_rhs => rw [measure_eq_comp_prod ρ]
+  have hf' :
+    integrable f ((kernel.const Unit ρ.fst ⊗ₖ kernel.prod_mk_left Unit ρ.cond_kernel) ()) := by
+    rwa [measure_eq_comp_prod ρ] at hf
+  rw [integral_comp_prod hf', kernel.const_apply]
+  simp_rw [kernel.prod_mk_left_apply]
+#align probability_theory.integral_cond_kernel ProbabilityTheory.integral_condKernel
+
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+theorem set_integral_condKernel {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E} {s : Set α}
+    (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (s ×ˢ t) ρ) :
+    (∫ a in s, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ t, f x ∂ρ :=
+  by
+  conv_rhs => rw [measure_eq_comp_prod ρ]
+  rw [set_integral_comp_prod hs ht]
+  · simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
+  · rwa [measure_eq_comp_prod ρ] at hf
+#align probability_theory.set_integral_cond_kernel ProbabilityTheory.set_integral_condKernel
+
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
+    {s : Set α} (hs : MeasurableSet s) (hf : IntegrableOn f (s ×ˢ univ) ρ) :
+    (∫ a in s, ∫ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in s ×ˢ univ, f x ∂ρ :=
+  by
+  rw [← set_integral_cond_kernel hs MeasurableSet.univ hf]
+  simp_rw [measure.restrict_univ]
+#align probability_theory.set_integral_cond_kernel_univ_right ProbabilityTheory.set_integral_condKernel_univ_right
+
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [FiniteMeasure ρ] {f : α × Ω → E}
+    {t : Set Ω} (ht : MeasurableSet t) (hf : IntegrableOn f (univ ×ˢ t) ρ) :
+    (∫ a, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst) = ∫ x in univ ×ˢ t, f x ∂ρ :=
+  by
+  rw [← set_integral_cond_kernel MeasurableSet.univ ht hf]
+  simp_rw [measure.restrict_univ]
+#align probability_theory.set_integral_cond_kernel_univ_left ProbabilityTheory.set_integral_condKernel_univ_left
+
+end IntegralCondKernel
+
 end Polish
 
 end ProbabilityTheory
 
+namespace MeasureTheory
+
+/-! ### Integrability
+
+We place these lemmas in the `measure_theory` namespace to enable dot notation. -/
+
+
+open ProbabilityTheory
+
+variable {α Ω E F : Type _} {mα : MeasurableSpace α} [MeasurableSpace Ω] [TopologicalSpace Ω]
+  [BorelSpace Ω] [PolishSpace Ω] [Nonempty Ω] [NormedAddCommGroup E] [NormedSpace ℝ E]
+  [CompleteSpace E] [NormedAddCommGroup F] {ρ : Measure (α × Ω)} [FiniteMeasure ρ]
+
+include mα
+
+theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
+    (hf : AEStronglyMeasurable f ρ) :
+    (∀ᵐ a ∂ρ.fst, Integrable (fun ω => f (a, ω)) (ρ.condKernel a)) ∧
+        Integrable (fun a => ∫ ω, ‖f (a, ω)‖ ∂ρ.condKernel a) ρ.fst ↔
+      Integrable f ρ :=
+  by
+  rw [measure_eq_comp_prod ρ] at hf
+  conv_rhs => rw [measure_eq_comp_prod ρ]
+  rw [integrable_comp_prod_iff hf]
+  simp_rw [kernel.prod_mk_left_apply, kernel.const_apply]
+#align measure_theory.ae_strongly_measurable.ae_integrable_cond_kernel_iff MeasureTheory.AEStronglyMeasurable.ae_integrable_condKernel_iff
+
+theorem Integrable.condKernel_ae {f : α × Ω → F} (hf_int : Integrable f ρ) :
+    ∀ᵐ a ∂ρ.fst, Integrable (fun ω => f (a, ω)) (ρ.condKernel a) :=
+  by
+  have hf_ae : ae_strongly_measurable f ρ := hf_int.1
+  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int
+  exact hf_int.1
+#align measure_theory.integrable.cond_kernel_ae MeasureTheory.Integrable.condKernel_ae
+
+theorem Integrable.integral_norm_condKernel {f : α × Ω → F} (hf_int : Integrable f ρ) :
+    Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ρ.condKernel x) ρ.fst :=
+  by
+  have hf_ae : ae_strongly_measurable f ρ := hf_int.1
+  rw [← hf_ae.ae_integrable_cond_kernel_iff] at hf_int
+  exact hf_int.2
+#align measure_theory.integrable.integral_norm_cond_kernel MeasureTheory.Integrable.integral_norm_condKernel
+
+theorem Integrable.norm_integral_condKernel {f : α × Ω → E} (hf_int : Integrable f ρ) :
+    Integrable (fun x => ‖∫ y, f (x, y) ∂ρ.condKernel x‖) ρ.fst :=
+  by
+  refine' hf_int.integral_norm_cond_kernel.mono hf_int.1.integral_condKernel.norm _
+  refine' eventually_of_forall fun x => _
+  rw [norm_norm]
+  refine' (norm_integral_le_integral_norm _).trans_eq (Real.norm_of_nonneg _).symm
+  exact integral_nonneg_of_ae (eventually_of_forall fun y => norm_nonneg _)
+#align measure_theory.integrable.norm_integral_cond_kernel MeasureTheory.Integrable.norm_integral_condKernel
+
+theorem Integrable.integral_condKernel {f : α × Ω → E} (hf_int : Integrable f ρ) :
+    Integrable (fun x => ∫ y, f (x, y) ∂ρ.condKernel x) ρ.fst :=
+  (integrable_norm_iff hf_int.1.integral_condKernel).mp hf_int.norm_integral_condKernel
+#align measure_theory.integrable.integral_cond_kernel MeasureTheory.Integrable.integral_condKernel
+
+end MeasureTheory
+

Changes in mathlib4

mathlib3
mathlib4
chore: replace set_integral with setIntegral (#12215)

Done with a global search and replace, and then (to fix the #align lines), replace (#align \S*)setIntegral with $1set_integral.

Diff
@@ -126,7 +126,7 @@ lemma isRatCondKernelCDFAux_density_Iic (κ : kernel α (γ × ℝ)) [IsFiniteKe
       refine ⟨i, hq.le.trans ?_⟩
       exact mod_cast hi i le_rfl
   integrable a q := integrable_density le_rfl a measurableSet_Iic
-  set_integral a A hA q := set_integral_density le_rfl a measurableSet_Iic hA
+  setIntegral a A hA q := setIntegral_density le_rfl a measurableSet_Iic hA
 
 /-- Taking the kernel density of intervals `Iic q` for `q : ℚ` gives a function with the property
 `isRatCondKernelCDF`. -/
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>

chore: avoid id.def (adaptation for nightly-2024-03-27) (#11829)

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

Diff
@@ -304,7 +304,7 @@ theorem exists_cond_kernel (γ : Type*) [MeasurableSpace γ] :
       Measure.map_apply h_prod_embed.measurable (h_prod_embed.measurableSet_image.mpr ht)]
     congr with x : 1
     rw [← @Prod.mk.eta _ _ x]
-    simp only [id.def, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
+    simp only [id, mem_preimage, Prod.map_mk, mem_image, Prod.mk.inj_iff, Prod.exists]
     refine' ⟨fun h => ⟨x.1, x.2, h, rfl, rfl⟩, _⟩
     rintro ⟨a, b, h_mem, rfl, hf_eq⟩
     rwa [hf.injective hf_eq] at h_mem
@@ -320,7 +320,7 @@ theorem exists_cond_kernel (γ : Type*) [MeasurableSpace γ] :
   · exact measurable_prod_mk_left ht
   have h1 : {c : ℝ | (a, c) ∈ Prod.map id f '' t} = f '' {c : Ω | (a, c) ∈ t} := by
     ext1 x
-    simp only [Prod_map, id.def, mem_image, Prod.mk.inj_iff, Prod.exists, mem_setOf_eq]
+    simp only [Prod_map, id, mem_image, Prod.mk.inj_iff, Prod.exists, mem_setOf_eq]
     constructor
     · rintro ⟨a', b, h_mem, rfl, hf_eq⟩
       exact ⟨b, h_mem, hf_eq⟩
refactor: use CdfToKernel in CondCdf (#11529)

The recently added file CdfToKernel contains generalizations of many lemmas in the file CondCdf. This PR refactors CondCdf to use the new results.

Co-authored-by: Rémy Degenne <remydegenne@gmail.com>

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, Kexing Ying
 -/
-import Mathlib.Probability.Kernel.CondCdf
+import Mathlib.Probability.Kernel.Disintegration.CondCdf
 import Mathlib.MeasureTheory.Constructions.Polish
 import Mathlib.Probability.Kernel.MeasureCompProd
 
@@ -66,7 +66,7 @@ noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ wher
 #align probability_theory.cond_kernel_real ProbabilityTheory.condKernelReal
 
 instance (ρ : Measure (α × ℝ)) : IsMarkovKernel (condKernelReal ρ) :=
-  ⟨fun a => by rw [condKernelReal]; exact instIsProbabilityMeasure ρ a⟩
+  ⟨fun a => by rw [condKernelReal]; exact instIsProbabilityMeasureCondCDF ρ a⟩
 
 theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
     condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCDF ρ a x) :=
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
@@ -534,7 +534,7 @@ lemma eq_condKernel_of_measure_eq_compProd_real (ρ : Measure (α × ℝ)) [IsFi
     exact ae_all_iff.2 fun q => eq_condKernel_of_measure_eq_compProd' ρ κ hκ measurableSet_Iic
   · filter_upwards [huniv] with x hxuniv t ht heq
     rw [measure_compl ht <| measure_ne_top _ _, heq, hxuniv, measure_compl ht <| measure_ne_top _ _]
-  · refine' ae_of_all _ (fun x f hdisj hf heq => _)
+  · filter_upwards with x f hdisj hf heq
     rw [measure_iUnion hdisj hf, measure_iUnion hdisj hf]
     exact tsum_congr heq
 
@@ -643,7 +643,7 @@ theorem Integrable.integral_norm_condKernel {f : α × Ω → F} (hf_int : Integ
 theorem Integrable.norm_integral_condKernel {f : α × Ω → E} (hf_int : Integrable f ρ) :
     Integrable (fun x => ‖∫ y, f (x, y) ∂ρ.condKernel x‖) ρ.fst := by
   refine' hf_int.integral_norm_condKernel.mono hf_int.1.integral_condKernel.norm _
-  refine' eventually_of_forall fun x => _
+  filter_upwards with x
   rw [norm_norm]
   refine' (norm_integral_le_integral_norm _).trans_eq (Real.norm_of_nonneg _).symm
   exact integral_nonneg_of_ae (eventually_of_forall fun y => norm_nonneg _)
chore: more backporting of simp changes from #10995 (#11001)

Co-authored-by: Patrick Massot <patrickmassot@free.fr> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -277,7 +277,7 @@ theorem exists_cond_kernel (γ : Type*) [MeasurableSpace γ] :
     rfl
   have h_ae : ∀ᵐ a ∂ρ.fst, a ∈ ρ_set := by
     rw [ae_iff]
-    simp only [not_mem_compl_iff, setOf_mem_eq, measure_toMeasurable]
+    simp only [ρ_set, not_mem_compl_iff, setOf_mem_eq, measure_toMeasurable]
     change ρ.fst {a : α | a ∉ {a' : α | condKernelReal ρ' a' (range f) = 1}} = 0
     rw [← ae_iff, ← h_fst]
     refine' ae_condKernelReal_eq_one ρ' hf.measurableSet_range _
@@ -555,7 +555,7 @@ theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel
   have hρ'' : ∀ᵐ x ∂ρ'.fst, kernel.map κ f hf.measurable x = ρ'.condKernel x := by
     refine' eq_condKernel_of_measure_eq_compProd_real ρ' (kernel.map κ f hf.measurable) _
     ext s hs
-    simp only [Measure.map_apply (measurable_id.prod_map hf.measurable) hs]
+    simp only [ρ', Measure.map_apply (measurable_id.prod_map hf.measurable) hs]
     conv_lhs => congr; rw [hκ]
     rw [Measure.compProd_apply hs, Measure.compProd_apply
       (measurable_id.prod_map hf.measurable hs), (_ : (ρ.map (Prod.map id f)).fst = ρ.fst)]
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -149,8 +149,8 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       refine' set_lintegral_congr_fun ht₁ (eventually_of_forall fun a ha => _)
       rw [h_prod_eq_snd a ha]
     have h_eq2 : ∫⁻ a in t₁ᶜ, condKernelReal ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst = 0 := by
-      suffices h_eq_zero : ∀ a ∈ t₁ᶜ, condKernelReal ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = 0
-      · rw [set_lintegral_congr_fun ht₁.compl (eventually_of_forall h_eq_zero)]
+      suffices h_eq_zero : ∀ a ∈ t₁ᶜ, condKernelReal ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = 0 by
+        rw [set_lintegral_congr_fun ht₁.compl (eventually_of_forall h_eq_zero)]
         simp only [lintegral_const, zero_mul]
       intro a hat₁
       rw [mem_compl_iff] at hat₁
@@ -265,8 +265,8 @@ theorem exists_cond_kernel (γ : Type*) [MeasurableSpace γ] :
     intro a ha
     rw [mem_compl_iff] at ha
     have h_ss := subset_toMeasurable ρ.fst {a : α | condKernelReal ρ' a (range f) = 1}ᶜ
-    suffices ha' : a ∉ {a : α | condKernelReal ρ' a (range f) = 1}ᶜ
-    · rwa [not_mem_compl_iff] at ha'
+    suffices ha' : a ∉ {a : α | condKernelReal ρ' a (range f) = 1}ᶜ by
+      rwa [not_mem_compl_iff] at ha'
     exact not_mem_subset h_ss ha
   have h_prod_embed : MeasurableEmbedding (Prod.map (id : α → α) f) :=
     MeasurableEmbedding.id.prod_mk hf
@@ -524,8 +524,8 @@ lemma eq_condKernel_of_measure_eq_compProd_real (ρ : Measure (α × ℝ)) [IsFi
     ∀ᵐ x ∂ρ.fst, κ x = ρ.condKernel x := by
   have huniv : ∀ᵐ x ∂ρ.fst, κ x Set.univ = ρ.condKernel x Set.univ :=
     eq_condKernel_of_measure_eq_compProd' ρ κ hκ MeasurableSet.univ
-  suffices : ∀ᵐ x ∂ρ.fst, ∀ ⦃t⦄, MeasurableSet t → κ x t = ρ.condKernel x t
-  · filter_upwards [this] with x hx
+  suffices ∀ᵐ x ∂ρ.fst, ∀ ⦃t⦄, MeasurableSet t → κ x t = ρ.condKernel x t by
+    filter_upwards [this] with x hx
     ext t ht; exact hx ht
   apply MeasurableSpace.ae_induction_on_inter Real.borel_eq_generateFrom_Iic_rat
     Real.isPiSystem_Iic_rat
@@ -547,13 +547,13 @@ theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel
 -- and then constructing a measure on `α × ℝ` using the obtained measurable embedding
   obtain ⟨f, hf⟩ := exists_measurableEmbedding_real Ω
   set ρ' : Measure (α × ℝ) := ρ.map (Prod.map id f) with hρ'def
-  have hρ' : ρ'.fst = ρ.fst
-  · ext s hs
+  have hρ' : ρ'.fst = ρ.fst := by
+    ext s hs
     rw [hρ'def, Measure.fst_apply, Measure.fst_apply, Measure.map_apply]
     exacts [rfl, Measurable.prod measurable_fst <| hf.measurable.comp measurable_snd,
       measurable_fst hs, hs, hs]
-  have hρ'' : ∀ᵐ x ∂ρ'.fst, kernel.map κ f hf.measurable x = ρ'.condKernel x
-  · refine' eq_condKernel_of_measure_eq_compProd_real ρ' (kernel.map κ f hf.measurable) _
+  have hρ'' : ∀ᵐ x ∂ρ'.fst, kernel.map κ f hf.measurable x = ρ'.condKernel x := by
+    refine' eq_condKernel_of_measure_eq_compProd_real ρ' (kernel.map κ f hf.measurable) _
     ext s hs
     simp only [Measure.map_apply (measurable_id.prod_map hf.measurable) hs]
     conv_lhs => congr; rw [hκ]
@@ -569,23 +569,23 @@ theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel
       · simp only [Prod_map, id_eq]; rfl
       · exact (hf.measurable.comp measurable_snd)
   rw [hρ'] at hρ''
-  suffices : ∀ᵐ x ∂ρ.fst, ∀ s, MeasurableSet s →
-    ((ρ.map (Prod.map id f)).condKernel x) s = (ρ.condKernel x) (f ⁻¹' s)
-  · filter_upwards [hρ'', this] with x hx h
+  suffices ∀ᵐ x ∂ρ.fst, ∀ s, MeasurableSet s →
+      ((ρ.map (Prod.map id f)).condKernel x) s = (ρ.condKernel x) (f ⁻¹' s) by
+    filter_upwards [hρ'', this] with x hx h
     rw [kernel.map_apply] at hx
     ext s hs
     rw [← Set.preimage_image_eq s hf.injective,
       ← Measure.map_apply hf.measurable <| hf.measurableSet_image.2 hs, hx,
       h _ <| hf.measurableSet_image.2 hs]
-  have hprod : (ρ.map (Prod.map id f)).fst = ρ.fst
-  · ext s hs
+  have hprod : (ρ.map (Prod.map id f)).fst = ρ.fst := by
+    ext s hs
     rw [Measure.fst_apply hs,
       Measure.map_apply (measurable_id.prod_map hf.measurable) (measurable_fst hs),
       ← Set.preimage_comp, Measure.fst_apply hs]
     rfl
-  suffices : ρ.map (Prod.map id f) =
-    ((ρ.map (Prod.map id f)).fst ⊗ₘ (kernel.map (Measure.condKernel ρ) f hf.measurable))
-  · have heq := eq_condKernel_of_measure_eq_compProd_real _ _ this
+  suffices ρ.map (Prod.map id f) =
+      ((ρ.map (Prod.map id f)).fst ⊗ₘ (kernel.map (Measure.condKernel ρ) f hf.measurable)) by
+    have heq := eq_condKernel_of_measure_eq_compProd_real _ _ this
     rw [hprod] at heq
     filter_upwards [heq] with x hx s hs
     rw [← hx, kernel.map_apply, Measure.map_apply hf.measurable hs]
feat(Probability): condKernel and condDistrib applied to singletons of non-zero measure (#9351)

From the PFR project.

Diff
@@ -369,6 +369,44 @@ theorem kernel.const_eq_compProd (γ : Type*) [MeasurableSpace γ] (ρ : Measure
     kernel.ext_iff'.mp (kernel.const_unit_eq_compProd ρ) () s hs
 #align probability_theory.kernel.const_eq_comp_prod ProbabilityTheory.kernel.const_eq_compProd
 
+/-- Auxiliary lemma for `condKernel_apply_of_ne_zero`. -/
+lemma condKernel_apply_of_ne_zero_of_measurableSet [MeasurableSingletonClass α]
+    {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
+    {x : α} (hx : ρ.fst {x} ≠ 0) {s : Set Ω} (hs : MeasurableSet s) :
+    ρ.condKernel x s = (ρ.fst {x})⁻¹ * ρ ({x} ×ˢ s) := by
+  nth_rewrite 3 [measure_eq_compProd ρ]
+  rw [Measure.compProd_apply (measurableSet_prod.mpr (Or.inl ⟨measurableSet_singleton x, hs⟩))]
+  classical
+  have : ∀ a, ρ.condKernel a (Prod.mk a ⁻¹' {x} ×ˢ s)
+      = ({x} : Set α).indicator (fun a ↦ ρ.condKernel a s) a := by
+    intro a
+    by_cases hax : a = x
+    · simp only [hax, Set.singleton_prod, Set.mem_singleton_iff, Set.indicator_of_mem]
+      congr with y
+      simp
+    · simp only [Set.singleton_prod, Set.mem_singleton_iff, hax, not_false_eq_true,
+        Set.indicator_of_not_mem]
+      have : Prod.mk a ⁻¹' (Prod.mk x '' s) = ∅ := by
+        ext y
+        simp [Ne.symm hax]
+      simp only [this, measure_empty]
+  simp_rw [this]
+  rw [MeasureTheory.lintegral_indicator _ (measurableSet_singleton x)]
+  simp only [Measure.restrict_singleton, lintegral_smul_measure, lintegral_dirac]
+  rw [← mul_assoc, ENNReal.inv_mul_cancel hx (measure_ne_top ρ.fst _), one_mul]
+
+/-- If the singleton `{x}` has non-zero mass for `ρ.fst`, then for all `s : Set Ω`,
+`ρ.condKernel x s = (ρ.fst {x})⁻¹ * ρ ({x} ×ˢ s)` . -/
+lemma condKernel_apply_of_ne_zero [MeasurableSingletonClass α]
+    {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {x : α} (hx : ρ.fst {x} ≠ 0)
+    (s : Set Ω) :
+    ρ.condKernel x s = (ρ.fst {x})⁻¹ * ρ ({x} ×ˢ s) := by
+  have : ρ.condKernel x s = ((ρ.fst {x})⁻¹ • ρ).comap (fun (y : Ω) ↦ (x, y)) s := by
+    congr 2 with s hs
+    simp [condKernel_apply_of_ne_zero_of_measurableSet hx hs,
+      (measurableEmbedding_prod_mk_left x).comap_apply]
+  simp [this, (measurableEmbedding_prod_mk_left x).comap_apply, hx]
+
 theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
     ∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst = ρ s := by
   conv_rhs => rw [measure_eq_compProd ρ]
chore : fix camelcase naming of PDF, CDF and PMF (#9681)

Replaces occurences of Pdf, Cdf and Pmf within camelCase situations by PDF, CDF and PMF respectively.

Diff
@@ -25,7 +25,7 @@ where `ρ.fst` is the marginal measure of `ρ` on `α`. In particular, `ρ = ρ.
 In order to obtain a disintegration for any standard Borel space, we use that these spaces embed
 measurably into `ℝ`: it then suffices to define a suitable kernel for `Ω = ℝ`. In the real case,
 we define a conditional kernel by taking for each `a : α` the measure associated to the Stieltjes
-function `condCdf ρ a` (the conditional cumulative distribution function).
+function `condCDF ρ a` (the conditional cumulative distribution function).
 
 ## Main definitions
 
@@ -61,22 +61,22 @@ section Real
 /-- Conditional measure on the second space of the product given the value on the first, as a
 kernel. Use the more general `condKernel`. -/
 noncomputable def condKernelReal (ρ : Measure (α × ℝ)) : kernel α ℝ where
-  val a := (condCdf ρ a).measure
-  property := measurable_measure_condCdf ρ
+  val a := (condCDF ρ a).measure
+  property := measurable_measure_condCDF ρ
 #align probability_theory.cond_kernel_real ProbabilityTheory.condKernelReal
 
 instance (ρ : Measure (α × ℝ)) : IsMarkovKernel (condKernelReal ρ) :=
   ⟨fun a => by rw [condKernelReal]; exact instIsProbabilityMeasure ρ a⟩
 
 theorem condKernelReal_Iic (ρ : Measure (α × ℝ)) (a : α) (x : ℝ) :
-    condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCdf ρ a x) :=
-  measure_condCdf_Iic ρ a x
+    condKernelReal ρ a (Iic x) = ENNReal.ofReal (condCDF ρ a x) :=
+  measure_condCDF_Iic ρ a x
 #align probability_theory.cond_kernel_real_Iic ProbabilityTheory.condKernelReal_Iic
 
 theorem set_lintegral_condKernelReal_Iic (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] (x : ℝ)
     {s : Set α} (hs : MeasurableSet s) :
     ∫⁻ a in s, condKernelReal ρ a (Iic x) ∂ρ.fst = ρ (s ×ˢ Iic x) := by
-  simp_rw [condKernelReal_Iic]; exact set_lintegral_condCdf ρ x hs
+  simp_rw [condKernelReal_Iic]; exact set_lintegral_condCDF ρ x hs
 #align probability_theory.set_lintegral_cond_kernel_real_Iic ProbabilityTheory.set_lintegral_condKernelReal_Iic
 
 theorem set_lintegral_condKernelReal_univ (ρ : Measure (α × ℝ)) {s : Set α} (hs : MeasurableSet s) :
chore(*): drop $/<| before fun (#9361)

Subset of #9319

Diff
@@ -493,7 +493,7 @@ lemma eq_condKernel_of_measure_eq_compProd_real (ρ : Measure (α × ℝ)) [IsFi
     Real.isPiSystem_Iic_rat
   · simp only [OuterMeasure.empty', Filter.eventually_true]
   · simp only [iUnion_singleton_eq_range, mem_range, forall_exists_index, forall_apply_eq_imp_iff]
-    exact ae_all_iff.2 <| fun q => eq_condKernel_of_measure_eq_compProd' ρ κ hκ measurableSet_Iic
+    exact ae_all_iff.2 fun q => eq_condKernel_of_measure_eq_compProd' ρ κ hκ measurableSet_Iic
   · filter_upwards [huniv] with x hxuniv t ht heq
     rw [measure_compl ht <| measure_ne_top _ _, heq, hxuniv, measure_compl ht <| measure_ne_top _ _]
   · refine' ae_of_all _ (fun x f hdisj hf heq => _)
refactor(*): change definition of Set.image2 etc (#9275)
  • Redefine Set.image2 to use ∃ a ∈ s, ∃ b ∈ t, f a b = c instead of ∃ a b, a ∈ s ∧ b ∈ t ∧ f a b = c.
  • Redefine Set.seq as Set.image2. The new definition is equal to the old one but rw [Set.seq] gives a different result.
  • Redefine Filter.map₂ to use ∃ u ∈ f, ∃ v ∈ g, image2 m u v ⊆ s instead of ∃ u v, u ∈ f ∧ v ∈ g ∧ ...
  • Update lemmas like Set.mem_image2, Finset.mem_image₂, Set.mem_mul, Finset.mem_div etc

The two reasons to make the change are:

  • ∃ a ∈ s, ∃ b ∈ t, _ is a simp-normal form, and
  • it looks a bit nicer.
Diff
@@ -139,7 +139,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
   apply MeasurableSpace.induction_on_inter generateFrom_prod.symm isPiSystem_prod _ _ _ _ hs
   · simp only [mem_empty_iff_false, setOf_false, measure_empty, lintegral_const,
       zero_mul]
-  · rintro _ ⟨t₁, t₂, ht₁, ht₂, rfl⟩
+  · rintro _ ⟨t₁, ht₁, t₂, ht₂, rfl⟩
     have h_prod_eq_snd : ∀ a ∈ t₁, {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = t₂ := by
       intro a ha
       simp only [ha, prod_mk_mem_set_prod_eq, true_and_iff, setOf_mem_eq]
chore(*): use rintro to golf some proofs (#9204)
Diff
@@ -139,9 +139,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
   apply MeasurableSpace.induction_on_inter generateFrom_prod.symm isPiSystem_prod _ _ _ _ hs
   · simp only [mem_empty_iff_false, setOf_false, measure_empty, lintegral_const,
       zero_mul]
-  · intro t ht
-    rw [mem_image2] at ht
-    obtain ⟨t₁, t₂, ht₁, ht₂, rfl⟩ := ht
+  · rintro _ ⟨t₁, t₂, ht₁, ht₂, rfl⟩
     have h_prod_eq_snd : ∀ a ∈ t₁, {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = t₂ := by
       intro a ha
       simp only [ha, prod_mk_mem_set_prod_eq, true_and_iff, setOf_mem_eq]
chore: remove uses of cases' (#9171)

I literally went through and regex'd some uses of cases', replacing them with rcases; this is meant to be a low effort PR as I hope that tools can do this in the future.

rcases is an easier replacement than cases, though with better tools we could in future do a second pass converting simple rcases added here (and existing ones) to cases.

Diff
@@ -145,9 +145,6 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
     have h_prod_eq_snd : ∀ a ∈ t₁, {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = t₂ := by
       intro a ha
       simp only [ha, prod_mk_mem_set_prod_eq, true_and_iff, setOf_mem_eq]
-    cases' eq_empty_or_nonempty t₂ with h h
-    · simp only [h, prod_empty, mem_empty_iff_false, setOf_false, measure_empty, lintegral_const,
-        zero_mul]
     rw [← lintegral_add_compl _ ht₁]
     have h_eq1 : ∫⁻ a in t₁, condKernelReal ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst =
         ∫⁻ a in t₁, condKernelReal ρ a t₂ ∂ρ.fst := by
feat: define the composition-product of a measure and a kernel (#8852)

The composition-product of a measure and a kernel, denoted by ⊗ₘ, takes μ : Measure α and κ : kernel α β and creates μ ⊗ₘ κ : Measure (α × β). The integral of a function against μ ⊗ₘ κ is ∫⁻ x, f x ∂(μ ⊗ₘ κ) = ∫⁻ a, ∫⁻ b, f (a, b) ∂(κ a) ∂μ.

This PR also modifies the Disintegration file to use the new definition.

From the PFR project.

Co-authored-by: Rémy Degenne <remydegenne@gmail.com>

Diff
@@ -5,7 +5,7 @@ Authors: Rémy Degenne, Kexing Ying
 -/
 import Mathlib.Probability.Kernel.CondCdf
 import Mathlib.MeasureTheory.Constructions.Polish
-import Mathlib.Probability.Kernel.IntegralCompProd
+import Mathlib.Probability.Kernel.MeasureCompProd
 
 #align_import probability.kernel.disintegration from "leanprover-community/mathlib"@"6315581f5650ffa2fbdbbbedc41243c8d7070981"
 
@@ -20,8 +20,7 @@ Then there exists a kernel `ρ.condKernel : kernel α Ω` such that for any meas
 In terms of kernels, `ρ.condKernel` is such that for any measurable space `γ`, we
 have a disintegration of the constant kernel from `γ` with value `ρ`:
 `kernel.const γ ρ = (kernel.const γ ρ.fst) ⊗ₖ (kernel.prodMkLeft γ (condKernel ρ))`,
-where `ρ.fst` is the marginal measure of `ρ` on `α`. In particular,
-`ρ = ((kernel.const Unit ρ.fst) ⊗ₖ (kernel.prodMkLeft Unit (condKernel ρ))) ()`.
+where `ρ.fst` is the marginal measure of `ρ` on `α`. In particular, `ρ = ρ.fst ⊗ₘ ρ.condKernel`.
 
 In order to obtain a disintegration for any standard Borel space, we use that these spaces embed
 measurably into `ℝ`: it then suffices to define a suitable kernel for `Ω = ℝ`. In the real case,
@@ -40,8 +39,7 @@ function `condCdf ρ a` (the conditional cumulative distribution function).
   `∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst = ρ s`
 * `ProbabilityTheory.kernel.const_eq_compProd`:
   `kernel.const γ ρ = (kernel.const γ ρ.fst) ⊗ₖ (kernel.prodMkLeft γ ρ.condKernel)`
-* `ProbabilityTheory.measure_eq_compProd`:
-  `ρ = ((kernel.const Unit ρ.fst) ⊗ₖ (kernel.prodMkLeft Unit ρ.condKernel)) ()`
+* `ProbabilityTheory.measure_eq_compProd`: `ρ = ρ.fst ⊗ₘ ρ.condKernel`
 * `ProbabilityTheory.eq_condKernel_of_measure_eq_compProd`: a.e. uniqueness of `condKernel`
 
 -/
@@ -217,31 +215,26 @@ theorem kernel.const_eq_compProd_real (γ : Type*) [MeasurableSpace γ] (ρ : Me
   rw [lintegral_condKernelReal_mem ρ hs]
 #align probability_theory.kernel.const_eq_comp_prod_real ProbabilityTheory.kernel.const_eq_compProd_real
 
-theorem measure_eq_compProd_real :
-    ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit (condKernelReal ρ)) () := by
-  rw [← kernel.const_eq_compProd_real Unit ρ, kernel.const_apply]
+theorem measure_eq_compProd_real : ρ = ρ.fst ⊗ₘ condKernelReal ρ := by
+  rw [Measure.compProd, ← kernel.const_eq_compProd_real Unit ρ, kernel.const_apply]
 #align probability_theory.measure_eq_comp_prod_real ProbabilityTheory.measure_eq_compProd_real
 
 theorem lintegral_condKernelReal {f : α × ℝ → ℝ≥0∞} (hf : Measurable f) :
     ∫⁻ a, ∫⁻ y, f (a, y) ∂condKernelReal ρ a ∂ρ.fst = ∫⁻ x, f x ∂ρ := by
   nth_rw 3 [measure_eq_compProd_real ρ]
-  rw [kernel.lintegral_compProd _ _ _ hf, kernel.const_apply]
-  simp_rw [kernel.prodMkLeft_apply]
+  rw [Measure.lintegral_compProd hf]
 #align probability_theory.lintegral_cond_kernel_real ProbabilityTheory.lintegral_condKernelReal
 
 theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ {x | x.snd ∈ sᶜ} = 0) :
     ∀ᵐ a ∂ρ.fst, condKernelReal ρ a s = 1 := by
-  have h : ρ {x | x.snd ∈ sᶜ} = (kernel.const Unit ρ.fst ⊗ₖ
-      kernel.prodMkLeft Unit (condKernelReal ρ)) () {x | x.snd ∈ sᶜ} := by
+  have h : ρ {x | x.snd ∈ sᶜ} = (ρ.fst ⊗ₘ condKernelReal ρ) {x | x.snd ∈ sᶜ} := by
     rw [← measure_eq_compProd_real]
-  rw [hρ, kernel.compProd_apply] at h
+  rw [hρ, Measure.compProd_apply] at h
   swap; · exact measurable_snd hs.compl
   rw [eq_comm, lintegral_eq_zero_iff] at h
   swap
-  · simp_rw [kernel.prodMkLeft_apply']
-    simp only [mem_compl_iff, mem_setOf_eq]
+  · simp only [mem_compl_iff, mem_setOf_eq]
     exact kernel.measurable_coe _ hs.compl
-  rw [kernel.const_apply] at h
   simp only [mem_compl_iff, mem_setOf_eq, kernel.prodMkLeft_apply'] at h
   filter_upwards [h] with a ha
   change condKernelReal ρ a sᶜ = 0 at ha
@@ -264,7 +257,7 @@ variable {Ω : Type*} [MeasurableSpace Ω] [StandardBorelSpace Ω]
 /-- Existence of a conditional kernel. Use the definition `condKernel` to get that kernel. -/
 theorem exists_cond_kernel (γ : Type*) [MeasurableSpace γ] :
     ∃ (η : kernel α Ω) (_h : IsMarkovKernel η), kernel.const γ ρ =
-      kernel.compProd (kernel.const γ ρ.fst) (kernel.prodMkLeft γ η) := by
+      (kernel.const γ ρ.fst) ⊗ₖ (kernel.prodMkLeft γ η) := by
   obtain ⟨f, hf⟩ := exists_measurableEmbedding_real Ω
   let ρ' : Measure (α × ℝ) := ρ.map (Prod.map id f)
   -- The general idea is to define `η = kernel.comapRight (condKernelReal ρ') hf`. There is
@@ -344,8 +337,7 @@ theorem exists_cond_kernel (γ : Type*) [MeasurableSpace γ] :
 #align probability_theory.exists_cond_kernel ProbabilityTheory.exists_cond_kernel
 
 /-- Conditional kernel of a measure on a product space: a Markov kernel such that
-`ρ = ((kernel.const Unit ρ.fst) ⊗ₖ (kernel.prodMkLeft Unit ρ.condKernel)) ()`
-(see `ProbabilityTheory.measure_eq_compProd`). -/
+`ρ = ρ.fst ⊗ₘ ρ.condKernel` (see `ProbabilityTheory.measure_eq_compProd`). -/
 noncomputable irreducible_def _root_.MeasureTheory.Measure.condKernel : kernel α Ω :=
   (exists_cond_kernel ρ Unit).choose
 #align measure_theory.measure.cond_kernel MeasureTheory.Measure.condKernel
@@ -366,9 +358,8 @@ theorem kernel.const_unit_eq_compProd :
 measure can be written as the composition-product of the constant kernel with value `ρ.fst`
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
 `ProbabilityTheory.condKernel ρ`. -/
-theorem measure_eq_compProd :
-    ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel) () := by
-  rw [← kernel.const_unit_eq_compProd, kernel.const_apply]
+theorem measure_eq_compProd : ρ = ρ.fst ⊗ₘ ρ.condKernel := by
+  rw [Measure.compProd, ← kernel.const_unit_eq_compProd, kernel.const_apply]
 #align probability_theory.measure_eq_comp_prod ProbabilityTheory.measure_eq_compProd
 
 /-- **Disintegration** of constant kernels. A constant kernel on a product space `α × Ω`, where `Ω`
@@ -386,40 +377,35 @@ theorem kernel.const_eq_compProd (γ : Type*) [MeasurableSpace γ] (ρ : Measure
 theorem lintegral_condKernel_mem {s : Set (α × Ω)} (hs : MeasurableSet s) :
     ∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst = ρ s := by
   conv_rhs => rw [measure_eq_compProd ρ]
-  simp_rw [kernel.compProd_apply _ _ _ hs, kernel.const_apply, kernel.prodMkLeft_apply]
+  simp_rw [Measure.compProd_apply hs]
+  rfl
 #align probability_theory.lintegral_cond_kernel_mem ProbabilityTheory.lintegral_condKernel_mem
 
 theorem set_lintegral_condKernel_eq_measure_prod {s : Set α} (hs : MeasurableSet s) {t : Set Ω}
     (ht : MeasurableSet t) : ∫⁻ a in s, ρ.condKernel a t ∂ρ.fst = ρ (s ×ˢ t) := by
-  have : ρ (s ×ˢ t) =
-      ((kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel) ()) (s ×ˢ t) := by
+  have : ρ (s ×ˢ t) = (ρ.fst ⊗ₘ ρ.condKernel) (s ×ˢ t) := by
     congr; exact measure_eq_compProd ρ
-  rw [this, kernel.compProd_apply _ _ _ (hs.prod ht)]
-  simp only [prod_mk_mem_set_prod_eq, kernel.lintegral_const, kernel.prodMkLeft_apply]
-  rw [← lintegral_indicator _ hs]
-  congr
-  ext1 x
+  rw [this, Measure.compProd_apply (hs.prod ht)]
   classical
-  rw [indicator_apply]
-  split_ifs with hx
-  · simp only [hx, if_true, true_and_iff, setOf_mem_eq]
-  · simp only [hx, if_false, false_and_iff, setOf_false, measure_empty]
+  have : ∀ a, ρ.condKernel a (Prod.mk a ⁻¹' s ×ˢ t)
+      = s.indicator (fun a ↦ ρ.condKernel a t) a := by
+    intro a
+    by_cases ha : a ∈ s <;> simp [ha]
+  simp_rw [this]
+  rw [lintegral_indicator _ hs]
 #align probability_theory.set_lintegral_cond_kernel_eq_measure_prod ProbabilityTheory.set_lintegral_condKernel_eq_measure_prod
 
 theorem lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) :
     ∫⁻ a, ∫⁻ ω, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x, f x ∂ρ := by
   conv_rhs => rw [measure_eq_compProd ρ]
-  rw [kernel.lintegral_compProd _ _ _ hf, kernel.const_apply]
-  simp_rw [kernel.prodMkLeft_apply]
+  rw [Measure.lintegral_compProd hf]
 #align probability_theory.lintegral_cond_kernel ProbabilityTheory.lintegral_condKernel
 
 theorem set_lintegral_condKernel {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
     (hs : MeasurableSet s) {t : Set Ω} (ht : MeasurableSet t) :
     ∫⁻ a in s, ∫⁻ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫⁻ x in s ×ˢ t, f x ∂ρ := by
   conv_rhs => rw [measure_eq_compProd ρ]
-  rw [← kernel.restrict_apply _ (hs.prod ht), ← kernel.compProd_restrict hs ht,
-    kernel.lintegral_compProd _ _ _ hf, kernel.restrict_apply]
-  conv_rhs => enter [2, b, 1]; rw [kernel.restrict_apply _ ht]
+  rw [Measure.set_lintegral_compProd hf hs ht]
 #align probability_theory.set_lintegral_cond_kernel ProbabilityTheory.set_lintegral_condKernel
 
 theorem set_lintegral_condKernel_univ_right {f : α × Ω → ℝ≥0∞} (hf : Measurable f) {s : Set α}
@@ -448,10 +434,8 @@ theorem _root_.MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Meas
 theorem integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
     (hf : Integrable f ρ) : ∫ a, ∫ x, f (a, x) ∂ρ.condKernel a ∂ρ.fst = ∫ ω, f ω ∂ρ := by
   conv_rhs => rw [measure_eq_compProd ρ]
-  have hf': Integrable f ((kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit ρ.condKernel) ()) := by
-    rwa [measure_eq_compProd ρ] at hf
-  rw [integral_compProd hf', kernel.const_apply]
-  simp_rw [kernel.prodMkLeft_apply]
+  have hf': Integrable f (ρ.fst ⊗ₘ ρ.condKernel) := by rwa [measure_eq_compProd ρ] at hf
+  rw [Measure.integral_compProd hf']
 #align probability_theory.integral_cond_kernel ProbabilityTheory.integral_condKernel
 
 theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
@@ -459,9 +443,8 @@ theorem set_integral_condKernel {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {
     (hf : IntegrableOn f (s ×ˢ t) ρ) :
     ∫ a in s, ∫ ω in t, f (a, ω) ∂ρ.condKernel a ∂ρ.fst = ∫ x in s ×ˢ t, f x ∂ρ := by
   conv_rhs => rw [measure_eq_compProd ρ]
-  rw [set_integral_compProd hs ht]
-  · simp_rw [kernel.prodMkLeft_apply, kernel.const_apply]
-  · rwa [measure_eq_compProd ρ] at hf
+  rw [Measure.set_integral_compProd hs ht]
+  rwa [measure_eq_compProd ρ] at hf
 #align probability_theory.set_integral_cond_kernel ProbabilityTheory.set_integral_condKernel
 
 theorem set_integral_condKernel_univ_right {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ] {f : α × Ω → E}
@@ -491,23 +474,20 @@ This theorem in the case of finite kernels is weaker than `eq_condKernel_of_meas
 which asserts that the kernels are equal almost everywhere and not just on a given measurable
 set. -/
 theorem eq_condKernel_of_measure_eq_compProd' (κ : kernel α Ω) [IsSFiniteKernel κ]
-    (hκ : ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit κ) ())
-    {s : Set Ω} (hs : MeasurableSet s) :
+    (hκ : ρ = ρ.fst ⊗ₘ κ) {s : Set Ω} (hs : MeasurableSet s) :
     ∀ᵐ x ∂ρ.fst, κ x s = ρ.condKernel x s := by
   refine' ae_eq_of_forall_set_lintegral_eq_of_sigmaFinite
     (kernel.measurable_coe κ hs) (kernel.measurable_coe ρ.condKernel hs) _
   intros t ht _
   conv_rhs => rw [set_lintegral_condKernel_eq_measure_prod _ ht hs, hκ]
-  simp only [kernel.compProd_apply _ _ _ (ht.prod hs), kernel.prodMkLeft_apply, Set.mem_prod,
-    kernel.lintegral_const, ← lintegral_indicator _ ht]
+  simp only [Measure.compProd_apply (ht.prod hs), Set.mem_prod, ← lintegral_indicator _ ht]
   congr; ext x
   by_cases hx : x ∈ t
   all_goals simp [hx]
 
 -- This lemma establishes uniqueness of the disintegration kernel on ℝ
 lemma eq_condKernel_of_measure_eq_compProd_real (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
-    (κ : kernel α ℝ) [IsFiniteKernel κ]
-    (hκ : ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit κ) ()) :
+    (κ : kernel α ℝ) [IsFiniteKernel κ] (hκ : ρ = ρ.fst ⊗ₘ κ) :
     ∀ᵐ x ∂ρ.fst, κ x = ρ.condKernel x := by
   have huniv : ∀ᵐ x ∂ρ.fst, κ x Set.univ = ρ.condKernel x Set.univ :=
     eq_condKernel_of_measure_eq_compProd' ρ κ hκ MeasurableSet.univ
@@ -528,7 +508,7 @@ lemma eq_condKernel_of_measure_eq_compProd_real (ρ : Measure (α × ℝ)) [IsFi
 /-- A finite kernel which satisfies the disintegration property is almost everywhere equal to the
 disintegration kernel. -/
 theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel κ]
-    (hκ : ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit κ) ()) :
+    (hκ : ρ = ρ.fst ⊗ₘ κ) :
     ∀ᵐ x ∂ρ.fst, κ x = ρ.condKernel x := by
 -- The idea is to transporting the question to `ℝ` from `Ω` using `exists_measurableEmbedding_real`
 -- and then constructing a measure on `α × ℝ` using the obtained measurable embedding
@@ -544,7 +524,7 @@ theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel
     ext s hs
     simp only [Measure.map_apply (measurable_id.prod_map hf.measurable) hs]
     conv_lhs => congr; rw [hκ]
-    rw [kernel.compProd_apply _ _ _ hs, kernel.compProd_apply _ _ _
+    rw [Measure.compProd_apply hs, Measure.compProd_apply
       (measurable_id.prod_map hf.measurable hs), (_ : (ρ.map (Prod.map id f)).fst = ρ.fst)]
     · congr
       ext x
@@ -571,24 +551,18 @@ theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel
       ← Set.preimage_comp, Measure.fst_apply hs]
     rfl
   suffices : ρ.map (Prod.map id f) =
-    (kernel.const Unit (ρ.map (Prod.map id f)).fst ⊗ₖ
-      kernel.prodMkLeft Unit (kernel.map (Measure.condKernel ρ) f hf.measurable)) ()
+    ((ρ.map (Prod.map id f)).fst ⊗ₘ (kernel.map (Measure.condKernel ρ) f hf.measurable))
   · have heq := eq_condKernel_of_measure_eq_compProd_real _ _ this
     rw [hprod] at heq
     filter_upwards [heq] with x hx s hs
     rw [← hx, kernel.map_apply, Measure.map_apply hf.measurable hs]
   ext s hs
-  have hinteq : ∀ x, (ρ.condKernel x).map f {c | (x, c) ∈ s} =
-      ρ.condKernel x {c | (x, c) ∈ Prod.map id f ⁻¹' s}
-  · intro x
-    rw [Measure.map_apply hf.measurable]
-    · rfl
-    · exact measurable_prod_mk_left hs
-  simp only [hprod, kernel.compProd_apply _ _ _ hs, kernel.prodMkLeft_apply,
-    kernel.map_apply _ hf.measurable, hinteq, Set.mem_preimage, Prod_map, id_eq,
-    kernel.lintegral_const]
+  simp only [hprod, Measure.compProd_apply hs, kernel.map_apply _ hf.measurable]
   rw [Measure.map_apply (measurable_id.prod_map hf.measurable) hs, ← lintegral_condKernel_mem]
-  · rfl
+  · simp only [mem_preimage, Prod_map, id_eq]
+    congr with a
+    rw [Measure.map_apply hf.measurable (measurable_prod_mk_left hs)]
+    rfl
   · exact measurable_id.prod_map hf.measurable hs
 
 end Unique
@@ -616,8 +590,7 @@ theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
       Integrable (fun a => ∫ ω, ‖f (a, ω)‖ ∂ρ.condKernel a) ρ.fst ↔ Integrable f ρ := by
   rw [measure_eq_compProd ρ] at hf
   conv_rhs => rw [measure_eq_compProd ρ]
-  rw [integrable_compProd_iff hf]
-  simp_rw [kernel.prodMkLeft_apply, kernel.const_apply]
+  rw [Measure.integrable_compProd_iff hf]
 #align measure_theory.ae_strongly_measurable.ae_integrable_cond_kernel_iff MeasureTheory.AEStronglyMeasurable.ae_integrable_condKernel_iff
 
 theorem Integrable.condKernel_ae {f : α × Ω → F} (hf_int : Integrable f ρ) :
chore: use StandardBorelSpace everywhere in the probability folder instead of PolishSpace (#8746)
Diff
@@ -13,7 +13,7 @@ import Mathlib.Probability.Kernel.IntegralCompProd
 # Disintegration of measures on product spaces
 
 Let `ρ` be a finite measure on `α × Ω`, where `Ω` is a standard Borel space. In mathlib terms, `Ω`
-verifies `[Nonempty Ω] [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω]`.
+verifies `[Nonempty Ω] [MeasurableSpace Ω] [StandardBorelSpace Ω]`.
 Then there exists a kernel `ρ.condKernel : kernel α Ω` such that for any measurable set
 `s : Set (α × Ω)`, `ρ s = ∫⁻ a, ρ.condKernel a {x | (a, x) ∈ s} ∂ρ.fst`.
 
@@ -250,15 +250,15 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ
 
 end Real
 
-section Polish
+section StandardBorel
 
-/-! ### Disintegration of measures on Polish Borel spaces
+/-! ### Disintegration of measures on standard Borel spaces
 
 Since every standard Borel space embeds measurably into `ℝ`, we can generalize the disintegration
 property on `ℝ` to all these spaces. -/
 
 
-variable {Ω : Type*} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω]
+variable {Ω : Type*} [MeasurableSpace Ω] [StandardBorelSpace Ω]
   [Nonempty Ω] (ρ : Measure (α × Ω)) [IsFiniteMeasure ρ]
 
 /-- Existence of a conditional kernel. Use the definition `condKernel` to get that kernel. -/
@@ -362,7 +362,7 @@ theorem kernel.const_unit_eq_compProd :
   simp_rw [condKernel_def]; exact (exists_cond_kernel ρ Unit).choose_spec.choose_spec
 #align probability_theory.kernel.const_unit_eq_comp_prod ProbabilityTheory.kernel.const_unit_eq_compProd
 
-/-- **Disintegration** of finite product measures on `α × Ω`, where `Ω` is Polish Borel. Such a
+/-- **Disintegration** of finite product measures on `α × Ω`, where `Ω` is standard Borel. Such a
 measure can be written as the composition-product of the constant kernel with value `ρ.fst`
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
 `ProbabilityTheory.condKernel ρ`. -/
@@ -372,9 +372,9 @@ theorem measure_eq_compProd :
 #align probability_theory.measure_eq_comp_prod ProbabilityTheory.measure_eq_compProd
 
 /-- **Disintegration** of constant kernels. A constant kernel on a product space `α × Ω`, where `Ω`
-is Polish Borel, can be written as the composition-product of the constant kernel with value `ρ.fst`
-(marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
-`ProbabilityTheory.condKernel ρ`. -/
+is standard Borel, can be written as the composition-product of the constant kernel with
+value `ρ.fst` (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that
+Markov kernel `ProbabilityTheory.condKernel ρ`. -/
 theorem kernel.const_eq_compProd (γ : Type*) [MeasurableSpace γ] (ρ : Measure (α × Ω))
     [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ ρ.condKernel := by
@@ -593,7 +593,7 @@ theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel
 
 end Unique
 
-end Polish
+end StandardBorel
 
 end ProbabilityTheory
 
@@ -606,8 +606,8 @@ We place these lemmas in the `MeasureTheory` namespace to enable dot notation. -
 
 open ProbabilityTheory
 
-variable {α Ω E F : Type*} {mα : MeasurableSpace α} [MeasurableSpace Ω] [TopologicalSpace Ω]
-  [BorelSpace Ω] [PolishSpace Ω] [Nonempty Ω] [NormedAddCommGroup E] [NormedSpace ℝ E]
+variable {α Ω E F : Type*} {mα : MeasurableSpace α} [MeasurableSpace Ω]
+  [StandardBorelSpace Ω] [Nonempty Ω] [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
 
 theorem AEStronglyMeasurable.ae_integrable_condKernel_iff {f : α × Ω → F}
feat(Filter): lemmas from Mandelbrot connectedness project (#7913)
  • Add Filter.frequently_iff_neBot and Filter.frequently_mem_iff_neBot.

  • Drop some implicit arguments that are available from variable.

  • Add Filter.disjoint_prod and Filter.frequently_prod_and.

  • Swap Filter.le_prod with Filter.tendsto_prod_iff' to use the latter in the proof of the former.

Co-Authored-By: @girving

Diff
@@ -128,7 +128,7 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
       prod_iUnion, measure_iUnion]
     · simp_rw [hf_eq]
     · intro i j hij
-      rw [Function.onFun, disjoint_prod]
+      rw [Function.onFun, Set.disjoint_prod]
       exact Or.inr (hf_disj hij)
     · exact fun i => MeasurableSet.prod hs (hf_meas i)
 #align probability_theory.set_lintegral_cond_kernel_real_prod ProbabilityTheory.set_lintegral_condKernelReal_prod
chore: swap primes on forall_apply_eq_imp_iff (#7705)

Two pairs of the form foo and foo', where foo' is the simp lemma (and hence used in many simp onlys) and foo is not used at all.

Swap the primes, so that when it is time (now!) to upstream the lemma we actually use, it doesn't need to have a prime...

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

Diff
@@ -517,7 +517,7 @@ lemma eq_condKernel_of_measure_eq_compProd_real (ρ : Measure (α × ℝ)) [IsFi
   apply MeasurableSpace.ae_induction_on_inter Real.borel_eq_generateFrom_Iic_rat
     Real.isPiSystem_Iic_rat
   · simp only [OuterMeasure.empty', Filter.eventually_true]
-  · simp only [iUnion_singleton_eq_range, mem_range, forall_exists_index, forall_apply_eq_imp_iff']
+  · simp only [iUnion_singleton_eq_range, mem_range, forall_exists_index, forall_apply_eq_imp_iff]
     exact ae_all_iff.2 <| fun q => eq_condKernel_of_measure_eq_compProd' ρ κ hκ measurableSet_Iic
   · filter_upwards [huniv] with x hxuniv t ht heq
     rw [measure_compl ht <| measure_ne_top _ _, heq, hxuniv, measure_compl ht <| measure_ne_top _ _]
feat(Probability/Kernel/Disintegration): Uniqueness of the disintegration kernel (#6110)

Co-authored-by: JasonKYi <kexing.ying19@imperial.ac.uk> Co-authored-by: RemyDegenne <Remydegenne@gmail.com>

Diff
@@ -1,7 +1,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
+Authors: Rémy Degenne, Kexing Ying
 -/
 import Mathlib.Probability.Kernel.CondCdf
 import Mathlib.MeasureTheory.Constructions.Polish
@@ -42,6 +42,7 @@ function `condCdf ρ a` (the conditional cumulative distribution function).
   `kernel.const γ ρ = (kernel.const γ ρ.fst) ⊗ₖ (kernel.prodMkLeft γ ρ.condKernel)`
 * `ProbabilityTheory.measure_eq_compProd`:
   `ρ = ((kernel.const Unit ρ.fst) ⊗ₖ (kernel.prodMkLeft Unit ρ.condKernel)) ()`
+* `ProbabilityTheory.eq_condKernel_of_measure_eq_compProd`: a.e. uniqueness of `condKernel`
 
 -/
 
@@ -477,6 +478,121 @@ theorem set_integral_condKernel_univ_left {ρ : Measure (α × Ω)} [IsFiniteMea
 
 end IntegralCondKernel
 
+section Unique
+
+/-! ### Uniqueness
+
+This section will prove that the conditional kernel is unique almost everywhere. -/
+
+/-- A s-finite kernel which satisfy the disintegration property of the given measure `ρ` is almost
+everywhere equal to the disintegration kernel of `ρ` when evaluated on a measurable set.
+
+This theorem in the case of finite kernels is weaker than `eq_condKernel_of_measure_eq_compProd`
+which asserts that the kernels are equal almost everywhere and not just on a given measurable
+set. -/
+theorem eq_condKernel_of_measure_eq_compProd' (κ : kernel α Ω) [IsSFiniteKernel κ]
+    (hκ : ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit κ) ())
+    {s : Set Ω} (hs : MeasurableSet s) :
+    ∀ᵐ x ∂ρ.fst, κ x s = ρ.condKernel x s := by
+  refine' ae_eq_of_forall_set_lintegral_eq_of_sigmaFinite
+    (kernel.measurable_coe κ hs) (kernel.measurable_coe ρ.condKernel hs) _
+  intros t ht _
+  conv_rhs => rw [set_lintegral_condKernel_eq_measure_prod _ ht hs, hκ]
+  simp only [kernel.compProd_apply _ _ _ (ht.prod hs), kernel.prodMkLeft_apply, Set.mem_prod,
+    kernel.lintegral_const, ← lintegral_indicator _ ht]
+  congr; ext x
+  by_cases hx : x ∈ t
+  all_goals simp [hx]
+
+-- This lemma establishes uniqueness of the disintegration kernel on ℝ
+lemma eq_condKernel_of_measure_eq_compProd_real (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ]
+    (κ : kernel α ℝ) [IsFiniteKernel κ]
+    (hκ : ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit κ) ()) :
+    ∀ᵐ x ∂ρ.fst, κ x = ρ.condKernel x := by
+  have huniv : ∀ᵐ x ∂ρ.fst, κ x Set.univ = ρ.condKernel x Set.univ :=
+    eq_condKernel_of_measure_eq_compProd' ρ κ hκ MeasurableSet.univ
+  suffices : ∀ᵐ x ∂ρ.fst, ∀ ⦃t⦄, MeasurableSet t → κ x t = ρ.condKernel x t
+  · filter_upwards [this] with x hx
+    ext t ht; exact hx ht
+  apply MeasurableSpace.ae_induction_on_inter Real.borel_eq_generateFrom_Iic_rat
+    Real.isPiSystem_Iic_rat
+  · simp only [OuterMeasure.empty', Filter.eventually_true]
+  · simp only [iUnion_singleton_eq_range, mem_range, forall_exists_index, forall_apply_eq_imp_iff']
+    exact ae_all_iff.2 <| fun q => eq_condKernel_of_measure_eq_compProd' ρ κ hκ measurableSet_Iic
+  · filter_upwards [huniv] with x hxuniv t ht heq
+    rw [measure_compl ht <| measure_ne_top _ _, heq, hxuniv, measure_compl ht <| measure_ne_top _ _]
+  · refine' ae_of_all _ (fun x f hdisj hf heq => _)
+    rw [measure_iUnion hdisj hf, measure_iUnion hdisj hf]
+    exact tsum_congr heq
+
+/-- A finite kernel which satisfies the disintegration property is almost everywhere equal to the
+disintegration kernel. -/
+theorem eq_condKernel_of_measure_eq_compProd (κ : kernel α Ω) [IsFiniteKernel κ]
+    (hκ : ρ = (kernel.const Unit ρ.fst ⊗ₖ kernel.prodMkLeft Unit κ) ()) :
+    ∀ᵐ x ∂ρ.fst, κ x = ρ.condKernel x := by
+-- The idea is to transporting the question to `ℝ` from `Ω` using `exists_measurableEmbedding_real`
+-- and then constructing a measure on `α × ℝ` using the obtained measurable embedding
+  obtain ⟨f, hf⟩ := exists_measurableEmbedding_real Ω
+  set ρ' : Measure (α × ℝ) := ρ.map (Prod.map id f) with hρ'def
+  have hρ' : ρ'.fst = ρ.fst
+  · ext s hs
+    rw [hρ'def, Measure.fst_apply, Measure.fst_apply, Measure.map_apply]
+    exacts [rfl, Measurable.prod measurable_fst <| hf.measurable.comp measurable_snd,
+      measurable_fst hs, hs, hs]
+  have hρ'' : ∀ᵐ x ∂ρ'.fst, kernel.map κ f hf.measurable x = ρ'.condKernel x
+  · refine' eq_condKernel_of_measure_eq_compProd_real ρ' (kernel.map κ f hf.measurable) _
+    ext s hs
+    simp only [Measure.map_apply (measurable_id.prod_map hf.measurable) hs]
+    conv_lhs => congr; rw [hκ]
+    rw [kernel.compProd_apply _ _ _ hs, kernel.compProd_apply _ _ _
+      (measurable_id.prod_map hf.measurable hs), (_ : (ρ.map (Prod.map id f)).fst = ρ.fst)]
+    · congr
+      ext x
+      simp only [Set.mem_preimage, Prod_map, id_eq, kernel.prodMkLeft_apply, kernel.map_apply]
+      rw [Measure.map_apply hf.measurable]
+      · rfl
+      · exact measurable_prod_mk_left hs
+    · rw [Measure.fst_map_prod_mk]
+      · simp only [Prod_map, id_eq]; rfl
+      · exact (hf.measurable.comp measurable_snd)
+  rw [hρ'] at hρ''
+  suffices : ∀ᵐ x ∂ρ.fst, ∀ s, MeasurableSet s →
+    ((ρ.map (Prod.map id f)).condKernel x) s = (ρ.condKernel x) (f ⁻¹' s)
+  · filter_upwards [hρ'', this] with x hx h
+    rw [kernel.map_apply] at hx
+    ext s hs
+    rw [← Set.preimage_image_eq s hf.injective,
+      ← Measure.map_apply hf.measurable <| hf.measurableSet_image.2 hs, hx,
+      h _ <| hf.measurableSet_image.2 hs]
+  have hprod : (ρ.map (Prod.map id f)).fst = ρ.fst
+  · ext s hs
+    rw [Measure.fst_apply hs,
+      Measure.map_apply (measurable_id.prod_map hf.measurable) (measurable_fst hs),
+      ← Set.preimage_comp, Measure.fst_apply hs]
+    rfl
+  suffices : ρ.map (Prod.map id f) =
+    (kernel.const Unit (ρ.map (Prod.map id f)).fst ⊗ₖ
+      kernel.prodMkLeft Unit (kernel.map (Measure.condKernel ρ) f hf.measurable)) ()
+  · have heq := eq_condKernel_of_measure_eq_compProd_real _ _ this
+    rw [hprod] at heq
+    filter_upwards [heq] with x hx s hs
+    rw [← hx, kernel.map_apply, Measure.map_apply hf.measurable hs]
+  ext s hs
+  have hinteq : ∀ x, (ρ.condKernel x).map f {c | (x, c) ∈ s} =
+      ρ.condKernel x {c | (x, c) ∈ Prod.map id f ⁻¹' s}
+  · intro x
+    rw [Measure.map_apply hf.measurable]
+    · rfl
+    · exact measurable_prod_mk_left hs
+  simp only [hprod, kernel.compProd_apply _ _ _ hs, kernel.prodMkLeft_apply,
+    kernel.map_apply _ hf.measurable, hinteq, Set.mem_preimage, Prod_map, id_eq,
+    kernel.lintegral_const]
+  rw [Measure.map_apply (measurable_id.prod_map hf.measurable) hs, ← lintegral_condKernel_mem]
+  · rfl
+  · exact measurable_id.prod_map hf.measurable hs
+
+end Unique
+
 end Polish
 
 end ProbabilityTheory
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -100,7 +100,7 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
   -- π-system that generates the Borel σ-algebra, hence we can get the same equality for any
   -- measurable set `t`.
   apply MeasurableSpace.induction_on_inter (borel_eq_generateFrom_Iic ℝ) isPiSystem_Iic _ _ _ _ ht
-  · simp only [measure_empty, lintegral_const, MulZeroClass.zero_mul, prod_empty]
+  · simp only [measure_empty, lintegral_const, zero_mul, prod_empty]
   · rintro t ⟨q, rfl⟩
     exact set_lintegral_condKernelReal_Iic ρ q hs
   · intro t ht ht_lintegral
@@ -139,7 +139,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
   -- for any measurable set `s`.
   apply MeasurableSpace.induction_on_inter generateFrom_prod.symm isPiSystem_prod _ _ _ _ hs
   · simp only [mem_empty_iff_false, setOf_false, measure_empty, lintegral_const,
-      MulZeroClass.zero_mul]
+      zero_mul]
   · intro t ht
     rw [mem_image2] at ht
     obtain ⟨t₁, t₂, ht₁, ht₂, rfl⟩ := ht
@@ -148,7 +148,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       simp only [ha, prod_mk_mem_set_prod_eq, true_and_iff, setOf_mem_eq]
     cases' eq_empty_or_nonempty t₂ with h h
     · simp only [h, prod_empty, mem_empty_iff_false, setOf_false, measure_empty, lintegral_const,
-        MulZeroClass.zero_mul]
+        zero_mul]
     rw [← lintegral_add_compl _ ht₁]
     have h_eq1 : ∫⁻ a in t₁, condKernelReal ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst =
         ∫⁻ a in t₁, condKernelReal ρ a t₂ ∂ρ.fst := by
@@ -157,7 +157,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
     have h_eq2 : ∫⁻ a in t₁ᶜ, condKernelReal ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} ∂ρ.fst = 0 := by
       suffices h_eq_zero : ∀ a ∈ t₁ᶜ, condKernelReal ρ a {x : ℝ | (a, x) ∈ t₁ ×ˢ t₂} = 0
       · rw [set_lintegral_congr_fun ht₁.compl (eventually_of_forall h_eq_zero)]
-        simp only [lintegral_const, MulZeroClass.zero_mul]
+        simp only [lintegral_const, zero_mul]
       intro a hat₁
       rw [mem_compl_iff] at hat₁
       simp only [hat₁, prod_mk_mem_set_prod_eq, false_and_iff, setOf_false, measure_empty]
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
@@ -52,7 +52,7 @@ open scoped ENNReal MeasureTheory Topology ProbabilityTheory
 
 namespace ProbabilityTheory
 
-variable {α : Type _} {mα : MeasurableSpace α}
+variable {α : Type*} {mα : MeasurableSpace α}
 
 section Real
 
@@ -207,7 +207,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
       _ = ρ (iUnion f) := (measure_iUnion hf_disj hf_meas).symm
 #align probability_theory.lintegral_cond_kernel_real_mem ProbabilityTheory.lintegral_condKernelReal_mem
 
-theorem kernel.const_eq_compProd_real (γ : Type _) [MeasurableSpace γ] (ρ : Measure (α × ℝ))
+theorem kernel.const_eq_compProd_real (γ : Type*) [MeasurableSpace γ] (ρ : Measure (α × ℝ))
     [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ (condKernelReal ρ) := by
   ext a s hs : 2
@@ -257,11 +257,11 @@ Since every standard Borel space embeds measurably into `ℝ`, we can generalize
 property on `ℝ` to all these spaces. -/
 
 
-variable {Ω : Type _} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω]
+variable {Ω : Type*} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace Ω] [BorelSpace Ω]
   [Nonempty Ω] (ρ : Measure (α × Ω)) [IsFiniteMeasure ρ]
 
 /-- Existence of a conditional kernel. Use the definition `condKernel` to get that kernel. -/
-theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
+theorem exists_cond_kernel (γ : Type*) [MeasurableSpace γ] :
     ∃ (η : kernel α Ω) (_h : IsMarkovKernel η), kernel.const γ ρ =
       kernel.compProd (kernel.const γ ρ.fst) (kernel.prodMkLeft γ η) := by
   obtain ⟨f, hf⟩ := exists_measurableEmbedding_real Ω
@@ -374,7 +374,7 @@ theorem measure_eq_compProd :
 is Polish Borel, can be written as the composition-product of the constant kernel with value `ρ.fst`
 (marginal measure over `α`) and a Markov kernel from `α` to `Ω`. We call that Markov kernel
 `ProbabilityTheory.condKernel ρ`. -/
-theorem kernel.const_eq_compProd (γ : Type _) [MeasurableSpace γ] (ρ : Measure (α × Ω))
+theorem kernel.const_eq_compProd (γ : Type*) [MeasurableSpace γ] (ρ : Measure (α × Ω))
     [IsFiniteMeasure ρ] :
     kernel.const γ ρ = kernel.const γ ρ.fst ⊗ₖ kernel.prodMkLeft γ ρ.condKernel := by
   ext a s hs : 2
@@ -435,7 +435,7 @@ theorem set_lintegral_condKernel_univ_left {f : α × Ω → ℝ≥0∞} (hf : M
 
 section IntegralCondKernel
 
-variable {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
 
 theorem _root_.MeasureTheory.AEStronglyMeasurable.integral_condKernel {ρ : Measure (α × Ω)}
     [IsFiniteMeasure ρ] {f : α × Ω → E} (hf : AEStronglyMeasurable f ρ) :
@@ -490,7 +490,7 @@ We place these lemmas in the `MeasureTheory` namespace to enable dot notation. -
 
 open ProbabilityTheory
 
-variable {α Ω E F : Type _} {mα : MeasurableSpace α} [MeasurableSpace Ω] [TopologicalSpace Ω]
+variable {α Ω E F : Type*} {mα : MeasurableSpace α} [MeasurableSpace Ω] [TopologicalSpace Ω]
   [BorelSpace Ω] [PolishSpace Ω] [Nonempty Ω] [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] {ρ : Measure (α × Ω)} [IsFiniteMeasure ρ]
 
refactor(Probability/Kernel/Composition): define compProd for all kernels (#6054)

compProd and prod make sense only for s-finite kernels and were defined only for those. I define them for all kernels, with default value 0 when one of the kernels is not s-finite. The new definitions allow rewriting a kernel inside a compProd, which was not possible before (it would raise a "motive is not type correct" error due to the s-finite argument).

Co-authored-by: Rémy Degenne <remydegenne@gmail.com>

Diff
@@ -262,9 +262,8 @@ variable {Ω : Type _} [TopologicalSpace Ω] [PolishSpace Ω] [MeasurableSpace 
 
 /-- Existence of a conditional kernel. Use the definition `condKernel` to get that kernel. -/
 theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
-    ∃ (η : kernel α Ω) (h : IsMarkovKernel η), kernel.const γ ρ =
-      @kernel.compProd γ α _ _ Ω _ (kernel.const γ ρ.fst) _ (kernel.prodMkLeft γ η)
-        (by haveI := h; infer_instance) := by
+    ∃ (η : kernel α Ω) (_h : IsMarkovKernel η), kernel.const γ ρ =
+      kernel.compProd (kernel.const γ ρ.fst) (kernel.prodMkLeft γ η) := by
   obtain ⟨f, hf⟩ := exists_measurableEmbedding_real Ω
   let ρ' : Measure (α × ℝ) := ρ.map (Prod.map id f)
   -- The general idea is to define `η = kernel.comapRight (condKernelReal ρ') hf`. There is
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,16 +2,13 @@
 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.disintegration
-! leanprover-community/mathlib commit 6315581f5650ffa2fbdbbbedc41243c8d7070981
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Probability.Kernel.CondCdf
 import Mathlib.MeasureTheory.Constructions.Polish
 import Mathlib.Probability.Kernel.IntegralCompProd
 
+#align_import probability.kernel.disintegration from "leanprover-community/mathlib"@"6315581f5650ffa2fbdbbbedc41243c8d7070981"
+
 /-!
 # Disintegration of measures on product spaces
 
fix: change compl precedence (#5586)

Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>

Diff
@@ -108,7 +108,7 @@ theorem set_lintegral_condKernelReal_prod {s : Set α} (hs : MeasurableSet s) {t
     exact set_lintegral_condKernelReal_Iic ρ q hs
   · intro t ht ht_lintegral
     calc
-      ∫⁻ a in s, condKernelReal ρ a (tᶜ) ∂ρ.fst =
+      ∫⁻ a in s, condKernelReal ρ a tᶜ ∂ρ.fst =
           ∫⁻ a in s, condKernelReal ρ a univ - condKernelReal ρ a t ∂ρ.fst := by
         congr with a; rw [measure_compl ht (measure_ne_top (condKernelReal ρ a) _)]
       _ = ∫⁻ a in s, condKernelReal ρ a univ ∂ρ.fst - ∫⁻ a in s, condKernelReal ρ a t ∂ρ.fst := by
@@ -169,7 +169,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
   · intro t ht ht_eq
     calc
       ∫⁻ a, condKernelReal ρ a {x : ℝ | (a, x) ∈ tᶜ} ∂ρ.fst =
-          ∫⁻ a, condKernelReal ρ a ({x : ℝ | (a, x) ∈ t}ᶜ) ∂ρ.fst := rfl
+          ∫⁻ a, condKernelReal ρ a {x : ℝ | (a, x) ∈ t}ᶜ ∂ρ.fst := rfl
       _ = ∫⁻ a, condKernelReal ρ a univ - condKernelReal ρ a {x : ℝ | (a, x) ∈ t} ∂ρ.fst := by
         congr with a : 1
         exact measure_compl (measurable_prod_mk_left ht) (measure_ne_top (condKernelReal ρ a) _)
@@ -183,7 +183,7 @@ theorem lintegral_condKernelReal_mem {s : Set (α × ℝ)} (hs : MeasurableSet s
         rw [lintegral_condKernelReal_univ]
         exact measure_lt_top ρ univ
       _ = ρ univ - ρ t := by rw [ht_eq, lintegral_condKernelReal_univ]
-      _ = ρ (tᶜ) := (measure_compl ht (measure_ne_top _ _)).symm
+      _ = ρ tᶜ := (measure_compl ht (measure_ne_top _ _)).symm
   · intro f hf_disj hf_meas hf_eq
     have h_eq : ∀ a, {x | (a, x) ∈ ⋃ i, f i} = ⋃ i, {x | (a, x) ∈ f i} := by
       intro a
@@ -246,7 +246,7 @@ theorem ae_condKernelReal_eq_one {s : Set ℝ} (hs : MeasurableSet s) (hρ : ρ
   rw [kernel.const_apply] at h
   simp only [mem_compl_iff, mem_setOf_eq, kernel.prodMkLeft_apply'] at h
   filter_upwards [h] with a ha
-  change condKernelReal ρ a (sᶜ) = 0 at ha
+  change condKernelReal ρ a sᶜ = 0 at ha
   rwa [prob_compl_eq_zero_iff hs] at ha
 #align probability_theory.ae_cond_kernel_real_eq_one ProbabilityTheory.ae_condKernelReal_eq_one
 
@@ -274,12 +274,12 @@ theorem exists_cond_kernel (γ : Type _) [MeasurableSpace γ] :
   -- however an issue: that `η` may not be a Markov kernel since its value is only a
   -- probability distribution almost everywhere with respect to `ρ.fst`, not everywhere.
   -- We modify it to obtain a Markov kernel which is almost everywhere equal.
-  let ρ_set := toMeasurable ρ.fst ({a | condKernelReal ρ' a (range f) = 1}ᶜ)ᶜ
+  let ρ_set := (toMeasurable ρ.fst {a | condKernelReal ρ' a (range f) = 1}ᶜ)ᶜ
   have hm : MeasurableSet ρ_set := (measurableSet_toMeasurable _ _).compl
   have h_eq_one_of_mem : ∀ a ∈ ρ_set, condKernelReal ρ' a (range f) = 1 := by
     intro a ha
     rw [mem_compl_iff] at ha
-    have h_ss := subset_toMeasurable ρ.fst ({a : α | condKernelReal ρ' a (range f) = 1}ᶜ)
+    have h_ss := subset_toMeasurable ρ.fst {a : α | condKernelReal ρ' a (range f) = 1}ᶜ
     suffices ha' : a ∉ {a : α | condKernelReal ρ' a (range f) = 1}ᶜ
     · rwa [not_mem_compl_iff] at ha'
     exact not_mem_subset h_ss ha
feat: port Probability.Kernel.Disintegration (#5289)

Dependencies 12 + 998

999 files ported (98.8%)
457930 lines ported (98.8%)
Show graph

The unported dependencies are

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