proposition: Lemma varianceD (X Y : {RV P >-> R}) : P.-integrable setT (EFin \o X) -> P.-integrable setT (EFin \o (X ^+ 2)%R) -> P.-integrable setT (EFin \o Y) -> P.-integrable setT (EFin \o (Y ^+ 2)%R) -> P.-integrable setT (EFin \o (X * Y)%R) -> 'V_P[X \+ Y]%R = 'V_P[X] + 'V_P[Y] + 2%:E * covariance P X Y.
proof: Proof. move=> X1 X2 Y1 Y2 XY1. rewrite -['V_P[_]]/(covariance P (X \+ Y)%R (X \+ Y)%R). have XY : P.-integrable [set: T] (EFin \o (X \+ Y)%R). by rewrite compreDr// integrableD. rewrite covarianceDl//=; last 3 first. - rewrite -expr2 sqrrD compreDr ?integrableD// compreDr// integrableD//. rewrite -mulr_natr -[(_ * 2)%R]/(2 \o* (X * Y))%R compre_scale//. exact: integrableZl. - by rewrite mulrDr compreDr ?integrableD. - by rewrite mulrDr mulrC compreDr ?integrableD. rewrite covarianceDr// covarianceDr; [|by []..|by rewrite mulrC |exact: Y2]. rewrite (covarianceC P Y X) [LHS]addeA [LHS](ACl (1*4*(2*3)))/=. by rewrite -[2%R]/(1 + 1)%R EFinD muleDl ?mul1e// covariance_fin_num. Qed.
imports: mathcomp(all_ssreflect) mathcomp(ssralg poly ssrnum ssrint interval finmap) mathcomp(mathcomp_extra boolp classical_sets functions) mathcomp(cardinality) HB(structures) exp numfun lebesgue_measure lebesgue_integral reals ereal signed topology normedtype sequences esum measure exp numfun lebesgue_measure lebesgue_integral