Let the user customize autogenerated identifiers #20369
Labels
kind: wish
Feature or enhancement requests.
needs: triage
The validity of this issue needs to be checked, or the issue itself updated.
Is your feature request related to a problem?
Yes. Sometimes I make the mistake of referring to an autogenerated variable of type
Bob
, e.g. after it appears in my context asb2
after somedestruct
orinversion
. 10000 lines later, I decide thatBob
is a bad name, and change it toRob
. But then, the name of the variable becomesr0
. By the way, there used to be a variableb3 : Bamboo
which now got the nameb2
since it was freed. That easily escalates and now a simple rename turned into a major refactor.Proposed solution
Give the user control over the base identifier for generating fresh variables of a specific type.
This would make Coq automatically use the provided identifier, for example:
Goal Bob -> Bob -> False. intros. destruct bobTheVariable, bobTheVariable0.
For types with parameters, the leftmost applied name counts. Another way out of this is allowing matching types against patterns:
I wouldn't bother with reductions - the type should match like a normal
constr
. If you haveRob := Bob
andH : Rob * Rob
, you can always dodestruct (H : Bob * Bob)
or usechange
.A bit bold extension to this
Let the user do the generation on their own (performance is on them):
Alternative solutions
It can be already circumvented to some extent by explicitly naming all parameters in all definitions and lambdas, but it's not something you always want to do (especially in a functional language with pointfree obsession). You can also assign names while eliminating/introing, although my experience is that dealing with
inversion
while sticking to this kills my will of life. It also does not really solve the problem, because you need to severely maintain variable names across any code changes anyway.Additional context
I seriously ended up renaming the type to
bRob
in my project just to keep that madness away. I acknowledge that it was bad coding since the beginning, but I can hardly find a good way to conveniently avoid doing this (inversion
). It also seems that Coq encourages using autogenerated variables by looking at the standard library, tutorials, and examples in the docs.The text was updated successfully, but these errors were encountered: