Module mathcomp.analysis.probability_theory.subpmf
From HB Require Import structures.From mathcomp Require Import boot order algebra.
#[warning="-warn-library-file-internal-analysis"]
From mathcomp Require Import unstable.
From mathcomp Require Import boolp classical_sets functions filter.
From mathcomp Require Import cardinality fsbigop reals.
From mathcomp Require Import topology normedtype sequences esum ereal numfun.
From mathcomp Require Import measure lebesgue_measure measurable_realfun
lebesgue_integral giry hoelder random_variable.
Reserved Notation "R '.-pmf' T"
(at level 1, T at level 2, format "R '.-pmf' T ").
Reserved Notation "\P_[ mu ] E" (at level 2, format "\P_[ mu ] E").
Reserved Notation "\P_[ mu , A ] E" (at level 2, format "\P_[ mu , A ] E").
Reserved Notation "\E_[ mu ] f" (at level 2, format "\E_[ mu ] f").
Reserved Notation "\E_[ mu , A ] f" (at level 2, format "\E_[ mu , A ] f").
Reserved Notation "\bind_ ( i <- d ) E"
(at level 36, E at level 36, i, d at level 50,
format "'[' \bind_ ( i <- d ) '/ ' E ']'").
Reserved Notation "\lim_ ( n ) E"
(at level 36, E at level 36, n at level 50,
format "'[' \lim_ ( n ) '/ ' E ']'").
Declare Scope subpmf_scope.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Import Order.TTheory GRing.Theory Num.Theory.
Local Open Scope ring_scope.
Local Open Scope classical_set_scope.
Local Notation "f '<=1' g"Source code := (forall xSource code, f x <= g x)
(at level 70, no associativity).
Local Notation "f '<=2' g"Source code := (forall xSource code ySource code, f x y <= g x y)
(at level 70, no associativity).
Definition discrete_measurable_space
discrete_measurable_space : choiceType -> Type discrete_measurable_space is not universe polymorphic Arguments discrete_measurable_space T discrete_measurable_space is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.discrete_measurable_space Declared in library mathcomp.analysis.probability_theory.subpmf, line 107, characters 11-36
Source code (TSource code : choiceType) : Type := T.
HBSource code.instanceSource code DefinitionSource code _Source code (TSource code :Source code choiceTypeSource code) :=
Choice.on (discrete_measurable_space T).
HBSource code.instanceSource code DefinitionSource code _Source code (TSource code :Source code choiceTypeSource code) := @isMeasurable.Build
default_measure_display (discrete_measurable_space T)
discrete_measurable discrete_measurable0
discrete_measurableC discrete_measurableU.
Lemma esum_setT_discreteSource code {RSource code : realType} {TSource code : choiceType} (fSource code : T -> \bar R) :
\esum_(xSource code in [set: discrete_measurable_space T]) f x =
\esum_(xSource code in [set: T]) f x.
Proof.
Lemma measurable_discreteSource code {TSource code : choiceType}
(ASource code : set (discrete_measurable_space T)) :
measurable A.
Proof.
#[global] Hint Resolve measurable_discrete : core.
Lemma measurable_fun_discreteSource code {TSource code : choiceType} {d'Source code} {USource code : sigmaRingType d'}
(DSource code : set (discrete_measurable_space T))
(fSource code : discrete_measurable_space T -> U) :
measurable_fun D f.
Proof.
#[global] Hint Resolve measurable_fun_discrete : core.
Lemma measurable_fun_discreteTSource code {TSource code USource code : choiceType} (hSource code : T -> U) :
measurable_fun [set: discrete_measurable_space T]
(h : discrete_measurable_space T -> discrete_measurable_space U).
Proof.
HBSource code.mixinSource code RecordSource code isSubPmfSource code {RSource code :Source code realType}Source code {T : choiceType} (mu : T -> R) := {
subpmf_ge0 : forall xSource code, 0 <= mu x ;
subpmf_summable : esummable [set: T] (EFin \o mu);
subpmf_sum_le1 : (esum [set: T] (EFin \o mu) <= 1)%E }.
HBSource code.structureSource code DefinitionSource code SubPmfSource code {RSource code :Source code realType}Source code {T : choiceType} :=
{fSource code of @isSubPmf R T f}.
Arguments subpmf_ge0 {R T} _.
Arguments subpmf_sum_le1 {R T} _.
#[global] Hint Extern 0 (is_true (0 <= _)) => solve [apply: subpmf_ge0] : core.
#[global] Hint Resolve subpmf_summable : core.
Notation "R '.-pmf' T"Source code := (@SubPmf.type R T) : subpmf_scope.
Local Open Scope subpmf_scope.
Lemma subpmf_eqPSource code {RSource code : realType} {TSource code : choiceType} (f1Source code f2Source code : R.-pmf T) :
f1 =1 f2 <-> f1 = f2.
Proof.
case: f1 => f1 [[]ge0_1 s1 le1_1].
case: f2 => f2 [[]ge0_2 s2 le1_2].
move => /funext /= h.
by subst; do 3 f_equal.
Qed.
Definition measure_of_pmf
measure_of_pmf : forall {R : realType} {T : choiceType}, (T -> R) -> set (discrete_measurable_space T) -> GRing.BaseAddMagma.sort \bar R measure_of_pmf is not universe polymorphic Arguments measure_of_pmf {R T} mu%_function_scope S%_classical_set_scope measure_of_pmf is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.measure_of_pmf Declared in library mathcomp.analysis.probability_theory.subpmf, line 171, characters 11-25
Source code {RSource code : realType} {TSource code : choiceType} (muSource code : T -> R)
(SSource code : set (discrete_measurable_space T)) :=
\esum_(xSource code in S) (EFin \o mu) x.
Context {RSource code : realType} {TSource code : choiceType} (muSource code : R.-pmf T).
Let P0Source code : measure_of_pmf mu set0 = 0.
Proof.
Let P_ge0Source code (SSource code : set (discrete_measurable_space T)) : (0 <= measure_of_pmf mu S)%E.
Let P_sigma_additiveSource code : semi_sigma_additive (measure_of_pmf mu).
Proof.
rewrite [X in _ --> X](_ : _ = \sum_(iSource code <oo) measure_of_pmf mu (F i))%E.
rewrite nneseries_esumT//; apply: esum_bigcup => //=.
exact: (sub_trivIset (@subsetT _ _)).
by move=> x; rewrite lee_fin.
by apply: is_cvg_nneseries => n _ _; apply: esum_ge0 => x _; rewrite lee_fin.
Qed.
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code isMeasureSource code.Build _ _ _ (measure_of_pmf mu)
P0 P_ge0 P_sigma_additive.
Let P_setTSource code : (measure_of_pmf mu [set: discrete_measurable_space T] <= 1)%E.
Proof.
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
@Measure_isSubProbabilitySource code.Build _ _ R (measure_of_pmf mu) P_setT.
End SubProbability_measure_subpmf.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (mu : R.-pmf T).
Local Open Scope ereal_scope.
Lemma integral_measure_of_pmfSource code muSource code (fSource code : T -> \bar R) : (forall xSource code, 0 <= f x) ->
\int[measure_of_pmf mu]_xSource code f x = \esum_(xSource code in [set: T]) (f x * (mu x)%:E).
Proof.
rewrite -(@integral_measure_of_density _ (discrete_measurable_space T) R
(@counting (discrete_measurable_space T) R) mu)//=.
move => H; apply: eq_measure_integral => A mA _ /=.
by rewrite /measure_of_density /measure_of_pmf integral_counting_esum.
Qed.
Lemma esummable_integrableSource code muSource code (ASource code : T -> \bar R) :
esummable [set: T] (fun xSource code : T => A x * (mu x)%:E)%E <->
(measure_of_pmf mu).-integrable [set: discrete_measurable_space T] A.
Proof.
under eq_esum do rewrite abseM abse_EFin (@ger0_norm _ (mu _))//.
rewrite ge0_fin_numE//.
by rewrite esum_ge0// => x _; rewrite mule_ge0 ?lee_fin ?abse_ge0.
split=> [Amu|/integrableP[_]].
apply/integrableP; split => //.
by rewrite integral_measure_of_pmf// => x; rewrite abse_ge0.
by rewrite integral_measure_of_pmf// => x; rewrite abse_ge0.
Qed.
Lemma expectation_pmfSource code muSource code (fSource code : T -> \bar R) :
'E_(measure_of_pmf mu)[f] = \esum_(xSource code in [set:T]) (f x * (mu x)%:E).
Proof.
Lemma expectation_pmfEFinSource code muSource code (gSource code : T -> R) :
'E_(measure_of_pmf mu) [EFin \o g] = \esum_(xSource code in [set: T]) (g x * mu x)%:E.
Proof.
Lemma expectation_pmf0Source code muSource code : 'E_(measure_of_pmf mu) [cst 0] = 0.
End expectation_measure_of_pmf.
HBSource code.factorySource code RecordSource code uniq_isSubPmfSource code {RSource code :Source code realType}Source code {T : choiceType} (mu : T -> R) := {
subpmf_ge0 : forall xSource code : T, 0 <= mu x ;
uniq_subpmf_le1 : forall JSource code, uniq J -> \sum_(jSource code <- J) mu j <= 1 }.
HBSource code.buildersSource code ContextSource code {RSource code :Source code realType}Source code {T : choiceType} (mu : T -> R)
& @uniq_isSubPmf R T mu.
Local Lemma pmf_ge0Source code xSource code : 0 <= mu x.
Proof.
Local Lemma pmf_summableSource code : esummable [set: T] (EFin \o mu).
Proof.
by move => ? _; rewrite lee_fin.
rewrite ge_ereal_sup//= => _ [X [finX _]] <-.
rewrite fsumEFin// lee_fin fsbig_finite//=.
rewrite (eq_bigr mu) ?uniq_subpmf_le1//.
by move => ? _; rewrite ger0_norm// subpmf_ge0.
Qed.
Local Lemma pmf_le1Source code : (esum [set: T] (EFin \o mu) <= 1)%E.
Proof.
by move => ? _; rewrite lee_fin subpmf_ge0.
rewrite ge_ereal_sup//= => _ [X [finX _]] <-.
by rewrite fsumEFin// lee_fin fsbig_finite//= uniq_subpmf_le1.
Qed.
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code @isSubPmfSource code.Build R T mu pmf_ge0 pmf_summable pmf_le1.
HBSource code.endSource code.
Import MeasurableR.
Context {dSource code} {TSource code : measurableType d} {RSource code : realType} (PSource code : probability T R)
(XSource code : {RV P >-> R}).
Let pmf_fin_bigcupSource code (JSource code : seq R) : uniq J ->
\sum_(jSource code <- J) (pmf X j)%:E = P (\bigcup_(jSource code in [set` J]) X @^-1` [set j]).
Proof.
rewrite (@measure_fin_bigcup _ _ _ P _ [set` J] (fun jSource code => X @^-1` [set j]))//.
- exact: finite_seq.
- exact: trivIset_preimage1.
- rewrite fsbig_seq//; apply: eq_fsbigr => j _.
by rewrite /pmf fineK// fin_num_measure.
Qed.
Let pmf_uniq_le1Source code (JSource code : seq R) : uniq J -> (\sum_(jSource code <- J) pmf X j <= 1)%R.
Proof.
by rewrite probability_le1//; exact: fin_bigcup_measurable.
Qed.
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
@uniq_isSubPmfSource code.Build R R (pmf X) (@pmf_ge0 _ _ _ P X) pmf_uniq_le1.
End pmf_subpmf.
Lemma subpmf_le1Source code {RSource code : realType} {TSource code : choiceType} (muSource code : R.-pmf T) xSource code : mu x <= 1.
Proof.
by rewrite esum_ge1// => ? _; rewrite lee_fin.
Qed.
Context {RSource code : realType} (TSource code : choiceType).
Implicit Types (mu : R.-pmf T) (A B E : pred T) (f : T -> R).
Definition pmf_prob
pmf_prob : forall {R : realType} [T : choiceType], SubPmf.type R T -> pred T -> R pmf_prob is not universe polymorphic Arguments pmf_prob {R} [T] mu E pmf_prob is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_prob Declared in library mathcomp.analysis.probability_theory.subpmf, line 323, characters 11-19
Source code muSource code ESource code := fine (\esum_(xSource code in [set: T]) ((E x)%:R * mu x)%:E).
Local Notation "\P_[ mu ] E"Source code := (pmf_prob mu E).
Definition pmf_cprob
pmf_cprob : forall {R : realType} [T : choiceType], SubPmf.type R T -> pred T -> pred T -> R pmf_cprob is not universe polymorphic Arguments pmf_cprob {R} [T] mu E A pmf_cprob is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_cprob Declared in library mathcomp.analysis.probability_theory.subpmf, line 327, characters 11-20
Source code muSource code ESource code ASource code := \P_[mu] [predI E & A] / \P_[mu] A.
Local Notation "\P_[ mu , A ] E"Source code := (pmf_cprob mu A E).
Definition pmf_expectation
pmf_expectation : forall {R : realType} [T : choiceType], SubPmf.type R T -> (T -> R) -> R pmf_expectation is not universe polymorphic Arguments pmf_expectation {R} [T] mu f%_function_scope pmf_expectation is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_expectation Declared in library mathcomp.analysis.probability_theory.subpmf, line 331, characters 11-26
Source code muSource code fSource code := fine (\esum_(xSource code in [set: T]) (f x * mu x)%:E).
Definition pmf_cexpectation
pmf_cexpectation : forall {R : realType} [T : choiceType], SubPmf.type R T -> (T -> R) -> pred T -> R pmf_cexpectation is not universe polymorphic Arguments pmf_cexpectation {R} [T] mu f%_function_scope A pmf_cexpectation is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_cexpectation Declared in library mathcomp.analysis.probability_theory.subpmf, line 333, characters 11-27
Source code muSource code fSource code ASource code :=
fine (\esum_(xSource code in [set: T]) (f x * \P_[mu, pred1 x] A)%:E).
Definition pmf_esummable
pmf_esummable : forall {R : realType} [T : choiceType], SubPmf.type R T -> (T -> R) -> bool pmf_esummable is not universe polymorphic Arguments pmf_esummable {R} [T] mu f%_function_scope pmf_esummable is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_esummable Declared in library mathcomp.analysis.probability_theory.subpmf, line 336, characters 11-24
Source code muSource code fSource code := esummable [set: T] (EFin \o (f \* mu)).
End StdDefs.
Notation "\P_[ mu ] E"Source code := (pmf_prob mu E) : subpmf_scope.
Notation "\P_[ mu , A ] E"Source code := (pmf_cprob mu E A) : subpmf_scope.
Notation "\E_[ mu ] f"Source code := (pmf_expectation mu f) : subpmf_scope.
Notation "\E_[ mu , A ] f"Source code := (pmf_cexpectation mu f A) : subpmf_scope.
Notation dweightSource code mu := (\P_[mu] predT).
Definition subpmf_sum
subpmf_sum : forall {R : realType} {T : choiceType}, (T -> R) -> Prop subpmf_sum is not universe polymorphic Arguments subpmf_sum {R T} mu%_function_scope subpmf_sum is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.subpmf_sum Declared in library mathcomp.analysis.probability_theory.subpmf, line 346, characters 11-21
Source code {RSource code : realType} {TSource code : choiceType} (muSource code : T -> R) :=
(forall xSource code, 0 <= mu x) /\ (forall JSource code, uniq J -> \sum_(jSource code <- J) mu j <= 1).
Lemma subpmf_sumPSource code {RSource code : realType} {ISource code : finType} (muSource code : I -> R) :
subpmf_sum mu <-> (forall xSource code, 0 <= mu x) /\ (\sum_jSource code mu j <= 1).
Proof.
Context {RSource code : realType} {TSource code : choiceType}.
Local Definition pmf_zero'
pmf_zero' not a defined object.
Source code (xSource code : T) : R := 0.
Let subpmf_zeroSource code : subpmf_sum pmf_zero'.
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
@uniq_isSubPmfSource code.Build R T pmf_zero' subpmf_zero.1 subpmf_zero.2.
End pmf_zero.
Definition pmf_zero
pmf_zero : forall {R : realType} {T : choiceType}, SubPmf.type R T pmf_zero is not universe polymorphic Arguments pmf_zero {R T} pmf_zero is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_zero Declared in library mathcomp.analysis.probability_theory.subpmf, line 371, characters 11-19
Source code {RSource code : realType} {TSource code : choiceType} : R.-pmf T :=
@pmf_zero' R T.
Lemma pmf_zeroESource code {RSource code : realType} {TSource code : choiceType} (xSource code : T) : pmf_zero x = 0 :> R.
Proof.
Lemma lef_pmf_zeroSource code {RSource code : realType} {TSource code : choiceType} (muSource code : R.-pmf T) :
pmf_zero <=1 mu.
Proof.
Lemma measure_of_pmf_zeroSource code {RSource code : realType} {TSource code : choiceType}
(SSource code : set (discrete_measurable_space T)) :
measure_of_pmf pmf_zero S = mzero S :> \bar R.
Proof.
Context {RSource code : realType} {TSource code : choiceType} (pSource code : pred T).
Definition pmf_restr'
pmf_restr' : forall {R : realType} {T : choiceType}, pred T -> SubPmf.type R T -> T -> R pmf_restr' is not universe polymorphic Arguments pmf_restr' {R T} p mu x pmf_restr' is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_restr' Declared in library mathcomp.analysis.probability_theory.subpmf, line 389, characters 11-21
Source code (muSource code : R.-pmf T) := fun xSource code => if p x then mu x else 0.
Let subpmf_restrSource code (muSource code : R.-pmf T) : subpmf_sum (pmf_restr' mu).
Proof.
move=> eqJ; apply/(@le_trans _ _ (\sum_(jSource code <- J) `|mu j|)).
- apply/ler_sum=> i _; rewrite /pmf_restr'; case: ifPn => _ //.
exact: ler_norm.
- rewrite -lee_fin (le_trans _ (subpmf_sum_le1 mu))//.
rewrite (@eq_esum _ _ _ _ (fun ySource code => `|(EFin \o mu) y|%E))//=.
by move=> *; rewrite ger0_norm.
exact: sum_esum_ge.
Qed.
HBSource code.instanceSource code DefinitionSource code _Source code (muSource code :Source code RSource code.-pmf T) := @uniq_isSubPmf.Build R T
(pmf_restr' mu) (subpmf_restr mu).1 (subpmf_restr mu).2.
Definition pmf_restr
pmf_restr : forall {R : realType} {T : choiceType}, pred T -> SubPmf.type R T -> SubPmf.type R T pmf_restr is not universe polymorphic Arguments pmf_restr {R T} p _ pmf_restr is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_restr Declared in library mathcomp.analysis.probability_theory.subpmf, line 406, characters 11-20
Source code : R .-pmf T -> R .-pmf T := pmf_restr'.
End Restr.
Lemma pmf_restrESource code {RSource code : realType} {TSource code : choiceType} pSource code muSource code {xSource code:T} :
pmf_restr p mu x = if p x then mu x else 0 :>R.
Proof.
Lemma measure_of_pmf_restrSource code {RSource code : realType} {TSource code : choiceType} (pSource code : pred T)
(muSource code : R.-pmf T)
(mpSource code : measurable ([set` p] : set (discrete_measurable_space T)))
(SSource code : set (discrete_measurable_space T)) :
measure_of_pmf (pmf_restr p mu) S = mrestr (measure_of_pmf mu) mp S.
Proof.
by rewrite /pmf_restr mem_setE unfold_in (fun_if EFin).
Qed.
Import MeasurableR.
Context {dSource code} {TSource code : pmeasurableType d} {RSource code : realType} (PSource code : probability T R)
(XSource code : {dRV P >-> R}).
Local Notation pmfXSource code := (@pmf _ _ _ P X).
Lemma esum_pmf_setTSource code :
esum [set: R] (EFin \o pmfX) = \esum_(rSource code in range X) (pmfX r)%:E.
Proof.
Lemma esum_pmf_range1Source code : \esum_(rSource code in range X) (pmfX r)%:E = 1%E.
Proof.
transitivity (\esum_(kSource code in dRV_dom X) enum_prob X k).
apply: eq_esum => k kd/=.
by rewrite /enum_prob patchE mem_set// /pmf fineK// fin_num_measure.
rewrite -[X in \esum_(kSource code in X) _]set_mem_set -nneseries_esum.
by move=> n _; rewrite /enum_prob patchE; case: ifP.
rewrite eseries_mkcond -[RHS](sum_enum_prob X measurable_set1).
apply: eq_eseriesr => k _; case: ifPn => // kd.
by rewrite /enum_prob patchE (negbTE kd).
Qed.
Lemma esum_pmf_predSource code (ASource code : set R) :
esum [set: R] (EFin \o (fun rSource code => (r \in A)%:R * pmfX r))%R =
\esum_(rSource code in A) (pmfX r)%:E.
Proof.
Lemma pmf_prob_dRVSource code (ASource code : set R) : measurable A ->
(\P_[pmfX] (mem A))%:E = distribution P X A.
Proof.
by rewrite fin_num_measure.
Qed.
End pr_pmf.
Context {RSource code : realType} {TSource code : choiceType}.
Lemma pmf_restrDSource code (muSource code : R.-pmf T) (pSource code : pred T) xSource code :
mu x = pmf_restr p mu x + pmf_restr (predC p) mu x.
Lemma supp_pmf_restrSource code (muSource code : R.-pmf T) (pSource code : pred T) xSource code :
(x \in supp (pmf_restr p mu)) = (x \in supp mu) && p x.
Proof.
- by rewrite pmf_restrE; case: ifP=> // _ /mem_suppP ->.
- by case/andP; rewrite pmf_restrE => /mem_suppP ? ->.
Qed.
End RestrTheory.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (s : seq T).
Local Definition pmf_count'
pmf_count' not a defined object.
Source code (sSource code : seq T) : T -> R :=
fun xSource code : T => (count (pred1 x) s)%:R / (size s)%:R.
Local Lemma pmf_count_ge0Source code sSource code xSource code : 0 <= pmf_count' s x.
Local Lemma pmf_count_sum_le1Source code sSource code JSource code : uniq J -> \sum_(iSource code <- J) pmf_count' s i <= 1.
Proof.
by move=> ->; rewrite invr0 mulr0 ler01.
move=> /eqP nz_s; rewrite ler_pdivrMr ?ltr0n ?lt0n // mul1r.
rewrite ler_nat (bigID (mem s)) /= [X in (_+X)%N]big1 ?addn0.
by move=> i /count_memPn.
have -> : (size s = \sum_(iSource code <- undup s) count_mem i s)%N.
rewrite -sum1_size -big_undup_iterop_count; apply: eq_bigr => i _.
by rewrite Monoid.iteropE iter_addn addn0 mul1n.
rewrite [X in (_ <= X)%N](bigID (mem J)) /= -ltnS -addSn.
rewrite ltn_addr //= ltnS -big_filter -[X in (_ <= X)%N]big_filter.
rewrite leq_eqVlt; apply/orP; left; apply/eqP/perm_big.
apply/uniq_perm; rewrite ?filter_uniq ?undup_uniq//.
by move=> x; rewrite !mem_filter mem_undup andbC.
Qed.
Let subpmf_countSource code sSource code : subpmf_sum (pmf_count' s).
Proof.
HBSource code.instanceSource code DefinitionSource code _Source code (sSource code :Source code seqSource code T) :=
@uniq_isSubPmf.Build R T (pmf_count' s) (subpmf_count s).1 (subpmf_count s).2.
Definition pmf_count
pmf_count : forall {R : realType} {T : choiceType}, seq T -> SubPmf.type R T pmf_count is not universe polymorphic Arguments pmf_count {R T} s%_seq_scope pmf_count is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_count Declared in library mathcomp.analysis.probability_theory.subpmf, line 520, characters 11-20
Source code sSource code : R.-pmf T := pmf_count' s.
Lemma pmf_countESource code sSource code xSource code : pmf_count s x = (count (pred1 x) s)%:R / (size s)%:R.
Proof.
Lemma pmf_count_sum_eq1Source code sSource code : (0 < size s)%N ->
\sum_(iSource code <- undup s) pmf_count s i = 1.
Proof.
Lemma esummable_pmf_countSource code sSource code : esummable [set :T] (EFin \o (pmf_count s)).
Proof.
by move => *; rewrite lee_fin.
rewrite ge_ereal_sup//= => _ [X [finX _]] <-.
rewrite fsumEFin // lee_fin fsbig_finite //=.
rewrite (eq_bigr (pmf_count s)).
by move => ? ?; rewrite ger0_norm ?pmf_count_ge0.
exact/pmf_count_sum_le1.
Qed.
End DCount.
HB
pmf_ret_unlock_subterm : unlockable (fun (R : realType) (T : choiceType) (x : T) => pmf_count [:: x]) pmf_ret_unlock_subterm is not universe polymorphic pmf_ret_unlock_subterm is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_ret_unlock_subterm Declared in library mathcomp.analysis.probability_theory.subpmf, line 548, characters 0-100
Source code.lock
pmf_ret_unlock_subterm : unlockable (fun (R : realType) (T : choiceType) (x : T) => pmf_count [:: x]) pmf_ret_unlock_subterm is not universe polymorphic pmf_ret_unlock_subterm is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_ret_unlock_subterm Declared in library mathcomp.analysis.probability_theory.subpmf, line 548, characters 0-100
Source code Definition
pmf_ret_unlock_subterm : unlockable (fun (R : realType) (T : choiceType) (x : T) => pmf_count [:: x]) pmf_ret_unlock_subterm is not universe polymorphic pmf_ret_unlock_subterm is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_ret_unlock_subterm Declared in library mathcomp.analysis.probability_theory.subpmf, line 548, characters 0-100
Source code pmf_ret
pmf_ret_unlock_subterm : unlockable (fun (R : realType) (T : choiceType) (x : T) => pmf_count [:: x]) pmf_ret_unlock_subterm is not universe polymorphic pmf_ret_unlock_subterm is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_ret_unlock_subterm Declared in library mathcomp.analysis.probability_theory.subpmf, line 548, characters 0-100
Source code {R
pmf_ret_unlock_subterm : unlockable (fun (R : realType) (T : choiceType) (x : T) => pmf_count [:: x]) pmf_ret_unlock_subterm is not universe polymorphic pmf_ret_unlock_subterm is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_ret_unlock_subterm Declared in library mathcomp.analysis.probability_theory.subpmf, line 548, characters 0-100
Source code : realType} {TSource code : choiceType} (xSource code : T) : R.-pmf T :=
pmf_count [:: x].
Canonical locked_pmf_ret
locked_pmf_ret : unlockable (fun (R : realType) (T : choiceType) (x : T) => pmf_count [:: x]) locked_pmf_ret is not universe polymorphic locked_pmf_ret is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.locked_pmf_ret Declared in library mathcomp.analysis.probability_theory.subpmf, line 550, characters 10-24
Source code := Unlockable pmf_ret.unlock.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (x y : T) (s : seq T).
Lemma pmf_retESource code xSource code ySource code : pmf_ret x y = (x == y)%:R :> R.
Proof.
Lemma pmf_retxxSource code xSource code : pmf_ret x x = 1 :> R.
Lemma pmf_ret0Source code xSource code ySource code : x != y -> (pmf_ret x) y = 0 :> R.
Proof.
Lemma in_pmf_retSource code (tSource code t'Source code : T) : t' \in @supp R _ (pmf_ret t) -> t' = t :> T.
End pmf_ret.
Lemma measure_of_pmf_retSource code {RSource code : realType} {TSource code : choiceType} (xSource code : T)
(SSource code : set (discrete_measurable_space T)) :
measure_of_pmf (pmf_ret x) S = \d_(x : discrete_measurable_space T) S :> \bar R.
Proof.
rewrite (@eq_esum R T _ _ (fun ySource code => if x == y then (y \in S)%:R%:E else 0%E)).
by move=> y _ /=; rewrite pmf_retE; case: ifPn => yS //; case: ifPn.
by rewrite esum_if_eq_op_set1.
Qed.
Definition pmf_uniform
pmf_uniform : forall {R : realType} {T : choiceType}, seq T -> SubPmf.type R T pmf_uniform is not universe polymorphic Arguments pmf_uniform {R T} s%_seq_scope pmf_uniform is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_uniform Declared in library mathcomp.analysis.probability_theory.subpmf, line 583, characters 11-22
Source code {RSource code : realType} {TSource code : choiceType} (sSource code : seq T) : R.-pmf T :=
pmf_count (undup s).
Lemma pmf_uniformESource code {RSource code : realType} {TSource code : choiceType} (sSource code : seq T) xSource code :
(pmf_uniform s) x = (x \in s)%:R / (size (undup s))%:R :> R.
Proof.
Context {RSource code : realType}.
Local Notation clampSource code := (@clamp R 0 1).
Definition pmf_flip'
pmf_flip' : forall {R : realType}, R -> bool -> R pmf_flip' is not universe polymorphic Arguments pmf_flip' {R} xt%_ring_scope b%_bool_scope pmf_flip' is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_flip' Declared in library mathcomp.analysis.probability_theory.subpmf, line 597, characters 11-20
Source code (xtSource code : R) := fun bSource code => if b then clamp xt else 1 - clamp xt.
Let subpmf_flipSource code xtSource code : subpmf_sum (pmf_flip' xt).
Proof.
by case: b; rewrite ?subr_ge0 clamp_gele.
by rewrite /index_enum !unlock /= addr0 addrC subrK.
Qed.
HBSource code.instanceSource code DefinitionSource code _Source code (xtSource code :Source code RSource code) :=
@uniq_isSubPmf.Build R _ (pmf_flip' xt) (subpmf_flip xt).1 (subpmf_flip xt).2.
Definition pmf_flip
pmf_flip : forall {R : realType}, R -> SubPmf.type R bool pmf_flip is not universe polymorphic Arguments pmf_flip {R} xt%_ring_scope pmf_flip is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_flip Declared in library mathcomp.analysis.probability_theory.subpmf, line 609, characters 11-19
Source code xtSource code : R.-pmf bool := pmf_flip' xt.
Lemma pmf_flipESource code xtSource code bSource code : pmf_flip xt b = if b then clamp xt else 1 - clamp xt.
Proof.
End Flip.
Context {RSource code : realType} {TSource code USource code : choiceType} (fSource code : T -> R.-pmf U) (muSource code : R.-pmf T).
Local Definition pmf_bind'
pmf_bind' not a defined object.
Source code (ySource code : U) :=
fine (\esum_(xSource code in [set: T]) (mu x * f x y)%:E).
Let pmf_bind_ge0Source code xSource code : 0 <= pmf_bind' x.
Let subpmf_bindSource code : subpmf_sum pmf_bind'.
Proof.
rewrite /pmf_bind' -lee_fin.
have hpos x i : (0 <= (mu x * f x i)%:E)%E.
by rewrite EFinM mule_ge0//= lee_fin.
apply: le_trans; first exact: sum_esum_ge.
apply/(le_trans _ (subpmf_sum_le1 mu)).
apply/(le_trans (le_esum_fine _ _ hpos)).
rewrite exchange_esum// le_esum// => i _.
under eq_esum do rewrite EFinM.
rewrite esumZ ?lee_fin// => [?|]; first by rewrite lee_fin.
rewrite muleC gee_pMl ?lee_fin//; last exact: subpmf_sum_le1.
rewrite (eq_esum _ _ (fun xSource code => `|(EFin \o f i) x|%E)).
by move=> *; rewrite gee0_abs// lee_fin.
by rewrite -esummableE.
Qed.
HBSource code.instanceSource code DefinitionSource code _Source code :=Source code
@uniq_isSubPmfSource code.Build R U pmf_bind' subpmf_bind.1 subpmf_bind.2.
Definition pmf_bind
pmf_bind : forall {R : realType} {T U : choiceType}, (T -> SubPmf.type R U) -> SubPmf.type R T -> SubPmf.type R U pmf_bind is not universe polymorphic Arguments pmf_bind {R T U} f%_function_scope mu pmf_bind is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_bind Declared in library mathcomp.analysis.probability_theory.subpmf, line 648, characters 11-19
Source code : R.-pmf U := pmf_bind'.
End Bind.
Notation "\bind_ ( i <- d ) E"Source code := (pmf_bind (fun iSource code => E) d) : subpmf_scope.
Lemma pmf_bindESource code {RSource code : realType} {TSource code USource code : choiceType} (fSource code : T -> R.-pmf U)
(muSource code : R.-pmf T) (ySource code : U) :
(\bind_( iSource code <- mu) f i) y = fine (\esum_(xSource code in [set: T]) (mu x * f x y)%:E).
Proof.
Context {RSource code : realType} {TSource code USource code : choiceType}.
Implicit Types (f g : T -> R.-pmf U) (mu nu : R.-pmf T).
Lemma pmf_bind_zeroSource code fSource code : \bind_(xSource code <- pmf_zero) f x =1 pmf_zero.
Lemma pmf_ret_bindSource code fSource code vSource code : \bind_(ySource code <- pmf_ret v) f y =1 f v.
Proof.
Lemma pmf_bind_retSource code muSource code : \bind_(tSource code <- mu) (pmf_ret t) =1 mu.
Proof.
Lemma supp_eq_pmf_bindSource code fSource code gSource code muSource code nuSource code : {in supp mu, f =2 g} -> mu =1 nu ->
pmf_bind f mu =1 pmf_bind g nu.
Proof.
Lemma esummable_pmf_bind_eltSource code (fSource code : T -> R.-pmf U) (muSource code : R.-pmf T) ySource code :
esummable [set: T] (fun xSource code => (mu x * f x y)%:E).
Proof.
under eq_esum do rewrite EFinM.
apply: esummableMr => //.
exists 1%E => // => i _.
by rewrite gee0_abs lee_fin// subpmf_le1.
exact: subpmf_summable.
Qed.
Lemma pmf_bind_is_fin_numSource code (fSource code : T -> R.-pmf U) (muSource code : R.-pmf T) ySource code :
\esum_(xSource code in [set: T]) (mu x * f x y)%:E \is a fin_num.
Proof.
by move => ?; rewrite mulr_ge0.
by rewrite -esummableE; exact: esummable_pmf_bind_elt.
Qed.
Lemma EFin_pmf_bindSource code (fSource code : T -> R.-pmf U) (muSource code : R.-pmf T) ySource code :
(pmf_bind f mu y)%:E = \esum_(xSource code in [set: T]) (mu x * f x y)%:E.
Proof.
Lemma supp_le_pmf_bindSource code fSource code gSource code muSource code : {in supp mu, f <=2 g} ->
\bind_(iSource code <- mu) f i <=1 \bind_(iSource code <- mu) g i.
Proof.
Lemma le_pmf_bindSource code fSource code muSource code nuSource code : mu <=1 nu ->
\bind_(iSource code <- mu) f i <=1 \bind_(iSource code <- nu) f i.
Proof.
Lemma supp_le_pmf_bind2Source code fSource code gSource code muSource code nuSource code : mu <=1 nu ->
{in supp mu, forall xSource code, f x <=1 g x} ->
\bind_(xSource code <- mu) f x <=1 \bind_(xSource code <- nu) g x.
Proof.
Lemma pmf_bindCSource code (muSource code : R.-pmf T) (nuSource code : R.-pmf U) ySource code :
(\bind_(_ <- mu) nu) y = dweight mu * nu y.
Proof.
Lemma supp_pmf_bindSource code fSource code muSource code ySource code : y \in supp (\bind_(xSource code <- mu) f x) ->
exists2 xSource code, x \in supp mu & f x y != 0.
Proof.
Let esum_eq0_pmf_bind_eltSource code (fSource code : T -> R.-pmf U) (muSource code : R.-pmf T) xSource code ySource code:
fine (\esum_(xSource code in [set: T]) (mu x * f x y)%:E) = 0 ->
(mu x * f x y)%:E = 0.
Proof.
Lemma pmf_bind_mem_suppSource code fSource code muSource code xSource code ySource code :
x \in supp mu -> f x y != 0 -> y \in supp (pmf_bind f mu).
Proof.
Lemma pmf_bind_eq0Source code (fSource code : T -> U) muSource code ySource code :
{in supp mu, forall xSource code, f x != y} -> (\bind_(xSource code <- mu) pmf_ret (f x)) y = 0.
Proof.
Lemma eq0_pmf_bindSource code (muSource code : R.-pmf T) (FSource code : T -> R.-pmf U ) ySource code :
(\bind_(xSource code <- mu) F x) y = 0 -> forall xSource code, x \in supp mu -> F x y = 0.
Proof.
End BindTheory.
Definition pmf_bindr
pmf_bindr : forall {R : realType} {T : choiceType}, (T -> SubPmf.type R T) -> SubPmf.type R T -> SubPmf.type R T pmf_bindr is not universe polymorphic Arguments pmf_bindr {R T} f%_function_scope d pmf_bindr is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_bindr Declared in library mathcomp.analysis.probability_theory.subpmf, line 800, characters 11-20
Source code {RSource code : realType} {TSource code : choiceType} (fSource code : T -> R.-pmf T) :=
fun dSource code => \bind_(xSource code <- d) f x.
Definition pmf_iter
pmf_iter : forall {R : realType} {T : choiceType}, nat -> (T -> SubPmf.type R T) -> T -> SubPmf.type R T pmf_iter is not universe polymorphic Arguments pmf_iter {R T} n%_nat_scope f%_function_scope a pmf_iter is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_iter Declared in library mathcomp.analysis.probability_theory.subpmf, line 803, characters 11-19
Source code {RSource code : realType} {TSource code : choiceType} nSource code (fSource code : T -> R.-pmf T) :=
fun aSource code => iter n (pmf_bindr f) (pmf_ret a).
Context {RSource code : realType} {TSource code USource code : choiceType}.
Local Open Scope ereal_scope.
Lemma measure_of_pmf_bindSource code (muSource code : R.-pmf T) (nuSource code : T -> R.-pmf U)
(SSource code : set (discrete_measurable_space U)) :
measure_of_pmf (pmf_bind nu mu) S =
\int[measure_of_pmf mu]_xSource code measure_of_pmf (nu x) S.
Proof.
under eq_esum do rewrite /= EFin_pmf_bind.
rewrite exchange_esum.
by move=> i j; rewrite lee_fin mulr_ge0.
apply: eq_esum => x _.
by rewrite muleC -esumZ //= => y _; rewrite lee_fin.
Qed.
Lemma measurable_measure_of_pmfSource code (nuSource code : T -> R.-pmf U) :
measurable_fun [set: discrete_measurable_space T]
(fun xSource code => (measure_of_pmf (nu x) : giry (discrete_measurable_space U) R)).
Proof.
Lemma measure_of_pmf_bind_girySource code (muSource code : R.-pmf T) (nuSource code : T -> R.-pmf U)
(SSource code : set (discrete_measurable_space U)) :
measure_of_pmf (pmf_bind nu mu) S =
giry_bind (measure_of_pmf mu) (measurable_measure_of_pmf nu) S.
Proof.
End MeasureOfPmf_Bind.
Context {RSource code : realType} {TSource code USource code VSource code : choiceType}
(f1Source code : T -> R.-pmf U) (f2Source code : U -> R.-pmf V).
Lemma pmf_bind_pmf_bindSource code (muSource code : R.-pmf T) :
\bind_(xSource code <- \bind_(ySource code <- mu) f1 y) f2 x =1
\bind_(ySource code <- mu) (\bind_(xSource code <- f1 y) f2 x).
Proof.
pose S ySource code xSource code := mu x * f1 x y * f2 y z.
rewrite (eq_esum _ _ (fun ySource code => \esum_(xSource code in setT) (S y x)%:E)).
move=> y _; rewrite EFinM EFin_pmf_bind//.
rewrite muleC -esumZ ?lee_fin// => [? _|].
by rewrite EFinM lee_fin mulr_ge0.
by apply eq_esum => *; rewrite -EFinM mulrC.
rewrite (eq_esum _ _ (fun xSource code => \esum_(ySource code in setT) (S y x)%:E)).
move=> x _; rewrite EFinM EFin_pmf_bind//.
rewrite -esumZ ?lee_fin// => [? _|].
by rewrite EFinM lee_fin mulr_ge0.
by apply eq_esum => * ; rewrite -EFinM mulrA.
by rewrite exchange_esum// => ? ?; rewrite /S EFinM lee_fin ?mulr_ge0.
Qed.
End Pmf_BindPmf_Bind.
Context {RSource code : realType} {TSource code USource code : choiceType} (muSource code mu1Source code mu2Source code : R.-pmf T).
Lemma pmf_bind_additiveSource code (fSource code : T -> R.-pmf U) zSource code :
(forall xSource code, mu x = mu1 x + mu2 x) ->
(\bind_(xSource code <- mu) f x) z = (\bind_(xSource code <- mu1) f x) z + (\bind_(xSource code <- mu2) f x) z.
Proof.
End Pmf_BindAlg.
Context {RSource code : realType} (TSource code : choiceType).
Implicit Types (f g : nat -> R.-pmf T).
Import numFieldNormedType.Exports.
Local Definition pmf_lim'
pmf_lim' not a defined object.
Source code fSource code : T -> R :=
fun xSource code => fine (limn_einf (fun nSource code => (f n x)%:E)).
Local Lemma pmf_lim_ge0'Source code fSource code xSource code : (0 <= limn_einf (fun nSource code => (f n x)%:E))%E.
Proof.
apply: nearW => n; apply: le_ereal_inf => _ [m _] <-.
by rewrite lee_fin.
Qed.
Local Lemma pmf_lim_le1'Source code fSource code xSource code : (limn_einf (fun nSource code => (f n x)%:E) <= 1%:E)%E.
Proof.
apply: nearW => n; apply: (@le_trans _ _ (f n x)%:E); first exact: ge_einfs.
by rewrite lee_fin subpmf_le1.
Qed.
Let limn_einf_fin_numSource code fSource code xSource code : limn_einf (fun nSource code => (f n x)%:E) \is a fin_num.
Proof.
rewrite ge0_fin_numE//.
by apply: le_lt_trans; [exact: pmf_lim_le1' |exact: ltry].
Qed.
Local Lemma EFin_pmf_lim'Source code fSource code xSource code : (pmf_lim' f x)%:E = limn_einf (fun nSource code => (f n x)%:E).
Let subpmf_limSource code fSource code : subpmf_sum (pmf_lim' f).
Proof.
rewrite -lee_fin -sumEFin.
under eq_bigr => j _ do rewrite EFin_pmf_lim' limn_einf_lim.
have ndE j : nondecreasing_seq (einfs (fun nSource code => (f n j)%:E)).
exact: nondecreasing_einfs.
have finE j : limn (einfs (fun nSource code => (f n j)%:E)) \is a fin_num.
by rewrite -limn_einf_lim limn_einf_fin_num.
rewrite (ereal_nondecreasing_sum_limn ndE finE); apply: lime_le.
apply: ereal_nondecreasing_is_cvgn => n m nm.
by apply: lee_sum => j _; exact: ndE.
apply: nearW => n; apply: (@le_trans _ _ (\sum_(jSource code <- J) (f n j)%:E)).
by apply: lee_sum => j _; exact: ge_einfs.
rewrite sumEFin; apply: le_trans (subpmf_sum_le1 (f n)).
exact: sum_esum_ge.
Qed.
HBSource code.instanceSource code DefinitionSource code _Source code fSource code :=Source code
@uniq_isSubPmfSource code.Build R T (pmf_lim' f) (subpmf_lim f).1 (subpmf_lim f).2.
Definition pmf_lim
pmf_lim : forall {R : realType} [T : choiceType], (nat -> SubPmf.type R T) -> SubPmf.type R T pmf_lim is not universe polymorphic Arguments pmf_lim {R} [T] f%_function_scope pmf_lim is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_lim Declared in library mathcomp.analysis.probability_theory.subpmf, line 935, characters 11-18
Source code fSource code : R.-pmf T := pmf_lim' f.
Lemma pmf_limESource code fSource code xSource code : pmf_lim f x = fine (limn_einf (fun nSource code => (f n x)%:E)).
Proof.
Lemma pmf_lim_limnSource code fSource code : nondecreasing_fun (f : _ -> _ -> R) ->
forall xSource code, pmf_lim f x = fine (limn (fun nSource code => (f n x)%:E)).
Proof.
apply: ereal_nondecreasing_is_cvgn => m n mn.
by rewrite lee_fin; exact/lefP/ndf.
Qed.
Lemma EFin_pmf_limSource code fSource code xSource code : (pmf_lim f x)%:E = limn_einf (fun nSource code => (f n x)%:E).
Proof.
Lemma EFin_pmf_lim_limnSource code fSource code : nondecreasing_fun (f : _ -> _ -> R) ->
forall xSource code, (pmf_lim f x)%:E = limn (fun nSource code => (f n x)%:E).
Proof.
apply: ereal_nondecreasing_is_cvgn => m n mn.
by rewrite lee_fin; exact/lefP/ndf.
Qed.
Lemma EFin_pmf_lim_supSource code fSource code : nondecreasing_fun (f : _ -> _ -> R) ->
forall xSource code, (pmf_lim f x)%:E = ereal_sup (range (fun nSource code => (f n x)%:E)).
Proof.
rewrite (EFin_pmf_lim_limn ndf) -sup_range_lim// => m n mn.
by rewrite lee_fin; exact/lefP/ndf.
Qed.
End pmf_lim.
Notation "\lim_ ( n ) E"Source code := (pmf_lim (fun nSource code => E)) : subpmf_scope.
Context {RSource code : realType} {TSource code USource code : choiceType}.
Implicit Types (f g : nat -> R.-pmf T) (h : T -> R.-pmf U) (mu : R.-pmf T).
Lemma pmf_limCSource code muSource code : \lim_(nSource code) mu =1 mu.
Proof.
Lemma pmf_lim_bumpSource code fSource code : \lim_(nSource code) f n.+1 =1 pmf_lim f.
Proof.
Lemma pmf_lim_liftSource code fSource code pSource code : \lim_(nSource code) f (n + p)%N =1 pmf_lim f.
Proof.
Lemma pmf_lim_ge0Source code fSource code xSource code : 0 <= pmf_lim f x.
Proof.
Lemma pmf_lim_le1Source code fSource code xSource code : pmf_lim f x <= 1.
Proof.
Lemma le_pmf_limSource code fSource code gSource code : (forall nSource code, f n <=1 g n) -> pmf_lim f <=1 pmf_lim g.
Proof.
apply: lee_lim; [exact: is_cvg_einfs..|].
apply: nearW => n; apply: le_ereal_inf => _ [m /= nm] <-.
by apply: (@le_trans _ _ ((f m x)%:E)); [exact: ge_einfs|rewrite lee_fin].
Qed.
Lemma eq_pmf_limSource code fSource code gSource code : (forall nSource code, f n =1 g n) -> pmf_lim f =1 pmf_lim g.
Proof.
apply/eqP; rewrite eq_le; apply/andP.
by split; apply: le_pmf_lim => ??; rewrite eq_fg.
Qed.
Lemma leub_pmf_limSource code fSource code muSource code : (forall nSource code, f n <=1 mu) -> pmf_lim f <=1 mu.
Proof.
Lemma pmf_lim_ubSource code fSource code kSource code : nondecreasing_fun (f : nat -> T -> R) -> f k <=1 pmf_lim f.
Proof.
apply: lime_ge.
apply: ereal_nondecreasing_is_cvgn => m n mn.
by rewrite lee_fin; exact/lefP/hf.
near do (rewrite lee_fin; apply/lefP/hf).
exact: nbhs_infty_ge.
Unshelve. all: by end_near. Qed.
End Pmf_LimTheory.
Context {RSource code : realType} {TSource code USource code : choiceType}.
Implicit Types (f : (R.-pmf T)^nat) (h : T -> R.-pmf R).
Lemma pmf_limM_supSource code fSource code (hfSource code : nondecreasing_fun (f : _ -> _ -> _)) (cSource code : R) xSource code :
0 <= c ->
(pmf_lim f x * c)%:E = ereal_sup (range (fun nSource code => (f n x * c)%:E)).
Proof.
rewrite EFinM (EFin_pmf_lim_sup hf) muleC.
rewrite (@ge0_ereal_supZl_range R T (fun tSource code nSource code => (f n t)%:E)) //=.
by move=> t n; rewrite lee_fin.
congr ereal_sup; apply/seteqP; split.
- by move=> ? [x0 ?]; rewrite -EFinM mulrC=> <- //=; exists x0.
- by move=> ? [x0 ?]; rewrite mulrC EFinM => <- //=; exists x0.
Qed.
Lemma pmf_bind_limSource code fSource code hSource code : nondecreasing_fun (f : _ -> _ -> _) ->
\bind_(xSource code <- pmf_lim f) h x =1 \lim_(nSource code) (\bind_(xSource code <- f n) h x).
Proof.
have nd : nondecreasing_fun (fun nSource code => \bind_(iSource code <- f n) h i : _ -> _).
move=> n m hnm; apply/lefP => x.
by apply: le_pmf_bind => ?; exact/lefP/ndf.
rewrite EFin_pmf_bind (EFin_pmf_lim_sup nd).
under eq_esum => x _ do rewrite (pmf_limM_sup ndf)//.
rewrite (@exchange_esum_ereal_sup _ _ (fun xSource code nSource code => (f n x * h x y)%:E))/=.
- by move=> t n; rewrite lee_fin mulr_ge0.
- by move=> x n m nm; rewrite lee_fin ler_wpM2r//; exact/lefP/ndf.
congr ereal_sup; apply/seteqP; split.
- by move=> ? [x0 ?]; rewrite -EFin_pmf_bind => <- //=; exists x0.
- by move=> ? [x0 ?]; rewrite EFin_pmf_bind => <- //=; exists x0.
Qed.
End Pmf_BindPmf_Lim.
Context {RSource code : realType} {TSource code USource code : choiceType} (fSource code : nat -> T -> R.-pmf U).
Hypothesis hmonoSource code : forall xSource code nSource code mSource code, (n <= m)%N -> f n x <=1 f m x.
Lemma pmf_lim_bindSource code (muSource code : R.-pmf T) :
\lim_(nSource code) \bind_(xSource code <- mu) (f n x) =1 \bind_(xSource code <- mu) \lim_(nSource code) (f n x).
Proof.
by move=> n m hnm; apply/lefP => x; exact: hmono.
have nd2 : nondecreasing_fun (fun nSource code => \bind_(iSource code <- mu) f n i : _ -> _).
move=> n m hnm; apply/lefP => x.
by apply: supp_le_pmf_bind => z _; exact: hmono.
move=> z; apply: EFin_inj.
rewrite (EFin_pmf_lim_sup nd2) EFin_pmf_bind.
under eq_esum => t _ do rewrite mulrC (pmf_limM_sup (nd1 t))//.
rewrite (@exchange_esum_ereal_sup _ _ (fun tSource code nSource code => (f n t z * mu t)%:E))/=.
- by move=> t n; rewrite lee_fin mulr_ge0.
- by move=> n m nm t; rewrite lee_fin ler_wpM2r// hmono.
congr ereal_sup; apply/seteqP; split.
- move=> ? [x0 ?]; rewrite EFin_pmf_bind => <-//=; exists x0 => //=.
by under eq_esum do rewrite mulrC.
- move=> ? [x0 ?]; under eq_esum do rewrite mulrC.
by move => <- //=; exists x0 => //=; rewrite -EFin_pmf_bind.
Qed.
End Pmf_LimPmf_Bind.
Context {RSource code : realType} {TSource code : choiceType} (fSource code : nat -> nat -> R.-pmf T).
Hypotheses (hmono1Source code : forall kSource code n1Source code n2Source code, (n1 <= n2)%N -> f n1 k <=1 f n2 k)
(hmono2Source code : forall kSource code n1Source code n2Source code, (n1 <= n2)%N -> f k n1 <=1 f k n2).
Local Lemma dhomo_apply2Source code : nondecreasing_fun (fun nSource code => f n n : _ -> R).
Lemma leub_pmf_lim_pmf_lim1Source code : \lim_(nSource code) pmf_lim (f n) <=1 \lim_(nSource code) f n n.
Proof.
apply: (@le_trans _ _ (f (maxn n m) (maxn n m) x)).
apply: (@le_trans _ _ (f (maxn n m) m x)).
- by rewrite hmono1// leq_maxl.
- by rewrite hmono2// leq_maxr.
by rewrite pmf_lim_ub//; exact : dhomo_apply2.
Qed.
Lemma pmf_lim_pmf_lim_ub1Source code : \lim_(nSource code) (f n n) <=1 \lim_(nSource code) \lim_(mSource code) f n m.
Proof.
- apply: pmf_lim_ub => ? ? ?.
by apply/lefP => ?; exact: hmono2.
- apply: pmf_lim_ub => ? ? ?.
by apply/lefP => ?; apply le_pmf_lim => ? ?; exact: hmono1.
Qed.
Lemma leub_pmf_lim_pmf_lim2Source code : \lim_(mSource code) (\lim_(nSource code) (f n m)) <=1 \lim_(nSource code) f n n.
Proof.
apply: (@le_trans _ _ (f (maxn n m) (maxn n m) x)).
apply: (@le_trans _ _ (f (maxn n m) n x)).
- by rewrite hmono1// leq_maxr.
- by rewrite hmono2// leq_maxl.
by apply: pmf_lim_ub; exact : dhomo_apply2.
Qed.
Lemma pmf_lim_pmf_lim_ub2Source code : \lim_(nSource code) (f n n) <=1 \lim_(mSource code) (\lim_(nSource code) f n m).
Proof.
- apply: pmf_lim_ub => ? ? ?.
by apply/lefP => ?; exact: hmono1.
- apply: pmf_lim_ub => ? ? ?.
by apply/lefP => y; apply le_pmf_lim => ? ?; exact: hmono2.
Qed.
Lemma pmf_lim_pmf_limSource code :
\lim_(nSource code) (\lim_(mSource code) (f n m)) =1 \lim_(mSource code) (\lim_(nSource code) f n m).
Proof.
- exact: (le_trans (leub_pmf_lim_pmf_lim1 x) (pmf_lim_pmf_lim_ub2 x)).
- exact: (le_trans (leub_pmf_lim_pmf_lim2 x) (pmf_lim_pmf_lim_ub1 x)).
Qed.
End Pmf_LimPmf_Lim.
Context {RSource code : realType} {TSource code USource code : choiceType}
(dSource code : (R.-pmf T)^nat) (hSource code : nat -> T -> R.-pmf R).
Hypotheses (hdSource code : nondecreasing_fun (d : nat -> _ -> R))
(HmonoSource code: forall kSource code n1Source code n2Source code, (n1 <= n2)%N -> h n1 k <=1 h n2 k).
Lemma nondecreasing_pmf_bindSource code (nmuSource code : nat -> R.-pmf T) :
nondecreasing_fun (nmu : (_ -> R)^nat) ->
nondecreasing_fun (fun nSource code => \bind_(iSource code <- nmu n) h n i : _ -> _).
Proof.
by move=> ?; exact/lefP/hnmu.
by move=> ? ? ?; exact: Hmono.
Qed.
Let pmf_bind_pmf_lim_diag_nSource code nSource code :
\bind_(xSource code <- d n) (\lim_(nSource code) (h n x)) <=1 \lim_(nSource code) (\bind_(xSource code <- d n) h n x).
Proof.
apply: (@le_trans _ _ ((\bind_(iSource code <- d (maxn m n)) h (maxn m n) i) w)).
apply: supp_le_pmf_bind2.
by move=> x; exact/lefP/hd/leq_maxr.
by move=> ? _; apply: Hmono; exact: leq_maxl.
exact: (@pmf_lim_ub _ _ (fun nSource code => \bind_(xSource code <- d n) h n x) (maxn m n)
(nondecreasing_pmf_bind hd)).
Qed.
Lemma pmf_bind_pmf_lim_diagSource code :
\bind_(xSource code <- \lim_(nSource code) d n) (\lim_(nSource code) (h n x)) =1
\lim_(nSource code) (\bind_(xSource code <- d n) h n x).
Proof.
- rewrite pmf_bind_lim//; apply: leub_pmf_lim => n.
exact: pmf_bind_pmf_lim_diag_n.
apply: leub_pmf_lim => n; apply: supp_le_pmf_bind2.
exact: (@pmf_lim_ub _ _ d n hd).
move=> x _; apply: pmf_lim_ub => ? ? ?.
by apply/lefP => ?; exact: Hmono.
Qed.
End pmf_bind_pmf_lim_diag.
Context {RSource code : realType} {TSource code USource code : choiceType} (hSource code : T -> U) (muSource code : R.-pmf T).
Definition pmf_margin
pmf_margin : forall {R : realType} {T U : choiceType}, (T -> U) -> SubPmf.type R T -> SubPmf.type R U pmf_margin is not universe polymorphic Arguments pmf_margin {R T U} h%_function_scope mu pmf_margin is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_margin Declared in library mathcomp.analysis.probability_theory.subpmf, line 1194, characters 11-21
Source code := \bind_(xSource code <- mu) (pmf_ret (h x)).
End Marginals.
Context {RSource code : realType} {TSource code USource code VSource code : choiceType}.
Lemma pmf_marginESource code (muSource code : R.-pmf T) (fSource code : T -> U) ySource code :
(pmf_margin f mu) y = fine (\esum_(xSource code in [set: T]) ((f x == y)%:R * mu x)%:E).
Lemma pmf_bind_marginSource code (muSource code : R.-pmf T) (fSource code : T -> U) (gSource code : U -> R.-pmf V):
\bind_(uSource code <- pmf_margin f mu) g u =1 \bind_(tSource code <- mu) (g (f t)).
Proof.
by move=> y _ z /=; rewrite pmf_ret_bind.
Qed.
Lemma pmf_margin_bindSource code (muSource code : R.-pmf T) (fSource code : U -> V) (gSource code : T -> R.-pmf U):
pmf_margin f (\bind_(tSource code <- mu) g t) =1 \bind_(tSource code <- mu) (pmf_margin f (g t)).
Proof.
Lemma pmf_margin_retSource code (tSource code : T) (fSource code : T -> U):
pmf_margin f (pmf_ret t) =1 pmf_ret (f t) :> R.-pmf U.
Proof.
End MarginalsTh.
Lemma measure_of_pmf_marginSource code {RSource code : realType} {TSource code USource code : choiceType} (hSource code : T -> U)
(muSource code : R.-pmf T) (SSource code : set (discrete_measurable_space U)) :
measure_of_pmf (pmf_margin h mu) S
= giry_map (measurable_fun_discreteT h) (measure_of_pmf mu) S.
Proof.
under eq_integral do rewrite measure_of_pmf_ret diracE.
by rewrite /giry_map/= /pushforward -(setIT (h @^-1` S)) -integral_indic.
Qed.
Notation pmf1Source code mu := (pmf_margin fst mu).
Notation pmf2Source code mu := (pmf_margin snd mu).
Context {RSource code : realType} {ASource code BSource code : choiceType} (muSource code : R.-pmf (A * B)%type).
Definition pmf_swap
pmf_swap : forall {R : realType} {A B : choiceType}, SubPmf.type R (A * B)%type -> SubPmf.type R (B * A)%type pmf_swap is not universe polymorphic Arguments pmf_swap {R A B} mu pmf_swap is transparent Expands to: Constant mathcomp.analysis.probability_theory.subpmf.pmf_swap Declared in library mathcomp.analysis.probability_theory.subpmf, line 1240, characters 11-19
Source code : R.-pmf (B * A)%type :=
pmf_margin (fun xySource code => (xy.2, xy.1)) mu.
End DSwap.
Context {RSource code : realType} {ASource code BSource code : choiceType} (muSource code : R.-pmf (A * B)%type).
Lemma pmf_swapESource code xySource code : pmf_swap mu xy = mu (xy.2, xy.1).
Proof.
by move=> ? ?; rewrite lee_fin mulr_ge0.
rewrite setI1 //= in_setT esum_set1 esum1 //=.
move=> ab [_ /eqP h] /=.
rewrite pmf_ret0 ?mulr0 //.
apply: contra h => /eqP <-/=.
by rewrite -surjective_pairing.
by case: xy => x y /=; rewrite pmf_retxx mulr1 addr0.
Qed.
End DSwapCoreTheory.
Context {RSource code : realType} {ASource code BSource code : choiceType} (muSource code : R.-pmf (A * B)%type).
Lemma pmf_swapKSource code : pmf_swap (pmf_swap mu) =1 mu.
Proof.
Lemma supp_pmf_swapSource code xySource code : (xy.2, xy.1) \in supp mu ->
xy \in supp (pmf_swap mu).
Lemma pmf1_swapSource code : pmf1 (pmf_swap mu) =1 pmf2 mu.
Proof.
by apply/supp_eq_pmf_bind => // -[x y] _ t /=; rewrite pmf_ret_bind.
Qed.
Lemma pmf2_swapSource code : pmf2 (pmf_swap mu) =1 pmf1 mu.
Proof.
by apply/supp_eq_pmf_bind => // -[x y] _ t /=; rewrite pmf_ret_bind.
Qed.
End DSwapTheory.
Context {RSource code : realType} {TSource code USource code : choiceType}.
Lemma pmf1ESource code (muSource code : R.-pmf (T * U)%type) xSource code :
pmf1 mu x = fine (\esum_(ySource code in [set: U]) (mu (x, y))%:E).
Proof.
rewrite (esumID [set zSource code : T * U | z.1 = x])/=.
by move=> z _; rewrite lee_fin mulr_ge0.
rewrite [X in _ + X]esum1 ?adde0.
by move=> z [_ /= /eqP zx]; rewrite pmf_ret0 ?mulr0.
rewrite (reindex_esum [set: U] _ (fun ySource code => (x, y))).
split => //.
- by move=> y1 y2 _ _ /(congr1 snd).
- move=> z [_ /= zx]; exists z.2 => //=.
by case: z zx => z1 z2 /= ->.
by apply: eq_esum => y _ /=; rewrite pmf_retxx mulr1.
Qed.
Lemma esummable_fstSource code (muSource code : R.-pmf (T * U)%type) xSource code :
esummable [set: U] (fun ySource code => (mu (x, y))%:E).
Proof.
rewrite -(reindex_esum [set:U] [set zSource code : T * U | z.1 = x]
(fun ySource code => (x, y)) (fun zSource code => (`|(mu z)%:E|)%E)).
split => //.
- by move=> y1 y2 _ _ /(congr1 snd).
- move=> z /= zx; exists z.2 => //=.
by case: z zx => z1 z2 /= ->.
by apply: subset_esum => //= z _; rewrite lee_tofin // mulr_ge0.
Qed.
End DFst.
Context {RSource code : realType} {TSource code USource code : choiceType}.
Lemma pmf2ESource code (muSource code : R.-pmf (T * U)%type) ySource code :
pmf2 mu y = fine (esum [set:T] (fun xSource code => (mu (x, y))%:E)).
Lemma esummable_sndSource code (muSource code : R.-pmf (T * U)%type) ySource code :
esummable [set: T] (fun xSource code => (mu (x, y))%:E).
Proof.
End DSnd.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (mu : R.-pmf T).
Lemma pmf_esummable_cstSource code muSource code cSource code : pmf_esummable mu (cst c).
Proof.
by apply: esummableZl => //; exact: subpmf_summable.
by apply/eq_esummable => x /= _; rewrite EFinM.
Qed.
Lemma pmf_esummableZSource code muSource code cSource code FSource code : pmf_esummable mu F -> pmf_esummable mu (c \*o F).
Proof.
have := esummableZl (f := EFin \o (fun xSource code => F x * mu x)) (c := c%:E) erefl heF.
apply/eq_esummable => x /=.
by rewrite -EFinM mulrA.
Qed.
Lemma bounded_pmf_esummableSource code muSource code FSource code :
(exists MSource code, forall xSource code, `|F x| <= M) -> pmf_esummable mu F.
Proof.
rewrite (eq_esum _ _ (fun xSource code => `|(F x)%:E * (mu x)%:E|)%E).
by move=> x _; rewrite -EFinM.
apply: esummableMl; last exact: subpmf_summable.
by exists M%:E => [x ?|//]; rewrite /= lee_fin leM.
Qed.
Lemma esummable_pmfSource code muSource code FSource code : esummable [set: T] (EFin \o F) -> pmf_esummable mu F.
Proof.
rewrite (eq_esum _ _ (fun xSource code => `|(F x)%:E * (mu x)%:E|)%E).
by move=> x _; rewrite -EFinM.
apply: esummableMr; last exact: smF.
by exists 1%:E => [x ?|//]; rewrite /= lee_fin ger0_norm// subpmf_le1.
Qed.
End pmf_esummable_lemmas.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (mu : R.-pmf T).
Lemma pmf_expectationZSource code muSource code fSource code cSource code : (forall xSource code, 0 <= f x) ->
\E_[mu] (fun xSource code => c * (f x)) = c * (\E_[mu] f).
Proof.
Lemma pmf_expectation_cstSource code muSource code rSource code : \E_[mu] (fun=> r) = \P_[mu] predT * r.
Proof.
Lemma pmf_expectation0Source code muSource code : \E_[mu] (fun=> 0) = 0.
Proof.
Lemma supp_eq_pmf_expectationSource code muSource code (f1Source code f2Source code : T -> R):
{in supp mu, f1 =1 f2} -> \E_[mu] f1 = \E_[mu] f2.
Proof.
Lemma pmf_expectationESource code muSource code (gSource code : T -> R) :
\E_[mu] g = fine ('E_(measure_of_pmf mu) [EFin \o g]).
Proof.
Lemma pmf_expectationBSource code muSource code (fSource code gSource code : T -> R) :
pmf_esummable mu f -> pmf_esummable mu g ->
\E_[mu] (f \- g) = \E_[mu] f - \E_[mu] g.
Proof.
rewrite expectationB//; [exact/Lfun1_integrable/esummable_integrable..|].
by rewrite fineB// expectation_pmfEFin esummable_esum_fin_num.
Qed.
Lemma pmf_expectation_ge0Source code muSource code (gSource code : T -> R) :
(forall ySource code, 0 <= g y) -> 0 <= \E_[mu] g.
Proof.
End pmf_expectation_lemmas.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (mu : R.-pmf T) (A B E : pred T).
Local Open Scope ereal_scope.
Lemma expectation_pmf_retSource code (fSource code : T -> \bar R) (xSource code : T) :
'E_(measure_of_pmf (pmf_ret x)) [f] = f x.
Proof.
rewrite (eq_measure_integral (\d_(x : discrete_measurable_space T))).
by move=> A _ _; exact: measure_of_pmf_ret.
by rewrite integral_dirac//= diracT mul1e.
Qed.
Lemma expectation_pmf_zeroSource code (fSource code : T -> \bar R) :
'E_(measure_of_pmf pmf_zero) [f] = 0.
Proof.
by move=> A _ _; exact: measure_of_pmf_zero.
Qed.
Lemma expectation_pmf_bindSource code {USource code : choiceType} muSource code (nuSource code : T -> R.-pmf U) FSource code :
(forall xSource code, 0 <= F x)%E ->
'E_(measure_of_pmf (pmf_bind nu mu)) [F] =
'E_(measure_of_pmf mu) [fun xSource code => 'E_(measure_of_pmf (nu x)) [F]].
Proof.
under [in RHS]eq_integral do rewrite expectation_def.
rewrite (eq_measure_integral
(giry_bind (measure_of_pmf mu) (measurable_measure_of_pmf nu))).
by move=> A _ _; exact: measure_of_pmf_bind_giry.
exact: giry_int_bind.
Qed.
Lemma expectation_pmf_marginSource code {USource code : choiceType} (hSource code : T -> U) muSource code (FSource code : U -> \bar R) :
(forall ySource code, 0 <= F y)%E ->
'E_(measure_of_pmf (pmf_margin h mu)) [F] = 'E_(measure_of_pmf mu) [F \o h].
Proof.
rewrite (eq_measure_integral
(giry_map (measurable_fun_discreteT h) (measure_of_pmf mu))).
by move=> A _ _; exact: measure_of_pmf_margin.
exact: giry_int_map.
Qed.
Local Open Scope ereal_scope.
Lemma expectation_pmf_bind_EFinSource code {USource code : choiceType} muSource code (nuSource code : T -> R.-pmf U)
(gSource code : U -> R) :
(forall ySource code, 0 <= g y)%R -> (forall etaSource code, pmf_esummable eta g) ->
'E_(measure_of_pmf (pmf_bind nu mu)) [EFin \o g] =
'E_(measure_of_pmf mu) [EFin \o (fun xSource code => \E_[nu x] g)].
Proof.
apply: eq_esum => t _ //=; rewrite expectation_pmf; congr (_ * _)%E.
by rewrite /pmf_expectation fineK// (esummable_esum_fin_num (sg (nu _))).
Qed.
End pmf_expectation_theory.
Import MeasurableR.
Context {dSource code} {TSource code : pmeasurableType d} {RSource code : realType} (PSource code : probability T R)
(XSource code : {dRV P >-> R}).
Local Notation pmfXSource code := (@pmf d T R P X).
Local Open Scope ereal_scope.
Lemma measure_of_pmf_distributionSource code (ASource code : set R) :
measurable A ->
measure_of_pmf pmfX A = distribution P X A.
Proof.
Lemma ge0_expectation_pmfSource code (fSource code : R -> \bar R) :
measurable_fun [set: R] f -> (forall rSource code, 0 <= f r) ->
'E_(measure_of_pmf pmfX) [f] = \int[P]_wSource code f (X w).
Proof.
have mid : measurable_fun [set: discrete_measurable_space R]
(idfun : discrete_measurable_space R -> R) by [].
transitivity (\int[giry_map mid (measure_of_pmf pmfX)]_ySource code f y).
exact/esym/giry_int_map.
by apply: eq_measure_integral => A mA _; exact: measure_of_pmf_distribution.
Qed.
Lemma expectation_pmf_integralSource code (fSource code : R -> \bar R) :
measurable_fun [set: R] f ->
'E_(measure_of_pmf pmfX) [f] = \int[P]_wSource code f (X w).
Proof.
- rewrite -[LHS]expectation_def ge0_expectation_pmf => //=.
exact: measurable_funepos.
by apply: eq_integral => w _; rewrite !funeposE.
- rewrite -[LHS]expectation_def ge0_expectation_pmf => //=.
exact: measurable_funeneg.
by apply: eq_integral => w _; rewrite !funenegE.
Qed.
Lemma expectation_pmf_expectationSource code :
'E_(measure_of_pmf pmfX) [EFin] = 'E_P[EFin \o X].
Proof.
End pmf_expectation_dRV.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (mu : R.-pmf T) (A B E : pred T).
Lemma prESource code ESource code muSource code : (\P_[mu] E)%:E = \esum_(xSource code in [set: T]) ((E x)%:R * mu x)%:E.
Proof.
Lemma prE_measureSource code muSource code ESource code : (\P_[mu] E)%:E = measure_of_pmf mu [set` E].
Proof.
apply: eq_esum => x _ /=; rewrite mem_setE unfold_in.
by case: (E x); rewrite ?mul1r ?mul0r.
Qed.
Lemma pmf_prob_pred0Source code muSource code : \P_[mu] pred0 = 0.
Lemma pmf_prob_pred1Source code muSource code xSource code : \P_[mu] (pred1 x) = mu x.
Proof.
Lemma pmf_prob_expectationSource code muSource code (QSource code : pred T) :
\P_[mu] Q = \E_[mu] (fun mSource code => (Q m)%:R).
Proof.
Lemma pmf_prob_predTSource code muSource code : \P_[mu] predT = fine (esum [set: T] (EFin \o mu)).
Proof.
Lemma expectation_pmf_cstSource code muSource code rSource code :
('E_(measure_of_pmf mu) [cst r] = (\P_[mu] predT)%:E * r)%E.
Proof.
rewrite muleC; congr (_ * _)%E.
rewrite pmf_prob_predT fineK//= esum_abse//=.
have := @subpmf_summable _ _ mu.
by rewrite esummableE.
Qed.
Lemma pmf_expectation_retSource code (fSource code : T -> R) (xSource code : T) : \E_[pmf_ret x] f = f x.
Proof.
Lemma pmf_prob_retSource code ESource code xSource code : \P_[pmf_ret x] E = (E x)%:R :> R.
Proof.
Lemma pmf_expectation_zeroSource code (fSource code : T -> R) : \E_[pmf_zero] f = 0.
Proof.
Lemma pmf_prob_zeroSource code ESource code : \P_[pmf_zero : R.-pmf T] E = 0.
Proof.
Lemma dweight_pmf_zeroSource code : dweight (@pmf_zero R T) = 0.
Proof.
Lemma pmf_expectation_marginSource code {USource code : choiceType} (hSource code : T -> U) muSource code (gSource code : U -> R) :
(forall ySource code, 0 <= g y) ->
\E_[pmf_margin h mu] g = \E_[mu] (g \o h).
Proof.
have g0E y : (0 <= (EFin \o g) y)%E by rewrite /= lee_fin.
by rewrite /pmf_expectation -!expectation_pmfEFin (expectation_pmf_margin h mu).
Qed.
Lemma pmf_prob_ge0Source code ASource code muSource code : 0 <= \P_[mu] A.
Proof.
Lemma pmf_cprob_ge0Source code ASource code BSource code muSource code : 0 <= \P_[mu, B] A.
Proof.
Lemma supp_eq_pmf_probSource code ASource code BSource code muSource code : {in supp mu, A =i B} -> \P_[mu] A = \P_[mu] B.
Proof.
Lemma eq_pmf_probSource code ASource code BSource code muSource code : A =i B -> \P_[mu] A = \P_[mu] B.
Proof.
Lemma pred0_pmf_prob_eq0Source code (muSource code : R.-pmf T) (ESource code : pred T) :
E =1 pred0 -> \P_[mu] E = 0.
Proof.
End PrCoreTheory.
Context {RSource code : realType} {TSource code USource code : choiceType} {ISource code : eqType}.
Implicit Types (mu : R.-pmf T) (A B E : pred T).
Lemma pmf_prob_eq0Source code ASource code muSource code :
(forall xSource code, x \in supp mu -> x \notin A) -> \P_[mu] A = 0.
Proof.
Lemma pmf_cprob_eq0Source code ASource code BSource code muSource code :
(forall xSource code, x \in supp mu -> x \in B -> x \notin A) ->
\P_[mu, B] A = 0.
Proof.
Lemma subset_pmf_probSource code ASource code BSource code muSource code : {subset B <= A} -> \P_[mu] B <= \P_[mu] A.
Proof.
Lemma pmf_prob_le1Source code ASource code muSource code : \P_[mu] A <= 1.
Proof.
rewrite pmf_prob_predT -fine1 fine_le//; [|exact: subpmf_sum_le1].
rewrite ge0_fin_numE.
by apply: esum_ge0 => x _; rewrite lee_fin.
by apply: le_lt_trans; [exact: subpmf_sum_le1|rewrite ltey].
Qed.
Lemma pmf_prob_bindSource code ESource code fSource code (muSource code : R.-pmf U) :
\P_[pmf_bind f mu] E = \E_[mu] (fun xSource code => \P_[f x] E).
Proof.
apply/(le_esummable (g := EFin \o mu)) => [x _|//].
by rewrite !lee_fin mulr_ge0 ?pmf_prob_ge0//= ler_piMl ?pmf_prob_le1.
apply: EFin_inj; rewrite prE_measure measure_of_pmf_bind.
under eq_integral do rewrite -prE_measure.
rewrite -expectation_def expectation_pmfEFin /pmf_expectation fineK//.
exact: esummable_esum_fin_num.
Qed.
Lemma pmf_prob_marginSource code ESource code fSource code (muSource code : R.-pmf U) :
\P_[pmf_margin f mu] E = \P_[mu] [pred xSource code | f x \in E].
Proof.
by apply/supp_eq_pmf_expectation=> x _; rewrite pmf_prob_ret.
Qed.
Lemma pmf_expectation_leSource code muSource code f1Source code f2Source code :
pmf_esummable mu f1 -> pmf_esummable mu f2 -> f1 <=1 f2 ->
\E_[mu] f1 <= \E_[mu] f2.
Proof.
- exact: (esummable_esum_fin_num sm1).
- exact: (esummable_esum_fin_num sm2).
- by apply: le_esum => x /=; rewrite lee_fin ler_wpM2r ?ge0_mu.
Qed.
Lemma le_mem_pmf_probSource code E1Source code E2Source code muSource code :
(forall xSource code, x \in supp mu -> x \in E1 -> x \in E2) ->
\P_[mu] E1 <= \P_[mu] E2.
Proof.
apply: le_esum => x _; rewrite lee_fin.
case/boolP: (x \in supp mu) => [xin|/memNsuppP ->]; last by rewrite !mulr0.
have hE : (E1 x)%:R <= (E2 x)%:R :> R.
rewrite ler_nat; have := le x xin; rewrite -!topredE /=.
by case: (E1 x) => // ->.
by rewrite ler_wpM2r // ?ge0_mu.
Qed.
Lemma le_pmf_pmf_probSource code ASource code (muSource code nuSource code : R.-pmf T) :
(forall xSource code, x \in supp nu -> x \in A -> nu x <= mu x) ->
\P_[nu] A <= \P_[mu] A.
Proof.
Lemma pmf_cprob_le1Source code ASource code BSource code muSource code : \P_[mu, B] A <= 1.
Proof.
case/predU1P => [<-|]; first by rewrite invr0 mulr0 ler01.
move/ler_pdivrMr=> ->; rewrite mul1r.
by apply: le_mem_pmf_prob => x _ /andP[].
Qed.
Lemma pmf_cprob_sumSource code ASource code muSource code : 0 < \P_[mu] A ->
fine (\esum_(xSource code in [set: T]) (\P_[mu, A] (pred1 x))%:E) = 1.
Proof.
have a0 i : 0 <= (A i)%:R * mu i by rewrite mulr_ge0// ler0n.
have hpr1 x : \P_[mu] [predI pred1 x & A] = (A x)%:R * mu x.
rewrite /pmf_prob.
rewrite (eq_esum _ _ ( fun ySource code => if x == y then ((A y)%:R * mu y)%:E else 0)).
move=> y _ /=; rewrite !inE [y == x]eq_sym.
by case: ifP => xy; rewrite ?mul0r.
by rewrite esum_if_eq_op_set1.
rewrite (eq_esum _ _ (fun xSource code => ((\P_[mu] A)^-1 * ((A x)%:R * mu x))%:E)).
by move=> x _; rewrite /pmf_cprob hpr1; congr (_ %:E); rewrite mulrC.
rewrite (EFin_esumZ _ _ a0).
by rewrite invr_ge0// pmf_prob_ge0.
by rewrite -prE -EFinM mulVf// gt_eqF.
Qed.
Lemma eq0_pmf_probSource code muSource code ESource code : \P_[mu] E = 0 -> forall xSource code, x \in E -> mu x = 0.
Proof.
Lemma pmf_probIDSource code ASource code BSource code muSource code :
\P_[mu] A = \P_[mu] [predI A & B] + \P_[mu] [predI A & predC B].
Proof.
by rewrite lee_fin mulr_ge0 ?ler0n ?ge0_mu.
apply: EFin_inj; rewrite EFinD !prE.
rewrite -(esumD (fun iSource code _ => ge0 _ i) (fun iSource code _ => ge0 _ i)).
apply: eq_esum => x _; rewrite -EFinD; congr (_ %:E).
rewrite !inE -!topredE /= -mulrDl; congr (_ * _).
rewrite -natrD; congr (_ %:R).
by case: (A x); case: (B x).
Qed.
Lemma pmf_prob_predU_indepSource code (ASource code BSource code : pred T) (muSource code : R.-pmf T) :
(forall xSource code, x \in A -> x \notin B) ->
\P_[mu] [predU A & B] = \P_[mu] A + \P_[mu] B.
Proof.
have ge0 (PSource code : pred T) iSource code : (0 <= ((P i)%:R * mu i)%:E)%E.
by rewrite lee_fin mulr_ge0 ?ler0n ?ge0_mu.
apply: EFin_inj; rewrite EFinD !prE.
rewrite -(esumD (fun iSource code _ => ge0 _ i) (fun iSource code _ => ge0 _ i)).
apply: eq_esum => x _; rewrite -EFinD; congr (_ %:E).
rewrite !inE -!topredE /= -mulrDl; congr (_ * _).
rewrite -natrD; congr (_ %:R).
case/boolP: (A x) => Ax; case/boolP: (B x) => Bx //=.
by move/dsj: Ax; rewrite -topredE /= Bx.
Qed.
Lemma pmf_prob_mem_mapSource code fSource code muSource code (rSource code : seq U) : uniq r ->
\P_[mu] [pred xSource code | f x \in r] =
\sum_(ySource code <- r) \P_[mu] [pred xSource code | f x == y].
Proof.
case/andP => yNr /ih {ih}h; rewrite big_cons -h -pmf_prob_predU_indep.
by move=> x; rewrite !inE => /eqP ->.
exact/eq_pmf_prob.
Qed.
Lemma pmf_prob_memSource code muSource code (rSource code : seq T) : uniq r ->
\P_[mu] [pred xSource code | x \in r] = \sum_(xSource code <- r) mu x.
Proof.
case/andP=> yNr /ih {ih}h; rewrite big_cons /= -pmf_prob_pred1.
by rewrite -h -pmf_prob_predU_indep // => x /eqP ->.
Qed.
Lemma pmf_prob_bigor_indepSource code muSource code (PSource code : I -> pred T) (rSource code : seq I) : uniq r ->
(forall p1Source code p2Source code xSource code,
p1 != p2 -> p1 \in r -> p2 \in r -> x \in P p1 -> x \notin P p2) ->
\P_[mu] [pred xSource code | has [pred pSource code | x \in P p] r] =
\sum_(pSource code <- r) \P_[mu] (P p).
Proof.
rewrite (@eq_pmf_prob _ _ _ S) => [x|]; first by rewrite !inE -big_has.
rewrite {}/S; elim: r uq_r dj => [_|p r ih /andP[pNr /ih {ih}h]] dj.
by rewrite big_nil pred0_pmf_prob_eq0 // => x; rewrite big_nil.
rewrite big_cons -h => [p1 p2 x ne_p p1r p2r|].
by apply/dj=> //; rewrite in_cons (p1r, p2r) orbT.
rewrite -pmf_prob_predU_indep => [x xNPp|].
rewrite -topredE /= big_has; apply/hasPn => y y_in_r.
apply/(dj p); rewrite ?in_cons ?(eqxx, y_in_r, orbT) //.
by apply: contra pNr => /eqP ->.
by apply/eq_pmf_prob => x; rewrite -!topredE /= big_cons.
Qed.
Lemma pmf_prob_predUSource code ASource code BSource code muSource code : \P_[mu] [predU A & B] =
\P_[mu] A + \P_[mu] B - \P_[mu] [predI A & B].
Proof.
Lemma pmf_prob_predISource code ASource code BSource code muSource code : \P_[mu] [predI A & B] =
\P_[mu] A + \P_[mu] B - \P_[mu] [predU A & B].
Proof.
Lemma le_pmf_prob_predUSource code ASource code BSource code muSource code : \P_[mu] [predU A & B] <= \P_[mu] A + \P_[mu] B.
Proof.
Lemma le_pmf_prob_predISource code ASource code BSource code muSource code : \P_[mu] [predI A & B] <= \P_[mu] A + \P_[mu] B.
Proof.
Lemma pmf_prob_predCSource code ESource code muSource code: \P_[mu](predC E) = \P_[mu] predT - \P_[mu] E.
Proof.
by apply/eqP/eq_pmf_prob => x; rewrite !inE orNb.
Qed.
Lemma pmf_prob_splitSource code BSource code ASource code muSource code : \P_[mu] A =
\P_[mu] B * \P_[mu, B] A
+ \P_[mu] (predC B) * \P_[mu, predC B] A.
Proof.
by rewrite (pmf_probID _ B); congr (_ + _); exact/h.
rewrite /pmf_cprob mulrCA; have [] := eqVneq (\P_[mu] B') 0; last first.
by move=> nzPB'; rewrite divff // mulr1.
move=> zPB'; rewrite zPB' invr0 !mulr0; apply/pmf_prob_eq0.
move=> x mux; move/eq0_pmf_prob: zPB' => /(_ x) h; rewrite !inE.
by apply/negP=> /andP[_ /h] /mem_suppP.
Qed.
Lemma pmf_cprob_pred1Source code (muSource code : R.-pmf T) xSource code ASource code :
\P_[mu, A] (pred1 x) = (A x)%:R * mu x / \P_[mu] A.
Proof.
Lemma esummable_pmf_prob_fSource code fSource code muSource code (PSource code : pred T):
pmf_esummable mu f ->
esummable [set: T] (EFin \o (fun xSource code => (P x)%:R * (f x * mu x))).
Proof.
Lemma esum_is_fin_num_mu_fSource code fSource code muSource code (PSource code : pred T):
pmf_esummable mu f ->
\esum_(xSource code in [set: T]) ((P x)%:R * (f x * mu x))%:E \is a fin_num.
Proof.
Lemma pmf_prob_cexpectation_esumSource code muSource code fSource code (PSource code : pred T):
pmf_esummable mu f ->
\P_[mu] P * \E_[mu, P] f =
fine (\esum_(xSource code in [set: T]) ((P x)%:R * (f x * mu x))%:E).
Proof.
have [c0|cn0] := eqVneq (\P_[mu] P) 0.
rewrite c0 mul0r [X in fine X](_ : _ = 0) ?fine0//.
rewrite esum1// => x _.
apply/eqP; rewrite eqe mulrCA mulf_eq0; apply/orP; right.
have [Px|]/= := boolP (P x); last by rewrite mul0r.
by rewrite mul1r (eq0_pmf_prob _ Px).
rewrite /pmf_cexpectation.
rewrite (eq_esum _ _ (fun xSource code => (\P_[mu] P)^-1 %:E * ((P x)%:R * (f x * mu x))%:E)%E).
move=> x ?.
rewrite /= pmf_cprob_pred1 -EFinM; congr (_ %:E).
by rewrite mulrA mulrC; congr (_ * _); exact: mulrCA.
rewrite (esummable_esumZ _ (esummable_pmf_prob_f P sm)).
by rewrite abse_fin_num.
by rewrite fineM ?abse_fin_num ?sum_fin_num_mu_f// mulVKf.
Qed.
Lemma pmf_expectation_splitSource code ASource code fSource code muSource code : pmf_esummable mu f ->
\E_[mu] f = \P_[mu] A * \E_[mu, A] f
+ \P_[mu] (predC A) * \E_[mu, predC A] f.
Proof.
rewrite [in RHS](pmf_prob_cexpectation_esum A)//.
rewrite [in RHS](pmf_prob_cexpectation_esum (predC A))//.
rewrite [in LHS]/pmf_expectation -fineD ?esum_is_fin_num_mu_f//.
congr fine.
rewrite -esummable_esumD//; [exact: esummable_pmf_prob_f..|].
apply: eq_esum => x ? /=; rewrite -EFinD; congr EFin.
by rewrite -mulrDl -natrD addnC addn_negb mul1r.
Qed.
Lemma bounded_pmf_expectation_leSource code muSource code FSource code (MSource code : R) :
0 <= M -> (forall xSource code, `|F x| <= M) -> \E_[mu] F <= M.
Proof.
apply/pmf_expectation_le.
- by apply/bounded_pmf_esummable; exists M.
- exact/pmf_esummable_cst.
- by move=> x; apply/(le_trans _ (bd x))/ler_norm.
by rewrite pmf_expectation_cst ler_piMl // pmf_prob_le1.
Qed.
Lemma ge0_pmf_expectation_bindSource code (muSource code : R.-pmf T) (nuSource code : T -> R.-pmf U) (gSource code : U -> R) :
(forall ySource code, 0 <= g y) -> (forall etaSource code, pmf_esummable eta g) ->
\E_[pmf_bind nu mu] g = \E_[mu] (fun xSource code => \E_[nu x] g).
Proof.
by rewrite -pmf_expectationE.
Qed.
Lemma le_pmf_esummableSource code {VSource code : choiceType} (muSource code : R.-pmf V) (kSource code hSource code : V -> R) :
(forall xSource code, `|k x| <= `|h x|) -> pmf_esummable mu h -> pmf_esummable mu k.
Proof.
rewrite esummableE ge0_fin_numE.
by apply: esum_ge0 => i _; exact: abse_ge0.
apply: (le_lt_trans _ fh); apply: le_esum.
by move => ? ?; rewrite lee_fin !normrM ler_wpM2r.
Qed.
Lemma pmf_esummable_expectationSource code (muSource code : R.-pmf T) (nuSource code : T -> R.-pmf U) (gSource code : U -> R) :
(forall ySource code, 0 <= g y) -> (forall etaSource code, pmf_esummable eta g) ->
pmf_esummable mu (fun xSource code => \E_[nu x] g).
Proof.
have hge0 x : 0 <= \E_[nu x] g * mu x by rewrite mulr_ge0// pmf_expectation_ge0.
rewrite /pmf_esummable esummableE.
rewrite (eq_esum _ _ (EFin \o (fun xSource code => \E_[nu x] g * mu x))).
by move=> x _ /=; rewrite ger0_norm.
rewrite -expectation_pmfEFin -(expectation_pmf_bind_EFin mu nu g0 sg).
rewrite expectation_pmfEFin.
exact: (esummable_esum_fin_num (sg (pmf_bind nu mu))).
Qed.
Lemma pmf_expectation_bindSource code muSource code (nuSource code : T -> R.-pmf U ) FSource code :
(forall etaSource code, pmf_esummable eta F) ->
\E_[pmf_bind nu mu] F = \E_[mu] (fun xSource code => \E_[nu x] F).
Proof.
have spF eta : pmf_esummable eta F^\+.
exact: (le_pmf_esummable (le_funrpos F) (sF eta)).
have snF eta : pmf_esummable eta F^\-.
exact: (le_pmf_esummable (le_funrneg F) (sF eta)).
transitivity (\E_[mu] (fun xSource code => \E_[nu x] F^\+)
- \E_[mu] (fun xSource code => \E_[nu x] F^\-)).
rewrite -(ge0_pmf_expectation_bind mu nu _ spF)//.
rewrite -(ge0_pmf_expectation_bind mu nu _ snF) //.
rewrite -(pmf_expectationB (spF _) (snF _)); congr (\E_[pmf_bind nu mu] _).
exact/esym/funrposBneg.
rewrite -(pmf_expectationB (pmf_esummable_expectation mu nu _ spF)
(pmf_esummable_expectation mu nu _ snF))//.
apply: supp_eq_pmf_expectation => x _ /=.
rewrite -(pmf_expectationB (spF _) (snF _)).
by congr (\E_[nu x] _); exact: funrposBneg.
Qed.
End PrTheory.
Context {RSource code : realType} {TSource code : choiceType} {fSource code : (R.-pmf T)^nat}.
Hypothesis ndfSource code : nondecreasing_fun (f : _ -> _ -> _).
Lemma nondecreasing_esum_EfnSource code (ESource code : T -> \bar R):
(forall mSource code, 0 <= E m)%E ->
forall mSource code nSource code, (m <= n)%N ->
(\esum_(xSource code in [set:T]) (E x * (f m x)%:E) <=
\esum_(xSource code in [set:T]) (E x * (f n x)%:E))%E.
Proof.
Lemma esum_pmf_lim_rSource code [ESource code : T -> \bar R] [rSource code : \bar R]:
(forall mSource code, 0 <= E m)%E ->
(forall nSource code, \esum_(xSource code in [set: T]) (E x * (f n x)%:E) <= r)%E ->
(\esum_(xSource code in [set: T]) (E x * ((pmf_lim f) x)%:E) <= r)%E.
Proof.
rewrite (@eq_esum _ _ _ _ (fun xSource code => ereal_sup (range (fun nSource code => E x * (f n x)%:E)%E))).
move => ? ?; rewrite EFin_pmf_lim_sup//.
rewrite (@ge0_ereal_supZl_range R T (fun aSource code bSource code => (f b a)%:E)) //.
by move => ? ?; rewrite lee_fin.
rewrite exchange_esum_ereal_sup//.
- by move => ? ?; rewrite mule_ge0 ?lee_fin.
- by move => ? ? ? ?; rewrite lee_pmul ?lee_fin //; exact/lefP/ndf.
by rewrite ge_ereal_sup//= => x [n s] <-; exact: h.
Qed.
Lemma esum_pmf_lim_r_rSource code [ESource code : T -> R] [rSource code : \bar R]:
(forall mSource code, 0 <= E m) ->
(forall nSource code, \esum_(xSource code in [set: T]) ((E x * f n x)%:E) <= r)%E ->
(\esum_(xSource code in [set: T]) (E x * (pmf_lim f) x)%:E <= r)%E.
Proof.
Lemma esum_pmf_limSource code (ESource code : pred T) :
\esum_(xSource code in [set: T]) ((E x)%:R * (pmf_lim f) x)%:E =
limn (fun nSource code => \esum_(xSource code in [set: T]) ((E x)%:R * f n x)%:E).
Proof.
(((E x)%:R * f n x)%:E <= ((E x)%:R * f m x)%:E)%E.
move=> nm x; rewrite lee_fin ler_wpM2l ?ler0n//.
exact/lefP/ndf.
transitivity (ereal_sup (range
(fun nSource code => \esum_(xSource code in [set: T]) ((E x)%:R * f n x)%:E))); last first.
apply: sup_range_lim => n m nm; apply: le_esum => x _.
exact: (hmono n m nm x).
rewrite -(@exchange_esum_ereal_sup _ _ (fun xSource code nSource code => ((E x)%:R * f n x)%:E))//.
- by move=> x n; rewrite lee_fin mulr_ge0// ler0n.
- by move => x n m nm; exact: hmono.
apply: eq_esum => x _.
rewrite EFinM EFin_pmf_lim_sup//.
rewrite (@ge0_ereal_supZl_range R T (fun aSource code bSource code => (f b a)%:E)) //.
by move=> t n; rewrite lee_fin.
by rewrite lee_fin.
Qed.
End mono_esum.