-- Mathlib/MeasureTheory/Function/ConditionalExpectation/Indicator.lean
theorem condExp_indicator (hf_int : Integrable f μ) (hs : MeasurableSet[m] s) :
    μ[s.indicator f|m] =ᵐ[μ] s.indicator (μ[f|m])

Proof state:
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝ : SigmaFinite (μ.trim hm)
this : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
⊢ s.indicator (μ[s.indicator f|m]) + s.indicator (μ[sᶜ.indicator f|m]) =ᶠ[ae μ]
    s.indicator (μ[s.indicator f|m]) + s.indicator (sᶜ.indicator (μ[sᶜ.indicator f|m]))

Tactic:
refine Filter.EventuallyEq.rfl.add ?_

Result:
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝ : SigmaFinite (μ.trim hm)
this : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
⊢ s.indicator (μ[sᶜ.indicator f|m]) =ᶠ[ae μ] s.indicator (sᶜ.indicator (μ[sᶜ.indicator f|m]))

Proof state:
case pos
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this : SigmaFinite (μ.trim hm)
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

Tactic:
have : s.indicator (μ[f|m]) =ᵐ[μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m]) := by
  rw [Set.indicator_self_add_compl s f]

Result:
case pos
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝ : SigmaFinite (μ.trim hm)
this : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

Proof state:
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝ : SigmaFinite (μ.trim hm)
this : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
⊢ sᶜ.indicator (μ[sᶜ.indicator f|m]) =ᶠ[ae μ] μ[sᶜ.indicator f|m]

Tactic:
refine (condExp_indicator_aux hs.compl ?_).symm.trans ?_

Result:
case refine_1
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝ : SigmaFinite (μ.trim hm)
this : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
⊢ sᶜ.indicator f =ᶠ[ae (μ.restrict sᶜᶜ)] 0

case refine_2
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝ : SigmaFinite (μ.trim hm)
this : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
⊢ μ[sᶜ.indicator (sᶜ.indicator f)|m] =ᶠ[ae μ] μ[sᶜ.indicator f|m]

Proof state:
case neg
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝¹ : SigmaFinite (μ.trim hm)
this✝ : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
this : sᶜ.indicator (μ[sᶜ.indicator f|m]) =ᶠ[ae μ] μ[sᶜ.indicator f|m]
x : α
hx : sᶜ.indicator (μ[sᶜ.indicator f|m]) x = (μ[sᶜ.indicator f|m]) x
hxs : x ∉ s
⊢ s.indicator (μ[sᶜ.indicator f|m]) x = s.indicator (sᶜ.indicator (μ[sᶜ.indicator f|m])) x

Tactic:
simp only [hxs, Set.indicator_of_not_mem, not_false_iff]

Result:
no goals

Proof state:
case pos
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm : SigmaFinite (μ.trim hm)
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

case neg
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm : ¬SigmaFinite (μ.trim hm)
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

Tactic:
swap

Result:
case neg
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm : ¬SigmaFinite (μ.trim hm)
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

case pos
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm : SigmaFinite (μ.trim hm)
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

Proof state:
case neg
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm : ¬SigmaFinite (μ.trim hm)
⊢ 0 =ᶠ[ae μ] 0

Tactic:
rfl

Result:
no goals

Proof state:
case pos
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

Tactic:
by_cases hμm : SigmaFinite (μ.trim hm)

Result:
case pos
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm : SigmaFinite (μ.trim hm)
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

case neg
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm : ¬SigmaFinite (μ.trim hm)
⊢ μ[s.indicator f|m] =ᶠ[ae μ] s.indicator (μ[f|m])

Proof state:
case refine_1
α : Type u_1
E : Type u_2
m m0 : MeasurableSpace α
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
μ : Measure α
f : α → E
s : Set α
hf_int : Integrable f μ
hs : MeasurableSet s
hm : m ≤ m0
hμm this✝ : SigmaFinite (μ.trim hm)
this : s.indicator (μ[f|m]) =ᶠ[ae μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m])
⊢ sᶜ.indicator f =ᶠ[ae (μ.restrict sᶜᶜ)] 0

Tactic:
exact indicator_ae_eq_restrict_compl (hm _ hs.compl)

Result:
no goals