File size: 1,378 Bytes
bf6216d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | module
public import Mathlib.Probability.ConditionalProbability
public import PFR.ForMathlib.FiniteRange.Defs
public section
open MeasureTheory Set
namespace ProbabilityTheory
variable {Ω α : Type*} {m : MeasurableSpace Ω} (μ : Measure Ω)
[MeasurableSpace α] [MeasurableSingletonClass α]
-- TODO: Replace `sum_meas_smul_cond_fiber` once `FiniteRange` is in Mathlib.
/-- The **law of total probability** for a random variable taking finitely many values: a measure
`μ` can be expressed as a linear combination of its conditional measures `μ[|X ← x]` on fibers of a
random variable `X` valued in a fintype. -/
lemma sum_meas_smul_cond_fiber' {X : Ω → α} (hX : Measurable X) [finX : FiniteRange X]
(μ : Measure Ω) [IsFiniteMeasure μ] :
∑ x ∈ finX.toFinset, μ (X ⁻¹' {x}) • μ[|X ← x] = μ := by
ext E hE
calc
_ = ∑ x ∈ finX.toFinset, μ (X ⁻¹' {x} ∩ E) := by
simp only [FunLike.coe_sum, FunLike.coe_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul]
simp_rw [mul_comm (μ _), cond_mul_eq_inter (hX (.singleton _))]
_ = _ := by
have : ⋃ x ∈ finX.toFinset, X ⁻¹' {x} ∩ E = E := by ext _; simp
rw [← measure_biUnion_finset _ fun _ _ ↦ (hX (.singleton _)).inter hE, this]
aesop (add simp [PairwiseDisjoint, Set.Pairwise, Function.onFun, disjoint_left])
end ProbabilityTheory
|