Zulip Chat Archive

Stream: new members

Topic: CoeDep instance for Fin n


Julia Scheaffer (Sep 27 2025 at 23:40):

Is an instance like this a bad idea?

instance {n m : Nat} : CoeDep Nat n (Fin (n + Nat.succ m)) where
  coe := Fin.mk n (by omega)

I wanted it for some code I was writing and managed to generalize it in a way, but I think this might not be good for lean for some reason.

Aaron Liu (Sep 27 2025 at 23:43):

we got rid of the global Nat \to Fin coercion because it was messing with type inference

Aaron Liu (Sep 27 2025 at 23:43):

you could have something go Fin -> Nat -> Fin

Julia Scheaffer (Sep 27 2025 at 23:43):

Ah, i figured something like that might be the case

Aaron Liu (Sep 27 2025 at 23:43):

this seems like it's reintroducing the problem

Julia Scheaffer (Sep 27 2025 at 23:43):

lol yes probably

Julia Scheaffer (Sep 27 2025 at 23:44):

okay, i will just inline it. It's not like i'm using it that much yet, it just seemed like it would be possible

Julia Scheaffer (Sep 27 2025 at 23:46):

A CoeDep instance would stop it from chaining coercions together, right?

Aaron Liu (Sep 27 2025 at 23:47):

oh yeah

Aaron Liu (Sep 27 2025 at 23:47):

but you could have a coercion applied to a bound variable which is then instantiated with another coercion

Julia Scheaffer (Sep 27 2025 at 23:48):

This project is my first time using coercions, so I dont understand the system very well yet.


Last updated: Dec 20 2025 at 21:32 UTC