Require Import Reals.
Require Import Lra Lia.
Require Import List Permutation.
Require Import Morphisms EquivDec Program.
Require Import Coquelicot.Rbar Coquelicot.Lub Coquelicot.Lim_seq.
Require Import Classical_Prop.
Require Import Classical.
Require Import Utils.
Require Import DVector.
Require Import NumberIso.
Require Import SigmaAlgebras.
Require Export FunctionsToReal ProbSpace BorelSigmaAlgebra.
Require Export RandomVariable.
Require Export Isomorphism.
Require Import FunctionalExtensionality.
Require Import RealVectorHilbert.
Import ListNotations.
Set Bullet Behavior "
Strict Subproofs".
Section VectorRandomVariables.
Context {
Ts:
Type} {
Td:
Type}.
Definition fun_to_vector_to_vector_of_funs
{
n:
nat}
(
f:
Ts ->
vector Td n)
:
vector (
Ts->
Td)
n
:=
vector_create 0
n (
fun m _ pf =>
fun x =>
vector_nth m pf (
f x)).
Definition vector_of_funs_to_fun_to_vector
{
n:
nat}
(
fs:
vector (
Ts->
Td)
n)
:
Ts ->
vector Td n
:=
fun x =>
vector_create 0
n (
fun m _ pf =>
vector_nth m pf fs x).
Program Global Instance vector_iso n :
Isomorphism (
Ts ->
vector Td n) (
vector (
Ts->
Td)
n)
:= {
iso_f :=
fun_to_vector_to_vector_of_funs
;
iso_b :=
vector_of_funs_to_fun_to_vector
}.
Next Obligation.
Next Obligation.
Lemma vector_nth_fun_to_vector {
n} (
f:
Ts->
vector Td n)
i pf :
vector_nth i pf (
fun_to_vector_to_vector_of_funs f) =
fun x:
Ts =>
vector_nth i pf (
f x).
Proof.
Lemma vector_of_funs_vector_nth {
n} (
v:
vector (
Ts->
Td)
n)
a i pf :
vector_nth i pf (
vector_of_funs_to_fun_to_vector v a) =
vector_nth i pf v a.
Proof.
Lemma vector_of_funs_vector_create n f :
rv_eq (
vector_of_funs_to_fun_to_vector (
vector_create 0
n f))
(
fun t=>
vector_create 0
n (
fun m pf1 pf2 =>
f m pf1 pf2 t))
.
Proof.
End VectorRandomVariables.
Require Import Expectation.
Section vector_ops.
Context
{
Ts:
Type}
{
dom:
SigmaAlgebra Ts}
{
prts:
ProbSpace dom}.
Definition vecrvconst (
n:
nat) (
c :
R) :=
(
fun (
omega :
Ts) =>
vector_const c n).
Definition vecrvplus {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n) :=
(
fun omega =>
Rvector_plus (
rv_X1 omega) (
rv_X2 omega)).
Definition vecrvmult {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n) :=
(
fun omega =>
Rvector_mult (
rv_X1 omega) (
rv_X2 omega)).
Definition vecrvscale {
n} (
c:
R) (
rv_X :
Ts ->
vector R n) :=
fun omega =>
Rvector_scale c (
rv_X omega).
Definition vecrvscalerv {
n} (
c:
Ts ->
R) (
rv_X :
Ts ->
vector R n) :=
fun omega =>
Rvector_scale (
c omega) (
rv_X omega).
Definition vecrvopp {
n} (
rv_X :
Ts ->
vector R n) :=
vecrvscale (-1)
rv_X.
Definition vecrvminus {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n) :=
vecrvplus rv_X1 (
vecrvopp rv_X2).
Definition vecrvsum {
n} (
rv_X :
Ts ->
vector R n) :
Ts ->
R :=
(
fun omega =>
Rvector_sum (
rv_X omega)).
Definition vecrvabs {
n} (
rv_X :
Ts ->
vector R n) :=
fun omega =>
Rvector_abs (
rv_X omega).
Definition rvmaxabs {
n} (
rv_X :
Ts ->
vector R n) :=
fun omega =>
Rvector_max_abs (
rv_X omega).
Definition rvinner {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n) :=
fun omega =>
Rvector_inner (
rv_X1 omega) (
rv_X2 omega).
Definition vecrvnth {
A} {
n}
i pf (
rv_X :
Ts ->
vector A n) :=
(
fun omega =>
vector_nth i pf (
rv_X omega)).
Global Instance vecrvplus_proper {
n} :
Proper (
rv_eq ==>
rv_eq ==>
rv_eq) (@
vecrvplus n).
Proof.
Global Instance vecrvmult_proper {
n} :
Proper (
rv_eq ==>
rv_eq ==>
rv_eq) (@
vecrvmult n).
Proof.
Global Instance vecrvscale_proper {
n} :
Proper (
eq ==>
rv_eq ==>
rv_eq) (@
vecrvscale n).
Proof.
Global Instance vecrvopp_proper {
n} :
Proper (
rv_eq ==>
rv_eq) (@
vecrvopp n).
Proof.
Global Instance vecrvminus_proper {
n} :
Proper (
rv_eq ==>
rv_eq ==>
rv_eq) (@
vecrvminus n).
Proof.
Global Instance vecrvsum_proper {
n} :
Proper (
rv_eq ==>
rv_eq) (@
vecrvsum n).
Proof.
Global Instance rvinner_proper {
n} :
Proper (
rv_eq ==>
rv_eq ==>
rv_eq) (@
rvinner n).
Proof.
Lemma rvinner_unfold {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n)
:
rv_eq (
rvinner rv_X1 rv_X2) (
vecrvsum (
vecrvmult rv_X1 rv_X2)).
Proof.
intros ?.
reflexivity.
Qed.
Class RealVectorMeasurable {
n} (
rv_X :
Ts ->
vector R n) :=
vecmeasurable :
forall i pf,
RealMeasurable dom (
vector_nth i pf (
iso_f rv_X)).
Definition Rvector_borel_sa (
n:
nat) :
SigmaAlgebra (
vector R n)
:=
vector_sa (
vector_const borel_sa n).
Lemma Rvector_borel_sa_closure (
n:
nat) :
Rvector_borel_sa n ===
closure_sigma_algebra
(
pre_event_set_vector_product (
vector_map (@
sa_sigma _) (
vector_const borel_sa n))).
Proof.
Instance RealVectorMeasurableRandomVariable {
n}
(
rv_X :
Ts ->
vector R n)
{
rvm:
RealVectorMeasurable rv_X} :
RandomVariable dom (
Rvector_borel_sa n)
rv_X.
Proof.
Instance RandomVariableRealVectorMeasurable {
n}
(
rv_X :
Ts ->
vector R n)
{
rrv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X} :
RealVectorMeasurable rv_X.
Proof.
Lemma RealVectorMeasurableComponent_simplify {
n} (
f:
Ts->
vector R n) :
(
forall (
i :
nat) (
pf : (
i <
n)%
nat),
RealMeasurable dom (
vector_nth i pf (
fun_to_vector_to_vector_of_funs f))) ->
(
forall (
i :
nat) (
pf : (
i <
n)%
nat),
RealMeasurable dom (
fun x =>
vector_nth i pf (
f x))).
Proof.
Instance Rvector_plus_measurable {
n} (
f g :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealVectorMeasurable g ->
RealVectorMeasurable (
vecrvplus f g).
Proof.
Instance Rvector_mult_measurable {
n} (
f g :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealVectorMeasurable g ->
RealVectorMeasurable (
vecrvmult f g).
Proof.
Lemma vecrvsum_rvsum {
n} (
f :
Ts ->
vector R n) :
rv_eq (
vecrvsum f) (
rvsum (
fun i x =>
match lt_dec i n with
|
left pf =>
vector_nth i pf (
f x)
|
right _ => 0%
R
end)
n).
Proof.
Instance Rvector_scale_measurable {
n}
c (
f :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealVectorMeasurable (
vecrvscale c f).
Proof.
Instance Rvector_scale_rv_measurable {
n} (
c :
Ts ->
R) (
f :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealMeasurable dom c ->
RealVectorMeasurable (
vecrvscalerv c f).
Proof.
Instance Rvector_opp_measurable {
n} (
f :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealVectorMeasurable (
vecrvopp f).
Proof.
Instance Rvector_abs_measurable {
n} (
f :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealVectorMeasurable (
vecrvabs f).
Proof.
Existing Instance RealMeasurable_proper.
Instance Rvector_sum_measurable {
n} (
f :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealMeasurable dom (
vecrvsum f).
Proof.
Instance Rvector_const_measurable {
n:
nat} (
c :
R) :
RealVectorMeasurable (
vecrvconst n c ).
Proof.
Instance Rvector_max_abs_measurable {
n} (
f :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealMeasurable dom (
rvmaxabs f).
Proof.
Instance Rvector_inner_measurable {
n} (
f g :
Ts ->
vector R n) :
RealVectorMeasurable f ->
RealVectorMeasurable g ->
RealMeasurable dom (
rvinner f g).
Proof.
Global Instance Rvector_plus_rv {
n} (
f g :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom (
Rvector_borel_sa n)
g ->
RandomVariable dom (
Rvector_borel_sa n) (
vecrvplus f g).
Proof.
Global Instance Rvector_mult_rv {
n} (
f g :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom (
Rvector_borel_sa n)
g ->
RandomVariable dom (
Rvector_borel_sa n) (
vecrvmult f g).
Proof.
Global Instance Rvector_scale_rv {
n}
c (
f :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom (
Rvector_borel_sa n) (
vecrvscale c f).
Proof.
Global Instance Rvector_scale_rv_rv {
n} (
c :
Ts ->
R) (
f :
Ts ->
vector R n) :
RandomVariable dom borel_sa c ->
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom (
Rvector_borel_sa n) (
vecrvscalerv c f).
Proof.
Global Instance Rvector_opp_rv {
n} (
f :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom (
Rvector_borel_sa n) (
vecrvopp f).
Proof.
Global Instance Rvector_abs_rv {
n} (
f :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom (
Rvector_borel_sa n) (
vecrvabs f).
Proof.
Global Instance Rvector_minus_rv {
n} (
f g :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom (
Rvector_borel_sa n)
g ->
RandomVariable dom (
Rvector_borel_sa n) (
vecrvminus f g).
Proof.
Global Instance Rvector_sum_rv {
n} (
f :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom borel_sa (
vecrvsum f).
Proof.
Global Instance Rvector_max_abs_rv {
n} (
f :
Ts ->
vector R n) :
RandomVariable dom (
Rvector_borel_sa n)
f ->
RandomVariable dom borel_sa (
rvmaxabs f).
Proof.
Global Instance Rvector_inner_rv {
n} (
f g :
Ts ->
vector R n)
{
rv1:
RandomVariable dom (
Rvector_borel_sa n)
f}
{
rv2:
RandomVariable dom (
Rvector_borel_sa n)
g} :
RandomVariable dom borel_sa (
rvinner f g).
Proof.
Global Instance vecrvnth_rv {
n}
i pf (
rv_X :
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X} :
RandomVariable dom borel_sa (
vecrvnth i pf rv_X).
Proof.
Global Program Instance vecrvnth_frf {
n}
i pf (
rv_X :
Ts ->
vector R n)
{
rv:
FiniteRangeFunction rv_X} :
FiniteRangeFunction (
vecrvnth i pf rv_X)
:=
{
frf_vals :=
map (
fun c =>
vector_nth i pf c)
frf_vals
}.
Next Obligation.
Global Instance Rvector_sum_pos {
n} (
f :
Ts ->
vector R n) :
(
forall i pf,
NonnegativeFunction (
fun x =>
vector_nth i pf (
f x))) ->
NonnegativeFunction (
vecrvsum f).
Proof.
Global Instance Rvector_inner_pos_mult {
n} (
f g :
Ts ->
vector R n) :
(
forall i pf,
NonnegativeFunction (
fun x =>
vector_nth i pf (
f x) *
vector_nth i pf (
g x))) ->
NonnegativeFunction (
rvinner f g).
Proof.
Global Instance Rvector_inner_self_pos {
n} (
f :
Ts ->
vector R n) :
NonnegativeFunction (
rvinner f f).
Proof.
Global Instance Rvector_inner_nneg_pos {
n} (
f g :
Ts ->
vector R n) :
(
forall i pf,
NonnegativeFunction (
fun x =>
vector_nth i pf (
f x))) ->
(
forall i pf,
NonnegativeFunction (
fun x =>
vector_nth i pf (
g x))) ->
NonnegativeFunction (
rvinner f g).
Proof.
Definition vector_Expectation {
n} (
rv_X :
Ts ->
vector R n) :
option (
vector Rbar n)
:=
vectoro_to_ovector (
vector_map Expectation (
iso_f rv_X)).
Program Instance vec_frf {
n} (
rv_X :
Ts ->
vector R n)
i (
pf : (
i <
n)%
nat)
(
frf :
FiniteRangeFunction rv_X) :
FiniteRangeFunction
(
vector_nth i pf (
iso_f rv_X))
:=
{
frf_vals :=
map (
fun c =>
vector_nth i pf c)
frf_vals
}.
Next Obligation.
Instance vec_rv {
n} (
rv_X :
Ts ->
vector R n)
i (
pf : (
i <
n)%
nat)
(
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X) :
RandomVariable dom borel_sa (
vector_nth i pf (
iso_f rv_X)).
Proof.
Lemma vector_RandomVariable {
n}
f
{
rv :
RandomVariable dom (
Rvector_borel_sa n)
f} :
Forall (
RandomVariable dom borel_sa) (
proj1_sig (
iso_f f)).
Proof.
Lemma RandomVariable_vector {
n} (
f:
Ts ->
vector R n)
(
frv:
Forall (
RandomVariable dom borel_sa) (
proj1_sig (
iso_f f)))
:
RandomVariable dom (
Rvector_borel_sa n)
f.
Proof.
Global Program Instance frf_vecrvconst n c :
FiniteRangeFunction (
vecrvconst n c)
:= {
frf_vals := (
vector_const c n)::
nil }.
Definition vector_SimpleExpectation {
n} (
rv_X :
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X} :
vector R n
:=
vector_create 0
n (
fun m _ pf =>
SimpleExpectation (
vector_nth m pf (
iso_f rv_X))
(
frf := (
vec_frf rv_X m pf frf))).
Definition vector_SimpleConditionalExpectationSA {
n} (
rv_X :
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
(
l :
list dec_sa_event) :
Ts ->
vector R n
:=
iso_b (
vector_create 0
n (
fun m _ pf =>
SimpleConditionalExpectationSA
(
vector_nth m pf (
iso_f rv_X))
(
frf := (
vec_frf rv_X m pf frf))
l)).
Program Instance FiniteRangeFunction_nth_vector {
n} {
Td} (
v:
Ts->
vector Td n)
(
frfs:
forall i pf1,
FiniteRangeFunction (
fun a =>
vector_nth i pf1 (
v a))) :
FiniteRangeFunction v
:= {
frf_vals :=
if Nat.eq_dec n 0
then [
vector0]
else
vector_list_product
(
vector_create 0
n
(
fun i _ pf => (@
frf_vals _ _ _ (
frfs i pf)))) }.
Next Obligation.
Instance vec_gen_condexp_rv {
n}
(
rv_X :
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
(
l :
list dec_sa_event) :
RandomVariable dom (
Rvector_borel_sa n)
(
vector_SimpleConditionalExpectationSA rv_X l).
Proof.
Instance vector_SimpleConditionalExpectationSA_simpl {
n}
(
rv_X :
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
(
l :
list dec_sa_event) :
FiniteRangeFunction (
vector_SimpleConditionalExpectationSA rv_X l).
Proof.
Lemma vector_gen_conditional_tower_law {
n}
(
rv_X :
Ts ->
vector R n)
{
rv :
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
(
l :
list dec_sa_event)
(
ispart:
is_partition_list (
map dsa_event l)) :
vector_SimpleExpectation rv_X =
vector_SimpleExpectation
(
vector_SimpleConditionalExpectationSA rv_X l).
Proof.
Program Instance frf_vecrvmult {
n}
(
rv_X1 rv_X2 :
Ts ->
vector R n)
{
frf1:
FiniteRangeFunction rv_X1}
{
frf2:
FiniteRangeFunction rv_X2}
:
FiniteRangeFunction (
vecrvmult rv_X1 rv_X2)
:= {
frf_vals :=
map (
fun ab =>
Rvector_mult (
fst ab) (
snd ab))
(
list_prod (
frf_vals (
FiniteRangeFunction:=
frf1))
(
frf_vals (
FiniteRangeFunction:=
frf2))) }.
Next Obligation.
destruct frf1.
destruct frf2.
rewrite in_map_iff.
exists (
rv_X1 x,
rv_X2 x).
split.
now simpl.
apply in_prod;
trivial.
Qed.
Global Program Instance frf_vecrvplus {
n}
(
rv_X1 rv_X2 :
Ts ->
vector R n)
{
frf1:
FiniteRangeFunction rv_X1}
{
frf2:
FiniteRangeFunction rv_X2}
:
FiniteRangeFunction (
vecrvplus rv_X1 rv_X2)
:= {
frf_vals :=
map (
fun ab =>
Rvector_plus (
fst ab) (
snd ab))
(
list_prod (
frf_vals (
FiniteRangeFunction:=
frf1))
(
frf_vals (
FiniteRangeFunction:=
frf2))) }.
Next Obligation.
destruct frf1.
destruct frf2.
rewrite in_map_iff.
exists (
rv_X1 x,
rv_X2 x).
split.
now simpl.
apply in_prod;
trivial.
Qed.
Global Program Instance frf_vecrvscale {
n} (
c:
R)
(
rv_X :
Ts ->
vector R n)
{
frf:
FiniteRangeFunction rv_X}
:
FiniteRangeFunction (
vecrvscale c rv_X)
:= {
frf_vals :=
map (
fun x =>
Rvector_scale c x)
(
frf_vals (
FiniteRangeFunction :=
frf)) }.
Next Obligation.
destruct frf.
rewrite in_map_iff.
exists (
rv_X x).
now split.
Qed.
Global Program Instance frf_vecrvscalerv {
n} (
c:
Ts ->
R)
(
rv_X :
Ts ->
vector R n)
{
frfc:
FiniteRangeFunction c}
{
frf:
FiniteRangeFunction rv_X}
:
FiniteRangeFunction (
vecrvscalerv c rv_X)
:= {
frf_vals :=
map (
fun ab =>
Rvector_scale (
fst ab) (
snd ab))
(
list_prod (
frf_vals (
FiniteRangeFunction:=
frfc))
(
frf_vals (
FiniteRangeFunction:=
frf))) }.
Next Obligation.
destruct frfc.
destruct frf.
rewrite in_map_iff.
exists (
c x,
rv_X x).
split.
now simpl.
apply in_prod;
trivial.
Qed.
Global Instance frf_vecropp {
n}
(
rv_X :
Ts ->
vector R n)
{
frf:
FiniteRangeFunction rv_X}
:
FiniteRangeFunction (
vecrvopp rv_X)
:=
frf_vecrvscale (-1)
rv_X.
Global Instance frf_vecrvminus {
n}
(
rv_X1 rv_X2 :
Ts ->
vector R n)
{
frf1 :
FiniteRangeFunction rv_X1}
{
frf2 :
FiniteRangeFunction rv_X2} :
FiniteRangeFunction (
vecrvminus rv_X1 rv_X2) :=
frf_vecrvplus rv_X1 (
vecrvopp rv_X2).
Program Instance frf_vecsum {
n}
(
rv_X :
Ts ->
vector R n)
{
frf:
FiniteRangeFunction rv_X}
:
FiniteRangeFunction (
vecrvsum rv_X)
:= {
frf_vals :=
map Rvector_sum frf_vals }.
Next Obligation.
destruct frf.
rewrite in_map_iff.
exists (
rv_X x).
easy.
Qed.
Global Instance frfinner {
n}
(
rv_X1 rv_X2 :
Ts ->
vector R n)
{
frf1:
FiniteRangeFunction rv_X1}
{
frf2:
FiniteRangeFunction rv_X2}
:
FiniteRangeFunction (
rvinner rv_X1 rv_X2).
Proof.
Global Program Instance frfmaxabs {
n}
(
rv_X :
Ts ->
vector R n)
{
frf:
FiniteRangeFunction rv_X}
:
FiniteRangeFunction (
rvmaxabs rv_X)
:= {
frf_vals :=
map Rvector_max_abs frf_vals }.
Next Obligation.
End vector_ops.
Lemma Rvector_borel_singleton {
n} (
c:
vector R n) :
sa_sigma (
SigmaAlgebra:=
Rvector_borel_sa n) (
pre_event_singleton c).
Proof.
Global Instance Rvector_borel_sa_has_preimages {
n} :
HasPreimageSingleton (
Rvector_borel_sa n).
Proof.
Section vector_ops_ext.
Context {
Ts:
Type}
{
dom:
SigmaAlgebra Ts}
{
prts:
ProbSpace dom}.
Lemma partition_measurable_vecrvplus {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n)
{
rv1 :
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rv2 :
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
{
frf1 :
FiniteRangeFunction rv_X1}
{
frf2 :
FiniteRangeFunction rv_X2}
(
l :
list (
event dom)) :
is_partition_list l ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X1 l ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X2 l ->
partition_measurable (
cod:=
Rvector_borel_sa n) (
vecrvplus rv_X1 rv_X2)
l.
Proof.
Lemma partition_measurable_vecrvscale {
n} (
c :
R) (
rv_X :
Ts ->
vector R n)
{
rv :
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
(
l :
list (
event dom)) :
is_partition_list l ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X l ->
partition_measurable (
cod:=
Rvector_borel_sa n) (
vecrvscale c rv_X)
l.
Proof.
Lemma partition_measurable_vecrvscalerv {
n} (
rv_c :
Ts ->
R)
(
rv_X :
Ts ->
vector R n)
{
rv :
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
rvc :
RandomVariable dom borel_sa rv_c}
{
frf :
FiniteRangeFunction rv_X}
{
frfc :
FiniteRangeFunction rv_c}
(
l :
list (
event dom)) :
is_partition_list l ->
partition_measurable rv_c l ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X l ->
partition_measurable (
cod:=
Rvector_borel_sa n) (
vecrvscalerv rv_c rv_X)
l.
Proof.
Lemma partition_measurable_vecrvminus {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n)
{
rv1 :
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rv2 :
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
{
frf1 :
FiniteRangeFunction rv_X1}
{
frf2 :
FiniteRangeFunction rv_X2}
(
l :
list (
event dom)) :
is_partition_list l ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X1 l ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X2 l ->
partition_measurable (
cod:=
Rvector_borel_sa n) (
vecrvminus rv_X1 rv_X2)
l.
Proof.
Instance rv_fun_simple_Rvector {
n} (
x:
Ts ->
vector R n) (
f :
vector R n ->
vector R n)
(
rvx :
RandomVariable dom (
Rvector_borel_sa n)
x)
(
frfx :
FiniteRangeFunction x) :
RandomVariable dom (
Rvector_borel_sa n) (
fun u =>
f (
x u)).
Proof.
Lemma partition_measurable_comp {
n} (
rv_X :
Ts ->
vector R n) (
f :
vector R n ->
vector R n)
{
rv :
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
(
l :
list (
event dom)) :
is_partition_list l ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X l ->
partition_measurable (
cod:=
Rvector_borel_sa n) (
fun v =>
f (
rv_X v))
l.
Proof.
Lemma partition_measurable_const {
n} (
c :
vector R n)
(
l :
list (
event dom)) :
is_partition_list l ->
partition_measurable (
cod:=
Rvector_borel_sa n) (
const c)
l.
Proof.
Program Definition vec_induced_sigma_generators {
n}
{
rv_X :
Ts ->
vector R n}
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
(
frf :
FiniteRangeFunction rv_X)
:
list dec_sa_event
:=
map (
fun (
c:
vector R n) =>
Build_dec_sa_event
(
preimage_singleton (σ
d:=(
Rvector_borel_sa n))
rv_X c)
_)
(
nodup vector_eq_dec frf_vals).
Next Obligation.
Lemma is_partition_vec_induced_gen {
n}
{
rv_X :
Ts ->
vector R n}
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
(
frf :
FiniteRangeFunction rv_X) :
is_partition_list (
map dsa_event (
vec_induced_sigma_generators frf)).
Proof.
Lemma vec_induced_partition_measurable {
n}
{
rv_X :
Ts ->
vector R n}
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
(
frf :
FiniteRangeFunction rv_X) :
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X (
map dsa_event (
vec_induced_sigma_generators frf)).
Proof.
Lemma FiniteRangeFunction_exist2_part
(
l :
list ({
rv_X:
Ts ->
R &
RandomVariable dom borel_sa rv_X &
FiniteRangeFunction rv_X})) :
FiniteRangeFunction
(
fold_right rvplus (
const 0) (
map (
fun '(
existT2 x _ _) =>
x)
l)).
Proof.
induction l; simpl.
- typeclasses eauto.
- destruct a; simpl.
typeclasses eauto.
Defined.
Lemma RandomVariable_exist2_part
(
l :
list ({
rv_X:
Ts ->
R &
RandomVariable dom borel_sa rv_X &
FiniteRangeFunction rv_X})) :
RandomVariable dom borel_sa
(
fold_right rvplus (
const 0) (
map (
fun '(
existT2 x _ _) =>
x)
l)).
Proof.
induction l; simpl.
- typeclasses eauto.
- destruct a; simpl.
typeclasses eauto.
Defined.
Definition make_simple_vector_package {
n}
(
rv_X :
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf:
FiniteRangeFunction rv_X} :
list ({
rv_X:
Ts ->
R &
RandomVariable dom borel_sa rv_X &
FiniteRangeFunction rv_X})
:=
proj1_sig (
vector_create 0
n
(
fun i _ pf =>
existT2 _ _ _ (
vec_rv _ i pf rv) (
vec_frf _ i pf frf))).
Lemma SimpleExpectation_fold_rvplus'
(
l :
list ({
rv_X:
Ts ->
R &
RandomVariable dom borel_sa rv_X &
FiniteRangeFunction rv_X})) :
SimpleExpectation (
fold_right rvplus (
const 0) (
map (
fun '(
existT2 x _ _) =>
x)
l))
(
rv:=
RandomVariable_exist2_part l)
(
frf:=
FiniteRangeFunction_exist2_part l) =
list_sum (
map (
fun '(
existT2 x rx sx) =>
SimpleExpectation x (
rv:=
rx) (
frf:=
sx))
l).
Proof.
Lemma make_simple_vector_package_proj1 {
n} (
rv_X:
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf:
FiniteRangeFunction rv_X} :
(
map (
fun '(@
existT2 _ _ _ x _ _) =>
x) (
make_simple_vector_package rv_X)) =
proj1_sig (
fun_to_vector_to_vector_of_funs rv_X).
Proof.
Lemma SimpleExpectation_rvsum {
n} (
rv_X :
Ts ->
vector R n)
{
rv:
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf1:
FiniteRangeFunction rv_X} :
SimpleExpectation (
vecrvsum rv_X) (
frf:=
frf_vecsum rv_X)
=
Rvector_sum (
vector_SimpleExpectation rv_X).
Proof.
Lemma SimpleExpectation_rvinner {
n} (
rv_X1 rv_X2 :
Ts ->
vector R n)
{
rv1:
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rv2:
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
{
frf1:
FiniteRangeFunction rv_X1}
{
frf2:
FiniteRangeFunction rv_X2} :
SimpleExpectation (
rvinner rv_X1 rv_X2) (
rv:=
Rvector_inner_rv _ _) (
frf:=
frfinner _ _)
=
Rvector_sum
(
vector_create
0
n
(
fun m _ pf =>
SimpleExpectation (
frf:=
frfmult _ _ (
frf1:=
vec_frf _ m pf _) (
frf2:=
vec_frf _ m pf _)) (
rv:=
rvmult_rv _ _ _ (
rv1:=
vec_rv _ m pf _) (
rv2:=
vec_rv _ m pf _))
(
rvmult (
vector_nth m pf (
iso_f rv_X1))
(
vector_nth m pf (
iso_f rv_X2))))).
Proof.
Lemma simple_expection_rvinner_measurable {
n}
(
rv_X1 rv_X2 :
Ts ->
vector R n)
{
rv1:
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rv2:
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
{
frf1 :
FiniteRangeFunction rv_X1}
{
frf2 :
FiniteRangeFunction rv_X2}
(
l :
list dec_sa_event) :
is_partition_list (
map dsa_event l) ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X1 (
map dsa_event l) ->
SimpleExpectation (
rvinner rv_X1 rv_X2) (
rv:=
Rvector_inner_rv _ _) (
frf:=
frfinner _ _) =
SimpleExpectation (
rvinner rv_X1 (
vector_SimpleConditionalExpectationSA rv_X2 l))
(
frf:=
frfinner _ _ (
frf2:=
vector_SimpleConditionalExpectationSA_simpl _ _))
(
rv:=
Rvector_inner_rv _ _ (
rv2:=
vec_gen_condexp_rv _ _)).
Proof.
Lemma simple_expectation_rvinner_measurable_zero {
n}
(
rv_X1 rv_X2 :
Ts ->
vector R n)
{
rv1:
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rv2:
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
{
frf1 :
FiniteRangeFunction rv_X1}
{
frf2 :
FiniteRangeFunction rv_X2}
(
l :
list dec_sa_event) :
rv_eq (
vector_SimpleConditionalExpectationSA rv_X2 l) (
const Rvector_zero) ->
is_partition_list (
map dsa_event l) ->
partition_measurable (
cod:=
Rvector_borel_sa n)
rv_X1 (
map dsa_event l) ->
SimpleExpectation (
rvinner rv_X1 rv_X2) (
rv:=
Rvector_inner_rv _ _) (
frf:=
frfinner _ _) = 0.
Proof.
Lemma vector_SimpleConditionalExpectationSA_vecrvscale {
size:
nat}
(
rv_X :
Ts ->
vector R size) (
b :
R)
{
rv:
RandomVariable dom (
Rvector_borel_sa size)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
(
l :
list dec_sa_event) :
is_partition_list (
map dsa_event l) ->
rv_eq
(
vector_SimpleConditionalExpectationSA (
vecrvscale b rv_X)
l)
(
vecrvscale b (
vector_SimpleConditionalExpectationSA rv_X l)).
Proof.
End vector_ops_ext.
Section real_pullback.
Lemma pullback_sa_vecrvscale_equiv {
Ts} {
n} (
c:
R) (
x :
Ts ->
vector R n) :
c <> 0 ->
sa_equiv (
pullback_sa (
Rvector_borel_sa n)
x) (
pullback_sa (
Rvector_borel_sa n) (
vecrvscale c x)).
Proof.
End real_pullback.
Section almost.
Program Lemma vector_Forall2_almost_nth_iff
{
Ts Td:
Type}
{
dom:
SigmaAlgebra Ts}
(
prts:
ProbSpace dom)
{
n}
(
P:
Td->
Td->
Prop) (
v1 v2:
Ts ->
vector Td n) :
(
forall (
i :
nat) (
pf : (
i <
n)%
nat),
almostR2 prts P (
vecrvnth i pf v1) (
vecrvnth i pf v2)) <->
almostR2 prts (
Forall2 P)
v1 v2.
Proof.
Lemma vector_nth_eq_almost {
Ts Td:
Type}
{
dom:
SigmaAlgebra Ts}
(
prts:
ProbSpace dom)
{
n} (
v1 v2:
Ts ->
vector Td n) :
(
forall i pf,
almostR2 prts eq (
vecrvnth i pf v1) (
vecrvnth i pf v2)) <->
almostR2 prts eq v1 v2.
Proof.
Lemma vectorize_relation_almost {
Ts Td:
Type}
{
dom:
SigmaAlgebra Ts}
(
prts:
ProbSpace dom)
(
RR:
Td->
Td->
Prop) {
n} (
v1 v2:
Ts ->
vector Td n) :
(
forall i pf,
almostR2 prts RR (
vecrvnth i pf v1) (
vecrvnth i pf v2)) <->
almostR2 prts (
vectorize_relation RR n)
v1 v2.
Proof.
End almost.
Require Import RandomVariableFinite.
Section vec_exp.
Context {
Ts:
Type}
{
dom:
SigmaAlgebra Ts}
(
prts:
ProbSpace dom).
Class vector_IsFiniteExpectation {
n} (
rv_X :
Ts ->
vector R n)
:=
is_vector_finite_expectation :
Forall (
IsFiniteExpectation prts) (
proj1_sig (
iso_f rv_X)).
Global Instance vector_IsFiniteExpectation_nth {
n} (
f:
Ts ->
vector R n)
i pf
{
isfe:
vector_IsFiniteExpectation f} :
IsFiniteExpectation prts (
vecrvnth i pf f).
Proof.
Definition vector_IsFiniteExpectation_Finite {
n} (
rv_X:
Ts ->
vector R n)
{
isfe:
vector_IsFiniteExpectation rv_X} :
{
x :
vector R n |
vector_Expectation rv_X =
Some (
vector_map Finite x)}.
Proof.
Definition vector_FiniteExpectation {
n} (
rv_X:
Ts ->
vector R n)
{
isfe:
vector_IsFiniteExpectation rv_X} :
vector R n
:=
proj1_sig (
vector_IsFiniteExpectation_Finite rv_X).
Lemma vector_FiniteExpectation_Expectation {
n} (
rv_X:
Ts->
vector R n)
{
isfe:
vector_IsFiniteExpectation rv_X} :
vector_Expectation rv_X =
Some (
vector_map Finite (
vector_FiniteExpectation rv_X)).
Proof.
Lemma vector_Expectation_const n c
{
rv:
RandomVariable dom (
Rvector_borel_sa n) (
const c)}
:
vector_Expectation (
const c) =
Some (
vector_map Finite c).
Proof.
Lemma vector_FiniteExpectation_const n c
{
rv:
RandomVariable dom (
Rvector_borel_sa n) (
const c)}
{
isfe:
vector_IsFiniteExpectation (
const c)}
:
vector_FiniteExpectation (
const c) =
c.
Proof.
Global Instance vector_IsFiniteExpectation_const {
n} (
c:
vector R n) :
vector_IsFiniteExpectation (
const c).
Proof.
Global Instance vector_IsFiniteExpectation_scale {
n} (
c:
R) (
f:
Ts ->
vector R n)
{
isfe:
vector_IsFiniteExpectation f} :
vector_IsFiniteExpectation (
vecrvscale c f).
Proof.
Global Instance vector_IsFiniteExpectation_plus {
n} (
f1 f2:
Ts ->
vector R n)
{
rv1 :
RandomVariable dom (
Rvector_borel_sa n)
f1}
{
rv2 :
RandomVariable dom (
Rvector_borel_sa n)
f2}
{
isfe1:
vector_IsFiniteExpectation f1}
{
isfe2:
vector_IsFiniteExpectation f2} :
vector_IsFiniteExpectation (
vecrvplus f1 f2).
Proof.
Lemma vector_IsFiniteExpectation_proper_almostR2 {
n}
rv_X1 rv_X2
{
rrv1:
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rrv2:
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
{
isfe1:
vector_IsFiniteExpectation rv_X1}
:
almostR2 prts eq rv_X1 rv_X2 ->
vector_IsFiniteExpectation rv_X2.
Proof.
Lemma vector_Expectation_proper_almostR2 {
n}
rv_X1 rv_X2
{
rrv1:
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rrv2:
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
:
almostR2 prts eq rv_X1 rv_X2 ->
vector_Expectation rv_X1 =
vector_Expectation rv_X2.
Proof.
Lemma vector_FiniteExpectation_proper_almostR2 {
n}
rv_X1 rv_X2
{
rrv1:
RandomVariable dom (
Rvector_borel_sa n)
rv_X1}
{
rrv2:
RandomVariable dom (
Rvector_borel_sa n)
rv_X2}
{
isfe1:
vector_IsFiniteExpectation rv_X1}
{
isfe2:
vector_IsFiniteExpectation rv_X2}
:
almostR2 prts eq rv_X1 rv_X2 ->
vector_FiniteExpectation rv_X1 =
vector_FiniteExpectation rv_X2.
Proof.
Lemma vector_nth_SimpleExpectation {
n}
(
f :
Ts ->
vector R n)
{
rvf :
RandomVariable dom (
Rvector_borel_sa n)
f}
{
isfev:
FiniteRangeFunction f}
i pf :
vector_nth i pf (
vector_SimpleExpectation f) =
SimpleExpectation (
vecrvnth i pf f).
Proof.
Lemma vector_nth_FiniteExpectation {
n}
(
f :
Ts ->
vector R n)
{
rvf :
RandomVariable dom (
Rvector_borel_sa n)
f}
{
isfev:
vector_IsFiniteExpectation f}
i pf :
vector_nth i pf (
vector_FiniteExpectation f) =
FiniteExpectation prts (
vecrvnth i pf f).
Proof.
Instance vector_IsFiniteExpectation_simple {
n} (
rv_X :
Ts ->
vector R n)
{
rvx_rv :
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X} :
vector_IsFiniteExpectation rv_X.
Proof.
Lemma vector_FiniteExpectation_simple {
n} (
rv_X :
Ts ->
vector R n)
{
rvx_rv :
RandomVariable dom (
Rvector_borel_sa n)
rv_X}
{
frf :
FiniteRangeFunction rv_X}
{
isfe :
vector_IsFiniteExpectation rv_X} :
vector_FiniteExpectation rv_X =
vector_SimpleExpectation rv_X.
Proof.
Lemma vector_isfe_In_isfe {
n}
(
f :
Ts ->
vector R n)
{
isfe:
vector_IsFiniteExpectation f}
(
c :
Ts ->
R)
(
pf :
In c (
proj1_sig (
iso_f f))) :
IsFiniteExpectation prts c.
Proof.
Lemma FiniteExpectation_vecrvsum' {
n}
(
f :
Ts ->
vector R n)
{
rvf :
RandomVariable dom (
Rvector_borel_sa n)
f}
{
isfe:
vector_IsFiniteExpectation f} :
Expectation (
vecrvsum f) =
Some (
Finite
(
RealVectorHilbert.Rvector_sum
(
vector_FiniteExpectation f))).
Proof.
Instance IsFiniteExpectation_vecrvsum {
n}
(
f :
Ts ->
vector R n)
{
rvf :
RandomVariable dom (
Rvector_borel_sa n)
f}
{
isfe:
vector_IsFiniteExpectation f} :
IsFiniteExpectation prts (
vecrvsum f).
Proof.
red.
now rewrite (FiniteExpectation_vecrvsum' f).
Qed.
Global Instance IsFiniteExpectation_inner_vecrvmult {
n}
(
f g :
Ts ->
vector R n)
{
rvf:
RandomVariable dom (
Rvector_borel_sa n)
f}
{
rvg:
RandomVariable dom (
Rvector_borel_sa n)
g}
{
isfe:
vector_IsFiniteExpectation (
vecrvmult f g)} :
IsFiniteExpectation prts (
rvinner f g).
Proof.
Lemma FiniteExpectation_vecrvsum {
n}
(
f :
Ts ->
vector R n)
{
rvf :
RandomVariable dom (
Rvector_borel_sa n)
f}
{
isfev:
vector_IsFiniteExpectation f} :
FiniteExpectation prts (
vecrvsum f) =
RealVectorHilbert.Rvector_sum (
vector_FiniteExpectation f).
Proof.
Lemma FiniteExpectation_rvinner {
n}
(
f g :
Ts ->
vector R n)
{
rvf :
RandomVariable dom (
Rvector_borel_sa n)
f}
{
rvgf:
RandomVariable dom (
Rvector_borel_sa n)
g}
{
isfe_inner:
IsFiniteExpectation prts (
rvinner f g)}
{
isfe_mult:
vector_IsFiniteExpectation (
vecrvmult f g)} :
FiniteExpectation prts (
rvinner f g) =
RealVectorHilbert.Rvector_sum (
vector_FiniteExpectation (
vecrvmult f g)).
Proof.
End vec_exp.