Module FormalML.ProbTheory.RandomVariableL2
Require Import Morphisms.
Require Import Equivalence.
Require Import Program.Basics.
Require Import Lra Lia.
Require Import Classical.
Require Import FunctionalExtensionality.
Require Import IndefiniteDescription ClassicalDescription.
Require Import hilbert.
Require Export RandomVariableLpR.
Require Import quotient_space.
Require Import RbarExpectation.
Require Import Event.
Require Import Almost.
Require Import utils.Utils.
Require Import List.
Set Bullet Behavior "
Strict Subproofs".
Section L2.
Context {
Ts:
Type}
{
dom:
SigmaAlgebra Ts}
(
prts:
ProbSpace dom).
Lemma big2 : 1 <= 2.
Proof.
lra.
Qed.
Let nneg2 :
nonnegreal :=
bignneg 2
big2.
Canonical nneg2.
Global Instance IsL2_Finite (
rv_X:
Ts->
R)
{
rrv:
RandomVariable dom borel_sa rv_X}
{
lp:
IsLp prts 2
rv_X} :
IsFiniteExpectation prts rv_X.
Proof.
Lemma isfe_sqr_islp2 (
f :
Ts ->
R) :
IsFiniteExpectation prts (
rvsqr f) ->
IsLp prts 2
f.
Proof.
Global Instance is_L2_mult_finite x y
{
xrv:
RandomVariable dom borel_sa x}
{
yrv:
RandomVariable dom borel_sa y} :
IsLp prts 2
x ->
IsLp prts 2
y ->
IsFiniteExpectation prts (
rvmult x y).
Proof.
Lemma isfe_l2_prod (
f g :
Ts ->
R)
(
rv1 :
RandomVariable dom borel_sa f)
(
rv2 :
RandomVariable dom borel_sa g) :
IsFiniteExpectation prts (
rvsqr f) ->
IsFiniteExpectation prts (
rvsqr g) ->
IsFiniteExpectation prts (
rvmult f g).
Proof.
Lemma isfe_sqr_seq (
X :
nat ->
Ts ->
R)
(
rv :
forall n,
RandomVariable dom borel_sa (
X n)) :
(
forall n,
IsFiniteExpectation prts (
rvsqr (
X n))) ->
forall j k,
IsFiniteExpectation prts (
rvmult (
X j) (
X k)).
Proof.
Lemma IsFiniteExpectation_rvsqr_lower f
{
rv:
RandomVariable dom borel_sa f}
{
isfe2 :
IsFiniteExpectation prts (
rvsqr f)} :
IsFiniteExpectation prts f.
Proof.
Definition L2RRVinner (
x y:
LpRRV prts 2) :
R
:=
FiniteExpectation prts (
rvmult x y).
Global Instance L2RRV_inner_proper :
Proper (
LpRRV_eq prts ==>
LpRRV_eq prts ==>
eq)
L2RRVinner.
Proof.
Lemma L2RRV_inner_comm (
x y :
LpRRV prts 2) :
L2RRVinner x y =
L2RRVinner y x.
Proof.
Lemma L2RRV_inner_pos (
x :
LpRRV prts 2) : 0 <=
L2RRVinner x x.
Proof.
Lemma L2RRV_inner_zero_inv (
x:
LpRRV prts 2) :
L2RRVinner x x = 0 ->
LpRRV_eq prts x (
LpRRVconst prts 0).
Proof.
Lemma L2RRV_inner_scal (
x y :
LpRRV prts 2) (
l :
R) :
L2RRVinner (
LpRRVscale prts l x)
y =
l *
L2RRVinner x y.
Proof.
Global Instance L2Expectation_l1_prod (
rv_X1 rv_X2:
Ts->
R)
{
rv1 :
RandomVariable dom borel_sa rv_X1}
{
rv2 :
RandomVariable dom borel_sa rv_X2}
{
l21:
IsLp prts 2
rv_X1}
{
l22:
IsLp prts 2
rv_X2}
:
IsFiniteExpectation prts (
rvabs (
rvmult rv_X1 rv_X2)).
Proof.
Lemma conv_l2_prob_le_div
(
eps :
posreal)
(
X :
Ts ->
R)
(
rv :
RandomVariable dom borel_sa X)
(
pofrf:
NonnegativeFunction X) :
Rbar_le (
ps_P (
event_ge dom X eps))
(
Rbar_div (
NonnegExpectation (
rvsqr X))
(
Rsqr eps)).
Proof.
Lemma conv_l2_prob_le1
(
eps :
posreal)
(
Xn:
Ts ->
R)
(
rvxn :
RandomVariable dom borel_sa Xn) :
is_finite (
NonnegExpectation (
rvsqr (
rvabs Xn))) ->
ps_P (
event_ge dom (
rvabs Xn)
eps) <=
(
NonnegExpectation (
rvsqr (
rvabs Xn))) / (
Rsqr eps).
Proof.
Lemma conv_l2_prob_le
(
eps :
posreal)
(
X Xn:
Ts ->
R)
(
rvx :
RandomVariable dom borel_sa X)
(
rvxn :
RandomVariable dom borel_sa Xn) :
is_finite (
NonnegExpectation (
rvsqr (
rvabs (
rvminus X Xn)))) ->
ps_P (
event_ge dom (
rvabs (
rvminus X Xn))
eps) <=
(
NonnegExpectation (
rvsqr (
rvabs (
rvminus X Xn)))) / (
Rsqr eps).
Proof.
Lemma conv_l1_prob_le
(
eps :
posreal)
(
X:
Ts ->
R)
{
rvx :
RandomVariable dom borel_sa X}:
is_finite (
NonnegExpectation (
rvabs X)) ->
ps_P (
event_ge dom (
rvabs X)
eps) <=
(
NonnegExpectation (
rvabs X)) /
eps.
Proof.
Lemma conv_l1_prob_le_minus
(
eps :
posreal)
(
X Xn:
Ts ->
R)
{
rvx :
RandomVariable dom borel_sa X}
{
rvxn :
RandomVariable dom borel_sa Xn} :
is_finite (
NonnegExpectation (
rvabs (
rvminus X Xn))) ->
ps_P (
event_ge dom (
rvabs (
rvminus X Xn))
eps) <=
(
NonnegExpectation (
rvabs (
rvminus X Xn))) /
eps.
Proof.
Lemma conv_l2_prob1
(
eps :
posreal)
(
Xn:
nat ->
Ts ->
R)
(
rvxn :
forall n,
RandomVariable dom borel_sa (
Xn n)) :
(
forall n,
is_finite (
NonnegExpectation (
rvsqr (
rvabs (
Xn n))))) ->
is_lim_seq (
fun n =>
NonnegExpectation (
rvsqr (
rvabs (
Xn n)))) 0 ->
is_lim_seq (
fun n =>
ps_P (
event_ge dom (
rvabs (
Xn n))
eps)) 0.
Proof.
Lemma conv_l2_prob
(
eps :
posreal)
(
X:
Ts ->
R)
(
Xn:
nat ->
Ts ->
R)
(
rvx :
RandomVariable dom borel_sa X)
(
rvxn :
forall n,
RandomVariable dom borel_sa (
Xn n)) :
(
forall n,
is_finite (
NonnegExpectation (
rvsqr (
rvabs (
rvminus X (
Xn n)))))) ->
is_lim_seq (
fun n =>
NonnegExpectation (
rvsqr (
rvabs (
rvminus X (
Xn n))))) 0 ->
is_lim_seq (
fun n =>
ps_P (
event_ge dom (
rvabs (
rvminus X (
Xn n)))
eps)) 0.
Proof.
Lemma conv_l1_prob
(
eps :
posreal)
(
X:
Ts ->
R)
(
Xn:
nat ->
Ts ->
R)
(
rvx :
RandomVariable dom borel_sa X)
(
rvxn :
forall n,
RandomVariable dom borel_sa (
Xn n)) :
(
forall n,
is_finite (
NonnegExpectation (
rvabs (
rvminus X (
Xn n))))) ->
is_lim_seq (
fun n =>
NonnegExpectation (
rvabs (
rvminus X (
Xn n)))) 0 ->
is_lim_seq (
fun n =>
ps_P (
event_ge dom (
rvabs (
rvminus X (
Xn n)))
eps)) 0.
Proof.
Lemma L2RRV_inner_plus (
x y z :
LpRRV prts 2) :
L2RRVinner (
LpRRVplus prts x y)
z =
L2RRVinner x z +
L2RRVinner y z.
Proof.
Lemma L2RRV_inner_plus_r (
x y z :
LpRRV prts 2) :
L2RRVinner x (
LpRRVplus prts y z) =
L2RRVinner x y +
L2RRVinner x z.
Proof.
Lemma L2RRV_inner_scal_r (
x y :
LpRRV prts 2) (
l :
R) :
L2RRVinner x (
LpRRVscale prts l y) =
l *
L2RRVinner x y.
Proof.
Lemma L2RRV_Cauchy_Schwarz (
x1 x2 :
LpRRV prts 2) :
0 <
L2RRVinner x2 x2 ->
Rsqr (
L2RRVinner x1 x2) <= (
L2RRVinner x1 x1)*(
L2RRVinner x2 x2).
Proof.
Ltac L2RRV_simpl
:=
repeat match goal with
| [
H :
LpRRV _ _ |-
_ ] =>
destruct H as [???]
end
;
unfold LpRRVplus,
LpRRVminus,
LpRRVopp,
LpRRVscale
;
simpl.
Lemma L2RRV_L2_L1
(
x :
LpRRV prts 2) :
Rsqr (
FiniteExpectation prts x) <=
FiniteExpectation prts (
rvsqr x).
Proof.
Lemma conv_l2_l1
(
Xn:
nat ->
Ts ->
R)
(
rvxn :
forall n,
RandomVariable dom borel_sa (
Xn n))
(
isl:
forall n,
IsLp prts 2 (
Xn n)):
is_lim_seq (
fun n =>
FiniteExpectation prts (
rvsqr (
rvabs (
Xn n)))) 0 ->
is_lim_seq (
fun n =>
FiniteExpectation prts (
rvabs (
Xn n))) 0.
Proof.
Lemma conv_l2_l1_minus
(
X:
Ts ->
R)
(
Xn:
nat ->
Ts ->
R)
(
rvx :
RandomVariable dom borel_sa X)
(
rvxn :
forall n,
RandomVariable dom borel_sa (
Xn n))
(
isl:
forall n,
IsLp prts 2 (
rvminus X (
Xn n))) :
is_lim_seq (
fun n =>
FiniteExpectation prts (
rvsqr (
rvabs (
rvminus X (
Xn n))))) 0 ->
is_lim_seq (
fun n =>
FiniteExpectation prts (
rvabs (
rvminus X (
Xn n)))) 0.
Proof.
Definition L2RRVq_inner :
LpRRVq prts 2 ->
LpRRVq prts 2 ->
R
:=
quot_lift2_to _ L2RRVinner.
Lemma L2RRVq_innerE x y :
L2RRVq_inner (
Quot _ x) (
Quot _ y) = (
L2RRVinner x y).
Proof.
Hint Rewrite L2RRVq_innerE :
quot.
Lemma L2RRVq_inner_comm (
x y :
LpRRVq_ModuleSpace prts nneg2) :
L2RRVq_inner x y =
L2RRVq_inner y x.
Proof.
Lemma L2RRVq_inner_pos (
x :
LpRRVq_ModuleSpace prts nneg2) : 0 <=
L2RRVq_inner x x.
Proof.
Lemma L2RRVq_inner_zero_inv (
x:
LpRRVq_ModuleSpace prts nneg2) :
L2RRVq_inner x x = 0 ->
x =
zero.
Proof.
Lemma L2RRVq_inner_scal (
x y :
LpRRVq_ModuleSpace prts nneg2) (
l :
R) :
L2RRVq_inner (
scal l x)
y =
l *
L2RRVq_inner x y.
Proof.
Lemma L2RRVq_inner_plus (
x y z :
LpRRVq_ModuleSpace prts nneg2) :
L2RRVq_inner (
plus x y)
z =
L2RRVq_inner x z +
L2RRVq_inner y z.
Proof.
Definition L2RRVq_PreHilbert_mixin :
PreHilbert.mixin_of (
LpRRVq_ModuleSpace prts nneg2)
:=
PreHilbert.Mixin (
LpRRVq_ModuleSpace prts nneg2)
L2RRVq_inner
L2RRVq_inner_comm L2RRVq_inner_pos L2RRVq_inner_zero_inv
L2RRVq_inner_scal L2RRVq_inner_plus.
Canonical L2RRVq_PreHilbert :=
PreHilbert.Pack (
LpRRVq prts 2) (
PreHilbert.Class _ _ L2RRVq_PreHilbert_mixin) (
LpRRVq prts 2).
Context {
p:
R}.
Context (
pbig:1 <=
p).
Lemma L2RRVq_Cauchy_Schwarz (
x1 x2 :
LpRRVq prts 2) :
0 <
L2RRVq_inner x2 x2 ->
Rsqr (
L2RRVq_inner x1 x2) <= (
L2RRVq_inner x1 x1)*(
L2RRVq_inner x2 x2).
Proof.
Lemma L2RRVq_norm_norm (
x :
LpRRVq prts 2) :
Hnorm x =
LpRRVq_norm prts x.
Proof.
Lemma L2RRVq_ball_ball (
x :
LpRRVq prts 2)
eps (
y :
LpRRVq prts 2) :
ball x eps y <->
LpRRVq_ball prts big2 x eps y.
Proof.
Lemma Hnorm_minus_opp {
T:
PreHilbert} (
a b:
T) :
(
Hnorm (
minus a b) =
Hnorm (
minus b a)).
Proof.
Lemma hball_pre_uniform_eq x eps :
@
Hierarchy.ball (@
PreHilbert_UniformSpace L2RRVq_PreHilbert)
x (
pos eps)
= @
Hierarchy.ball (
LpRRVq_UniformSpace prts 2
big2)
x (
pos eps).
Proof.
Lemma hball_pre_uniform (
F : (
PreHilbert_UniformSpace ->
Prop) ->
Prop)
x eps :
F (@
Hierarchy.ball (@
PreHilbert_UniformSpace L2RRVq_PreHilbert)
x (
pos eps)) ->
F (@
Hierarchy.ball (
LpRRVq_UniformSpace prts 2
big2)
x (
pos eps)).
Proof.
Lemma cauchy_pre_uniform (
F : (
PreHilbert_UniformSpace ->
Prop) ->
Prop) :
@
cauchy (@
PreHilbert_UniformSpace L2RRVq_PreHilbert)
F ->
@
cauchy (
LpRRVq_UniformSpace prts 2
big2)
F.
Proof.
intros HH eps.
destruct (
HH eps)
as [
x HH2].
exists x.
now apply hball_pre_uniform.
Qed.
Lemma L2RRVq_lim_complete (
F : (
PreHilbert_UniformSpace ->
Prop) ->
Prop) :
ProperFilter F ->
cauchy F ->
forall eps :
posreal,
F (
ball (
LpRRVq_lim prts big2 F)
eps).
Proof.
Definition L2RRVq_Hilbert_mixin :
Hilbert.mixin_of (
L2RRVq_PreHilbert)
:=
Hilbert.Mixin (
L2RRVq_PreHilbert) (
LpRRVq_lim prts big2)
L2RRVq_lim_complete.
Canonical L2RRVq_Hilbert :=
Hilbert.Pack (
LpRRVq prts 2) (
Hilbert.Class _ _ L2RRVq_Hilbert_mixin) (
LpRRVq prts 2).
End L2.