l3lab/ntp-mathlib huggingface dataset:
theorem continuousMapEval_bijective : Bijective (continuousMapEval X 𝕜) := by
  refine' ⟨fun x y hxy => _, fun φ => _⟩
  · contrapose! hxy
    rcases exists_continuous_zero_one_of_isClosed (isClosed_singleton : _root_.IsClosed {x})
        (isClosed_singleton : _root_.IsClosed {y}) (Set.disjoint_singleton.mpr hxy) with
      ⟨f, fx, fy, -⟩
    rw [FunLike.ne_iff]
    use (⟨fun (x : ℝ) => (x : 𝕜), IsROrC.continuous_ofReal⟩ : C(ℝ, 𝕜)).comp f
    simpa only [continuousMapEval_apply_apply, ContinuousMap.comp_apply, coe_mk, Ne.def,
      IsROrC.ofReal_inj] using
      ((fx (Set.mem_singleton x)).symm ▸ (fy (Set.mem_singleton y)).symm ▸ zero_ne_one : f x ≠ f y)
  · obtain ⟨x, hx⟩ := (ideal_isMaximal_iff (RingHom.ker φ)).mp inferInstance
    

Proof state:
case refine'_2.intro
X : Type u_1
𝕜 : Type u_2
inst✝³ : TopologicalSpace X
inst✝² : CompactSpace X
inst✝¹ : T2Space X
inst✝ : IsROrC 𝕜
φ : ↑(characterSpace 𝕜 C(X, 𝕜))
x : X
hx : idealOfSet 𝕜 {x}ᶜ = RingHom.ker φ
⊢ ∃ a, (continuousMapEval X 𝕜) a = φ

Next tactic:
refine' ⟨x, CharacterSpace.ext_ker <| Ideal.ext fun f => _⟩
theorem continuousMapEval_bijective : Bijective (continuousMapEval X 𝕜) := by
  refine' ⟨fun x y hxy => _, fun φ => _⟩
  · contrapose! hxy
    rcases exists_continuous_zero_one_of_isClosed (isClosed_singleton : _root_.IsClosed {x})
        (isClosed_singleton : _root_.IsClosed {y}) (Set.disjoint_singleton.mpr hxy) with
      ⟨f, fx, fy, -⟩
    rw [FunLike.ne_iff]
    use (⟨fun (x : ℝ) => (x : 𝕜), IsROrC.continuous_ofReal⟩ : C(ℝ, 𝕜)).comp f
    simpa only [continuousMapEval_apply_apply, ContinuousMap.comp_apply, coe_mk, Ne.def,
      IsROrC.ofReal_inj] using
      ((fx (Set.mem_singleton x)).symm ▸ (fy (Set.mem_singleton y)).symm ▸ zero_ne_one : f x ≠ f y)
  · obtain ⟨x, hx⟩ := (ideal_isMaximal_iff (RingHom.ker φ)).mp inferInstance
    refine' ⟨x, CharacterSpace.ext_ker <| Ideal.ext fun f => _⟩
    

Proof state:
case refine'_2.intro
X : Type u_1
𝕜 : Type u_2
inst✝³ : TopologicalSpace X
inst✝² : CompactSpace X
inst✝¹ : T2Space X
inst✝ : IsROrC 𝕜
φ : ↑(characterSpace 𝕜 C(X, 𝕜))
x : X
hx : idealOfSet 𝕜 {x}ᶜ = RingHom.ker φ
f : C(X, 𝕜)
⊢ f ∈ RingHom.ker ((continuousMapEval X 𝕜) x) ↔ f ∈ RingHom.ker φ

Next tactic:
simpa only [RingHom.mem_ker, continuousMapEval_apply_apply, mem_idealOfSet_compl_singleton,
      RingHom.mem_ker] using SetLike.ext_iff.mp hx f
