Module mathcomp.experimental_reals.distr
From mathcomp Require Import boot order algebra.
From mathcomp Require Import boolp classical_sets.
From mathcomp Require Import constructive_ereal reals.
From mathcomp Require Import xfinmap discrete realseq realsum.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Unset SsrOldRewriteGoalsOrder.
Import Order.TTheory GRing.Theory Num.Theory.
Local Open Scope ring_scope.
Local Notation simpmSource code := Monoid.simpm.
Reserved Notation "\dlet_ ( i <- d ) E"
(at level 36, E at level 36, i, d at level 50,
format "'[' \dlet_ ( i <- d ) '/ ' E ']'").
Reserved Notation "\dlim_ ( n ) E"
(at level 36, E at level 36, n at level 50,
format "'[' \dlim_ ( n ) '/ ' E ']'").
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 ] f" (at level 2, format "\E_[ mu ] f").
Reserved Notation "\E_[ mu , A ] f" (at level 2, format "\E_[ mu , A ] f").
Local Notation "\`| f |"Source code := (fun xSource code => `|f x|) (at level 2).
Section Distribution.
Variables (RSource code : realType) (TSource code : choiceType).
Structure distrSource code := Distr {
muSource code :> T -> R;
_ : forall xSource code, 0 <= mu x;
_ : summable mu;
_ : PosSum.psum mu <= 1
}.
Definition distr_of
Source code & phant R & phant T := distr.
End Distribution.
Notation "{ 'distr' T / R }"Source code := (distr_of (Phant R) (Phant T))
(at level 0, T at level 2, format "{ 'distr' T / R }")
: type_scope.
Section DistrCoreTh.
Context {RSource code : realType} (TSource code : choiceType) (muSource code : {distr T / R}).
Lemma ge0_muSource code : forall xSource code, 0 <= mu x.
Proof.
Lemma le1_muSource code : PosSum.psum mu <= 1.
Proof.
Lemma summable_muSource code : summable mu.
Proof.
#[global] Hint Extern 0 (is_true (0 <= _)) => solve [apply: ge0_mu] : core.
#[global] Hint Resolve le1_mu summable_mu : core.
Section Clamp.
Context {RSource code : realType}.
Definition clamp
Source code (xSource code : R) :=
Num.max (Num.min x 1) 0.
Lemma ge0_clampSource code xSource code : 0 <= clamp x.
Lemma le1_clampSource code xSource code : clamp x <= 1.
Definition cp01_clamp
distr_of : forall [R : realType] [T : choiceType], phant R -> phant T -> Type distr_of is not universe polymorphic Arguments distr_of [R T] _ _ distr_of is transparent Expands to: Constant mathcomp.experimental_reals.distr.distr_of Declared in library mathcomp.experimental_reals.distr, line 52, characters 11-19
Source code := (ge0_clamp, le1_clamp).
Lemma clamp_in01Source code xSource code : 0 <= x <= 1 -> clamp x = x.
Lemma clamp_idSource code xSource code : clamp (clamp x) = clamp x.
Proof.
Lemma clamp0Source code : clamp 0 = 0.
Proof.
Lemma clamp1Source code : clamp 1 = 1.
Proof.
Section StdDefs.
Context {RSource code : realType} (TSource code : choiceType).
Implicit Types (mu : {distr T / R}) (A B E : pred T) (f : T -> R).
Definition dinsupp
clamp : forall {R : realType}, R -> R clamp is not universe polymorphic Arguments clamp {R} x%_ring_scope clamp is transparent Expands to: Constant mathcomp.experimental_reals.distr.clamp Declared in library mathcomp.experimental_reals.distr, line 80, characters 11-16
Source code muSource code := fun xSource code => mu x != 0 :> R.
Lemma in_dinsuppSource code xSource code (muSource code : {distr T / R}) :
(x \in dinsupp mu) = (mu x != 0).
Proof.
Lemma dinsuppPSource code muSource code xSource code : reflect (mu x <> 0) (x \in dinsupp mu).
Lemma dinsuppPnSource code muSource code xSource code : reflect (mu x = 0) (x \notin dinsupp mu).
Definition pr
cp01_clamp : forall {R : realType}, (forall x : R, (0 <= clamp x)%R) * (forall x : R, (clamp x <= 1)%R) cp01_clamp is not universe polymorphic Arguments cp01_clamp {R} cp01_clamp is transparent Expands to: Constant mathcomp.experimental_reals.distr.cp01_clamp Declared in library mathcomp.experimental_reals.distr, line 89, characters 11-21
Source code muSource code ESource code := PosSum.psum (fun xSource code => (E x)%:R * mu x).
Definition prc
dinsupp : forall {R : realType} [T : choiceType], {distr T / R} -> T -> bool dinsupp is not universe polymorphic Arguments dinsupp {R} [T] mu x dinsupp is transparent Expands to: Constant mathcomp.experimental_reals.distr.dinsupp Declared in library mathcomp.experimental_reals.distr, line 110, characters 11-18
Source code muSource code ESource code ASource code := pr mu [predI E & A] / pr mu A.
Definition esp
pr : forall {R : realType} [T : choiceType], {distr T / R} -> pred T -> R pr is not universe polymorphic Arguments pr {R} [T] mu E pr is transparent Expands to: Constant mathcomp.experimental_reals.distr.pr Declared in library mathcomp.experimental_reals.distr, line 122, characters 11-13
Source code muSource code fSource code := sum (fun xSource code => f x * mu x).
Definition espc
prc : forall {R : realType} [T : choiceType], {distr T / R} -> pred T -> pred T -> R prc is not universe polymorphic Arguments prc {R} [T] mu E A prc is transparent Expands to: Constant mathcomp.experimental_reals.distr.prc Declared in library mathcomp.experimental_reals.distr, line 123, characters 11-14
Source code muSource code fSource code ASource code := sum (fun xSource code => f x * prc mu (pred1 x) A).
Definition has_esp
esp : forall {R : realType} [T : choiceType], {distr T / R} -> (T -> R) -> R esp is not universe polymorphic Arguments esp {R} [T] mu f%_function_scope esp is transparent Expands to: Constant mathcomp.experimental_reals.distr.esp Declared in library mathcomp.experimental_reals.distr, line 124, characters 11-14
Source code muSource code fSource code := summable (fun xSource code => f x * mu x).
End StdDefs.
Notation "\P_[ mu ] E"Source code := (pr mu E).
Notation "\P_[ mu , A ] E"Source code := (prc mu E A).
Notation "\E_[ mu ] f"Source code := (esp mu f).
Notation "\E_[ mu , A ] f"Source code := (espc mu f A).
Notation "\E?_[ mu ] f"Source code := (has_esp mu f).
Notation dweightSource code mu := (\P_[mu] predT).
Section DistrTheory.
Context {RSource code : realType} {TSource code : choiceType} (muSource code : T -> R).
Definition isdistr
espc : forall {R : realType} [T : choiceType], {distr T / R} -> (T -> R) -> pred T -> R espc is not universe polymorphic Arguments espc {R} [T] mu f%_function_scope A espc is transparent Expands to: Constant mathcomp.experimental_reals.distr.espc Declared in library mathcomp.experimental_reals.distr, line 125, characters 11-15
Source code :=
(forall xSource code, 0 <= mu x) /\ (forall JSource code, uniq J -> \sum_(jSource code <- J) mu j <= 1).
Hypothesis isdSource code : isdistr.
Local Lemma isd1Source code : forall xSource code, 0 <= mu x.
Proof.
Local Lemma isd2Source code : summable mu.
Proof.
Local Lemma isd3Source code : PosSum.psum mu <= 1.
Proof.
by exists 0, fset0; rewrite big_fset0.
apply/ubP=> y [x ->]; rewrite big_fset_seq /=.
by case: isd => _; apply; case: x => x /= /canonical_uniq.
Qed.
Definition mkdistr
has_esp : forall {R : realType} [T : choiceType], {distr T / R} -> (T -> R) -> Prop has_esp is not universe polymorphic Arguments has_esp {R} [T] mu f%_function_scope has_esp is transparent Expands to: Constant mathcomp.experimental_reals.distr.has_esp Declared in library mathcomp.experimental_reals.distr, line 127, characters 11-18
Source code := @Distr R T mu isd1 isd2 isd3.
Lemma mkdistrESource code : mkdistr =1 mu.
Proof.
Definition ispredistr
isdistr : forall {R : realType} {T : choiceType}, (T -> R) -> Prop isdistr is not universe polymorphic Arguments isdistr {R T} mu%_function_scope isdistr is transparent Expands to: Constant mathcomp.experimental_reals.distr.isdistr Declared in library mathcomp.experimental_reals.distr, line 141, characters 11-18
Source code {TSource code : choiceType} (muSource code : T -> R) :=
[/\ forall xSource code, 0 <= mu x & summable mu].
End DistrTheory.
Lemma isdistr_finPSource code {RSource code : realType} {ISource code : finType} (muSource code : I -> R) :
(isdistr mu) <-> (forall xSource code, 0 <= mu x) /\ (\sum_jSource code mu j <= 1).
Proof.
Lemma le1_mu1Source code
{RSource code : realType} {TSource code : choiceType} (muSource code : {distr T / R}) xSource code : mu x <= 1.
Proof.
Section DistrD.
Context {RSource code : realType} {TSource code : choiceType} (muSource code : T -> R).
Definition mnull
mkdistr : forall {R : realType} {T : choiceType} [mu : T -> R], isdistr mu -> distr R T mkdistr is not universe polymorphic Arguments mkdistr {R T} [mu]%_function_scope isd mkdistr is transparent Expands to: Constant mathcomp.experimental_reals.distr.mkdistr Declared in library mathcomp.experimental_reals.distr, line 164, characters 11-18
Source code := fun xSource code : T => (0 : R).
Lemma isd_mnullSource code : isdistr mnull.
Definition dnull
ispredistr : forall {R : realType} {T : choiceType}, (T -> R) -> Prop ispredistr is not universe polymorphic Arguments ispredistr {R T} mu%_function_scope ispredistr is transparent Expands to: Constant mathcomp.experimental_reals.distr.ispredistr Declared in library mathcomp.experimental_reals.distr, line 169, characters 11-21
Source code := locked (mkdistr isd_mnull).
Lemma dnullESource code xSource code : dnull x = 0.
Proof.
Definition mkdistrd
mnull : forall {R : realType} {T : choiceType}, T -> R mnull is not universe polymorphic Arguments mnull {R T} x mnull is transparent Expands to: Constant mathcomp.experimental_reals.distr.mnull Declared in library mathcomp.experimental_reals.distr, line 192, characters 11-16
Source code : {distr T / R} :=
if @idP `[< isdistr mu >] is ReflectT Px then
mkdistr (asboolW Px)
else dnull.
End DistrD.
Lemma lef_dnullSource code {RSource code : realType} {TSource code : choiceType} (muSource code : {distr T / R}) :
dnull <=1 mu.
Section Restr.
Context {RSource code : realType} {TSource code : choiceType} (pSource code : pred T).
Definition mrestr
dnull : forall {R : realType} {T : choiceType}, distr R T dnull is not universe polymorphic Arguments dnull {R T} dnull is transparent Expands to: Constant mathcomp.experimental_reals.distr.dnull Declared in library mathcomp.experimental_reals.distr, line 197, characters 11-16
Source code (muSource code : {distr T / R}) :=
fun xSource code => if p x then mu x else 0.
Lemma isd_mrestrSource code (muSource code : {distr T / R}) : isdistr (mrestr mu).
Proof.
Definition drestr
mkdistrd : forall {R : realType} {T : choiceType}, (T -> R) -> {distr T / R} mkdistrd is not universe polymorphic Arguments mkdistrd {R T} mu%_function_scope mkdistrd is transparent Expands to: Constant mathcomp.experimental_reals.distr.mkdistrd Declared in library mathcomp.experimental_reals.distr, line 202, characters 11-19
Source code (muSource code : {distr T / R}) := locked (mkdistr (isd_mrestr mu)).
Lemma drestrESource code (muSource code : {distr T / R}) xSource code :
drestr mu x = if p x then mu x else 0.
Proof.
Section RestrTheory.
Context {RSource code : realType} {TSource code : choiceType}.
Lemma drestrDSource code (muSource code : {distr T / R}) (pSource code : pred T) xSource code :
mu x = drestr p mu x + drestr (predC p) mu x.
Lemma dinsupp_restrSource code (muSource code : {distr T / R}) (pSource code : pred T) xSource code :
(x \in dinsupp (drestr p mu)) = (x \in dinsupp mu) && p x.
Proof.
Section DRat.
Context {RSource code : realType} (TSource code : choiceType).
Local Notation distrSource code := {distr T / R}.
Implicit Types (s : seq T).
Definition mrat
mrestr : forall {R : realType} {T : choiceType}, pred T -> {distr T / R} -> T -> R mrestr is not universe polymorphic Arguments mrestr {R T} p mu x mrestr is transparent Expands to: Constant mathcomp.experimental_reals.distr.mrestr Declared in library mathcomp.experimental_reals.distr, line 217, characters 11-17
Source code (sSource code : seq T) : T -> R :=
fun xSource code : T => (count (pred1 x) s)%:R / (size s)%:R.
Lemma ge0_mratSource code sSource code : forall xSource code, 0 <= mrat s x.
Local Lemma has_sup_mratSource code sSource code JSource code : uniq J -> \sum_(iSource code <- J) mrat 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.
Local Lemma mrat_supSource code sSource code : (0 < size s)%N ->
\sum_(iSource code <- undup s) mrat s i = 1.
Proof.
Local Lemma summable_mratSource code sSource code: summable (mrat s).
Proof.
by move=> j _; rewrite ger0_norm ?ge0_mrat.
by apply/has_sup_mrat.
Qed.
Lemma isd_mratSource code sSource code : isdistr (mrat s).
Proof.
Definition drat
drestr : forall {R : realType} {T : choiceType}, pred T -> {distr T / R} -> distr R T drestr is not universe polymorphic Arguments drestr {R T} p mu drestr is transparent Expands to: Constant mathcomp.experimental_reals.distr.drestr Declared in library mathcomp.experimental_reals.distr, line 229, characters 11-17
Source code sSource code := locked (mkdistr (isd_mrat s)).
Lemma drat1ESource code sSource code xSource code :
drat s x = (count_mem x s)%:R / (size s)%:R.
Definition dunit
mrat : forall {R : realType} [T : choiceType], seq T -> T -> R mrat is not universe polymorphic Arguments mrat {R} [T] s%_seq_scope _ mrat is transparent Expands to: Constant mathcomp.experimental_reals.distr.mrat Declared in library mathcomp.experimental_reals.distr, line 261, characters 11-15
Source code xSource code := locked (drat [:: x]).
Definition duni
drat : forall {R : realType} [T : choiceType], seq T -> distr R T drat is not universe polymorphic Arguments drat {R} [T] s%_seq_scope drat is transparent Expands to: Constant mathcomp.experimental_reals.distr.drat Declared in library mathcomp.experimental_reals.distr, line 304, characters 11-15
Source code sSource code := locked (drat (undup s)).
Lemma dunit1ESource code xSource code ySource code : (dunit x) y = (x == y)%:R.
Lemma duni1ESource code sSource code xSource code : (duni s) x = (x \in s)%:R / (size (undup s))%:R.
Proof.
Lemma in_dunitSource code tSource code t'Source code :
t' \in dinsupp (dunit t) -> t' = t :> T.
End DRat.
Section Flip.
Context {RSource code : realType}.
Definition mflip
dunit : forall {R : realType} [T : choiceType], T -> distr R T dunit is not universe polymorphic Arguments dunit {R} [T] x dunit is transparent Expands to: Constant mathcomp.experimental_reals.distr.dunit Declared in library mathcomp.experimental_reals.distr, line 310, characters 11-16
Source code (xtSource code : R) :=
fun bSource code => if b then clamp xt else 1 - clamp xt.
Lemma isd_mflipSource code xtSource code : isdistr (mflip xt).
Proof.
+ by case: b; rewrite ?subr_ge0 cp01_clamp.
+ by rewrite /index_enum !unlock /= addr0 addrC subrK.
Qed.
Definition dflip
duni : forall {R : realType} [T : choiceType], seq T -> distr R T duni is not universe polymorphic Arguments duni {R} [T] s%_seq_scope duni is transparent Expands to: Constant mathcomp.experimental_reals.distr.duni Declared in library mathcomp.experimental_reals.distr, line 311, characters 11-15
Source code (xtSource code : R) := locked (mkdistr (isd_mflip xt)).
Lemma dflip1ESource code xtSource code : dflip xt =1 mflip xt.
End Flip.
Section Std.
Context {RSource code : realType}.
Local Notation distrSource code T := {distr T / R}.
Implicit Types (T U : choiceType).
Section Bind.
Context {TSource code USource code : choiceType} (fSource code : T -> distr U) (muSource code : distr T).
Definition mlet
mflip : forall {R : realType}, R -> bool -> R mflip is not universe polymorphic Arguments mflip {R} xt%_ring_scope b%_bool_scope mflip is transparent Expands to: Constant mathcomp.experimental_reals.distr.mflip Declared in library mathcomp.experimental_reals.distr, line 332, characters 11-16
Source code := fun ySource code : U => PosSum.psum (fun xSource code => mu x * f x y).
Lemma isd_mletSource code : isdistr mlet.
Proof.
rewrite /mlet psum_bigop; first by move=> y x; rewrite mulr_ge0.
move=> u; apply/(le_summable (g := mu)) => //.
by move=> x; rewrite mulr_ge0 //= ler_piMr ?le1_mu1.
apply/(le_trans _ (le1_mu mu))/le_psum => //.
move=> x; rewrite sumr_ge0 /= => [y _|]; first by rewrite mulr_ge0.
rewrite -mulr_sumr ler_piMr //; apply/(le_trans _ (le1_mu (f x))).
have := summable_mu (f x) => /gerfinseq_psum => /(_ _ uqJ).
by apply/(le_trans _)/ler_sum=> y _; apply/ler_norm.
Qed.
Definition dlet
dflip : forall {R : realType}, R -> distr R Datatypes_bool__canonical__choice_Choice dflip is not universe polymorphic Arguments dflip {R} xt%_ring_scope dflip is transparent Expands to: Constant mathcomp.experimental_reals.distr.dflip Declared in library mathcomp.experimental_reals.distr, line 341, characters 11-16
Source code := locked (mkdistr isd_mlet).
Lemma dletESource code ySource code : dlet y = PosSum.psum (fun xSource code => mu x * f x y).
Proof.
Notation "\dlet_ ( i <- d ) E"Source code := (dlet (fun iSource code => E) d).
Definition dlift
mlet : forall {R : realType} {T U : choiceType}, (T -> {distr U / R}) -> {distr T / R} -> U -> R mlet is not universe polymorphic Arguments mlet {R T U} f%_function_scope mu y mlet is transparent Expands to: Constant mathcomp.experimental_reals.distr.mlet Declared in library mathcomp.experimental_reals.distr, line 359, characters 11-15
Source code {ASource code : choiceType} (fSource code : A -> {distr A / R}) :=
fun dSource code => \dlet_(xSource code <- d) f x.
Definition diter
dlet : forall {R : realType} {T U : choiceType}, (T -> {distr U / R}) -> {distr T / R} -> distr R U dlet is not universe polymorphic Arguments dlet {R T U} f%_function_scope mu dlet is transparent Expands to: Constant mathcomp.experimental_reals.distr.dlet Declared in library mathcomp.experimental_reals.distr, line 374, characters 11-15
Source code {ASource code : choiceType} nSource code (fSource code : A -> {distr A / R}) :=
fun aSource code => (iter n (dlift f) (dunit a)).
Section BindTheory.
Variables (TSource code USource code : choiceType).
Implicit Types (f g : T -> distr U) (mu nu : distr T).
Lemma dlet_nullSource code fSource code : dlet f dnull =1 dnull.
Lemma dlet_unitSource code fSource code vSource code : \dlet_(ySource code <- dunit v) f y =1 f v.
Proof.
Lemma dlet_dunit_idSource code muSource code : \dlet_(tSource code <- mu) (dunit t) =1 mu.
Proof.
Lemma eq_in_dletSource code fSource code gSource code muSource code nuSource code : {in dinsupp mu, f =2 g} -> mu =1 nu ->
dlet f mu =1 dlet g nu.
Proof.
Lemma summable_mu_wgtdSource code (fSource code : T -> R) muSource code :
(forall xSource code, 0 <= f x <= 1) -> summable (fun xSource code => mu x * f x).
Proof.
exists 1 => x; case/andP: (in01_f x) => ge0_fx le1_fx.
by rewrite ger0_norm.
Qed.
Lemma summable_mletSource code fSource code muSource code ySource code : summable (fun xSource code : T => mu x * (f x) y).
Proof.
Lemma le_in_dletSource code fSource code gSource code muSource code : {in dinsupp mu, f <=2 g} ->
dlet f mu <=1 dlet g mu.
Proof.
Lemma le_mu_dletSource code fSource code muSource code nuSource code : mu <=1 nu -> dlet f mu <=1 dlet f nu.
Proof.
Lemma le_dletSource code fSource code gSource code muSource code nuSource code :
mu <=1 nu
-> {in dinsupp mu, forall xSource code, f x <=1 g x}
-> \dlet_(xSource code <- mu) f x <=1 \dlet_(xSource code <- nu) g x.
Proof.
Lemma dletCSource code (muSource code : {distr T / R}) (nuSource code : {distr U / R}) ySource code :
(\dlet_(_ <- mu) nu) y = (dweight mu) * (nu y).
Proof.
Lemma dinsupp_dletSource code fSource code muSource code ySource code :
y \in dinsupp (\dlet_(xSource code <- mu) f x) ->
exists2 xSource code, x \in dinsupp mu & f x y != 0.
Proof.
Lemma dlet_dinsuppSource code fSource code muSource code xSource code ySource code :
x \in dinsupp mu -> f x y != 0 -> y \in dinsupp (dlet f mu).
Proof.
Lemma dlet_eq0Source code (fSource code : T -> U) muSource code ySource code :
{in dinsupp mu, forall xSource code, f x != y} -> (\dlet_(xSource code <- mu) dunit (f x)) y = 0.
Proof.
Lemma eq0_dletSource code (muSource code : {distr T / R}) (FSource code : T -> {distr U / R}) ySource code :
(\dlet_(xSource code <- mu) F x) y = 0 -> forall xSource code, x \in dinsupp mu -> F x y = 0.
Proof.
End BindTheory.
Section DLetDLet.
Context {TSource code USource code VSource code : choiceType} (f1Source code : T -> distr U) (f2Source code : U -> distr V).
Lemma dlet_dletSource code (muSource code : {distr T / R}) :
\dlet_(xSource code <- \dlet_(ySource code <- mu) f1 y) f2 x
=1 \dlet_(ySource code <- mu) (\dlet_(xSource code <- f1 y) f2 x).
Proof.
pose S ySource code xSource code := mu x * (f1 x y * f2 y z).
rewrite (eq_psum (F2 := fun ySource code => PosSum.psum (S^~ y))) => [x|].
by rewrite -psumZ //; apply/eq_psum => y /=.
rewrite interchange_psum.
+ by move=> x; apply/summableZ/summable_mlet.
+ rewrite {}/S; apply/(le_summable (g := mu)) => //.
move=> x; rewrite ge0_psum /= psumZ ?ler_piMr //.
apply/(le_trans _ (le1_mu (f1 x)))/le_psum => //.
by move=> y; rewrite mulr_ge0 //= ler_piMr ?le1_mu1.
apply/eq_psum=> y /=; rewrite -psumZr //.
by apply/eq_psum=> x /=; rewrite {}/S mulrA.
Qed.
End DLetDLet.
Section DLetAlg.
Context {TSource code USource code : choiceType} (muSource code mu1Source code mu2Source code : {distr T / R}).
Lemma dlet_additiveSource code (fSource code : T -> {distr U / R}) zSource code :
(forall xSource code, mu x = mu1 x + mu2 x) -> (\dlet_(xSource code <- mu) f x) z =
(\dlet_(xSource code <- mu1) f x) z + (\dlet_(xSource code <- mu2) f x) z.
Proof.
by move=> x; rewrite mulr_ge0. by move=> x; rewrite mulr_ge0.
by apply/summable_mlet. by apply/summable_mlet.
by apply/eq_psum=> x /=; rewrite -mulrDl -muD.
Qed.
Definition mlim
dlift : forall {R : realType} {A : choiceType}, (A -> {distr A / R}) -> {distr A / R} -> distr R A dlift is not universe polymorphic Arguments dlift {R A} f%_function_scope d dlift is transparent Expands to: Constant mathcomp.experimental_reals.distr.dlift Declared in library mathcomp.experimental_reals.distr, line 382, characters 11-16
Source code TSource code (fSource code : nat -> distr T) : T -> R :=
fun xSource code => fine (nlim (fun nSource code => f n x)).
Lemma isd_mlimSource code TSource code (fSource code : nat -> distr T) : isdistr (mlim f).
Proof.
case: nlimP=> // l cvSl; apply/fine_ge0/(ncvg_geC _ cvSl).
by move=> n; apply/ge0_mu.
move=> uqJ; pose F jSource code :=
if `[< iscvg (fun nSource code => f n j) >] then fun nSource code => f n j else 0%:S.
apply/(@le_trans _ _ (\sum_(jSource code <- J) (fine (nlim (F j) (*: R*))))).
apply/ler_sum=> j _; rewrite /F; case/boolP: `[< _ >] => //.
move/asboolPn=> h; rewrite nlimC; case: nlimP=> //.
by case=> // l cf; case: h; exists l.
rewrite -lee_fin -nlim_sumR => [i _|].
rewrite /F; case/boolP: `[< _ >] => [/asboolP //|].
by move=> _; apply/iscvgC.
rewrite leNgt; apply/negP; pose s nSource code := \sum_(jSource code <- J) F j n.
move/ncvg_gt=> -/(_ s (nlim_ncvg _)) [].
suff: iscvg s by case=> l cs; exists l%:E.
apply/iscvg_sum=> j _; rewrite /F; case/boolP: `[< _ >].
by move/asboolP. by move=> _; apply/iscvgC.
move=> K /(_ _ (leqnn K)) /=; apply/negP; rewrite -leNgt.
apply/(@le_trans _ _ (\sum_(jSource code <- J) f K j)); last first.
have /(gerfinseq_psum uqJ) := summable_mu (f K).
move/le_trans=> -/(_ _ (le1_mu (f K)))=> h.
by apply/(le_trans _ h)/ler_sum=> i _; apply/ler_norm.
by apply/ler_sum=> j _; rewrite /F; case/boolP: `[< _ >].
Qed.
Definition dlim
diter : forall {R : realType} {A : choiceType}, nat -> (A -> {distr A / R}) -> A -> {distr A / R} diter is not universe polymorphic Arguments diter {R A} n%_nat_scope f%_function_scope a diter is transparent Expands to: Constant mathcomp.experimental_reals.distr.diter Declared in library mathcomp.experimental_reals.distr, line 385, characters 11-16
Source code TSource code (fSource code : nat -> distr T) :=
locked (mkdistr (isd_mlim f)).
Notation "\dlim_ ( n ) E"Source code := (dlim (fun nSource code => E)).
Lemma dlimESource code TSource code (fSource code : nat -> distr T) xSource code :
(\dlim_(nSource code) f n) x = fine (nlim (fun nSource code => f n x)).
Proof.
Section DLimTheory.
Variables (TSource code USource code : choiceType).
Implicit Types (f g : nat -> distr T) (h : T -> {distr U / R}).
Implicit Types (mu : {distr T / R}).
Lemma dlimCSource code muSource code : \dlim_(nSource code) mu =1 mu.
Lemma eq_dlimSource code fSource code gSource code : f =2 g -> dlim f =1 dlim g.
Proof.
Lemma eq_from_dlimSource code KSource code fSource code gSource code :
(forall nSource code, (K <= n)%N -> f n =1 g n) -> dlim f =1 dlim g.
Proof.
by apply/(eq_from_nlim (K := K)); move=> n /eq_fg /(_ x).
Qed.
Definition dlim_bump
mlim : forall {R : realType} [T : choiceType], (nat -> {distr T / R}) -> T -> R mlim is not universe polymorphic Arguments mlim {R} [T] f%_function_scope _ mlim is transparent Expands to: Constant mathcomp.experimental_reals.distr.mlim Declared in library mathcomp.experimental_reals.distr, line 545, characters 11-15
Source code (muSource code : nat -> {distr T / R}) :
dlim (fun nSource code => mu n.+1) =1 dlim mu.
Definition dlim_lift
dlim : forall {R : realType} [T : choiceType], (nat -> {distr T / R}) -> distr R T dlim is not universe polymorphic Arguments dlim {R} [T] f%_function_scope dlim is transparent Expands to: Constant mathcomp.experimental_reals.distr.dlim Declared in library mathcomp.experimental_reals.distr, line 575, characters 11-15
Source code (muSource code : nat -> {distr T / R}) pSource code :
dlim (fun nSource code => mu (n + p)%N) =1 dlim mu.
Proof.
Definition dcvg
dlim_bump : forall {R : realType} [T : choiceType] (mu0 : nat -> {distr T / R}), \dlim_(n) mu0 n.+1 =1 \dlim_(n) mu0 n dlim_bump is not universe polymorphic Arguments dlim_bump {R} [T] mu%_function_scope x dlim_bump is opaque Expands to: Constant mathcomp.experimental_reals.distr.dlim_bump Declared in library mathcomp.experimental_reals.distr, line 607, characters 11-20
Source code {TSource code : choiceType} (fSource code : nat -> {distr T / R}) :=
forall xSource code, exists lSource code, ncvg (fun nSource code => f n x) l.
Definition ducvg
dlim_lift : forall {R : realType} [T : choiceType] (mu0 : nat -> {distr T / R}) (p : nat), \dlim_(n) mu0 (n + p) =1 \dlim_(n) mu0 n dlim_lift is not universe polymorphic Arguments dlim_lift {R} [T] mu%_function_scope p%_nat_scope x dlim_lift is opaque Expands to: Constant mathcomp.experimental_reals.distr.dlim_lift Declared in library mathcomp.experimental_reals.distr, line 611, characters 11-20
Source code {TSource code : choiceType} (fSource code : nat -> {distr T / R}) :=
exists lSource code, forall xSource code, ncvg (fun nSource code => f n x) l.
CoInductive dlim_specSource code fSource code (xSource code : T) : R -> Type :=
| DLimCvgSource code : forall lSource code : R, 0 <= l -> l <= 1 ->
ncvg (fun nSource code => f n x) l%:E -> dlim_spec f x l
| DLimOutSource code : ~ (exists lSource code : \bar R, ncvg (fun nSource code => f n x) l) ->
dlim_spec f x 0.
Lemma dlimPSource code fSource code xSource code : dlim_spec f x (dlim f x).
Proof.
Lemma dcvgPSource code fSource code : dcvg f -> forall xSource code,
exists2 lSource code, (0 <= l <= 1) & ncvg (f^~ x) l%:E.
Proof.
Lemma dcvg_homoSource code fSource code :
(forall nSource code mSource code, (n <= m)%N -> f n <=1 f m) -> dcvg f.
Proof.
by move=> n m /mn_f; apply.
case/ncvg_mono_bnd => {mn_f}; first apply/asboolP/nboundedP.
exists 2%:R => // n; apply/(@le_lt_trans _ _ 1%:R)/ltr_nat.
by rewrite ger0_norm // le1_mu1.
by move=> y h; exists y%:E.
Qed.
Lemma ge0_dlimSource code fSource code : forall xSource code, 0 <= dlim f x.
Proof.
Lemma le1_dlimSource code fSource code : forall xSource code, dlim f x <= 1.
Lemma le_dlimSource code fSource code gSource code :
(forall nSource code, f n <=1 g n) -> dcvg g -> dlim f <=1 dlim g.
Proof.
Lemma leub_dlimSource code fSource code muSource code : (forall nSource code, f n <=1 mu) -> dlim f <=1 mu.
Proof.
Lemma dlim_ubSource code fSource code kSource code :
(forall nSource code mSource code, (n <= m)%N -> f n <=1 f m) -> f k <=1 dlim f.
Proof.
apply/(ncvg_homo_le (u := u))=> [m n /mn_f|]; first by apply.
move/dcvg_homo: mn_f => /dcvgP /(_ x) [l _].
by move=> cv; rewrite (nlimE cv).
Qed.
Lemma __admitted__dlet_limSource code fSource code hSource code : (forall nSource code mSource code, (n <= m)%N -> f n <=1 f m) ->
\dlet_(xSource code <- dlim f) h x =1 \dlim_(nSource code) \dlet_(xSource code <- f n) h x.
Proof.
Lemma __admitted__dlim_letSource code (fSource code : nat -> T -> {distr U / R}) (muSource code : {distr T / R}) :
(forall xSource code nSource code mSource code, (n <= m)%N -> f n x <=1 f m x) ->
\dlim_(nSource code) \dlet_(xSource code <- mu) (f n x) =1
\dlet_(xSource code <- mu) \dlim_(nSource code) (f n x).
Proof using Type. End DLimTheory.
#[deprecated(since="mathcomp-analysis 0.6.2",
note="lacks proof, use __admitted__dlet_lim explicitly if you really want to use this lemma")]
Notation dlet_limSource code := __admitted__dlet_lim.
#[deprecated(since="mathcomp-analysis 0.6.2",
note="lacks proof, use __admitted__dlim_let explicitly if you really want to use this lemma")]
Notation dlim_letSource code := __admitted__dlim_let.
Section Marginals.
Variable (TSource code USource code : choiceType) (hSource code : T -> U) (muSource code : distr T).
Definition dmargin
dcvg : forall {R : realType} {T : choiceType}, (nat -> {distr T / R}) -> Prop dcvg is not universe polymorphic Arguments dcvg {R T} f%_function_scope dcvg is transparent Expands to: Constant mathcomp.experimental_reals.distr.dcvg Declared in library mathcomp.experimental_reals.distr, line 615, characters 11-15
Source code := \dlet_(xSource code <- mu) (dunit (h x)).
Lemma dmarginESource code : dmargin = \dlet_(ySource code <- mu) (dunit (h y)).
Proof.
Section MarginalsTh.
Variable (TSource code USource code VSource code : choiceType).
Lemma dmargin_psumESource code (muSource code : {distr T / R}) (fSource code : T -> U) ySource code :
(dmargin f mu) y = PosSum.psum (fun xSource code => (f x == y)%:R * mu x).
Lemma dlet_dmarginSource code (muSource code : {distr T / R}) (fSource code : T -> U) (gSource code : U -> {distr V / R}):
\dlet_(uSource code <- dmargin f mu) g u =1 \dlet_(tSource code <- mu) (g (f t)).
Proof.
Lemma dmargin_dletSource code (muSource code : {distr T / R}) (fSource code : U -> V) (gSource code : T -> {distr U / R}):
dmargin f (\dlet_(tSource code <- mu) g t) =1 \dlet_(tSource code <- mu) (dmargin f (g t)).
Proof.
Lemma dmargin_dunitSource code (tSource code : T) (fSource code : T -> U):
dmargin f (dunit t) =1 dunit (f t) :> {distr U / R}.
Proof.
End Std.
#[deprecated(since="1.17.0", note="use `dmargin_dlet` instead")]
Notation __deprecated__dmargin_dletSource code := dmargin_dlet (only parsing).
#[deprecated(since="1.17.0", note="use `dlet_dmargin` instead")]
Notation __deprecated__dlet_dmarginSource code := dlet_dmargin (only parsing).
#[deprecated(since="1.17.0", note="use `dlet_dlet` instead")]
Notation __deprecated__dlet_dletSource code := dlet_dlet (only parsing).
Notation dfstSource code mu := (dmargin fst mu).
Notation dsndSource code mu := (dmargin snd mu).
Notation "\dlet_ ( i <- d ) E"Source code := (dlet (fun iSource code => E) d).
Notation "\dlim_ ( n ) E"Source code := (dlim (fun nSource code => E)).
Section DSwap.
Context {RSource code : realType} {ASource code BSource code : choiceType} (muSource code : {distr (A * B) / R}).
Definition dswap
ducvg : forall {R : realType} {T : choiceType}, (nat -> {distr T / R}) -> Prop ducvg is not universe polymorphic Arguments ducvg {R T} f%_function_scope ducvg is transparent Expands to: Constant mathcomp.experimental_reals.distr.ducvg Declared in library mathcomp.experimental_reals.distr, line 618, characters 11-16
Source code : {distr (B * A) / R} :=
dmargin (fun xySource code => (xy.2, xy.1)) mu.
End DSwap.
Section DSwapCoreTheory.
Context {RSource code : realType} {ASource code BSource code : choiceType} (muSource code : {distr (A * B) / R}).
Lemma dswapESource code xySource code : dswap mu xy = mu (xy.2, xy.1).
Proof.
Section DSwapTheory.
Context {RSource code : realType} {ASource code BSource code : choiceType} (muSource code : {distr (A * B) / R}).
Lemma dswapKSource code : dswap (dswap mu) =1 mu.
Proof.
Lemma dinsupp_swapSource code xySource code : (xy.2, xy.1) \in dinsupp mu ->
xy \in dinsupp (dswap mu).
Lemma dfst_dswapSource code : dfst (dswap mu) =1 dsnd mu.
Proof.
by move=> _ t /=; rewrite dlet_unit /=.
Qed.
Lemma dsnd_dswapSource code : dsnd (dswap mu) =1 dfst mu.
Proof.
by move=> _ t /=; rewrite dlet_unit /=.
Qed.
#[deprecated(since="1.17.0", note="use `dfst_dswap` instead")]
Notation __deprecated__dfst_dswapSource code := dfst_dswap (only parsing).
#[deprecated(since="1.17.0", note="use `dsnd_dswap` instead")]
Notation __deprecated__dsnd_dswapSource code := dsnd_dswap (only parsing).
Section DFst.
Context {RSource code : realType} {TSource code USource code : choiceType}.
Lemma dfstESource code (muSource code : {distr (T * U) / R}) xSource code :
dfst mu x = PosSum.psum (fun ySource code => mu (x, y)).
Proof.
rewrite (reindex_psum (P := [pred zSource code | z.1 == x]) (h := h)) /=.
+ case=> a b; rewrite !inE/= mulf_eq0 => /norP[].
by rewrite pnatr_eq0 eqb0 negbK.
+ by exists snd => [z|[z1 z2]]; rewrite !inE //= => /eqP ->.
by apply/eq_psum => y; rewrite eqxx mul1r.
Qed.
Lemma summable_fstSource code (muSource code : {distr (T * U) / R}) xSource code :
summable (fun ySource code => mu (x, y)).
Proof.
apply/summable_seqP; exists M => // J uqJ; pose X := [seq (x, y) | ySource code <- J].
apply/(le_trans _ (h X _)); last by rewrite map_inj_uniq // => y1 y2 [].
by rewrite le_eqVlt big_map eqxx.
Qed.
Section DSnd.
Context {RSource code : realType} {TSource code USource code : choiceType}.
Lemma dsndESource code (muSource code : {distr (T * U) / R}) ySource code :
dsnd mu y = PosSum.psum (fun xSource code => mu (x, y)).
Proof.
Lemma summable_sndSource code (muSource code : {distr (T * U) / R}) ySource code :
summable (fun xSource code => mu (x, y)).
Proof.
#[deprecated(since="1.17.0", note="use `dsndE` instead")]
Notation __deprecated__dsndESource code := dsndE (only parsing).
Section PrCoreTheory.
Context {RSource code : realType} {TSource code : choiceType}.
Implicit Types (mu : {distr T / R}) (A B E : pred T).
Lemma summable_prSource code ESource code muSource code : summable (fun xSource code => (E x)%:R * mu x).
Proof.
by rewrite mulr_ge0 ?ler0n //= ler_piMl // lern1 leq_b1.
Qed.
Lemma pr_pred0Source code muSource code : \P_[mu] pred0 = 0.
Lemma pr_pred1Source code muSource code xSource code : mu x = \P_[mu] (pred1 x).
Proof.
Lemma pr_expSource code muSource code (ESource code : pred T) : \P_[mu] E = \E_[mu] (fun mSource code => (E m)%:R).
Lemma pr_predTSource code muSource code : \P_[mu] predT = PosSum.psum mu.
Lemma pr_dunitSource code ESource code xSource code : \P_[dunit x] E = (E x)%:R :> R.
Proof.
Lemma exp_dunitSource code (fSource code : T -> R) (xSource code : T) : \E_[dunit x] f = f x.
Proof.
Lemma exp_cstSource code muSource code rSource code : \E_[mu] (fun _ => r) = \P_[mu] predT * r.
Lemma exp0Source code muSource code : \E_[mu] (fun _ => 0) = 0.
Lemma has_expCSource code muSource code cSource code : \E?_[mu] (fun _ => c).
Proof.
Lemma has_exp0Source code muSource code : \E?_[mu] (fun _ => 0).
Proof.
Lemma has_exp1Source code muSource code : \E?_[mu] (fun _ => 1).
Proof.
Lemma has_expZSource code muSource code cSource code FSource code : \E?_[mu] F -> \E?_[mu] (c \*o F).
Proof.
Lemma expZSource code muSource code FSource code cSource code : \E_[mu] (c \*o F) = c * \E_[mu] F.
Lemma ge0_prSource code ASource code muSource code : 0 <= \P_[mu] A.
Proof.
Lemma ge0_prcSource code ASource code BSource code muSource code : 0 <= \P_[mu, B] A.
Lemma eq_in_prSource code ASource code BSource code muSource code :
{in dinsupp mu, A =i B} -> \P_[mu] A = \P_[mu] B.
Proof.
Lemma eq_prSource code ASource code BSource code muSource code : A =i B -> \P_[mu] A = \P_[mu] B.
Proof.
Lemma eq_expSource code muSource code (f1Source code f2Source code : T -> R):
{in dinsupp mu, f1 =1 f2} -> \E_[mu] f1 = \E_[mu] f2.
Proof.
Lemma pr_pred0_eqSource code (muSource code : {distr T / R}) (ESource code : pred T) :
E =1 pred0 -> \P_[mu] E = 0.
End PrCoreTheory.
Section PrTheory.
Context {RSource code : realType} {TSource code USource code : choiceType} {ISource code : eqType}.
Implicit Types (mu : {distr T / R}) (A B E : pred T).
Lemma pr_dletSource code ESource code fSource code (muSource code : {distr U / R}) :
\P_[dlet f mu] E = \E_[mu] (fun xSource code => \P_[f x] E).
Proof.
rewrite /pr; unlock dlet => /=; rewrite /mlet /=.
pose F xSource code ySource code := (E x)%:R * (mu y * f y x).
transitivity (PosSum.psum (fun xSource code => PosSum.psum (fun ySource code => F x y))); rewrite {}/F.
by apply/eq_psum => x; rewrite -psumZ ?ler0n.
rewrite interchange_psum /=; last first.
apply/eq_psum=> y /=; rewrite mulrC -psumZ //.
by apply/eq_psum=> x /=; rewrite mulrCA.
+ have := summable_pr E (dlet f mu); apply/eq_summable.
by move=> x; rewrite /= dletE psumZ ?ler0n.
+ by move=> t; exact/summable_condl/summable_mlet.
Qed.
Lemma pr_dmarginSource code ESource code fSource code (muSource code : {distr U / R}) :
\P_[dmargin f mu] E = \P_[mu] [pred xSource code | f x \in E].
Lemma eq0_prSource code ASource code muSource code :
(forall xSource code, x \in dinsupp mu -> x \notin A) -> \P_[mu] A = 0.
Proof.
Lemma eq0_prcSource code ASource code BSource code muSource code :
(forall xSource code, x \in dinsupp mu -> x \in B -> x \notin A)
-> \P_[mu, B] A = 0.
Proof.
Lemma subset_prSource code ASource code BSource code muSource code : {subset B <= A} -> \P_[mu] B <= \P_[mu] A.
Proof.
Lemma le1_prSource code ASource code muSource code : \P_[mu] A <= 1.
Lemma le_expSource code muSource code f1Source code f2Source code: \E?_[mu] f1 -> \E?_[mu] f2 ->
f1 <=1 f2 -> \E_[mu] f1 <= \E_[mu] f2.
Lemma le_in_prSource code E1Source code E2Source code muSource code :
(forall xSource code, x \in dinsupp mu -> x \in E1 -> x \in E2) ->
\P_[mu] E1 <= \P_[mu] E2.
Proof.
Lemma le_mu_prSource code ASource code muSource code nuSource code :
(forall xSource code, x \in dinsupp nu -> x \in A -> nu x <= mu x)
-> \P_[nu] A <= \P_[mu] A.
Proof.
Lemma le1_prcSource code ASource code BSource code muSource code : \P_[mu, B] A <= 1.
Proof.
Lemma prc_sumSource code ASource code muSource code : 0 < \P_[mu] A ->
PosSum.psum (fun xSource code => \P_[mu, A] (pred1 x)) = 1.
Proof.
rewrite (eq_psum (F2 := (fun xSource code => (A x)%:R * mu x))); last first.
by rewrite divff // gt_eqF.
move=> x /=; rewrite /pr (psum_finseq (r := [:: x])) ?big_seq1 //=.
move=> y; rewrite !inE; case: (y == x) => //=.
by rewrite mul0r eqxx.
by rewrite !inE eqxx -topredE ger0_norm ?mulr_ge0 ?ler0n.
Qed.
Lemma pr_eq0Source code muSource code ESource code : \P_[mu] E = 0 -> forall xSource code, x \in E -> mu x = 0.
Proof.
by move: xE; rewrite -topredE /= => ->; rewrite mul1r.
Qed.
Lemma prIDSource code ASource code BSource code muSource code :
\P_[mu] A = \P_[mu] [predI A & B] + \P_[mu] [predI A & predC B].
Proof.
Lemma pr_or_indepSource code (ASource code BSource code : pred T) (muSource code : {distr T / R}) :
(forall xSource code, x \in A -> x \notin B) ->
\P_[mu] [predU A & B] = \P_[mu] A + \P_[mu] B.
Proof.
Lemma pr_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 -pr_or_indep.
by move=> x; rewrite !inE => /eqP->. by apply/eq_pr.
Qed.
Lemma pr_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 /= pr_pred1.
by rewrite -h -pr_or_indep // => x /eqP ->.
Qed.
Lemma pr_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_pr (B := 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 pr_pred0_eq // => 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 -pr_or_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_pr=> x; rewrite -!topredE /= big_cons.
Qed.
Lemma pr_orSource 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 pr_andSource code ASource code BSource code muSource code : \P_[mu] [predI A & B] =
\P_[mu] A + \P_[mu] B - \P_[mu] [predU A & B].
Lemma ler_pr_orSource code ASource code BSource code muSource code :
\P_[mu] [predU A & B] <= \P_[mu] A + \P_[mu] B.
Lemma ler_pr_andSource code ASource code BSource code muSource code :
\P_[mu] [predI A & B] <= \P_[mu] A + \P_[mu] B.
Lemma pr_predCSource code ESource code muSource code: \P_[mu](predC E) = \P_[mu] predT - \P_[mu] E.
Proof.
Lemma pr_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 (prID _ B); congr (_ + _); apply/h.
rewrite /prc mulrCA; have [] := eqVneq (\P_[mu] B') 0; last first.
by move=> nzPB'; rewrite divff // mulr1.
move=> zPB'; rewrite zPB' invr0 !mulr0; apply/eq0_pr.
move=> x mux; move/pr_eq0: zPB' => /(_ x) h; rewrite !inE.
by apply/negP=> /andP[_ /h] /dinsuppP.
Qed.
Lemma __admitted__exp_splitSource code ASource code fSource code muSource code : \E?_[mu] f -> \E_[mu] f =
\P_[mu] A * \E_[mu, A] f
+ \P_[mu] (predC A) * \E_[mu, predC A] f.
Proof using Type.
Lemma has_esp_boundedSource code fSource code muSource code :
(exists MSource code, forall xSource code, `|f x| < M) -> \E?_[mu] f.
Proof.
case=> M ltM; rewrite /has_esp; apply/summable_seqP.
exists (Num.max M 0); first by rewrite le_max lexx orbT.
move=> J uqJ; apply/(@le_trans _ _ (\sum_(jSource code <- J) M * mu j)).
apply/ler_sum=> j _; rewrite normrM [X in _*X]ger0_norm //.
by apply/ler_wpM2r=> //; apply/ltW.
case: (ltrP M 0) => [lt0_M|ge0_M].
rewrite ?(ltW lt0_M) // -mulr_sumr.
by rewrite nmulr_rle0 //; apply/sumr_ge0.
by rewrite -mulr_sumr ler_piMr // -pr_mem ?le1_pr.
Qed.
Lemma bounded_has_expSource code muSource code FSource code :
(exists MSource code, forall xSource code, `|F x| <= M) -> \E?_[mu] F.
Proof.
Lemma summable_has_expSource code muSource code FSource code : summable F -> \E?_[mu] F.
Proof.
Lemma exp_le_bdSource code muSource code FSource code (MSource code : R) :
0 <= M -> (forall xSource code, `|F x| <= M) -> \E_[mu] F <= M.
Proof.
Lemma __admitted__exp_dletSource code muSource code (nuSource code : T -> {distr U / R}) FSource code :
(forall etaSource code, \E?_[eta] F) ->
\E_[dlet nu mu] F = \E_[mu] (fun xSource code => \E_[nu x] F).
Proof using Type*. End PrTheory.
#[deprecated(since="1.17.0", note="use `pr_dlet` instead")]
Notation __deprecated__pr_dletSource code := pr_dlet (only parsing).
#[deprecated(since="mathcomp-analysis 0.6.2",
note="lacks proof, use __admitted__exp_split explicitly if you really want to use this lemma")]
Notation exp_splitSource code := __admitted__exp_split.
#[deprecated(since="mathcomp-analysis 0.6.2",
note="lacks proof, use __admitted__exp_dlet explicitly is you really want to use this lemma")]
Notation exp_dletSource code := __admitted__exp_dlet.
Section Jensen.
Context {RSource code : realType} {ISource code : finType}.
Definition convexon
dmargin : forall {R : realType} [T U : choiceType], (T -> U) -> {distr T / R} -> distr R U dmargin is not universe polymorphic Arguments dmargin {R} [T U] h%_function_scope mu dmargin is transparent Expands to: Constant mathcomp.experimental_reals.distr.dmargin Declared in library mathcomp.experimental_reals.distr, line 707, characters 11-18
Source code (aSource code bSource code : \bar R) (fSource code : R -> R) :=
forall xSource code ySource code, (a <= x%:E <= b)%E -> (a <= y%:E <= b)%E ->
forall tSource code, 0 <= t <= 1 ->
f (t * x + (1 - t) * y) <= t * (f x) + (1 - t) * (f y).
Notation convexSource code f := (convexon -oo +oo f).
Section Jensen.
Context (fSource code : R -> R) (xSource code lSource code : I -> R).
Hypothesis cvx_fSource code : convex f.
Hypothesis ge0_lSource code : forall xSource code, 0 <= l x.
Hypothesis eq1_lSource code : \sum_iSource code (l i) = 1.
Lemma JensenSource code : f (\sum_iSource code (l i * x i)) <= \sum_iSource code (l i * f (x i)).
Proof.
by move/esym/eqP; rewrite oner_eq0.
elim: {i} s (l i) (ge0_l i) (x i) => [|j s ih] li ge0_li xi.
by rewrite !big_nil !addr0 => ->; rewrite !mul1r.
rewrite !big_cons; have := ge0_l j; rewrite le_eqVlt.
case/orP => [/eqP<-|gt0_lj].
by rewrite !Monoid.simpm /= !Monoid.simpm; apply/ih.
rewrite !addrA => eq1; pose z := (li * xi + l j * x j) / (li + l j).
have nz_lij: li + l j != 0 by rewrite gt_eqF ?ltr_wpDl.
have/ih := eq1 => -/(_ _ z); rewrite [_ * (_ / _)]mulrC.
rewrite mulfVK // => {}ih; apply/(le_trans (ih _)).
by rewrite addr_ge0 ?ge0_l.
rewrite lerD2r {ih}/z [_ / _]mulrDl ![_*_/_]mulrAC.
set c1 : R := _ / _; set c2 : R := _ / _; have eqc2: c2 = 1 - c1.
apply/(mulfI nz_lij); rewrite mulrBr mulr1 ![(li + l j)*_]mulrC.
by apply/eqP; rewrite !mulfVK // eq_sym subr_eq addrC.
set c := (li + l j); pose z := (c * c1 * f xi + c * c2 * f (x j)).
apply/(@le_trans _ _ z); last by rewrite /z ![_*(_/_)]mulrC !mulfVK.
rewrite {}/z -![c * _ * _]mulrA -mulrDr ler_wpM2l ?addr_ge0 //.
rewrite eqc2 cvx_f // ?leNye ?leey // divr_ge0 ?addr_ge0 //=.
by rewrite ler_pdivrMr ?mul1r ?lerDl ?ltr_wpDl.
Qed.
End Jensen.
Notation convexSource code f := (convexon \-inf \+inf f).