l3lab/ntp-mathlib huggingface dataset:
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 => _)
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
s : Set β
hs : MeasurableSet s
x : α
⊢ ‖ENNReal.toReal (↑↑(κ x) s)‖ ≤ ENNReal.toReal (IsFiniteKernel.bound κ)

Next tactic:
rw [Real.norm_eq_abs, abs_of_nonneg ENNReal.toReal_nonneg,
    ENNReal.toReal_le_toReal (measure_ne_top _ _) (IsFiniteKernel.bound_ne_top _)]
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 _)]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
s : Set β
hs : MeasurableSet s
x : α
⊢ ↑↑(κ x) s ≤ IsFiniteKernel.bound κ

Next tactic:
exact kernel.measure_le_bound _ _ _
/-- Sum of an indexed family of kernels. -/
protected noncomputable def sum [Countable ι] (κ : ι → kernel α β) : kernel α β where
  val a := Measure.sum fun n => κ n a
  property := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ : ι → ↥(kernel α β)
⊢ (fun a => Measure.sum fun n => (κ n) a) ∈ kernel α β

Next tactic:
refine' Measure.measurable_of_measurable_coe _ fun s hs => _
/-- Sum of an indexed family of kernels. -/
protected noncomputable def sum [Countable ι] (κ : ι → kernel α β) : kernel α β where
  val a := Measure.sum fun n => κ n a
  property := by
    refine' Measure.measurable_of_measurable_coe _ fun s hs => _
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ : ι → ↥(kernel α β)
s : Set β
hs : MeasurableSet s
⊢ Measurable fun b => ↑↑(Measure.sum fun n => (κ n) b) s

Next tactic:
simp_rw [Measure.sum_apply _ hs]
/-- Sum of an indexed family of kernels. -/
protected noncomputable def sum [Countable ι] (κ : ι → kernel α β) : kernel α β where
  val a := Measure.sum fun n => κ n a
  property := by
    refine' Measure.measurable_of_measurable_coe _ fun s hs => _
    simp_rw [Measure.sum_apply _ hs]
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ : ι → ↥(kernel α β)
s : Set β
hs : MeasurableSet s
⊢ Measurable fun b => ∑' (i : ι), ↑↑((κ i) b) s

Next tactic:
exact Measurable.ennreal_tsum fun n => kernel.measurable_coe (κ n) hs
theorem sum_apply' [Countable ι] (κ : ι → kernel α β) (a : α) {s : Set β} (hs : MeasurableSet s) :
    kernel.sum κ a s = ∑' n, κ n a s := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ : ι → ↥(kernel α β)
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑((kernel.sum κ) a) s = ∑' (n : ι), ↑↑((κ n) a) s

Next tactic:
rw [sum_apply κ a, Measure.sum_apply _ hs]
@[simp]
theorem sum_zero [Countable ι] : (kernel.sum fun _ : ι => (0 : kernel α β)) = 0 := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
inst✝ : Countable ι
⊢ (kernel.sum fun x => 0) = 0

Next tactic:
ext a s hs
@[simp]
theorem sum_zero [Countable ι] : (kernel.sum fun _ : ι => (0 : kernel α β)) = 0 := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
inst✝ : Countable ι
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑((kernel.sum fun x => 0) a) s = ↑↑(0 a) s

