l3lab/ntp-mathlib huggingface dataset:
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
this : singularPart μ ν = 0
⊢ withDensity ν (rnDeriv μ ν) = μ

Next tactic:
conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => 

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
this : singularPart μ ν = 0
| μ

Next tactic:
rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
⊢ singularPart μ ν = 0

Next tactic:
suffices μ.singularPart ν Set.univ = 0 by simpa using this
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by 

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
this : ↑↑(singularPart μ ν) Set.univ = 0
⊢ singularPart μ ν = 0

Next tactic:
simpa using this
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by simpa using this
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
⊢ ↑↑(singularPart μ ν) Set.univ = 0

Next tactic:
have h_sing := mutuallySingular_singularPart μ ν
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by simpa using this
  have h_sing := mutuallySingular_singularPart μ ν
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
h_sing : singularPart μ ν ⟂ₘ ν
⊢ ↑↑(singularPart μ ν) Set.univ = 0

Next tactic:
rw [← measure_add_measure_compl h_sing.measurableSet_nullSet]
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by simpa using this
  have h_sing := mutuallySingular_singularPart μ ν
  rw [← measure_add_measure_compl h_sing.measurableSet_nullSet]
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
h_sing : singularPart μ ν ⟂ₘ ν
⊢ ↑↑(singularPart μ ν) (MutuallySingular.nullSet h_sing) + ↑↑(singularPart μ ν) (MutuallySingular.nullSet h_sing)ᶜ = 0

Next tactic:
simp only [MutuallySingular.measure_nullSet, zero_add]
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by simpa using this
  have h_sing := mutuallySingular_singularPart μ ν
  rw [← measure_add_measure_compl h_sing.measurableSet_nullSet]
  simp only [MutuallySingular.measure_nullSet, zero_add]
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
h_sing : singularPart μ ν ⟂ₘ ν
⊢ ↑↑(singularPart μ ν) (MutuallySingular.nullSet h_sing)ᶜ = 0

Next tactic:
refine le_antisymm ?_ (zero_le _)
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by simpa using this
  have h_sing := mutuallySingular_singularPart μ ν
  rw [← measure_add_measure_compl h_sing.measurableSet_nullSet]
  simp only [MutuallySingular.measure_nullSet, zero_add]
  refine le_antisymm ?_ (zero_le _)
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
h_sing : singularPart μ ν ⟂ₘ ν
⊢ ↑↑(singularPart μ ν) (MutuallySingular.nullSet h_sing)ᶜ ≤ 0

Next tactic:
refine (singularPart_le μ ν ?_ ?_).trans_eq ?_
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by simpa using this
  have h_sing := mutuallySingular_singularPart μ ν
  rw [← measure_add_measure_compl h_sing.measurableSet_nullSet]
  simp only [MutuallySingular.measure_nullSet, zero_add]
  refine le_antisymm ?_ (zero_le _)
  refine (singularPart_le μ ν ?_ ?_).trans_eq ?_
  · 

Proof state:
case refine_1
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
h_sing : singularPart μ ν ⟂ₘ ν
⊢ MeasurableSet (MutuallySingular.nullSet h_sing)ᶜ

