Zulip Chat Archive
Stream: general
Topic: canonically_ordered_monoid
Yaël Dillies (Nov 04 2021 at 00:25):
What's the to_additive
tag on docs#canonically_ordered_monoid supposed to achieve? docs#canonically_ordered_add_monoid already exists by that point.
Yury G. Kudryashov (Nov 04 2021 at 00:51):
It registers the fact that canonically_ordered_add_monoid
is the additive version of canonically_ordered_monoid
.
Floris van Doorn (Nov 04 2021 at 08:46):
To expand on what Yury said: to_additive
cannot automatically create an additive structure/class (there are some automatically generated declarations - like the projections - that we cannot easily generate using metaprogramming).
But we still need tot tell to_additive
that canonically_ordered_add_monoid
is the additive version of canonically_ordered_monoid
and that the declarations generated automatically by canonically_ordered_monoid
also are matched up with their additive counterparts.
Yaël Dillies (Nov 04 2021 at 14:52):
Interesting! I didn't know about that.
Yaël Dillies (Nov 04 2021 at 14:54):
However it doesn't work on def
?
Floris van Doorn (Nov 04 2021 at 15:03):
It also works on def
. We sometimes first give the additive def
, and then the multiplicative def
marked with a to_additive
attribute. This is sometimes necessary when we hit one of the limitations to to_additive
.
Yaël Dillies (Nov 04 2021 at 15:05):
I tried to do this in data.list.defs
but it doesn't work. Is it just because to_additive
doesn't exist yet at that point?
Mario Carneiro (Nov 04 2021 at 15:06):
Most likely. Note that you can also do it in the other direction if the file is a dependency of to_additive
, i.e. you can add the attribute to all the core files inside the file that declares to_additive
Eric Wieser (Nov 04 2021 at 15:06):
Most likely. I think the file that defines to_additive adds the attribute on a bunch of things that appeared earlier in the import graph for exactly this reason
Mario Carneiro (Nov 04 2021 at 15:07):
I don't think data.list.defs
even knows the vocabulary to talk about groups and additive groups
Yaël Dillies (Nov 04 2021 at 15:08):
It was to link alternating_sum
and alternating_prod
.
Floris van Doorn (Nov 04 2021 at 16:09):
You should probably do this retroactively in some list file that has basic tactics (maybe data.list.basic
?)
Floris van Doorn (Nov 04 2021 at 16:10):
Floris van Doorn (Nov 04 2021 at 16:10):
-- list.sum was already defined in defs.lean, but we couldn't tag it with `to_additive` yet.
Yaël Dillies (Nov 04 2021 at 16:20):
Yeah, that's what was being done, and that's how I kept it: #10164
Floris van Doorn (Nov 04 2021 at 16:22):
Given that this confused you, can you add a docstring to list.alternating_prod
that the to_additive
is added later and why.
Eric Wieser (Nov 04 2021 at 17:33):
A regular comment would make more sense IMO
Yaël Dillies (Nov 04 2021 at 17:36):
I've put both to_additive
ization in a section with a comment.
Last updated: Dec 20 2023 at 11:08 UTC