Next tactic:
rw [sum_apply' _ a hs]
@[simp]
theorem sum_zero [Countable ι] : (kernel.sum fun _ : ι => (0 : kernel α β)) = 0 := by
  ext a s hs
  rw [sum_apply' _ a hs]
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
inst✝ : Countable ι
a : α
s : Set β
hs : MeasurableSet s
⊢ ∑' (n : ι), ↑↑(0 a) s = ↑↑(0 a) s

Next tactic:
simp only [zero_apply, Measure.coe_zero, Pi.zero_apply, tsum_zero]
theorem sum_comm [Countable ι] (κ : ι → ι → kernel α β) :
    (kernel.sum fun n => kernel.sum (κ n)) = kernel.sum fun m => kernel.sum fun n => κ n m := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ : ι → ι → ↥(kernel α β)
⊢ (kernel.sum fun n => kernel.sum (κ n)) = kernel.sum fun m => kernel.sum fun n => κ n m

Next tactic:
ext a s
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; 

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ : ι → ι → ↥(kernel α β)
a : α
s : Set β
a✝ : MeasurableSet s
⊢ ↑↑((kernel.sum fun n => kernel.sum (κ n)) a) s = ↑↑((kernel.sum fun m => kernel.sum fun n => κ n m) a) s

Next tactic:
simp_rw [sum_apply]
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; simp_rw [sum_apply]; 

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ : ι → ι → ↥(kernel α β)
a : α
s : Set β
a✝ : MeasurableSet s
⊢ ↑↑(Measure.sum fun n => Measure.sum fun n_1 => (κ n n_1) a) s =
    ↑↑(Measure.sum fun n => Measure.sum fun n_1 => (κ n_1 n) a) s

Next tactic:
rw [Measure.sum_comm]
@[simp]
theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Fintype ι
κ : ι → ↥(kernel α β)
⊢ kernel.sum κ = ∑ i : ι, κ i

Next tactic:
ext a s hs
@[simp]
theorem sum_fintype [Fintype ι] (κ : ι → kernel α β) : kernel.sum κ = ∑ i, κ i := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Fintype ι
κ : ι → ↥(kernel α β)
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑((kernel.sum κ) a) s = ↑↑((∑ i : ι, κ i) a) s

Next tactic:
simp only [sum_apply' κ a hs, finset_sum_apply' _ κ a s, tsum_fintype]
theorem sum_add [Countable ι] (κ η : ι → kernel α β) :
    (kernel.sum fun n => κ n + η n) = kernel.sum κ + kernel.sum η := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ η : ι → ↥(kernel α β)
⊢ (kernel.sum fun n => κ n + η n) = kernel.sum κ + kernel.sum η

Next tactic:
ext a s hs
theorem sum_add [Countable ι] (κ η : ι → kernel α β) :
    (kernel.sum fun n => κ n + η n) = kernel.sum κ + kernel.sum η := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
inst✝ : Countable ι
κ η : ι → ↥(kernel α β)
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑((kernel.sum fun n => κ n + η n) a) s = ↑↑((kernel.sum κ + kernel.sum η) a) s

Next tactic:
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]
instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
    IsSFiniteKernel κ :=
  ⟨⟨fun n => if n = 0 then κ else 0, fun n => by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
n : ℕ
⊢ IsFiniteKernel ((fun n => if n = 0 then κ else 0) n)

Next tactic:
simp only
instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
    IsSFiniteKernel κ :=
  ⟨⟨fun n => if n = 0 then κ else 0, fun n => by simp only; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
n : ℕ
⊢ IsFiniteKernel (if n = 0 then κ else 0)

Next tactic:
split_ifs
instance (priority := 100) IsFiniteKernel.isSFiniteKernel [h : IsFiniteKernel κ] :
    IsSFiniteKernel κ :=
  ⟨⟨fun n => if n = 0 then κ else 0, fun n => by simp only; split_ifs; 

Proof state:
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
n : ℕ
h✝ : n = 0
⊢ IsFiniteKernel κ
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
n : ℕ
h✝ : ¬n = 0
⊢ IsFiniteKernel 0

Next tactic:
exact h
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; 

Proof state:
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
n : ℕ
h✝ : ¬n = 0
⊢ IsFiniteKernel 0

Next tactic:
infer_instance
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
      

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
⊢ κ = kernel.sum fun n => if n = 0 then κ else 0

Next tactic:
ext a s hs
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 hs
      

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑(κ a) s = ↑↑((kernel.sum fun n => if n = 0 then κ else 0) a) s

Next tactic:
rw [kernel.sum_apply' _ _ hs]
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 hs
      rw [kernel.sum_apply' _ _ hs]
      

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑(κ a) s = ∑' (n : ℕ), ↑↑((if n = 0 then κ else 0) a) s

Next tactic:
have : (fun i => ((ite (i = 0) κ 0) a) s) = fun i => ite (i = 0) (κ a s) 0 := by
        ext1 i; split_ifs <;> rfl
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 hs
      rw [kernel.sum_apply' _ _ hs]
      have : (fun i => ((ite (i = 0) κ 0) a) s) = fun i => ite (i = 0) (κ a s) 0 := by
        

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
a : α
s : Set β
hs : MeasurableSet s
⊢ (fun i => ↑↑((if i = 0 then κ else 0) a) s) = fun i => if i = 0 then ↑↑(κ a) s else 0

Next tactic:
ext1 i
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 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; 

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
a : α
s : Set β
hs : MeasurableSet s
i : ℕ
⊢ ↑↑((if i = 0 then κ else 0) a) s = if i = 0 then ↑↑(κ a) s else 0

Next tactic:
split_ifs
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 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 <;> 

Proof state:
case pos
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
a : α
s : Set β
hs : MeasurableSet s
i : ℕ
h✝ : i = 0
⊢ ↑↑(κ a) s = ↑↑(κ a) s

Next tactic:
rfl
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 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 <;> 

Proof state:
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
a : α
s : Set β
hs : MeasurableSet s
i : ℕ
h✝ : ¬i = 0
⊢ ↑↑(0 a) s = 0

Next tactic:
rfl
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 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
      

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
h : IsFiniteKernel κ
a : α
s : Set β
hs : MeasurableSet s
this : (fun i => ↑↑((if i = 0 then κ else 0) a) s) = fun i => if i = 0 then ↑↑(κ a) s else 0
⊢ ↑↑(κ a) s = ∑' (n : ℕ), ↑↑((if n = 0 then κ else 0) a) s

Next tactic:
rw [this, tsum_ite_eq]
theorem measure_sum_seq (κ : kernel α β) [h : IsSFiniteKernel κ] (a : α) :
    (Measure.sum fun n => seq κ n a) = κ a := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ κ : ↥(kernel α β)
h : IsSFiniteKernel κ
a : α
⊢ (Measure.sum fun n => (seq κ n) a) = κ a

Next tactic:
rw [← kernel.sum_apply, kernel_sum_seq κ]
instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFiniteKernel η] :
    IsSFiniteKernel (κ + η) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ κ η : ↥(kernel α β)
inst✝¹ : IsSFiniteKernel κ
inst✝ : IsSFiniteKernel η
⊢ IsSFiniteKernel (κ + η)

Next tactic:
refine' ⟨⟨fun n => seq κ n + seq η n, fun n => inferInstance, _⟩⟩
instance IsSFiniteKernel.add (κ η : kernel α β) [IsSFiniteKernel κ] [IsSFiniteKernel η] :
    IsSFiniteKernel (κ + η) := by
  refine' ⟨⟨fun n => seq κ n + seq η n, fun n => inferInstance, _⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ κ η : ↥(kernel α β)
inst✝¹ : IsSFiniteKernel κ
inst✝ : IsSFiniteKernel η
⊢ κ + η = kernel.sum fun n => seq κ n + seq η n

Next tactic:
rw [sum_add, kernel_sum_seq κ, kernel_sum_seq η]
theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
    (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
I : Finset ι
h : ∀ i ∈ I, IsSFiniteKernel (κs i)
⊢ IsSFiniteKernel (∑ i in I, κs i)

Next tactic:
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 : IsSFiniteKernel (κs i) := h i (Finset.mem_insert_self _ _)
    have : IsSFiniteKernel (∑ x : ι in I, κs x) :=
      h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
    exact IsSFiniteKernel.add _ _
theorem IsSFiniteKernel.finset_sum {κs : ι → kernel α β} (I : Finset ι)
    (h : ∀ i ∈ I, IsSFiniteKernel (κs i)) : IsSFiniteKernel (∑ i in I, κs i) := by
  classical
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
I : Finset ι
h : ∀ i ∈ I, IsSFiniteKernel (κs i)
⊢ IsSFiniteKernel (∑ i in I, κs i)

Next tactic:
induction' I using Finset.induction with i I hi_nmem_I h_ind h
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
  · 

Proof state:
case empty
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
h : ∀ i ∈ ∅, IsSFiniteKernel (κs i)
⊢ IsSFiniteKernel (∑ i in ∅, κs i)

Next tactic:
rw [Finset.sum_empty]
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]; 

Proof state:
case empty
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
h : ∀ i ∈ ∅, IsSFiniteKernel (κs i)
⊢ IsSFiniteKernel 0

Next tactic:
infer_instance
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
  · 

Proof state:
case insert
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
i : ι
I : Finset ι
hi_nmem_I : i ∉ I
h_ind : (∀ i ∈ I, IsSFiniteKernel (κs i)) → IsSFiniteKernel (∑ i in I, κs i)
h : ∀ i_1 ∈ insert i I, IsSFiniteKernel (κs i_1)
⊢ IsSFiniteKernel (∑ i in insert i I, κs i)

Next tactic:
rw [Finset.sum_insert hi_nmem_I]
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]
    

Proof state:
case insert
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
i : ι
I : Finset ι
hi_nmem_I : i ∉ I
h_ind : (∀ i ∈ I, IsSFiniteKernel (κs i)) → IsSFiniteKernel (∑ i in I, κs i)
h : ∀ i_1 ∈ insert i I, IsSFiniteKernel (κs i_1)
⊢ IsSFiniteKernel (κs i + ∑ x in I, κs x)

Next tactic:
haveI : IsSFiniteKernel (κs i) := h i (Finset.mem_insert_self _ _)
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 : IsSFiniteKernel (κs i) := h i (Finset.mem_insert_self _ _)
    

Proof state:
case insert
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
i : ι
I : Finset ι
hi_nmem_I : i ∉ I
h_ind : (∀ i ∈ I, IsSFiniteKernel (κs i)) → IsSFiniteKernel (∑ i in I, κs i)
h : ∀ i_1 ∈ insert i I, IsSFiniteKernel (κs i_1)
this : IsSFiniteKernel (κs i)
⊢ IsSFiniteKernel (κs i + ∑ x in I, κs x)

Next tactic:
have : IsSFiniteKernel (∑ x : ι in I, κs x) :=
      h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
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 : IsSFiniteKernel (κs i) := h i (Finset.mem_insert_self _ _)
    have : IsSFiniteKernel (∑ x : ι in I, κs x) :=
      h_ind fun i hiI => h i (Finset.mem_insert_of_mem hiI)
    

Proof state:
case insert
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
κs : ι → ↥(kernel α β)
i : ι
I : Finset ι
hi_nmem_I : i ∉ I
h_ind : (∀ i ∈ I, IsSFiniteKernel (κs i)) → IsSFiniteKernel (∑ i in I, κs i)
h : ∀ i_1 ∈ insert i I, IsSFiniteKernel (κs i_1)
this✝ : IsSFiniteKernel (κs i)
this : IsSFiniteKernel (∑ x in I, κs x)
⊢ IsSFiniteKernel (κs i + ∑ x in I, κs x)

Next tactic:
exact IsSFiniteKernel.add _ _
theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel α β}
    (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
inst✝ : Denumerable ι
κs : ι → ↥(kernel α β)
hκs : ∀ (n : ι), IsSFiniteKernel (κs n)
⊢ IsSFiniteKernel (kernel.sum κs)

Next tactic:
let e : ℕ ≃ ι × ℕ := (Denumerable.eqv (ι × ℕ)).symm
theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel α β}
    (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) := by
  let e : ℕ ≃ ι × ℕ := (Denumerable.eqv (ι × ℕ)).symm
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
inst✝ : Denumerable ι
κs : ι → ↥(kernel α β)
hκs : ∀ (n : ι), IsSFiniteKernel (κs n)
e : ℕ ≃ ι × ℕ := (Denumerable.eqv (ι × ℕ)).symm
⊢ IsSFiniteKernel (kernel.sum κs)

Next tactic:
refine' ⟨⟨fun n => seq (κs (e n).1) (e n).2, inferInstance, _⟩⟩
theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel α β}
    (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) := by
  let e : ℕ ≃ ι × ℕ := (Denumerable.eqv (ι × ℕ)).symm
  refine' ⟨⟨fun n => seq (κs (e n).1) (e n).2, inferInstance, _⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