Next tactic:
exact h_sing.measurableSet_nullSet.compl
theorem withDensity_rnDeriv_eq (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (h : μ ≪ ν) :
    ν.withDensity (rnDeriv μ ν) = μ := by
  suffices μ.singularPart ν = 0 by
    conv_rhs => rw [haveLebesgueDecomposition_add μ ν, this, zero_add]
  suffices μ.singularPart ν Set.univ = 0 by simpa using this
  have h_sing := mutuallySingular_singularPart μ ν
  rw [← measure_add_measure_compl h_sing.measurableSet_nullSet]
  simp only [MutuallySingular.measure_nullSet, zero_add]
  refine le_antisymm ?_ (zero_le _)
  refine (singularPart_le μ ν ?_ ?_).trans_eq ?_
  · exact h_sing.measurableSet_nullSet.compl
  · 

Proof state:
case refine_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
h : μ ≪ ν
h_sing : singularPart μ ν ⟂ₘ ν
⊢ ↑↑μ (MutuallySingular.nullSet h_sing)ᶜ = 0

Next tactic:
exact h h_sing.measure_compl_nullSet
lemma rnDeriv_pos [HaveLebesgueDecomposition μ ν] (hμν : μ ≪ ν) :
    ∀ᵐ x ∂μ, 0 < μ.rnDeriv ν x := by
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
hμν : μ ≪ ν
⊢ ∀ᵐ (x : α) ∂μ, 0 < rnDeriv μ ν x

Next tactic:
rw [← Measure.withDensity_rnDeriv_eq _ _  hμν,
    ae_withDensity_iff (Measure.measurable_rnDeriv _ _), Measure.withDensity_rnDeriv_eq _ _  hμν]
lemma rnDeriv_pos [HaveLebesgueDecomposition μ ν] (hμν : μ ≪ ν) :
    ∀ᵐ x ∂μ, 0 < μ.rnDeriv ν x := by
  rw [← Measure.withDensity_rnDeriv_eq _ _  hμν,
    ae_withDensity_iff (Measure.measurable_rnDeriv _ _), Measure.withDensity_rnDeriv_eq _ _  hμν]
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝ : HaveLebesgueDecomposition μ ν
hμν : μ ≪ ν
⊢ ∀ᵐ (x : α) ∂ν, rnDeriv μ ν x ≠ 0 → 0 < rnDeriv μ ν x

Next tactic:
exact ae_of_all _ (fun x hx ↦ lt_of_le_of_ne (zero_le _) hx.symm)
lemma rnDeriv_pos' [SigmaFinite μ] [SigmaFinite ν] (hμν : μ ≪ ν) :
    ∀ᵐ x ∂μ, 0 < ν.rnDeriv μ x := by
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hμν : μ ≪ ν
⊢ ∀ᵐ (x : α) ∂μ, 0 < rnDeriv ν μ x

Next tactic:
refine (absolutelyContinuous_withDensity_rnDeriv hμν).ae_le ?_
lemma rnDeriv_pos' [SigmaFinite μ] [SigmaFinite ν] (hμν : μ ≪ ν) :
    ∀ᵐ x ∂μ, 0 < ν.rnDeriv μ x := by
  refine (absolutelyContinuous_withDensity_rnDeriv hμν).ae_le ?_
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hμν : μ ≪ ν
⊢ {x | (fun x => 0 < rnDeriv ν μ x) x} ∈ ae (withDensity μ (rnDeriv ν μ))

Next tactic:
filter_upwards [Measure.rnDeriv_pos (withDensity_absolutelyContinuous μ (ν.rnDeriv μ)),
    (withDensity_absolutelyContinuous μ (ν.rnDeriv μ)).ae_le
    (Measure.rnDeriv_withDensity μ (Measure.measurable_rnDeriv ν μ))] with x hx hx2
lemma rnDeriv_pos' [SigmaFinite μ] [SigmaFinite ν] (hμν : μ ≪ ν) :
    ∀ᵐ x ∂μ, 0 < ν.rnDeriv μ x := by
  refine (absolutelyContinuous_withDensity_rnDeriv hμν).ae_le ?_
  filter_upwards [Measure.rnDeriv_pos (withDensity_absolutelyContinuous μ (ν.rnDeriv μ)),
    (withDensity_absolutelyContinuous μ (ν.rnDeriv μ)).ae_le
    (Measure.rnDeriv_withDensity μ (Measure.measurable_rnDeriv ν μ))] with x hx hx2
  

Proof state:
case h
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hμν : μ ≪ ν
x : α
hx : 0 < rnDeriv (withDensity μ (rnDeriv ν μ)) μ x
hx2 : rnDeriv (withDensity μ (rnDeriv ν μ)) μ x = rnDeriv ν μ x
⊢ 0 < rnDeriv ν μ x

Next tactic:
rwa [← hx2]
/-- Auxiliary lemma for `rnDeriv_withDensity_left`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_left (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν]
    (hf : AEMeasurable f μ) (hf_ne_top : ∀ᵐ x ∂μ, f x ≠ ∞) :
    ((ν.withDensity (μ.rnDeriv ν)).withDensity f).rnDeriv ν =ᵐ[ν] (μ.withDensity f).rnDeriv ν := by
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_top : ∀ᵐ (x : α) ∂μ, f x ≠ ⊤
⊢ rnDeriv (withDensity (withDensity ν (rnDeriv μ ν)) f) ν =ᶠ[ae ν] rnDeriv (withDensity μ f) ν

Next tactic:
conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm, withDensity_add_measure]
/-- Auxiliary lemma for `rnDeriv_withDensity_left`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_left (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν]
    (hf : AEMeasurable f μ) (hf_ne_top : ∀ᵐ x ∂μ, f x ≠ ∞) :
    ((ν.withDensity (μ.rnDeriv ν)).withDensity f).rnDeriv ν =ᵐ[ν] (μ.withDensity f).rnDeriv ν := by
  conv_rhs => 

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_top : ∀ᵐ (x : α) ∂μ, f x ≠ ⊤
| rnDeriv (withDensity μ f) ν

