Zulip Chat Archive

Stream: general

Topic: has_nat_cast


Violeta Hernández (Jun 26 2022 at 15:58):

What's up with this new typeclass? What's the purpose?

Violeta Hernández (Jun 26 2022 at 15:58):

It doesn't seem to introduce notation, and I'm not sure what lemmas it could possibly introduce

Violeta Hernández (Jun 26 2022 at 16:00):

Was it not desirable to have nat.unary_castautomatically defined?

Yaël Dillies (Jun 26 2022 at 16:00):

It's to provide coe : ℕ → α. It was formerly deduced from [has_zero α] [has_one α] [has_add α]. Relevant PR is #12182.

Yaël Dillies (Jun 26 2022 at 16:01):

The problem is that we want coe : ℕ → ℕ to be defeq to id, coe : ℕ → ℤ to be defeq to docs#int.of_nat, coe : ℕ → with_bot ℕ to be defeq to the other coe : ℕ → with_bot ℕ (so defeq to some), etc...

Violeta Hernández (Jun 26 2022 at 16:01):

Oh, that makes sense.

Violeta Hernández (Jun 26 2022 at 16:02):

image.png Shouldn't this be has_nat_cast instead of has_coe?

Violeta Hernández (Jun 26 2022 at 16:02):

Or is the idea that you only use has_nat_cast for monoids or some other algebraic structure stronger than what pre-games are?

Yaël Dillies (Jun 26 2022 at 16:02):

Probably it should, yeah.

Eric Wieser (Jun 26 2022 at 16:18):

Is docs#add_monoid_with_one true for pgame?

Kevin Buzzard (Jun 26 2022 at 16:43):

I'm not even sure addition is associative on pgame, and really one could argue that there are many candidates for one. The idea is that game is a more sensible notion; pgame is some kind of auxiliary notion used in the construction of game.

Gabriel Ebner (Jun 26 2022 at 17:01):

Shouldn't this be has_nat_cast instead of has_coe?

It could be, but it doesn't buy you much. All the nat.cast lemmas require add_monoid_with_one, which pgame isn't.

Violeta Hernández (Jun 26 2022 at 22:03):

Addition isn't neither commutative nor associative on pgame!

Violeta Hernández (Jun 26 2022 at 22:04):

I do disagree with there being many candidates for 1, {{ | } | } with the obvious indexing types seems like the only reasonable choice

Violeta Hernández (Jun 26 2022 at 22:06):

But that's a whole other topic

Eric Rodriguez (Jul 06 2022 at 18:30):

is it worth making one of these for the redefinition of char_p? Or should I just inline it into char_p?

Eric Wieser (Jul 06 2022 at 18:33):

I think just inline it

Eric Wieser (Jul 06 2022 at 18:33):

Since it would be the only data field

Eric Rodriguez (Jul 06 2022 at 18:40):

I was also going to set defn control of smul, although I guess there's no real point as usually for charp the cast will just be x smul 1

Eric Wieser (Jul 06 2022 at 19:34):

The main reason for has_nat_cast (if my understanding is correct) is to make things like docs#function.injective.monoid easy to state


Last updated: Dec 20 2023 at 11:08 UTC