Repository navigation
Conversation
PR summary 2031cb460c
|
| Files | Import difference |
|---|---|
| ../mathlib-ci/scripts/pr_summary/import_trans_difference.sh all | |
| There are 8685 files with changed transitive imports taking up over 379676 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 (regex)
+ Bar
+ C
+ Fn
+ Foo
+ Ind
+ MyAnd
+ MyBar
+ MyFn
+ MySubtype
+ allowsNumericProj
+ disallowedNumericProjFn?
+ numericProjFn?
+ numericProjections
+ upstreamAllowed
+ which
+ withAux
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.
Declarations diff (Lean)
✅ Lean-aware diff — post-build, computed from the Lean environment (commit
2031cb4).
- +3 new declarations
- −0 removed declarations
+Mathlib.Linter.allowNumericProjExt
+Mathlib.Linter.allowsNumericProj
+Mathlib.Linter.linter.style.numericProjectionsNo changes to strong technical debt.
No changes to weak technical debt.
Current commit 2031cb460c
Reference commit a97078fa10
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.py 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).
These commands made the changes in this commit. To make the same fixes yourself, run them in your mathlib4 checkout.
JovanGerb
left a comment
There was a problem hiding this comment.
Thanks, the approach of this PR looks goot to me
…g asked an unrelated question. sure. that's fine. sigh.
| throwError "Expected `{.ofConstName n}` to be a structure.") | ||
|
|
||
| /-- We can't add to a tag attribute later on, so hardcode the upstream exempt declarations here. -/ | ||
| def upstreamAllowed := #[``Prod, ``PProd, ``Sigma, ``PSigma, ``And, ``Iff, ``Subtype, ``Fin] |
There was a problem hiding this comment.
This is something that requires a thorough Zulip discussion first, but I would like to propose that we restrict this list to
| def upstreamAllowed := #[``Prod, ``PProd, ``Sigma, ``PSigma, ``And, ``Iff, ``Subtype, ``Fin] | |
| def upstreamAllowed := #[``Prod, ``PProd, ``Sigma, ``PSigma] |
This would of course require many fixes in Mathlib before it can be compliant.
For the ones that I removed in the suggestion above, it is usually easier to tell the type of the object from the source when the projection is named. One of the pain point with eg. Subtype is that many types are def-eq to some subtype, and in the source you will often encounter x.1 for some x in such a type that you might not know to be a subtype of the top of your head . It takes longer to human-parse x.1 than it takes to understand x.val, which makes it immediately clear that x is some subtype-like object. similarly, x.property makes it immediate that you are looking at some property while x.2 will take longer to parse and will not make clear that you are looking at a proof.
There was a problem hiding this comment.
I never use numeric projections so I'd even support making it empty, but I think realistically such a linter won't get support without allowing the basics.
btw on the flip side, perhaps Complex and QuaternionAlgebra should be allowed since they're meant to be tuples.
There was a problem hiding this comment.
Of the ones you propose to remove, I'm not so sure about And, because I think of And as a tuple, and like to write .1/.2 for it.
There was a problem hiding this comment.
Perhaps the best way to navigate any such decision here will be to only lint against the really uncontroversial ones first, then gradually shrink the list :)
There was a problem hiding this comment.
Good point, but I still think Iff and And are quite uncontroversial.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the wrapped `ULift.down` field
Whitespace-only: wrap lines over 100 characters introduced by the `scripts/runSkimmer.sh` rewrite. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This pull request is no longer linked; it will merge on its own. |
…mathlib (#45389) This PR replaces numeric projections such as `.2` with the named version of that projection, with the exception of certain types. This was generated using `scripts/runSkimmer.sh` in the output of #45341, plus some manual fixes and an LLM whitespace-only fix for handling (hundreds of) long lines. Co-authored-by: Jireh Loreaux <[email protected]>
|
This PR/issue depends on: |
Takes num-proj-lint-skimmer (leanprover-community#45389) from upstream/master, where it has landed.
|
@thorimur @robin-carlier The question has been discussed in the maintainers stream and we came to the conclusion that this linter is certainly very useful and we'd like it to be merged. Concerning the exceptions, it was noted that for ``Prod, ``PProd, ``Sigma, ``PSigma, ``And, ``Iffusing numbers is pretty uncontroversial, since also for All in all, I'm delegating this with the request that the list of exceptions be ``Prod, ``PProd, ``Sigma, ``PSigma, ``And, ``Iff``Thanks once more for all your work! |
|
bors d+ |
|
✌️ thorimur can now approve this pull request until 2026-12-02 10:24 UTC (in 2 weeks). To approve and merge, reply with
|
|
@faenuccio Great, thanks so much! :) I am wondering: is Further I am wondering if logistically it would make sense to merge this PR now with the current list of exemptions (to prevent Mathlib from introducing any more numeric projections in the meantime), and then shrink the list immediately in a follow-up PR (which may acquire merge conflicts quickly), namely #46196 (to which I'll add |
|
#46196 is now stacked on #45341: both are in a linked bundle and merge in the same batch, or not at all. The batch applies #45341's changes first. Each pull request still needs its own Review: #46196's own changes: the diff of #46196 without #45341's changes. View this bundle in bors (sign in with GitHub to view). |
|
This pull request is no longer linked; it will merge on its own. |
|
Oh, wow, just non-exempting Would it be reasonable to do the following:
|
Yes, this is perfectly reasonable. |
|
Thanks for the last-minute review @Deicyde ! :) |
|
bors r+ |
This PR lints against numeric structure projections such as `foo.42`, and interactively suggests replacing them with the appropriate field name projection instead. This was discussed [on Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Linting.20against.20numeric.20projections/with/635575542). Structures may be exempted from the linter and permitted to use numeric projections by either attaching `@[allow_numeric_proj]` to the structure at the point it was defined, or by hardcoding them into the linter's list of exceptions (if they were defined upstream). This PR allows terms whose types begin with ``` Prod, PProd, Sigma, PSigma, And, Subtype, Fin, Complex, Quaternion ``` to use numeric projections. This also allows type definitions wrapping these types to use numeric projections, as only the projection itself is looked at. (This may be changed in the future.) However, note that `Subtype` and `Fin` will be non-exempted shortly. We also update the Archive and Counterexamples. Disclosure: although I don't use Claude to write important code, it so happened that Claude edited a key part of the file without being asked, after simply being asked to locate certain API(!). However, the resulting changes were sensible, so I've retained them. Claude also (this time on request!) assisted with testing the many situations in which numeric projections can appear. Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jireh Loreaux <[email protected]>
|
I'll also note here that merging now and then addressing Subtype/Fin in a subsequent PR was maintainer-approved over on Zulip (same thread as in PR description). |
|
Pull request successfully merged into master. Build succeeded: |
This PR lints against numeric structure projections such as `foo.42`, and interactively suggests replacing them with the appropriate field name projection instead. This was discussed [on Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Linting.20against.20numeric.20projections/with/635575542). Structures may be exempted from the linter and permitted to use numeric projections by either attaching `@[allow_numeric_proj]` to the structure at the point it was defined, or by hardcoding them into the linter's list of exceptions (if they were defined upstream). This PR allows terms whose types begin with ``` Prod, PProd, Sigma, PSigma, And, Subtype, Fin, Complex, Quaternion ``` to use numeric projections. This also allows type definitions wrapping these types to use numeric projections, as only the projection itself is looked at. (This may be changed in the future.) However, note that `Subtype` and `Fin` will be non-exempted shortly. We also update the Archive and Counterexamples. Disclosure: although I don't use Claude to write important code, it so happened that Claude edited a key part of the file without being asked, after simply being asked to locate certain API(!). However, the resulting changes were sensible, so I've retained them. Claude also (this time on request!) assisted with testing the many situations in which numeric projections can appear. Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Jireh Loreaux <[email protected]>
This PR lints against numeric structure projections such as
foo.42, and interactively suggests replacing them with the appropriate field name projection instead. This was discussed on Zulip.Structures may be exempted from the linter and permitted to use numeric projections by either attaching
@[allow_numeric_proj]to the structure at the point it was defined, or by hardcoding them into the linter's list of exceptions (if they were defined upstream).This PR allows terms whose types begin with
to use numeric projections. This also allows type definitions wrapping these types to use numeric projections, as only the projection itself is looked at. (This may be changed in the future.)
However, note that
SubtypeandFinwill be non-exempted shortly.We also update the Archive and Counterexamples.
Disclosure: although I don't use Claude to write important code, it so happened that Claude edited a key part of the file without being asked, after simply being asked to locate certain API(!). However, the resulting changes were sensible, so I've retained them. Claude also (this time on request!) assisted with testing the many situations in which numeric projections can appear.
Note: the linter itself + Archive/Counterexample changes may be reviewed via the bors stack link, and review comments may be added from there too. See also the bors stack comment.