Next tactic:
rw [μ.haveLebesgueDecomposition_add ν, add_comm, withDensity_add_measure]
/-- Auxiliary lemma for `rnDeriv_withDensity_left`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_left (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν]
    (hf : AEMeasurable f μ) (hf_ne_top : ∀ᵐ x ∂μ, f x ≠ ∞) :
    ((ν.withDensity (μ.rnDeriv ν)).withDensity f).rnDeriv ν =ᵐ[ν] (μ.withDensity f).rnDeriv ν := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm, withDensity_add_measure]
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_top : ∀ᵐ (x : α) ∂μ, f x ≠ ⊤
⊢ rnDeriv (withDensity (withDensity ν (rnDeriv μ ν)) f) ν =ᶠ[ae ν]
    rnDeriv (withDensity (withDensity ν (rnDeriv μ ν)) f + withDensity (singularPart μ ν) f) ν

Next tactic:
have : SigmaFinite ((μ.singularPart ν).withDensity f) :=
    SigmaFinite.withDensity_of_ne_top (hf.singularPart ν)
      ((Measure.absolutelyContinuous_of_le (Measure.singularPart_le _ _)).ae_le hf_ne_top)
/-- Auxiliary lemma for `rnDeriv_withDensity_left`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_left (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν]
    (hf : AEMeasurable f μ) (hf_ne_top : ∀ᵐ x ∂μ, f x ≠ ∞) :
    ((ν.withDensity (μ.rnDeriv ν)).withDensity f).rnDeriv ν =ᵐ[ν] (μ.withDensity f).rnDeriv ν := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm, withDensity_add_measure]
  have : SigmaFinite ((μ.singularPart ν).withDensity f) :=
    SigmaFinite.withDensity_of_ne_top (hf.singularPart ν)
      ((Measure.absolutelyContinuous_of_le (Measure.singularPart_le _ _)).ae_le hf_ne_top)
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_top : ∀ᵐ (x : α) ∂μ, f x ≠ ⊤
this : SigmaFinite (withDensity (singularPart μ ν) f)
⊢ rnDeriv (withDensity (withDensity ν (rnDeriv μ ν)) f) ν =ᶠ[ae ν]
    rnDeriv (withDensity (withDensity ν (rnDeriv μ ν)) f + withDensity (singularPart μ ν) f) ν

Next tactic:
have : SigmaFinite ((ν.withDensity (μ.rnDeriv ν)).withDensity f) :=
    SigmaFinite.withDensity_of_ne_top (hf.withDensity_rnDeriv ν)
      ((Measure.absolutelyContinuous_of_le (Measure.withDensity_rnDeriv_le _ _)).ae_le hf_ne_top)
/-- Auxiliary lemma for `rnDeriv_withDensity_left`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_left (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν]
    (hf : AEMeasurable f μ) (hf_ne_top : ∀ᵐ x ∂μ, f x ≠ ∞) :
    ((ν.withDensity (μ.rnDeriv ν)).withDensity f).rnDeriv ν =ᵐ[ν] (μ.withDensity f).rnDeriv ν := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm, withDensity_add_measure]
  have : SigmaFinite ((μ.singularPart ν).withDensity f) :=
    SigmaFinite.withDensity_of_ne_top (hf.singularPart ν)
      ((Measure.absolutelyContinuous_of_le (Measure.singularPart_le _ _)).ae_le hf_ne_top)
  have : SigmaFinite ((ν.withDensity (μ.rnDeriv ν)).withDensity f) :=
    SigmaFinite.withDensity_of_ne_top (hf.withDensity_rnDeriv ν)
      ((Measure.absolutelyContinuous_of_le (Measure.withDensity_rnDeriv_le _ _)).ae_le hf_ne_top)
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_top : ∀ᵐ (x : α) ∂μ, f x ≠ ⊤
this✝ : SigmaFinite (withDensity (singularPart μ ν) f)
this : SigmaFinite (withDensity (withDensity ν (rnDeriv μ ν)) f)
⊢ rnDeriv (withDensity (withDensity ν (rnDeriv μ ν)) f) ν =ᶠ[ae ν]
    rnDeriv (withDensity (withDensity ν (rnDeriv μ ν)) f + withDensity (singularPart μ ν) f) ν

