Zulip Chat Archive

Stream: general

Topic: iso to is_iso for types


Adam Topaz (Nov 10 2021 at 23:01):

Is the following expected behavior?

import category_theory.types

universe u

variables {X Y : Type u} (f : X  Y)

variables {C : Type*} [category_theory.category C] {A B : C} (g : A  B)

example : category_theory.is_iso g.hom := infer_instance -- ok.

example : category_theory.is_iso f.hom := infer_instance -- fails

Kevin Buzzard (Nov 10 2021 at 23:15):

The iso symbols have different meanings right? I'm not at lean and haven't got my glasses on so can't see whether the squiggles are the same or not

Adam Topaz (Nov 10 2021 at 23:15):

Those are both category theory isos

Kevin Buzzard (Nov 10 2021 at 23:17):

So presumably X and Y are being promoted to terms

Kevin Buzzard (Nov 10 2021 at 23:18):

I see, and the point is that you can let A and B be those coerced terms and then the typeclass system finds it

Adam Topaz (Nov 10 2021 at 23:20):

Well, the A and B are terms in a type C (which has a category instance)

Adam Topaz (Nov 10 2021 at 23:21):

I'm just noting that when you have an isomoprhism e between two objects A and B in an arbitrary category C, then typeclass inference finds the is_iso e.hom instance. But when the category is Type u, this fails.

Kevin Buzzard (Nov 10 2021 at 23:23):

Oh of course you just let Type u be the category, oh I had completely misunderstood, I should go to bed

Andrew Yang (Nov 10 2021 at 23:40):

I've met this somewhere else. The thing is that the inference somehow finds (λ x, x) ≫ f.hom defeq to f.hom so it goes into an infinite loop.
using attribute [irreducible] category_theory.types fixes it for me, although I don't know if this causes more problem for you.

Adam Topaz (Nov 10 2021 at 23:44):

Hmm... That's strange.

I guess another option would be to do some bundling.

Johan Commelin (Nov 11 2021 at 06:20):

@Andrew Yang nice debug. This is quite a sad failure.

Floris van Doorn (Nov 11 2021 at 11:40):

This could be solved by setting priorities. Either or both of the following lines solve the issue, and could be added globally in the library:

attribute [instance, priority 900] category_theory.is_iso.comp_is_iso
attribute [instance, priority 1100] category_theory.is_iso.of_iso

Adam Topaz (Nov 11 2021 at 15:04):

#10276

Johan Commelin (Nov 11 2021 at 15:07):

Please leave a comment that explains the gist of this thread

Adam Topaz (Nov 11 2021 at 15:11):

done

Johan Commelin (Nov 11 2021 at 15:34):

@Adam Topaz I meant in the actual code. I left a suggestion.

Adam Topaz (Nov 11 2021 at 15:34):

Oh, gotcha


Last updated: Dec 20 2023 at 11:08 UTC