/-- Given a measure `μ : Measure α` and a function `f : α → ℝ≥0∞`, `μ.withDensity f` is the
measure such that for a measurable set `s` we have `μ.withDensity f s = ∫⁻ a in s, f a ∂μ`. -/
noncomputable
def Measure.withDensity {m : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : Measure α :=
  Measure.ofMeasurable (fun s _ => ∫⁻ a in s, f a ∂μ) (by 

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
m : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
⊢ (fun s x => ∫⁻ (a : α) in s, f a ∂μ) ∅ (_ : MeasurableSet ∅) = 0

Next tactic:
simp
theorem withDensity_apply_le (f : α → ℝ≥0∞) (s : Set α) :
    ∫⁻ a in s, f a ∂μ ≤ μ.withDensity f s := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
s : Set α
⊢ ∫⁻ (a : α) in s, f a ∂μ ≤ ↑↑(withDensity μ f) s

Next tactic:
let t := toMeasurable (μ.withDensity f) s
theorem withDensity_apply_le (f : α → ℝ≥0∞) (s : Set α) :
    ∫⁻ a in s, f a ∂μ ≤ μ.withDensity f s := by
  let t := toMeasurable (μ.withDensity f) s
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
s : Set α
t : Set α := toMeasurable (withDensity μ f) s
⊢ ∫⁻ (a : α) in s, f a ∂μ ≤ ↑↑(withDensity μ f) s

Next tactic:
calc
  ∫⁻ a in s, f a ∂μ ≤ ∫⁻ a in t, f a ∂μ :=
    lintegral_mono_set (subset_toMeasurable (withDensity μ f) s)
  _ = μ.withDensity f t :=
    (withDensity_apply f (measurableSet_toMeasurable (withDensity μ f) s)).symm
  _ = μ.withDensity f s := measure_toMeasurable s
theorem withDensity_apply' [SFinite μ] (f : α → ℝ≥0∞) (s : Set α) :
    μ.withDensity f s = ∫⁻ a in s, f a ∂μ := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
inst✝ : SFinite μ
f : α → ℝ≥0∞
s : Set α
⊢ ↑↑(withDensity μ f) s = ∫⁻ (a : α) in s, f a ∂μ

Next tactic:
apply le_antisymm ?_ (withDensity_apply_le f s)
theorem withDensity_apply' [SFinite μ] (f : α → ℝ≥0∞) (s : Set α) :
    μ.withDensity f s = ∫⁻ a in s, f a ∂μ := by
  apply le_antisymm ?_ (withDensity_apply_le f s)
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
inst✝ : SFinite μ
f : α → ℝ≥0∞
s : Set α
⊢ ↑↑(withDensity μ f) s ≤ ∫⁻ (a : α) in s, f a ∂μ

Next tactic:
let t := toMeasurable μ s
theorem withDensity_apply' [SFinite μ] (f : α → ℝ≥0∞) (s : Set α) :
    μ.withDensity f s = ∫⁻ a in s, f a ∂μ := by
  apply le_antisymm ?_ (withDensity_apply_le f s)
  let t := toMeasurable μ s
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
inst✝ : SFinite μ
f : α → ℝ≥0∞
s : Set α
t : Set α := toMeasurable μ s
⊢ ↑↑(withDensity μ f) s ≤ ∫⁻ (a : α) in s, f a ∂μ

Next tactic:
calc
  μ.withDensity f s ≤ μ.withDensity f t := measure_mono (subset_toMeasurable μ s)
  _ = ∫⁻ a in t, f a ∂μ := withDensity_apply f (measurableSet_toMeasurable μ s)
  _ = ∫⁻ a in s, f a ∂μ := by congr 1; exact restrict_toMeasurable_of_sFinite s
theorem withDensity_apply' [SFinite μ] (f : α → ℝ≥0∞) (s : Set α) :
    μ.withDensity f s = ∫⁻ a in s, f a ∂μ := by
  apply le_antisymm ?_ (withDensity_apply_le f s)
  let t := toMeasurable μ s
  calc
  μ.withDensity f s ≤ μ.withDensity f t := measure_mono (subset_toMeasurable μ s)
  _ = ∫⁻ a in t, f a ∂μ := withDensity_apply f (measurableSet_toMeasurable μ s)
  _ = ∫⁻ a in s, f a ∂μ := by 

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
inst✝ : SFinite μ
f : α → ℝ≥0∞
s : Set α
t : Set α := toMeasurable μ s
⊢ ∫⁻ (a : α) in t, f a ∂μ = ∫⁻ (a : α) in s, f a ∂μ

Next tactic:
congr 1
theorem withDensity_apply' [SFinite μ] (f : α → ℝ≥0∞) (s : Set α) :
    μ.withDensity f s = ∫⁻ a in s, f a ∂μ := by
  apply le_antisymm ?_ (withDensity_apply_le f s)
  let t := toMeasurable μ s
  calc
  μ.withDensity f s ≤ μ.withDensity f t := measure_mono (subset_toMeasurable μ s)
  _ = ∫⁻ a in t, f a ∂μ := withDensity_apply f (measurableSet_toMeasurable μ s)
  _ = ∫⁻ a in s, f a ∂μ := by congr 1; 

Proof state:
case e_μ
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
inst✝ : SFinite μ
f : α → ℝ≥0∞
s : Set α
t : Set α := toMeasurable μ s
⊢ restrict μ t = restrict μ s

Next tactic:
exact restrict_toMeasurable_of_sFinite s
@[simp]
lemma withDensity_zero_left (f : α → ℝ≥0∞) : (0 : Measure α).withDensity f = 0 := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
⊢ withDensity 0 f = 0

Next tactic:
ext s hs
@[simp]
lemma withDensity_zero_left (f : α → ℝ≥0∞) : (0 : Measure α).withDensity f = 0 := by
  ext s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity 0 f) s = ↑↑0 s

Next tactic:
rw [withDensity_apply _ hs]
@[simp]
lemma withDensity_zero_left (f : α → ℝ≥0∞) : (0 : Measure α).withDensity f = 0 := by
  ext s hs
  rw [withDensity_apply _ hs]
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s, f a ∂0 = ↑↑0 s

Next tactic:
simp
theorem withDensity_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) :
    μ.withDensity f = μ.withDensity g := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
