Skip to content

Commit 37bdaa5

Browse files
authored
Integration of normal random variables (#1726)
* Integration of normal random variables * Add missing integral_density * Move examples/probability to selftest level 1
1 parent a902f2d commit 37bdaa5

File tree

7 files changed

+223
-44
lines changed

7 files changed

+223
-44
lines changed

doc/next-release.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ Incompatibilities
5555
- The left-hand side of `LIST_REL_MAP2` has been changed from `LIST_REL (\a b. R a b) l1 (MAP f l2)` to
5656
`LIST_REL R l1 (MAP f l2)`. We do not expect this to break proof scripts, but document this change here just in case.
5757

58+
- A few theorems (ended with `'`) in `real_sigmaTheory` are renamed to avoid naming conflicts
59+
with `realaxTheory`, or to better reflect their nature (see the table below for details.)
60+
In particular, users are recommended to *not* directly opening `realaxTheory` (an intermediate
61+
theory for constructing real numbers), in which all useful theorems should be also covered by
62+
`realTheory` (under same or different theorem names).
63+
64+
| Old name | New name | Statements |
65+
| --------------- | ------------------ | --------------------------------------------- |
66+
| `REAL_LE_SUP'` | `REAL_LE_SUP2` | `!s a b y. y IN s /\ a <= y /\ (!x. x IN s ==> x <= b) ==> a <= sup s` |
67+
| `REAL_LE_MUL'` | `REAL_LE_MUL_NEG` | `!x y. x <= 0 /\ y <= 0 ==> 0 <= x * y` |
68+
| `REAL_LT_MUL'` | `REAL_LT_MUL_NEG` | `!x y. x < 0 /\ y < 0 ==> 0 < x * y` |
69+
| `REAL_LT_LMUL'` | `REAL_LT_LMUL_NEG` | `!x y z. x < 0 ==> (x * y < x * z <=> z < y)` |
70+
| `REAL_LT_RMUL'` | `REAL_LT_RMUL_NEG` | `!x y z. z < 0 ==> (x * z < y * z <=> y < x)` |
71+
5872
Deprecations
5973
------------
6074

examples/probability/distributionScript.sml

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
(* *)
1111
(* Enriched by Chun Tian (Australian National University, 2024 - 2025) *)
1212
(* ========================================================================= *)
13+
1314
Theory distribution (* was: "normal_rv" *)
1415
Ancestors
1516
combin arithmetic logroot pred_set topology pair cardinal real
@@ -19,8 +20,6 @@ Ancestors
1920
Libs
2021
numLib hurdUtils pred_setLib tautLib jrhUtils realLib
2122

22-
23-
2423
fun METIS ths tm = prove(tm,METIS_TAC ths);
2524
val T_TAC = rpt (Q.PAT_X_ASSUM ‘T’ K_TAC);
2625

@@ -2984,6 +2983,86 @@ Proof
29842983
rw [ext_normal_rv_def, o_DEF, real_normal, ETA_AX]
29852984
QED
29862985

2986+
Theorem integration_of_normal_rv :
2987+
!p X mu sig g.
2988+
prob_space p /\ normal_rv X p mu sig /\ g IN borel_measurable borel ==>
2989+
(integrable p (Normal o g o X) <=>
2990+
integrable lborel (\x. Normal (g x * normal_density mu sig x)) /\
2991+
integral p (Normal o g o X) =
2992+
integral lborel (\x. Normal (g x * normal_density mu sig x)))
2993+
Proof
2994+
rpt GEN_TAC
2995+
>> simp [normal_rv_def, distribution_distr, random_variable_def,
2996+
p_space_def, events_def, prob_def, prob_space_def]
2997+
>> STRIP_TAC
2998+
>> Know ‘Normal o g IN Borel_measurable borel’
2999+
>- (MATCH_MP_TAC IN_MEASURABLE_BOREL_IMP_BOREL' \\
3000+
simp [sigma_algebra_borel])
3001+
>> DISCH_TAC
3002+
(* NOTE: To use “normal_rv X p mu sig” (distr p X s = normal_pmeasure mu sig s),
3003+
we have no choice but to use integral_distr.
3004+
*)
3005+
>> MP_TAC (Q.SPECL [‘p’, ‘borel’, ‘X’, ‘Normal o g’]
3006+
(INST_TYPE [beta |-> “:real”] integral_distr))
3007+
>> simp [sigma_algebra_borel]
3008+
>> STRIP_TAC
3009+
>> NTAC 2 (POP_ASSUM (REWRITE_TAC o wrap o SYM))
3010+
>> qabbrev_tac ‘M = (space borel,subsets borel,distr p X)’
3011+
>> Know ‘measure_space M’
3012+
>- (qunabbrev_tac ‘M’ \\
3013+
MATCH_MP_TAC measure_space_distr >> simp [sigma_algebra_borel])
3014+
>> DISCH_TAC
3015+
(* Now convert M to N, replacing “distr p X” by “normal_pmeasure mu sig” *)
3016+
>> qabbrev_tac ‘N = (space borel,subsets borel,normal_pmeasure mu sig)’
3017+
>> ‘measure_space N’ by PROVE_TAC [normal_measure_space]
3018+
>> ‘measure_space_eq M N’ by rw [measure_space_eq_def, Abbr ‘M’, Abbr ‘N’]
3019+
>> ‘integrable M (Normal o g) <=> integrable N (Normal o g)’
3020+
by simp [integrable_cong_measure']
3021+
>> ‘integral M (Normal o g) = integral N (Normal o g)’
3022+
by simp [integral_cong_measure']
3023+
>> NTAC 2 POP_ORW
3024+
(* cleanups *)
3025+
>> Q.PAT_X_ASSUM ‘measure_space p’ K_TAC
3026+
>> Q.PAT_X_ASSUM ‘measure p (m_space p) = 1’ K_TAC
3027+
>> Q.PAT_X_ASSUM ‘X IN borel_measurable _’ K_TAC
3028+
>> Q.PAT_X_ASSUM ‘!s. s IN subsets borel ==> _’ K_TAC
3029+
>> Q.PAT_X_ASSUM ‘measure_space M’ K_TAC
3030+
>> Q.PAT_X_ASSUM ‘measure_space_eq M N’ K_TAC
3031+
>> qunabbrev_tac ‘M’
3032+
(* NOTE: now converting “normal_pmeasure” to “normal_density” *)
3033+
>> qabbrev_tac ‘f = Normal_density mu sig’
3034+
>> qabbrev_tac ‘M = density lborel f’
3035+
>> Know ‘measure_space M’
3036+
>- (qunabbrev_tac ‘M’ \\
3037+
MATCH_MP_TAC measure_space_density >> simp [lborel_def, space_lborel] \\
3038+
simp [Abbr ‘f’, extreal_of_num_def, normal_density_nonneg,
3039+
IN_MEASURABLE_BOREL_normal_density'])
3040+
>> DISCH_TAC
3041+
>> Know ‘measure_space_eq N M’
3042+
>- (rw [measure_space_eq_def, Abbr ‘M’, Abbr ‘N’, density_def,
3043+
lborel_def, space_lborel, sets_lborel, space_borel] \\
3044+
simp [normal_pmeasure_def, density_measure_def, sets_lborel])
3045+
>> DISCH_TAC
3046+
>> ‘integrable N (Normal o g) <=> integrable M (Normal o g)’
3047+
by simp [integrable_cong_measure']
3048+
>> ‘integral N (Normal o g) = integral M (Normal o g)’
3049+
by simp [integral_cong_measure']
3050+
>> NTAC 2 POP_ORW
3051+
>> Q.PAT_X_ASSUM ‘measure_space M’ K_TAC
3052+
>> Q.PAT_X_ASSUM ‘measure_space N’ K_TAC
3053+
>> Q.PAT_X_ASSUM ‘measure_space_eq N M’ K_TAC
3054+
>> qunabbrevl_tac [‘M’, ‘N’]
3055+
(* applying integral_density *)
3056+
>> MP_TAC (Q.SPECL [‘lborel’, ‘f’, ‘Normal o g’]
3057+
(INST_TYPE [alpha |-> “:real”] integral_density))
3058+
>> simp [lborel_def, IN_MEASURABLE_BOREL_NORMAL, space_lborel]
3059+
>> impl_tac
3060+
>- simp [Abbr ‘f’, extreal_of_num_def, normal_density_nonneg,
3061+
IN_MEASURABLE_BOREL_normal_density']
3062+
>> Rewr'
3063+
>> simp [Abbr ‘f’, extreal_mul_eq]
3064+
QED
3065+
29873066
(* ------------------------------------------------------------------------- *)
29883067
(* Weak convergence and its relation with convergence in distribution *)
29893068
(* ------------------------------------------------------------------------- *)
@@ -3455,7 +3534,7 @@ Proof
34553534
>- (Q.X_GEN_TAC ‘n’ \\
34563535
MATCH_MP_TAC neg_add >> simp [])
34573536
>> Rewr'
3458-
>> Know ‘--Y sp + -Y s0 = -(-Y sp + Y s0)’
3537+
>> Know ‘- -Y sp + -Y s0 = -(-Y sp + Y s0)’
34593538
>- (SYM_TAC >> MATCH_MP_TAC neg_add >> simp [])
34603539
>> simp [] >> DISCH_THEN K_TAC
34613540
>> simp [le_neg]
@@ -3559,7 +3638,7 @@ Proof
35593638
>- (Q.X_GEN_TAC ‘n’ \\
35603639
MATCH_MP_TAC neg_add >> simp [])
35613640
>> Rewr'
3562-
>> Know ‘--Y sp + -Y s0 = -(-Y sp + Y s0)’
3641+
>> Know ‘- -Y sp + -Y s0 = -(-Y sp + Y s0)’
35633642
>- (SYM_TAC \\
35643643
MATCH_MP_TAC neg_add >> simp [])
35653644
>> simp []

src/parallel_builds/core/Holmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ EXDIRS = algebra/aat \
6060
logic/ncfolproofs logic/propositional_logic logic/relevant-logic \
6161
logic/temporal/src \
6262
misc \
63-
padics parity \
63+
padics parity probability \
6464
rings
6565

6666
# selftest directories under src/quotient
@@ -106,7 +106,7 @@ EX2DIRS = AKS algebra algorithms/boyer_moore \
106106
logic/ltl-transformations \
107107
l3-machine-code/decompilers \
108108
probability/legacy miller \
109-
probability vector \
109+
vector \
110110
separationLogic/src separationLogic/src/holfoot simple_complexity
111111

112112
ifdef POLY

src/probability/extrealScript.sml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
(* ------------------------------------------------------------------------- *)
77
(* Updated and further enriched by Chun Tian (2018 - 2025) *)
88
(* ------------------------------------------------------------------------- *)
9+
910
Theory extreal
1011
Ancestors
1112
combin pred_set pair prim_rec arithmetic topology real
@@ -15,7 +16,6 @@ Libs
1516
metisLib res_quanTools jrhUtils numLib tautLib pred_setLib
1617
hurdUtils realLib
1718

18-
1919
fun METIS ths tm = prove(tm, METIS_TAC ths);
2020
val set_ss = std_ss ++ PRED_SET_ss;
2121
val T_TAC = rpt (Q.PAT_X_ASSUM ‘T’ K_TAC);
@@ -5983,7 +5983,7 @@ Proof
59835983
QED
59845984

59855985
Theorem fn_plus_fmul :
5986-
!f c x. (!x. 0 <= c x) ==> fn_plus (\x. c x * f x) x = c x * fn_plus f x
5986+
!f c x. 0 <= c x ==> fn_plus (\x. c x * f x) x = c x * fn_plus f x
59875987
Proof
59885988
rpt GEN_TAC >> DISCH_TAC
59895989
>> simp [fn_plus_def]
@@ -6003,7 +6003,7 @@ Proof
60036003
QED
60046004

60056005
Theorem fn_minus_fmul :
6006-
!f c x. (!x. 0 <= c x) ==> fn_minus (\x. c x * f x) x = c x * fn_minus f x
6006+
!f c x. 0 <= c x ==> fn_minus (\x. c x * f x) x = c x * fn_minus f x
60076007
Proof
60086008
rpt GEN_TAC >> DISCH_TAC
60096009
>> simp [fn_minus_def]

0 commit comments

Comments
 (0)