l3lab/ntp-mathlib huggingface dataset:
protected theorem congr {X Y : Ω → E} (hXY : X =ᵐ[ℙ] Y) : pdf X ℙ μ = pdf Y ℙ μ :=
  by 

Proof state:
Ω : Type u_1
E : Type u_2
inst✝ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X Y : Ω → E
hXY : X =ᶠ[ae ℙ] Y
⊢ pdf X ℙ = pdf Y ℙ

Next tactic:
rw [pdf_def, pdf_def, map_congr hXY]
theorem lintegral_eq_measure_univ {X : Ω → E} [HasPDF X ℙ μ] :
    ∫⁻ x, pdf X ℙ μ x ∂μ = ℙ Set.univ := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
inst✝ : HasPDF X ℙ
⊢ ∫⁻ (x : E), pdf X ℙ x ∂μ = ↑↑ℙ Set.univ

Next tactic:
rw [← set_lintegral_univ, ← map_eq_set_lintegral_pdf X ℙ μ MeasurableSet.univ,
    map_apply_of_aemeasurable (HasPDF.aemeasurable X ℙ μ) MeasurableSet.univ, Set.preimage_univ]
theorem eq_of_map_eq_withDensity [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] (f : E → ℝ≥0∞)
    (hmf : AEMeasurable f μ) : map X ℙ = μ.withDensity f ↔ pdf X ℙ μ =ᵐ[μ] f := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → ℝ≥0∞
hmf : AEMeasurable f
⊢ map X ℙ = withDensity μ f ↔ pdf X ℙ =ᶠ[ae μ] f

Next tactic:
rw [map_eq_withDensity_pdf X ℙ μ]
theorem eq_of_map_eq_withDensity [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] (f : E → ℝ≥0∞)
    (hmf : AEMeasurable f μ) : map X ℙ = μ.withDensity f ↔ pdf X ℙ μ =ᵐ[μ] f := by
  rw [map_eq_withDensity_pdf X ℙ μ]
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → ℝ≥0∞
hmf : AEMeasurable f
⊢ withDensity μ (pdf X ℙ) = withDensity μ f ↔ pdf X ℙ =ᶠ[ae μ] f

Next tactic:
apply withDensity_eq_iff (measurable_pdf X ℙ μ).aemeasurable hmf
theorem eq_of_map_eq_withDensity [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] (f : E → ℝ≥0∞)
    (hmf : AEMeasurable f μ) : map X ℙ = μ.withDensity f ↔ pdf X ℙ μ =ᵐ[μ] f := by
  rw [map_eq_withDensity_pdf X ℙ μ]
  apply withDensity_eq_iff (measurable_pdf X ℙ μ).aemeasurable hmf
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → ℝ≥0∞
hmf : AEMeasurable f
⊢ ∫⁻ (x : E), pdf X ℙ x ∂μ ≠ ⊤

Next tactic:
rw [lintegral_eq_measure_univ]
theorem eq_of_map_eq_withDensity [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] (f : E → ℝ≥0∞)
    (hmf : AEMeasurable f μ) : map X ℙ = μ.withDensity f ↔ pdf X ℙ μ =ᵐ[μ] f := by
  rw [map_eq_withDensity_pdf X ℙ μ]
  apply withDensity_eq_iff (measurable_pdf X ℙ μ).aemeasurable hmf
  rw [lintegral_eq_measure_univ]
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝² : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → ℝ≥0∞
hmf : AEMeasurable f
⊢ ↑↑ℙ Set.univ ≠ ⊤

Next tactic:
exact measure_ne_top _ _
/-- **The Law of the Unconscious Statistician** for nonnegative random variables. -/
theorem lintegral_pdf_mul {X : Ω → E} [HasPDF X ℙ μ] {f : E → ℝ≥0∞}
    (hf : AEMeasurable f μ) : ∫⁻ x, pdf X ℙ μ x * f x ∂μ = ∫⁻ x, f (X x) ∂ℙ := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝¹ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → ℝ≥0∞
