Zulip Chat Archive

Stream: mathlib4

Topic: coe conflict in concrete categories


Yury G. Kudryashov (May 31 2023 at 19:41):

We have docs4#ConcreteCategory.hasCoeToSort. OTOH, for some bundled concrete categories we have coercions like docs4#CommRingCat.instCoeSortCommRingCatType

Yury G. Kudryashov (May 31 2023 at 19:43):

Since Lean 4 unfolds coercions, instances defined for one of these coercions (e.g., CommRing) won't work for the other.

Yury G. Kudryashov (May 31 2023 at 19:43):

Probably, Lean 3 was able to see that two has_coe_sort instances are defeq.

Yury G. Kudryashov (May 31 2023 at 19:46):

I see two possible solutions:

  1. Define ConcreteCategory.α or ConcreteCategory.Carrier and use it instead of X.α everywhere.
  2. Redefine ConcreteCategory so that coercions is an outParam argument and supply Bundled.α in the Bundled instance.

Yury G. Kudryashov (May 31 2023 at 19:46):

Do I miss some better solution?

Yury G. Kudryashov (May 31 2023 at 19:47):

The second approach would force us to unfold the definition of a Functor in ConcreteCategory.

Yury G. Kudryashov (May 31 2023 at 19:47):

While the first one drops very convenient X.α.

Yury G. Kudryashov (Jun 04 2023 at 23:50):

Ping here

Jujian Zhang (Jun 05 2023 at 01:30):

Also there are conflict about function coercion, there is ConcreteCategory.hasCoeToFun and coercion from FunLike instances when CommRing or similiar categories are in considerations. See also here

Scott Morrison (Jun 05 2023 at 06:03):

@Yury G. Kudryashov, could you point to a situation where there is a problem because of these two unrelated coercions? Sorry, I'm still trying to understand what's going on here.

Yury G. Kudryashov (Jun 05 2023 at 06:03):

In !4#4531

Yury G. Kudryashov (Jun 05 2023 at 06:04):

Sorry, let me check

Yury G. Kudryashov (Jun 05 2023 at 06:04):

Yes, in !4#4531

Yury G. Kudryashov (Jun 05 2023 at 06:04):

This file enables (locally) the generic coercion

Yury G. Kudryashov (Jun 05 2023 at 06:05):

But some instances assume the Bundled-specific coercion.

Yury G. Kudryashov (Jun 05 2023 at 06:05):

In Lean 3, both were hidden behind coe and were defeq.

Yury G. Kudryashov (Jun 05 2023 at 06:06):

Here they're still defeq but instances can no longer see it.


Last updated: Dec 20 2023 at 11:08 UTC