Open jdchristensen opened 4 years ago
I am not able to run anything at the moment, but what does Typeclass debug say when you try isequiv_compose with high priority?
Now that I think about it, I would have thought typeclasses would try to insert idmap for isequiv_compose but then realise it got the exact same goal and backtrack?
Since this was discussed in a merged pull request, #1204, I thought I should record a few things in an issue so they aren't lost. See #1204 for some more info.
Based on what I see with
Typeclasses eauto := debug
set, Coq spends time trying lots of other things before tryingisequiv_compose
when trying to showIsEquiv (g o f)
. If the priority of the instance is made too high, then I think Coq will also tryisequiv_compose
when trying to proveIsEquiv f
because it will insert an identity function. (Recall thato
is a notation andg o f
is definitionally equal tof
wheng
isfun x => x
.) So it's not simply a matter of making the priority higher.Ideas for what might work:
But will Coq still try the identity map with these?
Another idea is for the user to be more explicit. For example, in some cases writing
equiv_compose g f
instead ofg o f
makes things fast because it forces Coq to useisequiv_compose
right away.oE
is a notation forequiv_compose'
, but we could introduce a notation forequiv_compose
and use it in such situations.Another idea would be to define:
and then use
Eq g oE Eq f
instead ofg o f
. It does seem to work in a few tests that I did. If we only need this for composition, then an alternative tooE
is probably cleaner. But if we want to upgrade maps to equivalences more generally, thenEq
will work. There are lots of places in the library whereBuild_Equiv _ _ foo _
could be replaced byEq foo
.I see now that #1165 has an idea similar to my
Eq
idea as part of a more general framework.