h : f =ᶠ[ae μ] g
⊢ withDensity μ f = withDensity μ g

Next tactic:
refine Measure.ext fun s hs => ?_
theorem withDensity_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) :
    μ.withDensity f = μ.withDensity g := by
  refine Measure.ext fun s hs => ?_
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
h : f =ᶠ[ae μ] g
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ f) s = ↑↑(withDensity μ g) s

Next tactic:
rw [withDensity_apply _ hs, withDensity_apply _ hs]
theorem withDensity_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) :
    μ.withDensity f = μ.withDensity g := by
  refine Measure.ext fun s hs => ?_
  rw [withDensity_apply _ hs, withDensity_apply _ hs]
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
h : f =ᶠ[ae μ] g
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s, f a ∂μ = ∫⁻ (a : α) in s, g a ∂μ

Next tactic:
exact lintegral_congr_ae (ae_restrict_of_ae h)
lemma withDensity_mono {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) :
    μ.withDensity f ≤ μ.withDensity g := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
hfg : f ≤ᶠ[ae μ] g
⊢ withDensity μ f ≤ withDensity μ g

Next tactic:
intro s hs
lemma withDensity_mono {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) :
    μ.withDensity f ≤ μ.withDensity g := by
  intro s hs
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
hfg : f ≤ᶠ[ae μ] g
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ f) s ≤ ↑↑(withDensity μ g) s

Next tactic:
rw [withDensity_apply _ hs, withDensity_apply _ hs]
lemma withDensity_mono {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) :
    μ.withDensity f ≤ μ.withDensity g := by
  intro s hs
  rw [withDensity_apply _ hs, withDensity_apply _ hs]
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
hfg : f ≤ᶠ[ae μ] g
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s, f a ∂μ ≤ ∫⁻ (a : α) in s, g a ∂μ