inst✝ : Denumerable ι
κs : ι → ↥(kernel α β)
hκs : ∀ (n : ι), IsSFiniteKernel (κs n)
e : ℕ ≃ ι × ℕ := (Denumerable.eqv (ι × ℕ)).symm
⊢ kernel.sum κs = kernel.sum fun n => seq (κs (e n).1) (e n).2

Next tactic:
have hκ_eq : kernel.sum κs = kernel.sum fun n => kernel.sum (seq (κs n)) := by
    simp_rw [kernel_sum_seq]
theorem isSFiniteKernel_sum_of_denumerable [Denumerable ι] {κs : ι → kernel α β}
    (hκs : ∀ n, IsSFiniteKernel (κs n)) : IsSFiniteKernel (kernel.sum κs) := by
  let e : ℕ ≃ ι × ℕ := (Denumerable.eqv (ι × ℕ)).symm
  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
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
inst✝ : Denumerable ι
κs : ι → ↥(kernel α β)
hκs : ∀ (n : ι), IsSFiniteKernel (κs n)
e : ℕ ≃ ι × ℕ := (Denumerable.eqv (ι × ℕ)).symm
⊢ kernel.sum κs = kernel.sum fun n => kernel.sum (seq (κs n))

Next tactic:
simp_rw [kernel_sum_seq]