l3lab/ntp-mathlib huggingface dataset:
/-- A random variable that `HasPDF` transformed under a `QuasiMeasurePreserving`
map also `HasPDF` if `(map g (map X ℙ)).HaveLebesgueDecomposition μ`.

`quasiMeasurePreserving_hasPDF` is more useful in the case we are working with a
probability measure and a real-valued random variable. -/
theorem quasiMeasurePreserving_hasPDF {X : Ω → E} [HasPDF X ℙ μ] (hX : AEMeasurable X ℙ) {g : E → F}
    (hg : QuasiMeasurePreserving g μ ν) (hmap : (map g (map X ℙ)).HaveLebesgueDecomposition ν) :
    HasPDF (g ∘ X) ℙ ν := by
  wlog hmX : Measurable X
  · have hae : g ∘ X =ᵐ[ℙ] g ∘ hX.mk := hX.ae_eq_mk.mono fun x h ↦ by dsimp; rw [h]
    have hXmk : HasPDF hX.mk ℙ μ := HasPDF.congr hX.ae_eq_mk
    apply (HasPDF.congr' hae).mpr
    exact this hX.measurable_mk.aemeasurable hg (map_congr hX.ae_eq_mk ▸ hmap) hX.measurable_mk
  rw [hasPDF_iff, ← map_map hg.measurable hmX]
  refine' ⟨(hg.measurable.comp hmX).aemeasurable, hmap, _⟩
  rw [map_eq_withDensity_pdf X ℙ μ]
  refine' AbsolutelyContinuous.mk fun s hsm hs => _
  

Proof state:
Ω✝ : Type u_1
E✝ : Type u_2
inst✝⁴ : MeasurableSpace E✝
m✝ : MeasurableSpace Ω✝
ℙ✝ : Measure Ω✝
μ✝ : Measure E✝
F✝ : Type u_3
inst✝³ : MeasurableSpace F✝
ν✝ : Measure F✝
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝¹ : MeasurableSpace F
ν : Measure F
X : Ω → E
inst✝ : HasPDF X ℙ
hX : AEMeasurable X
g : E → F
hg : QuasiMeasurePreserving g
hmap : HaveLebesgueDecomposition (map g (map X ℙ)) ν
hmX : Measurable X
s : Set F
hsm : MeasurableSet s
hs : ↑↑ν s = 0
⊢ ↑↑(map g (withDensity μ (pdf X ℙ))) s = 0

Next tactic:
rw [map_apply hg.measurable hsm, withDensity_apply _ (hg.measurable hsm)]
/-- A random variable that `HasPDF` transformed under a `QuasiMeasurePreserving`
map also `HasPDF` if `(map g (map X ℙ)).HaveLebesgueDecomposition μ`.

`quasiMeasurePreserving_hasPDF` is more useful in the case we are working with a
probability measure and a real-valued random variable. -/
theorem quasiMeasurePreserving_hasPDF {X : Ω → E} [HasPDF X ℙ μ] (hX : AEMeasurable X ℙ) {g : E → F}
    (hg : QuasiMeasurePreserving g μ ν) (hmap : (map g (map X ℙ)).HaveLebesgueDecomposition ν) :
    HasPDF (g ∘ X) ℙ ν := by
  wlog hmX : Measurable X
  · have hae : g ∘ X =ᵐ[ℙ] g ∘ hX.mk := hX.ae_eq_mk.mono fun x h ↦ by dsimp; rw [h]
    have hXmk : HasPDF hX.mk ℙ μ := HasPDF.congr hX.ae_eq_mk
    apply (HasPDF.congr' hae).mpr
    exact this hX.measurable_mk.aemeasurable hg (map_congr hX.ae_eq_mk ▸ hmap) hX.measurable_mk
  rw [hasPDF_iff, ← map_map hg.measurable hmX]
  refine' ⟨(hg.measurable.comp hmX).aemeasurable, hmap, _⟩
  rw [map_eq_withDensity_pdf X ℙ μ]
  refine' AbsolutelyContinuous.mk fun s hsm hs => _
  rw [map_apply hg.measurable hsm, withDensity_apply _ (hg.measurable hsm)]
  

Proof state:
Ω✝ : Type u_1
E✝ : Type u_2
inst✝⁴ : MeasurableSpace E✝
m✝ : MeasurableSpace Ω✝
ℙ✝ : Measure Ω✝
μ✝ : Measure E✝
F✝ : Type u_3
inst✝³ : MeasurableSpace F✝
ν✝ : Measure F✝
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝¹ : MeasurableSpace F
ν : Measure F
X : Ω → E
inst✝ : HasPDF X ℙ
hX : AEMeasurable X
g : E → F
hg : QuasiMeasurePreserving g
hmap : HaveLebesgueDecomposition (map g (map X ℙ)) ν
hmX : Measurable X
s : Set F
hsm : MeasurableSet s
hs : ↑↑ν s = 0
⊢ ∫⁻ (a : E) in g ⁻¹' s, pdf X ℙ a ∂μ = 0

Next tactic:
have := hg.absolutelyContinuous hs
/-- A random variable that `HasPDF` transformed under a `QuasiMeasurePreserving`
map also `HasPDF` if `(map g (map X ℙ)).HaveLebesgueDecomposition μ`.

`quasiMeasurePreserving_hasPDF` is more useful in the case we are working with a
probability measure and a real-valued random variable. -/
theorem quasiMeasurePreserving_hasPDF {X : Ω → E} [HasPDF X ℙ μ] (hX : AEMeasurable X ℙ) {g : E → F}
    (hg : QuasiMeasurePreserving g μ ν) (hmap : (map g (map X ℙ)).HaveLebesgueDecomposition ν) :
    HasPDF (g ∘ X) ℙ ν := by
  wlog hmX : Measurable X
  · have hae : g ∘ X =ᵐ[ℙ] g ∘ hX.mk := hX.ae_eq_mk.mono fun x h ↦ by dsimp; rw [h]
    have hXmk : HasPDF hX.mk ℙ μ := HasPDF.congr hX.ae_eq_mk
    apply (HasPDF.congr' hae).mpr
    exact this hX.measurable_mk.aemeasurable hg (map_congr hX.ae_eq_mk ▸ hmap) hX.measurable_mk
  rw [hasPDF_iff, ← map_map hg.measurable hmX]
  refine' ⟨(hg.measurable.comp hmX).aemeasurable, hmap, _⟩
  rw [map_eq_withDensity_pdf X ℙ μ]
  refine' AbsolutelyContinuous.mk fun s hsm hs => _
  rw [map_apply hg.measurable hsm, withDensity_apply _ (hg.measurable hsm)]
  have := hg.absolutelyContinuous hs
  

Proof state:
Ω✝ : Type u_1
E✝ : Type u_2
inst✝⁴ : MeasurableSpace E✝
m✝ : MeasurableSpace Ω✝
ℙ✝ : Measure Ω✝
μ✝ : Measure E✝
F✝ : Type u_3
inst✝³ : MeasurableSpace F✝
ν✝ : Measure F✝
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝¹ : MeasurableSpace F
ν : Measure F
X : Ω → E
inst✝ : HasPDF X ℙ
hX : AEMeasurable X
g : E → F
hg : QuasiMeasurePreserving g
hmap : HaveLebesgueDecomposition (map g (map X ℙ)) ν
hmX : Measurable X
s : Set F
hsm : MeasurableSet s
hs : ↑↑ν s = 0
this : ↑↑(map g μ) s = 0
⊢ ∫⁻ (a : E) in g ⁻¹' s, pdf X ℙ a ∂μ = 0

Next tactic:
rw [map_apply hg.measurable hsm] at this
/-- A random variable that `HasPDF` transformed under a `QuasiMeasurePreserving`
map also `HasPDF` if `(map g (map X ℙ)).HaveLebesgueDecomposition μ`.

`quasiMeasurePreserving_hasPDF` is more useful in the case we are working with a
probability measure and a real-valued random variable. -/
theorem quasiMeasurePreserving_hasPDF {X : Ω → E} [HasPDF X ℙ μ] (hX : AEMeasurable X ℙ) {g : E → F}
    (hg : QuasiMeasurePreserving g μ ν) (hmap : (map g (map X ℙ)).HaveLebesgueDecomposition ν) :
    HasPDF (g ∘ X) ℙ ν := by
  wlog hmX : Measurable X
  · have hae : g ∘ X =ᵐ[ℙ] g ∘ hX.mk := hX.ae_eq_mk.mono fun x h ↦ by dsimp; rw [h]
    have hXmk : HasPDF hX.mk ℙ μ := HasPDF.congr hX.ae_eq_mk
    apply (HasPDF.congr' hae).mpr
    exact this hX.measurable_mk.aemeasurable hg (map_congr hX.ae_eq_mk ▸ hmap) hX.measurable_mk
  rw [hasPDF_iff, ← map_map hg.measurable hmX]
  refine' ⟨(hg.measurable.comp hmX).aemeasurable, hmap, _⟩
  rw [map_eq_withDensity_pdf X ℙ μ]
  refine' AbsolutelyContinuous.mk fun s hsm hs => _
  rw [map_apply hg.measurable hsm, withDensity_apply _ (hg.measurable hsm)]
  have := hg.absolutelyContinuous hs
  rw [map_apply hg.measurable hsm] at this
  

Proof state:
Ω✝ : Type u_1
E✝ : Type u_2
inst✝⁴ : MeasurableSpace E✝
m✝ : MeasurableSpace Ω✝
ℙ✝ : Measure Ω✝
μ✝ : Measure E✝
F✝ : Type u_3
inst✝³ : MeasurableSpace F✝
ν✝ : Measure F✝
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝¹ : MeasurableSpace F
ν : Measure F
X : Ω → E
inst✝ : HasPDF X ℙ
hX : AEMeasurable X
g : E → F
hg : QuasiMeasurePreserving g
hmap : HaveLebesgueDecomposition (map g (map X ℙ)) ν
hmX : Measurable X
s : Set F
hsm : MeasurableSet s
hs : ↑↑ν s = 0
this : ↑↑μ (g ⁻¹' s) = 0
⊢ ∫⁻ (a : E) in g ⁻¹' s, pdf X ℙ a ∂μ = 0

Next tactic:
exact set_lintegral_measure_zero _ _ this
/-- A real-valued random variable `X` `HasPDF X ℙ λ` (where `λ` is the Lebesgue measure) if and
only if the push-forward measure of `ℙ` along `X` is absolutely continuous with respect to `λ`. -/
nonrec theorem _root_.Real.hasPDF_iff_of_aemeasurable (hX : AEMeasurable X ℙ) :
    HasPDF X ℙ ↔ map X ℙ ≪ volume := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
hX : AEMeasurable X
⊢ HasPDF X ℙ ↔ map X ℙ ≪ volume

Next tactic:
rw [hasPDF_iff_of_aemeasurable hX]
/-- A real-valued random variable `X` `HasPDF X ℙ λ` (where `λ` is the Lebesgue measure) if and
only if the push-forward measure of `ℙ` along `X` is absolutely continuous with respect to `λ`. -/
nonrec theorem _root_.Real.hasPDF_iff_of_aemeasurable (hX : AEMeasurable X ℙ) :
    HasPDF X ℙ ↔ map X ℙ ≪ volume := by
  rw [hasPDF_iff_of_aemeasurable hX]
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
hX : AEMeasurable X
⊢ HaveLebesgueDecomposition (map X ℙ) volume ∧ map X ℙ ≪ volume ↔ map X ℙ ≪ volume

Next tactic:
exact and_iff_right inferInstance
theorem _root_.Real.hasPDF_iff : HasPDF X ℙ ↔ AEMeasurable X ℙ ∧ map X ℙ ≪ volume := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
⊢ HasPDF X ℙ ↔ AEMeasurable X ∧ map X ℙ ≪ volume

Next tactic:
by_cases hX : AEMeasurable X ℙ
theorem _root_.Real.hasPDF_iff : HasPDF X ℙ ↔ AEMeasurable X ℙ ∧ map X ℙ ≪ volume := by
  by_cases hX : AEMeasurable X ℙ
  · 

Proof state:
case pos
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
hX : AEMeasurable X
⊢ HasPDF X ℙ ↔ AEMeasurable X ∧ map X ℙ ≪ volume

Next tactic:
rw [Real.hasPDF_iff_of_aemeasurable hX, iff_and_self]
theorem _root_.Real.hasPDF_iff : HasPDF X ℙ ↔ AEMeasurable X ℙ ∧ map X ℙ ≪ volume := by
  by_cases hX : AEMeasurable X ℙ
  · rw [Real.hasPDF_iff_of_aemeasurable hX, iff_and_self]
    

Proof state:
case pos
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
hX : AEMeasurable X
⊢ map X ℙ ≪ volume → AEMeasurable X

Next tactic:
exact fun _ => hX
theorem _root_.Real.hasPDF_iff : HasPDF X ℙ ↔ AEMeasurable X ℙ ∧ map X ℙ ≪ volume := by
  by_cases hX : AEMeasurable X ℙ
  · rw [Real.hasPDF_iff_of_aemeasurable hX, iff_and_self]
    exact fun _ => hX
  · 

Proof state:
case neg
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
hX : ¬AEMeasurable X
⊢ HasPDF X ℙ ↔ AEMeasurable X ∧ map X ℙ ≪ volume

Next tactic:
exact ⟨fun h => False.elim (hX h.pdf'.1), fun h => False.elim (hX h.1)⟩
/-- If `X` is a real-valued random variable that has pdf `f`, then the expectation of `X` equals
`∫ x, x * f x ∂λ` where `λ` is the Lebesgue measure. -/
theorem integral_mul_eq_integral [HasPDF X ℙ] : ∫ x, x * (pdf X ℙ volume x).toReal = ∫ x, X x ∂ℙ :=
  calc
    _ = ∫ x, (pdf X ℙ volume x).toReal * x := by 

Proof state:
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → ℝ
inst✝ : HasPDF X ℙ
⊢ ∫ (x : ℝ), x * ENNReal.toReal (pdf X ℙ x) = ∫ (x : ℝ), ENNReal.toReal (pdf X ℙ x) * x

Next tactic:
congr with x
/-- If `X` is a real-valued random variable that has pdf `f`, then the expectation of `X` equals
`∫ x, x * f x ∂λ` where `λ` is the Lebesgue measure. -/
theorem integral_mul_eq_integral [HasPDF X ℙ] : ∫ x, x * (pdf X ℙ volume x).toReal = ∫ x, X x ∂ℙ :=
  calc
    _ = ∫ x, (pdf X ℙ volume x).toReal * x := by congr with x; 

Proof state:
case e_f.h
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → ℝ
inst✝ : HasPDF X ℙ
x : ℝ
⊢ x * ENNReal.toReal (pdf X ℙ x) = ENNReal.toReal (pdf X ℙ x) * x

Next tactic:
exact mul_comm _ _
theorem hasFiniteIntegral_mul {f : ℝ → ℝ} {g : ℝ → ℝ≥0∞} (hg : pdf X ℙ =ᵐ[volume] g)
    (hgi : ∫⁻ x, ‖f x‖₊ * g x ≠ ∞) :
    HasFiniteIntegral fun x => f x * (pdf X ℙ volume x).toReal := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
f : ℝ → ℝ
g : ℝ → ℝ≥0∞
hg : pdf X ℙ =ᶠ[ae volume] g
hgi : ∫⁻ (x : ℝ), ↑‖f x‖₊ * g x ≠ ⊤
⊢ HasFiniteIntegral fun x => f x * ENNReal.toReal (pdf X ℙ x)

Next tactic:
rw [HasFiniteIntegral]
theorem hasFiniteIntegral_mul {f : ℝ → ℝ} {g : ℝ → ℝ≥0∞} (hg : pdf X ℙ =ᵐ[volume] g)
    (hgi : ∫⁻ x, ‖f x‖₊ * g x ≠ ∞) :
    HasFiniteIntegral fun x => f x * (pdf X ℙ volume x).toReal := by
  rw [HasFiniteIntegral]
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
f : ℝ → ℝ
g : ℝ → ℝ≥0∞
hg : pdf X ℙ =ᶠ[ae volume] g
hgi : ∫⁻ (x : ℝ), ↑‖f x‖₊ * g x ≠ ⊤
⊢ ∫⁻ (a : ℝ), ↑‖f a * ENNReal.toReal (pdf X ℙ a)‖₊ < ⊤

Next tactic:
have : (fun x => ↑‖f x‖₊ * g x) =ᵐ[volume] fun x => ‖f x * (pdf X ℙ volume x).toReal‖₊ := by
    refine' ae_eq_trans (Filter.EventuallyEq.mul (ae_eq_refl fun x => (‖f x‖₊ : ℝ≥0∞))
      (ae_eq_trans hg.symm ofReal_toReal_ae_eq.symm)) _
    simp_rw [← smul_eq_mul, nnnorm_smul, ENNReal.coe_mul, smul_eq_mul]
    refine' Filter.EventuallyEq.mul (ae_eq_refl _) _
    simp only [Real.ennnorm_eq_ofReal ENNReal.toReal_nonneg, ae_eq_refl]
theorem hasFiniteIntegral_mul {f : ℝ → ℝ} {g : ℝ → ℝ≥0∞} (hg : pdf X ℙ =ᵐ[volume] g)
    (hgi : ∫⁻ x, ‖f x‖₊ * g x ≠ ∞) :
    HasFiniteIntegral fun x => f x * (pdf X ℙ volume x).toReal := by
  rw [HasFiniteIntegral]
  have : (fun x => ↑‖f x‖₊ * g x) =ᵐ[volume] fun x => ‖f x * (pdf X ℙ volume x).toReal‖₊ := by
    

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
f : ℝ → ℝ
g : ℝ → ℝ≥0∞
hg : pdf X ℙ =ᶠ[ae volume] g
hgi : ∫⁻ (x : ℝ), ↑‖f x‖₊ * g x ≠ ⊤
⊢ (fun x => ↑‖f x‖₊ * g x) =ᶠ[ae volume] fun x => ↑‖f x * ENNReal.toReal (pdf X ℙ x)‖₊

Next tactic:
refine' ae_eq_trans (Filter.EventuallyEq.mul (ae_eq_refl fun x => (‖f x‖₊ : ℝ≥0∞))
      (ae_eq_trans hg.symm ofReal_toReal_ae_eq.symm)) _
theorem hasFiniteIntegral_mul {f : ℝ → ℝ} {g : ℝ → ℝ≥0∞} (hg : pdf X ℙ =ᵐ[volume] g)
    (hgi : ∫⁻ x, ‖f x‖₊ * g x ≠ ∞) :
    HasFiniteIntegral fun x => f x * (pdf X ℙ volume x).toReal := by
  rw [HasFiniteIntegral]
  have : (fun x => ↑‖f x‖₊ * g x) =ᵐ[volume] fun x => ‖f x * (pdf X ℙ volume x).toReal‖₊ := by
    refine' ae_eq_trans (Filter.EventuallyEq.mul (ae_eq_refl fun x => (‖f x‖₊ : ℝ≥0∞))
      (ae_eq_trans hg.symm ofReal_toReal_ae_eq.symm)) _
    

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
f : ℝ → ℝ
g : ℝ → ℝ≥0∞
hg : pdf X ℙ =ᶠ[ae volume] g
hgi : ∫⁻ (x : ℝ), ↑‖f x‖₊ * g x ≠ ⊤
⊢ (fun x => ↑‖f x‖₊ * ENNReal.ofReal (ENNReal.toReal (pdf X ℙ x))) =ᶠ[ae volume] fun x =>
    ↑‖f x * ENNReal.toReal (pdf X ℙ x)‖₊

Next tactic:
simp_rw [← smul_eq_mul, nnnorm_smul, ENNReal.coe_mul, smul_eq_mul]
theorem hasFiniteIntegral_mul {f : ℝ → ℝ} {g : ℝ → ℝ≥0∞} (hg : pdf X ℙ =ᵐ[volume] g)
    (hgi : ∫⁻ x, ‖f x‖₊ * g x ≠ ∞) :
    HasFiniteIntegral fun x => f x * (pdf X ℙ volume x).toReal := by
  rw [HasFiniteIntegral]
  have : (fun x => ↑‖f x‖₊ * g x) =ᵐ[volume] fun x => ‖f x * (pdf X ℙ volume x).toReal‖₊ := by
    refine' ae_eq_trans (Filter.EventuallyEq.mul (ae_eq_refl fun x => (‖f x‖₊ : ℝ≥0∞))
      (ae_eq_trans hg.symm ofReal_toReal_ae_eq.symm)) _
    simp_rw [← smul_eq_mul, nnnorm_smul, ENNReal.coe_mul, smul_eq_mul]
    

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
f : ℝ → ℝ
g : ℝ → ℝ≥0∞
hg : pdf X ℙ =ᶠ[ae volume] g
hgi : ∫⁻ (x : ℝ), ↑‖f x‖₊ * g x ≠ ⊤
⊢ (fun x => ↑‖f x‖₊ * ENNReal.ofReal (ENNReal.toReal (pdf X ℙ x))) =ᶠ[ae volume] fun x =>
    ↑‖f x‖₊ * ↑‖ENNReal.toReal (pdf X ℙ x)‖₊

Next tactic:
refine' Filter.EventuallyEq.mul (ae_eq_refl _) _
theorem hasFiniteIntegral_mul {f : ℝ → ℝ} {g : ℝ → ℝ≥0∞} (hg : pdf X ℙ =ᵐ[volume] g)
    (hgi : ∫⁻ x, ‖f x‖₊ * g x ≠ ∞) :
    HasFiniteIntegral fun x => f x * (pdf X ℙ volume x).toReal := by
  rw [HasFiniteIntegral]
  have : (fun x => ↑‖f x‖₊ * g x) =ᵐ[volume] fun x => ‖f x * (pdf X ℙ volume x).toReal‖₊ := by
    refine' ae_eq_trans (Filter.EventuallyEq.mul (ae_eq_refl fun x => (‖f x‖₊ : ℝ≥0∞))
      (ae_eq_trans hg.symm ofReal_toReal_ae_eq.symm)) _
    simp_rw [← smul_eq_mul, nnnorm_smul, ENNReal.coe_mul, smul_eq_mul]
    refine' Filter.EventuallyEq.mul (ae_eq_refl _) _
    

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
f : ℝ → ℝ
g : ℝ → ℝ≥0∞
hg : pdf X ℙ =ᶠ[ae volume] g
hgi : ∫⁻ (x : ℝ), ↑‖f x‖₊ * g x ≠ ⊤
⊢ (fun x => ENNReal.ofReal (ENNReal.toReal (pdf X ℙ x))) =ᶠ[ae volume] fun x => ↑‖ENNReal.toReal (pdf X ℙ x)‖₊

Next tactic:
simp only [Real.ennnorm_eq_ofReal ENNReal.toReal_nonneg, ae_eq_refl]
theorem hasFiniteIntegral_mul {f : ℝ → ℝ} {g : ℝ → ℝ≥0∞} (hg : pdf X ℙ =ᵐ[volume] g)
    (hgi : ∫⁻ x, ‖f x‖₊ * g x ≠ ∞) :
    HasFiniteIntegral fun x => f x * (pdf X ℙ volume x).toReal := by
  rw [HasFiniteIntegral]
  have : (fun x => ↑‖f x‖₊ * g x) =ᵐ[volume] fun x => ‖f x * (pdf X ℙ volume x).toReal‖₊ := by
    refine' ae_eq_trans (Filter.EventuallyEq.mul (ae_eq_refl fun x => (‖f x‖₊ : ℝ≥0∞))
      (ae_eq_trans hg.symm ofReal_toReal_ae_eq.symm)) _
    simp_rw [← smul_eq_mul, nnnorm_smul, ENNReal.coe_mul, smul_eq_mul]
    refine' Filter.EventuallyEq.mul (ae_eq_refl _) _
    simp only [Real.ennnorm_eq_ofReal ENNReal.toReal_nonneg, ae_eq_refl]
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝ : IsFiniteMeasure ℙ
X : Ω → ℝ
f : ℝ → ℝ
g : ℝ → ℝ≥0∞
hg : pdf X ℙ =ᶠ[ae volume] g
hgi : ∫⁻ (x : ℝ), ↑‖f x‖₊ * g x ≠ ⊤
this : (fun x => ↑‖f x‖₊ * g x) =ᶠ[ae volume] fun x => ↑‖f x * ENNReal.toReal (pdf X ℙ x)‖₊
⊢ ∫⁻ (a : ℝ), ↑‖f a * ENNReal.toReal (pdf X ℙ a)‖₊ < ⊤

