Skip to content

Commit 5296b6a

Browse files
committed
bernoulli probability measure
1 parent 5a0c68f commit 5296b6a

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

CHANGELOG_UNRELEASED.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
### Added
66

7+
- in `signed.v`:
8+
+ definition `onem_NngNum`
9+
- in `measure.v`:
10+
+ definition `bernoulli`, declared as a probability measure instance
11+
- in `itv.v`:
12+
+ canonical `onem_itv01`
13+
714
### Changed
815

916
### Renamed

theories/itv.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ Lemma inum_lt : {mono inum : x y / (x < y)%O}. Proof. by []. Qed.
843843

844844
End Morph.
845845

846+
Canonical onem_itv01 {R : realDomainType} (p : {i01 R}) : {i01 R} :=
847+
@Itv.mk _ _ (onem p%:inum) [itv of 1 - p%:inum].
848+
846849
Section Test1.
847850

848851
Variable R : numDomainType.
@@ -882,8 +885,6 @@ apply/val_inj => /=.
882885
by rewrite subr0 mulr1 opprB addrCA subrr addr0.
883886
Qed.
884887

885-
Canonical onem_itv01 (p : {i01 R}) : {i01 R} :=
886-
@Itv.mk _ _ (onem p%:inum) [itv of 1 - p%:inum].
887888

888889
Definition s_of_pq' (p q : {i01 R}) : {i01 R} :=
889890
(`1- (`1-(p%:inum) * `1-(q%:inum)))%:i01.

theories/measure.v

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ From mathcomp Require Import all_ssreflect all_algebra finmap.
33
From mathcomp.classical Require Import boolp classical_sets functions.
44
From mathcomp.classical Require Import cardinality fsbigop mathcomp_extra.
55
Require Import reals ereal signed topology normedtype sequences esum numfun.
6+
Require Import itv.
67
From HB Require Import structures.
78

89
(******************************************************************************)
@@ -137,6 +138,8 @@ From HB Require Import structures.
137138
(* probability T R == probability measure over the measurableType T with *)
138139
(* value in R : realType *)
139140
(* Measure_isProbability == factor for probability measures *)
141+
(* bernoulli p1 == the p-Bernoulli probability where p1 is a proof that *)
142+
(* p : {nonneg R} is <= 1 *)
140143
(* *)
141144
(* mu.-negligible A == A is mu negligible *)
142145
(* {ae mu, forall x, P x} == P holds almost everywhere for the measure mu, *)
@@ -2826,6 +2829,26 @@ HB.instance Definition _ x :=
28262829

28272830
End pdirac.
28282831

2832+
Section bernoulli.
2833+
Variables (R : realType) (p : {i01 R}).
2834+
2835+
Definition bernoulli : set _ -> \bar R := measure_add
2836+
(mscale (NngNum (itv_ge0 p)) (dirac true))
2837+
(mscale (NngNum (itv_ge0 ((`1-(p%:inum))%:i01))) (dirac false)).
2838+
2839+
HB.instance Definition _ := Measure.on bernoulli.
2840+
2841+
Let bernoulli_setT : bernoulli [set: _] = 1.
2842+
Proof.
2843+
rewrite /bernoulli/= /measure_add/= /msum 2!big_ord_recr/= big_ord0 add0e/=.
2844+
by rewrite /mscale/= !diracT !mule1 -EFinD add_onemK.
2845+
Qed.
2846+
2847+
HB.instance Definition _ :=
2848+
@Measure_isProbability.Build _ _ R bernoulli bernoulli_setT.
2849+
2850+
End bernoulli.
2851+
28292852
Lemma sigma_finite_counting (R : realType) :
28302853
sigma_finite [set: nat] (@counting _ R).
28312854
Proof.

theories/signed.v

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ From mathcomp.classical Require Import mathcomp_extra.
106106
(* --> Canonical instances are also provided according to types, as a *)
107107
(* fallback when no known operator appears in the expression. Look to *)
108108
(* nat_snum below for an example on how to add your favorite type. *)
109+
(* *)
110+
(* onem_NngNum p1 == where p1 is a proof that p : {nonneg R} is <= 1 is the *)
111+
(* the number `1-p with type {nonneg R} *)
109112
(******************************************************************************)
110113

111114
Reserved Notation "{ 'compare' x0 & nz & cond }"
@@ -1182,4 +1185,7 @@ Lemma onemX_NngNum r (r1 : r <= 1) (r0 : 0 <= r) n :
11821185
`1-(r ^+ n) = (NngNum (onemX_ge0 n r0 r1))%:num.
11831186
Proof. by []. Qed.
11841187

1188+
Definition onem_NngNum (p : {nonneg R}) (p1 : (p%:num <= 1)%R) :=
1189+
NngNum (onem_ge0 p1).
1190+
11851191
End onem_signed.

0 commit comments

Comments
 (0)