Zulip Chat Archive
Stream: mathlib4
Topic: rename_bvar is broken
Patrick Massot (Jan 14 2025 at 14:06):
Still frantically trying to prepare for teaching using Lean 4, I see the rename_bvar
teaching tactic is broken in mathlib4:
import Mathlib.Tactic
example (a b c : ℤ) (h1 : a ∣ b) (h2 : b ∣ c) : a ∣ c := by
rcases h1 with ⟨k, hk⟩
show ∃ k, c = a * k
rename_bvar k → m
sorry
Patrick Massot (Jan 14 2025 at 14:06):
Here it does nothing, presumably because there is already some k
in the context (but that’s the whole point of the tactic: renaming to avoid apparent notation clash).
Patrick Massot (Jan 14 2025 at 14:07):
As usual any help is much appreciated while I hunt down the next bug.
Michael Rothgang (Jan 14 2025 at 15:47):
When this bug gets fixed: it would be great to add this test; the rename_bvar tactic is drastically undertested. (#18139 only added some very basic test.)
Patrick Massot (Jan 14 2025 at 15:48):
This is the curse of teaching tactics: they are not tested in Mathlib. Usually they are tested in teaching libs before going to Mathlib. But here it was tested in Lean 3 teaching lib, PRed to mathlib3 and ported to Lean 4 without being tested.
Kyle Miller (Jan 14 2025 at 16:37):
This case was triggered by metavariables not being handled.
There's also a fix in case the issue was metadata, but I didn't add a test for this.
Patrick Massot (Jan 14 2025 at 17:43):
Thanks!
Kyle Miller (Jan 14 2025 at 17:55):
instantiateMVarDeclMVars
is a function that could be helpful to fix tactics like this in general (it's a hammer that instantiates all metavariables that appear in the local context and target of a particular goal). Added it to https://github.com/leanprover-community/mathlib4/wiki/Metaprogramming-gotchas
Last updated: May 02 2025 at 03:31 UTC