Next tactic:
rwa [lt_top_iff_ne_top, ← lintegral_congr_ae this]
theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : IsUniform X s ℙ
⊢ AEMeasurable X

Next tactic:
dsimp [IsUniform] at hu
theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by
  dsimp [IsUniform] at hu
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : map X ℙ = (↑↑μ s)⁻¹ • restrict μ s
⊢ AEMeasurable X

Next tactic:
by_contra h
theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by
  dsimp [IsUniform] at hu
  by_contra h
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : map X ℙ = (↑↑μ s)⁻¹ • restrict μ s
h : ¬AEMeasurable X
⊢ False

Next tactic:
rw [map_of_not_aemeasurable h] at hu
theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by
  dsimp [IsUniform] at hu
  by_contra h
  rw [map_of_not_aemeasurable h] at hu
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : 0 = (↑↑μ s)⁻¹ • restrict μ s
h : ¬AEMeasurable X
⊢ False

Next tactic:
apply zero_ne_one' ℝ≥0∞
theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by
  dsimp [IsUniform] at hu
  by_contra h
  rw [map_of_not_aemeasurable h] at hu
  apply zero_ne_one' ℝ≥0∞
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : 0 = (↑↑μ s)⁻¹ • restrict μ s
h : ¬AEMeasurable X
⊢ 0 = 1