hf : AEMeasurable f
⊢ ∫⁻ (x : E), pdf X ℙ x * f x ∂μ = ∫⁻ (x : Ω), f (X x) ∂ℙ

Next tactic:
rw [pdf_def,
    ← lintegral_map' (hf.mono_ac HasPDF.absolutelyContinuous) (HasPDF.aemeasurable X ℙ μ),
    lintegral_rnDeriv_mul HasPDF.absolutelyContinuous hf]
theorem integrable_pdf_smul_iff [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] {f : E → F}
    (hf : AEStronglyMeasurable f μ) :
    Integrable (fun x => (pdf X ℙ μ x).toReal • f x) μ ↔ Integrable (fun x => f (X x)) ℙ := by
  -- porting note: using `erw` because `rw` doesn't recognize `(f <| X ·)` as `f ∘ X`
  -- https://github.com/leanprover-community/mathlib4/issues/5164
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝⁵ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝⁴ : NormedAddCommGroup F
inst✝³ : NormedSpace ℝ F
inst✝² : CompleteSpace F
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → F
hf : AEStronglyMeasurable f μ
⊢ (Integrable fun x => ENNReal.toReal (pdf X ℙ x) • f x) ↔ Integrable fun x => f (X x)

Next tactic:
erw [← integrable_map_measure (hf.mono' HasPDF.absolutelyContinuous) (HasPDF.aemeasurable X ℙ μ),
    map_eq_withDensity_pdf X ℙ μ, pdf_def, integrable_rnDeriv_smul_iff HasPDF.absolutelyContinuous]
theorem integrable_pdf_smul_iff [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] {f : E → F}
    (hf : AEStronglyMeasurable f μ) :
    Integrable (fun x => (pdf X ℙ μ x).toReal • f x) μ ↔ Integrable (fun x => f (X x)) ℙ := by
  -- porting note: using `erw` because `rw` doesn't recognize `(f <| X ·)` as `f ∘ X`
  -- https://github.com/leanprover-community/mathlib4/issues/5164
  erw [← integrable_map_measure (hf.mono' HasPDF.absolutelyContinuous) (HasPDF.aemeasurable X ℙ μ),
    map_eq_withDensity_pdf X ℙ μ, pdf_def, integrable_rnDeriv_smul_iff HasPDF.absolutelyContinuous]
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝⁵ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝⁴ : NormedAddCommGroup F
inst✝³ : NormedSpace ℝ F
inst✝² : CompleteSpace F
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → F
hf : AEStronglyMeasurable f μ
⊢ (Integrable fun x => f x) ↔ Integrable f

Next tactic:
eta_reduce
theorem integrable_pdf_smul_iff [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] {f : E → F}
    (hf : AEStronglyMeasurable f μ) :
    Integrable (fun x => (pdf X ℙ μ x).toReal • f x) μ ↔ Integrable (fun x => f (X x)) ℙ := by
  -- porting note: using `erw` because `rw` doesn't recognize `(f <| X ·)` as `f ∘ X`
  -- https://github.com/leanprover-community/mathlib4/issues/5164
  erw [← integrable_map_measure (hf.mono' HasPDF.absolutelyContinuous) (HasPDF.aemeasurable X ℙ μ),
    map_eq_withDensity_pdf X ℙ μ, pdf_def, integrable_rnDeriv_smul_iff HasPDF.absolutelyContinuous]
  eta_reduce
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝⁵ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝⁴ : NormedAddCommGroup F
inst✝³ : NormedSpace ℝ F
inst✝² : CompleteSpace F
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → F
hf : AEStronglyMeasurable f μ
⊢ Integrable f ↔ Integrable f

Next tactic:
rw [withDensity_rnDeriv_eq _ _ HasPDF.absolutelyContinuous]
/-- **The Law of the Unconscious Statistician**: Given a random variable `X` and a measurable
function `f`, `f ∘ X` is a random variable with expectation `∫ x, pdf X x • f x ∂μ`
where `μ` is a measure on the codomain of `X`. -/
theorem integral_pdf_smul [IsFiniteMeasure ℙ] {X : Ω → E} [HasPDF X ℙ μ] {f : E → F}
    (hf : AEStronglyMeasurable f μ) : ∫ x, (pdf X ℙ μ x).toReal • f x ∂μ = ∫ x, f (X x) ∂ℙ := by
  

Proof state:
Ω : Type u_1
E : Type u_2
inst✝⁵ : MeasurableSpace E
m : MeasurableSpace Ω
ℙ : Measure Ω
μ : Measure E
F : Type u_3
inst✝⁴ : NormedAddCommGroup F
inst✝³ : NormedSpace ℝ F
inst✝² : CompleteSpace F
inst✝¹ : IsFiniteMeasure ℙ
X : Ω → E
inst✝ : HasPDF X ℙ
f : E → F
hf : AEStronglyMeasurable f μ
⊢ ∫ (x : E), ENNReal.toReal (pdf X ℙ x) • f x ∂μ = ∫ (x : Ω), f (X x) ∂ℙ

Next tactic:
rw [← integral_map (HasPDF.aemeasurable X ℙ μ) (hf.mono' HasPDF.absolutelyContinuous),
    map_eq_withDensity_pdf X ℙ μ, pdf_def, integral_rnDeriv_smul HasPDF.absolutelyContinuous,
    withDensity_rnDeriv_eq _ _ HasPDF.absolutelyContinuous]
/-- 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
  

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
X : Ω → E
inst✝ : HasPDF X ℙ
hX : AEMeasurable X
g : E → F
hg : QuasiMeasurePreserving g
hmap : HaveLebesgueDecomposition (map g (map X ℙ)) ν
⊢ HasPDF (g ∘ X) ℙ

Next tactic:
wlog hmX : Measurable X
/-- 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
  · 

Proof state:
case inr
Ω : 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 ℙ)) ν
this :
  ∀ {Ω : Type u_1} {E : Type u_2} [inst : MeasurableSpace E] {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E}
    {F : Type u_3} [inst_1 : MeasurableSpace F] {ν : Measure F} {X : Ω → E} [inst_2 : HasPDF X ℙ],
    AEMeasurable X →
      ∀ {g : E → F},
        QuasiMeasurePreserving g → HaveLebesgueDecomposition (map g (map X ℙ)) ν → Measurable X → HasPDF (g ∘ X) ℙ
hmX : ¬Measurable X
⊢ HasPDF (g ∘ X) ℙ

Next tactic:
have hae : g ∘ X =ᵐ[ℙ] g ∘ hX.mk := hX.ae_eq_mk.mono fun x h ↦ by dsimp; rw [h]
/-- 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 

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
X : Ω → E
inst✝ : HasPDF X ℙ
hX : AEMeasurable X
g : E → F
hg : QuasiMeasurePreserving g
hmap : HaveLebesgueDecomposition (map g (map X ℙ)) ν
this :
  ∀ {Ω : Type u_1} {E : Type u_2} [inst : MeasurableSpace E] {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E}
    {F : Type u_3} [inst_1 : MeasurableSpace F] {ν : Measure F} {X : Ω → E} [inst_2 : HasPDF X ℙ],
    AEMeasurable X →
      ∀ {g : E → F},
        QuasiMeasurePreserving g → HaveLebesgueDecomposition (map g (map X ℙ)) ν → Measurable X → HasPDF (g ∘ X) ℙ
hmX : ¬Measurable X
x : Ω
h : X x = AEMeasurable.mk X hX x
⊢ (g ∘ X) x = (g ∘ AEMeasurable.mk X hX) x

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

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
X : Ω → E
inst✝ : HasPDF X ℙ
hX : AEMeasurable X
g : E → F
hg : QuasiMeasurePreserving g
hmap : HaveLebesgueDecomposition (map g (map X ℙ)) ν
this :
  ∀ {Ω : Type u_1} {E : Type u_2} [inst : MeasurableSpace E] {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E}
    {F : Type u_3} [inst_1 : MeasurableSpace F] {ν : Measure F} {X : Ω → E} [inst_2 : HasPDF X ℙ],
    AEMeasurable X →
      ∀ {g : E → F},
        QuasiMeasurePreserving g → HaveLebesgueDecomposition (map g (map X ℙ)) ν → Measurable X → HasPDF (g ∘ X) ℙ
hmX : ¬Measurable X
x : Ω
h : X x = AEMeasurable.mk X hX x
⊢ g (X x) = g (AEMeasurable.mk X hX x)

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

Proof state:
case inr
Ω : 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 ℙ)) ν
this :
  ∀ {Ω : Type u_1} {E : Type u_2} [inst : MeasurableSpace E] {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E}
    {F : Type u_3} [inst_1 : MeasurableSpace F] {ν : Measure F} {X : Ω → E} [inst_2 : HasPDF X ℙ],
    AEMeasurable X →
      ∀ {g : E → F},
        QuasiMeasurePreserving g → HaveLebesgueDecomposition (map g (map X ℙ)) ν → Measurable X → HasPDF (g ∘ X) ℙ
