Mathlib.Probability.Independence
Independence — Mathlib-shaped helpers: Basic, Conditional, Integral.
Basic 5 core · 10 supporting This file develops generic independence and conditional-independence facts for finite coordinate projections under product measures. ★ condIndepFun_pi_cond_residual_of_disjoint★ condIndepFun_pi_of_inter_subset
Independence Helpers for Product Coordinates
This file develops generic independence and conditional-independence facts for finite coordinate projections under product measures. The results are Mathlib-adjacent and do not depend on any model-specific definitions.
Main coordinate maps:
* finsetCoordProj S projects a dependent product to the coordinates indexed by
a finite set S.
* finsetCoordProjFromCondResidual S U reassembles the coordinates on S from
the conditioning block U and the residual block S \ U.
* finsetCoordProjPairFromUnion A B extracts the A and B sub-blocks from
their union.
Main results:
* indepFun_pi_of_disjoint proves independence of disjoint coordinate blocks
under a finite product measure.
* condIndepFun_bot_of_indepFun lifts ordinary independence to conditional
independence given the trivial σ-algebra.
* condIndepFun_pi_cond_residual_of_disjoint gives conditional independence of
two residual coordinate blocks after conditioning on a common block.
* condIndepFun_pi_of_inter_subset is the public finite-product criterion:
coordinate blocks on S and T are conditionally independent given U when
S ∩ T ⊆ U.
* comap_eq_bot_of_subsingleton, indepFun_of_map, and
condIndepFun_of_indepFun_indep provide small σ-algebra and pushforward
bridges used around the product-coordinate statements.
Given an index collection, a family of coordinate value spaces, and a finite coordinate block, the coordinate-block projection maps a full coordinate assignment to the assignment obtained by retaining exactly the coordinates in that block.
Definition (Lean source)
Given an index collection whose equality is decidable, a family of coordinate value spaces, a target coordinate block, and a conditioning block, the residual-reassembly map reconstructs an assignment on the target block from an assignment on the conditioning block and an assignment on those target coordinates outside that block.
Definition (Lean source)
Given an index collection whose equality is decidable, a family of coordinate value spaces, a first finite coordinate block, and a second finite coordinate block, the union-sub-block extraction map maps an assignment on their union to the pair of its restrictions to the first and second blocks.
Definition (Lean source)
For a finite index set, a family of standard Borel probability spaces indexed by it, and finite subsets S0, T0, U of the index set, if S0 and T0 are disjoint from each other and S0 is disjoint from U, then under the product probability measure, the pair consisting of the U-coordinates and the S0-coordinates is conditionally independent of the pair consisting of the U-coordinates and the T0-coordinates, given the σ-algebra generated by the U-coordinates.
Formal statement
Proof (Lean source)
Under a finite product probability measure, if the overlap S ∩ T is contained in the conditioning block U, then the coordinate tuple on S is conditionally independent of the coordinate tuple on T, given the coordinate tuple on U.
Formal statement
Proof (Lean source)
10 supporting declarations (lemmas, instances)
-
indepFun_pi_of_disjointtheorem — Coordinate-tuple projections at disjoint Finsets are IndepFun under Measure.pi of a family of probability measures. This is the binary aggregation of iIndepFun_pi via iIndepFun.indepFun_finset.hypothesesι :Type*Finite ιι → Type*∀ i, MeasurableSpace (Ω i)μ :(i : ι) → Measure (Ω i)∀ i, IsProbabilityMeasure (μ i)S T :Finset ιhST :Disjoint S TconclusionletI : Fintype ιProof (Lean source)
theorem indepFun_pi_of_disjoint {ι : Type*} [Finite ι] {Ω : ι → Type*} [∀ i, MeasurableSpace (Ω i)] (μ : (i : ι) → Measure (Ω i)) [∀ i, IsProbabilityMeasure (μ i)] {S T : Finset ι} (hST : Disjoint S T) : letI : Fintype ι := Fintype.ofFinite ι IndepFun (fun (x : ∀ i, Ω i) (i : {i // i ∈ S}) => x i.val) (fun (x : ∀ i, Ω i) (i : {i // i ∈ T}) => x i.val) (Measure.pi μ) := by letI : Fintype ι := Fintype.ofFinite ι have hiindep : iIndepFun (fun (i : ι) (ω : ∀ j, Ω j) => ω i) (Measure.pi μ) := iIndepFun_pi (X := fun _ (ω : Ω _) => ω) (fun _ => aemeasurable_id) exact hiindep.indepFun_finset S T hST (fun i => measurable_pi_apply i) -
measurable_finsetCoordProjtheorem — finsetCoordProj is measurable.hypothesesconclusionMeasurable (finsetCoordProj (Ω := Ω) S)Proof (Lean source)
@[fun_prop] theorem measurable_finsetCoordProj {ι : Type*} {Ω : ι → Type*} [∀ i, MeasurableSpace (Ω i)] (S : Finset ι) : Measurable (finsetCoordProj (Ω := Ω) S) := by refine measurable_pi_lambda _ ?_ intro i exact measurable_pi_apply i.val -
measurable_finsetCoordProjFromCondResidualtheorem — The residual reassembly map is measurable.hypothesesconclusionMeasurable (finsetCoordProjFromCondResidual (Ω := Ω) S U)Proof (Lean source)
@[fun_prop] theorem measurable_finsetCoordProjFromCondResidual {ι : Type*} [DecidableEq ι] {Ω : ι → Type*} [∀ i, MeasurableSpace (Ω i)] (S U : Finset ι) : Measurable (finsetCoordProjFromCondResidual (Ω := Ω) S U) := by refine measurable_pi_lambda _ ?_ intro i dsimp [finsetCoordProjFromCondResidual] by_cases hiU : i.val ∈ U · let j : {j // j ∈ U} := ⟨i.val, hiU⟩ simpa [hiU, j, Function.comp_def] using (measurable_pi_apply j).comp measurable_fst · let j : {j // j ∈ S \ U} := ⟨i.val, Finset.mem_sdiff.mpr ⟨i.property, hiU⟩⟩ simpa [hiU, j, Function.comp_def] using (measurable_pi_apply j).comp measurable_snd -
finsetCoordProjFromCondResidual_comptheorem — Reassembling π_U with the residual projection π_{S \ U} gives π_S.hypothesesι :S U :Finset ιconclusionfinsetCoordProjFromCondResidual (Ω := Ω) S U ∘ (fun x => (finsetCoordProj (Ω := Ω) U x, finsetCoordProj (Ω := Ω) (S \ U) x))= finsetCoordProj (Ω := Ω) SProof (Lean source)
theorem finsetCoordProjFromCondResidual_comp {ι : Type*} [DecidableEq ι] {Ω : ι → Type*} (S U : Finset ι) : finsetCoordProjFromCondResidual (Ω := Ω) S U ∘ (fun x => (finsetCoordProj (Ω := Ω) U x, finsetCoordProj (Ω := Ω) (S \ U) x)) = finsetCoordProj (Ω := Ω) S := by funext x i dsimp [finsetCoordProjFromCondResidual, finsetCoordProj] by_cases hiU : i.val ∈ U <;> simp [hiU] -
measurable_finsetCoordProjPairFromUniontheorem — The union sub-block extraction map is measurable.hypothesesconclusionMeasurable (finsetCoordProjPairFromUnion (Ω := Ω) A B)Proof (Lean source)
@[fun_prop] theorem measurable_finsetCoordProjPairFromUnion {ι : Type*} [DecidableEq ι] {Ω : ι → Type*} [∀ i, MeasurableSpace (Ω i)] (A B : Finset ι) : Measurable (finsetCoordProjPairFromUnion (Ω := Ω) A B) := by refine (measurable_pi_lambda _ ?_).prod (measurable_pi_lambda _ ?_) · intro i exact measurable_pi_apply (⟨i.val, Finset.mem_union.mpr (inl i.property)⟩ : {j // j ∈ A ∪ B}) · intro i exact measurable_pi_apply (⟨i.val, Finset.mem_union.mpr (inr i.property)⟩ : {j // j ∈ A ∪ B}) -
finsetCoordProjPairFromUnion_comptheorem — Projecting to A ∪ B and then extracting the two sub-blocks gives the pair of direct projections to A and B.hypothesesι :A B :Finset ιconclusionfinsetCoordProjPairFromUnion (Ω := Ω) A B ∘ finsetCoordProj (Ω := Ω) (A ∪ B)= fun x => (finsetCoordProj (Ω := Ω) A x, finsetCoordProj (Ω := Ω) B x)Proof (Lean source)
theorem finsetCoordProjPairFromUnion_comp {ι : Type*} [DecidableEq ι] {Ω : ι → Type*} (A B : Finset ι) : finsetCoordProjPairFromUnion (Ω := Ω) A B ∘ finsetCoordProj (Ω := Ω) (A ∪ B) = fun x => (finsetCoordProj (Ω := Ω) A x, finsetCoordProj (Ω := Ω) B x) := by funext x ext i <;> rfl -
condIndepFun_bot_of_indepFuntheorem — Bridge: if μ is a probability measure on a standard Borel space Ω, then unconditional IndepFun f g μ lifts to CondIndepFun ⊥ bot_le f g μ — conditional independence given the trivial σ-algebra.Proof (Lean source)
theorem condIndepFun_bot_of_indepFun {Ω : Type*} [MeasurableSpace Ω] [StandardBorelSpace Ω] {β γ : Type*} [MeasurableSpace β] [MeasurableSpace γ] {f : Ω → β} {g : Ω → γ} (hf : Measurable f) (hg : Measurable g) {μ : Measure Ω} [IsProbabilityMeasure μ] (h : IndepFun f g μ) : CondIndepFun ⊥ bot_le f g μ := by rw [condIndepFun_iff_condExp_inter_preimage_eq_mul hf hg] intro s t hs ht have hfs : MeasurableSet (f ⁻¹' s) := hf hs have hgt : MeasurableSet (g ⁻¹' t) := hg ht have hfgst : MeasurableSet (f ⁻¹' s ∩ g ⁻¹' t) := hfs.inter hgt have hmst : μ (f ⁻¹' s ∩ g ⁻¹' t) = μ (f ⁻¹' s) * μ (g ⁻¹' t) := h.measure_inter_preimage_eq_mul s t hs ht change condExp ⊥ μ (indicator (f ⁻¹' s ∩ g ⁻¹' t) (1 : Ω → ℝ)) =ᵐ[μ] fun ω => condExp ⊥ μ (indicator (f ⁻¹' s) (1 : Ω → ℝ)) ω * condExp ⊥ μ (indicator (g ⁻¹' t) (1 : Ω → ℝ)) ω rw [condExp_bot (μ := μ) _, condExp_bot (μ := μ) _, condExp_bot (μ := μ) _] refine Filter.Eventually.of_forall fun _ => ?_ simp only [integral_indicator_one hfgst, integral_indicator_one hfs, integral_indicator_one hgt, measureReal_def] rw [hmst, ENNReal.toReal_mul] -
comap_eq_bot_of_subsingletontheorem — The comap σ-algebra of a function into a Subsingleton codomain is the trivial σ-algebra ⊥. Every measurable set in the codomain is either empty or the full space, so every preimage is either ∅ or univ.hypothesesα β :f :α → βconclusionProof (Lean source)
theorem comap_eq_bot_of_subsingleton {α β : Type*} [MeasurableSpace β] [Subsingleton β] (f : α → β) : comap f inferInstance = (⊥ : MeasurableSpace α) := by refine le_antisymm ?_ bot_le rintro s ⟨t, _, rfl⟩ rcases t.eq_empty_or_nonempty with ht | ⟨x, hx⟩ · rw [ht, Set.preimage_empty] exact (MeasurableSpace.measurableSet_bot_iff).mpr (inl rfl) · have hpre : f ⁻¹' t = univ := by ext ω refine ⟨fun _ => trivial, fun _ => ?_⟩ have : f ω = x := Subsingleton.elim _ _ simp only [Set.mem_preimage, this, hx] rw [hpre] exact (MeasurableSpace.measurableSet_bot_iff).mpr (inr rfl) -
indepFun_of_maptheorem — Pushforward bridge for IndepFun: if X ∘ φ ⟂ᵢ Y ∘ φ under ν, then X ⟂ᵢ Y under ν.map φ. The conditional-independence analogue is Causalean.Mathlib.Probability.Independence.Conditional.condIndepFun_of_map.hypothesesconclusionIndepFun X Y (ν.map φ)Proof (Lean source)
theorem indepFun_of_map {α β γ δ : Type*} [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ] [MeasurableSpace δ] {ν : Measure α} {φ : α → β} (hφ : AEMeasurable φ ν) {X : β → γ} (hX : Measurable X) {Y : β → δ} (hY : Measurable Y) (h : IndepFun (X ∘ φ) (Y ∘ φ) ν) : IndepFun X Y (ν.map φ) := by rw [indepFun_iff_measure_inter_preimage_eq_mul] at h ⊢ intro s t hs ht rw [Measure.map_apply_of_aemeasurable hφ ((hX hs).inter (hY ht)), Measure.map_apply_of_aemeasurable hφ (hX hs), Measure.map_apply_of_aemeasurable hφ (hY ht)] have := h s t hs ht simp only [Set.preimage_comp] at this exact this -
condIndepFun_of_indepFun_indeptheorem — If X and Y are independent, and the joint (X, Y) is independent of the conditioning variable Z, then X and Y are conditionally independent given the σ-algebra generated by Z.hypothesesconclusionProof (Lean source)
theorem condIndepFun_of_indepFun_indep {Ω β γ δ : Type*} [MeasurableSpace Ω] [StandardBorelSpace Ω] [MeasurableSpace β] [MeasurableSpace γ] [MeasurableSpace δ] {μ : Measure Ω} [IsProbabilityMeasure μ] {X : Ω → β} {Y : Ω → γ} {Z : Ω → δ} (hX : Measurable X) (hY : Measurable Y) (_hZ : Measurable Z) (hXY : IndepFun X Y μ) (hindep : Indep (comap (fun ω => (X ω, Y ω)) inferInstance) (comap Z inferInstance) μ) : CondIndepFun (comap Z inferInstance) _hZ.comap_le X Y μ := by have hle₂ : comap Z inferInstance ≤ (inferInstance : MeasurableSpace Ω) := _hZ.comap_le have hXYmeas : Measurable (fun ω => (X ω, Y ω)) := by fun_prop have hle₁ : comap (fun ω => (X ω, Y ω)) inferInstance ≤ (inferInstance : MeasurableSpace Ω) := hXYmeas.comap_le rw [condIndepFun_iff_condExp_inter_preimage_eq_mul hX hY] intro s t hs ht have hAs : MeasurableSet[comap (fun ω => (X ω, Y ω)) inferInstance] (X ⁻¹' s) := by refine ⟨(s ×ˢ Set.univ : Set (β × γ)), hs.prod MeasurableSet.univ, ?_⟩ ext ω; simp have hAt : MeasurableSet[comap (fun ω => (X ω, Y ω)) inferInstance] (Y ⁻¹' t) := by refine ⟨(Set.univ ×ˢ t : Set (β × γ)), MeasurableSet.univ.prod ht, ?_⟩ ext ω; simp have hAst := hAs.inter hAt have hconst : ∀ {A : Set Ω}, MeasurableSet[comap (fun ω => (X ω, Y ω)) inferInstance] A → (μ⟦A | comap Z inferInstance⟧) =ᵐ[μ] fun _ => (μ A).toReal := by intro A hA have hsm : StronglyMeasurable[comap (fun ω => (X ω, Y ω)) inferInstance] (A.indicator (fun _ : Ω => (1 : ℝ))) := stronglyMeasurable_const.indicator hA have hmain := condExp_indep_eq hle₁ hle₂ hsm hindep refine hmain.trans ?_ refine Filter.Eventually.of_forall fun ω => ?_ have hAmeas : MeasurableSet A := hle₁ _ hA simp only [] rw [show (A.indicator (fun _ : Ω => (1 : ℝ))) = A.indicator 1 from rfl, integral_indicator_one hAmeas, measureReal_def] have h1 := hconst hAst have h2 := hconst hAs have h3 := hconst hAt have hmul := hXY.measure_inter_preimage_eq_mul s t hs ht filter_upwards [h1, h2, h3] with ω e1 e2 e3 rw [e1, e2, e3, hmul, ENNReal.toReal_mul]
Integral 1 core · 0 supporting This file proves a drop-of-conditioning identity for independent random variables: integrating a function of one variable over an event determined by an independent variable factors into the event's measure times the ful ★ integral_restrict_preimage_eq_mul
Integrals Under Independent Variables
This file proves a drop-of-conditioning identity for independent random variables: integrating a function of one variable over an event determined by an independent variable factors into the event's measure times the full integral.
Drop of conditioning. For random elements f and g that are independent, with f almost-everywhere measurable and g almost-everywhere measurable, given a measurable set E whose preimage f ⁻¹' E is measurable, and a function h that is almost-everywhere strongly measurable with respect to the pushforward measure of g, then restricting the integral of h ∘ g to the event f ⁻¹' E equals the measure of that event times the unrestricted integral of h ∘ g.
Formal statement
Proof (Lean source)
Pair 1 core · 1 supporting This module transports indexed independence across a product probability space: two independent families on separate samples become independent after their corresponding coordinates are paired. ★ iIndepFun_pair_prod
Paired independent families
This module transports indexed independence across a product probability space: two independent families on separate samples become independent after their corresponding coordinates are paired.
Given two probability spaces, a measurable indexed family of observations on the first, a measurable family with the same index set on the second, mutual independence of the first family under its probability law, and mutual independence of the second family under its probability law, the index-by-index pairs of observations form a mutually independent family under the product of the two probability laws.
Formal statement
Proof (Lean source)
1 supporting declaration (lemmas, instances)
-
map_pair_infinitePi_prodtheorem — Given an indexed collection of probability laws on the first value space and an indexed collection of probability laws on the second value space, pairing the corresponding coordinates sends the product of their array laws to the array law with coordinatewise product factors.hypothesesJ :sharedType u_1A :sharedType u_4B :sharedType u_5μj :J → Measure Aνj :J → Measure B∀ j, IsProbabilityMeasure (μj j)∀ j, IsProbabilityMeasure (νj j)conclusionMeasure.map (fun p : (J → A) × (J → B) => fun j => (p.1 j, p.2 j)) ((infinitePi μj).prod (infinitePi νj))= infinitePi (fun j => (μj j).prod (νj j))Proof (Lean source)
theorem map_pair_infinitePi_prod (μj : J → Measure A) (νj : J → Measure B) [∀ j, IsProbabilityMeasure (μj j)] [∀ j, IsProbabilityMeasure (νj j)] : Measure.map (fun p : (J → A) × (J → B) => fun j => (p.1 j, p.2 j)) ((infinitePi μj).prod (infinitePi νj)) = infinitePi (fun j => (μj j).prod (νj j)) := by classical apply eq_infinitePi intro s t ht have hfinite : Measure.map (fun p : (J → A) × (J → B) => fun j : s => (p.1 j, p.2 j)) ((infinitePi μj).prod (infinitePi νj)) = Measure.pi (fun j : s => (μj j).prod (νj j)) := by have hprod := Measure.map_prod_map (infinitePi μj) (infinitePi νj) (Finset.measurable_restrict s) (Finset.measurable_restrict s) rw [infinitePi_map_restrict, infinitePi_map_restrict] at hprod have hpair := (measurePreserving_arrowProdEquivProdArrow A B s (fun j : s => μj j) (fun j : s => νj j)).symm.map_eq calc _ = Measure.map (fun q : (s → A) × (s → B) => fun j => (q.1 j, q.2 j)) (Measure.map (map (s.restrict : (J → A) → (s → A)) (s.restrict : (J → B) → (s → B))) ((infinitePi μj).prod (infinitePi νj))) := by rw [map_map (by fun_prop) (by fun_prop)] rfl _ = Measure.map (fun q : (s → A) × (s → B) => fun j => (q.1 j, q.2 j)) ((Measure.pi (fun j : s => μj j)).prod (Measure.pi (fun j : s => νj j))) := by rw [← hprod] _ = _ := by simpa [MeasurableEquiv.arrowProdEquivProdArrow, Equiv.arrowProdEquivProdArrow] using hpair calc _ = (Measure.pi (fun j : s => (μj j).prod (νj j))) (Set.univ.pi (fun j : s => t j)) := by rw [← hfinite] rw [map_apply (by fun_prop) (.pi s.countable_toSet fun _ _ => ht _)] rw [map_apply (by fun_prop) (.pi Set.countable_univ fun _ _ => ht _)] congr 1 ext p simp [Set.mem_pi] _ = ∏ j : s, ((μj j).prod (νj j)) (t j) := by rw [Measure.pi_pi] _ = ∏ j ∈ s, ((μj j).prod (νj j)) (t j) := by simpa using (Finset.prod_attach s (fun j => ((μj j).prod (νj j)) (t j)))