Zulip Chat Archive

Stream: mathlib4

Topic: AddGroupWithOne


Johan Commelin (Mar 13 2024 at 15:40):

Why is docs#AddGroupWithOne defined in a file called Mathlib/Data/Int/Cast/Defs.lean. I would expect stuff about Int.Cast there. But not much more...

Jireh Loreaux (Mar 13 2024 at 15:44):

This is probably half a porting accident. AddGroupWithOne was new to Lean 4 and backported to Lean 3. So it already existed and material around ad hoc porting always had some special treatment.

In addition, I think the main point is that you can't put it any earlier (as we do with Algebra.Group.Defs) because you actually need the cast first.

Jireh Loreaux (Mar 13 2024 at 15:44):

docs#AddMonoidWithOne is also in Data.Nat.Cast.Defs

Johan Commelin (Mar 13 2024 at 15:59):

Right, it can't go earlier, but I still expected it later, outside Int/Cast/*

Jireh Loreaux (Mar 13 2024 at 16:00):

Fair enough.

Jireh Loreaux (Mar 13 2024 at 16:02):

I guess we could just split them out into Algebra.Monoid.WithOne and Algebra.Group.WithOne or something like that.

Yaël Dillies (Mar 13 2024 at 18:53):

Nonono, please don't do that

Matthew Ballard (Mar 13 2024 at 18:56):

@Yaël Dillies can you expand?

Yaël Dillies (Mar 13 2024 at 18:57):

Everything under Algebra.Monoid and Algebra.Group is meant to be additivisable. AddMonoidWithOne and AddGroupWithOne are not

Matthew Ballard (Mar 13 2024 at 18:58):

What would you recommend for a module?

Yaël Dillies (Mar 13 2024 at 18:58):

Furthermore, AddMonoidWithOne and AddGroupWithOne are exactly where they should be. They are part of the core definitions needed for Nat.cast/Int.cast

Yaël Dillies (Mar 13 2024 at 18:59):

I would recommend leaving them as is

Yaël Dillies (Mar 13 2024 at 19:00):

And Jireh is wrong in that it is not a porting accident

Yaël Dillies (Mar 13 2024 at 19:01):

It was Gabriel Ebner who defined much before the port and put them where they are now

Jireh Loreaux (Mar 13 2024 at 19:04):

Yaël, did I not say they were in place and then backported? My point is that during porting we didn't think terribly hard about where these should ‌‌/ would go; I know, because I ported them (IIRC).

Jireh Loreaux (Mar 13 2024 at 19:05):

But nevertheless, I take your point about being additivisable. Is that convention written down anywhere? If not, let's make that happen.

Eric Wieser (Mar 13 2024 at 19:19):

Yaël Dillies said:

Furthermore, AddMonoidWithOne and AddGroupWithOne are exactly where they should be. They are part of the core definitions needed for Nat.cast/Int.cast

This argument seems stronger to me than the one about additivizability

Yaël Dillies (Mar 13 2024 at 19:38):

Jireh Loreaux said:

My point is that during porting we didn't think terribly hard about where these should ‌‌/ would go; I know, because I ported them (IIRC).

I'm on my phone right now but I'm sure Eric can show you the PR from 2022 which defined AddMonoidWithOne.

Yaël Dillies (Mar 13 2024 at 19:40):

Jireh Loreaux said:

But nevertheless, I take your point about being additivisable. Is that convention written down anywhere? If not, let's make that happen.

It is not yet written anywhere because it is not yet true. I'm trying to make it happen but I'm stuck at docs#MonoidHom.End, for which I might have to make an exception.

Yaël Dillies (Mar 13 2024 at 19:41):

At least once it becomes true (maybe modulo MonoidHom.End) we won't have bogus things like basic files about groups importing rings

Eric Rodriguez (Mar 13 2024 at 19:48):

We can't have such things be policed by "Yael notices some github discussion and they put a stop to it" - can we put some documentation in the folders?

Eric Wieser (Mar 13 2024 at 19:53):

The PR Yael is talking about is https://github.com/leanprover-community/mathlib/pull/12182

Eric Wieser (Mar 13 2024 at 19:55):

Though I think it was indeed motivated by Lean 4's OfNat in some way (relevant message)

Eric Wieser (Mar 13 2024 at 19:56):

I think the summary is that in Lean 3 we had an Algebra diamond that we could put up with, but in lean 4 we were headed towards having a diamond in numeric literals, which made the problem much more urgent.

Yaël Dillies (Mar 13 2024 at 20:04):

Eric Rodriguez said:

can we put some documentation in the folders?

Yes actually I am still very much in favour of putting some markdown file inside each (somewhat interesting) folder to explain what is supposed to be in there.


Last updated: May 02 2025 at 03:31 UTC