l3lab/ntp-mathlib huggingface dataset:
@[simp]
lemma fst_compProd (κ : kernel α β) (η : kernel (α × β) γ) [IsSFiniteKernel κ] [IsMarkovKernel η] :
    fst (κ ⊗ₖ η) = κ := by
  ext x s hs
  rw [fst_apply' _ _ hs, compProd_apply]
  swap; · exact measurable_fst hs
  simp only [Set.mem_setOf_eq]
  classical
  have : ∀ b : β, η (x, b) {_c | b ∈ s} = s.indicator (fun _ ↦ 1) b := by
    intro b
    by_cases hb : b ∈ s <;> 

Proof state:
case neg
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α β)
η : ↥(kernel (α × β) γ)
inst✝¹ : IsSFiniteKernel κ
inst✝ : IsMarkovKernel η
x : α
s : Set β
hs : MeasurableSet s
b : β
hb : b ∉ s
⊢ ↑↑(η (x, b)) {_c | b ∈ s} = Set.indicator s (fun x => 1) b

Next tactic:
simp [hb]
@[simp]
lemma fst_compProd (κ : kernel α β) (η : kernel (α × β) γ) [IsSFiniteKernel κ] [IsMarkovKernel η] :
    fst (κ ⊗ₖ η) = κ := by
  ext x s hs
  rw [fst_apply' _ _ hs, compProd_apply]
  swap; · exact measurable_fst hs
  simp only [Set.mem_setOf_eq]
  classical
  have : ∀ b : β, η (x, b) {_c | b ∈ s} = s.indicator (fun _ ↦ 1) b := by
    intro b
    by_cases hb : b ∈ s <;> simp [hb]
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α β)
η : ↥(kernel (α × β) γ)
inst✝¹ : IsSFiniteKernel κ
inst✝ : IsMarkovKernel η
x : α
s : Set β
hs : MeasurableSet s
this : ∀ (b : β), ↑↑(η (x, b)) {_c | b ∈ s} = Set.indicator s (fun x => 1) b
⊢ ∫⁻ (b : β), ↑↑(η (x, b)) {c | b ∈ s} ∂κ x = ↑↑(κ x) s

Next tactic:
simp_rw [this]
@[simp]
lemma fst_compProd (κ : kernel α β) (η : kernel (α × β) γ) [IsSFiniteKernel κ] [IsMarkovKernel η] :
    fst (κ ⊗ₖ η) = κ := by
  ext x s hs
  rw [fst_apply' _ _ hs, compProd_apply]
  swap; · exact measurable_fst hs
  simp only [Set.mem_setOf_eq]
  classical
  have : ∀ b : β, η (x, b) {_c | b ∈ s} = s.indicator (fun _ ↦ 1) b := by
    intro b
    by_cases hb : b ∈ s <;> simp [hb]
  simp_rw [this]
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α β)
η : ↥(kernel (α × β) γ)
inst✝¹ : IsSFiniteKernel κ
inst✝ : IsMarkovKernel η
x : α
s : Set β
hs : MeasurableSet s
this : ∀ (b : β), ↑↑(η (x, b)) {_c | b ∈ s} = Set.indicator s (fun x => 1) b
⊢ ∫⁻ (b : β), Set.indicator s (fun x => 1) b ∂κ x = ↑↑(κ x) s

Next tactic:
rw [lintegral_indicator_const hs, one_mul]
theorem snd_apply' (κ : kernel α (β × γ)) (a : α) {s : Set γ} (hs : MeasurableSet s) :
    snd κ a s = κ a {p | p.2 ∈ s} := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set γ
hs : MeasurableSet s
⊢ ↑↑((snd κ) a) s = ↑↑(κ a) {p | p.2 ∈ s}

Next tactic:
rw [snd_apply, Measure.map_apply measurable_snd hs]
theorem snd_apply' (κ : kernel α (β × γ)) (a : α) {s : Set γ} (hs : MeasurableSet s) :
    snd κ a s = κ a {p | p.2 ∈ s} := by rw [snd_apply, Measure.map_apply measurable_snd hs]; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set γ
