/-- **The Lebesgue decomposition theorem**: Any pair of σ-finite measures `μ` and `ν`
`HaveLebesgueDecomposition`. That is to say, there exist a measure `ξ` and a measurable function
`f`, such that `ξ` is mutually singular with respect to `ν` and `μ = ξ + ν.withDensity f` -/
instance (priority := 100) haveLebesgueDecomposition_of_sigmaFinite (μ ν : Measure α)
    [SigmaFinite μ] [SigmaFinite ν] : HaveLebesgueDecomposition μ ν :=
  ⟨by
    -- Since `μ` and `ν` are both σ-finite, there exists a sequence of pairwise disjoint spanning
    -- sets which are finite with respect to both `μ` and `ν`
    obtain ⟨S, T, h₁, h₂⟩ := exists_eq_disjoint_finiteSpanningSetsIn μ ν
    have h₃ : Pairwise (Disjoint on T.set) := h₁ ▸ h₂
    -- We define `μn` and `νn` as sequences of measures such that `μn n = μ ∩ S n` and
    -- `νn n = ν ∩ S n` where `S` is the aforementioned finite spanning set sequence.
    -- Since `S` is spanning, it is clear that `sum μn = μ` and `sum νn = ν`
    set μn : ℕ → Measure α := fun n => μ.restrict (S.set n) with hμn
    have hμ : μ = sum μn := by rw [hμn, ← restrict_iUnion h₂ S.set_mem, S.spanning, restrict_univ]
    set νn : ℕ → Measure α := fun n => ν.restrict (T.set n) with hνn
    have hν : ν = sum νn := by rw [hνn, ← restrict_iUnion h₃ T.set_mem, T.spanning, restrict_univ]
    -- As `S` is finite with respect to both `μ` and `ν`, it is clear that `μn n` and `νn n` are
    -- finite measures for all `n : ℕ`. Thus, we may apply the finite Lebesgue decomposition theorem
    -- to `μn n` and `νn n`. We define `ξ` as the sum of the singular part of the Lebesgue
    -- decompositions of `μn n` and `νn n`, and `f` as the sum of the Radon-Nikodym derivatives of
    -- `μn n` and `νn n` restricted on `S n`
    set ξ := sum fun n => singularPart (μn n) (νn n) with hξ
    set f := ∑' n, (S.set n).indicator (rnDeriv (μn n) (νn n))
    -- I claim `ξ` and `f` form a Lebesgue decomposition of `μ` and `ν`
    refine' ⟨⟨ξ, f⟩, _, _, _⟩
    · exact
        Measurable.ennreal_tsum' fun n =>
          Measurable.indicator (measurable_rnDeriv (μn n) (νn n)) (S.set_mem n)
    -- We show that `ξ` is mutually singular with respect to `ν`
    · choose A hA₁ hA₂ hA₃ using fun n => mutuallySingular_singularPart (μn n) (νn n)
      simp only [hξ]
      -- We use the set `B := ⋃ j, (S.set j) ∩ A j` where `A n` is the set provided as
      -- `singularPart (μn n) (νn n) ⟂ₘ νn n`
      

Proof state:
case intro.intro.intro.refine'_2
α : Type u_1
β : Type u_2
m : MeasurableSpace α
μ✝ ν✝ μ ν : Measure α
inst✝¹ : SigmaFinite μ
inst✝ : SigmaFinite ν
S : FiniteSpanningSetsIn μ {s | MeasurableSet s}
T : FiniteSpanningSetsIn ν {s | MeasurableSet s}
h₁ : S.set = T.set
h₂ : Pairwise (Disjoint on S.set)
h₃ : Pairwise (Disjoint on T.set)
μn : ℕ → Measure α := fun n => restrict μ (FiniteSpanningSetsIn.set S n)
hμn : μn = fun n => restrict μ (FiniteSpanningSetsIn.set S n)
hμ : μ = sum μn
νn : ℕ → Measure α := fun n => restrict ν (FiniteSpanningSetsIn.set T n)
hνn : νn = fun n => restrict ν (FiniteSpanningSetsIn.set T n)
hν : ν = sum νn
ξ : Measure α := sum fun n => singularPart (μn n) (νn n)
hξ : ξ = sum fun n => singularPart (μn n) (νn n)
f : α → ℝ≥0∞ := ∑' (n : ℕ), indicator (FiniteSpanningSetsIn.set S n) (rnDeriv (μn n) (νn n))
A : ℕ → Set α
hA₁ : ∀ (n : ℕ), MeasurableSet (A n)
hA₂ : ∀ (n : ℕ), ↑↑(singularPart (μn n) (νn n)) (A n) = 0
hA₃ : ∀ (n : ℕ), ↑↑(νn n) (A n)ᶜ = 0
⊢ (sum fun n => singularPart (μn n) (νn n)) ⟂ₘ ν

Next tactic:
refine' ⟨⋃ j, S.set j ∩ A j, MeasurableSet.iUnion fun n => (S.set_mem n).inter (hA₁ n), _, _⟩