l3lab/ntp-mathlib huggingface dataset:
/-- The Yoneda embedding for preadditive categories sends an object `X` to the copresheaf sending an
object `Y` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End X`-module
structure, see `preadditiveCoyonedaObj`.
-/
@[simps]
def preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGroupCat.{v} where
  obj X := preadditiveCoyonedaObj X ⋙ forget₂ _ _
  map f :=
    { app := fun Y =>
        { toFun := fun g => f.unop ≫ g
          map_zero' := Limits.comp_zero
          map_add' := fun g g' => comp_add _ _ _ _ _ _ }
      naturality := fun Y Y' g =>
        AddCommGroupCat.ext fun x => Eq.symm <| Category.assoc _ _ _ }
  map_id _ := by ext; dsimp; simp
  map_comp f g := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preadditive C
X✝ Y✝ Z✝ : Cᵒᵖ
f : X✝ ⟶ Y✝
g : Y✝ ⟶ Z✝
⊢ { obj := fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat,
          map := fun {X Y} f =>
            NatTrans.mk fun Y_1 =>
              { toZeroHom := { toFun := fun g => f.unop ≫ g, map_zero' := (_ : f.unop ≫ 0 = 0) },
                map_add' :=
                  (_ :
                    ∀
                      (g g' :
                        ↑(((fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat) X).obj
                            Y_1)),
                      f.unop ≫ (g + g') = f.unop ≫ g + f.unop ≫ g') } }.map
      (f ≫ g) =
    { obj := fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat,
            map := fun {X Y} f =>
              NatTrans.mk fun Y_1 =>
                { toZeroHom := { toFun := fun g => f.unop ≫ g, map_zero' := (_ : f.unop ≫ 0 = 0) },
                  map_add' :=
                    (_ :
                      ∀
                        (g g' :
                          ↑(((fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat) X).obj
                              Y_1)),
                        f.unop ≫ (g + g') = f.unop ≫ g + f.unop ≫ g') } }.map
        f ≫
      { obj := fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat,
            map := fun {X Y} f =>
              NatTrans.mk fun Y_1 =>
                { toZeroHom := { toFun := fun g => f.unop ≫ g, map_zero' := (_ : f.unop ≫ 0 = 0) },
                  map_add' :=
                    (_ :
                      ∀
                        (g g' :
                          ↑(((fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat) X).obj
                              Y_1)),
                        f.unop ≫ (g + g') = f.unop ≫ g + f.unop ≫ g') } }.map
        g

Next tactic:
ext
/-- The Yoneda embedding for preadditive categories sends an object `X` to the copresheaf sending an
object `Y` to the group of morphisms `X ⟶ Y`. At each point, we get an additional `End X`-module
structure, see `preadditiveCoyonedaObj`.
-/
@[simps]
def preadditiveCoyoneda : Cᵒᵖ ⥤ C ⥤ AddCommGroupCat.{v} where
  obj X := preadditiveCoyonedaObj X ⋙ forget₂ _ _
  map f :=
    { app := fun Y =>
        { toFun := fun g => f.unop ≫ g
          map_zero' := Limits.comp_zero
          map_add' := fun g g' => comp_add _ _ _ _ _ _ }
      naturality := fun Y Y' g =>
        AddCommGroupCat.ext fun x => Eq.symm <| Category.assoc _ _ _ }
  map_id _ := by ext; dsimp; simp
  map_comp f g := by ext; dsimp; 

Proof state:
case w.h.w
C : Type u
inst✝¹ : Category.{v, u} C
inst✝ : Preadditive C
X✝ Y✝ Z✝ : Cᵒᵖ
f : X✝ ⟶ Y✝
g : Y✝ ⟶ Z✝
x✝¹ : C
x✝ :
  ↑(({ obj := fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat,
              map := fun {X Y} f =>
                NatTrans.mk fun Y_1 =>
                  { toZeroHom := { toFun := fun g => f.unop ≫ g, map_zero' := (_ : f.unop ≫ 0 = 0) },
                    map_add' :=
                      (_ :
                        ∀
                          (g g' :
                            ↑(((fun X => preadditiveCoyonedaObj X ⋙ forget₂ (ModuleCat (End X)) AddCommGroupCat) X).obj
                                Y_1)),
                          f.unop ≫ (g + g') = f.unop ≫ g + f.unop ≫ g') } }.obj
          X✝).obj
      x✝¹)
⊢ (g.unop ≫ f.unop) ≫ x✝ = g.unop ≫ f.unop ≫ x✝

Next tactic:
simp
instance [MeasurableSpace β] : IsMarkovKernel (condDistrib Y X μ) := by
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
inst✝ : MeasurableSpace β
⊢ IsMarkovKernel (condDistrib Y X μ)

Next tactic:
rw [condDistrib]
instance [MeasurableSpace β] : IsMarkovKernel (condDistrib Y X μ) := by
  rw [condDistrib]; 

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
inst✝ : MeasurableSpace β
⊢ IsMarkovKernel (Measure.condKernel (Measure.map (fun a => (X a, Y a)) μ))

Next tactic:
infer_instance
theorem _root_.MeasureTheory.AEStronglyMeasurable.ae_integrable_condDistrib_map_iff
    (hY : AEMeasurable Y μ) (hf : AEStronglyMeasurable f (μ.map fun a => (X a, Y a))) :
    (∀ᵐ a ∂μ.map X, Integrable (fun ω => f (a, ω)) (condDistrib Y X μ a)) ∧
      Integrable (fun a => ∫ ω, ‖f (a, ω)‖ ∂condDistrib Y X μ a) (μ.map X) ↔
    Integrable f (μ.map fun a => (X a, Y a)) := by
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hY : AEMeasurable Y
hf : AEStronglyMeasurable f (Measure.map (fun a => (X a, Y a)) μ)
⊢ ((∀ᵐ (a : β) ∂Measure.map X μ, Integrable fun ω => f (a, ω)) ∧
      Integrable fun a => ∫ (ω : Ω), ‖f (a, ω)‖ ∂(condDistrib Y X μ) a) ↔
    Integrable f

Next tactic:
rw [condDistrib, ← hf.ae_integrable_condKernel_iff, Measure.fst_map_prod_mk₀ hY]
theorem _root_.MeasureTheory.AEStronglyMeasurable.integral_condDistrib_map
    (hY : AEMeasurable Y μ) (hf : AEStronglyMeasurable f (μ.map fun a => (X a, Y a))) :
    AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂condDistrib Y X μ x) (μ.map X) := by
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁶ : MeasurableSpace Ω
inst✝⁵ : StandardBorelSpace Ω
inst✝⁴ : Nonempty Ω
inst✝³ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝² : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
inst✝¹ : NormedSpace ℝ F
inst✝ : CompleteSpace F
hY : AEMeasurable Y
hf : AEStronglyMeasurable f (Measure.map (fun a => (X a, Y a)) μ)
⊢ AEStronglyMeasurable (fun x => ∫ (y : Ω), f (x, y) ∂(condDistrib Y X μ) x) (Measure.map X μ)

Next tactic:
rw [← Measure.fst_map_prod_mk₀ hY, condDistrib]
theorem _root_.MeasureTheory.AEStronglyMeasurable.integral_condDistrib_map
    (hY : AEMeasurable Y μ) (hf : AEStronglyMeasurable f (μ.map fun a => (X a, Y a))) :
    AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂condDistrib Y X μ x) (μ.map X) := by
  rw [← Measure.fst_map_prod_mk₀ hY, condDistrib]; 

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁶ : MeasurableSpace Ω
inst✝⁵ : StandardBorelSpace Ω
inst✝⁴ : Nonempty Ω
inst✝³ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝² : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
inst✝¹ : NormedSpace ℝ F
inst✝ : CompleteSpace F
hY : AEMeasurable Y
hf : AEStronglyMeasurable f (Measure.map (fun a => (X a, Y a)) μ)
⊢ AEStronglyMeasurable (fun x => ∫ (y : Ω), f (x, y) ∂(Measure.condKernel (Measure.map (fun a => (X a, Y a)) μ)) x)
    (Measure.fst (Measure.map (fun a => (X a, Y a)) μ))

Next tactic:
exact hf.integral_condKernel
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
⊢ ∀ᵐ (x : β) ∂Measure.map X μ, κ x = (condDistrib Y X μ) x

Next tactic:
have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
  · 

Proof state:
case heq
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
⊢ Measure.map X μ = Measure.fst (Measure.map (fun x => (X x, Y x)) μ)

Next tactic:
ext s hs
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
  · ext s hs
    

Proof state:
case heq.h
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s✝ : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
s : Set β
hs : MeasurableSet s
⊢ ↑↑(Measure.map X μ) s = ↑↑(Measure.fst (Measure.map (fun x => (X x, Y x)) μ)) s

Next tactic:
rw [Measure.map_apply hX hs, Measure.fst_apply hs, Measure.map_apply]
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
  · ext s hs
    rw [Measure.map_apply hX hs, Measure.fst_apply hs, Measure.map_apply]
    

Proof state:
case heq.h
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s✝ : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
s : Set β
hs : MeasurableSet s
⊢ ↑↑μ (X ⁻¹' s) = ↑↑μ ((fun x => (X x, Y x)) ⁻¹' (Prod.fst ⁻¹' s))
case heq.h.hf
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s✝ : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
s : Set β
hs : MeasurableSet s
⊢ Measurable fun x => (X x, Y x)
case heq.h.hs
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s✝ : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
s : Set β
hs : MeasurableSet s
⊢ MeasurableSet (Prod.fst ⁻¹' s)

Next tactic:
exacts [rfl, Measurable.prod hX hY, measurable_fst hs]
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
  · ext s hs
    rw [Measure.map_apply hX hs, Measure.fst_apply hs, Measure.map_apply]
    exacts [rfl, Measurable.prod hX hY, measurable_fst hs]
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
heq : Measure.map X μ = Measure.fst (Measure.map (fun x => (X x, Y x)) μ)
⊢ ∀ᵐ (x : β) ∂Measure.map X μ, κ x = (condDistrib Y X μ) x

Next tactic:
rw [heq, condDistrib]
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
  · ext s hs
    rw [Measure.map_apply hX hs, Measure.fst_apply hs, Measure.map_apply]
    exacts [rfl, Measurable.prod hX hY, measurable_fst hs]
  rw [heq, condDistrib]
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
heq : Measure.map X μ = Measure.fst (Measure.map (fun x => (X x, Y x)) μ)
⊢ ∀ᵐ (x : β) ∂Measure.fst (Measure.map (fun x => (X x, Y x)) μ),
    κ x = (Measure.condKernel (Measure.map (fun a => (X a, Y a)) μ)) x

Next tactic:
refine' eq_condKernel_of_measure_eq_compProd _ _ _
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
  · ext s hs
    rw [Measure.map_apply hX hs, Measure.fst_apply hs, Measure.map_apply]
    exacts [rfl, Measurable.prod hX hY, measurable_fst hs]
  rw [heq, condDistrib]
  refine' eq_condKernel_of_measure_eq_compProd _ _ _
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
heq : Measure.map X μ = Measure.fst (Measure.map (fun x => (X x, Y x)) μ)
⊢ Measure.map (fun a => (X a, Y a)) μ = Measure.fst (Measure.map (fun a => (X a, Y a)) μ) ⊗ₘ κ

Next tactic:
convert hκ
/-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of
`condKernel`. -/
theorem condDistrib_ae_eq_of_measure_eq_compProd (hX : Measurable X) (hY : Measurable Y)
    (κ : kernel β Ω) [IsFiniteKernel κ] (hκ : μ.map (fun x => (X x, Y x)) = μ.map X ⊗ₘ κ) :
    ∀ᵐ x ∂μ.map X, κ x = condDistrib Y X μ x := by
  have heq : μ.map X = (μ.map (fun x => (X x, Y x))).fst
  · ext s hs
    rw [Measure.map_apply hX hs, Measure.fst_apply hs, Measure.map_apply]
    exacts [rfl, Measurable.prod hX hY, measurable_fst hs]
  rw [heq, condDistrib]
  refine' eq_condKernel_of_measure_eq_compProd _ _ _
  convert hκ
  

Proof state:
case h.e'_3.h.e'_5
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁵ : MeasurableSpace Ω
inst✝⁴ : StandardBorelSpace Ω
inst✝³ : Nonempty Ω
inst✝² : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : Measurable X
hY : Measurable Y
κ : ↥(kernel β Ω)
inst✝ : IsFiniteKernel κ
hκ : Measure.map (fun x => (X x, Y x)) μ = Measure.map X μ ⊗ₘ κ
heq : Measure.map X μ = Measure.fst (Measure.map (fun x => (X x, Y x)) μ)
⊢ Measure.fst (Measure.map (fun a => (X a, Y a)) μ) = Measure.map X μ

Next tactic:
exact heq.symm
theorem integrable_toReal_condDistrib (hX : AEMeasurable X μ) (hs : MeasurableSet s) :
    Integrable (fun a => (condDistrib Y X μ (X a) s).toReal) μ := by
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : AEMeasurable X
hs : MeasurableSet s
⊢ Integrable fun a => ENNReal.toReal (↑↑((condDistrib Y X μ) (X a)) s)

Next tactic:
refine' integrable_toReal_of_lintegral_ne_top _ _
theorem integrable_toReal_condDistrib (hX : AEMeasurable X μ) (hs : MeasurableSet s) :
    Integrable (fun a => (condDistrib Y X μ (X a) s).toReal) μ := by
  refine' integrable_toReal_of_lintegral_ne_top _ _
  · 

Proof state:
case refine'_1
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : AEMeasurable X
hs : MeasurableSet s
⊢ AEMeasurable fun a => ↑↑((condDistrib Y X μ) (X a)) s

Next tactic:
exact Measurable.comp_aemeasurable (kernel.measurable_coe _ hs) hX
theorem integrable_toReal_condDistrib (hX : AEMeasurable X μ) (hs : MeasurableSet s) :
    Integrable (fun a => (condDistrib Y X μ (X a) s).toReal) μ := by
  refine' integrable_toReal_of_lintegral_ne_top _ _
  · exact Measurable.comp_aemeasurable (kernel.measurable_coe _ hs) hX
  · 

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : AEMeasurable X
hs : MeasurableSet s
⊢ ∫⁻ (x : α), ↑↑((condDistrib Y X μ) (X x)) s ∂μ ≠ ⊤

Next tactic:
refine' ne_of_lt _
theorem integrable_toReal_condDistrib (hX : AEMeasurable X μ) (hs : MeasurableSet s) :
    Integrable (fun a => (condDistrib Y X μ (X a) s).toReal) μ := by
  refine' integrable_toReal_of_lintegral_ne_top _ _
  · exact Measurable.comp_aemeasurable (kernel.measurable_coe _ hs) hX
  · refine' ne_of_lt _
    

Proof state:
case refine'_2
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hX : AEMeasurable X
hs : MeasurableSet s
⊢ ∫⁻ (x : α), ↑↑((condDistrib Y X μ) (X x)) s ∂μ < ⊤

Next tactic:
calc
      ∫⁻ a, condDistrib Y X μ (X a) s ∂μ ≤ ∫⁻ _, 1 ∂μ := lintegral_mono fun a => prob_le_one
      _ = μ univ := lintegral_one
      _ < ∞ := measure_lt_top _ _
theorem _root_.MeasureTheory.Integrable.condDistrib_ae_map
    (hY : AEMeasurable Y μ) (hf_int : Integrable f (μ.map fun a => (X a, Y a))) :
    ∀ᵐ b ∂μ.map X, Integrable (fun ω => f (b, ω)) (condDistrib Y X μ b) := by
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hY : AEMeasurable Y
hf_int : Integrable f
⊢ ∀ᵐ (b : β) ∂Measure.map X μ, Integrable fun ω => f (b, ω)

Next tactic:
rw [condDistrib, ← Measure.fst_map_prod_mk₀ (X := X) hY]
theorem _root_.MeasureTheory.Integrable.condDistrib_ae_map
    (hY : AEMeasurable Y μ) (hf_int : Integrable f (μ.map fun a => (X a, Y a))) :
    ∀ᵐ b ∂μ.map X, Integrable (fun ω => f (b, ω)) (condDistrib Y X μ b) := by
  rw [condDistrib, ← Measure.fst_map_prod_mk₀ (X := X) hY]; 

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hY : AEMeasurable Y
hf_int : Integrable f
⊢ ∀ᵐ (b : β) ∂Measure.fst (Measure.map (fun a => (X a, Y a)) μ), Integrable fun ω => f (b, ω)

Next tactic:
exact hf_int.condKernel_ae
theorem _root_.MeasureTheory.Integrable.integral_norm_condDistrib_map
    (hY : AEMeasurable Y μ) (hf_int : Integrable f (μ.map fun a => (X a, Y a))) :
    Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂condDistrib Y X μ x) (μ.map X) := by
  

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hY : AEMeasurable Y
hf_int : Integrable f
⊢ Integrable fun x => ∫ (y : Ω), ‖f (x, y)‖ ∂(condDistrib Y X μ) x

Next tactic:
rw [condDistrib, ← Measure.fst_map_prod_mk₀ (X := X) hY]
theorem _root_.MeasureTheory.Integrable.integral_norm_condDistrib_map
    (hY : AEMeasurable Y μ) (hf_int : Integrable f (μ.map fun a => (X a, Y a))) :
    Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂condDistrib Y X μ x) (μ.map X) := by
  rw [condDistrib, ← Measure.fst_map_prod_mk₀ (X := X) hY]; 

Proof state:
α : Type u_1
β : Type u_2
Ω : Type u_3
F : Type u_4
inst✝⁴ : MeasurableSpace Ω
inst✝³ : StandardBorelSpace Ω
inst✝² : Nonempty Ω
inst✝¹ : NormedAddCommGroup F
mα : MeasurableSpace α
μ : Measure α
inst✝ : IsFiniteMeasure μ
X : α → β
Y : α → Ω
mβ : MeasurableSpace β
s : Set Ω
t : Set β
f : β × Ω → F
hY : AEMeasurable Y
hf_int : Integrable f
⊢ Integrable fun x => ∫ (y : Ω), ‖f (x, y)‖ ∂(Measure.condKernel (Measure.map (fun a => (X a, Y a)) μ)) x

Next tactic:
exact hf_int.integral_norm_condKernel