hs : MeasurableSet s
⊢ ↑↑(κ a) (Prod.snd ⁻¹' s) = ↑↑(κ a) {p | p.2 ∈ s}

Next tactic:
rfl
@[simp]
lemma snd_zero : snd (0 : kernel α (β × γ)) = 0 := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
⊢ snd 0 = 0

Next tactic:
simp [snd]
theorem lintegral_snd (κ : kernel α (β × γ)) (a : α) {g : γ → ℝ≥0∞} (hg : Measurable g) :
    ∫⁻ c, g c ∂snd κ a = ∫⁻ bc : β × γ, g bc.snd ∂κ a := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g✝ : γ → α
κ : ↥(kernel α (β × γ))
a : α
g : γ → ℝ≥0∞
hg : Measurable g
⊢ ∫⁻ (c : γ), g c ∂(snd κ) a = ∫⁻ (bc : β × γ), g bc.2 ∂κ a

Next tactic:
rw [snd, lintegral_map _ measurable_snd a hg]
instance IsMarkovKernel.snd (κ : kernel α (β × γ)) [IsMarkovKernel κ] : IsMarkovKernel (snd κ) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
inst✝ : IsMarkovKernel κ
⊢ IsMarkovKernel (kernel.snd κ)

Next tactic:
rw [kernel.snd]
instance IsMarkovKernel.snd (κ : kernel α (β × γ)) [IsMarkovKernel κ] : IsMarkovKernel (snd κ) := by
  rw [kernel.snd]; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
inst✝ : IsMarkovKernel κ
⊢ IsMarkovKernel (kernel.map κ Prod.snd (_ : Measurable Prod.snd))

Next tactic:
infer_instance
instance IsFiniteKernel.snd (κ : kernel α (β × γ)) [IsFiniteKernel κ] : IsFiniteKernel (snd κ) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
inst✝ : IsFiniteKernel κ
⊢ IsFiniteKernel (kernel.snd κ)

Next tactic:
rw [kernel.snd]
instance IsFiniteKernel.snd (κ : kernel α (β × γ)) [IsFiniteKernel κ] : IsFiniteKernel (snd κ) := by
  rw [kernel.snd]; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
inst✝ : IsFiniteKernel κ
⊢ IsFiniteKernel (kernel.map κ Prod.snd (_ : Measurable Prod.snd))

Next tactic:
infer_instance
instance IsSFiniteKernel.snd (κ : kernel α (β × γ)) [IsSFiniteKernel κ] : IsSFiniteKernel (snd κ) :=
  by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
inst✝ : IsSFiniteKernel κ
⊢ IsSFiniteKernel (kernel.snd κ)

Next tactic:
rw [kernel.snd]
instance IsSFiniteKernel.snd (κ : kernel α (β × γ)) [IsSFiniteKernel κ] : IsSFiniteKernel (snd κ) :=
  by rw [kernel.snd]; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
inst✝ : IsSFiniteKernel κ
⊢ IsSFiniteKernel (kernel.map κ Prod.snd (_ : Measurable Prod.snd))

Next tactic:
infer_instance
lemma snd_map_prod (κ : kernel α β) {f : β → γ} {g : β → δ}
    (hf : Measurable f) (hg : Measurable g) :
    snd (map κ (fun x ↦ (f x, g x)) (hf.prod_mk hg)) = map κ g hg := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f✝ : β → γ
g✝ : γ → α
κ : ↥(kernel α β)
f : β → γ
g : β → δ
hf : Measurable f
hg : Measurable g
⊢ snd (map κ (fun x => (f x, g x)) (_ : Measurable fun a => (f a, g a))) = map κ g hg

Next tactic:
ext x s hs
lemma snd_map_prod (κ : kernel α β) {f : β → γ} {g : β → δ}
    (hf : Measurable f) (hg : Measurable g) :
    snd (map κ (fun x ↦ (f x, g x)) (hf.prod_mk hg)) = map κ g hg := by
  ext x s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f✝ : β → γ
g✝ : γ → α
κ : ↥(kernel α β)
f : β → γ
g : β → δ
hf : Measurable f
hg : Measurable g
x : α
s : Set δ
hs : MeasurableSet s
⊢ ↑↑((snd (map κ (fun x => (f x, g x)) (_ : Measurable fun a => (f a, g a)))) x) s = ↑↑((map κ g hg) x) s

Next tactic:
rw [snd_apply' _ _ hs, map_apply', map_apply' _ _ _ hs]
lemma snd_map_prod (κ : kernel α β) {f : β → γ} {g : β → δ}
    (hf : Measurable f) (hg : Measurable g) :
    snd (map κ (fun x ↦ (f x, g x)) (hf.prod_mk hg)) = map κ g hg := by
  ext x s hs
  rw [snd_apply' _ _ hs, map_apply', map_apply' _ _ _ hs]
  · 

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f✝ : β → γ
g✝ : γ → α
κ : ↥(kernel α β)
f : β → γ
g : β → δ
hf : Measurable f
hg : Measurable g
x : α
s : Set δ
hs : MeasurableSet s
⊢ ↑↑(κ x) ((fun x => (f x, g x)) ⁻¹' {p | p.2 ∈ s}) = ↑↑(κ x) (g ⁻¹' s)

Next tactic:
rfl
lemma snd_map_prod (κ : kernel α β) {f : β → γ} {g : β → δ}
    (hf : Measurable f) (hg : Measurable g) :
    snd (map κ (fun x ↦ (f x, g x)) (hf.prod_mk hg)) = map κ g hg := by
  ext x s hs
  rw [snd_apply' _ _ hs, map_apply', map_apply' _ _ _ hs]
  · rfl
  · 

Proof state:
case h.h.hs
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f✝ : β → γ
g✝ : γ → α
κ : ↥(kernel α β)
f : β → γ
g : β → δ
hf : Measurable f
hg : Measurable g
x : α
s : Set δ
hs : MeasurableSet s
⊢ MeasurableSet {p | p.2 ∈ s}

Next tactic:
exact measurable_snd hs
@[simp]
lemma fst_swapRight (κ : kernel α (β × γ)) : fst (swapRight κ) = snd κ := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
⊢ fst (swapRight κ) = snd κ

Next tactic:
ext a s hs
@[simp]
lemma fst_swapRight (κ : kernel α (β × γ)) : fst (swapRight κ) = snd κ := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set γ
hs : MeasurableSet s
⊢ ↑↑((fst (swapRight κ)) a) s = ↑↑((snd κ) a) s

Next tactic:
rw [fst_apply' _ _ hs, swapRight_apply', snd_apply' _ _ hs]
@[simp]
lemma fst_swapRight (κ : kernel α (β × γ)) : fst (swapRight κ) = snd κ := by
  ext a s hs
  rw [fst_apply' _ _ hs, swapRight_apply', snd_apply' _ _ hs]
  · 

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set γ
hs : MeasurableSet s
⊢ ↑↑(κ a) {p | Prod.swap p ∈ {p | p.1 ∈ s}} = ↑↑(κ a) {p | p.2 ∈ s}

Next tactic:
rfl
@[simp]
lemma fst_swapRight (κ : kernel α (β × γ)) : fst (swapRight κ) = snd κ := by
  ext a s hs
  rw [fst_apply' _ _ hs, swapRight_apply', snd_apply' _ _ hs]
  · rfl
  · 

Proof state:
case h.h.hs
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set γ
hs : MeasurableSet s
⊢ MeasurableSet {p | p.1 ∈ s}

Next tactic:
exact measurable_fst hs
@[simp]
lemma snd_swapRight (κ : kernel α (β × γ)) : snd (swapRight κ) = fst κ := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
⊢ snd (swapRight κ) = fst κ

Next tactic:
ext a s hs
@[simp]
lemma snd_swapRight (κ : kernel α (β × γ)) : snd (swapRight κ) = fst κ := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑((snd (swapRight κ)) a) s = ↑↑((fst κ) a) s

Next tactic:
rw [snd_apply' _ _ hs, swapRight_apply', fst_apply' _ _ hs]
@[simp]
lemma snd_swapRight (κ : kernel α (β × γ)) : snd (swapRight κ) = fst κ := by
  ext a s hs
  rw [snd_apply' _ _ hs, swapRight_apply', fst_apply' _ _ hs]
  · 

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set β
hs : MeasurableSet s
⊢ ↑↑(κ a) {p | Prod.swap p ∈ {p | p.2 ∈ s}} = ↑↑(κ a) {p | p.1 ∈ s}

Next tactic:
rfl
@[simp]
lemma snd_swapRight (κ : kernel α (β × γ)) : snd (swapRight κ) = fst κ := by
  ext a s hs
  rw [snd_apply' _ _ hs, swapRight_apply', fst_apply' _ _ hs]
  · rfl
  · 

Proof state:
case h.h.hs
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
δ : Type u_4
mδ : MeasurableSpace δ
γ : Type u_5
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α (β × γ))
a : α
s : Set β
hs : MeasurableSet s
⊢ MeasurableSet {p | p.2 ∈ s}

Next tactic:
exact measurable_snd hs
theorem comp_apply' (η : kernel β γ) (κ : kernel α β) (a : α) {s : Set γ} (hs : MeasurableSet s) :
    (η ∘ₖ κ) a s = ∫⁻ b, η b s ∂κ a := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
κ : ↥(kernel α β)
a : α
s : Set γ
hs : MeasurableSet s
⊢ ↑↑((η ∘ₖ κ) a) s = ∫⁻ (b : β), ↑↑(η b) s ∂κ a

Next tactic:
rw [comp_apply, Measure.bind_apply hs (kernel.measurable _)]
theorem comp_eq_snd_compProd (η : kernel β γ) [IsSFiniteKernel η] (κ : kernel α β)
    [IsSFiniteKernel κ] : η ∘ₖ κ = snd (κ ⊗ₖ prodMkLeft α η) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
⊢ η ∘ₖ κ = snd (κ ⊗ₖ prodMkLeft α η)

Next tactic:
ext a s hs
theorem comp_eq_snd_compProd (η : kernel β γ) [IsSFiniteKernel η] (κ : kernel α β)
    [IsSFiniteKernel κ] : η ∘ₖ κ = snd (κ ⊗ₖ prodMkLeft α η) := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
a : α
s : Set γ
hs : MeasurableSet s
⊢ ↑↑((η ∘ₖ κ) a) s = ↑↑((snd (κ ⊗ₖ prodMkLeft α η)) a) s

Next tactic:
rw [comp_apply' _ _ _ hs, snd_apply' _ _ hs, compProd_apply]
theorem comp_eq_snd_compProd (η : kernel β γ) [IsSFiniteKernel η] (κ : kernel α β)
    [IsSFiniteKernel κ] : η ∘ₖ κ = snd (κ ⊗ₖ prodMkLeft α η) := by
  ext a s hs
  rw [comp_apply' _ _ _ hs, snd_apply' _ _ hs, compProd_apply]
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
a : α
s : Set γ
hs : MeasurableSet s
⊢ ∫⁻ (b : β), ↑↑(η b) s ∂κ a = ∫⁻ (b : β), ↑↑((prodMkLeft α η) (a, b)) {c | (b, c) ∈ {p | p.2 ∈ s}} ∂κ a
case h.h.hs
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
a : α
s : Set γ
hs : MeasurableSet s
⊢ MeasurableSet {p | p.2 ∈ s}

Next tactic:
swap
theorem comp_eq_snd_compProd (η : kernel β γ) [IsSFiniteKernel η] (κ : kernel α β)
    [IsSFiniteKernel κ] : η ∘ₖ κ = snd (κ ⊗ₖ prodMkLeft α η) := by
  ext a s hs
  rw [comp_apply' _ _ _ hs, snd_apply' _ _ hs, compProd_apply]
  swap
  · 

Proof state:
case h.h.hs
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
a : α
s : Set γ
hs : MeasurableSet s
⊢ MeasurableSet {p | p.2 ∈ s}

Next tactic:
exact measurable_snd hs
theorem comp_eq_snd_compProd (η : kernel β γ) [IsSFiniteKernel η] (κ : kernel α β)
    [IsSFiniteKernel κ] : η ∘ₖ κ = snd (κ ⊗ₖ prodMkLeft α η) := by
  ext a s hs
  rw [comp_apply' _ _ _ hs, snd_apply' _ _ hs, compProd_apply]
  swap
  · exact measurable_snd hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
a : α
s : Set γ
hs : MeasurableSet s
⊢ ∫⁻ (b : β), ↑↑(η b) s ∂κ a = ∫⁻ (b : β), ↑↑((prodMkLeft α η) (a, b)) {c | (b, c) ∈ {p | p.2 ∈ s}} ∂κ a

Next tactic:
simp only [Set.mem_setOf_eq, Set.setOf_mem_eq, prodMkLeft_apply' _ _ s]
theorem lintegral_comp (η : kernel β γ) (κ : kernel α β) (a : α) {g : γ → ℝ≥0∞}
    (hg : Measurable g) : ∫⁻ c, g c ∂(η ∘ₖ κ) a = ∫⁻ b, ∫⁻ c, g c ∂η b ∂κ a := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g✝ : γ → α
η : ↥(kernel β γ)
κ : ↥(kernel α β)
a : α
g : γ → ℝ≥0∞
hg : Measurable g
⊢ ∫⁻ (c : γ), g c ∂(η ∘ₖ κ) a = ∫⁻ (b : β), ∫⁻ (c : γ), g c ∂η b ∂κ a

Next tactic:
rw [comp_apply, Measure.lintegral_bind (kernel.measurable _) hg]
instance IsMarkovKernel.comp (η : kernel β γ) [IsMarkovKernel η] (κ : kernel α β)
    [IsMarkovKernel κ] : IsMarkovKernel (η ∘ₖ κ) := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsMarkovKernel η
κ : ↥(kernel α β)
inst✝ : IsMarkovKernel κ
⊢ IsMarkovKernel (η ∘ₖ κ)

Next tactic:
rw [comp_eq_snd_compProd]
instance IsMarkovKernel.comp (η : kernel β γ) [IsMarkovKernel η] (κ : kernel α β)
    [IsMarkovKernel κ] : IsMarkovKernel (η ∘ₖ κ) := by rw [comp_eq_snd_compProd]; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsMarkovKernel η
κ : ↥(kernel α β)
inst✝ : IsMarkovKernel κ
⊢ IsMarkovKernel (kernel.snd (κ ⊗ₖ kernel.prodMkLeft α η))

Next tactic:
infer_instance
instance IsFiniteKernel.comp (η : kernel β γ) [IsFiniteKernel η] (κ : kernel α β)
    [IsFiniteKernel κ] : IsFiniteKernel (η ∘ₖ κ) := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
⊢ IsFiniteKernel (η ∘ₖ κ)

Next tactic:
rw [comp_eq_snd_compProd]
instance IsFiniteKernel.comp (η : kernel β γ) [IsFiniteKernel η] (κ : kernel α β)
    [IsFiniteKernel κ] : IsFiniteKernel (η ∘ₖ κ) := by rw [comp_eq_snd_compProd]; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsFiniteKernel κ
⊢ IsFiniteKernel (kernel.snd (κ ⊗ₖ kernel.prodMkLeft α η))

Next tactic:
infer_instance
instance IsSFiniteKernel.comp (η : kernel β γ) [IsSFiniteKernel η] (κ : kernel α β)
    [IsSFiniteKernel κ] : IsSFiniteKernel (η ∘ₖ κ) := by 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
⊢ IsSFiniteKernel (η ∘ₖ κ)

Next tactic:
rw [comp_eq_snd_compProd]
instance IsSFiniteKernel.comp (η : kernel β γ) [IsSFiniteKernel η] (κ : kernel α β)
    [IsSFiniteKernel κ] : IsSFiniteKernel (η ∘ₖ κ) := by rw [comp_eq_snd_compProd]; 

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
η : ↥(kernel β γ)
inst✝¹ : IsSFiniteKernel η
κ : ↥(kernel α β)
inst✝ : IsSFiniteKernel κ
⊢ IsSFiniteKernel (kernel.snd (κ ⊗ₖ kernel.prodMkLeft α η))

Next tactic:
infer_instance
/-- Composition of kernels is associative. -/
theorem comp_assoc {δ : Type*} {mδ : MeasurableSpace δ} (ξ : kernel γ δ) [IsSFiniteKernel ξ]
    (η : kernel β γ) (κ : kernel α β) : ξ ∘ₖ η ∘ₖ κ = ξ ∘ₖ (η ∘ₖ κ) := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
δ : Type u_5
mδ : MeasurableSpace δ
ξ : ↥(kernel γ δ)
inst✝ : IsSFiniteKernel ξ
η : ↥(kernel β γ)
κ : ↥(kernel α β)
⊢ ξ ∘ₖ η ∘ₖ κ = ξ ∘ₖ (η ∘ₖ κ)

Next tactic:
refine' ext_fun fun a f hf => _
/-- Composition of kernels is associative. -/
theorem comp_assoc {δ : Type*} {mδ : MeasurableSpace δ} (ξ : kernel γ δ) [IsSFiniteKernel ξ]
    (η : kernel β γ) (κ : kernel α β) : ξ ∘ₖ η ∘ₖ κ = ξ ∘ₖ (η ∘ₖ κ) := by
  refine' ext_fun fun a f hf => _
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f✝ : β → γ
g : γ → α
δ : Type u_5
mδ : MeasurableSpace δ
ξ : ↥(kernel γ δ)
inst✝ : IsSFiniteKernel ξ
η : ↥(kernel β γ)
κ : ↥(kernel α β)
a : α
f : δ → ℝ≥0∞
hf : Measurable f
⊢ ∫⁻ (b : δ), f b ∂(ξ ∘ₖ η ∘ₖ κ) a = ∫⁻ (b : δ), f b ∂(ξ ∘ₖ (η ∘ₖ κ)) a

Next tactic:
simp_rw [lintegral_comp _ _ _ hf, lintegral_comp _ _ _ hf.lintegral_kernel]
theorem deterministic_comp_eq_map (hf : Measurable f) (κ : kernel α β) :
    deterministic f hf ∘ₖ κ = map κ f hf := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
hf : Measurable f
κ : ↥(kernel α β)
⊢ deterministic f hf ∘ₖ κ = map κ f hf

Next tactic:
ext a s hs
theorem deterministic_comp_eq_map (hf : Measurable f) (κ : kernel α β) :
    deterministic f hf ∘ₖ κ = map κ f hf := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
hf : Measurable f
κ : ↥(kernel α β)
a : α
s : Set γ
hs : MeasurableSet s
⊢ ↑↑((deterministic f hf ∘ₖ κ) a) s = ↑↑((map κ f hf) a) s

Next tactic:
simp_rw [map_apply' _ _ _ hs, comp_apply' _ _ _ hs, deterministic_apply' hf _ hs,
    lintegral_indicator_const_comp hf hs, one_mul]
theorem comp_deterministic_eq_comap (κ : kernel α β) (hg : Measurable g) :
    κ ∘ₖ deterministic g hg = comap κ g hg := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α β)
hg : Measurable g
⊢ κ ∘ₖ deterministic g hg = comap κ g hg

Next tactic:
ext a s hs
theorem comp_deterministic_eq_comap (κ : kernel α β) (hg : Measurable g) :
    κ ∘ₖ deterministic g hg = comap κ g hg := by
  ext a s hs
  

Proof state:
case h.h
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
f : β → γ
g : γ → α
κ : ↥(kernel α β)
hg : Measurable g
a : γ
s : Set β
hs : MeasurableSet s
⊢ ↑↑((κ ∘ₖ deterministic g hg) a) s = ↑↑((comap κ g hg) a) s

Next tactic:
simp_rw [comap_apply' _ _ _ s, comp_apply' _ _ _ hs, deterministic_apply hg a,
    lintegral_dirac' _ (kernel.measurable_coe κ hs)]
theorem prod_apply (κ : kernel α β) [IsSFiniteKernel κ] (η : kernel α γ) [IsSFiniteKernel η] (a : α)
    {s : Set (β × γ)} (hs : MeasurableSet s) :
    (κ ×ₖ η) a s = ∫⁻ b : β, (η a) {c : γ | (b, c) ∈ s} ∂κ a := by
  

Proof state:
α : Type u_1
β : Type u_2
ι : Type u_3
mα : MeasurableSpace α
mβ : MeasurableSpace β
γ : Type u_4
mγ : MeasurableSpace γ
κ : ↥(kernel α β)
inst✝¹ : IsSFiniteKernel κ
η : ↥(kernel α γ)
inst✝ : IsSFiniteKernel η
a : α
s : Set (β × γ)
hs : MeasurableSet s
⊢ ↑↑((κ ×ₖ η) a) s = ∫⁻ (b : β), ↑↑(η a) {c | (b, c) ∈ s} ∂κ a

Next tactic:
simp_rw [prod, compProd_apply _ _ _ hs, swapLeft_apply _ _, prodMkLeft_apply, Prod.swap_prod_mk]