Skip to content

Commit

Permalink
rebase wrt 0.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
affeldt-aist committed Nov 17, 2023
1 parent d7d02e2 commit e4c675f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 44 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/docker-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ jobs:
strategy:
matrix:
image:
- 'mathcomp/mathcomp:1.15.0-coq-8.14'
- 'mathcomp/mathcomp:1.15.0-coq-8.15'
- 'mathcomp/mathcomp:1.15.0-coq-8.16'
- 'mathcomp/mathcomp:1.16.0-coq-8.14'
- 'mathcomp/mathcomp:1.17.0-coq-8.15'
- 'mathcomp/mathcomp:1.17.0-coq-8.16'
- 'mathcomp/mathcomp:1.17.0-coq-8.17'
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion coq-mathcomp-classical.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the Coq proof-assistant and using the Mathematical Components library."""
build: [make "-C" "classical" "-j%{jobs}%"]
install: [make "-C" "classical" "install"]
depends: [
"coq" { (>= "8.14" & < "8.19~") | (= "dev") }
"coq" { (>= "8.16" & < "8.19~") | (= "dev") }
"coq-mathcomp-ssreflect" { (>= "1.13.0" & < "1.19~") | (= "dev") }
"coq-mathcomp-fingroup"
"coq-mathcomp-algebra"
Expand Down
6 changes: 3 additions & 3 deletions theories/lang_syntax.v
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Proof. done. Qed.
Let mswap_sigma_additive x : semi_sigma_additive (mswap x).
Proof. exact: measure_semi_sigma_additive. Qed.

HB.instance Definition _ x := isMeasure.Build _ R _
HB.instance Definition _ x := isMeasure.Build _ _ R
(mswap x) (mswap0 x) (mswap_ge0 x) (@mswap_sigma_additive x).

Definition mkswap : _ -> {measure set Z -> \bar R} :=
Expand Down Expand Up @@ -185,7 +185,7 @@ Let T0 z : (T' z) set0 = 0. Proof. by []. Qed.
Let T_ge0 z x : 0 <= (T' z) x. Proof. by []. Qed.
Let T_semi_sigma_additive z : semi_sigma_additive (T' z).
Proof. exact: measure_semi_sigma_additive. Qed.
HB.instance Definition _ z := @isMeasure.Build _ R X (T' z) (T0 z) (T_ge0 z)
HB.instance Definition _ z := @isMeasure.Build _ X R (T' z) (T0 z) (T_ge0 z)
(@T_semi_sigma_additive z).

Let sfinT z : sfinite_measure (T' z). Proof. exact: sfinite_kernel_measure. Qed.
Expand All @@ -197,7 +197,7 @@ Let U0 z : (U' z) set0 = 0. Proof. by []. Qed.
Let U_ge0 z x : 0 <= (U' z) x. Proof. by []. Qed.
Let U_semi_sigma_additive z : semi_sigma_additive (U' z).
Proof. exact: measure_semi_sigma_additive. Qed.
HB.instance Definition _ z := @isMeasure.Build _ R Y (U' z) (U0 z) (U_ge0 z)
HB.instance Definition _ z := @isMeasure.Build _ Y R (U' z) (U0 z) (U_ge0 z)
(@U_semi_sigma_additive z).

Let sfinU z : sfinite_measure (U' z). Proof. exact: sfinite_kernel_measure. Qed.
Expand Down
51 changes: 25 additions & 26 deletions theories/lang_syntax_examples.v
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Lemma letin'_sample_bernoulli d d' (T : measurableType d)
Proof.
rewrite letin'E/=.
rewrite ge0_integral_measure_sum// 2!big_ord_recl/= big_ord0 adde0/=.
by rewrite !ge0_integral_mscale//= !integral_dirac//= indicT 2!mul1e.
by rewrite !ge0_integral_mscale//= !integral_dirac//= !diracT 2!mul1e.
Qed.

Section letin'_return.
Expand All @@ -81,7 +81,7 @@ Lemma letin'_retk (f : X -> Y) (mf : measurable_fun setT f)
(k : R.-sfker Y * X ~> Z) x U :
measurable U -> letin' (ret mf) k x U = k (f x, x) U.
Proof.
move=> mU; rewrite letin'E retE integral_dirac ?indicT ?mul1e//.
move=> mU; rewrite letin'E retE integral_dirac ?diracT ?mul1e//.
exact: (measurableT_comp (measurable_kernel k _ mU)).
Qed.

Expand Down Expand Up @@ -218,9 +218,9 @@ Proof.
rewrite !execP_letin !execP_sample !execD_bernoulli execP_return /=.
rewrite execD_pair !exp_var'E (execD_var_erefl "x") (execD_var_erefl "y") /=.
rewrite letin'E integral_measure_add//= !ge0_integral_mscale//= /onem.
rewrite !integral_dirac//= !indicE !in_setT/= !mul1e.
rewrite !integral_dirac//= !diracT !mul1e.
rewrite !letin'E !integral_measure_add//= !ge0_integral_mscale//= /onem.
by rewrite !integral_dirac//= !indicE !in_setT/= !mul1e !diracE.
by rewrite !integral_dirac//= !diracT !mul1e.
Qed.

Lemma exec_sample_pair0_TandT :
Expand Down Expand Up @@ -266,9 +266,9 @@ Proof.
rewrite !execP_letin !execP_sample !execD_bernoulli execP_return /=.
rewrite (@execD_bin _ _ binop_and) !exp_var'E (execD_var_erefl "x") (execD_var_erefl "y") /=.
rewrite letin'E integral_measure_add//= !ge0_integral_mscale//= /onem.
rewrite !integral_dirac//= !indicE !in_setT/= !mul1e.
rewrite !integral_dirac//= !diracT !mul1e.
rewrite !letin'E !integral_measure_add//= !ge0_integral_mscale//= /onem.
rewrite !integral_dirac//= !indicE !in_setT/= !mul1e !diracE.
rewrite !integral_dirac//= !diracT !mul1e.
rewrite muleDr// -addeA; congr (_ + _)%E.
by rewrite !muleA; congr (_%:E); congr (_ * _); field.
rewrite -muleDl// !muleA -muleDl//.
Expand All @@ -289,11 +289,11 @@ rewrite !execP_letin !execP_sample !execD_bernoulli execP_return /=.
rewrite !(@execD_bin _ _ binop_and) !exp_var'E.
rewrite (execD_var_erefl "x") (execD_var_erefl "y") (execD_var_erefl "z") /=.
rewrite letin'E integral_measure_add//= !ge0_integral_mscale//= /onem.
rewrite !integral_dirac//= !indicE !in_setT/= !mul1e.
rewrite !integral_dirac//= !diracT !mul1e.
rewrite !letin'E !integral_measure_add//= !ge0_integral_mscale//= /onem.
rewrite !integral_dirac//= !indicE !in_setT/= !mul1e.
rewrite !integral_dirac//= !diracT !mul1e.
rewrite !letin'E !integral_measure_add//= !ge0_integral_mscale//= /onem.
rewrite !integral_dirac//= !indicE !in_setT/= !mul1e !diracE.
rewrite !integral_dirac//= !diracT !mul1e.
rewrite !muleDr// -!addeA.
by congr (_ + _)%E; rewrite ?addeA !muleA -?muleDl//;
congr (_ * _)%E; congr (_%:E); field.
Expand Down Expand Up @@ -336,24 +336,23 @@ rewrite !integral_measure_add //=; last by move=> b _; rewrite integral_ge0.
rewrite !ge0_integral_mscale //=; last 2 first.
by move=> b _; rewrite integral_ge0.
by move=> b _; rewrite integral_ge0.
rewrite !integral_dirac// !indicE !in_setT !mul1e.
rewrite !integral_dirac// !diracT !mul1e.
rewrite iteE/= !ge0_integral_mscale//=.
rewrite ger0_norm//.
rewrite !integral_indic//= !iteE/= /mscale/=.
rewrite setTI diracE !in_setT !mule1.
rewrite setTI !diracT !mule1.
rewrite ger0_norm//.
rewrite -EFinD/= eqe ifF; last first.
by apply/negbTE/negP => /orP[/eqP|//]; rewrite /onem; lra.
rewrite !letin'E/= !iteE/=.
rewrite !ge0_integral_mscale//=.
rewrite ger0_norm//.
rewrite !integral_dirac//= !indicE !in_setT /= !mul1e ger0_norm//.
rewrite !integral_dirac//= !diracT !mul1e ger0_norm//.
rewrite exp_var'E (execD_var_erefl "x")/=.
rewrite /bernoulli/= measure_addE/= /mscale/= !mul1r.
rewrite muleDl//; congr (_ + _)%E;
rewrite -!EFinM;
congr (_%:E);
by rewrite indicE /onem; case: (_ \in _); field.
by rewrite muleDl//; congr (_ + _)%E;
rewrite -!EFinM; congr (_%:E);
rewrite !indicT !indicE /onem /=; case: (_ \in _); field.
Qed.

Definition bernoulli12_score := [Normalize
Expand All @@ -379,25 +378,25 @@ rewrite !integral_measure_add //=; last by move=> b _; rewrite integral_ge0.
rewrite !ge0_integral_mscale //=; last 2 first.
by move=> b _; rewrite integral_ge0.
by move=> b _; rewrite integral_ge0.
rewrite !integral_dirac// !indicE !in_setT !mul1e.
rewrite !integral_dirac// !diracT !mul1e.
rewrite iteE/= !ge0_integral_mscale//=.
rewrite ger0_norm//.
rewrite !integral_indic//= !iteE/= /mscale/=.
rewrite setTI diracE !in_setT !mule1.
rewrite setTI !diracT !mule1.
rewrite ger0_norm//.
rewrite -EFinD/= eqe ifF; last first.
apply/negbTE/negP => /orP[/eqP|//].
by rewrite /onem; lra.
rewrite !letin'E/= !iteE/=.
rewrite !ge0_integral_mscale//=.
rewrite ger0_norm//.
rewrite !integral_dirac//= !indicE !in_setT /= !mul1e ger0_norm//.
rewrite !integral_dirac//= !diracT !mul1e ger0_norm//.
rewrite exp_var'E (execD_var_erefl "x")/=.
rewrite /bernoulli/= measure_addE/= /mscale/= !mul1r.
rewrite muleDl//; congr (_ + _)%E;
rewrite -!EFinM;
congr (_%:E);
by rewrite indicE /onem; case: (_ \in _); field.
by rewrite !indicT !indicE /onem /=; case: (_ \in _); field.
Qed.

(* https://dl.acm.org/doi/pdf/10.1145/2933575.2935313 (Sect. 4) *)
Expand Down Expand Up @@ -428,24 +427,24 @@ rewrite !integral_measure_add //=; last by move=> b _; rewrite integral_ge0.
rewrite !ge0_integral_mscale //=; last 2 first.
by move=> b _; exact: integral_ge0.
by move=> b _; exact: integral_ge0.
rewrite !integral_dirac// !indicE !in_setT !mul1e.
rewrite !integral_dirac// !diracT !mul1e.
rewrite iteE/= !ge0_integral_mscale//=.
rewrite ger0_norm//.
rewrite !integral_indic//= !iteE/= /mscale/=.
rewrite setTI diracE !in_setT !mule1.
rewrite !integral_cst//= !diracT !(mule1,mul1e).
rewrite !iteE/= /mscale/= !diracT !mule1.
rewrite ger0_norm//.
rewrite -EFinD/= eqe ifF; last first.
apply/negbTE/negP => /orP[/eqP|//].
by rewrite /onem; lra.
rewrite !letin'E/= !iteE/=.
rewrite !ge0_integral_mscale//=.
rewrite ger0_norm//.
rewrite !integral_dirac//= !indicE !in_setT /= !mul1e ger0_norm//.
rewrite !integral_dirac//= !diracT !mul1e ger0_norm//.
rewrite /bernoulli/= measure_addE/= /mscale/= !mul1r.
rewrite muleDl//; congr (_ + _)%E;
rewrite -!EFinM;
congr (_%:E);
by rewrite indicE /onem; case: (_ \in _); field.
by rewrite !indicT !indicE /onem /=; case: (_ \in _); field.
Qed.

End bernoulli_examples.
Expand Down Expand Up @@ -473,7 +472,7 @@ Proof.
apply/eq_sfkernel => x U.
rewrite letin'E/= /sample; unlock.
rewrite integral_measure_add//= ge0_integral_mscale//= ge0_integral_mscale//=.
rewrite integral_dirac//= integral_dirac//= !indicT/= !mul1e.
rewrite !integral_dirac//= !diracT/= !mul1e.
by rewrite /mscale/= iteE//= iteE//= fail'E mule0 adde0 ger0_norm.
Qed.

Expand Down
18 changes: 9 additions & 9 deletions theories/prob_lang.v
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Lemma integral_bernoulli {R : realType}
Proof.
move=> f0.
rewrite ge0_integral_measure_sum// 2!big_ord_recl/= big_ord0 adde0/=.
by rewrite !ge0_integral_mscale//= !integral_dirac//= indicT 2!mul1e.
by rewrite !ge0_integral_mscale//= !integral_dirac//= !diracT !mul1e.
Qed.

Section uniform_probability.
Expand All @@ -131,7 +131,7 @@ HB.instance Definition _ := Measure.on uniform_probability.
Let uniform_probability_setT : uniform_probability [set: _] = 1.
Proof.
rewrite /uniform_probability /mscale/= /mrestr/=.
rewrite setTI lebesgue_measure_itv hlength_itv/= lte_fin.
rewrite setTI lebesgue_measure_itv/= lte_fin.
by rewrite -subr_gt0 ab0 -EFinD -EFinM mulVf// gt_eqF// subr_gt0.
Qed.

Expand Down Expand Up @@ -528,7 +528,7 @@ Proof.
apply/eq_measure/funext => U.
rewrite /ite; unlock => /=.
rewrite /kcomp/= integral_dirac//=.
rewrite indicT mul1e.
rewrite diracT mul1e.
rewrite -/(measure_add (ITE.kiteT k1 (x, f x)) (ITE.kiteF k2 (x, f x))).
rewrite measure_addE.
rewrite /ITE.kiteT /ITE.kiteF/=.
Expand Down Expand Up @@ -588,7 +588,7 @@ Lemma letin_retk
x U : measurable U ->
letin (ret mf) k x U = k (x, f x) U.
Proof.
move=> mU; rewrite letinE retE integral_dirac ?indicT ?mul1e//.
move=> mU; rewrite letinE retE integral_dirac ?diracT ?mul1e//.
exact: (measurableT_comp (measurable_kernel k _ mU)).
Qed.

Expand Down Expand Up @@ -893,7 +893,7 @@ Let kcomp_scoreE d1 d2 (T1 : measurableType d1) (T2 : measurableType d2)
(score mf \; g) r U = `|f r|%:E * g (r, tt) U.
Proof.
rewrite /= /kcomp /kscore /= ge0_integral_mscale//=.
by rewrite integral_dirac// indicT mul1e.
by rewrite integral_dirac// diracT mul1e.
Qed.

Lemma scoreE d' (T' : measurableType d') (x : T * T') (U : set T') (f : R -> R)
Expand Down Expand Up @@ -926,7 +926,7 @@ Proof.
apply/eq_sfkernel => x U.
rewrite letinE/= /sample; unlock.
rewrite integral_measure_add//= ge0_integral_mscale//= ge0_integral_mscale//=.
rewrite integral_dirac//= integral_dirac//= !indicT/= !mul1e.
rewrite integral_dirac//= integral_dirac//= !diracT/= !mul1e.
by rewrite /mscale/= iteE//= iteE//= failE mule0 adde0 ger0_norm.
Qed.

Expand Down Expand Up @@ -1004,7 +1004,7 @@ Let T0 z : (T z) set0 = 0. Proof. by []. Qed.
Let T_ge0 z x : 0 <= (T z) x. Proof. by []. Qed.
Let T_semi_sigma_additive z : semi_sigma_additive (T z).
Proof. exact: measure_semi_sigma_additive. Qed.
HB.instance Definition _ z := @isMeasure.Build _ R X (T z) (T0 z) (T_ge0 z)
HB.instance Definition _ z := @isMeasure.Build _ X R (T z) (T0 z) (T_ge0 z)
(@T_semi_sigma_additive z).

Let sfinT z : sfinite_measure (T z). Proof. exact: sfinite_kernel_measure. Qed.
Expand All @@ -1016,7 +1016,7 @@ Let U0 z : (U z) set0 = 0. Proof. by []. Qed.
Let U_ge0 z x : 0 <= (U z) x. Proof. by []. Qed.
Let U_semi_sigma_additive z : semi_sigma_additive (U z).
Proof. exact: measure_semi_sigma_additive. Qed.
HB.instance Definition _ z := @isMeasure.Build _ R Y (U z) (U0 z) (U_ge0 z)
HB.instance Definition _ z := @isMeasure.Build _ Y R (U z) (U0 z) (U_ge0 z)
(@U_semi_sigma_additive z).

Let sfinU z : sfinite_measure (U z). Proof. exact: sfinite_kernel_measure. Qed.
Expand Down Expand Up @@ -1145,7 +1145,7 @@ Lemma letin_sample_bernoulli d d' (T : measurableType d)
Proof.
rewrite letinE/=.
rewrite ge0_integral_measure_sum// 2!big_ord_recl/= big_ord0 adde0/=.
by rewrite !ge0_integral_mscale//= !integral_dirac//= indicT 2!mul1e.
by rewrite !ge0_integral_mscale//= !integral_dirac//= !diracT 2!mul1e.
Qed.

Section sample_and_return.
Expand Down
2 changes: 1 addition & 1 deletion theories/prob_lang_wip.v
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ transitivity (\int[@mgauss01 R]_(y in U) (f1 y)%:E).
apply: eq_integral => //= r.
rewrite letinE/= ge0_integral_mscale//= ger0_norm//; last first.
by rewrite invr_ge0// gauss_density_ge0.
by rewrite integral_dirac// indicT mul1e diracE indicE.
by rewrite integral_dirac// diracT mul1e diracE indicE.
rewrite integral_mgauss01//.
transitivity (\int[lebesgue_measure]_(x in U) (\1_U x)%:E).
apply: eq_integral => /= y yU.
Expand Down

0 comments on commit e4c675f

Please sign in to comment.