probability.kernel.basicMathlib.Probability.Kernel.Basic

This file has been ported!

Changes since the initial port

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

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -520,23 +520,23 @@ theorem integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace
 #align probability_theory.kernel.integral_deterministic ProbabilityTheory.kernel.integral_deterministic
 -/
 
-#print ProbabilityTheory.kernel.set_integral_deterministic' /-
-theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+#print ProbabilityTheory.kernel.setIntegral_deterministic' /-
+theorem setIntegral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac' hf _ hs]
-#align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.set_integral_deterministic'
+#align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.setIntegral_deterministic'
 -/
 
-#print ProbabilityTheory.kernel.set_integral_deterministic /-
+#print ProbabilityTheory.kernel.setIntegral_deterministic /-
 @[simp]
-theorem set_integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem setIntegral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac f _ s]
-#align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.set_integral_deterministic
+#align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.setIntegral_deterministic
 -/
 
 end Deterministic
@@ -594,12 +594,12 @@ theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [
 #align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
 -/
 
-#print ProbabilityTheory.kernel.set_integral_const /-
+#print ProbabilityTheory.kernel.setIntegral_const /-
 @[simp]
-theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+theorem setIntegral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
     ∫ x in s, f x ∂kernel.const α μ a = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
-#align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
+#align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.setIntegral_const
 -/
 
 end Const
@@ -667,13 +667,13 @@ theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : 
 #align probability_theory.kernel.set_lintegral_restrict ProbabilityTheory.kernel.set_lintegral_restrict
 -/
 
-#print ProbabilityTheory.kernel.set_integral_restrict /-
+#print ProbabilityTheory.kernel.setIntegral_restrict /-
 @[simp]
-theorem set_integral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
-    [CompleteSpace E] {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
+theorem setIntegral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+    {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
     ∫ x in t, f x ∂kernel.restrict κ hs a = ∫ x in t ∩ s, f x ∂κ a := by
   rw [restrict_apply, measure.restrict_restrict' hs]
-#align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.set_integral_restrict
+#align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.setIntegral_restrict
 -/
 
 #print ProbabilityTheory.kernel.IsFiniteKernel.restrict /-
@@ -858,12 +858,12 @@ theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
 -/
 
-#print ProbabilityTheory.kernel.set_integral_piecewise /-
-theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+#print ProbabilityTheory.kernel.setIntegral_piecewise /-
+theorem setIntegral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] (a : α) (g : β → E) (t : Set β) :
     ∫ b in t, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
-#align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.set_integral_piecewise
+#align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.setIntegral_piecewise
 -/
 
 end Piecewise
Diff
@@ -239,7 +239,7 @@ theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → ∫⁻ b, f b
     κ = η := by
   ext a s hs
   specialize h a (s.indicator fun _ => 1) (Measurable.indicator measurable_const hs)
-  simp_rw [lintegral_indicator_const hs, one_mul] at h 
+  simp_rw [lintegral_indicator_const hs, one_mul] at h
   rw [h]
 #align probability_theory.kernel.ext_fun ProbabilityTheory.kernel.ext_fun
 -/
Diff
@@ -387,7 +387,15 @@ instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFin
 
 #print ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum /-
 theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
-    (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by classical
+    (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
+  classical
+  induction' I using Finset.induction with i I hi_nmem_I h_ind h
+  · rw [Finset.sum_empty]; infer_instance
+  · rw [Finset.sum_insert hi_nmem_I]
+    haveI : is_s_finite_kernel (κs i) := h i (Finset.mem_insert_self _ _)
+    have : is_s_finite_kernel (∑ x : ι in I, κs x) :=
+      h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
+    exact is_s_finite_kernel.add _ _
 #align probability_theory.kernel.is_s_finite_kernel.finset_sum ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum
 -/
 
Diff
@@ -387,15 +387,7 @@ instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFin
 
 #print ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum /-
 theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
-    (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
-  classical
-  induction' I using Finset.induction with i I hi_nmem_I h_ind h
-  · rw [Finset.sum_empty]; infer_instance
-  · rw [Finset.sum_insert hi_nmem_I]
-    haveI : is_s_finite_kernel (κs i) := h i (Finset.mem_insert_self _ _)
-    have : is_s_finite_kernel (∑ x : ι in I, κs x) :=
-      h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
-    exact is_s_finite_kernel.add _ _
+    (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by classical
 #align probability_theory.kernel.is_s_finite_kernel.finset_sum ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum
 -/
 
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Rémy Degenne. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 -/
-import Mathbin.MeasureTheory.Integral.Bochner
-import Mathbin.MeasureTheory.Constructions.Prod.Basic
+import MeasureTheory.Integral.Bochner
+import MeasureTheory.Constructions.Prod.Basic
 
 #align_import probability.kernel.basic from "leanprover-community/mathlib"@"fd4551cfe4b7484b81c2c9ba3405edae27659676"
 
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 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.basic
-! leanprover-community/mathlib commit fd4551cfe4b7484b81c2c9ba3405edae27659676
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.MeasureTheory.Integral.Bochner
 import Mathbin.MeasureTheory.Constructions.Prod.Basic
 
+#align_import probability.kernel.basic from "leanprover-community/mathlib"@"fd4551cfe4b7484b81c2c9ba3405edae27659676"
+
 /-!
 # Markov Kernels
 
Diff
@@ -240,7 +240,7 @@ theorem ext_iff' {η : kernel α β} :
 #print ProbabilityTheory.kernel.ext_fun /-
 theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → ∫⁻ b, f b ∂κ a = ∫⁻ b, f b ∂η a) :
     κ = η := by
-  ext (a s hs)
+  ext a s hs
   specialize h a (s.indicator fun _ => 1) (Measurable.indicator measurable_const hs)
   simp_rw [lintegral_indicator_const hs, one_mul] at h 
   rw [h]
@@ -298,7 +298,7 @@ theorem sum_apply' [Countable ι] (κ : ι → kernel α β) (a : α) {s : Set 
 @[simp]
 theorem sum_zero [Countable ι] : (kernel.sum fun i : ι => (0 : kernel α β)) = 0 :=
   by
-  ext (a s hs) : 2
+  ext a s hs : 2
   rw [sum_apply' _ a hs]
   simp only [zero_apply, measure.coe_zero, Pi.zero_apply, tsum_zero]
 #align probability_theory.kernel.sum_zero ProbabilityTheory.kernel.sum_zero
@@ -307,13 +307,13 @@ theorem sum_zero [Countable ι] : (kernel.sum fun i : ι => (0 : kernel α β))
 #print ProbabilityTheory.kernel.sum_comm /-
 theorem sum_comm [Countable ι] (κ : ι → ι → kernel α β) :
     (kernel.sum fun n => kernel.sum (κ n)) = kernel.sum fun m => kernel.sum fun n => κ n m := by
-  ext (a s hs); simp_rw [sum_apply]; rw [measure.sum_comm]
+  ext a s hs; simp_rw [sum_apply]; rw [measure.sum_comm]
 #align probability_theory.kernel.sum_comm ProbabilityTheory.kernel.sum_comm
 -/
 
 #print ProbabilityTheory.kernel.sum_fintype /-
 @[simp]
-theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i := by ext (a s hs);
+theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i := by ext a s hs;
   simp only [sum_apply' κ a hs, finset_sum_apply' _ κ a s, tsum_fintype]
 #align probability_theory.kernel.sum_fintype ProbabilityTheory.kernel.sum_fintype
 -/
@@ -322,7 +322,7 @@ theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = 
 theorem sum_add [Countable ι] (κ η : ι → kernel α β) :
     (kernel.sum fun n => κ n + η n) = kernel.sum κ + kernel.sum η :=
   by
-  ext (a s hs)
+  ext a s hs
   simp only [coe_fn_add, Pi.add_apply, sum_apply, measure.sum_apply _ hs, Pi.add_apply,
     measure.coe_add, tsum_add ENNReal.summable ENNReal.summable]
 #align probability_theory.kernel.sum_add ProbabilityTheory.kernel.sum_add
@@ -344,7 +344,7 @@ instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ
     IsSFiniteKernel κ :=
   ⟨⟨fun n => if n = 0 then κ else 0, fun n => by split_ifs; exact h; infer_instance,
       by
-      ext (a s hs)
+      ext a s hs
       rw [kernel.sum_apply' _ _ hs]
       have : (fun i => ((ite (i = 0) κ 0) a) s) = fun i => ite (i = 0) (κ a s) 0 := by ext1 i;
         split_ifs <;> rfl
@@ -411,7 +411,7 @@ theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel
   refine' ⟨⟨fun n => seq (κs (e n).1) (e n).2, inferInstance, _⟩⟩
   have hκ_eq : kernel.sum κs = kernel.sum fun n => kernel.sum (seq (κs n)) := by
     simp_rw [kernel_sum_seq]
-  ext (a s hs) : 2
+  ext a s hs : 2
   rw [hκ_eq]
   simp_rw [kernel.sum_apply' _ _ hs]
   change ∑' (i) (m), seq (κs i) m a s = ∑' n, (fun im : ι × ℕ => seq (κs im.fst) im.snd a s) (e n)
Diff
@@ -78,29 +78,29 @@ instance {α β : Type _} [MeasurableSpace α] [MeasurableSpace β] :
 
 variable {α β ι : Type _} {mα : MeasurableSpace α} {mβ : MeasurableSpace β}
 
-include mα mβ
-
 namespace Kernel
 
+#print ProbabilityTheory.kernel.coeFn_zero /-
 @[simp]
 theorem coeFn_zero : ⇑(0 : kernel α β) = 0 :=
   rfl
 #align probability_theory.kernel.coe_fn_zero ProbabilityTheory.kernel.coeFn_zero
+-/
 
+#print ProbabilityTheory.kernel.coeFn_add /-
 @[simp]
 theorem coeFn_add (κ η : kernel α β) : ⇑(κ + η) = κ + η :=
   rfl
 #align probability_theory.kernel.coe_fn_add ProbabilityTheory.kernel.coeFn_add
+-/
 
-omit mα mβ
-
+#print ProbabilityTheory.kernel.coeAddHom /-
 /-- Coercion to a function as an additive monoid homomorphism. -/
 def coeAddHom (α β : Type _) [MeasurableSpace α] [MeasurableSpace β] :
     kernel α β →+ α → Measure β :=
   ⟨coeFn, coeFn_zero, coeFn_add⟩
 #align probability_theory.kernel.coe_add_hom ProbabilityTheory.kernel.coeAddHom
-
-include mα mβ
+-/
 
 #print ProbabilityTheory.kernel.zero_apply /-
 @[simp]
@@ -109,51 +109,69 @@ theorem zero_apply (a : α) : (0 : kernel α β) a = 0 :=
 #align probability_theory.kernel.zero_apply ProbabilityTheory.kernel.zero_apply
 -/
 
+#print ProbabilityTheory.kernel.coe_finset_sum /-
 @[simp]
 theorem coe_finset_sum (I : Finset ι) (κ : ι → kernel α β) : ⇑(∑ i in I, κ i) = ∑ i in I, κ i :=
   (coeAddHom α β).map_sum _ _
 #align probability_theory.kernel.coe_finset_sum ProbabilityTheory.kernel.coe_finset_sum
+-/
 
+#print ProbabilityTheory.kernel.finset_sum_apply /-
 theorem finset_sum_apply (I : Finset ι) (κ : ι → kernel α β) (a : α) :
     (∑ i in I, κ i) a = ∑ i in I, κ i a := by rw [coe_finset_sum, Finset.sum_apply]
 #align probability_theory.kernel.finset_sum_apply ProbabilityTheory.kernel.finset_sum_apply
+-/
 
+#print ProbabilityTheory.kernel.finset_sum_apply' /-
 theorem finset_sum_apply' (I : Finset ι) (κ : ι → kernel α β) (a : α) (s : Set β) :
     (∑ i in I, κ i) a s = ∑ i in I, κ i a s := by rw [finset_sum_apply, measure.finset_sum_apply]
 #align probability_theory.kernel.finset_sum_apply' ProbabilityTheory.kernel.finset_sum_apply'
+-/
 
 end Kernel
 
+#print ProbabilityTheory.IsMarkovKernel /-
 /-- A kernel is a Markov kernel if every measure in its image is a probability measure. -/
 class IsMarkovKernel (κ : kernel α β) : Prop where
   IsProbabilityMeasure : ∀ a, IsProbabilityMeasure (κ a)
 #align probability_theory.is_markov_kernel ProbabilityTheory.IsMarkovKernel
+-/
 
+#print ProbabilityTheory.IsFiniteKernel /-
 /-- A kernel is finite if every measure in its image is finite, with a uniform bound. -/
 class IsFiniteKernel (κ : kernel α β) : Prop where
   exists_univ_le : ∃ C : ℝ≥0∞, C < ∞ ∧ ∀ a, κ a Set.univ ≤ C
 #align probability_theory.is_finite_kernel ProbabilityTheory.IsFiniteKernel
+-/
 
+#print ProbabilityTheory.IsFiniteKernel.bound /-
 /-- A constant `C : ℝ≥0∞` such that `C < ∞` (`is_finite_kernel.bound_lt_top κ`) and for all
 `a : α` and `s : set β`, `κ a s ≤ C` (`measure_le_bound κ a s`). -/
 noncomputable def IsFiniteKernel.bound (κ : kernel α β) [h : IsFiniteKernel κ] : ℝ≥0∞ :=
   h.exists_univ_le.some
 #align probability_theory.is_finite_kernel.bound ProbabilityTheory.IsFiniteKernel.bound
+-/
 
+#print ProbabilityTheory.IsFiniteKernel.bound_lt_top /-
 theorem IsFiniteKernel.bound_lt_top (κ : kernel α β) [h : IsFiniteKernel κ] :
     IsFiniteKernel.bound κ < ∞ :=
   h.exists_univ_le.choose_spec.1
 #align probability_theory.is_finite_kernel.bound_lt_top ProbabilityTheory.IsFiniteKernel.bound_lt_top
+-/
 
+#print ProbabilityTheory.IsFiniteKernel.bound_ne_top /-
 theorem IsFiniteKernel.bound_ne_top (κ : kernel α β) [h : IsFiniteKernel κ] :
     IsFiniteKernel.bound κ ≠ ∞ :=
   (IsFiniteKernel.bound_lt_top κ).Ne
 #align probability_theory.is_finite_kernel.bound_ne_top ProbabilityTheory.IsFiniteKernel.bound_ne_top
+-/
 
+#print ProbabilityTheory.kernel.measure_le_bound /-
 theorem kernel.measure_le_bound (κ : kernel α β) [h : IsFiniteKernel κ] (a : α) (s : Set β) :
     κ a s ≤ IsFiniteKernel.bound κ :=
   (measure_mono (Set.subset_univ s)).trans (h.exists_univ_le.choose_spec.2 a)
 #align probability_theory.kernel.measure_le_bound ProbabilityTheory.kernel.measure_le_bound
+-/
 
 #print ProbabilityTheory.isFiniteKernel_zero /-
 instance isFiniteKernel_zero (α β : Type _) {mα : MeasurableSpace α} {mβ : MeasurableSpace β} :
@@ -163,6 +181,7 @@ instance isFiniteKernel_zero (α β : Type _) {mα : MeasurableSpace α} {mβ :
 #align probability_theory.is_finite_kernel_zero ProbabilityTheory.isFiniteKernel_zero
 -/
 
+#print ProbabilityTheory.IsFiniteKernel.add /-
 instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFiniteKernel η] :
     IsFiniteKernel (κ + η) :=
   by
@@ -173,38 +192,52 @@ instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFinite
   simp_rw [kernel.coe_fn_add, Pi.add_apply, measure.coe_add, Pi.add_apply]
   exact add_le_add (kernel.measure_le_bound _ _ _) (kernel.measure_le_bound _ _ _)
 #align probability_theory.is_finite_kernel.add ProbabilityTheory.IsFiniteKernel.add
+-/
 
 variable {κ : kernel α β}
 
+#print ProbabilityTheory.IsMarkovKernel.is_probability_measure' /-
 instance IsMarkovKernel.is_probability_measure' [h : IsMarkovKernel κ] (a : α) :
     IsProbabilityMeasure (κ a) :=
   IsMarkovKernel.isProbabilityMeasure a
 #align probability_theory.is_markov_kernel.is_probability_measure' ProbabilityTheory.IsMarkovKernel.is_probability_measure'
+-/
 
+#print ProbabilityTheory.IsFiniteKernel.isFiniteMeasure /-
 instance IsFiniteKernel.isFiniteMeasure [h : IsFiniteKernel κ] (a : α) : IsFiniteMeasure (κ a) :=
   ⟨(kernel.measure_le_bound κ a Set.univ).trans_lt (IsFiniteKernel.bound_lt_top κ)⟩
 #align probability_theory.is_finite_kernel.is_finite_measure ProbabilityTheory.IsFiniteKernel.isFiniteMeasure
+-/
 
+#print ProbabilityTheory.IsMarkovKernel.isFiniteKernel /-
 instance (priority := 100) IsMarkovKernel.isFiniteKernel [h : IsMarkovKernel κ] :
     IsFiniteKernel κ :=
   ⟨⟨1, ENNReal.one_lt_top, fun a => prob_le_one⟩⟩
 #align probability_theory.is_markov_kernel.is_finite_kernel ProbabilityTheory.IsMarkovKernel.isFiniteKernel
+-/
 
 namespace Kernel
 
+#print ProbabilityTheory.kernel.ext /-
 @[ext]
 theorem ext {η : kernel α β} (h : ∀ a, κ a = η a) : κ = η := by ext1; ext1 a; exact h a
 #align probability_theory.kernel.ext ProbabilityTheory.kernel.ext
+-/
 
+#print ProbabilityTheory.kernel.ext_iff /-
 theorem ext_iff {η : kernel α β} : κ = η ↔ ∀ a, κ a = η a :=
   ⟨fun h a => by rw [h], ext⟩
 #align probability_theory.kernel.ext_iff ProbabilityTheory.kernel.ext_iff
+-/
 
+#print ProbabilityTheory.kernel.ext_iff' /-
 theorem ext_iff' {η : kernel α β} :
     κ = η ↔ ∀ (a) (s : Set β) (hs : MeasurableSet s), κ a s = η a s := by
   simp_rw [ext_iff, measure.ext_iff]
 #align probability_theory.kernel.ext_iff' ProbabilityTheory.kernel.ext_iff'
+-/
 
+#print ProbabilityTheory.kernel.ext_fun /-
 theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → ∫⁻ b, f b ∂κ a = ∫⁻ b, f b ∂η a) :
     κ = η := by
   ext (a s hs)
@@ -212,23 +245,31 @@ theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → ∫⁻ b, f b
   simp_rw [lintegral_indicator_const hs, one_mul] at h 
   rw [h]
 #align probability_theory.kernel.ext_fun ProbabilityTheory.kernel.ext_fun
+-/
 
+#print ProbabilityTheory.kernel.ext_fun_iff /-
 theorem ext_fun_iff {η : kernel α β} :
     κ = η ↔ ∀ a f, Measurable f → ∫⁻ b, f b ∂κ a = ∫⁻ b, f b ∂η a :=
   ⟨fun h a f hf => by rw [h], ext_fun⟩
 #align probability_theory.kernel.ext_fun_iff ProbabilityTheory.kernel.ext_fun_iff
+-/
 
+#print ProbabilityTheory.kernel.measurable /-
 protected theorem measurable (κ : kernel α β) : Measurable κ :=
   κ.Prop
 #align probability_theory.kernel.measurable ProbabilityTheory.kernel.measurable
+-/
 
+#print ProbabilityTheory.kernel.measurable_coe /-
 protected theorem measurable_coe (κ : kernel α β) {s : Set β} (hs : MeasurableSet s) :
     Measurable fun a => κ a s :=
   (Measure.measurable_coe hs).comp (kernel.measurable κ)
 #align probability_theory.kernel.measurable_coe ProbabilityTheory.kernel.measurable_coe
+-/
 
 section Sum
 
+#print ProbabilityTheory.kernel.sum /-
 /-- Sum of an indexed family of kernels. -/
 protected noncomputable def sum [Countable ι] (κ : ι → kernel α β) : kernel α β
     where
@@ -238,16 +279,22 @@ protected noncomputable def sum [Countable ι] (κ : ι → kernel α β) : kern
     simp_rw [measure.sum_apply _ hs]
     exact Measurable.ennreal_tsum fun n => kernel.measurable_coe (κ n) hs
 #align probability_theory.kernel.sum ProbabilityTheory.kernel.sum
+-/
 
+#print ProbabilityTheory.kernel.sum_apply /-
 theorem sum_apply [Countable ι] (κ : ι → kernel α β) (a : α) :
     kernel.sum κ a = Measure.sum fun n => κ n a :=
   rfl
 #align probability_theory.kernel.sum_apply ProbabilityTheory.kernel.sum_apply
+-/
 
+#print ProbabilityTheory.kernel.sum_apply' /-
 theorem sum_apply' [Countable ι] (κ : ι → kernel α β) (a : α) {s : Set β} (hs : MeasurableSet s) :
     kernel.sum κ a s = ∑' n, κ n a s := by rw [sum_apply κ a, measure.sum_apply _ hs]
 #align probability_theory.kernel.sum_apply' ProbabilityTheory.kernel.sum_apply'
+-/
 
+#print ProbabilityTheory.kernel.sum_zero /-
 @[simp]
 theorem sum_zero [Countable ι] : (kernel.sum fun i : ι => (0 : kernel α β)) = 0 :=
   by
@@ -255,17 +302,23 @@ theorem sum_zero [Countable ι] : (kernel.sum fun i : ι => (0 : kernel α β))
   rw [sum_apply' _ a hs]
   simp only [zero_apply, measure.coe_zero, Pi.zero_apply, tsum_zero]
 #align probability_theory.kernel.sum_zero ProbabilityTheory.kernel.sum_zero
+-/
 
+#print ProbabilityTheory.kernel.sum_comm /-
 theorem sum_comm [Countable ι] (κ : ι → ι → kernel α β) :
     (kernel.sum fun n => kernel.sum (κ n)) = kernel.sum fun m => kernel.sum fun n => κ n m := by
   ext (a s hs); simp_rw [sum_apply]; rw [measure.sum_comm]
 #align probability_theory.kernel.sum_comm ProbabilityTheory.kernel.sum_comm
+-/
 
+#print ProbabilityTheory.kernel.sum_fintype /-
 @[simp]
 theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i := by ext (a s hs);
   simp only [sum_apply' κ a hs, finset_sum_apply' _ κ a s, tsum_fintype]
 #align probability_theory.kernel.sum_fintype ProbabilityTheory.kernel.sum_fintype
+-/
 
+#print ProbabilityTheory.kernel.sum_add /-
 theorem sum_add [Countable ι] (κ η : ι → kernel α β) :
     (kernel.sum fun n => κ n + η n) = kernel.sum κ + kernel.sum η :=
   by
@@ -273,16 +326,20 @@ theorem sum_add [Countable ι] (κ η : ι → kernel α β) :
   simp only [coe_fn_add, Pi.add_apply, sum_apply, measure.sum_apply _ hs, Pi.add_apply,
     measure.coe_add, tsum_add ENNReal.summable ENNReal.summable]
 #align probability_theory.kernel.sum_add ProbabilityTheory.kernel.sum_add
+-/
 
 end Sum
 
 section SFinite
 
+#print ProbabilityTheory.IsSFiniteKernel /-
 /-- A kernel is s-finite if it can be written as the sum of countably many finite kernels. -/
 class ProbabilityTheory.IsSFiniteKernel (κ : kernel α β) : Prop where
   tsum_finite : ∃ κs : ℕ → kernel α β, (∀ n, IsFiniteKernel (κs n)) ∧ κ = kernel.sum κs
 #align probability_theory.is_s_finite_kernel ProbabilityTheory.IsSFiniteKernel
+-/
 
+#print ProbabilityTheory.kernel.IsFiniteKernel.isSFiniteKernel /-
 instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
     IsSFiniteKernel κ :=
   ⟨⟨fun n => if n = 0 then κ else 0, fun n => by split_ifs; exact h; infer_instance,
@@ -293,33 +350,45 @@ instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ
         split_ifs <;> rfl
       rw [this, tsum_ite_eq]⟩⟩
 #align probability_theory.kernel.is_finite_kernel.is_s_finite_kernel ProbabilityTheory.kernel.IsFiniteKernel.isSFiniteKernel
+-/
 
+#print ProbabilityTheory.kernel.seq /-
 /-- A sequence of finite kernels such that `κ = kernel.sum (seq κ)`. See `is_finite_kernel_seq`
 and `kernel_sum_seq`. -/
 noncomputable def seq (κ : kernel α β) [h : IsSFiniteKernel κ] : ℕ → kernel α β :=
   h.tsum_finite.some
 #align probability_theory.kernel.seq ProbabilityTheory.kernel.seq
+-/
 
+#print ProbabilityTheory.kernel.kernel_sum_seq /-
 theorem kernel_sum_seq (κ : kernel α β) [h : IsSFiniteKernel κ] : kernel.sum (seq κ) = κ :=
   h.tsum_finite.choose_spec.2.symm
 #align probability_theory.kernel.kernel_sum_seq ProbabilityTheory.kernel.kernel_sum_seq
+-/
 
+#print ProbabilityTheory.kernel.measure_sum_seq /-
 theorem measure_sum_seq (κ : kernel α β) [h : IsSFiniteKernel κ] (a : α) :
     (Measure.sum fun n => seq κ n a) = κ a := by rw [← kernel.sum_apply, kernel_sum_seq κ]
 #align probability_theory.kernel.measure_sum_seq ProbabilityTheory.kernel.measure_sum_seq
+-/
 
+#print ProbabilityTheory.kernel.isFiniteKernel_seq /-
 instance isFiniteKernel_seq (κ : kernel α β) [h : IsSFiniteKernel κ] (n : ℕ) :
     IsFiniteKernel (kernel.seq κ n) :=
   h.tsum_finite.choose_spec.1 n
 #align probability_theory.kernel.is_finite_kernel_seq ProbabilityTheory.kernel.isFiniteKernel_seq
+-/
 
+#print ProbabilityTheory.kernel.IsSFiniteKernel.add /-
 instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFiniteKernel η] :
     IsSFiniteKernel (κ + η) :=
   by
   refine' ⟨⟨fun n => seq κ n + seq η n, fun n => inferInstance, _⟩⟩
   rw [sum_add, kernel_sum_seq κ, kernel_sum_seq η]
 #align probability_theory.kernel.is_s_finite_kernel.add ProbabilityTheory.kernel.IsSFiniteKernel.add
+-/
 
+#print ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum /-
 theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
     (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
   classical
@@ -331,8 +400,10 @@ theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
       h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
     exact is_s_finite_kernel.add _ _
 #align probability_theory.kernel.is_s_finite_kernel.finset_sum ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i m) -/
+#print ProbabilityTheory.kernel.isSFiniteKernel_sum_of_denumerable /-
 theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel α β}
     (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) :=
   by
@@ -348,7 +419,9 @@ theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel
   · rw [tsum_prod' ENNReal.summable fun _ => ENNReal.summable]
   · infer_instance
 #align probability_theory.kernel.is_s_finite_kernel_sum_of_denumerable ProbabilityTheory.kernel.isSFiniteKernel_sum_of_denumerable
+-/
 
+#print ProbabilityTheory.kernel.isSFiniteKernel_sum /-
 theorem isSFiniteKernel_sum [Countable ι] {κs : ι → kernel α β}
     (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) :=
   by
@@ -359,11 +432,13 @@ theorem isSFiniteKernel_sum [Countable ι] {κs : ι → kernel α β}
   haveI : Denumerable ι := Denumerable.ofEncodableOfInfinite ι
   exact is_s_finite_kernel_sum_of_denumerable hκs
 #align probability_theory.kernel.is_s_finite_kernel_sum ProbabilityTheory.kernel.isSFiniteKernel_sum
+-/
 
 end SFinite
 
 section Deterministic
 
+#print ProbabilityTheory.kernel.deterministic /-
 /-- Kernel which to `a` associates the dirac measure at `f a`. This is a Markov kernel. -/
 noncomputable def deterministic (f : α → β) (hf : Measurable f) : kernel α β
     where
@@ -373,12 +448,16 @@ noncomputable def deterministic (f : α → β) (hf : Measurable f) : kernel α
     simp_rw [measure.dirac_apply' _ hs]
     exact measurable_one.indicator (hf hs)
 #align probability_theory.kernel.deterministic ProbabilityTheory.kernel.deterministic
+-/
 
+#print ProbabilityTheory.kernel.deterministic_apply /-
 theorem deterministic_apply {f : α → β} (hf : Measurable f) (a : α) :
     deterministic f hf a = Measure.dirac (f a) :=
   rfl
 #align probability_theory.kernel.deterministic_apply ProbabilityTheory.kernel.deterministic_apply
+-/
 
+#print ProbabilityTheory.kernel.deterministic_apply' /-
 theorem deterministic_apply' {f : α → β} (hf : Measurable f) (a : α) {s : Set β}
     (hs : MeasurableSet s) : deterministic f hf a s = s.indicator (fun _ => 1) (f a) :=
   by
@@ -386,6 +465,7 @@ theorem deterministic_apply' {f : α → β} (hf : Measurable f) (a : α) {s : S
   change measure.dirac (f a) s = s.indicator 1 (f a)
   simp_rw [measure.dirac_apply' _ hs]
 #align probability_theory.kernel.deterministic_apply' ProbabilityTheory.kernel.deterministic_apply'
+-/
 
 #print ProbabilityTheory.kernel.isMarkovKernel_deterministic /-
 instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
@@ -394,50 +474,65 @@ instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
 #align probability_theory.kernel.is_markov_kernel_deterministic ProbabilityTheory.kernel.isMarkovKernel_deterministic
 -/
 
+#print ProbabilityTheory.kernel.lintegral_deterministic' /-
 theorem lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     (hf : Measurable f) : ∫⁻ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, lintegral_dirac' _ hf]
 #align probability_theory.kernel.lintegral_deterministic' ProbabilityTheory.kernel.lintegral_deterministic'
+-/
 
+#print ProbabilityTheory.kernel.lintegral_deterministic /-
 @[simp]
 theorem lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] : ∫⁻ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, lintegral_dirac (g a) f]
 #align probability_theory.kernel.lintegral_deterministic ProbabilityTheory.kernel.lintegral_deterministic
+-/
 
+#print ProbabilityTheory.kernel.set_lintegral_deterministic' /-
 theorem set_lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
     ∫⁻ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_lintegral_dirac' hf hs]
 #align probability_theory.kernel.set_lintegral_deterministic' ProbabilityTheory.kernel.set_lintegral_deterministic'
+-/
 
+#print ProbabilityTheory.kernel.set_lintegral_deterministic /-
 @[simp]
 theorem set_lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
     ∫⁻ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_lintegral_dirac f s]
 #align probability_theory.kernel.set_lintegral_deterministic ProbabilityTheory.kernel.set_lintegral_deterministic
+-/
 
+#print ProbabilityTheory.kernel.integral_deterministic' /-
 theorem integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac' _ _ hf]
 #align probability_theory.kernel.integral_deterministic' ProbabilityTheory.kernel.integral_deterministic'
+-/
 
+#print ProbabilityTheory.kernel.integral_deterministic /-
 @[simp]
 theorem integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac _ (g a)]
 #align probability_theory.kernel.integral_deterministic ProbabilityTheory.kernel.integral_deterministic
+-/
 
+#print ProbabilityTheory.kernel.set_integral_deterministic' /-
 theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac' hf _ hs]
 #align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.set_integral_deterministic'
+-/
 
+#print ProbabilityTheory.kernel.set_integral_deterministic /-
 @[simp]
 theorem set_integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
@@ -445,21 +540,20 @@ theorem set_integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSp
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac f _ s]
 #align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.set_integral_deterministic
+-/
 
 end Deterministic
 
 section Const
 
-omit mα mβ
-
+#print ProbabilityTheory.kernel.const /-
 /-- Constant kernel, which always returns the same measure. -/
 def const (α : Type _) {β : Type _} [MeasurableSpace α] {mβ : MeasurableSpace β} (μβ : Measure β) :
     kernel α β where
   val _ := μβ
   property := Measure.measurable_of_measurable_coe _ fun s hs => measurable_const
 #align probability_theory.kernel.const ProbabilityTheory.kernel.const
-
-include mα mβ
+-/
 
 #print ProbabilityTheory.kernel.const_apply /-
 theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
@@ -513,8 +607,7 @@ theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ
 
 end Const
 
-omit mα
-
+#print ProbabilityTheory.kernel.ofFunOfCountable /-
 /-- In a countable space with measurable singletons, every function `α → measure β` defines a
 kernel. -/
 def ofFunOfCountable [MeasurableSpace α] {mβ : MeasurableSpace β} [Countable α]
@@ -523,13 +616,13 @@ def ofFunOfCountable [MeasurableSpace α] {mβ : MeasurableSpace β} [Countable
   val := f
   property := measurable_of_countable f
 #align probability_theory.kernel.of_fun_of_countable ProbabilityTheory.kernel.ofFunOfCountable
-
-include mα
+-/
 
 section Restrict
 
 variable {s t : Set β}
 
+#print ProbabilityTheory.kernel.restrict /-
 /-- Kernel given by the restriction of the measures in the image of a kernel to a set. -/
 protected noncomputable def restrict (κ : kernel α β) (hs : MeasurableSet s) : kernel α β
     where
@@ -539,40 +632,54 @@ protected noncomputable def restrict (κ : kernel α β) (hs : MeasurableSet s)
     simp_rw [measure.restrict_apply ht]
     exact kernel.measurable_coe κ (ht.inter hs)
 #align probability_theory.kernel.restrict ProbabilityTheory.kernel.restrict
+-/
 
+#print ProbabilityTheory.kernel.restrict_apply /-
 theorem restrict_apply (κ : kernel α β) (hs : MeasurableSet s) (a : α) :
     kernel.restrict κ hs a = (κ a).restrict s :=
   rfl
 #align probability_theory.kernel.restrict_apply ProbabilityTheory.kernel.restrict_apply
+-/
 
+#print ProbabilityTheory.kernel.restrict_apply' /-
 theorem restrict_apply' (κ : kernel α β) (hs : MeasurableSet s) (a : α) (ht : MeasurableSet t) :
     kernel.restrict κ hs a t = (κ a) (t ∩ s) := by
   rw [restrict_apply κ hs a, measure.restrict_apply ht]
 #align probability_theory.kernel.restrict_apply' ProbabilityTheory.kernel.restrict_apply'
+-/
 
+#print ProbabilityTheory.kernel.restrict_univ /-
 @[simp]
 theorem restrict_univ : kernel.restrict κ MeasurableSet.univ = κ := by ext1 a;
   rw [kernel.restrict_apply, measure.restrict_univ]
 #align probability_theory.kernel.restrict_univ ProbabilityTheory.kernel.restrict_univ
+-/
 
+#print ProbabilityTheory.kernel.lintegral_restrict /-
 @[simp]
 theorem lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞) :
     ∫⁻ b, f b ∂kernel.restrict κ hs a = ∫⁻ b in s, f b ∂κ a := by rw [restrict_apply]
 #align probability_theory.kernel.lintegral_restrict ProbabilityTheory.kernel.lintegral_restrict
+-/
 
+#print ProbabilityTheory.kernel.set_lintegral_restrict /-
 @[simp]
 theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞)
     (t : Set β) : ∫⁻ b in t, f b ∂kernel.restrict κ hs a = ∫⁻ b in t ∩ s, f b ∂κ a := by
   rw [restrict_apply, measure.restrict_restrict' hs]
 #align probability_theory.kernel.set_lintegral_restrict ProbabilityTheory.kernel.set_lintegral_restrict
+-/
 
+#print ProbabilityTheory.kernel.set_integral_restrict /-
 @[simp]
 theorem set_integral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
     ∫ x in t, f x ∂kernel.restrict κ hs a = ∫ x in t ∩ s, f x ∂κ a := by
   rw [restrict_apply, measure.restrict_restrict' hs]
 #align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.set_integral_restrict
+-/
 
+#print ProbabilityTheory.kernel.IsFiniteKernel.restrict /-
 instance IsFiniteKernel.restrict (κ : kernel α β) [IsFiniteKernel κ] (hs : MeasurableSet s) :
     IsFiniteKernel (kernel.restrict κ hs) :=
   by
@@ -580,7 +687,9 @@ instance IsFiniteKernel.restrict (κ : kernel α β) [IsFiniteKernel κ] (hs : M
   rw [restrict_apply' κ hs a MeasurableSet.univ]
   exact measure_le_bound κ a _
 #align probability_theory.kernel.is_finite_kernel.restrict ProbabilityTheory.kernel.IsFiniteKernel.restrict
+-/
 
+#print ProbabilityTheory.kernel.IsSFiniteKernel.restrict /-
 instance IsSFiniteKernel.restrict (κ : kernel α β) [IsSFiniteKernel κ] (hs : MeasurableSet s) :
     IsSFiniteKernel (kernel.restrict κ hs) :=
   by
@@ -588,6 +697,7 @@ instance IsSFiniteKernel.restrict (κ : kernel α β) [IsSFiniteKernel κ] (hs :
   ext1 a
   simp_rw [sum_apply, restrict_apply, ← measure.restrict_sum _ hs, ← sum_apply, kernel_sum_seq]
 #align probability_theory.kernel.is_s_finite_kernel.restrict ProbabilityTheory.kernel.IsSFiniteKernel.restrict
+-/
 
 end Restrict
 
@@ -595,8 +705,7 @@ section ComapRight
 
 variable {γ : Type _} {mγ : MeasurableSpace γ} {f : γ → β}
 
-include mγ
-
+#print ProbabilityTheory.kernel.comapRight /-
 /-- Kernel with value `(κ a).comap f`, for a measurable embedding `f`. That is, for a measurable set
 `t : set β`, `comap_right κ hf a t = κ a (f '' t)`. -/
 noncomputable def comapRight (κ : kernel α β) (hf : MeasurableEmbedding f) : kernel α γ
@@ -612,18 +721,24 @@ noncomputable def comapRight (κ : kernel α β) (hf : MeasurableEmbedding f) :
     rw [this]
     exact kernel.measurable_coe _ (hf.measurable_set_image.mpr ht)
 #align probability_theory.kernel.comap_right ProbabilityTheory.kernel.comapRight
+-/
 
+#print ProbabilityTheory.kernel.comapRight_apply /-
 theorem comapRight_apply (κ : kernel α β) (hf : MeasurableEmbedding f) (a : α) :
     comapRight κ hf a = Measure.comap f (κ a) :=
   rfl
 #align probability_theory.kernel.comap_right_apply ProbabilityTheory.kernel.comapRight_apply
+-/
 
+#print ProbabilityTheory.kernel.comapRight_apply' /-
 theorem comapRight_apply' (κ : kernel α β) (hf : MeasurableEmbedding f) (a : α) {t : Set γ}
     (ht : MeasurableSet t) : comapRight κ hf a t = κ a (f '' t) := by
   rw [comap_right_apply,
     measure.comap_apply _ hf.injective (fun s => hf.measurable_set_image.mpr) _ ht]
 #align probability_theory.kernel.comap_right_apply' ProbabilityTheory.kernel.comapRight_apply'
+-/
 
+#print ProbabilityTheory.kernel.IsMarkovKernel.comapRight /-
 theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding f)
     (hκ : ∀ a, κ a (Set.range f) = 1) : IsMarkovKernel (comapRight κ hf) :=
   by
@@ -632,7 +747,9 @@ theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding
   simp only [Set.image_univ, Subtype.range_coe_subtype, Set.setOf_mem_eq]
   exact hκ a
 #align probability_theory.kernel.is_markov_kernel.comap_right ProbabilityTheory.kernel.IsMarkovKernel.comapRight
+-/
 
+#print ProbabilityTheory.kernel.IsFiniteKernel.comapRight /-
 instance IsFiniteKernel.comapRight (κ : kernel α β) [IsFiniteKernel κ]
     (hf : MeasurableEmbedding f) : IsFiniteKernel (comapRight κ hf) :=
   by
@@ -640,7 +757,9 @@ instance IsFiniteKernel.comapRight (κ : kernel α β) [IsFiniteKernel κ]
   rw [comap_right_apply' κ hf a MeasurableSet.univ]
   exact measure_le_bound κ a _
 #align probability_theory.kernel.is_finite_kernel.comap_right ProbabilityTheory.kernel.IsFiniteKernel.comapRight
+-/
 
+#print ProbabilityTheory.kernel.IsSFiniteKernel.comapRight /-
 instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
     (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) :=
   by
@@ -659,6 +778,7 @@ instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
     rw [measure.comap_apply _ hf.injective (fun s' => hf.measurable_set_image.mpr) _ ht]
   rw [this, measure_sum_seq]
 #align probability_theory.kernel.is_s_finite_kernel.comap_right ProbabilityTheory.kernel.IsSFiniteKernel.comapRight
+-/
 
 end ComapRight
 
@@ -666,6 +786,7 @@ section Piecewise
 
 variable {η : kernel α β} {s : Set α} {hs : MeasurableSet s} [DecidablePred (· ∈ s)]
 
+#print ProbabilityTheory.kernel.piecewise /-
 /-- `piecewise hs κ η` is the kernel equal to `κ` on the measurable set `s` and to `η` on its
 complement. -/
 def piecewise (hs : MeasurableSet s) (κ η : kernel α β) : kernel α β
@@ -673,21 +794,29 @@ def piecewise (hs : MeasurableSet s) (κ η : kernel α β) : kernel α β
   val a := if a ∈ s then κ a else η a
   property := Measurable.piecewise hs (kernel.measurable _) (kernel.measurable _)
 #align probability_theory.kernel.piecewise ProbabilityTheory.kernel.piecewise
+-/
 
+#print ProbabilityTheory.kernel.piecewise_apply /-
 theorem piecewise_apply (a : α) : piecewise hs κ η a = if a ∈ s then κ a else η a :=
   rfl
 #align probability_theory.kernel.piecewise_apply ProbabilityTheory.kernel.piecewise_apply
+-/
 
+#print ProbabilityTheory.kernel.piecewise_apply' /-
 theorem piecewise_apply' (a : α) (t : Set β) :
     piecewise hs κ η a t = if a ∈ s then κ a t else η a t := by rw [piecewise_apply];
   split_ifs <;> rfl
 #align probability_theory.kernel.piecewise_apply' ProbabilityTheory.kernel.piecewise_apply'
+-/
 
+#print ProbabilityTheory.kernel.IsMarkovKernel.piecewise /-
 instance IsMarkovKernel.piecewise [IsMarkovKernel κ] [IsMarkovKernel η] :
     IsMarkovKernel (piecewise hs κ η) := by refine' ⟨fun a => ⟨_⟩⟩;
   rw [piecewise_apply', measure_univ, measure_univ, if_t_t]
 #align probability_theory.kernel.is_markov_kernel.piecewise ProbabilityTheory.kernel.IsMarkovKernel.piecewise
+-/
 
+#print ProbabilityTheory.kernel.IsFiniteKernel.piecewise /-
 instance IsFiniteKernel.piecewise [IsFiniteKernel κ] [IsFiniteKernel η] :
     IsFiniteKernel (piecewise hs κ η) :=
   by
@@ -696,7 +825,9 @@ instance IsFiniteKernel.piecewise [IsFiniteKernel κ] [IsFiniteKernel η] :
   rw [piecewise_apply']
   exact (ite_le_sup _ _ _).trans (sup_le_sup (measure_le_bound _ _ _) (measure_le_bound _ _ _))
 #align probability_theory.kernel.is_finite_kernel.piecewise ProbabilityTheory.kernel.IsFiniteKernel.piecewise
+-/
 
+#print ProbabilityTheory.kernel.IsSFiniteKernel.piecewise /-
 instance IsSFiniteKernel.piecewise [IsSFiniteKernel κ] [IsSFiniteKernel η] :
     IsSFiniteKernel (piecewise hs κ η) :=
   by
@@ -705,29 +836,38 @@ instance IsSFiniteKernel.piecewise [IsSFiniteKernel κ] [IsSFiniteKernel η] :
   simp_rw [sum_apply, kernel.piecewise_apply]
   split_ifs <;> exact (measure_sum_seq _ a).symm
 #align probability_theory.kernel.is_s_finite_kernel.piecewise ProbabilityTheory.kernel.IsSFiniteKernel.piecewise
+-/
 
+#print ProbabilityTheory.kernel.lintegral_piecewise /-
 theorem lintegral_piecewise (a : α) (g : β → ℝ≥0∞) :
     ∫⁻ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.lintegral_piecewise ProbabilityTheory.kernel.lintegral_piecewise
+-/
 
+#print ProbabilityTheory.kernel.set_lintegral_piecewise /-
 theorem set_lintegral_piecewise (a : α) (g : β → ℝ≥0∞) (t : Set β) :
     ∫⁻ b in t, g b ∂piecewise hs κ η a =
       if a ∈ s then ∫⁻ b in t, g b ∂κ a else ∫⁻ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_lintegral_piecewise ProbabilityTheory.kernel.set_lintegral_piecewise
+-/
 
+#print ProbabilityTheory.kernel.integral_piecewise /-
 theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     (a : α) (g : β → E) :
     ∫ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
+-/
 
+#print ProbabilityTheory.kernel.set_integral_piecewise /-
 theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] (a : α) (g : β → E) (t : Set β) :
     ∫ b in t, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.set_integral_piecewise
+-/
 
 end Piecewise
 
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.basic
-! leanprover-community/mathlib commit fd5edc43dc4f10b85abfe544b88f82cf13c5f844
+! leanprover-community/mathlib commit fd4551cfe4b7484b81c2c9ba3405edae27659676
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.MeasureTheory.Constructions.Prod.Basic
 /-!
 # Markov Kernels
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 A kernel from a measurable space `α` to another measurable space `β` is a measurable map
 `α → measure β`, where the measurable space instance on `measure β` is the one defined in
 `measure_theory.measure.measurable_space`. That is, a kernel `κ` verifies that for all measurable
Diff
@@ -202,7 +202,7 @@ theorem ext_iff' {η : kernel α β} :
   simp_rw [ext_iff, measure.ext_iff]
 #align probability_theory.kernel.ext_iff' ProbabilityTheory.kernel.ext_iff'
 
-theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a) :
+theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → ∫⁻ b, f b ∂κ a = ∫⁻ b, f b ∂η a) :
     κ = η := by
   ext (a s hs)
   specialize h a (s.indicator fun _ => 1) (Measurable.indicator measurable_const hs)
@@ -211,7 +211,7 @@ theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f
 #align probability_theory.kernel.ext_fun ProbabilityTheory.kernel.ext_fun
 
 theorem ext_fun_iff {η : kernel α β} :
-    κ = η ↔ ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a :=
+    κ = η ↔ ∀ a f, Measurable f → ∫⁻ b, f b ∂κ a = ∫⁻ b, f b ∂η a :=
   ⟨fun h a f hf => by rw [h], ext_fun⟩
 #align probability_theory.kernel.ext_fun_iff ProbabilityTheory.kernel.ext_fun_iff
 
@@ -340,7 +340,7 @@ theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel
   ext (a s hs) : 2
   rw [hκ_eq]
   simp_rw [kernel.sum_apply' _ _ hs]
-  change (∑' (i) (m), seq (κs i) m a s) = ∑' n, (fun im : ι × ℕ => seq (κs im.fst) im.snd a s) (e n)
+  change ∑' (i) (m), seq (κs i) m a s = ∑' n, (fun im : ι × ℕ => seq (κs im.fst) im.snd a s) (e n)
   rw [e.tsum_eq]
   · rw [tsum_prod' ENNReal.summable fun _ => ENNReal.summable]
   · infer_instance
@@ -392,46 +392,46 @@ instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
 -/
 
 theorem lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
-    (hf : Measurable f) : (∫⁻ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    (hf : Measurable f) : ∫⁻ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, lintegral_dirac' _ hf]
 #align probability_theory.kernel.lintegral_deterministic' ProbabilityTheory.kernel.lintegral_deterministic'
 
 @[simp]
 theorem lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
-    [MeasurableSingletonClass β] : (∫⁻ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    [MeasurableSingletonClass β] : ∫⁻ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, lintegral_dirac (g a) f]
 #align probability_theory.kernel.lintegral_deterministic ProbabilityTheory.kernel.lintegral_deterministic
 
 theorem set_lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
-    (∫⁻ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫⁻ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_lintegral_dirac' hf hs]
 #align probability_theory.kernel.set_lintegral_deterministic' ProbabilityTheory.kernel.set_lintegral_deterministic'
 
 @[simp]
 theorem set_lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
-    (∫⁻ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫⁻ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_lintegral_dirac f s]
 #align probability_theory.kernel.set_lintegral_deterministic ProbabilityTheory.kernel.set_lintegral_deterministic
 
 theorem integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
-    (hf : StronglyMeasurable f) : (∫ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    (hf : StronglyMeasurable f) : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac' _ _ hf]
 #align probability_theory.kernel.integral_deterministic' ProbabilityTheory.kernel.integral_deterministic'
 
 @[simp]
 theorem integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
-    [MeasurableSingletonClass β] : (∫ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    [MeasurableSingletonClass β] : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac _ (g a)]
 #align probability_theory.kernel.integral_deterministic ProbabilityTheory.kernel.integral_deterministic
 
 theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
-    (∫ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac' hf _ hs]
 #align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.set_integral_deterministic'
 
@@ -439,7 +439,7 @@ theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedS
 theorem set_integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
-    (∫ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac f _ s]
 #align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.set_integral_deterministic
 
@@ -481,21 +481,21 @@ instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure
 #print ProbabilityTheory.kernel.lintegral_const /-
 @[simp]
 theorem lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} :
-    (∫⁻ x, f x ∂kernel.const α μ a) = ∫⁻ x, f x ∂μ := by rw [kernel.const_apply]
+    ∫⁻ x, f x ∂kernel.const α μ a = ∫⁻ x, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.lintegral_const ProbabilityTheory.kernel.lintegral_const
 -/
 
 #print ProbabilityTheory.kernel.set_lintegral_const /-
 @[simp]
 theorem set_lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} {s : Set β} :
-    (∫⁻ x in s, f x ∂kernel.const α μ a) = ∫⁻ x in s, f x ∂μ := by rw [kernel.const_apply]
+    ∫⁻ x in s, f x ∂kernel.const α μ a = ∫⁻ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_lintegral_const ProbabilityTheory.kernel.set_lintegral_const
 -/
 
 #print ProbabilityTheory.kernel.integral_const /-
 @[simp]
 theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
-    {f : β → E} {μ : Measure β} {a : α} : (∫ x, f x ∂kernel.const α μ a) = ∫ x, f x ∂μ := by
+    {f : β → E} {μ : Measure β} {a : α} : ∫ x, f x ∂kernel.const α μ a = ∫ x, f x ∂μ := by
   rw [kernel.const_apply]
 #align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
 -/
@@ -504,7 +504,7 @@ theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [
 @[simp]
 theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
-    (∫ x in s, f x ∂kernel.const α μ a) = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
+    ∫ x in s, f x ∂kernel.const α μ a = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
 -/
 
@@ -554,19 +554,19 @@ theorem restrict_univ : kernel.restrict κ MeasurableSet.univ = κ := by ext1 a;
 
 @[simp]
 theorem lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞) :
-    (∫⁻ b, f b ∂kernel.restrict κ hs a) = ∫⁻ b in s, f b ∂κ a := by rw [restrict_apply]
+    ∫⁻ b, f b ∂kernel.restrict κ hs a = ∫⁻ b in s, f b ∂κ a := by rw [restrict_apply]
 #align probability_theory.kernel.lintegral_restrict ProbabilityTheory.kernel.lintegral_restrict
 
 @[simp]
 theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞)
-    (t : Set β) : (∫⁻ b in t, f b ∂kernel.restrict κ hs a) = ∫⁻ b in t ∩ s, f b ∂κ a := by
+    (t : Set β) : ∫⁻ b in t, f b ∂kernel.restrict κ hs a = ∫⁻ b in t ∩ s, f b ∂κ a := by
   rw [restrict_apply, measure.restrict_restrict' hs]
 #align probability_theory.kernel.set_lintegral_restrict ProbabilityTheory.kernel.set_lintegral_restrict
 
 @[simp]
 theorem set_integral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
-    (∫ x in t, f x ∂kernel.restrict κ hs a) = ∫ x in t ∩ s, f x ∂κ a := by
+    ∫ x in t, f x ∂kernel.restrict κ hs a = ∫ x in t ∩ s, f x ∂κ a := by
   rw [restrict_apply, measure.restrict_restrict' hs]
 #align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.set_integral_restrict
 
@@ -704,26 +704,25 @@ instance IsSFiniteKernel.piecewise [IsSFiniteKernel κ] [IsSFiniteKernel η] :
 #align probability_theory.kernel.is_s_finite_kernel.piecewise ProbabilityTheory.kernel.IsSFiniteKernel.piecewise
 
 theorem lintegral_piecewise (a : α) (g : β → ℝ≥0∞) :
-    (∫⁻ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a := by
+    ∫⁻ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.lintegral_piecewise ProbabilityTheory.kernel.lintegral_piecewise
 
 theorem set_lintegral_piecewise (a : α) (g : β → ℝ≥0∞) (t : Set β) :
-    (∫⁻ b in t, g b ∂piecewise hs κ η a) =
+    ∫⁻ b in t, g b ∂piecewise hs κ η a =
       if a ∈ s then ∫⁻ b in t, g b ∂κ a else ∫⁻ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_lintegral_piecewise ProbabilityTheory.kernel.set_lintegral_piecewise
 
 theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     (a : α) (g : β → E) :
-    (∫ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
+    ∫ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
 
 theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] (a : α) (g : β → E) (t : Set β) :
-    (∫ b in t, g b ∂piecewise hs κ η a) =
-      if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
+    ∫ b in t, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.set_integral_piecewise
 
Diff
@@ -56,6 +56,7 @@ open scoped MeasureTheory ENNReal NNReal BigOperators
 
 namespace ProbabilityTheory
 
+#print ProbabilityTheory.kernel /-
 /-- A kernel from a measurable space `α` to another measurable space `β` is a measurable function
 `κ : α → measure β`. The measurable space structure on `measure β` is given by
 `measure_theory.measure.measurable_space`. A map `κ : α → measure β` is measurable iff
@@ -66,6 +67,7 @@ def kernel (α β : Type _) [MeasurableSpace α] [MeasurableSpace β] : AddSubmo
   zero_mem' := measurable_zero
   add_mem' f g hf hg := Measurable.add hf hg
 #align probability_theory.kernel ProbabilityTheory.kernel
+-/
 
 instance {α β : Type _} [MeasurableSpace α] [MeasurableSpace β] :
     CoeFun (kernel α β) fun _ => α → Measure β :=
@@ -97,10 +99,12 @@ def coeAddHom (α β : Type _) [MeasurableSpace α] [MeasurableSpace β] :
 
 include mα mβ
 
+#print ProbabilityTheory.kernel.zero_apply /-
 @[simp]
 theorem zero_apply (a : α) : (0 : kernel α β) a = 0 :=
   rfl
 #align probability_theory.kernel.zero_apply ProbabilityTheory.kernel.zero_apply
+-/
 
 @[simp]
 theorem coe_finset_sum (I : Finset ι) (κ : ι → kernel α β) : ⇑(∑ i in I, κ i) = ∑ i in I, κ i :=
@@ -148,11 +152,13 @@ theorem kernel.measure_le_bound (κ : kernel α β) [h : IsFiniteKernel κ] (a :
   (measure_mono (Set.subset_univ s)).trans (h.exists_univ_le.choose_spec.2 a)
 #align probability_theory.kernel.measure_le_bound ProbabilityTheory.kernel.measure_le_bound
 
+#print ProbabilityTheory.isFiniteKernel_zero /-
 instance isFiniteKernel_zero (α β : Type _) {mα : MeasurableSpace α} {mβ : MeasurableSpace β} :
     IsFiniteKernel (0 : kernel α β) :=
   ⟨⟨0, ENNReal.coe_lt_top, fun a => by
       simp only [kernel.zero_apply, measure.coe_zero, Pi.zero_apply, le_zero_iff]⟩⟩
 #align probability_theory.is_finite_kernel_zero ProbabilityTheory.isFiniteKernel_zero
+-/
 
 instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFiniteKernel η] :
     IsFiniteKernel (κ + η) :=
@@ -378,10 +384,12 @@ theorem deterministic_apply' {f : α → β} (hf : Measurable f) (a : α) {s : S
   simp_rw [measure.dirac_apply' _ hs]
 #align probability_theory.kernel.deterministic_apply' ProbabilityTheory.kernel.deterministic_apply'
 
+#print ProbabilityTheory.kernel.isMarkovKernel_deterministic /-
 instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
     IsMarkovKernel (deterministic f hf) :=
   ⟨fun a => by rw [deterministic_apply hf]; infer_instance⟩
 #align probability_theory.kernel.is_markov_kernel_deterministic ProbabilityTheory.kernel.isMarkovKernel_deterministic
+-/
 
 theorem lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     (hf : Measurable f) : (∫⁻ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
@@ -450,41 +458,55 @@ def const (α : Type _) {β : Type _} [MeasurableSpace α] {mβ : MeasurableSpac
 
 include mα mβ
 
+#print ProbabilityTheory.kernel.const_apply /-
 theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
   rfl
 #align probability_theory.kernel.const_apply ProbabilityTheory.kernel.const_apply
+-/
 
+#print ProbabilityTheory.kernel.isFiniteKernel_const /-
 instance isFiniteKernel_const {μβ : Measure β} [hμβ : IsFiniteMeasure μβ] :
     IsFiniteKernel (const α μβ) :=
   ⟨⟨μβ Set.univ, measure_lt_top _ _, fun a => le_rfl⟩⟩
 #align probability_theory.kernel.is_finite_kernel_const ProbabilityTheory.kernel.isFiniteKernel_const
+-/
 
+#print ProbabilityTheory.kernel.isMarkovKernel_const /-
 instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure μβ] :
     IsMarkovKernel (const α μβ) :=
   ⟨fun a => hμβ⟩
 #align probability_theory.kernel.is_markov_kernel_const ProbabilityTheory.kernel.isMarkovKernel_const
+-/
 
+#print ProbabilityTheory.kernel.lintegral_const /-
 @[simp]
 theorem lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} :
     (∫⁻ x, f x ∂kernel.const α μ a) = ∫⁻ x, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.lintegral_const ProbabilityTheory.kernel.lintegral_const
+-/
 
+#print ProbabilityTheory.kernel.set_lintegral_const /-
 @[simp]
 theorem set_lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} {s : Set β} :
     (∫⁻ x in s, f x ∂kernel.const α μ a) = ∫⁻ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_lintegral_const ProbabilityTheory.kernel.set_lintegral_const
+-/
 
+#print ProbabilityTheory.kernel.integral_const /-
 @[simp]
 theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     {f : β → E} {μ : Measure β} {a : α} : (∫ x, f x ∂kernel.const α μ a) = ∫ x, f x ∂μ := by
   rw [kernel.const_apply]
 #align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
+-/
 
+#print ProbabilityTheory.kernel.set_integral_const /-
 @[simp]
 theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
     (∫ x in s, f x ∂kernel.const α μ a) = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
+-/
 
 end Const
 
Diff
@@ -119,7 +119,7 @@ end Kernel
 
 /-- A kernel is a Markov kernel if every measure in its image is a probability measure. -/
 class IsMarkovKernel (κ : kernel α β) : Prop where
-  ProbabilityMeasure : ∀ a, ProbabilityMeasure (κ a)
+  IsProbabilityMeasure : ∀ a, IsProbabilityMeasure (κ a)
 #align probability_theory.is_markov_kernel ProbabilityTheory.IsMarkovKernel
 
 /-- A kernel is finite if every measure in its image is finite, with a uniform bound. -/
@@ -168,13 +168,13 @@ instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFinite
 variable {κ : kernel α β}
 
 instance IsMarkovKernel.is_probability_measure' [h : IsMarkovKernel κ] (a : α) :
-    ProbabilityMeasure (κ a) :=
-  IsMarkovKernel.probabilityMeasure a
+    IsProbabilityMeasure (κ a) :=
+  IsMarkovKernel.isProbabilityMeasure a
 #align probability_theory.is_markov_kernel.is_probability_measure' ProbabilityTheory.IsMarkovKernel.is_probability_measure'
 
-instance IsFiniteKernel.finiteMeasure [h : IsFiniteKernel κ] (a : α) : FiniteMeasure (κ a) :=
+instance IsFiniteKernel.isFiniteMeasure [h : IsFiniteKernel κ] (a : α) : IsFiniteMeasure (κ a) :=
   ⟨(kernel.measure_le_bound κ a Set.univ).trans_lt (IsFiniteKernel.bound_lt_top κ)⟩
-#align probability_theory.is_finite_kernel.is_finite_measure ProbabilityTheory.IsFiniteKernel.finiteMeasure
+#align probability_theory.is_finite_kernel.is_finite_measure ProbabilityTheory.IsFiniteKernel.isFiniteMeasure
 
 instance (priority := 100) IsMarkovKernel.isFiniteKernel [h : IsMarkovKernel κ] :
     IsFiniteKernel κ :=
@@ -314,13 +314,13 @@ instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFin
 theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
     (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
   classical
-    induction' I using Finset.induction with i I hi_nmem_I h_ind h
-    · rw [Finset.sum_empty]; infer_instance
-    · rw [Finset.sum_insert hi_nmem_I]
-      haveI : is_s_finite_kernel (κs i) := h i (Finset.mem_insert_self _ _)
-      have : is_s_finite_kernel (∑ x : ι in I, κs x) :=
-        h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
-      exact is_s_finite_kernel.add _ _
+  induction' I using Finset.induction with i I hi_nmem_I h_ind h
+  · rw [Finset.sum_empty]; infer_instance
+  · rw [Finset.sum_insert hi_nmem_I]
+    haveI : is_s_finite_kernel (κs i) := h i (Finset.mem_insert_self _ _)
+    have : is_s_finite_kernel (∑ x : ι in I, κs x) :=
+      h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
+    exact is_s_finite_kernel.add _ _
 #align probability_theory.kernel.is_s_finite_kernel.finset_sum ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i m) -/
@@ -454,12 +454,12 @@ theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
   rfl
 #align probability_theory.kernel.const_apply ProbabilityTheory.kernel.const_apply
 
-instance isFiniteKernel_const {μβ : Measure β} [hμβ : FiniteMeasure μβ] :
+instance isFiniteKernel_const {μβ : Measure β} [hμβ : IsFiniteMeasure μβ] :
     IsFiniteKernel (const α μβ) :=
   ⟨⟨μβ Set.univ, measure_lt_top _ _, fun a => le_rfl⟩⟩
 #align probability_theory.kernel.is_finite_kernel_const ProbabilityTheory.kernel.isFiniteKernel_const
 
-instance isMarkovKernel_const {μβ : Measure β} [hμβ : ProbabilityMeasure μβ] :
+instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure μβ] :
     IsMarkovKernel (const α μβ) :=
   ⟨fun a => hμβ⟩
 #align probability_theory.kernel.is_markov_kernel_const ProbabilityTheory.kernel.isMarkovKernel_const
Diff
@@ -200,7 +200,7 @@ theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f
     κ = η := by
   ext (a s hs)
   specialize h a (s.indicator fun _ => 1) (Measurable.indicator measurable_const hs)
-  simp_rw [lintegral_indicator_const hs, one_mul] at h
+  simp_rw [lintegral_indicator_const hs, one_mul] at h 
   rw [h]
 #align probability_theory.kernel.ext_fun ProbabilityTheory.kernel.ext_fun
 
Diff
@@ -52,7 +52,7 @@ Particular kernels:
 
 open MeasureTheory
 
-open MeasureTheory ENNReal NNReal BigOperators
+open scoped MeasureTheory ENNReal NNReal BigOperators
 
 namespace ProbabilityTheory
 
Diff
@@ -184,11 +184,7 @@ instance (priority := 100) IsMarkovKernel.isFiniteKernel [h : IsMarkovKernel κ]
 namespace Kernel
 
 @[ext]
-theorem ext {η : kernel α β} (h : ∀ a, κ a = η a) : κ = η :=
-  by
-  ext1
-  ext1 a
-  exact h a
+theorem ext {η : kernel α β} (h : ∀ a, κ a = η a) : κ = η := by ext1; ext1 a; exact h a
 #align probability_theory.kernel.ext ProbabilityTheory.kernel.ext
 
 theorem ext_iff {η : kernel α β} : κ = η ↔ ∀ a, κ a = η a :=
@@ -252,17 +248,12 @@ theorem sum_zero [Countable ι] : (kernel.sum fun i : ι => (0 : kernel α β))
 #align probability_theory.kernel.sum_zero ProbabilityTheory.kernel.sum_zero
 
 theorem sum_comm [Countable ι] (κ : ι → ι → kernel α β) :
-    (kernel.sum fun n => kernel.sum (κ n)) = kernel.sum fun m => kernel.sum fun n => κ n m :=
-  by
-  ext (a s hs)
-  simp_rw [sum_apply]
-  rw [measure.sum_comm]
+    (kernel.sum fun n => kernel.sum (κ n)) = kernel.sum fun m => kernel.sum fun n => κ n m := by
+  ext (a s hs); simp_rw [sum_apply]; rw [measure.sum_comm]
 #align probability_theory.kernel.sum_comm ProbabilityTheory.kernel.sum_comm
 
 @[simp]
-theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i :=
-  by
-  ext (a s hs)
+theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i := by ext (a s hs);
   simp only [sum_apply' κ a hs, finset_sum_apply' _ κ a s, tsum_fintype]
 #align probability_theory.kernel.sum_fintype ProbabilityTheory.kernel.sum_fintype
 
@@ -285,15 +276,11 @@ class ProbabilityTheory.IsSFiniteKernel (κ : kernel α β) : Prop where
 
 instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
     IsSFiniteKernel κ :=
-  ⟨⟨fun n => if n = 0 then κ else 0, fun n => by
-      split_ifs
-      exact h
-      infer_instance, by
+  ⟨⟨fun n => if n = 0 then κ else 0, fun n => by split_ifs; exact h; infer_instance,
+      by
       ext (a s hs)
       rw [kernel.sum_apply' _ _ hs]
-      have : (fun i => ((ite (i = 0) κ 0) a) s) = fun i => ite (i = 0) (κ a s) 0 :=
-        by
-        ext1 i
+      have : (fun i => ((ite (i = 0) κ 0) a) s) = fun i => ite (i = 0) (κ a s) 0 := by ext1 i;
         split_ifs <;> rfl
       rw [this, tsum_ite_eq]⟩⟩
 #align probability_theory.kernel.is_finite_kernel.is_s_finite_kernel ProbabilityTheory.kernel.IsFiniteKernel.isSFiniteKernel
@@ -328,8 +315,7 @@ theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
     (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
   classical
     induction' I using Finset.induction with i I hi_nmem_I h_ind h
-    · rw [Finset.sum_empty]
-      infer_instance
+    · rw [Finset.sum_empty]; infer_instance
     · rw [Finset.sum_insert hi_nmem_I]
       haveI : is_s_finite_kernel (κs i) := h i (Finset.mem_insert_self _ _)
       have : is_s_finite_kernel (∑ x : ι in I, κs x) :=
@@ -394,9 +380,7 @@ theorem deterministic_apply' {f : α → β} (hf : Measurable f) (a : α) {s : S
 
 instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
     IsMarkovKernel (deterministic f hf) :=
-  ⟨fun a => by
-    rw [deterministic_apply hf]
-    infer_instance⟩
+  ⟨fun a => by rw [deterministic_apply hf]; infer_instance⟩
 #align probability_theory.kernel.is_markov_kernel_deterministic ProbabilityTheory.kernel.isMarkovKernel_deterministic
 
 theorem lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
@@ -542,9 +526,7 @@ theorem restrict_apply' (κ : kernel α β) (hs : MeasurableSet s) (a : α) (ht
 #align probability_theory.kernel.restrict_apply' ProbabilityTheory.kernel.restrict_apply'
 
 @[simp]
-theorem restrict_univ : kernel.restrict κ MeasurableSet.univ = κ :=
-  by
-  ext1 a
+theorem restrict_univ : kernel.restrict κ MeasurableSet.univ = κ := by ext1 a;
   rw [kernel.restrict_apply, measure.restrict_univ]
 #align probability_theory.kernel.restrict_univ ProbabilityTheory.kernel.restrict_univ
 
@@ -672,16 +654,12 @@ theorem piecewise_apply (a : α) : piecewise hs κ η a = if a ∈ s then κ a e
 #align probability_theory.kernel.piecewise_apply ProbabilityTheory.kernel.piecewise_apply
 
 theorem piecewise_apply' (a : α) (t : Set β) :
-    piecewise hs κ η a t = if a ∈ s then κ a t else η a t :=
-  by
-  rw [piecewise_apply]
+    piecewise hs κ η a t = if a ∈ s then κ a t else η a t := by rw [piecewise_apply];
   split_ifs <;> rfl
 #align probability_theory.kernel.piecewise_apply' ProbabilityTheory.kernel.piecewise_apply'
 
 instance IsMarkovKernel.piecewise [IsMarkovKernel κ] [IsMarkovKernel η] :
-    IsMarkovKernel (piecewise hs κ η) :=
-  by
-  refine' ⟨fun a => ⟨_⟩⟩
+    IsMarkovKernel (piecewise hs κ η) := by refine' ⟨fun a => ⟨_⟩⟩;
   rw [piecewise_apply', measure_univ, measure_univ, if_t_t]
 #align probability_theory.kernel.is_markov_kernel.piecewise ProbabilityTheory.kernel.IsMarkovKernel.piecewise
 
@@ -704,35 +682,27 @@ instance IsSFiniteKernel.piecewise [IsSFiniteKernel κ] [IsSFiniteKernel η] :
 #align probability_theory.kernel.is_s_finite_kernel.piecewise ProbabilityTheory.kernel.IsSFiniteKernel.piecewise
 
 theorem lintegral_piecewise (a : α) (g : β → ℝ≥0∞) :
-    (∫⁻ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a :=
-  by
-  simp_rw [piecewise_apply]
-  split_ifs <;> rfl
+    (∫⁻ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a := by
+  simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.lintegral_piecewise ProbabilityTheory.kernel.lintegral_piecewise
 
 theorem set_lintegral_piecewise (a : α) (g : β → ℝ≥0∞) (t : Set β) :
     (∫⁻ b in t, g b ∂piecewise hs κ η a) =
       if a ∈ s then ∫⁻ b in t, g b ∂κ a else ∫⁻ b in t, g b ∂η a :=
-  by
-  simp_rw [piecewise_apply]
-  split_ifs <;> rfl
+  by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_lintegral_piecewise ProbabilityTheory.kernel.set_lintegral_piecewise
 
 theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     (a : α) (g : β → E) :
-    (∫ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a :=
-  by
-  simp_rw [piecewise_apply]
-  split_ifs <;> rfl
+    (∫ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
+  simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
 
 theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] (a : α) (g : β → E) (t : Set β) :
     (∫ b in t, g b ∂piecewise hs κ η a) =
       if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
-  by
-  simp_rw [piecewise_apply]
-  split_ifs <;> rfl
+  by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.set_integral_piecewise
 
 end Piecewise
Diff
@@ -231,7 +231,7 @@ protected noncomputable def sum [Countable ι] (κ : ι → kernel α β) : kern
   property := by
     refine' measure.measurable_of_measurable_coe _ fun s hs => _
     simp_rw [measure.sum_apply _ hs]
-    exact Measurable.eNNReal_tsum fun n => kernel.measurable_coe (κ n) hs
+    exact Measurable.ennreal_tsum fun n => kernel.measurable_coe (κ n) hs
 #align probability_theory.kernel.sum ProbabilityTheory.kernel.sum
 
 theorem sum_apply [Countable ι] (κ : ι → kernel α β) (a : α) :
Diff
@@ -4,11 +4,12 @@ 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.basic
-! leanprover-community/mathlib commit a9545e8a564bac7f24637443f52ae955474e4991
+! leanprover-community/mathlib commit fd5edc43dc4f10b85abfe544b88f82cf13c5f844
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
-import Mathbin.MeasureTheory.Constructions.Prod
+import Mathbin.MeasureTheory.Integral.Bochner
+import Mathbin.MeasureTheory.Constructions.Prod.Basic
 
 /-!
 # Markov Kernels
Diff
@@ -118,7 +118,7 @@ end Kernel
 
 /-- A kernel is a Markov kernel if every measure in its image is a probability measure. -/
 class IsMarkovKernel (κ : kernel α β) : Prop where
-  IsProbabilityMeasure : ∀ a, IsProbabilityMeasure (κ a)
+  ProbabilityMeasure : ∀ a, ProbabilityMeasure (κ a)
 #align probability_theory.is_markov_kernel ProbabilityTheory.IsMarkovKernel
 
 /-- A kernel is finite if every measure in its image is finite, with a uniform bound. -/
@@ -167,13 +167,13 @@ instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFinite
 variable {κ : kernel α β}
 
 instance IsMarkovKernel.is_probability_measure' [h : IsMarkovKernel κ] (a : α) :
-    IsProbabilityMeasure (κ a) :=
-  IsMarkovKernel.isProbabilityMeasure a
+    ProbabilityMeasure (κ a) :=
+  IsMarkovKernel.probabilityMeasure a
 #align probability_theory.is_markov_kernel.is_probability_measure' ProbabilityTheory.IsMarkovKernel.is_probability_measure'
 
-instance IsFiniteKernel.isFiniteMeasure [h : IsFiniteKernel κ] (a : α) : IsFiniteMeasure (κ a) :=
+instance IsFiniteKernel.finiteMeasure [h : IsFiniteKernel κ] (a : α) : FiniteMeasure (κ a) :=
   ⟨(kernel.measure_le_bound κ a Set.univ).trans_lt (IsFiniteKernel.bound_lt_top κ)⟩
-#align probability_theory.is_finite_kernel.is_finite_measure ProbabilityTheory.IsFiniteKernel.isFiniteMeasure
+#align probability_theory.is_finite_kernel.is_finite_measure ProbabilityTheory.IsFiniteKernel.finiteMeasure
 
 instance (priority := 100) IsMarkovKernel.isFiniteKernel [h : IsMarkovKernel κ] :
     IsFiniteKernel κ :=
@@ -469,12 +469,12 @@ theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
   rfl
 #align probability_theory.kernel.const_apply ProbabilityTheory.kernel.const_apply
 
-instance isFiniteKernel_const {μβ : Measure β} [hμβ : IsFiniteMeasure μβ] :
+instance isFiniteKernel_const {μβ : Measure β} [hμβ : FiniteMeasure μβ] :
     IsFiniteKernel (const α μβ) :=
   ⟨⟨μβ Set.univ, measure_lt_top _ _, fun a => le_rfl⟩⟩
 #align probability_theory.kernel.is_finite_kernel_const ProbabilityTheory.kernel.isFiniteKernel_const
 
-instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure μβ] :
+instance isMarkovKernel_const {μβ : Measure β} [hμβ : ProbabilityMeasure μβ] :
     IsMarkovKernel (const α μβ) :=
   ⟨fun a => hμβ⟩
 #align probability_theory.kernel.is_markov_kernel_const ProbabilityTheory.kernel.isMarkovKernel_const
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.basic
-! leanprover-community/mathlib commit 483dd86cfec4a1380d22b1f6acd4c3dc53f501ff
+! leanprover-community/mathlib commit a9545e8a564bac7f24637443f52ae955474e4991
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -30,7 +30,7 @@ Classes of kernels:
   particular that all measures in the image of `κ` are finite, but is stronger since it requires an
   uniform bound. This stronger condition is necessary to ensure that the composition of two finite
   kernels is finite.
-* `probability_theory.kernel.is_s_finite_kernel κ`: a kernel is called s-finite if it is a countable
+* `probability_theory.is_s_finite_kernel κ`: a kernel is called s-finite if it is a countable
   sum of finite kernels.
 
 Particular kernels:
@@ -183,14 +183,23 @@ instance (priority := 100) IsMarkovKernel.isFiniteKernel [h : IsMarkovKernel κ]
 namespace Kernel
 
 @[ext]
-theorem ext {κ : kernel α β} {η : kernel α β} (h : ∀ a, κ a = η a) : κ = η :=
+theorem ext {η : kernel α β} (h : ∀ a, κ a = η a) : κ = η :=
   by
   ext1
   ext1 a
   exact h a
 #align probability_theory.kernel.ext ProbabilityTheory.kernel.ext
 
-theorem ext_fun {κ η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a) :
+theorem ext_iff {η : kernel α β} : κ = η ↔ ∀ a, κ a = η a :=
+  ⟨fun h a => by rw [h], ext⟩
+#align probability_theory.kernel.ext_iff ProbabilityTheory.kernel.ext_iff
+
+theorem ext_iff' {η : kernel α β} :
+    κ = η ↔ ∀ (a) (s : Set β) (hs : MeasurableSet s), κ a s = η a s := by
+  simp_rw [ext_iff, measure.ext_iff]
+#align probability_theory.kernel.ext_iff' ProbabilityTheory.kernel.ext_iff'
+
+theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a) :
     κ = η := by
   ext (a s hs)
   specialize h a (s.indicator fun _ => 1) (Measurable.indicator measurable_const hs)
@@ -198,6 +207,11 @@ theorem ext_fun {κ η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b,
   rw [h]
 #align probability_theory.kernel.ext_fun ProbabilityTheory.kernel.ext_fun
 
+theorem ext_fun_iff {η : kernel α β} :
+    κ = η ↔ ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a :=
+  ⟨fun h a f hf => by rw [h], ext_fun⟩
+#align probability_theory.kernel.ext_fun_iff ProbabilityTheory.kernel.ext_fun_iff
+
 protected theorem measurable (κ : kernel α β) : Measurable κ :=
   κ.Prop
 #align probability_theory.kernel.measurable ProbabilityTheory.kernel.measurable
@@ -264,9 +278,9 @@ end Sum
 section SFinite
 
 /-- A kernel is s-finite if it can be written as the sum of countably many finite kernels. -/
-class IsSFiniteKernel (κ : kernel α β) : Prop where
+class ProbabilityTheory.IsSFiniteKernel (κ : kernel α β) : Prop where
   tsum_finite : ∃ κs : ℕ → kernel α β, (∀ n, IsFiniteKernel (κs n)) ∧ κ = kernel.sum κs
-#align probability_theory.kernel.is_s_finite_kernel ProbabilityTheory.kernel.IsSFiniteKernel
+#align probability_theory.is_s_finite_kernel ProbabilityTheory.IsSFiniteKernel
 
 instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
     IsSFiniteKernel κ :=
@@ -384,6 +398,58 @@ instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
     infer_instance⟩
 #align probability_theory.kernel.is_markov_kernel_deterministic ProbabilityTheory.kernel.isMarkovKernel_deterministic
 
+theorem lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
+    (hf : Measurable f) : (∫⁻ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+  rw [kernel.deterministic_apply, lintegral_dirac' _ hf]
+#align probability_theory.kernel.lintegral_deterministic' ProbabilityTheory.kernel.lintegral_deterministic'
+
+@[simp]
+theorem lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
+    [MeasurableSingletonClass β] : (∫⁻ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+  rw [kernel.deterministic_apply, lintegral_dirac (g a) f]
+#align probability_theory.kernel.lintegral_deterministic ProbabilityTheory.kernel.lintegral_deterministic
+
+theorem set_lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
+    (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
+    (∫⁻ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+  rw [kernel.deterministic_apply, set_lintegral_dirac' hf hs]
+#align probability_theory.kernel.set_lintegral_deterministic' ProbabilityTheory.kernel.set_lintegral_deterministic'
+
+@[simp]
+theorem set_lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
+    [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
+    (∫⁻ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+  rw [kernel.deterministic_apply, set_lintegral_dirac f s]
+#align probability_theory.kernel.set_lintegral_deterministic ProbabilityTheory.kernel.set_lintegral_deterministic
+
+theorem integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+    [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
+    (hf : StronglyMeasurable f) : (∫ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+  rw [kernel.deterministic_apply, integral_dirac' _ _ hf]
+#align probability_theory.kernel.integral_deterministic' ProbabilityTheory.kernel.integral_deterministic'
+
+@[simp]
+theorem integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+    [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
+    [MeasurableSingletonClass β] : (∫ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+  rw [kernel.deterministic_apply, integral_dirac _ (g a)]
+#align probability_theory.kernel.integral_deterministic ProbabilityTheory.kernel.integral_deterministic
+
+theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+    [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
+    (hf : StronglyMeasurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
+    (∫ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+  rw [kernel.deterministic_apply, set_integral_dirac' hf _ hs]
+#align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.set_integral_deterministic'
+
+@[simp]
+theorem set_integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+    [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
+    [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
+    (∫ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+  rw [kernel.deterministic_apply, set_integral_dirac f _ s]
+#align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.set_integral_deterministic
+
 end Deterministic
 
 section Const
@@ -413,6 +479,28 @@ instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure
   ⟨fun a => hμβ⟩
 #align probability_theory.kernel.is_markov_kernel_const ProbabilityTheory.kernel.isMarkovKernel_const
 
+@[simp]
+theorem lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} :
+    (∫⁻ x, f x ∂kernel.const α μ a) = ∫⁻ x, f x ∂μ := by rw [kernel.const_apply]
+#align probability_theory.kernel.lintegral_const ProbabilityTheory.kernel.lintegral_const
+
+@[simp]
+theorem set_lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} {s : Set β} :
+    (∫⁻ x in s, f x ∂kernel.const α μ a) = ∫⁻ x in s, f x ∂μ := by rw [kernel.const_apply]
+#align probability_theory.kernel.set_lintegral_const ProbabilityTheory.kernel.set_lintegral_const
+
+@[simp]
+theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+    {f : β → E} {μ : Measure β} {a : α} : (∫ x, f x ∂kernel.const α μ a) = ∫ x, f x ∂μ := by
+  rw [kernel.const_apply]
+#align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
+
+@[simp]
+theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+    {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
+    (∫ x in s, f x ∂kernel.const α μ a) = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
+#align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
+
 end Const
 
 omit mα
@@ -452,10 +540,31 @@ theorem restrict_apply' (κ : kernel α β) (hs : MeasurableSet s) (a : α) (ht
   rw [restrict_apply κ hs a, measure.restrict_apply ht]
 #align probability_theory.kernel.restrict_apply' ProbabilityTheory.kernel.restrict_apply'
 
+@[simp]
+theorem restrict_univ : kernel.restrict κ MeasurableSet.univ = κ :=
+  by
+  ext1 a
+  rw [kernel.restrict_apply, measure.restrict_univ]
+#align probability_theory.kernel.restrict_univ ProbabilityTheory.kernel.restrict_univ
+
+@[simp]
 theorem lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞) :
     (∫⁻ b, f b ∂kernel.restrict κ hs a) = ∫⁻ b in s, f b ∂κ a := by rw [restrict_apply]
 #align probability_theory.kernel.lintegral_restrict ProbabilityTheory.kernel.lintegral_restrict
 
+@[simp]
+theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞)
+    (t : Set β) : (∫⁻ b in t, f b ∂kernel.restrict κ hs a) = ∫⁻ b in t ∩ s, f b ∂κ a := by
+  rw [restrict_apply, measure.restrict_restrict' hs]
+#align probability_theory.kernel.set_lintegral_restrict ProbabilityTheory.kernel.set_lintegral_restrict
+
+@[simp]
+theorem set_integral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+    [CompleteSpace E] {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
+    (∫ x in t, f x ∂kernel.restrict κ hs a) = ∫ x in t ∩ s, f x ∂κ a := by
+  rw [restrict_apply, measure.restrict_restrict' hs]
+#align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.set_integral_restrict
+
 instance IsFiniteKernel.restrict (κ : kernel α β) [IsFiniteKernel κ] (hs : MeasurableSet s) :
     IsFiniteKernel (kernel.restrict κ hs) :=
   by
@@ -474,6 +583,159 @@ instance IsSFiniteKernel.restrict (κ : kernel α β) [IsSFiniteKernel κ] (hs :
 
 end Restrict
 
+section ComapRight
+
+variable {γ : Type _} {mγ : MeasurableSpace γ} {f : γ → β}
+
+include mγ
+
+/-- Kernel with value `(κ a).comap f`, for a measurable embedding `f`. That is, for a measurable set
+`t : set β`, `comap_right κ hf a t = κ a (f '' t)`. -/
+noncomputable def comapRight (κ : kernel α β) (hf : MeasurableEmbedding f) : kernel α γ
+    where
+  val a := (κ a).comap f
+  property := by
+    refine' measure.measurable_measure.mpr fun t ht => _
+    have : (fun a => measure.comap f (κ a) t) = fun a => κ a (f '' t) :=
+      by
+      ext1 a
+      rw [measure.comap_apply _ hf.injective (fun s' hs' => _) _ ht]
+      exact hf.measurable_set_image.mpr hs'
+    rw [this]
+    exact kernel.measurable_coe _ (hf.measurable_set_image.mpr ht)
+#align probability_theory.kernel.comap_right ProbabilityTheory.kernel.comapRight
+
+theorem comapRight_apply (κ : kernel α β) (hf : MeasurableEmbedding f) (a : α) :
+    comapRight κ hf a = Measure.comap f (κ a) :=
+  rfl
+#align probability_theory.kernel.comap_right_apply ProbabilityTheory.kernel.comapRight_apply
+
+theorem comapRight_apply' (κ : kernel α β) (hf : MeasurableEmbedding f) (a : α) {t : Set γ}
+    (ht : MeasurableSet t) : comapRight κ hf a t = κ a (f '' t) := by
+  rw [comap_right_apply,
+    measure.comap_apply _ hf.injective (fun s => hf.measurable_set_image.mpr) _ ht]
+#align probability_theory.kernel.comap_right_apply' ProbabilityTheory.kernel.comapRight_apply'
+
+theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding f)
+    (hκ : ∀ a, κ a (Set.range f) = 1) : IsMarkovKernel (comapRight κ hf) :=
+  by
+  refine' ⟨fun a => ⟨_⟩⟩
+  rw [comap_right_apply' κ hf a MeasurableSet.univ]
+  simp only [Set.image_univ, Subtype.range_coe_subtype, Set.setOf_mem_eq]
+  exact hκ a
+#align probability_theory.kernel.is_markov_kernel.comap_right ProbabilityTheory.kernel.IsMarkovKernel.comapRight
+
+instance IsFiniteKernel.comapRight (κ : kernel α β) [IsFiniteKernel κ]
+    (hf : MeasurableEmbedding f) : IsFiniteKernel (comapRight κ hf) :=
+  by
+  refine' ⟨⟨is_finite_kernel.bound κ, is_finite_kernel.bound_lt_top κ, fun a => _⟩⟩
+  rw [comap_right_apply' κ hf a MeasurableSet.univ]
+  exact measure_le_bound κ a _
+#align probability_theory.kernel.is_finite_kernel.comap_right ProbabilityTheory.kernel.IsFiniteKernel.comapRight
+
+instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
+    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) :=
+  by
+  refine' ⟨⟨fun n => comap_right (seq κ n) hf, inferInstance, _⟩⟩
+  ext1 a
+  rw [sum_apply]
+  simp_rw [comap_right_apply _ hf]
+  have :
+    (measure.sum fun n => measure.comap f (seq κ n a)) =
+      measure.comap f (measure.sum fun n => seq κ n a) :=
+    by
+    ext1 t ht
+    rw [measure.comap_apply _ hf.injective (fun s' => hf.measurable_set_image.mpr) _ ht,
+      measure.sum_apply _ ht, measure.sum_apply _ (hf.measurable_set_image.mpr ht)]
+    congr with n : 1
+    rw [measure.comap_apply _ hf.injective (fun s' => hf.measurable_set_image.mpr) _ ht]
+  rw [this, measure_sum_seq]
+#align probability_theory.kernel.is_s_finite_kernel.comap_right ProbabilityTheory.kernel.IsSFiniteKernel.comapRight
+
+end ComapRight
+
+section Piecewise
+
+variable {η : kernel α β} {s : Set α} {hs : MeasurableSet s} [DecidablePred (· ∈ s)]
+
+/-- `piecewise hs κ η` is the kernel equal to `κ` on the measurable set `s` and to `η` on its
+complement. -/
+def piecewise (hs : MeasurableSet s) (κ η : kernel α β) : kernel α β
+    where
+  val a := if a ∈ s then κ a else η a
+  property := Measurable.piecewise hs (kernel.measurable _) (kernel.measurable _)
+#align probability_theory.kernel.piecewise ProbabilityTheory.kernel.piecewise
+
+theorem piecewise_apply (a : α) : piecewise hs κ η a = if a ∈ s then κ a else η a :=
+  rfl
+#align probability_theory.kernel.piecewise_apply ProbabilityTheory.kernel.piecewise_apply
+
+theorem piecewise_apply' (a : α) (t : Set β) :
+    piecewise hs κ η a t = if a ∈ s then κ a t else η a t :=
+  by
+  rw [piecewise_apply]
+  split_ifs <;> rfl
+#align probability_theory.kernel.piecewise_apply' ProbabilityTheory.kernel.piecewise_apply'
+
+instance IsMarkovKernel.piecewise [IsMarkovKernel κ] [IsMarkovKernel η] :
+    IsMarkovKernel (piecewise hs κ η) :=
+  by
+  refine' ⟨fun a => ⟨_⟩⟩
+  rw [piecewise_apply', measure_univ, measure_univ, if_t_t]
+#align probability_theory.kernel.is_markov_kernel.piecewise ProbabilityTheory.kernel.IsMarkovKernel.piecewise
+
+instance IsFiniteKernel.piecewise [IsFiniteKernel κ] [IsFiniteKernel η] :
+    IsFiniteKernel (piecewise hs κ η) :=
+  by
+  refine' ⟨⟨max (is_finite_kernel.bound κ) (is_finite_kernel.bound η), _, fun a => _⟩⟩
+  · exact max_lt (is_finite_kernel.bound_lt_top κ) (is_finite_kernel.bound_lt_top η)
+  rw [piecewise_apply']
+  exact (ite_le_sup _ _ _).trans (sup_le_sup (measure_le_bound _ _ _) (measure_le_bound _ _ _))
+#align probability_theory.kernel.is_finite_kernel.piecewise ProbabilityTheory.kernel.IsFiniteKernel.piecewise
+
+instance IsSFiniteKernel.piecewise [IsSFiniteKernel κ] [IsSFiniteKernel η] :
+    IsSFiniteKernel (piecewise hs κ η) :=
+  by
+  refine' ⟨⟨fun n => piecewise hs (seq κ n) (seq η n), inferInstance, _⟩⟩
+  ext1 a
+  simp_rw [sum_apply, kernel.piecewise_apply]
+  split_ifs <;> exact (measure_sum_seq _ a).symm
+#align probability_theory.kernel.is_s_finite_kernel.piecewise ProbabilityTheory.kernel.IsSFiniteKernel.piecewise
+
+theorem lintegral_piecewise (a : α) (g : β → ℝ≥0∞) :
+    (∫⁻ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a :=
+  by
+  simp_rw [piecewise_apply]
+  split_ifs <;> rfl
+#align probability_theory.kernel.lintegral_piecewise ProbabilityTheory.kernel.lintegral_piecewise
+
+theorem set_lintegral_piecewise (a : α) (g : β → ℝ≥0∞) (t : Set β) :
+    (∫⁻ b in t, g b ∂piecewise hs κ η a) =
+      if a ∈ s then ∫⁻ b in t, g b ∂κ a else ∫⁻ b in t, g b ∂η a :=
+  by
+  simp_rw [piecewise_apply]
+  split_ifs <;> rfl
+#align probability_theory.kernel.set_lintegral_piecewise ProbabilityTheory.kernel.set_lintegral_piecewise
+
+theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+    (a : α) (g : β → E) :
+    (∫ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a :=
+  by
+  simp_rw [piecewise_apply]
+  split_ifs <;> rfl
+#align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
+
+theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+    [CompleteSpace E] (a : α) (g : β → E) (t : Set β) :
+    (∫ b in t, g b ∂piecewise hs κ η a) =
+      if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
+  by
+  simp_rw [piecewise_apply]
+  split_ifs <;> rfl
+#align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.set_integral_piecewise
+
+end Piecewise
+
 end Kernel
 
 end ProbabilityTheory
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.basic
-! leanprover-community/mathlib commit caf83ba4dfbf4e2f28e1ae6a0780cbafc3d19d6f
+! leanprover-community/mathlib commit 483dd86cfec4a1380d22b1f6acd4c3dc53f501ff
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -21,36 +21,30 @@ sets `s` of `β`, `a ↦ κ a s` is measurable.
 ## Main definitions
 
 Classes of kernels:
-* `kernel α β`: kernels from `α` to `β`, defined as the `add_submonoid` of the measurable
-  functions in `α → measure β`.
-* `is_markov_kernel κ`: a kernel from `α` to `β` is said to be a Markov kernel if for all `a : α`,
-  `k a` is a probability measure.
-* `is_finite_kernel κ`: a kernel from `α` to `β` is said to be finite if there exists `C : ℝ≥0∞`
-  such that `C < ∞` and for all `a : α`, `κ a univ ≤ C`. This implies in particular that all
-  measures in the image of `κ` are finite, but is stronger since it requires an uniform bound. This
-  stronger condition is necessary to ensure that the composition of two finite kernels is finite.
-* `is_s_finite_kernel κ`: a kernel is called s-finite if it is a countable sum of finite kernels.
+* `probability_theory.kernel α β`: kernels from `α` to `β`, defined as the `add_submonoid` of the
+  measurable functions in `α → measure β`.
+* `probability_theory.is_markov_kernel κ`: a kernel from `α` to `β` is said to be a Markov kernel
+  if for all `a : α`, `k a` is a probability measure.
+* `probability_theory.is_finite_kernel κ`: a kernel from `α` to `β` is said to be finite if there
+  exists `C : ℝ≥0∞` such that `C < ∞` and for all `a : α`, `κ a univ ≤ C`. This implies in
+  particular that all measures in the image of `κ` are finite, but is stronger since it requires an
+  uniform bound. This stronger condition is necessary to ensure that the composition of two finite
+  kernels is finite.
+* `probability_theory.kernel.is_s_finite_kernel κ`: a kernel is called s-finite if it is a countable
+  sum of finite kernels.
 
 Particular kernels:
-* `deterministic (f : α → β) (hf : measurable f)`: kernel `a ↦ measure.dirac (f a)`.
-* `const α (μβ : measure β)`: constant kernel `a ↦ μβ`.
-* `kernel.restrict κ (hs : measurable_set s)`: kernel for which the image of `a : α` is
-  `(κ a).restrict s`.
+* `probability_theory.kernel.deterministic (f : α → β) (hf : measurable f)`:
+  kernel `a ↦ measure.dirac (f a)`.
+* `probability_theory.kernel.const α (μβ : measure β)`: constant kernel `a ↦ μβ`.
+* `probability_theory.kernel.restrict κ (hs : measurable_set s)`: kernel for which the image of
+  `a : α` is `(κ a).restrict s`.
   Integral: `∫⁻ b, f b ∂(kernel.restrict κ hs a) = ∫⁻ b in s, f b ∂(κ a)`
-* `kernel.with_density κ (f : α → β → ℝ≥0∞)`: kernel `a ↦ (κ a).with_density (f a)`.
-  It is defined if `κ` is s-finite. If `f` is finite everywhere, then this is also an s-finite
-  kernel. The class of s-finite kernels is the smallest class of kernels that contains finite
-  kernels and which is stable by `with_density`.
-  Integral: `∫⁻ b, g b ∂(with_density κ f a) = ∫⁻ b, f a b * g b ∂(κ a)`
 
 ## Main statements
 
-* `ext_fun`: if `∫⁻ b, f b ∂(κ a) = ∫⁻ b, f b ∂(η a)` for all measurable functions `f` and all `a`,
-  then the two kernels `κ` and `η` are equal.
-
-* `measurable_lintegral`: the function `a ↦ ∫⁻ b, f a b ∂(κ a)` is measurable, for an s-finite
-  kernel `κ : kernel α β` and a function `f : α → β → ℝ≥0∞` such that `function.uncurry f`
-  is measurable.
+* `probability_theory.kernel.ext_fun`: if `∫⁻ b, f b ∂(κ a) = ∫⁻ b, f b ∂(η a)` for all measurable
+  functions `f` and all `a`, then the two kernels `κ` and `η` are equal.
 
 -/
 
@@ -480,376 +474,6 @@ instance IsSFiniteKernel.restrict (κ : kernel α β) [IsSFiniteKernel κ] (hs :
 
 end Restrict
 
-section MeasurableLintegral
-
-/-- This is an auxiliary lemma for `measurable_prod_mk_mem`. -/
-theorem measurable_prod_mk_mem_of_finite (κ : kernel α β) {t : Set (α × β)} (ht : MeasurableSet t)
-    (hκs : ∀ a, IsFiniteMeasure (κ a)) : Measurable fun a => κ a { b | (a, b) ∈ t } :=
-  by
-  -- `t` is a measurable set in the product `α × β`: we use that the product σ-algebra is generated
-  -- by boxes to prove the result by induction.
-  refine' MeasurableSpace.induction_on_inter generate_from_prod.symm isPiSystem_prod _ _ _ _ ht
-  ·-- case `t = ∅`
-    simp only [Set.mem_empty_iff_false, Set.setOf_false, measure_empty, measurable_const]
-  · -- case of a box: `t = t₁ ×ˢ t₂` for measurable sets `t₁` and `t₂`
-    intro t' ht'
-    simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht'
-    obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht'
-    simp only [Set.prod_mk_mem_set_prod_eq]
-    classical
-      have h_eq_ite :
-        (fun a => κ a { b : β | a ∈ t₁ ∧ b ∈ t₂ }) = fun a => ite (a ∈ t₁) (κ a t₂) 0 :=
-        by
-        ext1 a
-        split_ifs
-        · simp only [h, true_and_iff]
-          rfl
-        · simp only [h, false_and_iff, Set.setOf_false, Set.inter_empty, measure_empty]
-      rw [h_eq_ite]
-      exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const
-  · -- we assume that the result is true for `t` and we prove it for `tᶜ`
-    intro t' ht' h_meas
-    have h_eq_sdiff : ∀ a, { b : β | (a, b) ∈ t'ᶜ } = Set.univ \ { b : β | (a, b) ∈ t' } :=
-      by
-      intro a
-      ext1 b
-      simp only [Set.mem_compl_iff, Set.mem_setOf_eq, Set.mem_diff, Set.mem_univ, true_and_iff]
-    simp_rw [h_eq_sdiff]
-    have :
-      (fun a => κ a (Set.univ \ { b : β | (a, b) ∈ t' })) = fun a =>
-        κ a Set.univ - κ a { b : β | (a, b) ∈ t' } :=
-      by
-      ext1 a
-      rw [← Set.diff_inter_self_eq_diff, Set.inter_univ, measure_diff]
-      · exact Set.subset_univ _
-      · exact (@measurable_prod_mk_left α β _ _ a) t' ht'
-      · exact measure_ne_top _ _
-    rw [this]
-    exact Measurable.sub (kernel.measurable_coe κ MeasurableSet.univ) h_meas
-  · -- we assume that the result is true for a family of disjoint sets and prove it for their union
-    intro f h_disj hf_meas hf
-    have h_Union :
-      (fun a => κ a { b : β | (a, b) ∈ ⋃ i, f i }) = fun a => κ a (⋃ i, { b : β | (a, b) ∈ f i }) :=
-      by
-      ext1 a
-      congr with b
-      simp only [Set.mem_unionᵢ, Set.supᵢ_eq_unionᵢ, Set.mem_setOf_eq]
-      rfl
-    rw [h_Union]
-    have h_tsum :
-      (fun a => κ a (⋃ i, { b : β | (a, b) ∈ f i })) = fun a =>
-        ∑' i, κ a { b : β | (a, b) ∈ f i } :=
-      by
-      ext1 a
-      rw [measure_Union]
-      · intro i j hij s hsi hsj b hbs
-        have habi : {(a, b)} ⊆ f i := by
-          rw [Set.singleton_subset_iff]
-          exact hsi hbs
-        have habj : {(a, b)} ⊆ f j := by
-          rw [Set.singleton_subset_iff]
-          exact hsj hbs
-        simpa only [Set.bot_eq_empty, Set.le_eq_subset, Set.singleton_subset_iff,
-          Set.mem_empty_iff_false] using h_disj hij habi habj
-      · exact fun i => (@measurable_prod_mk_left α β _ _ a) _ (hf_meas i)
-    rw [h_tsum]
-    exact Measurable.eNNReal_tsum hf
-#align probability_theory.kernel.measurable_prod_mk_mem_of_finite ProbabilityTheory.kernel.measurable_prod_mk_mem_of_finite
-
-theorem measurable_prod_mk_mem (κ : kernel α β) [IsSFiniteKernel κ] {t : Set (α × β)}
-    (ht : MeasurableSet t) : Measurable fun a => κ a { b | (a, b) ∈ t } :=
-  by
-  rw [← kernel_sum_seq κ]
-  have :
-    ∀ a, kernel.sum (seq κ) a { b : β | (a, b) ∈ t } = ∑' n, seq κ n a { b : β | (a, b) ∈ t } :=
-    fun a => kernel.sum_apply' _ _ (measurable_prod_mk_left ht)
-  simp_rw [this]
-  refine' Measurable.eNNReal_tsum fun n => _
-  exact measurable_prod_mk_mem_of_finite (seq κ n) ht inferInstance
-#align probability_theory.kernel.measurable_prod_mk_mem ProbabilityTheory.kernel.measurable_prod_mk_mem
-
-theorem measurable_lintegral_indicator_const (κ : kernel α β) [IsSFiniteKernel κ] {t : Set (α × β)}
-    (ht : MeasurableSet t) (c : ℝ≥0∞) :
-    Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a :=
-  by
-  simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]
-  exact Measurable.const_mul (measurable_prod_mk_mem _ ht) c
-#align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.kernel.measurable_lintegral_indicator_const
-
-/-- For an s-finite kernel `κ` and a function `f : α → β → ℝ≥0∞` which is measurable when seen as a
-map from `α × β` (hypothesis `measurable (function.uncurry f)`), the integral
-`a ↦ ∫⁻ b, f a b ∂(κ a)` is measurable. -/
-theorem measurable_lintegral (κ : kernel α β) [IsSFiniteKernel κ] {f : α → β → ℝ≥0∞}
-    (hf : Measurable (Function.uncurry f)) : Measurable fun a => ∫⁻ b, f a b ∂κ a :=
-  by
-  let F : ℕ → simple_func (α × β) ℝ≥0∞ := simple_func.eapprox (Function.uncurry f)
-  have h : ∀ a, (⨆ n, F n a) = Function.uncurry f a :=
-    simple_func.supr_eapprox_apply (Function.uncurry f) hf
-  simp only [Prod.forall, Function.uncurry_apply_pair] at h
-  simp_rw [← h]
-  have : ∀ a, (∫⁻ b, ⨆ n, F n (a, b) ∂κ a) = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a :=
-    by
-    intro a
-    rw [lintegral_supr]
-    · exact fun n => (F n).Measurable.comp measurable_prod_mk_left
-    · exact fun i j hij b => simple_func.monotone_eapprox (Function.uncurry f) hij _
-  simp_rw [this]
-  refine' measurable_supᵢ fun n => simple_func.induction _ _ (F n)
-  · intro c t ht
-    simp only [simple_func.const_zero, simple_func.coe_piecewise, simple_func.coe_const,
-      simple_func.coe_zero, Set.piecewise_eq_indicator]
-    exact measurable_lintegral_indicator_const κ ht c
-  · intro g₁ g₂ h_disj hm₁ hm₂
-    simp only [simple_func.coe_add, Pi.add_apply]
-    have h_add :
-      (fun a => ∫⁻ b, g₁ (a, b) + g₂ (a, b) ∂κ a) =
-        (fun a => ∫⁻ b, g₁ (a, b) ∂κ a) + fun a => ∫⁻ b, g₂ (a, b) ∂κ a :=
-      by
-      ext1 a
-      rw [Pi.add_apply, lintegral_add_left (g₁.measurable.comp measurable_prod_mk_left)]
-    rw [h_add]
-    exact Measurable.add hm₁ hm₂
-#align probability_theory.kernel.measurable_lintegral ProbabilityTheory.kernel.measurable_lintegral
-
-theorem measurable_lintegral' (κ : kernel α β) [IsSFiniteKernel κ] {f : β → ℝ≥0∞}
-    (hf : Measurable f) : Measurable fun a => ∫⁻ b, f b ∂κ a :=
-  measurable_lintegral κ (hf.comp measurable_snd)
-#align probability_theory.kernel.measurable_lintegral' ProbabilityTheory.kernel.measurable_lintegral'
-
-theorem measurableSet_lintegral (κ : kernel α β) [IsSFiniteKernel κ] {f : α → β → ℝ≥0∞}
-    (hf : Measurable (Function.uncurry f)) {s : Set β} (hs : MeasurableSet s) :
-    Measurable fun a => ∫⁻ b in s, f a b ∂κ a :=
-  by
-  simp_rw [← lintegral_restrict κ hs]
-  exact measurable_lintegral _ hf
-#align probability_theory.kernel.measurable_set_lintegral ProbabilityTheory.kernel.measurableSet_lintegral
-
-theorem measurableSet_lintegral' (κ : kernel α β) [IsSFiniteKernel κ] {f : β → ℝ≥0∞}
-    (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
-    Measurable fun a => ∫⁻ b in s, f b ∂κ a :=
-  measurableSet_lintegral κ (hf.comp measurable_snd) hs
-#align probability_theory.kernel.measurable_set_lintegral' ProbabilityTheory.kernel.measurableSet_lintegral'
-
-end MeasurableLintegral
-
-section WithDensity
-
-variable {f : α → β → ℝ≥0∞}
-
-/-- Kernel with image `(κ a).with_density (f a)` if `function.uncurry f` is measurable, and
-with image 0 otherwise. If `function.uncurry f` is measurable, it satisfies
-`∫⁻ b, g b ∂(with_density κ f hf a) = ∫⁻ b, f a b * g b ∂(κ a)`. -/
-noncomputable def withDensity (κ : kernel α β) [IsSFiniteKernel κ] (f : α → β → ℝ≥0∞) :
-    kernel α β :=
-  @dite _ (Measurable (Function.uncurry f)) (Classical.dec _)
-    (fun hf =>
-      ({  val := fun a => (κ a).withDensity (f a)
-          property := by
-            refine' measure.measurable_of_measurable_coe _ fun s hs => _
-            simp_rw [with_density_apply _ hs]
-            exact measurable_set_lintegral κ hf hs } :
-        kernel α β))
-    fun hf => 0
-#align probability_theory.kernel.with_density ProbabilityTheory.kernel.withDensity
-
-theorem withDensity_of_not_measurable (κ : kernel α β) [IsSFiniteKernel κ]
-    (hf : ¬Measurable (Function.uncurry f)) : withDensity κ f = 0 := by classical exact dif_neg hf
-#align probability_theory.kernel.with_density_of_not_measurable ProbabilityTheory.kernel.withDensity_of_not_measurable
-
-protected theorem withDensity_apply (κ : kernel α β) [IsSFiniteKernel κ]
-    (hf : Measurable (Function.uncurry f)) (a : α) : withDensity κ f a = (κ a).withDensity (f a) :=
-  by
-  classical
-    rw [with_density, dif_pos hf]
-    rfl
-#align probability_theory.kernel.with_density_apply ProbabilityTheory.kernel.withDensity_apply
-
-theorem withDensity_apply' (κ : kernel α β) [IsSFiniteKernel κ]
-    (hf : Measurable (Function.uncurry f)) (a : α) {s : Set β} (hs : MeasurableSet s) :
-    withDensity κ f a s = ∫⁻ b in s, f a b ∂κ a := by
-  rw [kernel.with_density_apply κ hf, with_density_apply _ hs]
-#align probability_theory.kernel.with_density_apply' ProbabilityTheory.kernel.withDensity_apply'
-
-theorem lintegral_withDensity (κ : kernel α β) [IsSFiniteKernel κ]
-    (hf : Measurable (Function.uncurry f)) (a : α) {g : β → ℝ≥0∞} (hg : Measurable g) :
-    (∫⁻ b, g b ∂withDensity κ f a) = ∫⁻ b, f a b * g b ∂κ a :=
-  by
-  rw [kernel.with_density_apply _ hf,
-    lintegral_with_density_eq_lintegral_mul _ (Measurable.of_uncurry_left hf) hg]
-  simp_rw [Pi.mul_apply]
-#align probability_theory.kernel.lintegral_with_density ProbabilityTheory.kernel.lintegral_withDensity
-
-theorem withDensity_add_left (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFiniteKernel η]
-    (f : α → β → ℝ≥0∞) : withDensity (κ + η) f = withDensity κ f + withDensity η f :=
-  by
-  by_cases hf : Measurable (Function.uncurry f)
-  · ext (a s hs) : 2
-    simp only [kernel.with_density_apply _ hf, coe_fn_add, Pi.add_apply, with_density_add_measure,
-      measure.add_apply]
-  · simp_rw [with_density_of_not_measurable _ hf]
-    rw [zero_add]
-#align probability_theory.kernel.with_density_add_left ProbabilityTheory.kernel.withDensity_add_left
-
-theorem withDensity_kernel_sum [Countable ι] (κ : ι → kernel α β) (hκ : ∀ i, IsSFiniteKernel (κ i))
-    (f : α → β → ℝ≥0∞) :
-    @withDensity _ _ _ _ (kernel.sum κ) (isSFiniteKernel_sum hκ) f =
-      kernel.sum fun i => withDensity (κ i) f :=
-  by
-  by_cases hf : Measurable (Function.uncurry f)
-  · ext1 a
-    simp_rw [sum_apply, kernel.with_density_apply _ hf, sum_apply,
-      with_density_sum (fun n => κ n a) (f a)]
-  · simp_rw [with_density_of_not_measurable _ hf]
-    exact sum_zero.symm
-#align probability_theory.kernel.with_density_kernel_sum ProbabilityTheory.kernel.withDensity_kernel_sum
-
-theorem withDensity_tsum [Countable ι] (κ : kernel α β) [IsSFiniteKernel κ] {f : ι → α → β → ℝ≥0∞}
-    (hf : ∀ i, Measurable (Function.uncurry (f i))) :
-    withDensity κ (∑' n, f n) = kernel.sum fun n => withDensity κ (f n) :=
-  by
-  have h_sum_a : ∀ a, Summable fun n => f n a := fun a => pi.summable.mpr fun b => ENNReal.summable
-  have h_sum : Summable fun n => f n := pi.summable.mpr h_sum_a
-  ext (a s hs) : 2
-  rw [sum_apply' _ a hs, with_density_apply' κ _ a hs]
-  swap
-  · have : Function.uncurry (∑' n, f n) = ∑' n, Function.uncurry (f n) :=
-      by
-      ext1 p
-      simp only [Function.uncurry_def]
-      rw [tsum_apply h_sum, tsum_apply (h_sum_a _), tsum_apply]
-      exact pi.summable.mpr fun p => ENNReal.summable
-    rw [this]
-    exact Measurable.eNNReal_tsum' hf
-  have : (∫⁻ b in s, (∑' n, f n) a b ∂κ a) = ∫⁻ b in s, ∑' n, (fun b => f n a b) b ∂κ a :=
-    by
-    congr with b
-    rw [tsum_apply h_sum, tsum_apply (h_sum_a a)]
-  rw [this, lintegral_tsum fun n => (Measurable.of_uncurry_left (hf n)).AEMeasurable]
-  congr with n
-  rw [with_density_apply' _ (hf n) a hs]
-#align probability_theory.kernel.with_density_tsum ProbabilityTheory.kernel.withDensity_tsum
-
-/-- If a kernel `κ` is finite and a function `f : α → β → ℝ≥0∞` is bounded, then `with_density κ f`
-is finite. -/
-theorem isFiniteKernel_withDensity_of_bounded (κ : kernel α β) [IsFiniteKernel κ] {B : ℝ≥0∞}
-    (hB_top : B ≠ ∞) (hf_B : ∀ a b, f a b ≤ B) : IsFiniteKernel (withDensity κ f) :=
-  by
-  by_cases hf : Measurable (Function.uncurry f)
-  ·
-    exact
-      ⟨⟨B * is_finite_kernel.bound κ, ENNReal.mul_lt_top hB_top (is_finite_kernel.bound_ne_top κ),
-          fun a => by
-          rw [with_density_apply' κ hf a MeasurableSet.univ]
-          calc
-            (∫⁻ b in Set.univ, f a b ∂κ a) ≤ ∫⁻ b in Set.univ, B ∂κ a := lintegral_mono (hf_B a)
-            _ = B * κ a Set.univ := by simp only [measure.restrict_univ, lintegral_const]
-            _ ≤ B * is_finite_kernel.bound κ := mul_le_mul_left' (measure_le_bound κ a Set.univ) _
-            ⟩⟩
-  · rw [with_density_of_not_measurable _ hf]
-    infer_instance
-#align probability_theory.kernel.is_finite_kernel_with_density_of_bounded ProbabilityTheory.kernel.isFiniteKernel_withDensity_of_bounded
-
-/-- Auxiliary lemma for `is_s_finite_kernel_with_density`.
-If a kernel `κ` is finite, then `with_density κ f` is s-finite. -/
-theorem isSFiniteKernel_withDensity_of_isFiniteKernel (κ : kernel α β) [IsFiniteKernel κ]
-    (hf_ne_top : ∀ a b, f a b ≠ ∞) : IsSFiniteKernel (withDensity κ f) :=
-  by
-  -- We already have that for `f` bounded from above and a `κ` a finite kernel,
-  -- `with_density κ f` is finite. We write any function as a countable sum of bounded
-  -- functions, and decompose an s-finite kernel as a sum of finite kernels. We then use that
-  -- `with_density` commutes with sums for both arguments and get a sum of finite kernels.
-  by_cases hf : Measurable (Function.uncurry f)
-  swap
-  · rw [with_density_of_not_measurable _ hf]
-    infer_instance
-  let fs : ℕ → α → β → ℝ≥0∞ := fun n a b => min (f a b) (n + 1) - min (f a b) n
-  have h_le : ∀ a b n, ⌈(f a b).toReal⌉₊ ≤ n → f a b ≤ n :=
-    by
-    intro a b n hn
-    have : (f a b).toReal ≤ n := Nat.le_of_ceil_le hn
-    rw [← ENNReal.le_ofReal_iff_toReal_le (hf_ne_top a b) _] at this
-    · refine' this.trans (le_of_eq _)
-      rw [ENNReal.ofReal_coe_nat]
-    · norm_cast
-      exact zero_le _
-  have h_zero : ∀ a b n, ⌈(f a b).toReal⌉₊ ≤ n → fs n a b = 0 :=
-    by
-    intro a b n hn
-    suffices min (f a b) (n + 1) = f a b ∧ min (f a b) n = f a b by
-      simp_rw [fs, this.1, this.2, tsub_self (f a b)]
-    exact
-      ⟨min_eq_left ((h_le a b n hn).trans (le_add_of_nonneg_right zero_le_one)),
-        min_eq_left (h_le a b n hn)⟩
-  have hf_eq_tsum : f = ∑' n, fs n :=
-    by
-    have h_sum_a : ∀ a, Summable fun n => fs n a :=
-      by
-      refine' fun a => pi.summable.mpr fun b => _
-      suffices : ∀ n, n ∉ Finset.range ⌈(f a b).toReal⌉₊ → fs n a b = 0
-      exact summable_of_ne_finset_zero this
-      intro n hn_not_mem
-      rw [Finset.mem_range, not_lt] at hn_not_mem
-      exact h_zero a b n hn_not_mem
-    ext (a b) : 2
-    rw [tsum_apply (pi.summable.mpr h_sum_a), tsum_apply (h_sum_a a),
-      ENNReal.tsum_eq_liminf_sum_nat]
-    have h_finset_sum : ∀ n, (∑ i in Finset.range n, fs i a b) = min (f a b) n :=
-      by
-      intro n
-      induction' n with n hn
-      · simp only [Finset.range_zero, Finset.sum_empty, algebraMap.coe_zero, min_zero]
-      rw [Finset.sum_range_succ, hn]
-      simp_rw [fs]
-      norm_cast
-      rw [add_tsub_cancel_iff_le]
-      refine' min_le_min le_rfl _
-      norm_cast
-      exact Nat.le_succ n
-    simp_rw [h_finset_sum]
-    refine' (Filter.Tendsto.liminf_eq _).symm
-    refine' Filter.Tendsto.congr' _ tendsto_const_nhds
-    rw [Filter.EventuallyEq, Filter.eventually_atTop]
-    exact ⟨⌈(f a b).toReal⌉₊, fun n hn => (min_eq_left (h_le a b n hn)).symm⟩
-  rw [hf_eq_tsum, with_density_tsum _ fun n : ℕ => _]
-  swap
-  · exact (hf.min measurable_const).sub (hf.min measurable_const)
-  refine' is_s_finite_kernel_sum fun n => _
-  suffices is_finite_kernel (with_density κ (fs n))
-    by
-    haveI := this
-    infer_instance
-  refine' is_finite_kernel_with_density_of_bounded _ (ENNReal.coe_ne_top : ↑n + 1 ≠ ∞) fun a b => _
-  norm_cast
-  calc
-    fs n a b ≤ min (f a b) (n + 1) := tsub_le_self
-    _ ≤ n + 1 := (min_le_right _ _)
-    _ = ↑(n + 1) := by norm_cast
-    
-#align probability_theory.kernel.is_s_finite_kernel_with_density_of_is_finite_kernel ProbabilityTheory.kernel.isSFiniteKernel_withDensity_of_isFiniteKernel
-
-/-- For a s-finite kernel `κ` and a function `f : α → β → ℝ≥0∞` which is everywhere finite,
-`with_density κ f` is s-finite. -/
-theorem IsSFiniteKernel.withDensity (κ : kernel α β) [IsSFiniteKernel κ]
-    (hf_ne_top : ∀ a b, f a b ≠ ∞) : IsSFiniteKernel (withDensity κ f) :=
-  by
-  have h_eq_sum : with_density κ f = kernel.sum fun i => with_density (seq κ i) f :=
-    by
-    rw [← with_density_kernel_sum _ _]
-    congr
-    exact (kernel_sum_seq κ).symm
-  rw [h_eq_sum]
-  exact
-    is_s_finite_kernel_sum fun n =>
-      is_s_finite_kernel_with_density_of_is_finite_kernel (seq κ n) hf_ne_top
-#align probability_theory.kernel.is_s_finite_kernel.with_density ProbabilityTheory.kernel.IsSFiniteKernel.withDensity
-
-/-- For a s-finite kernel `κ` and a function `f : α → β → ℝ≥0`, `with_density κ f` is s-finite. -/
-instance (κ : kernel α β) [IsSFiniteKernel κ] (f : α → β → ℝ≥0) :
-    IsSFiniteKernel (withDensity κ fun a b => f a b) :=
-  IsSFiniteKernel.withDensity κ fun _ _ => ENNReal.coe_ne_top
-
-end WithDensity
-
 end Kernel
 
 end ProbabilityTheory
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.basic
-! leanprover-community/mathlib commit 97d1aa955750bd57a7eeef91de310e633881670b
+! leanprover-community/mathlib commit caf83ba4dfbf4e2f28e1ae6a0780cbafc3d19d6f
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -32,7 +32,7 @@ Classes of kernels:
 * `is_s_finite_kernel κ`: a kernel is called s-finite if it is a countable sum of finite kernels.
 
 Particular kernels:
-* `deterministic {f : α → β} (hf : measurable f)`: kernel `a ↦ measure.dirac (f a)`.
+* `deterministic (f : α → β) (hf : measurable f)`: kernel `a ↦ measure.dirac (f a)`.
 * `const α (μβ : measure β)`: constant kernel `a ↦ μβ`.
 * `kernel.restrict κ (hs : measurable_set s)`: kernel for which the image of `a : α` is
   `(κ a).restrict s`.
@@ -361,7 +361,7 @@ end SFinite
 section Deterministic
 
 /-- Kernel which to `a` associates the dirac measure at `f a`. This is a Markov kernel. -/
-noncomputable def deterministic {f : α → β} (hf : Measurable f) : kernel α β
+noncomputable def deterministic (f : α → β) (hf : Measurable f) : kernel α β
     where
   val a := Measure.dirac (f a)
   property := by
@@ -371,12 +371,12 @@ noncomputable def deterministic {f : α → β} (hf : Measurable f) : kernel α
 #align probability_theory.kernel.deterministic ProbabilityTheory.kernel.deterministic
 
 theorem deterministic_apply {f : α → β} (hf : Measurable f) (a : α) :
-    deterministic hf a = Measure.dirac (f a) :=
+    deterministic f hf a = Measure.dirac (f a) :=
   rfl
 #align probability_theory.kernel.deterministic_apply ProbabilityTheory.kernel.deterministic_apply
 
 theorem deterministic_apply' {f : α → β} (hf : Measurable f) (a : α) {s : Set β}
-    (hs : MeasurableSet s) : deterministic hf a s = s.indicator (fun _ => 1) (f a) :=
+    (hs : MeasurableSet s) : deterministic f hf a s = s.indicator (fun _ => 1) (f a) :=
   by
   rw [deterministic]
   change measure.dirac (f a) s = s.indicator 1 (f a)
@@ -384,7 +384,7 @@ theorem deterministic_apply' {f : α → β} (hf : Measurable f) (a : α) {s : S
 #align probability_theory.kernel.deterministic_apply' ProbabilityTheory.kernel.deterministic_apply'
 
 instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
-    IsMarkovKernel (deterministic hf) :=
+    IsMarkovKernel (deterministic f hf) :=
   ⟨fun a => by
     rw [deterministic_apply hf]
     infer_instance⟩
Diff
@@ -153,11 +153,11 @@ theorem kernel.measure_le_bound (κ : kernel α β) [h : IsFiniteKernel κ] (a :
   (measure_mono (Set.subset_univ s)).trans (h.exists_univ_le.choose_spec.2 a)
 #align probability_theory.kernel.measure_le_bound ProbabilityTheory.kernel.measure_le_bound
 
-instance isFiniteKernelZero (α β : Type _) {mα : MeasurableSpace α} {mβ : MeasurableSpace β} :
+instance isFiniteKernel_zero (α β : Type _) {mα : MeasurableSpace α} {mβ : MeasurableSpace β} :
     IsFiniteKernel (0 : kernel α β) :=
   ⟨⟨0, ENNReal.coe_lt_top, fun a => by
       simp only [kernel.zero_apply, measure.coe_zero, Pi.zero_apply, le_zero_iff]⟩⟩
-#align probability_theory.is_finite_kernel_zero ProbabilityTheory.isFiniteKernelZero
+#align probability_theory.is_finite_kernel_zero ProbabilityTheory.isFiniteKernel_zero
 
 instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFiniteKernel η] :
     IsFiniteKernel (κ + η) :=
@@ -172,10 +172,10 @@ instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFinite
 
 variable {κ : kernel α β}
 
-instance IsMarkovKernel.isProbabilityMeasure' [h : IsMarkovKernel κ] (a : α) :
+instance IsMarkovKernel.is_probability_measure' [h : IsMarkovKernel κ] (a : α) :
     IsProbabilityMeasure (κ a) :=
   IsMarkovKernel.isProbabilityMeasure a
-#align probability_theory.is_markov_kernel.is_probability_measure' ProbabilityTheory.IsMarkovKernel.isProbabilityMeasure'
+#align probability_theory.is_markov_kernel.is_probability_measure' ProbabilityTheory.IsMarkovKernel.is_probability_measure'
 
 instance IsFiniteKernel.isFiniteMeasure [h : IsFiniteKernel κ] (a : α) : IsFiniteMeasure (κ a) :=
   ⟨(kernel.measure_le_bound κ a Set.univ).trans_lt (IsFiniteKernel.bound_lt_top κ)⟩
@@ -303,10 +303,10 @@ theorem measure_sum_seq (κ : kernel α β) [h : IsSFiniteKernel κ] (a : α) :
     (Measure.sum fun n => seq κ n a) = κ a := by rw [← kernel.sum_apply, kernel_sum_seq κ]
 #align probability_theory.kernel.measure_sum_seq ProbabilityTheory.kernel.measure_sum_seq
 
-instance isFiniteKernelSeq (κ : kernel α β) [h : IsSFiniteKernel κ] (n : ℕ) :
+instance isFiniteKernel_seq (κ : kernel α β) [h : IsSFiniteKernel κ] (n : ℕ) :
     IsFiniteKernel (kernel.seq κ n) :=
   h.tsum_finite.choose_spec.1 n
-#align probability_theory.kernel.is_finite_kernel_seq ProbabilityTheory.kernel.isFiniteKernelSeq
+#align probability_theory.kernel.is_finite_kernel_seq ProbabilityTheory.kernel.isFiniteKernel_seq
 
 instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFiniteKernel η] :
     IsSFiniteKernel (κ + η) :=
@@ -315,7 +315,7 @@ instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFin
   rw [sum_add, kernel_sum_seq κ, kernel_sum_seq η]
 #align probability_theory.kernel.is_s_finite_kernel.add ProbabilityTheory.kernel.IsSFiniteKernel.add
 
-theorem IsSFiniteKernel.finsetSum {κs : ι → kernel α β} (I : Finset ι)
+theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
     (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
   classical
     induction' I using Finset.induction with i I hi_nmem_I h_ind h
@@ -326,10 +326,10 @@ theorem IsSFiniteKernel.finsetSum {κs : ι → kernel α β} (I : Finset ι)
       have : is_s_finite_kernel (∑ x : ι in I, κs x) :=
         h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
       exact is_s_finite_kernel.add _ _
-#align probability_theory.kernel.is_s_finite_kernel.finset_sum ProbabilityTheory.kernel.IsSFiniteKernel.finsetSum
+#align probability_theory.kernel.is_s_finite_kernel.finset_sum ProbabilityTheory.kernel.IsSFiniteKernel.finset_sum
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i m) -/
-theorem isSFiniteKernelSumOfDenumerable [Denumerable ι] {κs : ι → kernel α β}
+theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel α β}
     (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) :=
   by
   let e : ℕ ≃ ι × ℕ := Denumerable.equiv₂ ℕ (ι × ℕ)
@@ -343,10 +343,10 @@ theorem isSFiniteKernelSumOfDenumerable [Denumerable ι] {κs : ι → kernel α
   rw [e.tsum_eq]
   · rw [tsum_prod' ENNReal.summable fun _ => ENNReal.summable]
   · infer_instance
-#align probability_theory.kernel.is_s_finite_kernel_sum_of_denumerable ProbabilityTheory.kernel.isSFiniteKernelSumOfDenumerable
+#align probability_theory.kernel.is_s_finite_kernel_sum_of_denumerable ProbabilityTheory.kernel.isSFiniteKernel_sum_of_denumerable
 
-theorem isSFiniteKernelSum [Countable ι] {κs : ι → kernel α β} (hκs : ∀ n, IsSFiniteKernel (κs n)) :
-    IsSFiniteKernel (kernel.sum κs) :=
+theorem isSFiniteKernel_sum [Countable ι] {κs : ι → kernel α β}
+    (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) :=
   by
   cases fintypeOrInfinite ι
   · rw [sum_fintype]
@@ -354,7 +354,7 @@ theorem isSFiniteKernelSum [Countable ι] {κs : ι → kernel α β} (hκs : 
   haveI : Encodable ι := Encodable.ofCountable ι
   haveI : Denumerable ι := Denumerable.ofEncodableOfInfinite ι
   exact is_s_finite_kernel_sum_of_denumerable hκs
-#align probability_theory.kernel.is_s_finite_kernel_sum ProbabilityTheory.kernel.isSFiniteKernelSum
+#align probability_theory.kernel.is_s_finite_kernel_sum ProbabilityTheory.kernel.isSFiniteKernel_sum
 
 end SFinite
 
@@ -383,12 +383,12 @@ theorem deterministic_apply' {f : α → β} (hf : Measurable f) (a : α) {s : S
   simp_rw [measure.dirac_apply' _ hs]
 #align probability_theory.kernel.deterministic_apply' ProbabilityTheory.kernel.deterministic_apply'
 
-instance isMarkovKernelDeterministic {f : α → β} (hf : Measurable f) :
+instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
     IsMarkovKernel (deterministic hf) :=
   ⟨fun a => by
     rw [deterministic_apply hf]
     infer_instance⟩
-#align probability_theory.kernel.is_markov_kernel_deterministic ProbabilityTheory.kernel.isMarkovKernelDeterministic
+#align probability_theory.kernel.is_markov_kernel_deterministic ProbabilityTheory.kernel.isMarkovKernel_deterministic
 
 end Deterministic
 
@@ -409,15 +409,15 @@ theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
   rfl
 #align probability_theory.kernel.const_apply ProbabilityTheory.kernel.const_apply
 
-instance isFiniteKernelConst {μβ : Measure β} [hμβ : IsFiniteMeasure μβ] :
+instance isFiniteKernel_const {μβ : Measure β} [hμβ : IsFiniteMeasure μβ] :
     IsFiniteKernel (const α μβ) :=
   ⟨⟨μβ Set.univ, measure_lt_top _ _, fun a => le_rfl⟩⟩
-#align probability_theory.kernel.is_finite_kernel_const ProbabilityTheory.kernel.isFiniteKernelConst
+#align probability_theory.kernel.is_finite_kernel_const ProbabilityTheory.kernel.isFiniteKernel_const
 
-instance isMarkovKernelConst {μβ : Measure β} [hμβ : IsProbabilityMeasure μβ] :
+instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure μβ] :
     IsMarkovKernel (const α μβ) :=
   ⟨fun a => hμβ⟩
-#align probability_theory.kernel.is_markov_kernel_const ProbabilityTheory.kernel.isMarkovKernelConst
+#align probability_theory.kernel.is_markov_kernel_const ProbabilityTheory.kernel.isMarkovKernel_const
 
 end Const
 
@@ -692,7 +692,7 @@ theorem withDensity_add_left (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFin
 
 theorem withDensity_kernel_sum [Countable ι] (κ : ι → kernel α β) (hκ : ∀ i, IsSFiniteKernel (κ i))
     (f : α → β → ℝ≥0∞) :
-    @withDensity _ _ _ _ (kernel.sum κ) (isSFiniteKernelSum hκ) f =
+    @withDensity _ _ _ _ (kernel.sum κ) (isSFiniteKernel_sum hκ) f =
       kernel.sum fun i => withDensity (κ i) f :=
   by
   by_cases hf : Measurable (Function.uncurry f)
@@ -724,14 +724,14 @@ theorem withDensity_tsum [Countable ι] (κ : kernel α β) [IsSFiniteKernel κ]
     by
     congr with b
     rw [tsum_apply h_sum, tsum_apply (h_sum_a a)]
-  rw [this, lintegral_tsum fun n => (Measurable.of_uncurry_left (hf n)).AeMeasurable]
+  rw [this, lintegral_tsum fun n => (Measurable.of_uncurry_left (hf n)).AEMeasurable]
   congr with n
   rw [with_density_apply' _ (hf n) a hs]
 #align probability_theory.kernel.with_density_tsum ProbabilityTheory.kernel.withDensity_tsum
 
 /-- If a kernel `κ` is finite and a function `f : α → β → ℝ≥0∞` is bounded, then `with_density κ f`
 is finite. -/
-theorem isFiniteKernelWithDensityOfBounded (κ : kernel α β) [IsFiniteKernel κ] {B : ℝ≥0∞}
+theorem isFiniteKernel_withDensity_of_bounded (κ : kernel α β) [IsFiniteKernel κ] {B : ℝ≥0∞}
     (hB_top : B ≠ ∞) (hf_B : ∀ a b, f a b ≤ B) : IsFiniteKernel (withDensity κ f) :=
   by
   by_cases hf : Measurable (Function.uncurry f)
@@ -747,11 +747,11 @@ theorem isFiniteKernelWithDensityOfBounded (κ : kernel α β) [IsFiniteKernel 
             ⟩⟩
   · rw [with_density_of_not_measurable _ hf]
     infer_instance
-#align probability_theory.kernel.is_finite_kernel_with_density_of_bounded ProbabilityTheory.kernel.isFiniteKernelWithDensityOfBounded
+#align probability_theory.kernel.is_finite_kernel_with_density_of_bounded ProbabilityTheory.kernel.isFiniteKernel_withDensity_of_bounded
 
 /-- Auxiliary lemma for `is_s_finite_kernel_with_density`.
 If a kernel `κ` is finite, then `with_density κ f` is s-finite. -/
-theorem isSFiniteKernelWithDensityOfIsFiniteKernel (κ : kernel α β) [IsFiniteKernel κ]
+theorem isSFiniteKernel_withDensity_of_isFiniteKernel (κ : kernel α β) [IsFiniteKernel κ]
     (hf_ne_top : ∀ a b, f a b ≠ ∞) : IsSFiniteKernel (withDensity κ f) :=
   by
   -- We already have that for `f` bounded from above and a `κ` a finite kernel,
@@ -825,7 +825,7 @@ theorem isSFiniteKernelWithDensityOfIsFiniteKernel (κ : kernel α β) [IsFinite
     _ ≤ n + 1 := (min_le_right _ _)
     _ = ↑(n + 1) := by norm_cast
     
-#align probability_theory.kernel.is_s_finite_kernel_with_density_of_is_finite_kernel ProbabilityTheory.kernel.isSFiniteKernelWithDensityOfIsFiniteKernel
+#align probability_theory.kernel.is_s_finite_kernel_with_density_of_is_finite_kernel ProbabilityTheory.kernel.isSFiniteKernel_withDensity_of_isFiniteKernel
 
 /-- For a s-finite kernel `κ` and a function `f : α → β → ℝ≥0∞` which is everywhere finite,
 `with_density κ f` is s-finite. -/
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.basic
-! leanprover-community/mathlib commit 57ac39bd365c2f80589a700f9fbb664d3a1a30c2
+! leanprover-community/mathlib commit 97d1aa955750bd57a7eeef91de310e633881670b
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -405,6 +405,10 @@ def const (α : Type _) {β : Type _} [MeasurableSpace α] {mβ : MeasurableSpac
 
 include mα mβ
 
+theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
+  rfl
+#align probability_theory.kernel.const_apply ProbabilityTheory.kernel.const_apply
+
 instance isFiniteKernelConst {μβ : Measure β} [hμβ : IsFiniteMeasure μβ] :
     IsFiniteKernel (const α μβ) :=
   ⟨⟨μβ Set.univ, measure_lt_top _ _, fun a => le_rfl⟩⟩
Diff
@@ -818,7 +818,7 @@ theorem isSFiniteKernelWithDensityOfIsFiniteKernel (κ : kernel α β) [IsFinite
   norm_cast
   calc
     fs n a b ≤ min (f a b) (n + 1) := tsub_le_self
-    _ ≤ n + 1 := min_le_right _ _
+    _ ≤ n + 1 := (min_le_right _ _)
     _ = ↑(n + 1) := by norm_cast
     
 #align probability_theory.kernel.is_s_finite_kernel_with_density_of_is_finite_kernel ProbabilityTheory.kernel.isSFiniteKernelWithDensityOfIsFiniteKernel
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.basic
-! leanprover-community/mathlib commit 31a8a27684ce9a5749914f4248c3f7bf76605d41
+! leanprover-community/mathlib commit 57ac39bd365c2f80589a700f9fbb664d3a1a30c2
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -739,8 +739,7 @@ theorem isFiniteKernelWithDensityOfBounded (κ : kernel α β) [IsFiniteKernel 
           calc
             (∫⁻ b in Set.univ, f a b ∂κ a) ≤ ∫⁻ b in Set.univ, B ∂κ a := lintegral_mono (hf_B a)
             _ = B * κ a Set.univ := by simp only [measure.restrict_univ, lintegral_const]
-            _ ≤ B * is_finite_kernel.bound κ :=
-              ENNReal.mul_le_mul le_rfl (measure_le_bound κ a Set.univ)
+            _ ≤ B * is_finite_kernel.bound κ := mul_le_mul_left' (measure_le_bound κ a Set.univ) _
             ⟩⟩
   · rw [with_density_of_not_measurable _ hf]
     infer_instance
Diff
@@ -57,7 +57,7 @@ Particular kernels:
 
 open MeasureTheory
 
-open MeasureTheory Ennreal NNReal BigOperators
+open MeasureTheory ENNReal NNReal BigOperators
 
 namespace ProbabilityTheory
 
@@ -155,7 +155,7 @@ theorem kernel.measure_le_bound (κ : kernel α β) [h : IsFiniteKernel κ] (a :
 
 instance isFiniteKernelZero (α β : Type _) {mα : MeasurableSpace α} {mβ : MeasurableSpace β} :
     IsFiniteKernel (0 : kernel α β) :=
-  ⟨⟨0, Ennreal.coe_lt_top, fun a => by
+  ⟨⟨0, ENNReal.coe_lt_top, fun a => by
       simp only [kernel.zero_apply, measure.coe_zero, Pi.zero_apply, le_zero_iff]⟩⟩
 #align probability_theory.is_finite_kernel_zero ProbabilityTheory.isFiniteKernelZero
 
@@ -183,7 +183,7 @@ instance IsFiniteKernel.isFiniteMeasure [h : IsFiniteKernel κ] (a : α) : IsFin
 
 instance (priority := 100) IsMarkovKernel.isFiniteKernel [h : IsMarkovKernel κ] :
     IsFiniteKernel κ :=
-  ⟨⟨1, Ennreal.one_lt_top, fun a => prob_le_one⟩⟩
+  ⟨⟨1, ENNReal.one_lt_top, fun a => prob_le_one⟩⟩
 #align probability_theory.is_markov_kernel.is_finite_kernel ProbabilityTheory.IsMarkovKernel.isFiniteKernel
 
 namespace Kernel
@@ -222,7 +222,7 @@ protected noncomputable def sum [Countable ι] (κ : ι → kernel α β) : kern
   property := by
     refine' measure.measurable_of_measurable_coe _ fun s hs => _
     simp_rw [measure.sum_apply _ hs]
-    exact Measurable.ennreal_tsum fun n => kernel.measurable_coe (κ n) hs
+    exact Measurable.eNNReal_tsum fun n => kernel.measurable_coe (κ n) hs
 #align probability_theory.kernel.sum ProbabilityTheory.kernel.sum
 
 theorem sum_apply [Countable ι] (κ : ι → kernel α β) (a : α) :
@@ -262,7 +262,7 @@ theorem sum_add [Countable ι] (κ η : ι → kernel α β) :
   by
   ext (a s hs)
   simp only [coe_fn_add, Pi.add_apply, sum_apply, measure.sum_apply _ hs, Pi.add_apply,
-    measure.coe_add, tsum_add Ennreal.summable Ennreal.summable]
+    measure.coe_add, tsum_add ENNReal.summable ENNReal.summable]
 #align probability_theory.kernel.sum_add ProbabilityTheory.kernel.sum_add
 
 end Sum
@@ -341,7 +341,7 @@ theorem isSFiniteKernelSumOfDenumerable [Denumerable ι] {κs : ι → kernel α
   simp_rw [kernel.sum_apply' _ _ hs]
   change (∑' (i) (m), seq (κs i) m a s) = ∑' n, (fun im : ι × ℕ => seq (κs im.fst) im.snd a s) (e n)
   rw [e.tsum_eq]
-  · rw [tsum_prod' Ennreal.summable fun _ => Ennreal.summable]
+  · rw [tsum_prod' ENNReal.summable fun _ => ENNReal.summable]
   · infer_instance
 #align probability_theory.kernel.is_s_finite_kernel_sum_of_denumerable ProbabilityTheory.kernel.isSFiniteKernelSumOfDenumerable
 
@@ -549,7 +549,7 @@ theorem measurable_prod_mk_mem_of_finite (κ : kernel α β) {t : Set (α × β)
           Set.mem_empty_iff_false] using h_disj hij habi habj
       · exact fun i => (@measurable_prod_mk_left α β _ _ a) _ (hf_meas i)
     rw [h_tsum]
-    exact Measurable.ennreal_tsum hf
+    exact Measurable.eNNReal_tsum hf
 #align probability_theory.kernel.measurable_prod_mk_mem_of_finite ProbabilityTheory.kernel.measurable_prod_mk_mem_of_finite
 
 theorem measurable_prod_mk_mem (κ : kernel α β) [IsSFiniteKernel κ] {t : Set (α × β)}
@@ -560,7 +560,7 @@ theorem measurable_prod_mk_mem (κ : kernel α β) [IsSFiniteKernel κ] {t : Set
     ∀ a, kernel.sum (seq κ) a { b : β | (a, b) ∈ t } = ∑' n, seq κ n a { b : β | (a, b) ∈ t } :=
     fun a => kernel.sum_apply' _ _ (measurable_prod_mk_left ht)
   simp_rw [this]
-  refine' Measurable.ennreal_tsum fun n => _
+  refine' Measurable.eNNReal_tsum fun n => _
   exact measurable_prod_mk_mem_of_finite (seq κ n) ht inferInstance
 #align probability_theory.kernel.measurable_prod_mk_mem ProbabilityTheory.kernel.measurable_prod_mk_mem
 
@@ -703,7 +703,7 @@ theorem withDensity_tsum [Countable ι] (κ : kernel α β) [IsSFiniteKernel κ]
     (hf : ∀ i, Measurable (Function.uncurry (f i))) :
     withDensity κ (∑' n, f n) = kernel.sum fun n => withDensity κ (f n) :=
   by
-  have h_sum_a : ∀ a, Summable fun n => f n a := fun a => pi.summable.mpr fun b => Ennreal.summable
+  have h_sum_a : ∀ a, Summable fun n => f n a := fun a => pi.summable.mpr fun b => ENNReal.summable
   have h_sum : Summable fun n => f n := pi.summable.mpr h_sum_a
   ext (a s hs) : 2
   rw [sum_apply' _ a hs, with_density_apply' κ _ a hs]
@@ -713,9 +713,9 @@ theorem withDensity_tsum [Countable ι] (κ : kernel α β) [IsSFiniteKernel κ]
       ext1 p
       simp only [Function.uncurry_def]
       rw [tsum_apply h_sum, tsum_apply (h_sum_a _), tsum_apply]
-      exact pi.summable.mpr fun p => Ennreal.summable
+      exact pi.summable.mpr fun p => ENNReal.summable
     rw [this]
-    exact Measurable.ennreal_tsum' hf
+    exact Measurable.eNNReal_tsum' hf
   have : (∫⁻ b in s, (∑' n, f n) a b ∂κ a) = ∫⁻ b in s, ∑' n, (fun b => f n a b) b ∂κ a :=
     by
     congr with b
@@ -733,14 +733,14 @@ theorem isFiniteKernelWithDensityOfBounded (κ : kernel α β) [IsFiniteKernel 
   by_cases hf : Measurable (Function.uncurry f)
   ·
     exact
-      ⟨⟨B * is_finite_kernel.bound κ, Ennreal.mul_lt_top hB_top (is_finite_kernel.bound_ne_top κ),
+      ⟨⟨B * is_finite_kernel.bound κ, ENNReal.mul_lt_top hB_top (is_finite_kernel.bound_ne_top κ),
           fun a => by
           rw [with_density_apply' κ hf a MeasurableSet.univ]
           calc
             (∫⁻ b in Set.univ, f a b ∂κ a) ≤ ∫⁻ b in Set.univ, B ∂κ a := lintegral_mono (hf_B a)
             _ = B * κ a Set.univ := by simp only [measure.restrict_univ, lintegral_const]
             _ ≤ B * is_finite_kernel.bound κ :=
-              Ennreal.mul_le_mul le_rfl (measure_le_bound κ a Set.univ)
+              ENNReal.mul_le_mul le_rfl (measure_le_bound κ a Set.univ)
             ⟩⟩
   · rw [with_density_of_not_measurable _ hf]
     infer_instance
@@ -764,9 +764,9 @@ theorem isSFiniteKernelWithDensityOfIsFiniteKernel (κ : kernel α β) [IsFinite
     by
     intro a b n hn
     have : (f a b).toReal ≤ n := Nat.le_of_ceil_le hn
-    rw [← Ennreal.le_ofReal_iff_toReal_le (hf_ne_top a b) _] at this
+    rw [← ENNReal.le_ofReal_iff_toReal_le (hf_ne_top a b) _] at this
     · refine' this.trans (le_of_eq _)
-      rw [Ennreal.ofReal_coe_nat]
+      rw [ENNReal.ofReal_coe_nat]
     · norm_cast
       exact zero_le _
   have h_zero : ∀ a b n, ⌈(f a b).toReal⌉₊ ≤ n → fs n a b = 0 :=
@@ -789,7 +789,7 @@ theorem isSFiniteKernelWithDensityOfIsFiniteKernel (κ : kernel α β) [IsFinite
       exact h_zero a b n hn_not_mem
     ext (a b) : 2
     rw [tsum_apply (pi.summable.mpr h_sum_a), tsum_apply (h_sum_a a),
-      Ennreal.tsum_eq_liminf_sum_nat]
+      ENNReal.tsum_eq_liminf_sum_nat]
     have h_finset_sum : ∀ n, (∑ i in Finset.range n, fs i a b) = min (f a b) n :=
       by
       intro n
@@ -815,7 +815,7 @@ theorem isSFiniteKernelWithDensityOfIsFiniteKernel (κ : kernel α β) [IsFinite
     by
     haveI := this
     infer_instance
-  refine' is_finite_kernel_with_density_of_bounded _ (Ennreal.coe_ne_top : ↑n + 1 ≠ ∞) fun a b => _
+  refine' is_finite_kernel_with_density_of_bounded _ (ENNReal.coe_ne_top : ↑n + 1 ≠ ∞) fun a b => _
   norm_cast
   calc
     fs n a b ≤ min (f a b) (n + 1) := tsub_le_self
@@ -843,7 +843,7 @@ theorem IsSFiniteKernel.withDensity (κ : kernel α β) [IsSFiniteKernel κ]
 /-- For a s-finite kernel `κ` and a function `f : α → β → ℝ≥0`, `with_density κ f` is s-finite. -/
 instance (κ : kernel α β) [IsSFiniteKernel κ] (f : α → β → ℝ≥0) :
     IsSFiniteKernel (withDensity κ fun a b => f a b) :=
-  IsSFiniteKernel.withDensity κ fun _ _ => Ennreal.coe_ne_top
+  IsSFiniteKernel.withDensity κ fun _ _ => ENNReal.coe_ne_top
 
 end WithDensity
 

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 2 (#12361)

A PR analogous to #12338: reformatting proofs following the multiple goals linter of #12339.

Diff
@@ -296,7 +296,10 @@ class _root_.ProbabilityTheory.IsSFiniteKernel (κ : kernel α β) : Prop where
 
 instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
     IsSFiniteKernel κ :=
-  ⟨⟨fun n => if n = 0 then κ else 0, fun n => by simp only; split_ifs; exact h; infer_instance, by
+  ⟨⟨fun n => if n = 0 then κ else 0, fun n => by
+      simp only; split_ifs
+      · exact h
+      · infer_instance, by
       ext a s hs
       rw [kernel.sum_apply' _ _ hs]
       have : (fun i => ((ite (i = 0) κ 0) a) s) = fun i => ite (i = 0) (κ a s) 0 := by
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
@@ -434,20 +434,28 @@ theorem integral_deterministic {E : Type*} [NormedAddCommGroup E] [NormedSpace 
   rw [kernel.deterministic_apply, integral_dirac _ (g a)]
 #align probability_theory.kernel.integral_deterministic ProbabilityTheory.kernel.integral_deterministic
 
-theorem set_integral_deterministic' {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem setIntegral_deterministic' {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
-  rw [kernel.deterministic_apply, set_integral_dirac' hf _ hs]
-#align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.set_integral_deterministic'
+  rw [kernel.deterministic_apply, setIntegral_dirac' hf _ hs]
+#align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.setIntegral_deterministic'
+
+@[deprecated]
+alias set_integral_deterministic' :=
+  setIntegral_deterministic' -- deprecated on 2024-04-17
 
 @[simp]
-theorem set_integral_deterministic {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem setIntegral_deterministic {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
-  rw [kernel.deterministic_apply, set_integral_dirac f _ s]
-#align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.set_integral_deterministic
+  rw [kernel.deterministic_apply, setIntegral_dirac f _ s]
+#align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.setIntegral_deterministic
+
+@[deprecated]
+alias set_integral_deterministic :=
+  setIntegral_deterministic -- deprecated on 2024-04-17
 
 end Deterministic
 
@@ -509,10 +517,14 @@ theorem integral_const {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
 #align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
 
 @[simp]
-theorem set_integral_const {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem setIntegral_const {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
     ∫ x in s, f x ∂kernel.const α μ a = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
-#align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
+#align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.setIntegral_const
+
+@[deprecated]
+alias set_integral_const :=
+  setIntegral_const -- deprecated on 2024-04-17
 
 end Const
 
@@ -565,11 +577,15 @@ theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : 
 #align probability_theory.kernel.set_lintegral_restrict ProbabilityTheory.kernel.set_lintegral_restrict
 
 @[simp]
-theorem set_integral_restrict {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem setIntegral_restrict {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
     ∫ x in t, f x ∂kernel.restrict κ hs a = ∫ x in t ∩ s, f x ∂κ a := by
   rw [restrict_apply, Measure.restrict_restrict' hs]
-#align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.set_integral_restrict
+#align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.setIntegral_restrict
+
+@[deprecated]
+alias set_integral_restrict :=
+  setIntegral_restrict -- deprecated on 2024-04-17
 
 instance IsFiniteKernel.restrict (κ : kernel α β) [IsFiniteKernel κ] (hs : MeasurableSet s) :
     IsFiniteKernel (kernel.restrict κ hs) := by
@@ -713,12 +729,16 @@ theorem integral_piecewise {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
 
-theorem set_integral_piecewise {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem setIntegral_piecewise {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     (a : α) (g : β → E) (t : Set β) :
     ∫ b in t, g b ∂piecewise hs κ η a =
       if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
-#align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.set_integral_piecewise
+#align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.setIntegral_piecewise
+
+@[deprecated]
+alias set_integral_piecewise :=
+  setIntegral_piecewise -- deprecated on 2024-04-17
 
 end Piecewise
 
feat: density of a finite kernel wrt another kernel (#10948)

Let κ : kernel α (γ × β) and ν : kernel α γ be two finite kernels with kernel.fst κ ≤ ν, where γ has a countably generated σ-algebra (true in particular for standard Borel spaces). We build a function f : α → γ → Set β → ℝ jointly measurable in the first two arguments such that for all a : α and all measurable sets s : Set β and A : Set γ, ∫ x in A, f a x s ∂(ν a) = (κ a (A ×ˢ s)).toReal.

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

Diff
@@ -169,6 +169,10 @@ instance IsFiniteKernel.add (κ η : kernel α β) [IsFiniteKernel κ] [IsFinite
   exact add_le_add (kernel.measure_le_bound _ _ _) (kernel.measure_le_bound _ _ _)
 #align probability_theory.is_finite_kernel.add ProbabilityTheory.IsFiniteKernel.add
 
+lemma isFiniteKernel_of_le {κ ν : kernel α β} [hν : IsFiniteKernel ν] (hκν : κ ≤ ν) :
+    IsFiniteKernel κ := by
+  refine ⟨hν.bound, hν.bound_lt_top, fun a ↦ (hκν _ _).trans (kernel.measure_le_bound ν a Set.univ)⟩
+
 variable {κ : kernel α β}
 
 instance IsMarkovKernel.is_probability_measure' [IsMarkovKernel κ] (a : α) :
feat(Probability/Kernel): add compProd_add_left/right (#11272)

Interaction of the composition-product of kernels with addition.

Diff
@@ -465,6 +465,9 @@ theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
 lemma const_zero : kernel.const α (0 : Measure β) = 0 := by
   ext x s _; simp [kernel.const_apply]
 
+lemma const_add (β : Type*) [MeasurableSpace β] (μ ν : Measure α) :
+    const β (μ + ν) = const β μ + const β ν := by ext; simp
+
 lemma sum_const [Countable ι] (μ : ι → Measure β) :
     kernel.sum (fun n ↦ const α (μ n)) = const α (Measure.sum μ) := by
   ext x s hs
chore: classify todo porting notes (#11216)

Classifies by adding issue number #11215 to porting notes claiming "TODO".

Diff
@@ -133,8 +133,9 @@ class IsFiniteKernel (κ : kernel α β) : Prop where
 /-- A constant `C : ℝ≥0∞` such that `C < ∞` (`ProbabilityTheory.IsFiniteKernel.bound_lt_top κ`) and
 for all `a : α` and `s : Set β`, `κ a s ≤ C` (`ProbabilityTheory.kernel.measure_le_bound κ a s`).
 
-Porting note: TODO: does it make sense to make `ProbabilityTheory.IsFiniteKernel.bound` the least
-possible bound? Should it be an `NNReal` number? -/
+Porting note (#11215): TODO: does it make sense to
+-- make `ProbabilityTheory.IsFiniteKernel.bound` the least possible bound?
+-- Should it be an `NNReal` number? -/
 noncomputable def IsFiniteKernel.bound (κ : kernel α β) [h : IsFiniteKernel κ] : ℝ≥0∞ :=
   h.exists_univ_le.choose
 #align probability_theory.is_finite_kernel.bound ProbabilityTheory.IsFiniteKernel.bound
feat: add kernel.(co)map_id (#10801)
Diff
@@ -608,6 +608,10 @@ theorem comapRight_apply' (κ : kernel α β) (hf : MeasurableEmbedding f) (a :
     Measure.comap_apply _ hf.injective (fun s => hf.measurableSet_image.mpr) _ ht]
 #align probability_theory.kernel.comap_right_apply' ProbabilityTheory.kernel.comapRight_apply'
 
+@[simp]
+lemma comapRight_id (κ : kernel α β) : comapRight κ MeasurableEmbedding.id = κ := by
+  ext _ _ hs; rw [comapRight_apply' _ _ _ hs]; simp
+
 theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding f)
     (hκ : ∀ a, κ a (Set.range f) = 1) : IsMarkovKernel (comapRight κ hf) := by
   refine' ⟨fun a => ⟨_⟩⟩
feat: instances CovariantAddLE and OrderBot for kernel (#10802)
Diff
@@ -70,6 +70,16 @@ instance {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] :
   coe := Subtype.val
   coe_injective' := Subtype.val_injective
 
+instance kernel.instCovariantAddLE {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] :
+    CovariantClass (kernel α β) (kernel α β) (· + ·) (· ≤ ·) :=
+  ⟨fun _ _ _ hμ a ↦ add_le_add_left (hμ a) _⟩
+
+noncomputable
+instance kernel.instOrderBot {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] :
+    OrderBot (kernel α β) where
+  bot := 0
+  bot_le κ a := by simp only [ZeroMemClass.coe_zero, Pi.zero_apply, Measure.zero_le]
+
 variable {α β ι : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β}
 
 namespace kernel
chore: reduce imports (#9830)

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

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

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Rémy Degenne
 -/
 import Mathlib.MeasureTheory.Integral.Bochner
-import Mathlib.MeasureTheory.Constructions.Prod.Basic
+import Mathlib.MeasureTheory.Measure.GiryMonad
 
 #align_import probability.kernel.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
 
refactor(*): abbreviation for non-dependent FunLike (#9833)

This follows up from #9785, which renamed FunLike to DFunLike, by introducing a new abbreviation FunLike F α β := DFunLike F α (fun _ => β), to make the non-dependent use of FunLike easier.

I searched for the pattern DFunLike.*fun and DFunLike.*λ in all files to replace expressions of the form DFunLike F α (fun _ => β) with FunLike F α β. I did this everywhere except for extends clauses for two reasons: it would conflict with #8386, and more importantly extends must directly refer to a structure with no unfolding of defs or abbrevs.

Diff
@@ -64,9 +64,9 @@ noncomputable def kernel (α β : Type*) [MeasurableSpace α] [MeasurableSpace 
   add_mem' hf hg := Measurable.add hf hg
 #align probability_theory.kernel ProbabilityTheory.kernel
 
--- Porting note: using `DFunLike` instead of `CoeFun` to use `DFunLike.coe`
+-- Porting note: using `FunLike` instead of `CoeFun` to use `DFunLike.coe`
 instance {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] :
-    DFunLike (kernel α β) α fun _ => Measure β where
+    FunLike (kernel α β) α (Measure β) where
   coe := Subtype.val
   coe_injective' := Subtype.val_injective
 
chore(*): rename FunLike to DFunLike (#9785)

This prepares for the introduction of a non-dependent synonym of FunLike, which helps a lot with keeping #8386 readable.

This is entirely search-and-replace in 680197f combined with manual fixes in 4145626, e900597 and b8428f8. The commands that generated this change:

sed -i 's/\bFunLike\b/DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoFunLike\b/toDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/import Mathlib.Data.DFunLike/import Mathlib.Data.FunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bHom_FunLike\b/Hom_DFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean     
sed -i 's/\binstFunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\bfunLike\b/instDFunLike/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean
sed -i 's/\btoo many metavariables to apply `fun_like.has_coe_to_fun`/too many metavariables to apply `DFunLike.hasCoeToFun`/g' {Archive,Counterexamples,Mathlib,test}/**/*.lean

Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -64,9 +64,9 @@ noncomputable def kernel (α β : Type*) [MeasurableSpace α] [MeasurableSpace 
   add_mem' hf hg := Measurable.add hf hg
 #align probability_theory.kernel ProbabilityTheory.kernel
 
--- Porting note: using `FunLike` instead of `CoeFun` to use `FunLike.coe`
+-- Porting note: using `DFunLike` instead of `CoeFun` to use `DFunLike.coe`
 instance {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] :
-    FunLike (kernel α β) α fun _ => Measure β where
+    DFunLike (kernel α β) α fun _ => Measure β where
   coe := Subtype.val
   coe_injective' := Subtype.val_injective
 
@@ -177,10 +177,10 @@ instance (priority := 100) IsMarkovKernel.isFiniteKernel [IsMarkovKernel κ] :
 namespace kernel
 
 @[ext]
-theorem ext {η : kernel α β} (h : ∀ a, κ a = η a) : κ = η := FunLike.ext _ _ h
+theorem ext {η : kernel α β} (h : ∀ a, κ a = η a) : κ = η := DFunLike.ext _ _ h
 #align probability_theory.kernel.ext ProbabilityTheory.kernel.ext
 
-theorem ext_iff {η : kernel α β} : κ = η ↔ ∀ a, κ a = η a := FunLike.ext_iff
+theorem ext_iff {η : kernel α β} : κ = η ↔ ∀ a, κ a = η a := DFunLike.ext_iff
 #align probability_theory.kernel.ext_iff ProbabilityTheory.kernel.ext_iff
 
 theorem ext_iff' {η : kernel α β} :
chore(*): drop $/<| before fun (#9361)

Subset of #9319

Diff
@@ -215,7 +215,7 @@ lemma IsFiniteKernel.integrable (μ : Measure α) [IsFiniteMeasure μ]
     Integrable (fun x => (κ x s).toReal) μ := by
   refine' Integrable.mono' (integrable_const (IsFiniteKernel.bound κ).toReal)
     ((kernel.measurable_coe κ hs).ennreal_toReal.aestronglyMeasurable)
-    (ae_of_all μ <| fun x => _)
+    (ae_of_all μ fun x => _)
   rw [Real.norm_eq_abs, abs_of_nonneg ENNReal.toReal_nonneg,
     ENNReal.toReal_le_toReal (measure_ne_top _ _) (IsFiniteKernel.bound_ne_top _)]
   exact kernel.measure_le_bound _ _ _
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
@@ -454,11 +454,21 @@ theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
 lemma const_zero : kernel.const α (0 : Measure β) = 0 := by
   ext x s _; simp [kernel.const_apply]
 
+lemma sum_const [Countable ι] (μ : ι → Measure β) :
+    kernel.sum (fun n ↦ const α (μ n)) = const α (Measure.sum μ) := by
+  ext x s hs
+  rw [const_apply, Measure.sum_apply _ hs, kernel.sum_apply' _ _ hs]
+  simp only [const_apply]
+
 instance isFiniteKernel_const {μβ : Measure β} [IsFiniteMeasure μβ] :
     IsFiniteKernel (const α μβ) :=
   ⟨⟨μβ Set.univ, measure_lt_top _ _, fun _ => le_rfl⟩⟩
 #align probability_theory.kernel.is_finite_kernel_const ProbabilityTheory.kernel.isFiniteKernel_const
 
+instance isSFiniteKernel_const {μβ : Measure β} [SFinite μβ] :
+    IsSFiniteKernel (const α μβ) :=
+  ⟨fun n ↦ const α (sFiniteSeq μβ n), fun n ↦ inferInstance, by rw [sum_const, sum_sFiniteSeq]⟩
+
 instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure μβ] :
     IsMarkovKernel (const α μβ) :=
   ⟨fun _ => hμβ⟩
chore: remove deprecated MonoidHom.map_prod, AddMonoidHom.map_sum (#8787)
Diff
@@ -97,7 +97,7 @@ theorem zero_apply (a : α) : (0 : kernel α β) a = 0 :=
 
 @[simp]
 theorem coe_finset_sum (I : Finset ι) (κ : ι → kernel α β) : ⇑(∑ i in I, κ i) = ∑ i in I, ⇑(κ i) :=
-  (coeAddHom α β).map_sum _ _
+  map_sum (coeAddHom α β) _ _
 #align probability_theory.kernel.coe_finset_sum ProbabilityTheory.kernel.coe_finset_sum
 
 theorem finset_sum_apply (I : Finset ι) (κ : ι → kernel α β) (a : α) :
feat(Probability): add simp lemmas for kernels (#8497)
Diff
@@ -445,10 +445,15 @@ def const (α : Type*) {β : Type*} [MeasurableSpace α] {_ : MeasurableSpace β
   property := measurable_const
 #align probability_theory.kernel.const ProbabilityTheory.kernel.const
 
+@[simp]
 theorem const_apply (μβ : Measure β) (a : α) : const α μβ a = μβ :=
   rfl
 #align probability_theory.kernel.const_apply ProbabilityTheory.kernel.const_apply
 
+@[simp]
+lemma const_zero : kernel.const α (0 : Measure β) = 0 := by
+  ext x s _; simp [kernel.const_apply]
+
 instance isFiniteKernel_const {μβ : Measure β} [IsFiniteMeasure μβ] :
     IsFiniteKernel (const α μβ) :=
   ⟨⟨μβ Set.univ, measure_lt_top _ _, fun _ => le_rfl⟩⟩
feat: generalize some lemmas using withDensity_apply' (#8383)

@sgouezel added a version of withDensity_apply that does not require measurability of the set if the measure is s-finite. This PR uses that result in other files of the library.

For results about rnDeriv, I put a prime on the version that assumes measurability of the set and no prime on the version for s-finite measures, as the second one should be the main use case.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: RemyDegenne <Remydegenne@gmail.com>

Diff
@@ -308,6 +308,9 @@ instance isFiniteKernel_seq (κ : kernel α β) [h : IsSFiniteKernel κ] (n : 
   h.tsum_finite.choose_spec.1 n
 #align probability_theory.kernel.is_finite_kernel_seq ProbabilityTheory.kernel.isFiniteKernel_seq
 
+instance IsSFiniteKernel.sFinite [IsSFiniteKernel κ] (a : α) : SFinite (κ a) :=
+  ⟨⟨fun n ↦ seq κ n a, inferInstance, (measure_sum_seq κ a).symm⟩⟩
+
 instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFiniteKernel η] :
     IsSFiniteKernel (κ + η) := by
   refine' ⟨⟨fun n => seq κ n + seq η n, fun n => inferInstance, _⟩⟩
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
@@ -57,7 +57,7 @@ namespace ProbabilityTheory
 `κ : α → Measure β`. The measurable space structure on `MeasureTheory.Measure β` is given by
 `MeasureTheory.Measure.instMeasurableSpace`. A map `κ : α → MeasureTheory.Measure β` is measurable
 iff `∀ s : Set β, MeasurableSet s → Measurable (fun a ↦ κ a s)`. -/
-noncomputable def kernel (α β : Type _) [MeasurableSpace α] [MeasurableSpace β] :
+noncomputable def kernel (α β : Type*) [MeasurableSpace α] [MeasurableSpace β] :
     AddSubmonoid (α → Measure β) where
   carrier := Measurable
   zero_mem' := measurable_zero
@@ -65,12 +65,12 @@ noncomputable def kernel (α β : Type _) [MeasurableSpace α] [MeasurableSpace
 #align probability_theory.kernel ProbabilityTheory.kernel
 
 -- Porting note: using `FunLike` instead of `CoeFun` to use `FunLike.coe`
-instance {α β : Type _} [MeasurableSpace α] [MeasurableSpace β] :
+instance {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] :
     FunLike (kernel α β) α fun _ => Measure β where
   coe := Subtype.val
   coe_injective' := Subtype.val_injective
 
-variable {α β ι : Type _} {mα : MeasurableSpace α} {mβ : MeasurableSpace β}
+variable {α β ι : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β}
 
 namespace kernel
 
@@ -85,7 +85,7 @@ theorem coeFn_add (κ η : kernel α β) : ⇑(κ + η) = κ + η :=
 #align probability_theory.kernel.coe_fn_add ProbabilityTheory.kernel.coeFn_add
 
 /-- Coercion to a function as an additive monoid homomorphism. -/
-def coeAddHom (α β : Type _) [MeasurableSpace α] [MeasurableSpace β] :
+def coeAddHom (α β : Type*) [MeasurableSpace α] [MeasurableSpace β] :
     kernel α β →+ α → Measure β :=
   AddSubmonoid.subtype _
 #align probability_theory.kernel.coe_add_hom ProbabilityTheory.kernel.coeAddHom
@@ -144,7 +144,7 @@ theorem kernel.measure_le_bound (κ : kernel α β) [h : IsFiniteKernel κ] (a :
   (measure_mono (Set.subset_univ s)).trans (h.exists_univ_le.choose_spec.2 a)
 #align probability_theory.kernel.measure_le_bound ProbabilityTheory.kernel.measure_le_bound
 
-instance isFiniteKernel_zero (α β : Type _) {mα : MeasurableSpace α} {mβ : MeasurableSpace β} :
+instance isFiniteKernel_zero (α β : Type*) {mα : MeasurableSpace α} {mβ : MeasurableSpace β} :
     IsFiniteKernel (0 : kernel α β) :=
   ⟨⟨0, ENNReal.coe_lt_top, fun _ => by
       simp only [kernel.zero_apply, Measure.coe_zero, Pi.zero_apply, le_zero_iff]⟩⟩
@@ -403,20 +403,20 @@ theorem set_lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a :
   rw [kernel.deterministic_apply, set_lintegral_dirac f s]
 #align probability_theory.kernel.set_lintegral_deterministic ProbabilityTheory.kernel.set_lintegral_deterministic
 
-theorem integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem integral_deterministic' {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac' _ _ hf]
 #align probability_theory.kernel.integral_deterministic' ProbabilityTheory.kernel.integral_deterministic'
 
 @[simp]
-theorem integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem integral_deterministic {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac _ (g a)]
 #align probability_theory.kernel.integral_deterministic ProbabilityTheory.kernel.integral_deterministic
 
-theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem set_integral_deterministic' {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
@@ -424,7 +424,7 @@ theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedS
 #align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.set_integral_deterministic'
 
 @[simp]
-theorem set_integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem set_integral_deterministic {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
     ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
@@ -436,7 +436,7 @@ end Deterministic
 section Const
 
 /-- Constant kernel, which always returns the same measure. -/
-def const (α : Type _) {β : Type _} [MeasurableSpace α] {_ : MeasurableSpace β} (μβ : Measure β) :
+def const (α : Type*) {β : Type*} [MeasurableSpace α] {_ : MeasurableSpace β} (μβ : Measure β) :
     kernel α β where
   val _ := μβ
   property := measurable_const
@@ -467,13 +467,13 @@ theorem set_lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} {
 #align probability_theory.kernel.set_lintegral_const ProbabilityTheory.kernel.set_lintegral_const
 
 @[simp]
-theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem integral_const {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     {f : β → E} {μ : Measure β} {a : α} : ∫ x, f x ∂kernel.const α μ a = ∫ x, f x ∂μ := by
   rw [kernel.const_apply]
 #align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
 
 @[simp]
-theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem set_integral_const {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
     ∫ x in s, f x ∂kernel.const α μ a = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
@@ -529,7 +529,7 @@ theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : 
 #align probability_theory.kernel.set_lintegral_restrict ProbabilityTheory.kernel.set_lintegral_restrict
 
 @[simp]
-theorem set_integral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem set_integral_restrict {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
     ∫ x in t, f x ∂kernel.restrict κ hs a = ∫ x in t ∩ s, f x ∂κ a := by
   rw [restrict_apply, Measure.restrict_restrict' hs]
@@ -553,7 +553,7 @@ end Restrict
 
 section ComapRight
 
-variable {γ : Type _} {mγ : MeasurableSpace γ} {f : γ → β}
+variable {γ : Type*} {mγ : MeasurableSpace γ} {f : γ → β}
 
 /-- Kernel with value `(κ a).comap f`, for a measurable embedding `f`. That is, for a measurable set
 `t : Set β`, `ProbabilityTheory.kernel.comapRight κ hf a t = κ a (f '' t)`. -/
@@ -667,13 +667,13 @@ theorem set_lintegral_piecewise (a : α) (g : β → ℝ≥0∞) (t : Set β) :
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_lintegral_piecewise ProbabilityTheory.kernel.set_lintegral_piecewise
 
-theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem integral_piecewise {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     (a : α) (g : β → E) :
     ∫ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
 
-theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
+theorem set_integral_piecewise {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
     (a : α) (g : β → E) (t : Set β) :
     ∫ b in t, g b ∂piecewise hs κ η a =
       if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
feat(Probability/Kernel/Basic): Evaluation function of a finite kernel is integrable (#6111)

Co-authored-by: JasonKYi <kexing.ying19@imperial.ac.uk>

Diff
@@ -210,6 +210,21 @@ protected theorem measurable_coe (κ : kernel α β) {s : Set β} (hs : Measurab
   (Measure.measurable_coe hs).comp (kernel.measurable κ)
 #align probability_theory.kernel.measurable_coe ProbabilityTheory.kernel.measurable_coe
 
+lemma IsFiniteKernel.integrable (μ : Measure α) [IsFiniteMeasure μ]
+    (κ : kernel α β) [IsFiniteKernel κ] {s : Set β} (hs : MeasurableSet s) :
+    Integrable (fun x => (κ x s).toReal) μ := by
+  refine' Integrable.mono' (integrable_const (IsFiniteKernel.bound κ).toReal)
+    ((kernel.measurable_coe κ hs).ennreal_toReal.aestronglyMeasurable)
+    (ae_of_all μ <| fun x => _)
+  rw [Real.norm_eq_abs, abs_of_nonneg ENNReal.toReal_nonneg,
+    ENNReal.toReal_le_toReal (measure_ne_top _ _) (IsFiniteKernel.bound_ne_top _)]
+  exact kernel.measure_le_bound _ _ _
+
+lemma IsMarkovKernel.integrable (μ : Measure α) [IsFiniteMeasure μ]
+    (κ : kernel α β) [IsMarkovKernel κ] {s : Set β} (hs : MeasurableSet s) :
+    Integrable (fun x => (κ x s).toReal) μ :=
+  IsFiniteKernel.integrable μ κ hs
+
 section Sum
 
 /-- Sum of an indexed family of kernels. -/
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,15 +2,12 @@
 Copyright (c) 2022 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.basic
-! leanprover-community/mathlib commit fd5edc43dc4f10b85abfe544b88f82cf13c5f844
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.MeasureTheory.Integral.Bochner
 import Mathlib.MeasureTheory.Constructions.Prod.Basic
 
+#align_import probability.kernel.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
+
 /-!
 # Markov Kernels
 
feat(MeasureTheory.Integral.Bochner): drop completeness requirement from the definition (#5910)

The notion of Bochner integral of a function taking values in a normed space E requires that E is complete. This means that whenever we write down an integral, the term contains the assertion that E is complete.

In this PR, we remove the completeness requirement from the definition, using the junk value 0 when the space is not complete. Mathematically this does not make any difference, as all reasonable applications will be with a complete E. But it means that terms involving integrals become a little bit simpler and that completeness will not have to be checked by the system when applying a bunch of basic lemmas on integrals.

Diff
@@ -455,13 +455,13 @@ theorem set_lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} {
 #align probability_theory.kernel.set_lintegral_const ProbabilityTheory.kernel.set_lintegral_const
 
 @[simp]
-theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     {f : β → E} {μ : Measure β} {a : α} : ∫ x, f x ∂kernel.const α μ a = ∫ x, f x ∂μ := by
   rw [kernel.const_apply]
 #align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
 
 @[simp]
-theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
     ∫ x in s, f x ∂kernel.const α μ a = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
@@ -518,7 +518,7 @@ theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : 
 
 @[simp]
 theorem set_integral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
-    [CompleteSpace E] {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
+    {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
     ∫ x in t, f x ∂kernel.restrict κ hs a = ∫ x in t ∩ s, f x ∂κ a := by
   rw [restrict_apply, Measure.restrict_restrict' hs]
 #align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.set_integral_restrict
@@ -655,14 +655,14 @@ theorem set_lintegral_piecewise (a : α) (g : β → ℝ≥0∞) (t : Set β) :
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_lintegral_piecewise ProbabilityTheory.kernel.set_lintegral_piecewise
 
-theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
+theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     (a : α) (g : β → E) :
     ∫ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
 
 theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
-    [CompleteSpace E] (a : α) (g : β → E) (t : Set β) :
+    (a : α) (g : β → E) (t : Set β) :
     ∫ b in t, g b ∂piecewise hs κ η a =
       if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
chore: remove superfluous parentheses around integrals (#5591)
Diff
@@ -191,7 +191,7 @@ theorem ext_iff' {η : kernel α β} :
   simp_rw [ext_iff, Measure.ext_iff]
 #align probability_theory.kernel.ext_iff' ProbabilityTheory.kernel.ext_iff'
 
-theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a) :
+theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → ∫⁻ b, f b ∂κ a = ∫⁻ b, f b ∂η a) :
     κ = η := by
   ext a s hs
   specialize h a (s.indicator fun _ => 1) (Measurable.indicator measurable_const hs)
@@ -200,7 +200,7 @@ theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f
 #align probability_theory.kernel.ext_fun ProbabilityTheory.kernel.ext_fun
 
 theorem ext_fun_iff {η : kernel α β} :
-    κ = η ↔ ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a :=
+    κ = η ↔ ∀ a f, Measurable f → ∫⁻ b, f b ∂κ a = ∫⁻ b, f b ∂η a :=
   ⟨fun h a f _ => by rw [h], ext_fun⟩
 #align probability_theory.kernel.ext_fun_iff ProbabilityTheory.kernel.ext_fun_iff
 
@@ -368,46 +368,46 @@ instance isMarkovKernel_deterministic {f : α → β} (hf : Measurable f) :
 #align probability_theory.kernel.is_markov_kernel_deterministic ProbabilityTheory.kernel.isMarkovKernel_deterministic
 
 theorem lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
-    (hf : Measurable f) : (∫⁻ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    (hf : Measurable f) : ∫⁻ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, lintegral_dirac' _ hf]
 #align probability_theory.kernel.lintegral_deterministic' ProbabilityTheory.kernel.lintegral_deterministic'
 
 @[simp]
 theorem lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
-    [MeasurableSingletonClass β] : (∫⁻ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    [MeasurableSingletonClass β] : ∫⁻ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, lintegral_dirac (g a) f]
 #align probability_theory.kernel.lintegral_deterministic ProbabilityTheory.kernel.lintegral_deterministic
 
 theorem set_lintegral_deterministic' {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
-    (∫⁻ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫⁻ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_lintegral_dirac' hf hs]
 #align probability_theory.kernel.set_lintegral_deterministic' ProbabilityTheory.kernel.set_lintegral_deterministic'
 
 @[simp]
 theorem set_lintegral_deterministic {f : β → ℝ≥0∞} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
-    (∫⁻ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫⁻ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_lintegral_dirac f s]
 #align probability_theory.kernel.set_lintegral_deterministic ProbabilityTheory.kernel.set_lintegral_deterministic
 
 theorem integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
-    (hf : StronglyMeasurable f) : (∫ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    (hf : StronglyMeasurable f) : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac' _ _ hf]
 #align probability_theory.kernel.integral_deterministic' ProbabilityTheory.kernel.integral_deterministic'
 
 @[simp]
 theorem integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
-    [MeasurableSingletonClass β] : (∫ x, f x ∂kernel.deterministic g hg a) = f (g a) := by
+    [MeasurableSingletonClass β] : ∫ x, f x ∂kernel.deterministic g hg a = f (g a) := by
   rw [kernel.deterministic_apply, integral_dirac _ (g a)]
 #align probability_theory.kernel.integral_deterministic ProbabilityTheory.kernel.integral_deterministic
 
 theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     (hf : StronglyMeasurable f) {s : Set β} (hs : MeasurableSet s) [Decidable (g a ∈ s)] :
-    (∫ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac' hf _ hs]
 #align probability_theory.kernel.set_integral_deterministic' ProbabilityTheory.kernel.set_integral_deterministic'
 
@@ -415,7 +415,7 @@ theorem set_integral_deterministic' {E : Type _} [NormedAddCommGroup E] [NormedS
 theorem set_integral_deterministic {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {g : α → β} {a : α} (hg : Measurable g)
     [MeasurableSingletonClass β] (s : Set β) [Decidable (g a ∈ s)] :
-    (∫ x in s, f x ∂kernel.deterministic g hg a) = if g a ∈ s then f (g a) else 0 := by
+    ∫ x in s, f x ∂kernel.deterministic g hg a = if g a ∈ s then f (g a) else 0 := by
   rw [kernel.deterministic_apply, set_integral_dirac f _ s]
 #align probability_theory.kernel.set_integral_deterministic ProbabilityTheory.kernel.set_integral_deterministic
 
@@ -446,24 +446,24 @@ instance isMarkovKernel_const {μβ : Measure β} [hμβ : IsProbabilityMeasure
 
 @[simp]
 theorem lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} :
-    (∫⁻ x, f x ∂kernel.const α μ a) = ∫⁻ x, f x ∂μ := by rw [kernel.const_apply]
+    ∫⁻ x, f x ∂kernel.const α μ a = ∫⁻ x, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.lintegral_const ProbabilityTheory.kernel.lintegral_const
 
 @[simp]
 theorem set_lintegral_const {f : β → ℝ≥0∞} {μ : Measure β} {a : α} {s : Set β} :
-    (∫⁻ x in s, f x ∂kernel.const α μ a) = ∫⁻ x in s, f x ∂μ := by rw [kernel.const_apply]
+    ∫⁻ x in s, f x ∂kernel.const α μ a = ∫⁻ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_lintegral_const ProbabilityTheory.kernel.set_lintegral_const
 
 @[simp]
 theorem integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
-    {f : β → E} {μ : Measure β} {a : α} : (∫ x, f x ∂kernel.const α μ a) = ∫ x, f x ∂μ := by
+    {f : β → E} {μ : Measure β} {a : α} : ∫ x, f x ∂kernel.const α μ a = ∫ x, f x ∂μ := by
   rw [kernel.const_apply]
 #align probability_theory.kernel.integral_const ProbabilityTheory.kernel.integral_const
 
 @[simp]
 theorem set_integral_const {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     {f : β → E} {μ : Measure β} {a : α} {s : Set β} :
-    (∫ x in s, f x ∂kernel.const α μ a) = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
+    ∫ x in s, f x ∂kernel.const α μ a = ∫ x in s, f x ∂μ := by rw [kernel.const_apply]
 #align probability_theory.kernel.set_integral_const ProbabilityTheory.kernel.set_integral_const
 
 end Const
@@ -507,19 +507,19 @@ theorem restrict_univ : kernel.restrict κ MeasurableSet.univ = κ := by
 
 @[simp]
 theorem lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞) :
-    (∫⁻ b, f b ∂kernel.restrict κ hs a) = ∫⁻ b in s, f b ∂κ a := by rw [restrict_apply]
+    ∫⁻ b, f b ∂kernel.restrict κ hs a = ∫⁻ b in s, f b ∂κ a := by rw [restrict_apply]
 #align probability_theory.kernel.lintegral_restrict ProbabilityTheory.kernel.lintegral_restrict
 
 @[simp]
 theorem set_lintegral_restrict (κ : kernel α β) (hs : MeasurableSet s) (a : α) (f : β → ℝ≥0∞)
-    (t : Set β) : (∫⁻ b in t, f b ∂kernel.restrict κ hs a) = ∫⁻ b in t ∩ s, f b ∂κ a := by
+    (t : Set β) : ∫⁻ b in t, f b ∂kernel.restrict κ hs a = ∫⁻ b in t ∩ s, f b ∂κ a := by
   rw [restrict_apply, Measure.restrict_restrict' hs]
 #align probability_theory.kernel.set_lintegral_restrict ProbabilityTheory.kernel.set_lintegral_restrict
 
 @[simp]
 theorem set_integral_restrict {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] {f : β → E} {a : α} (hs : MeasurableSet s) (t : Set β) :
-    (∫ x in t, f x ∂kernel.restrict κ hs a) = ∫ x in t ∩ s, f x ∂κ a := by
+    ∫ x in t, f x ∂kernel.restrict κ hs a = ∫ x in t ∩ s, f x ∂κ a := by
   rw [restrict_apply, Measure.restrict_restrict' hs]
 #align probability_theory.kernel.set_integral_restrict ProbabilityTheory.kernel.set_integral_restrict
 
@@ -645,25 +645,25 @@ protected instance IsSFiniteKernel.piecewise [IsSFiniteKernel κ] [IsSFiniteKern
 #align probability_theory.kernel.is_s_finite_kernel.piecewise ProbabilityTheory.kernel.IsSFiniteKernel.piecewise
 
 theorem lintegral_piecewise (a : α) (g : β → ℝ≥0∞) :
-    (∫⁻ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a := by
+    ∫⁻ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫⁻ b, g b ∂κ a else ∫⁻ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.lintegral_piecewise ProbabilityTheory.kernel.lintegral_piecewise
 
 theorem set_lintegral_piecewise (a : α) (g : β → ℝ≥0∞) (t : Set β) :
-    (∫⁻ b in t, g b ∂piecewise hs κ η a) =
+    ∫⁻ b in t, g b ∂piecewise hs κ η a =
       if a ∈ s then ∫⁻ b in t, g b ∂κ a else ∫⁻ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_lintegral_piecewise ProbabilityTheory.kernel.set_lintegral_piecewise
 
 theorem integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E]
     (a : α) (g : β → E) :
-    (∫ b, g b ∂piecewise hs κ η a) = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
+    ∫ b, g b ∂piecewise hs κ η a = if a ∈ s then ∫ b, g b ∂κ a else ∫ b, g b ∂η a := by
   simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.integral_piecewise ProbabilityTheory.kernel.integral_piecewise
 
 theorem set_integral_piecewise {E : Type _} [NormedAddCommGroup E] [NormedSpace ℝ E]
     [CompleteSpace E] (a : α) (g : β → E) (t : Set β) :
-    (∫ b in t, g b ∂piecewise hs κ η a) =
+    ∫ b in t, g b ∂piecewise hs κ η a =
       if a ∈ s then ∫ b in t, g b ∂κ a else ∫ b in t, g b ∂η a :=
   by simp_rw [piecewise_apply]; split_ifs <;> rfl
 #align probability_theory.kernel.set_integral_piecewise ProbabilityTheory.kernel.set_integral_piecewise
chore: tidy various files (#5458)
Diff
@@ -23,7 +23,7 @@ measurable sets `s` of `β`, `a ↦ κ a s` is measurable.
 
 Classes of kernels:
 * `ProbabilityTheory.kernel α β`: kernels from `α` to `β`, defined as the `AddSubmonoid` of the
-  measurable functions in `α → measure β`.
+  measurable functions in `α → Measure β`.
 * `ProbabilityTheory.IsMarkovKernel κ`: a kernel from `α` to `β` is said to be a Markov kernel
   if for all `a : α`, `k a` is a probability measure.
 * `ProbabilityTheory.IsFiniteKernel κ`: a kernel from `α` to `β` is said to be finite if there
@@ -36,7 +36,7 @@ Classes of kernels:
 
 Particular kernels:
 * `ProbabilityTheory.kernel.deterministic (f : α → β) (hf : Measurable f)`:
-  kernel `a ↦ measure.dirac (f a)`.
+  kernel `a ↦ Measure.dirac (f a)`.
 * `ProbabilityTheory.kernel.const α (μβ : measure β)`: constant kernel `a ↦ μβ`.
 * `ProbabilityTheory.kernel.restrict κ (hs : MeasurableSet s)`: kernel for which the image of
   `a : α` is `(κ a).restrict s`.
@@ -57,7 +57,7 @@ open scoped MeasureTheory ENNReal NNReal BigOperators
 namespace ProbabilityTheory
 
 /-- A kernel from a measurable space `α` to another measurable space `β` is a measurable function
-`κ : α → measure β`. The measurable space structure on `MeasureTheory.Measure β` is given by
+`κ : α → Measure β`. The measurable space structure on `MeasureTheory.Measure β` is given by
 `MeasureTheory.Measure.instMeasurableSpace`. A map `κ : α → MeasureTheory.Measure β` is measurable
 iff `∀ s : Set β, MeasurableSet s → Measurable (fun a ↦ κ a s)`. -/
 noncomputable def kernel (α β : Type _) [MeasurableSpace α] [MeasurableSpace β] :
chore: bump Std4 (#5219)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -193,10 +193,9 @@ theorem ext_iff' {η : kernel α β} :
 
 theorem ext_fun {η : kernel α β} (h : ∀ a f, Measurable f → (∫⁻ b, f b ∂κ a) = ∫⁻ b, f b ∂η a) :
     κ = η := by
-   -- porting note: why `ext` doesn't accept `hs` as a third argument (here and below)?
-  ext a s; intro hs
+  ext a s hs
   specialize h a (s.indicator fun _ => 1) (Measurable.indicator measurable_const hs)
-  simp_rw [lintegral_indicator_const hs, one_mul] at h 
+  simp_rw [lintegral_indicator_const hs, one_mul] at h
   rw [h]
 #align probability_theory.kernel.ext_fun ProbabilityTheory.kernel.ext_fun
 
@@ -236,25 +235,25 @@ theorem sum_apply' [Countable ι] (κ : ι → kernel α β) (a : α) {s : Set 
 
 @[simp]
 theorem sum_zero [Countable ι] : (kernel.sum fun _ : ι => (0 : kernel α β)) = 0 := by
-  ext a s; intro hs
+  ext a s hs
   rw [sum_apply' _ a hs]
   simp only [zero_apply, Measure.coe_zero, Pi.zero_apply, tsum_zero]
 #align probability_theory.kernel.sum_zero ProbabilityTheory.kernel.sum_zero
 
 theorem sum_comm [Countable ι] (κ : ι → ι → kernel α β) :
     (kernel.sum fun n => kernel.sum (κ n)) = kernel.sum fun m => kernel.sum fun n => κ n m := by
-  ext a s; intro; simp_rw [sum_apply]; rw [Measure.sum_comm]
+  ext a s; simp_rw [sum_apply]; rw [Measure.sum_comm]
 #align probability_theory.kernel.sum_comm ProbabilityTheory.kernel.sum_comm
 
 @[simp]
 theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i := by
-  ext a s; intro hs
+  ext a s hs
   simp only [sum_apply' κ a hs, finset_sum_apply' _ κ a s, tsum_fintype]
 #align probability_theory.kernel.sum_fintype ProbabilityTheory.kernel.sum_fintype
 
 theorem sum_add [Countable ι] (κ η : ι → kernel α β) :
     (kernel.sum fun n => κ n + η n) = kernel.sum κ + kernel.sum η := by
-  ext a s; intro hs
+  ext a s hs
   simp only [coeFn_add, Pi.add_apply, sum_apply, Measure.sum_apply _ hs, Pi.add_apply,
     Measure.coe_add, tsum_add ENNReal.summable ENNReal.summable]
 #align probability_theory.kernel.sum_add ProbabilityTheory.kernel.sum_add
@@ -271,7 +270,7 @@ class _root_.ProbabilityTheory.IsSFiniteKernel (κ : kernel α β) : Prop where
 instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
     IsSFiniteKernel κ :=
   ⟨⟨fun n => if n = 0 then κ else 0, fun n => by simp only; split_ifs; exact h; infer_instance, by
-      ext a s; intro hs
+      ext a s hs
       rw [kernel.sum_apply' _ _ hs]
       have : (fun i => ((ite (i = 0) κ 0) a) s) = fun i => ite (i = 0) (κ a s) 0 := by
         ext1 i; split_ifs <;> rfl
@@ -321,7 +320,7 @@ theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel
   refine' ⟨⟨fun n => seq (κs (e n).1) (e n).2, inferInstance, _⟩⟩
   have hκ_eq : kernel.sum κs = kernel.sum fun n => kernel.sum (seq (κs n)) := by
     simp_rw [kernel_sum_seq]
-  ext a s; intro hs
+  ext a s hs
   rw [hκ_eq]
   simp_rw [kernel.sum_apply' _ _ hs]
   change (∑' i, ∑' m, seq (κs i) m a s) = ∑' n, (fun im : ι × ℕ => seq (κs im.fst) im.snd a s) (e n)
@@ -674,4 +673,3 @@ end Piecewise
 end kernel
 
 end ProbabilityTheory
-
chore: convert lambda in docs to fun (#5045)

Found with git grep -n "λ [a-zA-Z_ ]*,"

Diff
@@ -59,7 +59,7 @@ namespace ProbabilityTheory
 /-- A kernel from a measurable space `α` to another measurable space `β` is a measurable function
 `κ : α → measure β`. The measurable space structure on `MeasureTheory.Measure β` is given by
 `MeasureTheory.Measure.instMeasurableSpace`. A map `κ : α → MeasureTheory.Measure β` is measurable
-iff `∀ s : Set β, MeasurableSet s → Measurable (λ a, κ a s)`. -/
+iff `∀ s : Set β, MeasurableSet s → Measurable (fun a ↦ κ a s)`. -/
 noncomputable def kernel (α β : Type _) [MeasurableSpace α] [MeasurableSpace β] :
     AddSubmonoid (α → Measure β) where
   carrier := Measurable
chore: fix grammar 3/3 (#5003)

Part 3 of #5001

Diff
@@ -28,7 +28,7 @@ Classes of kernels:
   if for all `a : α`, `k a` is a probability measure.
 * `ProbabilityTheory.IsFiniteKernel κ`: a kernel from `α` to `β` is said to be finite if there
   exists `C : ℝ≥0∞` such that `C < ∞` and for all `a : α`, `κ a univ ≤ C`. This implies in
-  particular that all measures in the image of `κ` are finite, but is stronger since it requires an
+  particular that all measures in the image of `κ` are finite, but is stronger since it requires a
   uniform bound. This stronger condition is necessary to ensure that the composition of two finite
   kernels is finite.
 * `ProbabilityTheory.IsSFiniteKernel κ`: a kernel is called s-finite if it is a countable
feat: port Probability.Kernel.Basic (#4879)

Dependencies 12 + 938

939 files ported (98.7%)
430063 lines ported (98.7%)
Show graph

The unported dependencies are

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