l3lab/ntp-mathlib huggingface dataset:
@[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
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
s t✝ : Set β
κ : ↥(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

Next tactic:
rw [restrict_apply, Measure.restrict_restrict' hs]
@[simp]
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
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : ↥(kernel α β)
s t✝ : Set β
E : Type u_4
inst✝¹ : NormedAddCommGroup E
inst✝ : 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

Next tactic:
rw [restrict_apply, Measure.restrict_restrict' hs]
instance IsFiniteKernel.restrict (κ : kernel α β) [IsFiniteKernel κ] (hs : MeasurableSet s) :
    IsFiniteKernel (kernel.restrict κ hs) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
s t : Set β
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
hs : MeasurableSet s
⊢ IsFiniteKernel (kernel.restrict κ hs)

Next tactic:
refine' ⟨⟨IsFiniteKernel.bound κ, IsFiniteKernel.bound_lt_top κ, fun a => _⟩⟩
instance IsFiniteKernel.restrict (κ : kernel α β) [IsFiniteKernel κ] (hs : MeasurableSet s) :
    IsFiniteKernel (kernel.restrict κ hs) := by
  refine' ⟨⟨IsFiniteKernel.bound κ, IsFiniteKernel.bound_lt_top κ, fun a => _⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
s t : Set β
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
hs : MeasurableSet s
a : α
⊢ ↑↑((kernel.restrict κ hs) a) Set.univ ≤ IsFiniteKernel.bound κ

Next tactic:
rw [restrict_apply' κ hs a MeasurableSet.univ]
instance IsFiniteKernel.restrict (κ : kernel α β) [IsFiniteKernel κ] (hs : MeasurableSet s) :
    IsFiniteKernel (kernel.restrict κ hs) := by
  refine' ⟨⟨IsFiniteKernel.bound κ, IsFiniteKernel.bound_lt_top κ, fun a => _⟩⟩
  rw [restrict_apply' κ hs a MeasurableSet.univ]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
s t : Set β
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
hs : MeasurableSet s
a : α
⊢ ↑↑(κ a) (Set.univ ∩ s) ≤ IsFiniteKernel.bound κ

Next tactic:
exact measure_le_bound κ a _
instance IsSFiniteKernel.restrict (κ : kernel α β) [IsSFiniteKernel κ] (hs : MeasurableSet s) :
    IsSFiniteKernel (kernel.restrict κ hs) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
s t : Set β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hs : MeasurableSet s
⊢ IsSFiniteKernel (kernel.restrict κ hs)

Next tactic:
refine' ⟨⟨fun n => kernel.restrict (seq κ n) hs, inferInstance, _⟩⟩
instance IsSFiniteKernel.restrict (κ : kernel α β) [IsSFiniteKernel κ] (hs : MeasurableSet s) :
    IsSFiniteKernel (kernel.restrict κ hs) := by
  refine' ⟨⟨fun n => kernel.restrict (seq κ n) hs, inferInstance, _⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
s t : Set β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hs : MeasurableSet s
⊢ kernel.restrict κ hs = kernel.sum fun n => kernel.restrict (seq κ n) hs

Next tactic:
ext1 a
instance IsSFiniteKernel.restrict (κ : kernel α β) [IsSFiniteKernel κ] (hs : MeasurableSet s) :
    IsSFiniteKernel (kernel.restrict κ hs) := by
  refine' ⟨⟨fun n => kernel.restrict (seq κ n) hs, inferInstance, _⟩⟩
  ext1 a
  

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

Next tactic:
simp_rw [sum_apply, restrict_apply, ← Measure.restrict_sum _ hs, ← sum_apply, kernel_sum_seq]
/-- 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)`. -/
noncomputable def comapRight (κ : kernel α β) (hf : MeasurableEmbedding f) : kernel α γ where
  val a := (κ a).comap f
  property := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
⊢ (fun a => Measure.comap f (κ a)) ∈ kernel α γ

Next tactic:
refine' Measure.measurable_measure.mpr fun t ht => _
/-- 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)`. -/
noncomputable def comapRight (κ : kernel α β) (hf : MeasurableEmbedding f) : kernel α γ where
  val a := (κ a).comap f
  property := by
    refine' Measure.measurable_measure.mpr fun t ht => _
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
t : Set γ
ht : MeasurableSet t
⊢ Measurable fun b => ↑↑(Measure.comap f (κ b)) t

Next tactic:
have : (fun a => Measure.comap f (κ a) t) = fun a => κ a (f '' t) := by
      ext1 a
      rw [Measure.comap_apply _ hf.injective _ _ ht]
      exact fun s' hs' ↦ hf.measurableSet_image.mpr hs'
/-- 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)`. -/
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
      

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
t : Set γ
ht : MeasurableSet t
⊢ (fun a => ↑↑(Measure.comap f (κ a)) t) = fun a => ↑↑(κ a) (f '' t)

Next tactic:
ext1 a
/-- 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)`. -/
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
      

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
t : Set γ
ht : MeasurableSet t
a : α
⊢ ↑↑(Measure.comap f (κ a)) t = ↑↑(κ a) (f '' t)

Next tactic:
rw [Measure.comap_apply _ hf.injective _ _ ht]
/-- 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)`. -/
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 _ _ ht]
      

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
t : Set γ
ht : MeasurableSet t
a : α
⊢ ∀ (s : Set γ), MeasurableSet s → MeasurableSet (f '' s)

Next tactic:
exact fun s' hs' ↦ hf.measurableSet_image.mpr hs'
/-- 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)`. -/
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 _ _ ht]
      exact fun s' hs' ↦ hf.measurableSet_image.mpr hs'
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
t : Set γ
ht : MeasurableSet t
this : (fun a => ↑↑(Measure.comap f (κ a)) t) = fun a => ↑↑(κ a) (f '' t)
⊢ Measurable fun b => ↑↑(Measure.comap f (κ b)) t

Next tactic:
rw [this]
/-- 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)`. -/
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 _ _ ht]
      exact fun s' hs' ↦ hf.measurableSet_image.mpr hs'
    rw [this]
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
t : Set γ
ht : MeasurableSet t
this : (fun a => ↑↑(Measure.comap f (κ a)) t) = fun a => ↑↑(κ a) (f '' t)
⊢ Measurable fun a => ↑↑(κ a) (f '' t)

Next tactic:
exact kernel.measurable_coe _ (hf.measurableSet_image.mpr ht)
theorem comapRight_apply' (κ : kernel α β) (hf : MeasurableEmbedding f) (a : α) {t : Set γ}
    (ht : MeasurableSet t) : comapRight κ hf a t = κ a (f '' t) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
a : α
t : Set γ
ht : MeasurableSet t
⊢ ↑↑((comapRight κ hf) a) t = ↑↑(κ a) (f '' t)

Next tactic:
rw [comapRight_apply,
    Measure.comap_apply _ hf.injective (fun s => hf.measurableSet_image.mpr) _ ht]
theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding f)
    (hκ : ∀ a, κ a (Set.range f) = 1) : IsMarkovKernel (comapRight κ hf) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
hκ : ∀ (a : α), ↑↑(κ a) (Set.range f) = 1
⊢ IsMarkovKernel (kernel.comapRight κ hf)

Next tactic:
refine' ⟨fun a => ⟨_⟩⟩
theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding f)
    (hκ : ∀ a, κ a (Set.range f) = 1) : IsMarkovKernel (comapRight κ hf) := by
  refine' ⟨fun a => ⟨_⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
hκ : ∀ (a : α), ↑↑(κ a) (Set.range f) = 1
a : α
⊢ ↑↑((kernel.comapRight κ hf) a) Set.univ = 1

Next tactic:
rw [comapRight_apply' κ hf a MeasurableSet.univ]
theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding f)
    (hκ : ∀ a, κ a (Set.range f) = 1) : IsMarkovKernel (comapRight κ hf) := by
  refine' ⟨fun a => ⟨_⟩⟩
  rw [comapRight_apply' κ hf a MeasurableSet.univ]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
hκ : ∀ (a : α), ↑↑(κ a) (Set.range f) = 1
a : α
⊢ ↑↑(κ a) (f '' Set.univ) = 1

Next tactic:
simp only [Set.image_univ, Subtype.range_coe_subtype, Set.setOf_mem_eq]
theorem IsMarkovKernel.comapRight (κ : kernel α β) (hf : MeasurableEmbedding f)
    (hκ : ∀ a, κ a (Set.range f) = 1) : IsMarkovKernel (comapRight κ hf) := by
  refine' ⟨fun a => ⟨_⟩⟩
  rw [comapRight_apply' κ hf a MeasurableSet.univ]
  simp only [Set.image_univ, Subtype.range_coe_subtype, Set.setOf_mem_eq]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
hf : MeasurableEmbedding f
hκ : ∀ (a : α), ↑↑(κ a) (Set.range f) = 1
a : α
⊢ ↑↑(κ a) (Set.range f) = 1

Next tactic:
exact hκ a
instance IsFiniteKernel.comapRight (κ : kernel α β) [IsFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsFiniteKernel (comapRight κ hf) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
hf : MeasurableEmbedding f
⊢ IsFiniteKernel (kernel.comapRight κ hf)

Next tactic:
refine' ⟨⟨IsFiniteKernel.bound κ, IsFiniteKernel.bound_lt_top κ, fun a => _⟩⟩
instance IsFiniteKernel.comapRight (κ : kernel α β) [IsFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨IsFiniteKernel.bound κ, IsFiniteKernel.bound_lt_top κ, fun a => _⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
hf : MeasurableEmbedding f
a : α
⊢ ↑↑((kernel.comapRight κ hf) a) Set.univ ≤ IsFiniteKernel.bound κ

Next tactic:
rw [comapRight_apply' κ hf a .univ]
instance IsFiniteKernel.comapRight (κ : kernel α β) [IsFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨IsFiniteKernel.bound κ, IsFiniteKernel.bound_lt_top κ, fun a => _⟩⟩
  rw [comapRight_apply' κ hf a .univ]
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
hf : MeasurableEmbedding f
a : α
⊢ ↑↑(κ a) (f '' Set.univ) ≤ IsFiniteKernel.bound κ

Next tactic:
exact measure_le_bound κ a _
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
⊢ IsSFiniteKernel (comapRight κ hf)

Next tactic:
refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
⊢ comapRight κ hf = kernel.sum fun n => comapRight (seq κ n) hf

Next tactic:
ext1 a
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
⊢ (comapRight κ hf) a = (kernel.sum fun n => comapRight (seq κ n) hf) a

Next tactic:
rw [sum_apply]
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  rw [sum_apply]
  

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
⊢ (comapRight κ hf) a = Measure.sum fun n => (comapRight (seq κ n) hf) a

Next tactic:
simp_rw [comapRight_apply _ hf]
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  rw [sum_apply]
  simp_rw [comapRight_apply _ hf]
  

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
⊢ Measure.comap f (κ a) = Measure.sum fun n => Measure.comap f ((seq κ n) a)

Next tactic:
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.measurableSet_image.mpr) _ ht,
      Measure.sum_apply _ ht, Measure.sum_apply _ (hf.measurableSet_image.mpr ht)]
    congr with n : 1
    rw [Measure.comap_apply _ hf.injective (fun s' => hf.measurableSet_image.mpr) _ ht]
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  rw [sum_apply]
  simp_rw [comapRight_apply _ hf]
  have :
    (Measure.sum fun n => Measure.comap f (seq κ n a)) =
      Measure.comap f (Measure.sum fun n => seq κ n a) := by
    

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
⊢ (Measure.sum fun n => Measure.comap f ((seq κ n) a)) = Measure.comap f (Measure.sum fun n => (seq κ n) a)

Next tactic:
ext1 t ht
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  rw [sum_apply]
  simp_rw [comapRight_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
    

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
t : Set γ
ht : MeasurableSet t
⊢ ↑↑(Measure.sum fun n => Measure.comap f ((seq κ n) a)) t = ↑↑(Measure.comap f (Measure.sum fun n => (seq κ n) a)) t

Next tactic:
rw [Measure.comap_apply _ hf.injective (fun s' => hf.measurableSet_image.mpr) _ ht,
      Measure.sum_apply _ ht, Measure.sum_apply _ (hf.measurableSet_image.mpr ht)]
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  rw [sum_apply]
  simp_rw [comapRight_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.measurableSet_image.mpr) _ ht,
      Measure.sum_apply _ ht, Measure.sum_apply _ (hf.measurableSet_image.mpr ht)]
    

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
t : Set γ
ht : MeasurableSet t
⊢ ∑' (i : ℕ), ↑↑(Measure.comap f ((seq κ i) a)) t = ∑' (i : ℕ), ↑↑((seq κ i) a) (f '' t)

Next tactic:
congr with n : 1
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  rw [sum_apply]
  simp_rw [comapRight_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.measurableSet_image.mpr) _ ht,
      Measure.sum_apply _ ht, Measure.sum_apply _ (hf.measurableSet_image.mpr ht)]
    congr with n : 1
    

Proof state:
case h.e_f.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
t : Set γ
ht : MeasurableSet t
n : ℕ
⊢ ↑↑(Measure.comap f ((seq κ n) a)) t = ↑↑((seq κ n) a) (f '' t)

Next tactic:
rw [Measure.comap_apply _ hf.injective (fun s' => hf.measurableSet_image.mpr) _ ht]
protected instance IsSFiniteKernel.comapRight (κ : kernel α β) [IsSFiniteKernel κ]
    (hf : MeasurableEmbedding f) : IsSFiniteKernel (comapRight κ hf) := by
  refine' ⟨⟨fun n => comapRight (seq κ n) hf, inferInstance, _⟩⟩
  ext1 a
  rw [sum_apply]
  simp_rw [comapRight_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.measurableSet_image.mpr) _ ht,
      Measure.sum_apply _ ht, Measure.sum_apply _ (hf.measurableSet_image.mpr ht)]
    congr with n : 1
    rw [Measure.comap_apply _ hf.injective (fun s' => hf.measurableSet_image.mpr) _ ht]
  

Proof state:
case h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ✝ : ↥(kernel α β)
γ : Type u_4
mγ : MeasurableSpace γ
f : γ → β
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
hf : MeasurableEmbedding f
a : α
this : (Measure.sum fun n => Measure.comap f ((seq κ n) a)) = Measure.comap f (Measure.sum fun n => (seq κ n) a)
⊢ Measure.comap f (κ a) = Measure.sum fun n => Measure.comap f ((seq κ n) a)

Next tactic:
rw [this, measure_sum_seq]
theorem piecewise_apply' (a : α) (t : Set β) :
    piecewise hs κ η a t = if a ∈ s then κ a t else η a t := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ η : ↥(kernel α β)
s : Set α
hs : MeasurableSet s
inst✝ : DecidablePred fun x => x ∈ s
a : α
t : Set β
⊢ ↑↑((piecewise hs κ η) a) t = if a ∈ s then ↑↑(κ a) t else ↑↑(η a) t

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

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ η : ↥(kernel α β)
s : Set α
hs : MeasurableSet s
inst✝ : DecidablePred fun x => x ∈ s
a : α
t : Set β
⊢ ↑↑(if a ∈ s then κ a else η a) t = if a ∈ s then ↑↑(κ a) t else ↑↑(η a) t

Next tactic:
split_ifs