Zulip Chat Archive
Stream: mathlib4
Topic: Redefining `AbsConvex` to use a single ring of scalars
Christopher Hoskin (Oct 06 2025 at 20:56):
Currently the definition of Absolutely Convex in Mathlib is a little unexpected:
def AbsConvex (s : Set E) : Prop := Balanced π s β§ Convex β s
At the time this definition was formulated, Mathlib's definition of Convex required the scalars to be an OrderedSemiring whereas the definition of Balanced required the scalars to be a SeminormedRing. Mathlib didn't have a concept of a semi-normed ordered ring, so a set was defined as AbsConvex if it is balanced over a SeminormedRing π and convex over β.
Recently the requirements for the definition of Convex have been relaxed (#24392, #20595) so it is now possible to use a single scalar ring in common with the literature.
I've opened a PR to make this change (#29342) but @Jireh Loreaux has suggested that it should be discussed here first, in particular the partial order on the complex numbers https://github.com/leanprover-community/mathlib4/pull/29342/files#diff-ba50cd1f8d6dfb5d017128c6e40f79de27adf53ce8c572d22bef36ff7a777795R85
Previous discussion:
- https://github.com/leanprover-community/mathlib4/pull/17029#discussion_r1782249323
- https://github.com/leanprover-community/mathlib4/pull/26345#discussion_r2287535746
Thanks,
Christopher
Christopher Hoskin (Oct 10 2025 at 06:19):
Are there any opinions on this or alternative suggestions on how to proceed please? @YaΓ«l Dillies @Eric Wieser @Filippo A. E. Nuccio @Moritz Doll @Jon Bannon @Anatole Dedecker @Monica Omar (list of people who have been kind enough to comment on related PRs). Thanks.
Filippo A. E. Nuccio (Oct 10 2025 at 06:51):
I am sorry, I had completely overseen your first message. I'll try to have a look, but as a start I do not understand why docs#IsOrderedRing is not IsOrderedSemiring.
YaΓ«l Dillies (Oct 10 2025 at 06:53):
Oh, that's just the same reason as to why docs#Module is not called Semimodule: when a typeclass covers several use cases, we do not necessarily name it after the most general one, but after the most common one.
Filippo A. E. Nuccio (Oct 10 2025 at 06:54):
Well, but this is highly misleading I find. Since we put some effort in the library to keep Semiring and Ring separated (unlike Semimodule, that appears much less), I would expect a different treatement. Or is it a general agreement to avoid Is+ Semi altogether?
YaΓ«l Dillies (Oct 10 2025 at 06:56):
Filippo, I am sympathetic to your argument, but this is a different discussion to the one Christopher is trying to have
Filippo A. E. Nuccio (Oct 10 2025 at 06:56):
Yes, good point. My apologies. I'll try to look at the PR and might resurrect this point elsewhere. Thanks for the alert :slight_smile:
YaΓ«l Dillies (Oct 10 2025 at 06:57):
I have thought about this a bit a while ago, and I seem to remember that it was important that the two scalar rings could be different. I do not think it matters further than being able to set one of them to \R and the other one to \C (or similarly \Q and \Q(i)), so if you're willing to talk about the order on \C/\Q(i), then I see no downside to your refactor.
YaΓ«l Dillies (Oct 10 2025 at 06:58):
Do people in fact care about \Q-absolutely convex sets?
Christopher Hoskin (Oct 10 2025 at 07:23):
YaΓ«l Dillies said:
I have thought about this a bit a while ago, and I seem to remember that it was important that the two scalar rings could be different.
The other possibility would be to make the definition something like this:
variable (πβ πβ) [SeminormedRing πβ] [SMul πβ E] [SMul πβ E] [Semiring πβ] [PartialOrder πβ]
[AddCommMonoid E]
/-- A set is absolutely convex if it is balanced and convex. -/
def AbsConvex (s : Set E) : Prop := Balanced πβ s β§ Convex πβ s
YaΓ«l Dillies said:
I do not think it matters further than being able to set one of them to
\Rand the other one to\C
I introduced convex_RCLike_iff_convex_real in #29248 to move between the real and complex case.
YaΓ«l Dillies said:
(or similarly
\Qand\Q(i))
I occasionally find myself wondering how much of RCLike actually holds for any quadratic alternative real division algebra (i.e. β, β, β and π) - but I haven't given that any serious thought.
YaΓ«l Dillies (Oct 10 2025 at 07:24):
Christopher Hoskin said:
The other possibility would be to make the definition something like this:
Yes, but at this point are you saving much over just using Balanced πβ s β§ Convex πβ s?
Christopher Hoskin (Oct 10 2025 at 07:24):
Christopher Hoskin said:
At the time this definition was formulated, Mathlib's definition of
Convexrequired the scalars to be anOrderedSemiringwhereas the definition ofBalancedrequired the scalars to be aSeminormedRing. Mathlib didn't have a concept of a semi-normed ordered ring, so a set was defined asAbsConvexif it is balanced over aSeminormedRingπand convex overβ.
This was just guesswork on my part, so there may have been other reasons for defining it this way.
Filippo A. E. Nuccio (Oct 10 2025 at 07:32):
For what is worth, there is a crucial user of convexity for vector spaces over nonarchimedean fields, and there quadratic extensions are galore. That being said, the current definition of convex, even with this refactor, does not align with the one used in that context .
Christopher Hoskin (Oct 10 2025 at 07:55):
Kaup and Upmeier, Jordan algebras and Symmetric Siegel Domains in Banach Spaces, Math. Z. 157, 179-200 (1977) define complex extreme points (and by extension complex convexity) using scalars in the unit ball of β rather than the positive unit ball.
Kenny Lau (Oct 10 2025 at 09:12):
@Christopher Hoskin do you have a usecase in mind?
Kenny Lau (Oct 10 2025 at 09:13):
YaΓ«l Dillies said:
one of them to
\Rand the other one to\C
but isn't the C-unit disc in C the same as the R-unit disc in C?
Kenny Lau (Oct 10 2025 at 09:13):
oh, never mind, they are different
Kenny Lau (Oct 10 2025 at 09:14):
do you remember why you needed that?
Monica Omar (Oct 10 2025 at 10:45):
am i right in thinking that theyβre equivalent definitions? a π-balanced set is π-convex iff itβs β-convex?
Kenny Lau (Oct 10 2025 at 10:46):
what does 0<x<1 mean if x is complex?
Monica Omar (Oct 10 2025 at 10:57):
right, but weβre weakening the definition to a seminormed ring /bbk, not R or C
Monica Omar (Oct 10 2025 at 10:58):
ignore me. this refactor looks fine to me
Kevin Buzzard (Oct 10 2025 at 11:03):
Kenny Lau said:
what does 0<x<1 mean if x is complex?
According to mathlib it means terms of this type:
import Mathlib
open scoped ComplexOrder
example : Type := {x : β // 0 < x β§ x < 1}
Anatole Dedecker (Oct 10 2025 at 11:10):
They are precisely the real numbers 0 < x < 1, see docs#Complex.lt_def and the aforementionned docs#convex_RCLike_iff_convex_real
Monica Omar (Oct 10 2025 at 11:13):
lol I thought kenny's question was rhetorical
Anatole Dedecker (Oct 10 2025 at 11:15):
Ah, maybe it was, but I guess answering it doesn't hurt x)
Anatole Dedecker (Oct 10 2025 at 11:23):
I think I'm in favor of this refactor. Anything that means that we don't have to work with both a real and a complex structure is good, and mathematically it shouldn't change anything (unless people care about this definition for other rings, but I can't really see that happening)
Last updated: Dec 20 2025 at 21:32 UTC