Zulip Chat Archive

Stream: general

Topic: redefine has_ordered_sub


Violeta Hernández (Aug 10 2022 at 21:42):

Here's a petition. Currently, the docs#has_ordered_sub typeclass has ∀ (a b c : α), a - b ≤ c ↔ a ≤ c + b as an assumption. I want it to have ∀ (a b c : α), a - b ≤ c ↔ a ≤ b + c instead. The key difference is that this would allow us to put a has_ordered_sub instance on ordinals. I think every current concrete instance is with commutative addition, so this change shouldn't impact it.

Violeta Hernández (Aug 10 2022 at 21:45):

I think this may have already been the original intention. Quoting from the docstring:

In other words, a - b is the least c such that a ≤ b + c.

This of course is only true in noncommutative contexts with the redefinition I'm proposing.

Violeta Hernández (Aug 10 2022 at 21:48):

Also, almost all of the API is proven with the add_comm_semigroup assumption.

Violeta Hernández (Aug 10 2022 at 21:51):

Oh actually, this change is actually very easy to do

Violeta Hernández (Aug 10 2022 at 21:52):

It's literally just swapping a few _right lemmas with a few _left lemmas and that's it

Violeta Hernández (Aug 10 2022 at 21:56):

Yeah let's try this: #15991

Violeta Hernández (Aug 10 2022 at 22:54):

Oh, wait

Violeta Hernández (Aug 10 2022 at 22:55):

This change would mean that additive groups no longer have an ordered substraction

Violeta Hernández (Aug 10 2022 at 22:55):

That's probably undesirable

Violeta Hernández (Aug 10 2022 at 23:00):

I guess we could make two separate classeshas_left_ordered_sub and has_right_ordered_sub but maybe that's overkill

Violeta Hernández (Aug 10 2022 at 23:06):

Actually, having two separate classes might not be such a bad idea. We do have a concrete purpose for each, after all.

Violeta Hernández (Aug 10 2022 at 23:36):

I wish we had more examples of has_left_ordered_sub though, i.e. the one for ordinals

Violeta Hernández (Aug 11 2022 at 03:28):

I guess docs#nonote would also have a has_left_ordered_sub instance, so that's two examples?

Violeta Hernández (Aug 11 2022 at 03:28):

Kind of a lame example since that's basically just ordinals again and there's not all that much API on that, but still

Junyan Xu (Aug 11 2022 at 08:13):

I think ordinal subtraction should really be written -a+b, but mathlib lacks a typeclass/notation for subtraction/division/quotient from the left ... I guess that's partially because mathlib doesn't have https://en.m.wikipedia.org/wiki/Quasigroup

Junyan Xu (Aug 11 2022 at 08:17):

We're about to get Jordan algebras. How about octonions and Moufang loops?

We also see left exponential notation in https://en.m.wikipedia.org/wiki/Racks_and_quandles

Floris van Doorn (Aug 11 2022 at 09:24):

The current definition of has_ordered_sub feels a lot more canonical, since you're adding/subtracting b on the right on both sides of the . It's unfortunate that it doesn't apply for ordinals indeed, but I don't think it's worth it to add a separate class just for ordinal (and nonote), unless we find more examples.

Eric Wieser (Aug 11 2022 at 10:35):

Presumaby things like ordinal × ordinal are also examples, but I don't think they're interesting enough unless you have a convincing use for them

Violeta Hernández (Aug 11 2022 at 14:53):

I think we also have structures order-isomorphic to subsets of ordinals as examples, such as the lex sum of N and N

Violeta Hernández (Aug 11 2022 at 14:53):

Though in that case addition is badly behaved too

Junyan Xu (Aug 11 2022 at 15:02):

I think the docs#add_opposite of ordinals will satisfy has_ordered_sub, if sub is unchanged even though add is swapped.

Violeta Hernández (Aug 11 2022 at 15:41):

Could we use that to easily port theorems of has_ordered_sub to ordinals?


Last updated: Dec 20 2023 at 11:08 UTC