Next tactic:
exact (rnDeriv_add_of_mutuallySingular _ _ _ (mutuallySingular_singularPart μ ν).withDensity).symm
/-- Auxiliary lemma for `rnDeriv_withDensity_right`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_right (μ ν : Measure α) [SigmaFinite μ]
    [SigmaFinite ν] (hf : AEMeasurable f ν) (hf_ne_zero : ∀ᵐ x ∂ν, f x ≠ 0)
    (hf_ne_top : ∀ᵐ x ∂ν, f x ≠ ∞) :
    (ν.withDensity (μ.rnDeriv ν)).rnDeriv (ν.withDensity f) =ᵐ[ν] μ.rnDeriv (ν.withDensity f) := by
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_zero : ∀ᵐ (x : α) ∂ν, f x ≠ 0
hf_ne_top : ∀ᵐ (x : α) ∂ν, f x ≠ ⊤
⊢ rnDeriv (withDensity ν (rnDeriv μ ν)) (withDensity ν f) =ᶠ[ae ν] rnDeriv μ (withDensity ν f)

Next tactic:
conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm]
/-- Auxiliary lemma for `rnDeriv_withDensity_right`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_right (μ ν : Measure α) [SigmaFinite μ]
    [SigmaFinite ν] (hf : AEMeasurable f ν) (hf_ne_zero : ∀ᵐ x ∂ν, f x ≠ 0)
    (hf_ne_top : ∀ᵐ x ∂ν, f x ≠ ∞) :
    (ν.withDensity (μ.rnDeriv ν)).rnDeriv (ν.withDensity f) =ᵐ[ν] μ.rnDeriv (ν.withDensity f) := by
  conv_rhs => 

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_zero : ∀ᵐ (x : α) ∂ν, f x ≠ 0
hf_ne_top : ∀ᵐ (x : α) ∂ν, f x ≠ ⊤
| rnDeriv μ (withDensity ν f)

Next tactic:
rw [μ.haveLebesgueDecomposition_add ν, add_comm]
/-- Auxiliary lemma for `rnDeriv_withDensity_right`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_right (μ ν : Measure α) [SigmaFinite μ]
    [SigmaFinite ν] (hf : AEMeasurable f ν) (hf_ne_zero : ∀ᵐ x ∂ν, f x ≠ 0)
    (hf_ne_top : ∀ᵐ x ∂ν, f x ≠ ∞) :
    (ν.withDensity (μ.rnDeriv ν)).rnDeriv (ν.withDensity f) =ᵐ[ν] μ.rnDeriv (ν.withDensity f) := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm]
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_zero : ∀ᵐ (x : α) ∂ν, f x ≠ 0
hf_ne_top : ∀ᵐ (x : α) ∂ν, f x ≠ ⊤
⊢ rnDeriv (withDensity ν (rnDeriv μ ν)) (withDensity ν f) =ᶠ[ae ν]
    rnDeriv (withDensity ν (rnDeriv μ ν) + singularPart μ ν) (withDensity ν f)

Next tactic:
have hν_ac : ν ≪ ν.withDensity f := withDensity_absolutelyContinuous' hf hf_ne_zero hf_ne_top
/-- Auxiliary lemma for `rnDeriv_withDensity_right`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_right (μ ν : Measure α) [SigmaFinite μ]
    [SigmaFinite ν] (hf : AEMeasurable f ν) (hf_ne_zero : ∀ᵐ x ∂ν, f x ≠ 0)
    (hf_ne_top : ∀ᵐ x ∂ν, f x ≠ ∞) :
    (ν.withDensity (μ.rnDeriv ν)).rnDeriv (ν.withDensity f) =ᵐ[ν] μ.rnDeriv (ν.withDensity f) := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm]
  have hν_ac : ν ≪ ν.withDensity f := withDensity_absolutelyContinuous' hf hf_ne_zero hf_ne_top
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_zero : ∀ᵐ (x : α) ∂ν, f x ≠ 0
hf_ne_top : ∀ᵐ (x : α) ∂ν, f x ≠ ⊤
hν_ac : ν ≪ withDensity ν f
⊢ rnDeriv (withDensity ν (rnDeriv μ ν)) (withDensity ν f) =ᶠ[ae ν]
    rnDeriv (withDensity ν (rnDeriv μ ν) + singularPart μ ν) (withDensity ν f)

