-- Mathlib/MeasureTheory/Integral/Average.lean
theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
    (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
    ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ]

Proof state:
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
⊢ ⨍⁻ (x : α) in s ∪ t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

Tactic:
by_cases hs₀ : μ s = 0

Result:
case pos
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : μ s = 0
⊢ ⨍⁻ (x : α) in s ∪ t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

case neg
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : ¬μ s = 0
⊢ ⨍⁻ (x : α) in s ∪ t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

Proof state:
case neg
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : ¬μ s = 0
⊢ μ s / (μ s + μ t) + μ t / (μ s + μ t) = 1

Tactic:
rw [← ENNReal.add_div,
  ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]

Result:
no goals

Proof state:
case pos
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : s =ᶠ[ae μ] ∅
⊢ ⨍⁻ (x : α) in s ∪ t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

Tactic:
rw [restrict_congr_set (hs₀.union EventuallyEq.rfl), empty_union]

Result:
case pos
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : s =ᶠ[ae μ] ∅
⊢ ⨍⁻ (x : α) in t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

Proof state:
case neg
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : ¬μ s = 0
⊢ ⨍⁻ (x : α) in s ∪ t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

Tactic:
refine
  ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), zero_le _, zero_le _, ?_, (laverage_union hd ht).symm⟩

Result:
case neg
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : ¬μ s = 0
⊢ μ s / (μ s + μ t) + μ t / (μ s + μ t) = 1

Proof state:
case pos
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : s =ᶠ[ae μ] ∅
⊢ ⨍⁻ (x : α) in t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

Tactic:
exact right_mem_segment _ _ _

Result:
no goals

Proof state:
case pos
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : μ s = 0
⊢ ⨍⁻ (x : α) in s ∪ t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]

Tactic:
rw [← ae_eq_empty] at hs₀

Result:
case pos
α : Type u_1
m0 : MeasurableSpace α
μ : Measure α
s t : Set α
f : α → ℝ≥0∞
hd : AEDisjoint μ s t
ht : NullMeasurableSet t μ
hsμ : μ s ≠ ⊤
htμ : μ t ≠ ⊤
hs₀ : s =ᶠ[ae μ] ∅
⊢ ⨍⁻ (x : α) in s ∪ t, f x ∂μ ∈ [⨍⁻ (x : α) in s, f x ∂μ-[ℝ≥0∞]⨍⁻ (x : α) in t, f x ∂μ]