Skip to content

Conversation

@IshiguroYoshihiro
Copy link
Contributor

Motivation for this change

Add a part of generalized version of integration by parts for unbound intervals `[a, +oo[.
This PR is over #1656 and #1662.
I don't sure that I should add 4 more lemmas and complete all variation of integration by parts for unbound intervals.
I think that 8 similar lemmas would be a mess. So, I'd like to somehow make them up into one or two lemmas, but I don't have an idea.

Checklist
  • added corresponding entries in CHANGELOG_UNRELEASED.md
  • added corresponding documentation in the headers

Reference: How to document

Merge policy

As a rule of thumb:

  • PRs with several commits that make sense individually and that
    all compile are preferentially merged into master.
  • PRs with disorganized commits are very likely to be squash-rebased.
Reminder to reviewers

@Tragicus
Copy link
Collaborator

Are not all 4 versions the same, the only difference being whether the minus is inside or outside the integral?

@IshiguroYoshihiro
Copy link
Contributor Author

Are not all 4 versions the same, the only difference being whether the minus is inside or outside the integral?

If you said that these lemmas can be proved with one of them, I think it is no.
As you can see, the version of le0_ge0 and le0_le0 can be proved with ge0_ge0 or ge0_le0, but ge0_le0 can not proved from ge0_ge0.
Because that integration by substitusion using a transformation F -> F \o -%R change the unbounded side of the interval from `[a, +oo[ to `[-oo, - a[, I may have to set 4 more variations of this lemma for `[-oo, -a[.
It will makes messy for the use to set 8 variation of the lemma. So I will consider some good way.

@affeldt-aist affeldt-aist force-pushed the integration_by_partsy_20250704 branch from 949b179 to 0802b9c Compare October 30, 2025 07:07
@affeldt-aist affeldt-aist marked this pull request as ready for review October 30, 2025 09:32
@affeldt-aist
Copy link
Member

Are not all 4 versions the same, the only difference being whether the minus is inside or outside the integral?

Indeed le0_le0 is the same as ge0_ge0 (and it is proved as such).
Similarly, for ge0_le0 vs. le0_ge0.
I don't think we can have more sharing.
Do you think that we should work towards a general version? A single lemma encompassing them all?

@affeldt-aist
Copy link
Member

Are not all 4 versions the same, the only difference being whether the minus is inside or outside the integral?

Indeed le0_le0 is the same as ge0_ge0 (and it is proved as such). Similarly, for ge0_le0 vs. le0_ge0. I don't think we can have more sharing. Do you think that we should work towards a general version? A single lemma encompassing them all?

To give a bit of context, these lemmas have been written this way after having been tested to formalize the Gamma function. Maybe their apparent specialization is the result of practical considerations? @IshiguroYoshihiro can you confirm? (Or am I remembering wrong?)

Copy link
Collaborator

@Tragicus Tragicus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I am back.
One way to factorize would be to ask for the relevant functions to have constant sign. I was also wondering whether we want to generalize over the interval, instead of [a, +oo[. We would require that the relevant functions are derivable on the interior of the interval and have limits at the boundaries.
@affeldt-aist Some of the following suggestions are quite ugly but save a lot of time, what do you think?

theories/ftc.v Outdated
Comment on lines 1105 to 1111
rewrite (@integration_by_partsy_le0_ge0 R (- F)%R G (- f)%R g a (- FGoo))//.
- rewrite oppeD; last exact: fin_num_adde_defr.
rewrite -EFinN opprD 2!opprK mulNr.
by under eq_integral do rewrite mulNr EFinN oppeK.
- by move=> ?; apply: cvgN; exact: cf.
- exact: derivable_oy_continuous_bndN.
- by move=> ? ?; rewrite fctE derive1N ?Ff//; move: Foy => [+ _]; apply.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rewrite (@integration_by_partsy_le0_ge0 R (- F)%R G (- f)%R g a (- FGoo))//.
- rewrite oppeD; last exact: fin_num_adde_defr.
rewrite -EFinN opprD 2!opprK mulNr.
by under eq_integral do rewrite mulNr EFinN oppeK.
- by move=> ?; apply: cvgN; exact: cf.
- exact: derivable_oy_continuous_bndN.
- by move=> ? ?; rewrite fctE derive1N ?Ff//; move: Foy => [+ _]; apply.
rewrite (@integration_by_partsy_le0_ge0 R (- F)%R G (- f)%R g a (- FGoo))//.
- rewrite oppeD; last exact: fin_num_adde_defr.
rewrite -EFinN opprD 2!opprK mulNr.
by under eq_integral do rewrite mulNr EFinN oppeK.
- by move=> ?; apply: cvgN; exact: cf.
- exact: derivable_oy_continuous_bndN.
- by move=> ? ?; rewrite fctE derive1N ?Ff => [//|//|]; apply: Foy.1.

.6s faster

@affeldt-aist affeldt-aist added this to the 1.15.0 milestone Nov 4, 2025
@affeldt-aist affeldt-aist added the enhancement ✨ This issue/PR is about adding new features enhancing the library label Nov 4, 2025
affeldt-aist and others added 18 commits November 18, 2025 11:01
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
Co-authored-by: Quentin VERMANDE <[email protected]>
@IshiguroYoshihiro IshiguroYoshihiro mentioned this pull request Nov 18, 2025
2 tasks
@affeldt-aist
Copy link
Member

To give a bit of context, these lemmas have been written this way after having been tested to formalize the Gamma function.

FYI, here is the PR that formalizes the Gamma function:
#1762

One way to factorize would be to ask for the relevant functions to have constant sign. I was also wondering whether we want to generalize over the interval, instead of [a, +oo[. We would require that the relevant functions are derivable on the interior of the interval and have limits at the boundaries.

This has not been tested yet (by lack of time). :-(

Some of the following suggestions are quite ugly but save a lot of time, what do you think?

We have merged all of them. Thanks for identifying the performance issues, that helps.

{in `]a, +oo[, forall x, (f x * G x)%:E <= 0} ->
{in `]a, +oo[, forall x, (F x * g x)%:E <= 0} ->
\int[mu]_(x in `[a, +oo[) (F x * g x)%:E = (FGoo - F a * G a)%:E +
\int[mu]_(x in `[a, +oo[) (- (f x * G x)%:E).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that this minus sign can be brought out of the integral, so that the statements become more uniform.

Copy link
Member

@t6s t6s Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this:

Lemma integration_by_partsy_le0_ge0 :
  {in `]a, +oo[, forall x, (f x * G x)%:E <= 0} ->
  {in `]a, +oo[, forall x, 0 <= (F x * g x)%:E} ->
  \int[mu]_(x in `[a, +oo[) (F x * g x)%:E = (FGoo - F a * G a)%:E -
  \int[mu]_(x in `[a, +oo[) (f x * G x)%:E.
Proof.
move=> fG0 Fg0.
have /= mMfG : measurable_fun `]a, +oo[ (fun x => (- (f x * G x))%R).
  exact: measurableT_comp.
rewrite -integral_itv_obnd_cbnd// -[in RHS]integral_itv_obnd_cbnd//.
rewrite -integralN/=; last first.
  rewrite fin_num_adde_defr//.
  under eq_integral => ? ?.
    by rewrite (le0_funeposE fG0); first over; rewrite inE.
  by rewrite integral_cst// mul0e.
rewrite itv_bndy_bigcup_BRight seqDU_bigcup_eq.
rewrite 2?ge0_integral_bigcup//= -?seqDU_bigcup_eq -?itv_bndy_bigcup_BRight.
- rewrite [LHS]sum_integral_limn; apply: cvg_lim => //.
  apply: cvgeD; first exact: fin_num_adde_defr; first exact: FGaoo.
  under eq_cvg do rewrite sumNint_sumintN_fG.
  apply: is_cvg_nneseries_cond => n _ _; apply: integral_ge0 => x.
  rewrite seqDUE => anx; rewrite EFinN oppe_ge0.
  apply: fG0; rewrite inE/=.
  by apply: subset_itv anx; rewrite bnd_simp// lerDl.
- by move=> k; apply: measurableD => //; apply: bigsetU_measurable.
- exact/measurable_EFinP/measurableT_comp.
- by move=> ? ?; rewrite EFinN oppe_ge0 fG0// inE.
- by move=> k; apply: measurableD => //; apply: bigsetU_measurable.
- exact/measurable_EFinP.
- by move=> ? ?; rewrite Fg0// inE.
Qed.

@t6s
Copy link
Member

t6s commented Dec 11, 2025

I suggest keeping 4 lemmas as is, and additionally, provide a unified interface lemma that use the constant_sign predicate

rewrite -integral_itv_obnd_cbnd// -[in RHS]integral_itv_obnd_cbnd//.
rewrite itv_bndy_bigcup_BRight seqDU_bigcup_eq.
rewrite 2?ge0_integral_bigcup//= -?seqDU_bigcup_eq -?itv_bndy_bigcup_BRight.
- rewrite [LHS]sum_integral_limn; apply: cvg_lim => //.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The character immediately after apply: (that looks like a whitespace) seems to be 0xa0, not an whitespace.
This causes a build failure in my env.

by apply: cvg_comp; [apply: cvgr_idn|apply: cvg_addrl].
Qed.

Let sumN_Nsum_fG n :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this Let is almost useless.

by apply: subset_itv; rewrite // bnd_simp// lerDl.
Qed.

Let sumNint_sumintN_fG n :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be reduced to a mere application of integralN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ This issue/PR is about adding new features enhancing the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants