feat(Tactic/Linter): add auxLemma linter for auto-generated declaration references#37364
feat(Tactic/Linter): add auxLemma linter for auto-generated declaration references#37364
auxLemma linter for auto-generated declaration references#37364Conversation
PR summary 9036ce5439
|
| Files | Import difference |
|---|---|
| ../mathlib-ci/scripts/pr_summary/import_trans_difference.sh all | |
| There are 7884 files with changed transitive imports taking up over 342404 characters: this is too many to display! | |
You can run this locally from your mathlib4 directory: |
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
Declarations diff
+ auxLemmaLinter
+ isAuxName
+ matchesAuxPattern
+ nameRefersToAuxLemma
You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>
## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.
No changes to technical debt.
This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
- The
relativevalue is the weighted sum of the differences with weight given by the inverse of the current value of the statistic. - The
absolutevalue is therelativevalue divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
thorimur
left a comment
There was a problem hiding this comment.
Ah, this is great! :) These comments are mostly minor (style and naming), but I also extended what counts as autogenerated.
|
!bench |
|
Benchmark results for 5896be2 against 00fca21 are in. Significant changes detected! @thorimur Warning These warnings may indicate that the benchmark results are not directly comparable, for example due to changes in the runner configuration or hardware.
No significant changes detected. |
|
Hmm, maybe if you merge master, the bench will succeed. Let's try again after master is merged + the changes are applied. |
|
This pull request has conflicts, please merge |
…tion references Add a syntax linter that flags explicit references to auto-generated auxiliary declarations such as `_proof_N`, `match_N`, `_match_N`, and `_sizeOf_N`. These names are internal to the Lean elaborator and are not stable across refactors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5896be2 to
8261284
Compare
|
!bench |
|
Benchmark results for 8261284 against 9036ce5 are in. No significant results found. @thorimur
Small changes (1🟥)
|
Apply review suggestions from @thorimur: - move out of `Style` namespace and rename option to `linter.auxLemma` - broaden the matched prefix list (`_sizeOf_`, `grind_`, `_simp_`, `_gcongr_`, `_aux_`) - use `s.rawEndPos > pfx.rawEndPos`, `MonadLog.hasErrors`, `@[inline]` on `matchesAuxPattern`, and `@[inherit_doc]` on the linter - minor wording / docstring fixes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This PR adds a syntax linter that flags explicit references to auto-generated auxiliary declarations such as
_proof_N,match_N,_match_N, and_sizeOf_N. These names are internal to the Lean elaborator and are not stable across refactors (e.g. reordering fields in a structure can renumber_proof_indices).The linter matches precisely: it requires the suffix after the prefix to be all digits, so
_proof_helperwould not be flagged. It only inspects identifier syntax nodes, so references in comments and docstrings are ignored.Current hits in Mathlib (suppressed with
set_option linter.style.auxLemma false):Mathlib/CategoryTheory/Functor/Category.lean—hcomp._proof_2Mathlib/Analysis/Calculus/FormalMultilinearSeries.lean—constFormalMultilinearSeries.match_1.eq_2Mathlib/Data/List/Sigma.lean—_sizeOf_1Companion PR to track these suppressions in the tech debt report: leanprover-community/mathlib-ci#17
🤖 Prepared with Claude Code