Skip to content

chore: minimize all imports#160

Merged
fmontesi merged 8 commits into
leanprover:mainfrom
chenson2018:min-imports
Nov 19, 2025
Merged

chore: minimize all imports#160
fmontesi merged 8 commits into
leanprover:mainfrom
chenson2018:min-imports

Conversation

@chenson2018

@chenson2018 chenson2018 commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator

This PR does the following:

  • remove a full import Mathlib from Cslib.Foundations.Lint.Basic that was then transitively imported everywhere
  • add import Mathlib.Tactic.Common to Cslib.Init.lean so that we don't need to manually import these tactics each time while also reducing the number of build jobs
  • when appropriate, change the imports of every file to match what is given by lake exe shake or record an exception in scripts/noshake.json
  • Add lake exe shake in CI to maintain this going forward.

@ctchou ctchou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

@ctchou

ctchou commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator

Presumably you used a script to identify the changes in this PR? If so, perhaps that script can be added to the repo so that everyone can run it. I for one often forget to run #min_imports.

@chenson2018

Copy link
Copy Markdown
Collaborator Author

I actually did this by hand because it wasn't that long... but now that you mention it, I think lake exe shake Cslib works here. Let me try to set it up...

@chenson2018 chenson2018 requested a review from kim-em as a code owner November 17, 2025 19:53
@chenson2018

chenson2018 commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator Author

Okay, that was pretty simple, great idea @ctchou!

Now if you run lake exe shake Cslib, it will list what imports should be changed and I have added this as a check to CI. Any false positives due to typeclasses and tactics can be excluded by listing them in scripts/noshake.json (which has a couple of examples already).

This slightly conflicts with imports in #157 and #158. Probably easier to review/merge those first.

@chenson2018

Copy link
Copy Markdown
Collaborator Author

On second thought, if the notation changes in those other PRs are problematic maybe we should merge this first to minimize merge conflicts.

@chenson2018

Copy link
Copy Markdown
Collaborator Author

At Kim's suggestion I have changed Mathlib.Tactic to Mathlib.Tactic.Common. Altogether this drastically reduces the number of build jobs from ~7000 to ~1600!

@fmontesi As an added bonus, this removes the syntax conflicts in #157 and #158! I still slightly worry that it could cause trouble down the line, but we are not forced to make that decision now (and it is relatively simple to change) so I am closing those PRs for now.

@fmontesi fmontesi merged commit d11dbb6 into leanprover:main Nov 19, 2025
5 checks passed
thomaskwaring pushed a commit to thomaskwaring/cslib_SKI that referenced this pull request Apr 6, 2026
This PR does the following:

- remove a full `import Mathlib` from `Cslib.Foundations.Lint.Basic`
that was then transitively imported everywhere
- add `import Mathlib.Tactic.Common` to `Cslib.Init.lean` so that we
don't need to manually import these tactics each time while also
reducing the number of build jobs
- when appropriate, change the imports of every file to match what is
given by `lake exe shake` or record an exception in
`scripts/noshake.json`
- Add `lake exe shake` in CI to maintain this going forward.
benbrastmckie pushed a commit to benbrastmckie/cslib that referenced this pull request Jun 14, 2026
This PR does the following:

- remove a full `import Mathlib` from `Cslib.Foundations.Lint.Basic`
that was then transitively imported everywhere
- add `import Mathlib.Tactic.Common` to `Cslib.Init.lean` so that we
don't need to manually import these tactics each time while also
reducing the number of build jobs
- when appropriate, change the imports of every file to match what is
given by `lake exe shake` or record an exception in
`scripts/noshake.json`
- Add `lake exe shake` in CI to maintain this going forward.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntax elaboration conflicts Notation conflict with Mathlib.Finsupp (both use →₀)

4 participants