chore: Init.lean and some related refactoring - #625
Open
alvinylt wants to merge 18 commits into
Open
Conversation
This avoids having to make exceptions regarding how code is organised
… importing `Init.lean`
…gData.lean` CI fails with them as modules
No exception for `Iris/ProofMode/Porting.lean`
Contributor
Author
|
For reference, I tried enabling
So here's my idea: instead of gradually adopting the linter by tweaking it to ignore some modules, we can perhaps create an issue listing the linter options we’d like to enable. This way we avoid having to deal with complicated module dependencies, and we don't have decide what linter features to adopt all at once. |
MackieLoeffel
approved these changes
Aug 13, 2026
MackieLoeffel
left a comment
Collaborator
There was a problem hiding this comment.
This looks good to me. I also like the idea of enabling the linters one at a time. @markusdemedeiros @lzy0505 Do you have thoughts on this PR?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Several sets of changes to align with conventions in Lean, Mathlib and Iris-Rocq, as well as to prepare for the linter setup.
Init.leanas the Initial ModuleA follow-up on #552 (comment).
Similar to
Init.leanin Mathlib, this module is imported by all modules within the project (except by the modules listed inInit.lean, obviously). Mathlib's documentation forInit.leanexplains how it is used. In particular, linter modules can be imported here to enable them throughout the project in the future.As our plan is to adopt linting gradually (see #445 (comment)),
Init.leanalong with the recent overhaul of linter configurations in Lean 4.32 makes the setup a lot easier. I have been doing some experiments with the linters in a separate branch, and it seems to be the case that we can simply toggle some options to choose what built-in/Batteries linters to use. The code style linters are trickier as they are located within Mathlib. We can perhaps consider porting some of those linter modules intoIris/Stdif needed.Besides linting setup, the immediate benefit of having
Init.leanis that we are now able to remove imports ofIris.Std.RocqPortingscattered around in the project. Some 50+ unnecessary imports are removed as a result.Commits: 73fd66d, e5626e5, 3e99009
Extending the Script for
Init.leanA follow-up on #589.
The script is now able to check two requirements:
Iris.leanimports all modules (existing feature).Init.lean(new feature in this PR).There are now several valid ways to use the script:
With the option
--minimal-init, one immediately gets a list of modules that would satisfy the check.The CI script is updated to run
lake exe check-imports Irisandlake exe check-imports --entry-points-only IrisMath.In case there is a need for the same feature but only for a submodule, then one can create
Init.leanunder the subdirectory (e.g.Iris/Algebra/Init.lean), and the script run (e.g.lake exe check-imports Iris.Algebra) works exactly the same.@lzy0505
I'm makingThe CI run fails with the latter being a module ofIris/ProofMode/Porting.leanandIris/Std/DumpPortingData.leanmodules so that the script does not have to make exceptions for them. Is this change reasonable?Iris. However, it works if we moveDumpPortingData.leantoscripts/, alongsideCheckImports.lean.Commits: 73fd66d, 0bae996, bbf29ce, 04d42bd, 055a536
Moving Test Directories and Test Driver Setup
Currently the tests are located under the directories
Iris/Iris/Tests/andIris/IrisMath/Tests/, with the tests built as part of theIrismodule and under theIrisnamespace.My suggestion is to relocate them to
Iris/IrisTest/andIris/IrisMathTest/. This aligns with how the code in Iris-Rocq and Mathlib are organised.iris/iris/(e.g.iris/iris/algebra,iris/iris/bi) while tests are located underiris/tests.MathlibandMathlibTestare both top-level directories in the Mathlib repository.As a side note, the existing
lakefile.tomlalready has the following setup (even thoughIrisTestdoes not exist as a directory).For some reason,
lake builddoes not throw any error, which is why we have never been aware of the issue so far. However, other tools such aslake shakecomplains about the missing directory.Upon relocating the tests, my suggestion is to update
lakefile.tomlwith the following:Then,
lake buildbuilds the core Iris modules underIris/, whilelake testruns the tests underIrisTest/(after buildingIris, if not up-to-date). Same as in Mathlib.The CI specifically has the infrastructure for tests:
Commits: cb9a0e2, 6c7771e
Remove Unnecessary Imports
lake shakeoffers some useful suggestions, but it is not desirable to apply all of them directly. So I've manually gone through some suggestions and removed plenty of unnecessary imports. In particular, there are lots of redundantmeta importdeclarations (some of those modules do not involve metaprogramming at all).Commits: 2bae2c0, 4090f72
Checklist
authorssection of any appropriate files