Open madvorak opened 1 year ago
The relevant (top-level) code is in src/lean/Lean/Elab/Tactic/Rewrite.lean
and src/lean/Lean/Elab/Tactic/Location.lean
In the following, if loc
(the location) turns out to be Location.Wildcard
, then we want to somehow change that "actually, all locations, except these specific local hypotheses"
@[builtin_tactic Lean.Parser.Tactic.rewriteSeq] def evalRewriteSeq : Tactic := fun stx => do
let cfg ← elabRewriteConfig stx[1]
let loc := expandOptLocation stx[3]
withRWRulesSeq stx[0] stx[2] fun symm term => do
withLocation loc
(rewriteLocalDecl term symm · cfg)
(rewriteTarget term symm cfg)
(throwTacticEx `rewrite · "did not find instance of the pattern in the current goal")
Perhaps rewriteLocalDecl
could gain a flag allowSelf := true
that, if set to false, stops if term
is the local hypothesis. Then in evalRewriteSeq
quoted above we could set that flag according to whether loc \ne *
.
(It may be worth checking how Lean 3 handled this special case.)
Description
In Lean 4, if you use
rw [foo] at *
then it rewrites everything includingfoo
. If you hadfoo : x = y
then you obtainfoo : y = y
afterwards. It might happen thatfoo
would be useful again later. Afterrw [foo] at *
it is useless andfoo
only clutters the infoview.Steps to Reproduce
Expected behavior:
I think that
rw [hab] at *
should rewritea
only inhac
and the goal. This is how it worked in Lean 3.Actual behavior:
After
rw [hab] at *
you can see thathab : b = b
is in the infoview.Reproduces how often:
100 %
Additional Information
Lean 3 code
gives: