-- Mathlib/MeasureTheory/Integral/Layercake.lean
theorem Integrable.integral_eq_integral_meas_lt
    (f_intble : Integrable f μ) (f_nn : 0 ≤ᵐ[μ] f) :
    ∫ ω, f ω ∂μ = ∫ t in Set.Ioi 0, ENNReal.toReal (μ {a : α | t < f a})

Proof state:
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
aux :
  ∫ (a : ℝ) in Ioi 0, (μ {a_1 | a < f a_1}).toReal =
    (∫⁻ (a : ℝ) in Ioi 0, ENNReal.ofReal (μ {a_1 | a < f a_1}).toReal).toReal
⊢ ∀ x ∈ Ioi 0, ENNReal.ofReal (μ {a | x < f a}).toReal = μ {a | x < f a}

Tactic:
exact fun t t_pos ↦ ENNReal.ofReal_toReal (rhs_integrand_finite t t_pos).ne

Result:
no goals

Proof state:
case h.e'_3.refine_1
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
⊢ 0 ≤ᶠ[ae (volume.restrict (Ioi 0))] fun t => (μ {a | t < f a}).toReal

Tactic:
exact Eventually.of_forall (fun x ↦ by simp only [Pi.zero_apply, ENNReal.toReal_nonneg])

Result:
no goals

Proof state:
case h.e'_3.refine_2.hf
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
⊢ Measurable fun t => (μ {a | t < f a}).toReal

Tactic:
refine Measurable.ennreal_toReal ?_

Result:
case h.e'_3.refine_2.hf
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
⊢ Measurable fun t => μ {a | t < f a}

Proof state:
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
⊢ ∫ (ω : α), f ω ∂μ = ∫ (t : ℝ) in Ioi 0, (μ {a | t < f a}).toReal

Tactic:
have rhs_finite : ∫⁻ (t : ℝ) in Set.Ioi 0, μ {a | t < f a} < ∞ := by simp only [← key, lhs_finite]

Result:
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
⊢ ∫ (ω : α), f ω ∂μ = ∫ (t : ℝ) in Ioi 0, (μ {a | t < f a}).toReal

Proof state:
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
x : ℝ
⊢ 0 x ≤ (fun t => (μ {a | t < f a}).toReal) x

Tactic:
simp only [Pi.zero_apply, ENNReal.toReal_nonneg]

Result:
no goals

Proof state:
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
⊢ ∫ (ω : α), f ω ∂μ = ∫ (t : ℝ) in Ioi 0, (μ {a | t < f a}).toReal

Tactic:
convert (ENNReal.toReal_eq_toReal lhs_finite.ne rhs_finite.ne).mpr key

Result:
case h.e'_2
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
⊢ ∫ (ω : α), f ω ∂μ = (∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ).toReal

case h.e'_3
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
⊢ ∫ (t : ℝ) in Ioi 0, (μ {a | t < f a}).toReal = (∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}).toReal

Proof state:
case h.e'_2
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
⊢ ∫ (ω : α), f ω ∂μ = (∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ).toReal

Tactic:
exact integral_eq_lintegral_of_nonneg_ae f_nn f_intble.aestronglyMeasurable

Result:
no goals

Proof state:
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
⊢ ∫ (ω : α), f ω ∂μ = ∫ (t : ℝ) in Ioi 0, (μ {a | t < f a}).toReal

Tactic:
have key := lintegral_eq_lintegral_meas_lt μ f_nn f_intble.aemeasurable

Result:
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
⊢ ∫ (ω : α), f ω ∂μ = ∫ (t : ℝ) in Ioi 0, (μ {a | t < f a}).toReal

Proof state:
case h.e'_3.refine_3
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
aux :
  ∫ (a : ℝ) in Ioi 0, (μ {a_1 | a < f a_1}).toReal =
    (∫⁻ (a : ℝ) in Ioi 0, ENNReal.ofReal (μ {a_1 | a < f a_1}).toReal).toReal
⊢ (∫⁻ (a : ℝ) in Ioi 0, ENNReal.ofReal (μ {a_1 | a < f a_1}).toReal).toReal =
    (∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}).toReal

Tactic:
congr 1

Result:
case h.e'_3.refine_3.e_a
α : Type u_1
inst✝ : MeasurableSpace α
μ : Measure α
f : α → ℝ
f_intble : Integrable f μ
f_nn : 0 ≤ᶠ[ae μ] f
key : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}
lhs_finite : ∫⁻ (ω : α), ENNReal.ofReal (f ω) ∂μ < ⊤
rhs_finite : ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a} < ⊤
rhs_integrand_finite : ∀ t > 0, μ {a | t < f a} < ⊤
aux :
  ∫ (a : ℝ) in Ioi 0, (μ {a_1 | a < f a_1}).toReal =
    (∫⁻ (a : ℝ) in Ioi 0, ENNReal.ofReal (μ {a_1 | a < f a_1}).toReal).toReal
⊢ ∫⁻ (a : ℝ) in Ioi 0, ENNReal.ofReal (μ {a_1 | a < f a_1}).toReal = ∫⁻ (t : ℝ) in Ioi 0, μ {a | t < f a}