hmX : ¬Measurable X
hae : g ∘ X =ᶠ[ae ℙ] g ∘ AEMeasurable.mk X hX
⊢ HasPDF (g ∘ X) ℙ

Next tactic:
have hXmk : HasPDF hX.mk ℙ μ := HasPDF.congr hX.ae_eq_mk
/-- 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
    

Proof state:
case inr
Ω : 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 ℙ)) ν
this :
  ∀ {Ω : Type u_1} {E : Type u_2} [inst : MeasurableSpace E] {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E}
    {F : Type u_3} [inst_1 : MeasurableSpace F] {ν : Measure F} {X : Ω → E} [inst_2 : HasPDF X ℙ],
    AEMeasurable X →
      ∀ {g : E → F},
        QuasiMeasurePreserving g → HaveLebesgueDecomposition (map g (map X ℙ)) ν → Measurable X → HasPDF (g ∘ X) ℙ
hmX : ¬Measurable X
hae : g ∘ X =ᶠ[ae ℙ] g ∘ AEMeasurable.mk X hX
hXmk : HasPDF (AEMeasurable.mk X hX) ℙ
⊢ HasPDF (g ∘ X) ℙ

Next tactic:
apply (HasPDF.congr' hae).mpr
/-- 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
    

Proof state:
case inr
Ω : 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 ℙ)) ν
this :
  ∀ {Ω : Type u_1} {E : Type u_2} [inst : MeasurableSpace E] {m : MeasurableSpace Ω} {ℙ : Measure Ω} {μ : Measure E}
    {F : Type u_3} [inst_1 : MeasurableSpace F] {ν : Measure F} {X : Ω → E} [inst_2 : HasPDF X ℙ],
    AEMeasurable X →
      ∀ {g : E → F},
        QuasiMeasurePreserving g → HaveLebesgueDecomposition (map g (map X ℙ)) ν → Measurable X → HasPDF (g ∘ X) ℙ
