Feature esum psum esum only#1978
Conversation
d5fc795 to
bc6feda
Compare
8e0aacb to
3aec29b
Compare
|
@t6s I am pinging you because this PR changes the definition of |
4d86e16 to
ba957d0
Compare
|
@lyonel2017 @strub rebased |
|
It looks like there are several chunks of changes contained in this PR, making it difficult to review it at once. Can you provide a bit more detailed description of intention for each of them? For example, which lemmas do you consider are important? |
This is maybe for @lyonel2017 and @strub to say because this PR is used to develop another one. From my viewpoint, the main change is the definition of Definition esum S f := pos_esum S f^\+ - pos_esum S f^\-.Before that, it was only the positive part. |
I started porting the distr.v file from |
| Qed. | ||
| End SumTh. | ||
|
|
||
| Lemma esum_psum {R : realType} {T : choiceType} (f : T -> R) : |
There was a problem hiding this comment.
Noting that esum has a very similar definition to sum, the following proof strategy is also possible:
discard the negative part of esum, and show PosEsum.pos_esum and psum are equal.
An attempt is as follows, but resulted in a longer proof:
Lemma ge0_funenegET :
forall [T : Type] [R : realDomainType] [f : T -> \bar R],
(forall x : T, (0%R <= f x)%E) -> f^\-%E = cst 0.
Proof.
move=> ? ? ? H; apply/funext => ?.
have ->// := @ge0_funenegE _ _ setT.
by rewrite mem_set.
Qed.
Lemma ge0_funrposET :
forall [T : Type] [R : realDomainType] [f : T -> R],
(forall x : T, 0 <= f x) -> f^\+ = f.
Proof.
move=> ? ? ? H; apply/funext => ?.
have ->// := @ge0_funrposE _ _ setT.
by rewrite mem_set.
Qed.
Lemma fsetsTE (T : choiceType) : fsets [set: T] = finite_set.
Proof. by apply/funext=> ?; apply/propext; split => // -[]. Qed.
Lemma exists_fsetE (T : choiceType) (P : {fset T} -> Prop) :
(exists J : {fset T}, P J) = (exists2 J : set T, finite_set J & P (fset_set J)).
Proof.
apply/propext; split.
by case=> J ?; exists [set` J]%classic => //; rewrite set_fsetK.
by case=> J ? ?; exists (fset_set J).
Qed.
Lemma exists_finite_setE (T : choiceType) (P : set T -> Prop) :
(exists2 J : set T, finite_set J & P J) = (exists J : {fset T}, P [set` J]%classic).
Proof.
rewrite exists_fsetE; apply/propext; split => -[] J ?.
by move=> ?; exists J => //; rewrite fset_setK.
by rewrite fset_setK// => ?; exists J.
Qed.
Lemma esymE (T : Type) (x y : T) : (x = y) = (y = x).
Proof. by apply/propext; split => /esym. Qed.
Lemma esum_psum {R : realType} {T : choiceType} (f : T -> R) :
(forall i, 0 <= f i) -> summable f ->
\esum_(x in [set: T]) (f x)%:E = (psum f)%:E.
Proof.
move=> f0 h.
rewrite /esum ge0_funenegET// [X in (_ - X)%E]PosEsum.pos_esum1// sube0.
rewrite /PosEsum.pos_esum fsetsTE.
rewrite /psum/=; case:asboolP => // _.
set S := (S in sup S).
have S_has_ubound : has_ubound S.
by case: h => M HM; exists M => ?/= [] J ->; exact: HM.
(* summable f -> has_ubound S; (S in the definition of psum) *)
have S_nonempty : (S !=set0)%classic.
by exists 0, fset0; rewrite big1// => i; have := fsvalP i.
(* S always has the sum over the emptyset as its elements *)
rewrite -ereal_sup_EFin; [exact: S_has_ubound | exact: S_nonempty |].
congr ereal_sup.
under eq_imagel do rewrite fsbig_finite//= funerpos/= sumEFin.
rewrite -[LHS]image_comp; congr image.
rewrite /S; apply: funext=> x/=.
rewrite exists_finite_setE; congr ex; apply/funext => J.
rewrite [LHS]esymE; congr eq.
rewrite -(big_seq_fsetE _ _ xpredT (Num.norm \o f))/= set_fsetK.
apply: eq_bigr => ? _.
by rewrite ger0_norm// ge0_funrposET.
Qed.
There was a problem hiding this comment.
Further refactored; this ge0_psumEpos_esum can also be used to shorten esumEsum.
Lemma ge0_psumEpos_esum {R : realType} {T : choiceType} (f : T -> R) :
(forall i, 0 <= f i) -> summable f ->
(psum f)%:E = PosEsum.pos_esum [set: T] (EFin \o f).
Proof.
move=> f0 h.
rewrite /psum/=; case: asboolP => // _.
rewrite /PosEsum.pos_esum fsetsTE.
set S := (S in sup S).
have S_has_ubound : has_ubound S.
by case: h => M HM; exists M => ?/= [] J ->; exact: HM.
(* summable f -> has_ubound S; (S in the definition of psum) *)
have S_nonempty : (S !=set0)%classic.
by exists 0, fset0; rewrite big1// => i; have := fsvalP i.
(* S always has the sum over the emptyset as its elements *)
rewrite -ereal_sup_EFin; [exact: S_has_ubound | exact: S_nonempty |].
congr ereal_sup.
under [RHS]eq_imagel do rewrite fsbig_finite//= sumEFin.
rewrite -[RHS]image_comp; congr image.
rewrite /S; apply: funext=> x/=.
rewrite exists_finite_setE; congr ex; apply/funext => J.
rewrite [LHS]esymE; congr eq.
rewrite -(big_seq_fsetE _ _ xpredT (Num.norm \o f))/= set_fsetK.
apply: eq_bigr => ? _.
by rewrite ger0_norm.
Qed.
Lemma esum_psum {R : realType} {T : choiceType} (f : T -> R) :
(forall i, 0 <= f i) -> summable f ->
\esum_(x in [set: T]) (f x)%:E = (psum f)%:E.
Proof.
move=> f0 h.
rewrite /esum ge0_funenegET// [X in (_ - X)%E]PosEsum.pos_esum1// sube0.
by rewrite psumEpos_esum// funerpos ge0_funrposET.
Qed.
There was a problem hiding this comment.
I am not sure we need to revise the proof scripts,
even though I am still unsure about the quality of the API:
this PR is certainly an improvement but work remains.
For example, what about renaming psum to pos_sum (to match pos_esum and also because it looks like "partial sum" to me, since we use gt0 to say "positive" in MathComp---of course in lemmas).
There was a problem hiding this comment.
This is a right observation to say that some lemma should bridge pos_esum and psum,
but while pos_esum is "hidden" in a Module, psum isn't yet.
There was a problem hiding this comment.
But, if we were to really "hide" psum in a Module, it is maybe reasonable to postpone because the API of psum contains infamous admitted lemmas (__admitted__psumB and __admitted__interchange_psum).
Fixing the latter is a goal of @lyonel2017, so we shall come back to it anyway.
There was a problem hiding this comment.
The last commit (86ec8af) proves __admitted_psumB (it was about time...).
There was a problem hiding this comment.
Noting that
esumhas a very similar definition tosum, the following proof strategy is also possible: discard the negative part ofesum, and showPosEsum.pos_esumandpsumare equal.An attempt is as follows, but resulted in a longer proof:
[crunch] Lemma fsetsTE (T : choiceType) : fsets [set: T] = finite_set. Proof. by apply/funext=> ?; apply/propext; split => // -[]. Qed. [crunch]
I kept this lemma but didn't integrate the other ones.
In particular, I didn't keep ge0_funenegET and its pos variant because iirc they were introduced at some point but turned out to be less useful than their extensional variants (forall x, ... x = ... x).
ba957d0 to
ae2b17b
Compare
Co-authored-by: Takafumi Saikawa <tscompor@gmail.com>
t6s
left a comment
There was a problem hiding this comment.
After playing for a while with this code, I have a feeling that the code is in a consistent state.
I am inspired to do some additions (other than I suggested in the previous review comments) to fsbig, which could possibly simplify PosEsum, psum, and esum, but I will let them go into a separate PR rather than requesting changes here.
|
ah, but one thing: naming conventions seem to be incoherent between |
Yes indeed, |
* Add missing lemmas for distr
* use fun{r,e}{pos,neg} instead of f{pos,neg}
* esum lemmas from PR math-comp#1954
* new definition of esum
* prove __admitted__psumB
---------
Co-authored-by: Lionel Blatter <lionel.blatter@wanadoo.fr>
Co-authored-by: Takafumi Saikawa <tscompor@gmail.com>
Motivation for this change
closes #1954
This PR intends to extract the reusable part of PR #1954
esumfposandfneg(superseded byfunrposandfunrneg)TODO: completed (?)
some scripts still need to be lintedsome lemmas are wrongly namedome lemmas are not in the right filesfyi: @lyonel2017 @strub
Checklist
CHANGELOG_UNRELEASED.mdReference: How to document
Merge policy
As a rule of thumb:
all compile are preferentially merged into master.
Reminder to reviewers