Zulip Chat Archive
Stream: general
Topic: coe_trans
Kenny Lau (Jul 12 2020 at 13:17):
instance coe_trans {a : Sort u₁} {b : Sort u₂} {c : Sort u₃} [has_coe_t b c] [has_coe a b] : has_coe_t a c
Kenny Lau (Jul 12 2020 at 13:17):
why doesn't this instance cause loops in typeclass search?
Floris van Doorn (Jul 12 2020 at 22:32):
When looking for has_coe_t a c
it first looks for instances for has_coe a ?m
(which should only be a finite list, if you know a
) and then looks for has_coe_t b c
so as long as we restrict the has_coe
instances enough (no cycles, adherence to this library note: https://leanprover-community.github.io/mathlib_docs/notes.html#use%20has_coe_t) there should not be a loop.
Floris van Doorn (Jul 12 2020 at 22:33):
(instance arguments are filled in from right-to-left, to speed-up the search for classes like algebra R A
).
Johan Commelin (Jul 13 2020 at 05:36):
But the trouble with algebra_trans
would come from the identity algebra R R
... that would cause loops anyway )-;
Kenny Lau (Jul 13 2020 at 05:48):
@Johan Commelin we can avoid that by having algebra_t R R
Kenny Lau (Jul 13 2020 at 05:49):
you won't ever have algebra R R
to cause the loop
Johan Commelin (Jul 13 2020 at 05:51):
Aah, and you are saying that we should only ever use algebra_t
?
But aren't we still going to run into non-defeq diamonds?
Johan Commelin (Jul 13 2020 at 05:52):
Like, I compose the algebra instance int -> rat
with rat -> real
, and this will not be defeq to int -> real
.
Johan Commelin (Jul 13 2020 at 05:52):
That's why I think we should have a typeclass like tower
or commutes
that expresses the provable equality of these instances.
Kenny Lau (Jul 13 2020 at 06:09):
fair
Last updated: Dec 20 2023 at 11:08 UTC