Zulip Chat Archive
Stream: mathlib4
Topic: undetected unused instance arguments
Jovan Gerbscheid (Jun 08 2024 at 00:21):
The functions ContinuousMultilinearMap.norm_mkPiAlgebraFin
and ContinuousMultilinearMap.norm_mkPiAlgebraFin_le_of_pos
contain some unused type class arguments, but these are not detected by the unused variable linter, because they technically are used in the definition. In the first case, the definition starts like this:
theorem norm_mkPiAlgebraFin [NormOneClass A] :
‖ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A‖ = 1 := by
cases n
here, the tactic cases n
causes all n
in the local context to be replaced by Nat.zero
. It does this for all variables introduced with a variable
command that contain n
, and thus forces these variables to be used in the current declaration, even though some of these variables are not necessary at all.
This particular case can easily be fixed, but I wonder if there is a better way to detect this kind of mistake?
Kevin Buzzard (Jun 08 2024 at 00:38):
See lean4#2452
Yury G. Kudryashov (Jun 08 2024 at 04:21):
It looks like the only way we can deal with it until hte bug is fixed is to minimize variable
s for each section instead of having a long variable
declaration at the top of the file with all variables that will be needed below.
Jovan Gerbscheid (Jun 08 2024 at 05:42):
Here's a fix for this particular case: #13628
Yury G. Kudryashov (Jun 08 2024 at 05:54):
Delegated
Last updated: May 02 2025 at 03:31 UTC