Theorem: MeasureTheory.toFinite_withDensity_restrict_sigmaFiniteSet
File: Mathlib/MeasureTheory/Measure/WithDensityFinite.lean

Proof steps:
state_before: α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s t : Set α
μ : Measure α
inst✝ : SFinite μ
⊢ (μ.toFinite.withDensity fun x => if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1).restrict
      μ.sigmaFiniteSet =
    μ.restrict μ.sigmaFiniteSet
state_after: α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
⊢ (μ.toFinite.withDensity fun x => if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1).restrict
      μ.sigmaFiniteSet =
    μ.restrict μ.sigmaFiniteSet
tactic: have : μ.restrict μ.sigmaFiniteSet
      = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet := by
    rw [withDensity_densitytoFinite μ]
state_before: α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
⊢ (μ.toFinite.withDensity fun x => if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1).restrict
      μ.sigmaFiniteSet =
    μ.restrict μ.sigmaFiniteSet
state_after: α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
⊢ (μ.toFinite.withDensity fun x => if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1).restrict
      μ.sigmaFiniteSet =
    (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
tactic: rw [this]
state_before: α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
⊢ (μ.toFinite.withDensity fun x => if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1).restrict
      μ.sigmaFiniteSet =
    (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
state_after: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
⊢ ((μ.toFinite.withDensity fun x => if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1).restrict
        μ.sigmaFiniteSet)
      s =
    ((μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet) s
tactic: ext s hs
state_before: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
⊢ ((μ.toFinite.withDensity fun x => if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1).restrict
        μ.sigmaFiniteSet)
      s =
    ((μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet) s
state_after: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s ∩ μ.sigmaFiniteSet, if μ.densityToFinite a ≠ ⊤ then μ.densityToFinite a else 1 ∂μ.toFinite =
    ∫⁻ (a : α) in s ∩ μ.sigmaFiniteSet, μ.densityToFinite a ∂μ.toFinite
tactic: rw [Measure.restrict_apply hs, Measure.restrict_apply hs,
    withDensity_apply _ (hs.inter (measurableSet_sigmaFiniteSet μ)),
    withDensity_apply _ (hs.inter (measurableSet_sigmaFiniteSet μ))]
state_before: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
⊢ ∫⁻ (a : α) in s ∩ μ.sigmaFiniteSet, if μ.densityToFinite a ≠ ⊤ then μ.densityToFinite a else 1 ∂μ.toFinite =
    ∫⁻ (a : α) in s ∩ μ.sigmaFiniteSet, μ.densityToFinite a ∂μ.toFinite
state_after: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
x : α
hx : x ∈ s ∩ μ.sigmaFiniteSet
⊢ μ.densityToFinite x = if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1
tactic: refine setLIntegral_congr_fun (hs.inter (measurableSet_sigmaFiniteSet μ))
    (ae_of_all _ (fun x hx ↦ Eq.symm ?_))
state_before: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
x : α
hx : x ∈ s ∩ μ.sigmaFiniteSet
⊢ μ.densityToFinite x = if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1
state_after: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
x : α
hx : x ∈ s ∧ ¬μ.densityToFinite x = ⊤
⊢ μ.densityToFinite x = if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1
tactic: simp only [Measure.sigmaFiniteSet, Set.mem_inter_iff, Set.mem_compl_iff, Set.mem_setOf_eq,
    ne_eq] at hx
state_before: case h
α : Type u_1
mα : MeasurableSpace α
μ✝ : Measure α
s✝ t : Set α
μ : Measure α
inst✝ : SFinite μ
this : μ.restrict μ.sigmaFiniteSet = (μ.toFinite.withDensity μ.densityToFinite).restrict μ.sigmaFiniteSet
s : Set α
hs : MeasurableSet s
x : α
hx : x ∈ s ∧ ¬μ.densityToFinite x = ⊤
⊢ μ.densityToFinite x = if μ.densityToFinite x ≠ ⊤ then μ.densityToFinite x else 1
state_after: no goals
tactic: rw [if_pos hx.2]