Next tactic:
refine hν_ac.ae_eq ?_
/-- Auxiliary lemma for `rnDeriv_withDensity_right`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_right (μ ν : Measure α) [SigmaFinite μ]
    [SigmaFinite ν] (hf : AEMeasurable f ν) (hf_ne_zero : ∀ᵐ x ∂ν, f x ≠ 0)
    (hf_ne_top : ∀ᵐ x ∂ν, f x ≠ ∞) :
    (ν.withDensity (μ.rnDeriv ν)).rnDeriv (ν.withDensity f) =ᵐ[ν] μ.rnDeriv (ν.withDensity f) := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm]
  have hν_ac : ν ≪ ν.withDensity f := withDensity_absolutelyContinuous' hf hf_ne_zero hf_ne_top
  refine hν_ac.ae_eq ?_
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_zero : ∀ᵐ (x : α) ∂ν, f x ≠ 0
hf_ne_top : ∀ᵐ (x : α) ∂ν, f x ≠ ⊤
hν_ac : ν ≪ withDensity ν f
⊢ rnDeriv (withDensity ν (rnDeriv μ ν)) (withDensity ν f) =ᶠ[ae (withDensity ν f)]
    rnDeriv (withDensity ν (rnDeriv μ ν) + singularPart μ ν) (withDensity ν f)

Next tactic:
have : SigmaFinite (ν.withDensity f) := SigmaFinite.withDensity_of_ne_top hf hf_ne_top
/-- Auxiliary lemma for `rnDeriv_withDensity_right`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_right (μ ν : Measure α) [SigmaFinite μ]
    [SigmaFinite ν] (hf : AEMeasurable f ν) (hf_ne_zero : ∀ᵐ x ∂ν, f x ≠ 0)
    (hf_ne_top : ∀ᵐ x ∂ν, f x ≠ ∞) :
    (ν.withDensity (μ.rnDeriv ν)).rnDeriv (ν.withDensity f) =ᵐ[ν] μ.rnDeriv (ν.withDensity f) := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm]
  have hν_ac : ν ≪ ν.withDensity f := withDensity_absolutelyContinuous' hf hf_ne_zero hf_ne_top
  refine hν_ac.ae_eq ?_
  have : SigmaFinite (ν.withDensity f) := SigmaFinite.withDensity_of_ne_top hf hf_ne_top
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_zero : ∀ᵐ (x : α) ∂ν, f x ≠ 0
hf_ne_top : ∀ᵐ (x : α) ∂ν, f x ≠ ⊤
hν_ac : ν ≪ withDensity ν f
this : SigmaFinite (withDensity ν f)
⊢ rnDeriv (withDensity ν (rnDeriv μ ν)) (withDensity ν f) =ᶠ[ae (withDensity ν f)]
    rnDeriv (withDensity ν (rnDeriv μ ν) + singularPart μ ν) (withDensity ν f)

Next tactic:
refine (rnDeriv_add_of_mutuallySingular _ _ _ ?_).symm
/-- Auxiliary lemma for `rnDeriv_withDensity_right`. -/
lemma rnDeriv_withDensity_withDensity_rnDeriv_right (μ ν : Measure α) [SigmaFinite μ]
    [SigmaFinite ν] (hf : AEMeasurable f ν) (hf_ne_zero : ∀ᵐ x ∂ν, f x ≠ 0)
    (hf_ne_top : ∀ᵐ x ∂ν, f x ≠ ∞) :
    (ν.withDensity (μ.rnDeriv ν)).rnDeriv (ν.withDensity f) =ᵐ[ν] μ.rnDeriv (ν.withDensity f) := by
  conv_rhs => rw [μ.haveLebesgueDecomposition_add ν, add_comm]
  have hν_ac : ν ≪ ν.withDensity f := withDensity_absolutelyContinuous' hf hf_ne_zero hf_ne_top
  refine hν_ac.ae_eq ?_
  have : SigmaFinite (ν.withDensity f) := SigmaFinite.withDensity_of_ne_top hf hf_ne_top
  refine (rnDeriv_add_of_mutuallySingular _ _ _ ?_).symm
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝¹ ν✝¹ μ✝ ν✝ : Measure α
f : α → ℝ≥0∞
μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hf : AEMeasurable f
hf_ne_zero : ∀ᵐ (x : α) ∂ν, f x ≠ 0
hf_ne_top : ∀ᵐ (x : α) ∂ν, f x ≠ ⊤
hν_ac : ν ≪ withDensity ν f
this : SigmaFinite (withDensity ν f)
⊢ singularPart μ ν ⟂ₘ withDensity ν f

Next tactic:
exact ((mutuallySingular_singularPart μ ν).symm.withDensity).symm
lemma rnDeriv_withDensity_left_of_absolutelyContinuous {ν : Measure α} [SigmaFinite μ]
    [SigmaFinite ν] (hμν : μ ≪ ν) (hf : AEMeasurable f ν) :
    (μ.withDensity f).rnDeriv ν =ᵐ[ν] fun x ↦ f x * μ.rnDeriv ν x := by
  

Proof state:
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝ ν✝¹ μ ν✝ : Measure α
f : α → ℝ≥0∞
ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hμν : μ ≪ ν
hf : AEMeasurable f
⊢ rnDeriv (withDensity μ f) ν =ᶠ[ae ν] fun x => f x * rnDeriv μ ν x

Next tactic:
refine (Measure.eq_rnDeriv₀ ?_ Measure.MutuallySingular.zero_left ?_).symm
lemma rnDeriv_withDensity_left_of_absolutelyContinuous {ν : Measure α} [SigmaFinite μ]
    [SigmaFinite ν] (hμν : μ ≪ ν) (hf : AEMeasurable f ν) :
    (μ.withDensity f).rnDeriv ν =ᵐ[ν] fun x ↦ f x * μ.rnDeriv ν x := by
  refine (Measure.eq_rnDeriv₀ ?_ Measure.MutuallySingular.zero_left ?_).symm
  · 

Proof state:
case refine_1
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝ ν✝¹ μ ν✝ : Measure α
f : α → ℝ≥0∞
ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hμν : μ ≪ ν
hf : AEMeasurable f
⊢ AEMeasurable fun x => f x * rnDeriv μ ν x

Next tactic:
exact hf.mul (Measure.measurable_rnDeriv _ _).aemeasurable
lemma rnDeriv_withDensity_left_of_absolutelyContinuous {ν : Measure α} [SigmaFinite μ]
    [SigmaFinite ν] (hμν : μ ≪ ν) (hf : AEMeasurable f ν) :
    (μ.withDensity f).rnDeriv ν =ᵐ[ν] fun x ↦ f x * μ.rnDeriv ν x := by
  refine (Measure.eq_rnDeriv₀ ?_ Measure.MutuallySingular.zero_left ?_).symm
  · exact hf.mul (Measure.measurable_rnDeriv _ _).aemeasurable
  · 

Proof state:
case refine_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝ ν✝¹ μ ν✝ : Measure α
f : α → ℝ≥0∞
ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hμν : μ ≪ ν
hf : AEMeasurable f
⊢ withDensity μ f = 0 + withDensity ν fun x => f x * rnDeriv μ ν x

Next tactic:
ext1 s hs
lemma rnDeriv_withDensity_left_of_absolutelyContinuous {ν : Measure α} [SigmaFinite μ]
    [SigmaFinite ν] (hμν : μ ≪ ν) (hf : AEMeasurable f ν) :
    (μ.withDensity f).rnDeriv ν =ᵐ[ν] fun x ↦ f x * μ.rnDeriv ν x := by
  refine (Measure.eq_rnDeriv₀ ?_ Measure.MutuallySingular.zero_left ?_).symm
  · exact hf.mul (Measure.measurable_rnDeriv _ _).aemeasurable
  · ext1 s hs
    

Proof state:
case refine_2.h
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝ ν✝¹ μ ν✝ : Measure α
f : α → ℝ≥0∞
ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
hμν : μ ≪ ν
hf : AEMeasurable f
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ f) s = ↑↑(0 + withDensity ν fun x => f x * rnDeriv μ ν x) s

Next tactic:
rw [zero_add, withDensity_apply _ hs, withDensity_apply _ hs]