Skip to content

Commit 4e89861

Browse files
committed
Connection between esum and lesbegue_integral
1 parent 68b3cfc commit 4e89861

2 files changed

Lines changed: 156 additions & 0 deletions

File tree

_CoqProject

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,7 @@ theories/all_analysis.v
154154
theories/showcase/summability.v
155155
theories/showcase/pnt.v
156156

157+
theories/esum_counting.v
158+
157159
analysis_stdlib/Rstruct_topology.v
158160
analysis_stdlib/showcase/uniform_bigO.v

theories/esum_counting.v

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
From HB Require Import structures.
2+
From mathcomp Require Import boot order algebra.
3+
From mathcomp.classical Require Import boolp classical_sets mathcomp_extra functions.
4+
From mathcomp Require Import xfinmap constructive_ereal reals discrete.
5+
From mathcomp Require Import realseq realsum.
6+
From mathcomp Require Import esum sequences normedtype ereal cardinality fsbigop.
7+
From mathcomp Require Import measure lebesgue_integral.
8+
9+
Set Implicit Arguments.
10+
Unset Strict Implicit.
11+
Unset Printing Implicit Defensive.
12+
Unset SsrOldRewriteGoalsOrder. (* remove this line when requiring MathComp >= 2.6 *)
13+
14+
Import Order.TTheory GRing.Theory Num.Theory.
15+
16+
Local Open Scope ring_scope.
17+
18+
(* -------------------------------------------------------------------- *)
19+
Local Notation simpm := Monoid.simpm.
20+
21+
Local Open Scope classical_set_scope.
22+
23+
(* -------------------------------------------------------------------- *)
24+
25+
Definition discrete_measurable_space (T : choiceType) : Type := T.
26+
27+
HB.instance Definition _ (T : choiceType) :=
28+
Choice.on (discrete_measurable_space T).
29+
30+
HB.instance Definition _ (T : choiceType) := @isMeasurable.Build
31+
default_measure_display
32+
(discrete_measurable_space T) discrete_measurable discrete_measurable0
33+
discrete_measurableC discrete_measurableU.
34+
35+
36+
Section Counting.
37+
Context (R : realType) (T : choiceType).
38+
39+
Lemma esum_bigcup_set (T1 T2 : choiceType) (K : set T1) (J : T1 -> set T2)
40+
(a : T2 -> \bar R) :
41+
trivIset setT J -> (forall x, (0 <= a x)%E) ->
42+
(\esum_(i in \bigcup_(k in K) J k) a i =
43+
\esum_(k in K) \esum_(j in J k) a j)%E.
44+
Proof.
45+
move=> tJ a0; rewrite esum_esum//; apply: reindex_esum => //; split.
46+
- by move=> [/= i j] [Ki Jij]; exists i.
47+
- move=> [/= i1 j1] [/= i2 j2] /set_mem/= [Ki1 Jij1] /set_mem/= [Ki2 Jij2] /= j12.
48+
have iE : i1 = i2.
49+
by apply: (tJ i1 i2) => //; exists j1; split=> //; rewrite j12.
50+
by rewrite iE j12.
51+
- by move=> j [i Ki Jij]/=; exists (i, j).
52+
Qed.
53+
54+
Lemma counting_esum_cst (c : R) (A : set T) : (0 <= c)%R ->
55+
(c%:E * @counting (discrete_measurable_space T) R A
56+
= \esum_(x in A) c%:E)%E.
57+
Proof.
58+
move=> c0.
59+
have [-> | c_neq] := eqVneq c 0%R.
60+
by rewrite mul0e; apply/esym/esum1.
61+
have c_pos : (0 < c)%R by rewrite lt_def c_neq.
62+
have [finA|infA] := pselect (finite_set A).
63+
+ rewrite /counting (asboolT finA).
64+
rewrite esum_fset// fsbig_finite//=.
65+
rewrite sumEFin big_const_seq count_predT iter_addr addr0.
66+
rewrite -EFinM; congr (_%:E).
67+
rewrite mulr_natr; congr (c *+ _).
68+
apply: (elimT (@fcard_eq (discrete_measurable_space T) T A A finA finA)).
69+
exact: card_eqxx.
70+
+ rewrite /counting asboolF//=.
71+
rewrite mulry gtr0_sg// mul1e.
72+
apply/esym/eqyP => r r0.
73+
have [B BA Brc] := infinite_set_fset (Num.Def.truncn (c^-1 * r)).+1 infA.
74+
apply: esum_ge => // ; exists [set` B].
75+
by split=> //; apply/subsetP => x; rewrite inE => /BA.
76+
rewrite fsbig_finite//= set_fsetK sumEFin big_const_seq count_predT.
77+
rewrite iter_addr addr0 -mulr_natr lee_fin -ler_pdivrMl//.
78+
apply: (@le_trans _ _ (((Num.Def.truncn (c^-1 * r)).+1)%:R)).
79+
exact: ltW (truncnS_gt _).
80+
rewrite ler_nat.
81+
exact: Brc.
82+
Qed.
83+
84+
Import HBNNSimple.
85+
86+
Lemma sintegral_counting_esum
87+
(h : {nnsfun (discrete_measurable_space T) >-> R}) :
88+
(sintegral (@counting (discrete_measurable_space T) R) h
89+
= \esum_(x in [set: T]) (h x)%:E)%E.
90+
Proof.
91+
rewrite sintegralE //=.
92+
transitivity (\sum_(c \in range h)
93+
\esum_(x in (h @^-1` [set c] : set T)) (h x)%:E)%E.
94+
+ apply: eq_fsbigr => c /set_mem/= -[x _ <-{c}].
95+
rewrite counting_esum_cst//.
96+
by apply: (eq_esum _ (fun=> (h x)%:E)) => x0 ->.
97+
+ rewrite -esum_fset//.
98+
+ by move=> ? _; apply: esum_ge0 => ? _; rewrite lee_fin.
99+
rewrite -esum_bigcup_set.
100+
+ exact: trivIset_preimage1.
101+
+ by move=> ?; rewrite lee_fin.
102+
+ suff -> : \bigcup_(c in range h) h @^-1` [set c] = [set: T] by [].
103+
apply/seteqP; split => [//|y _].
104+
by exists (h y); [exists y|].
105+
Qed.
106+
107+
Lemma int1 f i :
108+
(\int[@counting (discrete_measurable_space T) R]_(x in [set i]) f x = f i)%E.
109+
Proof.
110+
transitivity (\int[@counting (discrete_measurable_space T) R]_(x in [set i])
111+
cst (f i) x)%E.
112+
+ by apply: eq_integral => x /set_mem/= ->.
113+
rewrite integral_cst// -[X in _ = X](mule1 (f i)).
114+
congr (f i * _)%E => /=.
115+
rewrite /counting (asboolT (finite_set1 i)).
116+
by rewrite fset_set1 cardfs1.
117+
Qed.
118+
119+
Lemma UA (A : set T): \bigcup_(i in A) [set i] = A.
120+
Proof.
121+
by apply/seteqP; split=> [x [i Ai ->//]|x Ax]; exists x.
122+
Qed.
123+
124+
Lemma intA f : forall A : set T, finite_set A ->
125+
(forall x, (0 <= f x)%E) ->
126+
(\int[@counting (discrete_measurable_space T) R]_(x in A) f x = \sum_(x \in A) f x)%E.
127+
Proof.
128+
move=> A finA ?.
129+
rewrite fsbig_finite//=.
130+
rewrite (eq_bigr (fun i => (\int[counting]_(x in [set i]) f x)%E)).
131+
+ by move => ??;rewrite int1.
132+
(* under eq_bigr do rewrite -int1. *)
133+
rewrite -ge0_integral_bigsetU //=.
134+
- exact: fset_uniq.
135+
- by move=> i j _ _ [x [-> ->]].
136+
- by rewrite (@bigsetU_fset_set _ _ _ _ finA) UA.
137+
Qed.
138+
139+
Lemma integral_counting_esum (f : T -> \bar R) :
140+
(forall x, (0 <= f x)%E) ->
141+
(\int[@counting (discrete_measurable_space T) R]_x f x
142+
= \esum_(x in [set: T]) f x)%E.
143+
Proof.
144+
move=> f0 ; apply/eqP; rewrite eq_le; apply/andP; split.
145+
- rewrite ge0_integralTE //=.
146+
apply: ge_ereal_sup => /= _ [h /= hf] <-.
147+
rewrite sintegral_counting_esum.
148+
apply: le_esum => x _; exact: hf.
149+
- rewrite ge0_esum //; apply: ge_ereal_sup => /= _ [A [finA _] <-].
150+
rewrite -intA//.
151+
by apply: ge0_subset_integral => //.
152+
Qed.
153+
154+
End Counting.

0 commit comments

Comments
 (0)