Skip to content

chore: remove or annotate import alls - #42462

Draft
thorimur wants to merge 3 commits into
leanprover-community:masterfrom
thorimur:chore-easy-import-all
Draft

chore: remove or annotate import alls#42462
thorimur wants to merge 3 commits into
leanprover-community:masterfrom
thorimur:chore-easy-import-all

Conversation

@thorimur

@thorimur thorimur commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This PR removes immediately removable import all and adds a comment to un-annotated unremovable import alls explaining what they're for (except for import all Mathlib.NumberTheory.Height.Basic in Mathlib.NumberTheory.Height.MvPolynomial, which seems to depend on multiple parts of the private interface).


Open in Gitpod

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

PR summary 5d653388ef

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Lean.Meta.RefinedDiscrTree.Encode 63 61 -2 (-3.17%)
Mathlib.Tactic.GCongr.Core 83 82 -1 (-1.20%)
Mathlib.Data.Int.Bitwise 403 400 -3 (-0.74%)
Mathlib.Control.Monad.Cont 139 138 -1 (-0.72%)
Mathlib.Data.Fintype.Parity 464 461 -3 (-0.65%)
Mathlib.Tactic.PNatToNat 489 486 -3 (-0.61%)
Mathlib.Tactic.FieldSimp.Discharger 514 512 -2 (-0.39%)
Import changes for all files
Files Import difference
../mathlib-ci/scripts/pr_summary/import_trans_difference.sh all
There are 7723 files with changed transitive imports taking up over 342728 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)

No declarations were harmed in the making of this PR! 🐙

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 5da66e9).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit 5d653388ef
Reference commit 4d6f98930f

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 relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@thorimur

thorimur commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Aug 4, 2026

Copy link
Copy Markdown

Benchmark results for d213f73 against 4d6f989 are in. No significant results found. @thorimur

  • 🟥 build//instructions: +9.1G (+0.01%)

Small changes (1✅)

  • build/module/Mathlib.Tactic.GCongr.Core//instructions: -885.0M (-4.02%)

@felixpernegger

Copy link
Copy Markdown
Contributor

See also #41389 :')

module

import all Lean.Meta.Tactic.Simp.Rewrite
import all Lean.Meta.Tactic.Simp.Rewrite -- for `Simp.dischargeUsingAssumption?`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you are at it, can you order the imports in these files accordingly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I'd say yes, I'd rather keep this PR tightly focused for easy review (and not be too much of a time sink for me!) and leave import reordering to other PRs if that's alright :)

@thorimur

thorimur commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

See also #41389 :')

Oops, so sorry to overlap! 😅

It'll be interesting to see if the bench comes back differently.

@thorimur

thorimur commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Hmm, a smaller increase than the other PR, but still not green on instructions overall. Very weird.

@felixpernegger

Copy link
Copy Markdown
Contributor

Hmm, a smaller increase than the other PR, but still not green on instructions overall. Very weird.

0.01% is small enough that if you run it again after empty commit, it might just get green. (generally everything under <0.07% or so I'd say)

@thorimur
thorimur marked this pull request as draft August 5, 2026 19:30
@mathlib-bors

mathlib-bors Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This pull request is now in draft mode. No active bors state needed cleanup.

While this PR remains draft, bors will ignore commands on this PR. Mark it ready for review before using commands like bors r+ or bors try.

@thorimur

thorimur commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

But I'm still confused as to why yours takes a hit and mine doesn't 🤔 As far as I can tell the only two changes are (1) Cont, which I missed! (2) a bitwise reduction (3) how I also removed a DiscrTree import (ideally, this should not affect anything, since it's dragged in at the same visibility by a later import).

I'm going to test out these two changes, see what happens, then one way or another close this PR and maintainer merge yours :) Would you mind grabbing the three annotations from this PR?

@thorimur

thorimur commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Aug 5, 2026

Copy link
Copy Markdown

Benchmark results for 5da66e9 against 4d6f989 are in. No significant results found. @thorimur

  • 🟥 build//instructions: +12.9G (+0.01%)

Small changes (1✅)

  • build/module/Mathlib.Tactic.GCongr.Core//instructions: -882.1M (-4.00%)

@thorimur

thorimur commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar

leanprover-radar commented Aug 5, 2026

Copy link
Copy Markdown

Benchmark results for 5d65338 against 4d6f989 are in. No significant results found. @thorimur

  • 🟥 build//instructions: +251.7M (+0.00%)

Small changes (1✅)

  • build/module/Mathlib.Tactic.GCongr.Core//instructions: -904.2M (-4.10%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants