Zulip Chat Archive

Stream: mathlib4

Topic: data.nat.cast.defs


Jireh Loreaux (Nov 16 2022 at 16:33):

I've been avoiding this file even though it's close to the top because I know that coercions have changed in Lean 4. Has anyone else started thinking about this file yet? If so, do we have any sort of plan?

Gabriel Ebner (Nov 16 2022 at 17:26):

The thinking has been going on for a long time. :smile: Most of the file is already ported, just in the "wrong" places (grep for AddMonoidWithOne). I think only some of the lemmas are missing.

Jireh Loreaux (Nov 16 2022 at 17:53):

I kind of figured someone smarter than me had seen it coming. :smiley:

Jireh Loreaux (Nov 16 2022 at 17:55):

Do we have any sort of standard procedure for dealing with the coercion transition then? If so, can we write it up somewhere?

Moritz Doll (Nov 16 2022 at 23:53):

I think it should be done together with Algebra.GroupWithZero.Defs in mathlib4#563

Jireh Loreaux (Nov 17 2022 at 18:44):

I will tackle this and then incorporate it into mathlib4#563

Jireh Loreaux (Nov 17 2022 at 19:23):

Am I correct that has_nat_cast should just go away entirely?

Mario Carneiro (Nov 17 2022 at 19:24):

cc @Gabriel Ebner

Gabriel Ebner (Nov 17 2022 at 19:41):

Well spotted! I wrote both the Lean 3 and Lean 4 versions of add_monoid_with_one in parallel. The first version didn't have has_nat_cast, and that's the state that mathlib4 is in.

Gabriel Ebner (Nov 17 2022 at 19:42):

I think I've added has_nat_cast afterwards to make defining type class instances easier. (That is, you can set up the ℕ → R map without first proving that R is an additive monoid.)

Gabriel Ebner (Nov 17 2022 at 19:43):

So what we should do is backport (forward port?) the NatCast type class to mathlib4.

Yaël Dillies (Nov 17 2022 at 19:43):

Yes, from experience having has_nat_cast makes defining instances more comfortable.

Jireh Loreaux (Nov 17 2022 at 19:45):

Okay, so I should port has_nat_cast to a NatCasttype class. Got it.

Jireh Loreaux (Nov 17 2022 at 19:46):

Should it still go in data.nat.cast.defs? Or should I put it in Mathlib.Algebra.GroupWithZero.Defs?

Gabriel Ebner (Nov 17 2022 at 19:51):

I've also moved around the mathlib3 files long after the mathlib4 one was merged. One reason was to reduce the imports. So I think we should also have a Mathlib.Data.Nat.Cast.Defs split in mathlib4.

Jireh Loreaux (Nov 17 2022 at 20:30):

Currently, in mathlib3, add_monoid_with_one and has_nat_cast are both defined in data.nat.cast. In mathlib4, AddMonoidWithOne is defined in Mathlib.Algebra.GroupWithZero.Defs. Are you wanting me to move that? Sorry, I'm just not understanding the plan.

Jireh Loreaux (Nov 17 2022 at 20:34):

Nevermind, I think I understand now. I just read the details on #563. These things should move in mathlib4 to the places they appear in mathlib3.


Last updated: Dec 20 2023 at 11:08 UTC