-- Mathlib/MeasureTheory/Integral/Bochner.lean
theorem integral_eq_lintegral_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f)
    (hfm : AEStronglyMeasurable f μ) :
    ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ)

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ AEMeasurable (fun a => ENNReal.ofReal (-f a)) μ

Tactic:
exact measurable_ofReal.comp_aemeasurable hfm.aemeasurable.neg

Result:
no goals

Proof state:
case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ¬Integrable f μ
⊢ 0 = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Tactic:
simp_rw [Integrable, hfm, hasFiniteIntegral_iff_norm, lt_top_iff_ne_top, Ne, true_and,
  Classical.not_not] at hfi

Result:
case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
⊢ 0 = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Proof state:
case pos
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
h_min : ∫⁻ (a : α), ENNReal.ofReal (-f a) ∂μ = 0
⊢ (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal - (∫⁻ (a : α), ENNReal.ofReal (-f a) ∂μ).toReal =
    (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Tactic:
rw [h_min, zero_toReal, _root_.sub_zero]

Result:
no goals

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ ∀ (x : α), 0 ≤ f x → ENNReal.ofReal (-f x) = 0

Tactic:
intro a h

Result:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
a : α
h : 0 ≤ f a
⊢ ENNReal.ofReal (-f a) = 0

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
a : α
h : 0 a ≤ f a
⊢ (fun a => ENNReal.ofReal (f a)) a = (fun a => ENNReal.ofReal ‖f a‖) a

Tactic:
dsimp only

Result:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
a : α
h : 0 a ≤ f a
⊢ ENNReal.ofReal (f a) = ENNReal.ofReal ‖f a‖

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
⊢ ∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ = ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ

Tactic:
refine lintegral_congr_ae (hf.mono fun a h => ?_)

Result:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
a : α
h : 0 a ≤ f a
⊢ (fun a => ENNReal.ofReal (f a)) a = (fun a => ENNReal.ofReal ‖f a‖) a

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ ∀ (x : α), 0 x ≤ f x → (fun a => ENNReal.ofReal (-f a)) x = 0 x

Tactic:
simp only [Pi.zero_apply]

Result:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ ∀ (x : α), 0 ≤ f x → ENNReal.ofReal (-f x) = 0

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ ∫⁻ (a : α), ENNReal.ofReal (-f a) ∂μ = 0

Tactic:
rw [lintegral_eq_zero_iff']

Result:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ (fun a => ENNReal.ofReal (-f a)) =ᶠ[ae μ] 0

α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ AEMeasurable (fun a => ENNReal.ofReal (-f a)) μ

Proof state:
case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ¬Integrable f μ
⊢ ∫ (a : α), f a ∂μ = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Tactic:
rw [integral_undef hfi]

Result:
case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ¬Integrable f μ
⊢ 0 = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Proof state:
case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
⊢ 0 = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Tactic:
have : ∫⁻ a : α, ENNReal.ofReal (f a) ∂μ = ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ := by
  refine lintegral_congr_ae (hf.mono fun a h => ?_)
  dsimp only
  rw [Real.norm_eq_abs, abs_of_nonneg h]

Result:
case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
this : ∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ = ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ
⊢ 0 = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Proof state:
case pos
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ ∫ (a : α), f a ∂μ = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Tactic:
rw [integral_eq_lintegral_pos_part_sub_lintegral_neg_part hfi]

Result:
case pos
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal - (∫⁻ (a : α), ENNReal.ofReal (-f a) ∂μ).toReal =
    (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Proof state:
case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
this : ∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ = ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ
⊢ 0 = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Tactic:
rw [this, hfi, top_toReal]

Result:
no goals

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ∫⁻ (a : α), ENNReal.ofReal ‖f a‖ ∂μ = ⊤
a : α
h : 0 a ≤ f a
⊢ ENNReal.ofReal (f a) = ENNReal.ofReal ‖f a‖

Tactic:
rw [Real.norm_eq_abs, abs_of_nonneg h]

Result:
no goals

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
⊢ ∫ (a : α), f a ∂μ = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Tactic:
by_cases hfi : Integrable f μ

Result:
case pos
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ ∫ (a : α), f a ∂μ = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

case neg
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : ¬Integrable f μ
⊢ ∫ (a : α), f a ∂μ = (∫⁻ (a : α), ENNReal.ofReal (f a) ∂μ).toReal

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
a : α
h : 0 ≤ f a
⊢ ENNReal.ofReal (-f a) = 0

Tactic:
simp only [h, neg_nonpos, ofReal_eq_zero]

Result:
no goals

Proof state:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ (fun a => ENNReal.ofReal (-f a)) =ᶠ[ae μ] 0

Tactic:
refine hf.mono ?_

Result:
α : Type u_1
m : MeasurableSpace α
μ : Measure α
f : α → ℝ
hf : 0 ≤ᶠ[ae μ] f
hfm : AEStronglyMeasurable f μ
hfi : Integrable f μ
⊢ ∀ (x : α), 0 x ≤ f x → (fun a => ENNReal.ofReal (-f a)) x = 0 x