Is there a fast way to create an evar in Ltac2? I currently use open_constr:(_ : $type)
but that incurs a huge cost if $type
is not obviously a Type/Prop.
Not that I know of. Note that for safety reason, even if we introduced such a function, it'd have to check that the type of the conclusion you provided it with is a sort.
We can always provide also an unsafe function, but it's a bit dangerous.
Unsafe is what I was hoping for. I already manage my universes manually so I might as well do the same with evars..
open_constr:(_ : ltac:(exact_no_check $type))
or something based on it might work
if $type is obviously a type you probably get significantly more overhead though
open_constr:(_ : ltac:(exact_no_check $type)) or something based on it might work
This does indeed speed things up. Thanks a lot!
I have another question. It seems that the open_constr
trick is flawed because the evar doesn't actually include the goal's hypotheses. (E.g. making the evar into a goal with Control.new_goal
and running typeclasses_eauto
on it will fail to select instances from the hypotheses.) But I cannot find another way to get an evar of a given type using the existing Ltac2 primitives. Am I missing something?
Ltac2 misses a lot of primitives, so if you find one you deem useful, do not hesitate to open an issue.
I shall write a bunch for the next release now that we start to have a consistent base of users.
I didn't mean it like "this should exist" (although I wish it did exist as a proper primitive) but more like "can anybody think of a workaround?"
Are you sure you're calling the open_constr thunk at the right moment?
AFAIR it should include all the current variables
I am in the middle of a horrible struggle with let-bindings inside inductive arities in a branch of mine so I cannot test, but I'd expect it to be the case.
I am not so sure any more what is going on. The evar has all hypotheses in its instance. I remembered that I could simply check that by printing it with Printing Existential Instances
. The problem must be elsewhere. Sorry for the false alarm!
(The problem seems to be a bug in typeclasses_eauto
.)
@Pierre-Marie Pédrot you might actually know what's going on here since you worked on this stuff recently: https://github.com/coq/coq/issues/13600
Oh, discriminated databases... I had almost managed to forget them.
Same behavior without discriminated
.
As already answered in the issue, I think this is normal actually. What other behaviour could you implement?
The union of transparent states is not commutative, just as the union of maps is not.
This is BTW some issue limiting the creation of a Hint Union
command.
I think we have too much stuff in our hint databases. They grew out of practicality, but that limits the algebraic operations you can perform on them.
I simply didn't read the documentation thoroughly. I wouldn't mind a more explicit user interface (an extra argument to typeclasses eauto
that sets that db apart from the others) but you can only do so much when users don't read the docs :(
Interestingly enough, the next tactic, autoapply
only uses its (unique) database argument for the transparency information.
Last updated: Oct 03 2023 at 20:01 UTC