Next tactic:
calc
    0 = (0 : Measure E) Set.univ := rfl
    _ = _ := by rw [hu, smul_apply, restrict_apply MeasurableSet.univ,
      Set.univ_inter, smul_eq_mul, ENNReal.inv_mul_cancel hns hnt]
theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ := by
  dsimp [IsUniform] at hu
  by_contra h
  rw [map_of_not_aemeasurable h] at hu
  apply zero_ne_one' ℝ≥0∞
  calc
    0 = (0 : Measure E) Set.univ := rfl
    _ = _ := by 

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : 0 = (↑↑μ s)⁻¹ • restrict μ s
h : ¬AEMeasurable X
⊢ ↑↑0 Set.univ = 1

Next tactic:
rw [hu, smul_apply, restrict_apply MeasurableSet.univ,
      Set.univ_inter, smul_eq_mul, ENNReal.inv_mul_cancel hns hnt]
theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hu : IsUniform X s ℙ
⊢ map X ℙ ≪ μ

Next tactic:
intro t ht
theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ := by
  intro t ht
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hu : IsUniform X s ℙ
t : Set E
ht : ↑↑μ t = 0
⊢ ↑↑(map X ℙ) t = 0

Next tactic:
rw [hu, smul_apply, smul_eq_mul]
theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ := by
  intro t ht
  rw [hu, smul_apply, smul_eq_mul]
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hu : IsUniform X s ℙ
t : Set E
ht : ↑↑μ t = 0
⊢ (↑↑μ s)⁻¹ * ↑↑(restrict μ s) t = 0

