@@ -790,6 +790,103 @@ lemma condIndepFun_iff_map_prod_eq_prod_comp_trim
790790 rfl
791791 · rw [Measure.compProd_eq_comp_prod]
792792
793+ /-- Two random variables `f, g` are conditionally independent given a third `k` iff the
794+ joint distribution of `k, f, g` factors into a product of their conditional distributions
795+ given `k`. -/
796+ theorem condIndepFun_iff_map_prod_eq_prod_condDistrib_prod_condDistrib
797+ {γ : Type *} {mγ : MeasurableSpace γ} {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
798+ [StandardBorelSpace β] [Nonempty β] [StandardBorelSpace β'] [Nonempty β']
799+ (hf : Measurable f) (hg : Measurable g) {k : Ω → γ} (hk : Measurable k) :
800+ CondIndepFun _ hk.comap_le f g μ ↔
801+ μ.map (fun ω ↦ (k ω, f ω, g ω)) =
802+ (Kernel.id ×ₖ (condDistrib f k μ ×ₖ condDistrib g k μ)) ∘ₘ μ.map k := by
803+ rw [condIndepFun_iff_map_prod_eq_prod_comp_trim hf hg]
804+ simp_rw [Measure.ext_prod₃_iff]
805+ have hk_meas {s : Set γ} (hs : MeasurableSet s) : MeasurableSet[mγ.comap k] (k ⁻¹' s) :=
806+ ⟨s, hs, rfl⟩
807+ have h_left {s : Set γ} {t : Set β} {u : Set β'} (hs : MeasurableSet s) (ht : MeasurableSet t)
808+ (hu : MeasurableSet u) :
809+ (μ.map (fun ω ↦ (k ω, f ω, g ω))) (s ×ˢ t ×ˢ u) =
810+ (@Measure.map _ _ _ ((mγ.comap k).prod inferInstance)
811+ (fun ω ↦ (ω, f ω, g ω)) μ) ((k ⁻¹' s) ×ˢ t ×ˢ u) := by
812+ rw [Measure.map_apply (by fun_prop) (hs.prod (ht.prod hu)),
813+ Measure.map_apply _ ((hk_meas hs).prod (ht.prod hu))]
814+ · simp [Set.mk_preimage_prod]
815+ · exact (measurable_id.mono le_rfl hk.comap_le).prodMk (by fun_prop)
816+ have h_right {s : Set γ} {t : Set β} {u : Set β'} (hs : MeasurableSet s) (ht : MeasurableSet t)
817+ (hu : MeasurableSet u) :
818+ ((Kernel.id ×ₖ (condDistrib f k μ ×ₖ condDistrib g k μ)) ∘ₘ μ.map k) (s ×ˢ t ×ˢ u) =
819+ ((Kernel.id ×ₖ
820+ ((condExpKernel μ (mγ.comap k)).map f ×ₖ (condExpKernel μ (mγ.comap k)).map g)) ∘ₘ
821+ μ.trim hk.comap_le) ((k ⁻¹' s) ×ˢ t ×ˢ u) := by
822+ rw [Measure.bind_apply ((hk_meas hs).prod (ht.prod hu)) (by fun_prop),
823+ Measure.bind_apply (hs.prod (ht.prod hu)) (by fun_prop), lintegral_map ?_ (by fun_prop),
824+ lintegral_trim]
825+ rotate_left
826+ · exact Kernel.measurable_coe _ ((hk_meas hs).prod (ht.prod hu))
827+ · exact Kernel.measurable_coe _ (hs.prod (ht.prod hu))
828+ refine lintegral_congr_ae ?_
829+ filter_upwards [condDistrib_apply_ae_eq_condExpKernel_map hf hk ht,
830+ condDistrib_apply_ae_eq_condExpKernel_map hg hk hu] with a haX haT
831+ simp only [Kernel.prod_apply_prod, Kernel.id_apply, Measure.dirac_apply' _ hs]
832+ rw [@Measure.dirac_apply' _ (mγ.comap k) _ _ (hk_meas hs)]
833+ congr
834+ refine ⟨fun h s t u hs ht hu ↦ ?_, fun h ↦ ?_⟩
835+ · convert h (hk_meas hs) ht hu
836+ · exact h_left hs ht hu
837+ · exact h_right hs ht hu
838+ · rintro - t u ⟨s, hs, rfl⟩ ht hu
839+ convert h hs ht hu
840+ · exact (h_left hs ht hu).symm
841+ · exact (h_right hs ht hu).symm
842+
843+ /-- Two random variables `f, g` are conditionally independent given a third `k` iff the
844+ conditional distribution of `f` given `k` and `g` is equal to the conditional distribution of `f`
845+ given `k`. -/
846+ theorem condIndepFun_iff_condDistrib_prod_ae_eq_prodMkLeft
847+ {γ : Type *} {mγ : MeasurableSpace γ} {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'}
848+ [StandardBorelSpace β] [Nonempty β] [StandardBorelSpace β'] [Nonempty β']
849+ (hf : Measurable f) (hg : Measurable g) {k : Ω → γ} (hk : Measurable k) :
850+ CondIndepFun (mγ.comap k) hk.comap_le g f μ ↔
851+ condDistrib f (fun ω ↦ (k ω, g ω)) μ =ᵐ[μ.map (fun ω ↦ (k ω, g ω))]
852+ (condDistrib f k μ).prodMkRight _ := by
853+ rw [condDistrib_ae_eq_iff_measure_eq_compProd (μ := μ) _ hf.aemeasurable,
854+ condIndepFun_iff_map_prod_eq_prod_condDistrib_prod_condDistrib hg hf hk,
855+ Measure.compProd_eq_comp_prod]
856+ let e : γ × β' × β ≃ᵐ (γ × β') × β := MeasurableEquiv.prodAssoc.symm
857+ have h_eq : ((Kernel.id ×ₖ condDistrib g k μ) ×ₖ condDistrib f k μ) ∘ₘ μ.map k =
858+ (Kernel.id ×ₖ (condDistrib f k μ).prodMkRight _) ∘ₘ μ.map (fun a ↦ (k a, g a)) := by
859+ calc ((Kernel.id ×ₖ condDistrib g k μ) ×ₖ condDistrib f k μ) ∘ₘ μ.map k
860+ _ = (Kernel.id ×ₖ (condDistrib f k μ).prodMkRight _) ∘ₘ (μ.map k ⊗ₘ condDistrib g k μ) := by
861+ rw [Measure.compProd_eq_comp_prod, Measure.comp_assoc]
862+ congr 2
863+ have h := Kernel.prod_prodMkRight_comp_deterministic_prod (condDistrib g k μ)
864+ (condDistrib f k μ) Kernel.id measurable_id
865+ rw [← Kernel.id] at h
866+ simpa using h.symm
867+ _ = (Kernel.id ×ₖ (condDistrib f k μ).prodMkRight _) ∘ₘ μ.map (fun a ↦ (k a, g a)) := by
868+ rw [compProd_map_condDistrib hg.aemeasurable]
869+ rw [← h_eq]
870+ have h1 : μ.map (fun x ↦ ((k x, g x), f x)) = (μ.map (fun a ↦ (k a , g a, f a))).map e := by
871+ rw [Measure.map_map (by fun_prop) (by fun_prop)]
872+ rfl
873+ have h1_symm : μ.map (fun a ↦ (k a , g a, f a)) =
874+ (μ.map (fun x ↦ ((k x, g x), f x))).map e.symm := by
875+ rw [h1, Measure.map_map (by fun_prop) (by fun_prop), MeasurableEquiv.symm_comp_self,
876+ Measure.map_id]
877+ have h2 : ((Kernel.id ×ₖ condDistrib g k μ) ×ₖ condDistrib f k μ) ∘ₘ μ.map k =
878+ ((Kernel.id ×ₖ (condDistrib g k μ ×ₖ condDistrib f k μ)) ∘ₘ μ.map k).map e := by
879+ rw [← Measure.deterministic_comp_eq_map e.measurable, Measure.comp_assoc]
880+ congr 2
881+ unfold e
882+ rw [Kernel.deterministic_comp_eq_map, Kernel.prodAssoc_symm_prod]
883+ have h2_symm : (Kernel.id ×ₖ (condDistrib g k μ ×ₖ condDistrib f k μ)) ∘ₘ μ.map k =
884+ (((Kernel.id ×ₖ condDistrib g k μ) ×ₖ condDistrib f k μ) ∘ₘ μ.map k).map e.symm := by
885+ rw [h2, Measure.map_map (by fun_prop) (by fun_prop), MeasurableEquiv.symm_comp_self,
886+ Measure.map_id]
887+ rw [h1, h2]
888+ exact ⟨fun h ↦ by rw [h], fun h ↦ by rw [h1_symm, h1, h2_symm, h2, h]⟩
889+
793890section iCondIndepFun
794891variable {β : ι → Type *} {m : ∀ i, MeasurableSpace (β i)} {f : ∀ i, Ω → β i}
795892
0 commit comments