Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carve out Algebra, Data and Order sublibraries #11757

Open
YaelDillies opened this issue Mar 28, 2024 · 1 comment
Open

Carve out Algebra, Data and Order sublibraries #11757

YaelDillies opened this issue Mar 28, 2024 · 1 comment
Assignees

Comments

@YaelDillies
Copy link
Collaborator

YaelDillies commented Mar 28, 2024

The bottom part of mathlib is quite a mess. Algebra, data structures and order theory could be developed separately (at least for a while) but are not. Instead, "horizontal" imports keep happening between what would otherwise be three disjoint trees.

The main sources of trouble are

  • Nat and Int, as they are ubiquitous. Their basic properties can be accessed through typeclass-mediated lemmas by importing Data.Nat.Basic and Data.Nat.Order.Basic. However this comes at the cost of importing basic algebra or basic algebraic order theory where unnecessary. Instead, we can use the Nat- and Int-specific lemmas provided by Std.
  • Many pure algebraic/order theoretic/data structuresque files import non-pure algebraic/order theoretic/data structuresque files just to prove a few properties of an object defined in the non-pure file. In that case, the import can be reversed so that the pure file has pure imports.
  • Misplaced files. Eg Polynomial, Real or Set.Icc are defined under Data. The solution is to simply move them to the correct top-level folder.

The purpose of this issue is to collect the PRs doing at least one of the above:

Once all these issues will be fixed, we will be able to create three new Lean libraries Algebra, Data, Order, all still living in the current repository.

After such a split, these sublibraries would form a DAG in terms of dependencies. This adds some constraints to future refactors, as that DAG would essentially become immutable.

The benefits?

  • working towards it requires drastically cleaning up the import graph, which currently is full of "horizontal gene transfer".
  • the sublibrary DAG being immutable is also helpful: it prevents some dependency regressions!
  • even though everything will remain in one repository (this is important to minimise the cost of cross-repository refactors), it will be possible in lake to specify that you only want to depend on a subset of these libraries.
@YaelDillies YaelDillies self-assigned this Mar 28, 2024
@eric-wieser
Copy link
Member

it will be possible in lake to specify that you only want to depend on a subset of these libraries.

I don't understand why this is useful. Already, if you do lake build in your project, it only builds the bits of mathlib that you actually import. You can use lake exe cache in a similar way. So the "unused" bits of mathlib are already not meaningfully "depended" on.

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

No branches or pull requests

2 participants