How to add variables introduced by set tactic to a Hint DB?
Question
I want to use a Hint DB with variables introduced by set. For example,
forall n : nat, n + n = n + nforall n : nat, n + n = n + nn: natn + n = n + nn: nat
m:= n + n: natm = m
Is there any way to achieve this, or is it impossible?
Answer
It's not possible to do this like you suggested because after you finish foo with Qed the local variable m will be out of scope, but hints go straight into some global database.
However, you can use the Section mechanism, as the hints declared inside a section are local to that section:
Section LocalHints. Variable n : nat. Let m := n + n.n: nat
m:= n + n: natm = mn: nat
m:= n + n: natm = mreflexivity. Qed. End LocalHints.n: nat
m:= n + n: natn + n = n + n