Next tactic:
apply mul_eq_zero.mpr
theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ := by
  intro t ht
  rw [hu, smul_apply, smul_eq_mul]
  apply mul_eq_zero.mpr
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hu : IsUniform X s ℙ
t : Set E
ht : ↑↑μ t = 0
⊢ (↑↑μ s)⁻¹ = 0 ∨ ↑↑(restrict μ s) t = 0

Next tactic:
refine Or.inr (le_antisymm ?_ (zero_le _))
theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ := by
  intro t ht
  rw [hu, smul_apply, smul_eq_mul]
  apply mul_eq_zero.mpr
  refine Or.inr (le_antisymm ?_ (zero_le _))
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hu : IsUniform X s ℙ
t : Set E
ht : ↑↑μ t = 0
⊢ ↑↑(restrict μ s) t ≤ 0

Next tactic:
exact ht ▸ restrict_apply_le s t
theorem measure_preimage {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) {A : Set E} (hA : MeasurableSet A) :
    ℙ (X ⁻¹' A) = μ (s ∩ A) / μ s := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : IsUniform X s ℙ
A : Set E
hA : MeasurableSet A
⊢ ↑↑ℙ (X ⁻¹' A) = ↑↑μ (s ∩ A) / ↑↑μ s

Next tactic:
rw [← map_apply_of_aemeasurable (hu.aemeasurable hns hnt) hA, hu, smul_apply, restrict_apply hA,
    ENNReal.div_eq_inv_mul, smul_eq_mul, Set.inter_comm]
theorem isProbabilityMeasure {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : IsProbabilityMeasure ℙ :=
  ⟨by
    

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : IsUniform X s ℙ
⊢ ↑↑ℙ Set.univ = 1

Next tactic:
have : X ⁻¹' Set.univ = Set.univ := by simp only [Set.preimage_univ]
theorem isProbabilityMeasure {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : IsProbabilityMeasure ℙ :=
  ⟨by
    have : X ⁻¹' Set.univ = Set.univ := by 

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
s : Set E
hns : ↑↑μ s ≠ 0
hnt : ↑↑μ s ≠ ⊤
hu : IsUniform X s ℙ
⊢ X ⁻¹' Set.univ = Set.univ

Next tactic:
simp only [Set.preimage_univ]