/-- The (Bochner) integral of the product of two independent, integrable random
  variables is the product of their integrals. The proof is pedestrian decomposition
  into their positive and negative parts in order to apply `IndepFun.integral_mul_of_nonneg`
  four times. -/
theorem IndepFun.integral_mul_of_integrable (hXY : IndepFun X Y μ) (hX : Integrable X μ)
    (hY : Integrable Y μ) : integral μ (X * Y) = integral μ X * integral μ Y := by
  let pos : ℝ → ℝ := fun x => max x 0
  let neg : ℝ → ℝ := fun x => max (-x) 0
  have posm : Measurable pos := measurable_id'.max measurable_const
  have negm : Measurable neg := measurable_id'.neg.max measurable_const
  let Xp := pos ∘ X
  -- `X⁺` would look better but it makes `simp_rw` below fail
  let Xm := neg ∘ X
  let Yp := pos ∘ Y
  let Ym := neg ∘ Y
  have hXpm : X = Xp - Xm := funext fun ω => (max_zero_sub_max_neg_zero_eq_self (X ω)).symm
  have hYpm : Y = Yp - Ym := funext fun ω => (max_zero_sub_max_neg_zero_eq_self (Y ω)).symm
  have hp1 : 0 ≤ Xm := fun ω => le_max_right _ _
  have hp2 : 0 ≤ Xp := fun ω => le_max_right _ _
  have hp3 : 0 ≤ Ym := fun ω => le_max_right _ _
  have hp4 : 0 ≤ Yp := fun ω => le_max_right _ _
  have hm1 : AEMeasurable Xm μ := hX.1.aemeasurable.neg.max aemeasurable_const
  have hm2 : AEMeasurable Xp μ := hX.1.aemeasurable.max aemeasurable_const
  have hm3 : AEMeasurable Ym μ := hY.1.aemeasurable.neg.max aemeasurable_const
  have hm4 : AEMeasurable Yp μ := hY.1.aemeasurable.max aemeasurable_const
  have hv1 : Integrable Xm μ := hX.neg_part
  have hv2 : Integrable Xp μ := hX.pos_part
  have hv3 : Integrable Ym μ := hY.neg_part
  have hv4 : Integrable Yp μ := hY.pos_part
  have hi1 : IndepFun Xm Ym μ := hXY.comp negm negm
  have hi2 : IndepFun Xp Ym μ := hXY.comp posm negm
  have hi3 : IndepFun Xm Yp μ := hXY.comp negm posm
  have hi4 : IndepFun Xp Yp μ := hXY.comp posm posm
  have hl1 : Integrable (Xm * Ym) μ := hi1.integrable_mul hv1 hv3
  have hl2 : Integrable (Xp * Ym) μ := hi2.integrable_mul hv2 hv3
  have hl3 : Integrable (Xm * Yp) μ := hi3.integrable_mul hv1 hv4
  have hl4 : Integrable (Xp * Yp) μ := hi4.integrable_mul hv2 hv4
  have hl5 : Integrable (Xp * Yp - Xm * Yp) μ := hl4.sub hl3
  have hl6 : Integrable (Xp * Ym - Xm * Ym) μ := hl2.sub hl1
  

Proof state:
Ω : Type u_1
mΩ : MeasurableSpace Ω
μ : Measure Ω
f g : Ω → ℝ≥0∞
X Y : Ω → ℝ
hXY : IndepFun X Y
hX : Integrable X
hY : Integrable Y
pos : ℝ → ℝ := fun x => max x 0
neg : ℝ → ℝ := fun x => max (-x) 0
posm : Measurable pos
negm : Measurable neg
Xp : Ω → ℝ := pos ∘ X
Xm : Ω → ℝ := neg ∘ X
Yp : Ω → ℝ := pos ∘ Y
Ym : Ω → ℝ := neg ∘ Y
hXpm : X = Xp - Xm
hYpm : Y = Yp - Ym
hp1 : 0 ≤ Xm
hp2 : 0 ≤ Xp
hp3 : 0 ≤ Ym
hp4 : 0 ≤ Yp
hm1 : AEMeasurable Xm
hm2 : AEMeasurable Xp
hm3 : AEMeasurable Ym
hm4 : AEMeasurable Yp
hv1 : Integrable Xm
hv2 : Integrable Xp
hv3 : Integrable Ym
hv4 : Integrable Yp
hi1 : IndepFun Xm Ym
hi2 : IndepFun Xp Ym
hi3 : IndepFun Xm Yp
hi4 : IndepFun Xp Yp
hl1 : Integrable (Xm * Ym)
hl2 : Integrable (Xp * Ym)
hl3 : Integrable (Xm * Yp)
hl4 : Integrable (Xp * Yp)
hl5 : Integrable (Xp * Yp - Xm * Yp)
hl6 : Integrable (Xp * Ym - Xm * Ym)
⊢ integral μ (X * Y) = integral μ X * integral μ Y

Next tactic:
rw [hXpm, hYpm, mul_sub, sub_mul, sub_mul]