Next tactic:
refine set_lintegral_mono_ae' hs ?_
lemma withDensity_mono {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) :
    μ.withDensity f ≤ μ.withDensity g := by
  intro s hs
  rw [withDensity_apply _ hs, withDensity_apply _ hs]
  refine set_lintegral_mono_ae' hs ?_
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
hfg : f ≤ᶠ[ae μ] g
s : Set α
hs : MeasurableSet s
⊢ ∀ᵐ (x : α) ∂μ, x ∈ s → f x ≤ g x

Next tactic:
filter_upwards [hfg] with x h_le using fun _ ↦ h_le
theorem withDensity_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) :
    μ.withDensity (f + g) = μ.withDensity f + μ.withDensity g := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
hf : Measurable f
g : α → ℝ≥0∞
⊢ withDensity μ (f + g) = withDensity μ f + withDensity μ g

Next tactic:
refine' Measure.ext fun s hs => _
theorem withDensity_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) :
    μ.withDensity (f + g) = μ.withDensity f + μ.withDensity g := by
  refine' Measure.ext fun s hs => _
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
hf : Measurable f
g : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ (f + g)) s = ↑↑(withDensity μ f + withDensity μ g) s

Next tactic:
rw [withDensity_apply _ hs, Measure.add_apply, withDensity_apply _ hs, withDensity_apply _ hs,
    ← lintegral_add_left hf]
theorem withDensity_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) :
    μ.withDensity (f + g) = μ.withDensity f + μ.withDensity g := by
  refine' Measure.ext fun s hs => _
  rw [withDensity_apply _ hs, Measure.add_apply, withDensity_apply _ hs, withDensity_apply _ hs,
    ← lintegral_add_left hf]
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
hf : Measurable f
g : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s, (f + g) a ∂μ = ∫⁻ (a : α) in s, f a + g a ∂μ

Next tactic:
simp only [Pi.add_apply]
theorem withDensity_add_right (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : Measurable g) :
    μ.withDensity (f + g) = μ.withDensity f + μ.withDensity g := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f g : α → ℝ≥0∞
hg : Measurable g
⊢ withDensity μ (f + g) = withDensity μ f + withDensity μ g

Next tactic:
simpa only [add_comm] using withDensity_add_left hg f
theorem withDensity_add_measure {m : MeasurableSpace α} (μ ν : Measure α) (f : α → ℝ≥0∞) :
    (μ + ν).withDensity f = μ.withDensity f + ν.withDensity f := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
m : MeasurableSpace α
μ ν : Measure α
f : α → ℝ≥0∞
⊢ withDensity (μ + ν) f = withDensity μ f + withDensity ν f

Next tactic:
ext1 s hs
theorem withDensity_add_measure {m : MeasurableSpace α} (μ ν : Measure α) (f : α → ℝ≥0∞) :
    (μ + ν).withDensity f = μ.withDensity f + ν.withDensity f := by
  ext1 s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
m : MeasurableSpace α
μ ν : Measure α
f : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity (μ + ν) f) s = ↑↑(withDensity μ f + withDensity ν f) s

Next tactic:
simp only [withDensity_apply f hs, restrict_add, lintegral_add_measure, Measure.add_apply]
theorem withDensity_sum {ι : Type*} {m : MeasurableSpace α} (μ : ι → Measure α) (f : α → ℝ≥0∞) :
    (sum μ).withDensity f = sum fun n => (μ n).withDensity f := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
ι : Type u_2
m : MeasurableSpace α
μ : ι → Measure α
f : α → ℝ≥0∞
⊢ withDensity (sum μ) f = sum fun n => withDensity (μ n) f

Next tactic:
ext1 s hs
theorem withDensity_sum {ι : Type*} {m : MeasurableSpace α} (μ : ι → Measure α) (f : α → ℝ≥0∞) :
    (sum μ).withDensity f = sum fun n => (μ n).withDensity f := by
  ext1 s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
