Zulip Chat Archive

Stream: general

Topic: odd_gt_zero


Michael Stoll (Jun 01 2022 at 20:10):

There is docs#nat.odd_gt_zero, which defies naming conventions. (I was looking for something containing pos or perhaps zero_lt.) It would also be nice to have the same statement with the assumption n % 2 = 1 instead of odd n.
It looks like it is not used anywhere in mathlib right now and otherwise only once (in archive/imo/imo1998_q2.lean).
I'd suggest to rename it nat.odd_pos (and add nat.odd_pos' for the variant).

Alex J. Best (Jun 01 2022 at 20:13):

Oh yeah I started doing this a while back and forgot about it #13040, I'll try and get this merged now lol. Then you can add the variant you want separately if you like.

Michael Stoll (Jun 01 2022 at 20:14):

OK, sounds good.

Yaël Dillies (Jun 01 2022 at 22:28):

Actually, you can generalize it quite a bit.

Violeta Hernández (Jun 02 2022 at 04:40):

Agree with odd_pos

Ruben Van de Velde (Jun 02 2022 at 04:47):

Can't we do odd.pos for canonically ordered monoids it something?

Violeta Hernández (Jun 02 2022 at 04:51):

This might be a bit of an offhand comment, but I feel like there should be something more general than canonically ordered monoids for which many of the order results still hold true, including this one

Violeta Hernández (Jun 02 2022 at 04:52):

I recently ran into the problem of ordinals not being a canonically ordered monoid, just because of the technicality that addition isn't commutative

Violeta Hernández (Jun 02 2022 at 04:52):

odd.pos would still hold true for ordinals, though

Mario Carneiro (Jun 02 2022 at 04:52):

ordinals are rather odd as an algebraic structure though. Cardinals too

Mario Carneiro (Jun 02 2022 at 04:54):

I generally try to avoid introducing a new weak algebraic structure if there is only one example

Mario Carneiro (Jun 02 2022 at 04:55):

even defining what it means to be an "odd ordinal" is a bit subtle and the definition that works for ordinals isn't necessarily the most natural or correct in other situations

Mario Carneiro (Jun 02 2022 at 04:56):

and "odd cardinal" is all sorts of broken

Violeta Hernández (Jun 02 2022 at 04:57):

That's fair

Violeta Hernández (Jun 02 2022 at 04:59):

Yeah actually, odd and even ordinals would be quite broken under the current definition

Violeta Hernández (Jun 02 2022 at 04:59):

ω + 1 is both even as (ω + 1) + (ω + 1), and odd as 2 * ω + 1

Violeta Hernández (Jun 02 2022 at 04:59):

Nevermind my remark then

Mario Carneiro (Jun 02 2022 at 05:00):

the "correct" definition for ordinals is that an ordinal is odd if its finite part is odd, or equivalently it has the form o * 2 + 1

Mario Carneiro (Jun 02 2022 at 05:04):

hm, actually you're right, that "or equivalently" definition doesn't work since (ω + 1) * 2 = ω * 2 + 1. I think it works if you use o.nmul 2

Violeta Hernández (Jun 02 2022 at 05:05):

Ordinals with natural operations aren't canonically ordered though, since there's no ordinal with 1 nadd o = ω

Violeta Hernández (Jun 02 2022 at 05:06):

Being canonically ordered feels like too strong of a property to state some of the order results like 0 ≤ x and this one, but I don't know what the appropriate generalization would be

Mario Carneiro (Jun 02 2022 at 05:07):

I mean it's basically just zero_le_order

Violeta Hernández (Jun 02 2022 at 05:07):

Wait, that's a typeclass?

Mario Carneiro (Jun 02 2022 at 05:07):

I'm not sure there's really anything else to this kind of structure besides general compatibility of + and <=

Mario Carneiro (Jun 02 2022 at 05:07):

no it's not

Johan Commelin (Jun 02 2022 at 05:09):

Can you use bot_le instead? I assume is defeq to 0.

Mario Carneiro (Jun 02 2022 at 05:09):

you need a typeclass that asserts it if you want it to be part of odd.pos

Violeta Hernández (Jun 02 2022 at 05:09):

A typeclass for has_bot + has_zero with ⊥ = 0 seems like it could be useful

Violeta Hernández (Jun 02 2022 at 05:10):

I feel like I'm derailing this thread, though...

Violeta Hernández (Jun 02 2022 at 05:10):

I'll make a new one

Violeta Hernández (Jun 02 2022 at 05:29):

Here's another mostly unrelated remark, but why does odd require a semiring?

Violeta Hernández (Jun 02 2022 at 05:30):

Is the definition ∃ k, a = k + k + 1 not good enough?

Violeta Hernández (Jun 02 2022 at 05:30):

Arguably this might lead to worse def-eq, but if so, why is even defined as ∃ k, a = k + k and not as ∃ k, a = 2 * k?

Violeta Hernández (Jun 02 2022 at 05:33):

Even then, why not just require has_add, has_mul, and has_one?

Damiano Testa (Jun 02 2022 at 05:59):

For the even/odd definition, there was a previous thread.

The summary: even is more useful, no one really has strong feelings as to what is a "good" definition of odd.

Violeta Hernández (Jun 02 2022 at 05:59):

Understandable

Damiano Testa (Jun 02 2022 at 05:59):

With respect to the "ordinal odd", it seems that in this case, all that you use of "odd" is that the ordinal is a successor and therefore non-zero, right? This might be more useful for ordinals, than defining odd for them.


Last updated: Dec 20 2023 at 11:08 UTC