Zulip Chat Archive

Stream: lean4

Topic: identity functor in Cat.{uβ‚€,vβ‚€}


Dean Young (Aug 21 2023 at 20:23):

This code gives me an error message:

invalid field 'obj', the environment does not contain 'Quiver.Hom.obj'
  πŸ™ C
has type
  C ⟢ C
variable {C : Cat.{uβ‚€,vβ‚€}}
#check (πŸ™ C).obj

Is seems it didn't infer the full functor but instead only a quantale. All this time I thought it was inferring the full functor.

Dean Young (Aug 21 2023 at 20:41):

Here's a similar error:

invalid field notation, type is not of the form (C ...) where C is a constant
  πŸ™ (AdjComDom Ο†)
has type
  CategoryStruct.toQuiver.1 (AdjComDom Ο†) (AdjComDom Ο†)

It should have type functor but it's not inferring it.

Adam Topaz (Aug 21 2023 at 20:50):

#mwe

Dean Young (Aug 21 2023 at 20:57):

This is the smallest portion of code which produces the "just a quiver" error:

variable {C : Cat}
#check (πŸ™ C)
#check (πŸ™ C).obj

I just need the identity functor is all but it won't infer it.

Jason Rute (Aug 21 2023 at 20:59):

It’s not a #mwe if you don’t have all the imports

Adam Topaz (Aug 21 2023 at 21:03):

import Mathlib.CategoryTheory.Category.Cat

open CategoryTheory

variable (C : Cat)

#check (πŸ™ C : C β₯€ C).obj

Adam Topaz (Aug 21 2023 at 21:05):

The issue you're facing is that Lean4 considers πŸ™ C as a morphism in Cat, as opposed to a functor. Of course morphisms in Cat are defined as the type of functors, but Lean4 has a hard time distinguishing the two without hints. If you want the identity functor as a functor, you can use 𝟭 C. E.g.:

import Mathlib.CategoryTheory.Category.Cat

open CategoryTheory

variable (C : Cat)

example : πŸ™ C = 𝟭 C := rfl

Last updated: Dec 20 2023 at 11:08 UTC