Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convex exp #873

Merged
merged 22 commits into from
Apr 20, 2023
Merged

Convex exp #873

merged 22 commits into from
Apr 20, 2023

Conversation

affeldt-aist
Copy link
Member

@affeldt-aist affeldt-aist commented Mar 13, 2023

Motivation for this change

This is a continuation of PR #794 (I have duplicated the PR because it looks like I cannot push commits to it).
On top of PR #794, it introduces convex spaces and use the type {i01 R} from the PR #869.

This PR introduce convexs spaces, show that lmodType form instances, and use them to show that a function with a non-negative second derivative is convex (like the exponential function @hoheinzollern).

closes #794

Things done/to do
  • added corresponding entries in CHANGELOG_UNRELEASED.md
    (do not edit former entries, only append new ones, be careful:
    merge and rebase have a tendency to mess up CHANGELOG_UNRELEASED.md)
  • added corresponding documentation in the headers
Automatic note to reviewers

Read this Checklist and put a milestone if possible.

Comment on lines 155 to 156
Definition derivable_interval {R : numFieldType} (f : R -> R) (a b : R) :=
forall x, x \in `[a, b] -> derivable f x 1.
Copy link
Member Author

Choose a reason for hiding this comment

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

[NB: review comment by @zstone1 copied verbatim from PR #794]

This definition misbehaves at the endpoints. In particular, it requires f to be be "differentiable from the left at a". That makes this definition rely on values of f outside [a,b]. One big consequence is characteristic functions like if x \in `[a,b] then 1 else 0 fails this definition, as its not derivable at a or b. For what it's worth, I had an analogous issue with realfun.v, see #752 for how I addressed it there. You'll need something slightly different here, though.

I've seen textbooks take these approaches:

  1. Demanding "continuity up the endpoints" is one approach
forall x, x \in `]a, b[ -> derivable f x 1.
/\
cvg (at_right a f^`()) /\ cvg (at_right b f^`())

or some variation of this. However, this implies some continuity of the derivative, which is maybe not ideal.
2. We could change the derivative to use a different topology. One way to do that is add an analog to the {within `[a,b], continuous f} notation of {within `[a,b], derivable f}. This would take limits only on the subspace topology.
3. Similarly, but specialized to working in R, it should be fine to define it like

forall x, x \in `]a, b[ -> derivable f x 1
/\
"differentiable from the right at b" /\ "differentiable from the left at a"

For some sensible notion of "left" and "right" derivative.

Copy link
Member Author

@affeldt-aist affeldt-aist Mar 29, 2023

Choose a reason for hiding this comment

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

1. Demanding "continuity up the endpoints" is one approach
forall x, x \in `]a, b[ -> derivable f x 1.
/\
cvg (at_right a f^`()) /\ cvg (at_right b f^`())

or some variation of this. However, this implies some continuity of the derivative, which is maybe not ideal.

The last two commits implement this solution.
(Hopefully, we think that you wrote cvg (at_right a f^`()) but actually meant cvg (at_right a f).)
Is it in the right direction? @zstone1

Comment on lines +183 to +138
Section twice_derivable_convex.
Context {R : realType}.
Variables (f : R -> R^o) (a b : R^o).
Copy link
Member Author

Choose a reason for hiding this comment

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

[NB: review comment by @zstone1 copied verbatim from PR #794 ]

Where do we need the assumption that the range of f is R? If it's painless, generalizing to a vector space would be quite helpful for me. I'll need some stuff about convexity in both R and R^n for my work on space-filling curves, so I'm happy to have these results either way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Where do we need the assumption that the range of f is R?

We at least need to be able to compare to 0 but I maybe need to spend more time.

@affeldt-aist
Copy link
Member Author

[NB: review comment by @zstone1 copied verbatim from PR https://github.com//pull/794 ]

Nice results. I've made comments about a couple generalizations, one regarding annoying endpoint issues, the other regarding generalizing to vector space ranges. I care more about the endpoints one mostly because it's much harder to fix later. Happy to work with you on that if that'd be helpful.

@affeldt-aist affeldt-aist changed the base branch from master to itv March 13, 2023 17:25
@affeldt-aist affeldt-aist added this to the 0.6.2 milestone Mar 13, 2023
@affeldt-aist affeldt-aist mentioned this pull request Mar 14, 2023
2 tasks
@affeldt-aist affeldt-aist added the enhancement ✨ This issue/PR is about adding new features enhancing the library label Mar 15, 2023
@affeldt-aist affeldt-aist changed the base branch from itv to master March 15, 2023 15:31
@hoheinzollern
Copy link
Collaborator

On top of being helpful for the exponential function, definitions about convexity are also necessary for the formalization of Hoelder's inequality and the special case of Cauchy Schwarz's inequality from PR #790.

@CohenCyril CohenCyril added the TODO: MC2 port This PR must be ported to mathcomp 2 now that the. Remove this label when the port is done. label Mar 27, 2023
@affeldt-aist affeldt-aist requested a review from zstone1 April 7, 2023 04:51
Copy link
Contributor

@zstone1 zstone1 left a comment

Choose a reason for hiding this comment

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

Much improved from before.

  • It looks like all the endpoint conditions all make sense. It should now work correctly for the indicator function on [0,1]
  • I generalized a few things to topologicalType.
  • Happy to see the generalization to convex spaces.

Other than the small generalizations, looks good to me.

@affeldt-aist
Copy link
Member Author

Many thanks for the review!

@affeldt-aist affeldt-aist merged commit f129011 into math-comp:master Apr 20, 2023
affeldt-aist added a commit that referenced this pull request Apr 21, 2023
* Introduce convex

- introduce convex spaces
- proof of second_derivative_convex_pt
- using `{i01 R}`
- expR convex

Co-authored-by: Reynald Affeldt <reynald.affeldt@aist.go.jp>
Co-authored-by: Alessandro Bruni <alessandro.bruni@gmail.com>
Co-authored-by: Takafumi Saikawa <tscompor@gmail.com>
Co-authored-by: zstone1 <zstonex@gmail.com>
Co-authored-by: Yoshihiro Imai <y.imai@aist.go.jp>
@proux01 proux01 removed the TODO: MC2 port This PR must be ported to mathcomp 2 now that the. Remove this label when the port is done. label Apr 29, 2023
Comment on lines +472 to +473
Lemma convex_expR (t : {i01 R}) (a b : R^o) : a <= b ->
expR (a <| t |> b) <= (expR a : R^o) <| t |> (expR b : R^o).
Copy link
Member

Choose a reason for hiding this comment

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

@affeldt-aist the multiplications of such lemmas call for a notion of convex function (or convex function on a given domain)

Comment on lines +14 to +15
(* derivable_oo_continuous_bnd f x y == f is derivable on `]x, y[ and *)
(* continuous up to the boundary *)
Copy link
Member

@CohenCyril CohenCyril Aug 17, 2023

Choose a reason for hiding this comment

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

Unfortunately {in `]x, y[, forall x, derivable f x 1} does not mean f is derivable on `]x, y[ 🤷

@CohenCyril CohenCyril mentioned this pull request Oct 2, 2023
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.

6 participants