ι : Type u_2
m : MeasurableSpace α
μ : ι → Measure α
f : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity (sum μ) f) s = ↑↑(sum fun n => withDensity (μ n) f) s

Next tactic:
simp_rw [sum_apply _ hs, withDensity_apply f hs, restrict_sum μ hs, lintegral_sum_measure]
theorem withDensity_smul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) :
    μ.withDensity (r • f) = r • μ.withDensity f := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
hf : Measurable f
⊢ withDensity μ (r • f) = r • withDensity μ f

Next tactic:
refine' Measure.ext fun s hs => _
theorem withDensity_smul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) :
    μ.withDensity (r • f) = r • μ.withDensity f := by
  refine' Measure.ext fun s hs => _
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
hf : Measurable f
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ (r • f)) s = ↑↑(r • withDensity μ f) s

Next tactic:
rw [withDensity_apply _ hs, Measure.coe_smul, Pi.smul_apply, withDensity_apply _ hs,
    smul_eq_mul, ← lintegral_const_mul r hf]
theorem withDensity_smul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) :
    μ.withDensity (r • f) = r • μ.withDensity f := by
  refine' Measure.ext fun s hs => _
  rw [withDensity_apply _ hs, Measure.coe_smul, Pi.smul_apply, withDensity_apply _ hs,
    smul_eq_mul, ← lintegral_const_mul r hf]
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
hf : Measurable f
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s, (r • f) a ∂μ = ∫⁻ (a : α) in s, r * f a ∂μ

Next tactic:
simp only [Pi.smul_apply, smul_eq_mul]
theorem withDensity_smul' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) :
    μ.withDensity (r • f) = r • μ.withDensity f := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
hr : r ≠ ⊤
⊢ withDensity μ (r • f) = r • withDensity μ f

Next tactic:
refine' Measure.ext fun s hs => _
theorem withDensity_smul' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) :
    μ.withDensity (r • f) = r • μ.withDensity f := by
  refine' Measure.ext fun s hs => _
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
hr : r ≠ ⊤
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ (r • f)) s = ↑↑(r • withDensity μ f) s

Next tactic:
rw [withDensity_apply _ hs, Measure.coe_smul, Pi.smul_apply, withDensity_apply _ hs,
    smul_eq_mul, ← lintegral_const_mul' r f hr]
theorem withDensity_smul' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) :
    μ.withDensity (r • f) = r • μ.withDensity f := by
  refine' Measure.ext fun s hs => _
  rw [withDensity_apply _ hs, Measure.coe_smul, Pi.smul_apply, withDensity_apply _ hs,
    smul_eq_mul, ← lintegral_const_mul' r f hr]
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
hr : r ≠ ⊤
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s, (r • f) a ∂μ = ∫⁻ (a : α) in s, r * f a ∂μ

Next tactic:
simp only [Pi.smul_apply, smul_eq_mul]
theorem withDensity_smul_measure (r : ℝ≥0∞) (f : α → ℝ≥0∞) :
    (r • μ).withDensity f = r • μ.withDensity f := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
⊢ withDensity (r • μ) f = r • withDensity μ f

Next tactic:
ext s hs
theorem withDensity_smul_measure (r : ℝ≥0∞) (f : α → ℝ≥0∞) :
    (r • μ).withDensity f = r • μ.withDensity f := by
  ext s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
r : ℝ≥0∞
f : α → ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity (r • μ) f) s = ↑↑(r • withDensity μ f) s

Next tactic:
rw [withDensity_apply _ hs, Measure.coe_smul, Pi.smul_apply, withDensity_apply _ hs,
    smul_eq_mul, set_lintegral_smul_measure]
theorem isFiniteMeasure_withDensity {f : α → ℝ≥0∞} (hf : ∫⁻ a, f a ∂μ ≠ ∞) :
    IsFiniteMeasure (μ.withDensity f) :=
  { measure_univ_lt_top := by
      

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
hf : ∫⁻ (a : α), f a ∂μ ≠ ⊤
⊢ ↑↑(withDensity μ f) univ < ⊤

Next tactic:
rwa [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ, lt_top_iff_ne_top]
theorem withDensity_absolutelyContinuous {m : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) :
    μ.withDensity f ≪ μ := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
m : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
⊢ withDensity μ f ≪ μ

Next tactic:
refine' AbsolutelyContinuous.mk fun s hs₁ hs₂ => _
theorem withDensity_absolutelyContinuous {m : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) :
    μ.withDensity f ≪ μ := by
  refine' AbsolutelyContinuous.mk fun s hs₁ hs₂ => _
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
m : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
s : Set α
hs₁ : MeasurableSet s
hs₂ : ↑↑μ s = 0
⊢ ↑↑(withDensity μ f) s = 0

Next tactic:
rw [withDensity_apply _ hs₁]
theorem withDensity_absolutelyContinuous {m : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) :
    μ.withDensity f ≪ μ := by
  refine' AbsolutelyContinuous.mk fun s hs₁ hs₂ => _
  rw [withDensity_apply _ hs₁]
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ✝ : Measure α
m : MeasurableSpace α
μ : Measure α
f : α → ℝ≥0∞
s : Set α
hs₁ : MeasurableSet s
hs₂ : ↑↑μ s = 0
⊢ ∫⁻ (a : α) in s, f a ∂μ = 0

Next tactic:
exact set_lintegral_measure_zero _ _ hs₂
@[simp]
theorem withDensity_zero : μ.withDensity 0 = 0 := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
⊢ withDensity μ 0 = 0

Next tactic:
ext1 s hs
@[simp]
theorem withDensity_zero : μ.withDensity 0 = 0 := by
  ext1 s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ 0) s = ↑↑0 s

Next tactic:
simp [withDensity_apply _ hs]
@[simp]
theorem withDensity_one : μ.withDensity 1 = μ := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
⊢ withDensity μ 1 = μ

Next tactic:
ext1 s hs
@[simp]
theorem withDensity_one : μ.withDensity 1 = μ := by
  ext1 s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ 1) s = ↑↑μ s

Next tactic:
simp [withDensity_apply _ hs]
@[simp]
theorem withDensity_const (c : ℝ≥0∞) : μ.withDensity (fun _ ↦ c) = c • μ := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
c : ℝ≥0∞
⊢ (withDensity μ fun x => c) = c • μ

Next tactic:
ext1 s hs
@[simp]
theorem withDensity_const (c : ℝ≥0∞) : μ.withDensity (fun _ ↦ c) = c • μ := by
  ext1 s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
c : ℝ≥0∞
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ fun x => c) s = ↑↑(c • μ) s