hmX : ¬Measurable X
hae : g ∘ X =ᶠ[ae ℙ] g ∘ AEMeasurable.mk X hX
hXmk : HasPDF (AEMeasurable.mk X hX) ℙ
⊢ HasPDF (g ∘ AEMeasurable.mk X hX) ℙ

Next tactic:
exact this hX.measurable_mk.aemeasurable hg (map_congr hX.ae_eq_mk ▸ hmap) hX.measurable_mk
/-- 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
  

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
⊢ HasPDF (g ∘ X) ℙ

Next tactic:
rw [hasPDF_iff, ← map_map hg.measurable hmX]
/-- 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]
  

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
⊢ AEMeasurable (g ∘ X) ∧ HaveLebesgueDecomposition (map g (map X ℙ)) ν ∧ map g (map X ℙ) ≪ ν

Next tactic:
refine' ⟨(hg.measurable.comp hmX).aemeasurable, hmap, _⟩
/-- 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, _⟩
  

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
⊢ map g (map X ℙ) ≪ ν

Next tactic:
rw [map_eq_withDensity_pdf X ℙ μ]
/-- 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 ℙ μ]
  

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
⊢ map g (withDensity μ (pdf X ℙ)) ≪ ν

Next tactic:
refine' AbsolutelyContinuous.mk fun s hsm hs => _