@@ -77,6 +77,19 @@ From mathcomp Require Import lebesgue_measure numfun realfun function_spaces.
7777(* nicely_shrinking x E == the sequence of sets E is nicely shrinking to x *)
7878(* ```` *)
7979(* *)
80+ (* About the use of simple functions: *)
81+ (* Because of a limitation of HB <= 1.8.0, we need some care to be able to *)
82+ (* use simple functions. *)
83+ (* The structure SimpleFun (resp. NonNegSimpleFun) is located inside the *)
84+ (* module HBSimple (resp. HBNNSimple). *)
85+ (* As a consequence, we need to import HBSimple (resp. HBNNSimple) to use the *)
86+ (* coercion from simple functions (resp. non-negative simple functions) to *)
87+ (* Coq functions. *)
88+ (* Also, assume that f (e.g., cst, indic) is equipped with the structure of *)
89+ (* MeasurableFun. For f to be equipped with the structure of SimpleFun *)
90+ (* (resp. NonNegSimpleFun), one need locallu to import HBSimple (resp. *)
91+ (* HBNNSimple) and to instantiate FiniteImage (resp. NonNegFun) locally. *)
92+ (* *)
8093(***************************************************************************** *)
8194
8295Set Implicit Arguments .
@@ -204,11 +217,8 @@ Proof. by split=> [->//|fg]; apply/val_inj/funext. Qed.
204217
205218HB.instance Definition _ := [Choice of {mfun aT >-> rT} by <:].
206219
207- Lemma cst_mfun_subproof x : @measurable_fun d _ aT rT [set: aT] (cst x).
208- Proof . by []. Qed .
209-
210220HB.instance Definition _ x := isMeasurableFun.Build d _ aT rT (cst x)
211- (@cst_mfun_subproof x).
221+ (@measurable_cst _ _ aT rT setT x).
212222
213223End mfun.
214224
@@ -245,8 +255,8 @@ split=> [|f g|f g]; rewrite !inE/=.
245255- exact: measurable_funB.
246256- exact: measurable_funM.
247257Qed .
248- HB.instance Definition _ := GRing.isSubringClosed.Build _ (@mfun d default_measure_display aT rT)
249- mfun_subring_closed.
258+ HB.instance Definition _ := GRing.isSubringClosed.Build _
259+ (@mfun d default_measure_display aT rT) mfun_subring_closed.
250260HB.instance Definition _ := [SubChoice_isSubComRing of {mfun aT >-> rT} by <:].
251261
252262Implicit Types (f g : {mfun aT >-> rT}).
@@ -272,22 +282,13 @@ HB.instance Definition _ f g := MeasurableFun.copy (f \- g) (f - g).
272282HB.instance Definition _ f g := MeasurableFun.copy (f \* g) (f * g).
273283
274284Definition mindic (D : set aT) of measurable D : aT -> rT := \1_D.
285+
275286Lemma mindicE (D : set aT) (mD : measurable D) :
276287 mindic mD = (fun x => (x \in D)%:R).
277288Proof . by rewrite /mindic funeqE => t; rewrite indicE. Qed .
278- HB.instance Definition _ (D : set aT) (mD : measurable D) :
279- @FImFun aT rT (mindic mD) := FImFun.on (mindic mD).
280- Lemma indic_mfun_subproof (D : set aT) (mD : measurable D) :
281- @isMeasurableFun d _ aT rT (mindic mD).
282- Proof .
283- split=> mA /= B mB; rewrite preimage_indic.
284- case: ifPn => B1; case: ifPn => B0 //.
285- - by rewrite setIT.
286- - exact: measurableI.
287- - by apply: measurableI => //; apply: measurableC.
288- - by rewrite setI0.
289- Qed .
290- HB.instance Definition _ D mD := @indic_mfun_subproof D mD.
289+
290+ HB.instance Definition _ D mD := @isMeasurableFun.Build _ _ aT rT (mindic mD)
291+ (@measurable_fun_indic _ aT rT setT D mD).
291292
292293Definition indic_mfun (D : set aT) (mD : measurable D) :=
293294 [the {mfun aT >-> rT} of mindic mD].
@@ -297,7 +298,9 @@ Definition scale_mfun k f := [the {mfun aT >-> rT} of k \o* f].
297298
298299Lemma max_mfun_subproof f g : @isMeasurableFun d _ aT rT (f \max g).
299300Proof . by split; apply: measurable_maxr. Qed .
301+
300302HB.instance Definition _ f g := max_mfun_subproof f g.
303+
301304Definition max_mfun f g := [the {mfun aT >-> _} of f \max g].
302305
303306End ring.
@@ -362,11 +365,8 @@ Proof. by split=> [->//|fg]; apply/val_inj/funext. Qed.
362365
363366HB.instance Definition _ := [Choice of {sfun aT >-> rT} by <:].
364367
365- (* TODO: BUG: HB *)
366- (* HB.instance Definition _ (x : rT) := @cst_mfun_subproof aT rT x. *)
367-
368- (* NB: duplicate from cardinality.v *)
369- HB.instance Definition _ x := @cst_fimfun_subproof aT rT x.
368+ (* NB: already instantiated in cardinality.v *)
369+ HB.instance Definition _ x : @FImFun aT rT (cst x) := FImFun.on (cst x).
370370
371371Definition cst_sfun x := [the {sfun aT >-> rT} of cst x].
372372
@@ -425,7 +425,7 @@ HB.instance Definition _ f g := MeasurableFun.copy (f \- g) (f - g).
425425HB.instance Definition _ f g := MeasurableFun.copy (f \* g) (f * g).
426426
427427Import HBSimple.
428- (* NB: duplicate from lebesgue_integral.v *)
428+ (* NB: already instantiated in lebesgue_integral.v *)
429429HB.instance Definition _ (D : set aT) (mD : measurable D) :
430430 @FImFun aT rT (mindic _ mD) := FImFun.on (mindic _ mD).
431431
@@ -495,23 +495,23 @@ Context d (T : measurableType d) (R : realType).
495495
496496Import HBNNSimple.
497497
498- Lemma cst_nnfun_subproof (x : {nonneg R}) : @isNonNegFun T R (cst x%:num).
499- Proof . by split=> /=. Qed .
500- HB.instance Definition _ x := @cst_nnfun_subproof x.
501-
502- HB.instance Definition _ x := isMeasurableFun.Build d _ T R (cst x)
503- (@cst_mfun_subproof _ _ _ _ x).
498+ Lemma cst_nnfun_subproof (x : {nonneg R}) : forall t : T, 0 <= cst x%:num t.
499+ Proof . by move=> /=. Qed .
500+ HB.instance Definition _ x := @isNonNegFun.Build T R (cst x%:num)
501+ (cst_nnfun_subproof x).
504502
505- (* NB: duplicate from cardinality.v *)
506- HB.instance Definition _ x := @cst_fimfun_subproof T R x .
503+ (* NB: already instantiated in cardinality.v *)
504+ HB.instance Definition _ x : @FImFun T R (cst x) := FImFun.on (cst x) .
507505
508506Definition cst_nnsfun (r : {nonneg R}) := [the {nnsfun T >-> R} of cst r%:num].
509507
510508Definition nnsfun0 : {nnsfun T >-> R} := cst_nnsfun 0%R%:nng.
511509
512- Lemma indic_nnfun_subproof (D : set T) : @isNonNegFun T R (\1_D).
513- Proof . by split=> //=; rewrite /indic. Qed .
514- HB.instance Definition _ D := @indic_nnfun_subproof D.
510+ Lemma indic_nnfun_subproof (D : set T) : forall x, 0 <= (\1_D) x :> R.
511+ Proof . by []. Qed .
512+
513+ HB.instance Definition _ D := @isNonNegFun.Build T R \1_D
514+ (indic_nnfun_subproof D).
515515
516516HB.instance Definition _ D (mD : measurable D) :
517517 @NonNegFun T R (mindic R mD) := NonNegFun.on (mindic R mD).
824824
825825End le_sintegral.
826826
827- Section tmp .
827+ Section is_cvg_sintegral .
828828Import HBNNSimple.
829829
830830Lemma is_cvg_sintegral d (T : measurableType d) (R : realType)
@@ -835,13 +835,13 @@ move=> nd_f; apply/cvg_ex; eexists; apply/ereal_nondecreasing_cvgn => a b ab.
835835by apply: le_sintegral => // => x; exact/nd_f.
836836Qed .
837837
838- End tmp .
838+ End is_cvg_sintegral .
839839
840840Definition proj_nnsfun d (T : measurableType d) (R : realType)
841841 (f : {nnsfun T >-> R}) (A : set T) (mA : measurable A) :=
842842 mul_nnsfun f (indic_nnsfun R mA).
843843
844- Section tmp .
844+ Section mrestrict .
845845Import HBNNSimple.
846846
847847Definition mrestrict d (T : measurableType d) (R : realType) (f : {nnsfun T >-> R})
@@ -851,7 +851,7 @@ apply/funext => x /=; rewrite /patch mindicE.
851851by case: ifP; rewrite (mulr0, mulr1).
852852Qed .
853853
854- End tmp .
854+ End mrestrict .
855855
856856Definition scale_nnsfun d (T : measurableType d) (R : realType)
857857 (f : {nnsfun T >-> R}) (k : R) (k0 : 0 <= k) :=
@@ -1749,10 +1749,13 @@ Context d (T : measurableType d) (R : realType) (f : T -> \bar R).
17491749Variables (D : set T) (mD : measurable D) (mf : measurable_fun D f).
17501750
17511751Import HBSimple.
1752- (* duplicate *)
1753- HB.instance Definition _ x := @cst_fimfun_subproof T R x.
1754- HB.instance Definition _ x := isMeasurableFun.Build d _ T R (cst x)
1755- (@cst_mfun_subproof _ _ _ _ x).
1752+ (* NB: already instantiated in cardinality.v *)
1753+ HB.instance Definition _ x : @FImFun T R (cst x) := FImFun.on (cst x).
1754+
1755+ Import HBNNSimple.
1756+ (* NB: already instantiated in lebesgue_integral.v *)
1757+ HB.instance Definition _ x : @NonNegFun T R (cst x%:num) :=
1758+ NonNegFun.on (cst x%:num).
17561759
17571760Lemma approximation_sfun :
17581761 exists g : {sfun T >-> R}^nat, (forall x, D x -> EFin \o g ^~ x @ \oo --> f x).
@@ -1761,14 +1764,6 @@ have [fp_ [fp_nd fp_cvg]] :=
17611764 approximation mD (measurable_funepos mf) (fun=> ltac:(by [])).
17621765have [fn_ [fn_nd fn_cvg]] :=
17631766 approximation mD (measurable_funeneg mf) (fun=> ltac:(by [])).
1764-
1765- Import HBNNSimple.
1766- (* duplicate *)
1767- HB.instance Definition _ x := @cst_fimfun_subproof T R x.
1768- HB.instance Definition _ x := isMeasurableFun.Build d _ T R (cst x)
1769- (@cst_mfun_subproof _ _ _ _ x).
1770- HB.instance Definition _ x := @cst_nnfun_subproof _ T R x.
1771-
17721767exists (fun n => [the {sfun T >-> R} of fp_ n \+ cst (-1) \* fn_ n]) => x /=.
17731768rewrite [X in X @ \oo --> _](_ : _ =
17741769 EFin \o fp_^~ x \+ (-%E \o EFin \o fn_^~ x))%E; last first.
@@ -2790,8 +2785,7 @@ Qed.
27902785
27912786End integral_measure_sum_nnsfun.
27922787
2793- Section tmp.
2794-
2788+ Section integral_measure_add_nnsfun.
27952789Import HBNNSimple.
27962790
27972791Lemma integral_measure_add_nnsfun d (T : measurableType d) (R : realType)
@@ -2804,7 +2798,7 @@ rewrite /measureD integral_measure_sum_nnsfun// 2!big_ord_recl/= big_ord0.
28042798by rewrite adde0.
28052799Qed .
28062800
2807- End tmp .
2801+ End integral_measure_add_nnsfun .
28082802
28092803Section integral_mfun_measure_sum.
28102804Local Open Scope ereal_scope.
@@ -3824,20 +3818,6 @@ exists N; split => // t /= /not_implyP[_].
38243818by rewrite patchE; case: ifPn => //; rewrite inE.
38253819Qed .
38263820
3827- Import HBNNSimple.
3828-
3829- Lemma funID (N : set T) (mN : measurable N) (f : T -> \bar R) :
3830- let oneCN := [the {nnsfun T >-> R} of mindic R (measurableC mN)] in
3831- let oneN := [the {nnsfun T >-> R} of mindic R mN] in
3832- f = (fun x => f x * (oneCN x)%:E) \+ (fun x => f x * (oneN x)%:E).
3833- Proof .
3834- move=> oneCN oneN; rewrite funeqE => x.
3835- rewrite /oneCN /oneN/= /mindic !indicE.
3836- have [xN|xN] := boolP (x \in N).
3837- by rewrite mule1 in_setC xN mule0 add0e.
3838- by rewrite in_setC xN mule0 adde0 mule1.
3839- Qed .
3840-
38413821Lemma negligible_integrable (D N : set T) (f : T -> \bar R) :
38423822 measurable N -> measurable D -> measurable_fun D f ->
38433823 mu N = 0 -> mu.-integrable D f <-> mu.-integrable (D `\` N) f.
@@ -3860,7 +3840,7 @@ have h1 : mu.-integrable D f <-> mu.-integrable D (f \_ ~` N).
38603840 rewrite -integral_mkcondr; case: intf => _; apply: le_lt_trans.
38613841 by apply: ge0_subset_integral => //=; [exact:measurableI|
38623842 exact:measurableT_comp].
3863- apply/integrableP; split => //; rewrite (ereal. funID N f).
3843+ apply/integrableP; split => //; rewrite (funID N f).
38643844 have ? : measurable_fun D (f \_ ~` N).
38653845 by apply/measurable_restrict => //; exact: measurable_funS mf.
38663846 have ? : measurable_fun D (f \_ N).
@@ -3898,7 +3878,7 @@ Lemma ge0_negligible_integral (D N : set T) (f : T -> \bar R) :
38983878 mu N = 0 -> \int[mu]_(x in D) f x = \int[mu]_(x in D `\` N) f x.
38993879Proof .
39003880move=> mN mD mf f0 muN0.
3901- rewrite {1}(ereal. funID N f) ge0_integralD//; last 4 first.
3881+ rewrite {1}(funID N f) ge0_integralD//; last 4 first.
39023882 - by move=> x Dx; rewrite patchE; case: ifPn => // _; exact: f0.
39033883 - apply/measurable_restrict => //; first exact/measurableC.
39043884 exact: measurable_funS mf.
0 commit comments