I want to override the reflexivity
tactic so that it does a bit more. This tactic is defined in the Ltac ML module. If I write Print Ltac
I can see that reflexivity
has the tactic value <ltac_plugin::reflexivity@0>
but I can't seem to access this myself?
I want to essentially rename the old reflexivity
to something else so I can still use it.
I think you can do Ltac old_reflexivity := reflexivity. Tactic Notation "reflexivity" := ...
and it should work correctly.
Or even Ltac old_reflexivity := reflexivity. Ltac reflexivity := ...
might work
Huh weird, I had initially tried your second suggestion, but I kept running into a stackoverflow. Now however, everything seems to work fine...
Oh wait this is still a problem
When I do your second suggestion and then do Print Ltac reflexivity.
it shows the plugin definition (at least outside the file)
If I instead use ::=
instead of :=
for the new reflexivity I get stackoverflow, since I am guessing the old_reflexivity now points to the new one.
Here is what I am trying to do:
Ltac old_reflexivity := reflexivity.
Ltac reflexivity := old_reflexivity
|| (intros;
let R := match goal with |- ?R ?x ?y => constr:(R) end in
let pre_proof_term_head := constr:(@reflexivity _ R _) in
let proof_term_head := (eval cbn in pre_proof_term_head) in
apply (proof_term_head : forall x, R x x)).
In a file that imports this, I do Print Ltac reflexivity
and I get the original definition (which is wrong?)
But as I mentioned if I use ::=
then this also changes the definition of old_reflexivity
to be circular
but the tactic notation seems to work!
Ali Caglayan said:
In a file that imports this, I do
Print Ltac reflexivity
and I get the original definition (which is wrong?)
Sounds like a bug, try making a stand-alone test-case and reporting it?
(Alternatively, you're running into an issue with import order)
May I ask why your improved-reflexivity tactic needs to be called exactly reflexivity?
Well I'm working on removing the copy of the coq prelude that the HoTT library has. One of the things the HoTT library does is redefine the reflexivity tactic. At the moment, this is done with a little bit of hackery.
I also can't seem to recreate this bug on its own.
Last updated: Oct 03 2023 at 19:01 UTC