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

[Merged by Bors] - chore(*): reduce imports #3235

Closed
wants to merge 12 commits into from
Closed

Conversation

semorrison
Copy link
Collaborator

The RFC pull request simply removes some import tactic or import tactic.basic, and then makes the necessary changes in later files to import things as needed.

I'm not sure if it's useful or not --- the reason I did it was to try to make life a bit easier while working on tactics/ files, to reduce the recompilation load. On the other hand, maybe people like the simplicity of always having import tactic.basic done as early as possible, even if it is a slight bottleneck in compilation.

I have a slight preference to make changes in this direction, but am happy to be overrruled.


@semorrison semorrison added the RFC Request for comment label Jun 30, 2020
@urkud
Copy link
Member

urkud commented Jun 30, 2020

You can always use the new --old argument.

@jcommelin
Copy link
Member

@semorrison I understand where you are coming from, but as user I would rather have import tactic available asap, so that I can forget about it.
I guess we need to find a balance (-;
(The same is true to some extent for other "regular" library imports, of course.)

@semorrison
Copy link
Collaborator Author

Nothing of course is preventing you using import tactic.basic and import tactic in any new file (or adding it to any file you're working on).

Certainly import tactic has not generally already been imported in mathlib --- I think I actually removed the only two or three instances here, which were already off in leaves of mathlib. So the question is whether to import tactic.basic early or not.

@PatrickMassot
Copy link
Member

If this makes the life of tactic writers easier then I vote yes, despite the inconvenience of breaking the flow of working on some file when you suddenly need to go up and add a tactic import.

@gebner
Copy link
Member

gebner commented Jun 30, 2020

I'm not sure if it's useful or not --- the reason I did it was to try to make life a bit easier while working on tactics/ files, to reduce the recompilation load. On the other hand, maybe people like the simplicity of always having import tactic.basic done as early as possible, even if it is a slight bottleneck in compilation.

For this particular use case, you can also add --old as an extra command-line argument. (Then you can also comfortably hack on tactic.core.)

@semorrison
Copy link
Collaborator Author

I guess --old hasn't really done it for me; I like just being able to work in VSCode, and I'm hesitant to modify the path settings there.

@gebner
Copy link
Member

gebner commented Jun 30, 2020

You need to set it under Lean: Extra Options in the settings. And yes, it just works in vscode.

@robertylewis
Copy link
Member

I have a slight preference to make changes in this direction, but am happy to be overrruled.

I think this sums up my preferences too. import tactic is fine if you're using mathlib as a dependency. For library development, there are (minor) gains in having a more refined import hierarchy.

@robertylewis
Copy link
Member

Regarding --old, I find myself in this position sometimes: I'm editing a tactic early in the hierarchy, and it fails in a file high in the hierarchy, in a way that's hard to minimize/decouple from the imports. If I change the tactic and want to see the results, I need to recompile everything in between. --old doesn't help me here, right? But a refined import hierarchy would, if the tactic were imported by less in between it and the failing proof.

@gebner
Copy link
Member

gebner commented Jun 30, 2020

If I change the tactic and want to see the results, I need to recompile everything in between. --old doesn't help me here, right?

This is exactly the use case that --old addresses. For example, I just added a trace message to simpa and could immediately* see it in mfderiv.lean.

*Lean had to recompile mfderiv.lean, but nothing else.

@robertylewis
Copy link
Member

Then I misunderstood what --old did, and it's more wonderful than I imagined!

@PatrickMassot
Copy link
Member

It indeed sounds wonderful! Where can we find documentation about that?

@semorrison
Copy link
Collaborator Author

--old is indeed awesome. Thanks!

Nevertheless, there's another reason to shrink the import hierarchy (particularly for import tactic and import tactic.basic) which is just that when working on PRs very often one has to merge master during the late stages of development. (Especially if you try to reduce the load on reviewers by making multiple small PRs.) Merging master very often changes the tactic imports, and in this case --old doesn't save you anything. (Of course you can wait for olean from CI, but 🤺 isn't always a good solution.)

@semorrison semorrison added awaiting-review The author would like community review of the PR and removed RFC Request for comment labels Jul 1, 2020
@robertylewis
Copy link
Member

bors merge

@github-actions github-actions bot added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Jul 2, 2020
@github-actions github-actions bot removed the awaiting-review The author would like community review of the PR label Jul 2, 2020
bors bot pushed a commit that referenced this pull request Jul 2, 2020
The RFC pull request simply removes some `import tactic` or `import tactic.basic`, and then makes the necessary changes in later files to import things as needed.

I'm not sure if it's useful or not 

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Jul 2, 2020

Build failed (retrying...):

bors bot pushed a commit that referenced this pull request Jul 2, 2020
The RFC pull request simply removes some `import tactic` or `import tactic.basic`, and then makes the necessary changes in later files to import things as needed.

I'm not sure if it's useful or not 

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Jul 2, 2020

Build failed:

@robertylewis robertylewis added awaiting-author A reviewer has asked the author a question or requested changes and removed ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) labels Jul 2, 2020
@semorrison semorrison added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jul 3, 2020
@semorrison
Copy link
Collaborator Author

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Jul 3, 2020
bors bot pushed a commit that referenced this pull request Jul 3, 2020
The RFC pull request simply removes some `import tactic` or `import tactic.basic`, and then makes the necessary changes in later files to import things as needed.

I'm not sure if it's useful or not 

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
@bors
Copy link

bors bot commented Jul 3, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title chore(*): reduce imports [Merged by Bors] - chore(*): reduce imports Jul 3, 2020
@bors bors bot closed this Jul 3, 2020
@bors bors bot deleted the reduce_imports branch July 3, 2020 02:21
bors bot pushed a commit that referenced this pull request Jul 8, 2020
Following on from #3256 and #3235, this slices a little out of `data.fintype.basic`, and reduces imports, mostly in the vicinity of `data.fintype.basic`.



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
bors bot pushed a commit that referenced this pull request Jul 10, 2020
#3333)

As discussed on [zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/import.20refactor.20and.20library_search), #3235 had the unfortunate effect of making `library_search` and `#where` and various other things unavailable in many places in mathlib.

This PR makes an effort to import `tactic.basic` as early as possible, while otherwise reducing unnecessary imports. 

1. import `tactic.basic` "as early as possible" (i.e. in any file that `tactic.basic` doesn't depend on, and which imports any tactic strictly between `tactic.core` and `tactic.basic`, just `import tactic.basic` itself
2. add `tactic.finish`, `tactic.tauto` and `tactic.norm_cast` to tactic.basic (doesn't requires adding any dependencies)
3. delete various unnecessary imports




Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
jcommelin pushed a commit that referenced this pull request Jul 10, 2020
#3333)

As discussed on [zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/import.20refactor.20and.20library_search), #3235 had the unfortunate effect of making `library_search` and `#where` and various other things unavailable in many places in mathlib.

This PR makes an effort to import `tactic.basic` as early as possible, while otherwise reducing unnecessary imports. 

1. import `tactic.basic` "as early as possible" (i.e. in any file that `tactic.basic` doesn't depend on, and which imports any tactic strictly between `tactic.core` and `tactic.basic`, just `import tactic.basic` itself
2. add `tactic.finish`, `tactic.tauto` and `tactic.norm_cast` to tactic.basic (doesn't requires adding any dependencies)
3. delete various unnecessary imports




Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
The RFC pull request simply removes some `import tactic` or `import tactic.basic`, and then makes the necessary changes in later files to import things as needed.

I'm not sure if it's useful or not 

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
…unity#3319)

Following on from leanprover-community#3256 and leanprover-community#3235, this slices a little out of `data.fintype.basic`, and reduces imports, mostly in the vicinity of `data.fintype.basic`.



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
leanprover-community#3333)

As discussed on [zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/import.20refactor.20and.20library_search), leanprover-community#3235 had the unfortunate effect of making `library_search` and `#where` and various other things unavailable in many places in mathlib.

This PR makes an effort to import `tactic.basic` as early as possible, while otherwise reducing unnecessary imports. 

1. import `tactic.basic` "as early as possible" (i.e. in any file that `tactic.basic` doesn't depend on, and which imports any tactic strictly between `tactic.core` and `tactic.basic`, just `import tactic.basic` itself
2. add `tactic.finish`, `tactic.tauto` and `tactic.norm_cast` to tactic.basic (doesn't requires adding any dependencies)
3. delete various unnecessary imports




Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants