Canonical structures #2258
Replies: 3 comments
-
|
Looks promising! I haven't played with this, but I think @Alizter has. |
Beta Was this translation helpful? Give feedback.
-
|
BTW, another alternative is to first define the graph structure, and then to define the special name |
Beta Was this translation helpful? Give feedback.
-
|
Do you have a small reproducible example where making |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Today I was formalizing an equivalence of categories today between two categories
CandD. Both of the categories had concretely defined hom-types with their own namesC_HomandD_Hom, similarly to how the category ofGroupshas an associated typeGroupHomomorphismdefined; but one can also speak about them using the typeclass notation,Hom x y, where the instance is inferred. The theorems to be proved involved a mix of the two notations.I started running into some quite painful errors where unification was unable to solve simple things like
refine (alpha $@ _)because$@expects its first argument to be an element of something which is of the formHom x yby definition, but insteadalphawas a 2-cell of the "concrete" typeC_Hom2 f g, and unification was unable to solve for the missingIsGraphstructure such thatC_Hom2 x ywould have been the projection. Now after unification fails, typeclass search is launched, and it tries to instantiate the typeclass instances in a consistent way. But since the categoryDwas defined more recently thanC, it guessesisgraph_D is01cat_Detc. for all the typeclass holes, so unification fails again because it infers the wrong category. So, I had to add lots of annotations.I know that canonical structures can be used to solve for the record that a projection 'comes from', so I added:
Lo and behold, this worked like a charm, and suddenly I was able to remove all my annotations. I was pretty thrilled about this.
I originally had some fears that canonical structures and typeclasses would play together in unexpected and complex ways, leading to dynamics that are difficult to debug. I am no longer as worried about this, because canonical structures is part of unification whereas typeclasses is fairly separate from unification.
I hope this hint is helpful for others having unification woes!
Beta Was this translation helpful? Give feedback.
All reactions