Next tactic:
simp [withDensity_apply _ hs]
theorem withDensity_tsum {f : ℕ → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) :
    μ.withDensity (∑' n, f n) = sum fun n => μ.withDensity (f n) := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : ℕ → α → ℝ≥0∞
h : ∀ (i : ℕ), Measurable (f i)
⊢ withDensity μ (∑' (n : ℕ), f n) = sum fun n => withDensity μ (f n)

Next tactic:
ext1 s hs
theorem withDensity_tsum {f : ℕ → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) :
    μ.withDensity (∑' n, f n) = sum fun n => μ.withDensity (f n) := by
  ext1 s hs
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : ℕ → α → ℝ≥0∞
h : ∀ (i : ℕ), Measurable (f i)
s : Set α
hs : MeasurableSet s
⊢ ↑↑(withDensity μ (∑' (n : ℕ), f n)) s = ↑↑(sum fun n => withDensity μ (f n)) s

Next tactic:
simp_rw [sum_apply _ hs, withDensity_apply _ hs]
theorem withDensity_tsum {f : ℕ → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) :
    μ.withDensity (∑' n, f n) = sum fun n => μ.withDensity (f n) := by
  ext1 s hs
  simp_rw [sum_apply _ hs, withDensity_apply _ hs]
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : ℕ → α → ℝ≥0∞
h : ∀ (i : ℕ), Measurable (f i)
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s, tsum (fun n => f n) a ∂μ = ∑' (i : ℕ), ∫⁻ (a : α) in s, f i a ∂μ

Next tactic:
change ∫⁻ x in s, (∑' n, f n) x ∂μ = ∑' i : ℕ, ∫⁻ x, f i x ∂μ.restrict s
theorem withDensity_tsum {f : ℕ → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) :
    μ.withDensity (∑' n, f n) = sum fun n => μ.withDensity (f n) := by
  ext1 s hs
  simp_rw [sum_apply _ hs, withDensity_apply _ hs]
  change ∫⁻ x in s, (∑' n, f n) x ∂μ = ∑' i : ℕ, ∫⁻ x, f i x ∂μ.restrict s
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : ℕ → α → ℝ≥0∞
h : ∀ (i : ℕ), Measurable (f i)
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (x : α) in s, tsum (fun n => f n) x ∂μ = ∑' (i : ℕ), ∫⁻ (x : α) in s, f i x ∂μ

Next tactic:
rw [← lintegral_tsum fun i => (h i).aemeasurable]
theorem withDensity_tsum {f : ℕ → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) :
    μ.withDensity (∑' n, f n) = sum fun n => μ.withDensity (f n) := by
  ext1 s hs
  simp_rw [sum_apply _ hs, withDensity_apply _ hs]
  change ∫⁻ x in s, (∑' n, f n) x ∂μ = ∑' i : ℕ, ∫⁻ x, f i x ∂μ.restrict s
  rw [← lintegral_tsum fun i => (h i).aemeasurable]
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : ℕ → α → ℝ≥0∞
h : ∀ (i : ℕ), Measurable (f i)
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (x : α) in s, tsum (fun n => f n) x ∂μ = ∫⁻ (a : α) in s, ∑' (i : ℕ), f i a ∂μ

Next tactic:
refine' lintegral_congr fun x => tsum_apply (Pi.summable.2 fun _ => ENNReal.summable)
theorem withDensity_indicator {s : Set α} (hs : MeasurableSet s) (f : α → ℝ≥0∞) :
    μ.withDensity (s.indicator f) = (μ.restrict s).withDensity f := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s : Set α
hs : MeasurableSet s
f : α → ℝ≥0∞
⊢ withDensity μ (indicator s f) = withDensity (restrict μ s) f

Next tactic:
ext1 t ht
theorem withDensity_indicator {s : Set α} (hs : MeasurableSet s) (f : α → ℝ≥0∞) :
    μ.withDensity (s.indicator f) = (μ.restrict s).withDensity f := by
  ext1 t ht
  

Proof state:
case h
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s : Set α
hs : MeasurableSet s
f : α → ℝ≥0∞
t : Set α
ht : MeasurableSet t
⊢ ↑↑(withDensity μ (indicator s f)) t = ↑↑(withDensity (restrict μ s) f) t

Next tactic:
rw [withDensity_apply _ ht, lintegral_indicator _ hs, restrict_comm hs, ←
    withDensity_apply _ ht]
theorem withDensity_indicator_one {s : Set α} (hs : MeasurableSet s) :
    μ.withDensity (s.indicator 1) = μ.restrict s := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s : Set α
hs : MeasurableSet s
⊢ withDensity μ (indicator s 1) = restrict μ s

Next tactic:
rw [withDensity_indicator hs, withDensity_one]
theorem withDensity_ofReal_mutuallySingular {f : α → ℝ} (hf : Measurable f) :
    (μ.withDensity fun x => ENNReal.ofReal <| f x) ⟂ₘ
      μ.withDensity fun x => ENNReal.ofReal <| -f x := by
  

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : Measurable f
⊢ (withDensity μ fun x => ENNReal.ofReal (f x)) ⟂ₘ withDensity μ fun x => ENNReal.ofReal (-f x)

Next tactic:
set S : Set α := { x | f x < 0 }