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] - refactor: do not import old-style have/suffices/replace within mathlib #10534

Closed
wants to merge 7 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Feb 14, 2024

This syntax remains available downstream with import Mathlib.Tactic, but is no longer available in mathlib itself.

This follows on from #10640, which remove all current uses of this syntax.

By removing these imports, we prevent further regressions in mathlib,
and save reviewers from having to look out for this in review.

In future we could delete this syntax entirely, but this would harm downstream code, especially mathport output.


Open in Gitpod

@eric-wieser eric-wieser added WIP Work in progress awaiting-CI labels Feb 14, 2024
@eric-wieser eric-wieser changed the title refactor: remove old-style have/suffices in mathlib refactor: do not import old-style have/suffices within mathlib Feb 14, 2024
@eric-wieser eric-wieser added awaiting-review The author would like community review of the PR and removed WIP Work in progress labels Feb 14, 2024
@sgouezel
Copy link
Contributor

I think it's really strange to have a tactic in mathlib which is not usable in mathlib. I'd rather remove the file completely, for coherence and predictability.

@eric-wieser
Copy link
Member Author

eric-wieser commented Feb 14, 2024

I'd rather leave it in for now so as not to break anyone's teaching material. Perhaps we can have it raise a code action that rewrites it to the new style.

I think it's really strange to have a tactic in mathlib which is not usable in mathlib.

I don't think this is all that far away from our existing rule of "don't use import Mathlib.Tactic in mathlib".

@sgouezel
Copy link
Contributor

Are you sure this change desactivate the stream of consciousness have? I have just made a test, and it seems to be still there even on this branch (maybe I messed up something, of course).

@sgouezel
Copy link
Contributor

(Scratch that, my tests were done on a previous commit in whic Replace wasn't disabled, and it imports Tactic.Have).

@sgouezel
Copy link
Contributor

It turns out that in fact there were some bad uses of have in the library. I have started fixing things.

@eric-wieser
Copy link
Member Author

I now see that #6964 recommends not spending manual effort here, and waiting for a syntax transformation tool instead.

Sorry for the false claim that we already didn't use this syntax anywhere!

@sgouezel
Copy link
Contributor

Given the examples I've fixed (some of them very obfuscated), I don't think an automatic tool could do this. So I think I'm gonna fix this by hand instead of waiting, if you don't mind.

@sgouezel
Copy link
Contributor

sgouezel commented Feb 15, 2024

Speaking of obfuscation, this one is quite nice:

  suffices; exact (encode_lt_pair cf cg).imp (fun h => lt_trans h this) fun h => lt_trans h this
  change _; simp [encodeCode_eq, encodeCode]

I think Mario knows too well for his own good how everything works.

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added merge-conflict The PR has a merge conflict with master, and needs manual merging. and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. labels Feb 15, 2024
@grunweg grunweg force-pushed the eric-wieser/remove-tactic.Have branch from 8e9ad34 to 89a5316 Compare February 16, 2024 17:15
@eric-wieser eric-wieser changed the title refactor: do not import old-style have/suffices within mathlib refactor: do not import or use old-style have/suffices/replace within mathlib Feb 16, 2024
@grunweg grunweg changed the title refactor: do not import or use old-style have/suffices/replace within mathlib refactor: rewrite all old-style have/replace/suffices within mathlib Feb 16, 2024
@grunweg
Copy link
Collaborator

grunweg commented Feb 16, 2024

The two remaining linter warnings shouldn't be hard (just about line length). fixed now

@grunweg
Copy link
Collaborator

grunweg commented Feb 16, 2024

I could use a hand fixing the two remaining tests.

@sgouezel
Copy link
Contributor

Now that everything is fixed (hopefully), I have extracted another PR keeping just the fixes to the library, and not touching the tactic files. Hopefully it shouldn't be controversial and can be merged quickly, and then we will discuss here what to do of the tactic files (disable them or remove them).

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added blocked-by-other-PR This PR depends on another PR to Mathlib merge-conflict The PR has a merge conflict with master, and needs manual merging. and removed blocked-by-other-PR This PR depends on another PR to Mathlib labels Feb 16, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

This syntax remains available downstream with `import Mathlib.Tactic`, but is not available in mathlib
Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

Thanks 🎉

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Feb 20, 2024
mathlib-bors bot pushed a commit that referenced this pull request Feb 20, 2024
…mathlib (#10534)

This syntax remains available downstream with `import Mathlib.Tactic`, but is no longer available in mathlib itself.

This follows on from #10640, which remove all current uses of this syntax.

By removing these imports, we prevent further regressions in mathlib,
and save reviewers from having to look out for this in review.

In future we could delete this syntax entirely, but this would harm downstream code, especially mathport output.



Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Feb 20, 2024

Build failed (retrying...):

  • Build

mathlib-bors bot pushed a commit that referenced this pull request Feb 20, 2024
…mathlib (#10534)

This syntax remains available downstream with `import Mathlib.Tactic`, but is no longer available in mathlib itself.

This follows on from #10640, which remove all current uses of this syntax.

By removing these imports, we prevent further regressions in mathlib,
and save reviewers from having to look out for this in review.

In future we could delete this syntax entirely, but this would harm downstream code, especially mathport output.



Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Feb 20, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title refactor: do not import old-style have/suffices/replace within mathlib [Merged by Bors] - refactor: do not import old-style have/suffices/replace within mathlib Feb 20, 2024
@mathlib-bors mathlib-bors bot closed this Feb 20, 2024
@mathlib-bors mathlib-bors bot deleted the eric-wieser/remove-tactic.Have branch February 20, 2024 19:12
thorimur pushed a commit that referenced this pull request Feb 24, 2024
…mathlib (#10534)

This syntax remains available downstream with `import Mathlib.Tactic`, but is no longer available in mathlib itself.

This follows on from #10640, which remove all current uses of this syntax.

By removing these imports, we prevent further regressions in mathlib,
and save reviewers from having to look out for this in review.

In future we could delete this syntax entirely, but this would harm downstream code, especially mathport output.



Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
thorimur pushed a commit that referenced this pull request Feb 26, 2024
…mathlib (#10534)

This syntax remains available downstream with `import Mathlib.Tactic`, but is no longer available in mathlib itself.

This follows on from #10640, which remove all current uses of this syntax.

By removing these imports, we prevent further regressions in mathlib,
and save reviewers from having to look out for this in review.

In future we could delete this syntax entirely, but this would harm downstream code, especially mathport output.



Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
mathlib-bors bot pushed a commit that referenced this pull request Feb 28, 2024
This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.
mathlib-bors bot pushed a commit that referenced this pull request Feb 28, 2024
This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.
riccardobrasca pushed a commit that referenced this pull request Mar 1, 2024
…mathlib (#10534)

This syntax remains available downstream with `import Mathlib.Tactic`, but is no longer available in mathlib itself.

This follows on from #10640, which remove all current uses of this syntax.

By removing these imports, we prevent further regressions in mathlib,
and save reviewers from having to look out for this in review.

In future we could delete this syntax entirely, but this would harm downstream code, especially mathport output.



Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
riccardobrasca pushed a commit that referenced this pull request Mar 1, 2024
This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.
kbuzzard pushed a commit that referenced this pull request Mar 12, 2024
This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.
dagurtomas pushed a commit that referenced this pull request Mar 22, 2024
…mathlib (#10534)

This syntax remains available downstream with `import Mathlib.Tactic`, but is no longer available in mathlib itself.

This follows on from #10640, which remove all current uses of this syntax.

By removing these imports, we prevent further regressions in mathlib,
and save reviewers from having to look out for this in review.

In future we could delete this syntax entirely, but this would harm downstream code, especially mathport output.



Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
dagurtomas pushed a commit that referenced this pull request Mar 22, 2024
This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.
Louddy pushed a commit that referenced this pull request Apr 15, 2024
This covers many instances, but is not exhaustive.

Independently of whether that syntax should be avoided (similar to #10534), I think all these changes are small improvements.
mathlib-bors bot pushed a commit that referenced this pull request Jun 24, 2024
Just the syntax replacements are split into #13219.

Most of its occurrences were removed in #11045 and #12850; #13219 removed the last instances.

**Why is this removed?** In a nutshell, my understanding is that this is preferred against for similar reasons as #10534:
- it's a Lean3-ism, which can be unlearned now
- the syntax `obtain foo : type := proof` is slightly shorter; particularly so when the next tactic is `exact`
- when using it as `obtain foo : type; · proof`, there is an intermediate state with multiple goals right before the focusing dot
(This gets amplified with the in-flight "multiple goal linter", which in my perception seems generally desired - for many reasons, including teachability. Granted, the linter could be tweaked to not lint in this case... but by now, the "old" syntax is not clearly better.) 
- the old syntax *could* be slightly nicer when deferring goals: In the 30 replacements of the last PR, this occurred *twice* (i.e., very rarely). In both cases, `suffices` or `rsuffices` can be used, and would imho be clearer.

Alternatively, the `obtain` tactic in Lean core could also be changed: this change does not block this at all,
but moves forward with something that is doable within mathlib today.
kbuzzard pushed a commit that referenced this pull request Jun 26, 2024
Just the syntax replacements are split into #13219.

Most of its occurrences were removed in #11045 and #12850; #13219 removed the last instances.

**Why is this removed?** In a nutshell, my understanding is that this is preferred against for similar reasons as #10534:
- it's a Lean3-ism, which can be unlearned now
- the syntax `obtain foo : type := proof` is slightly shorter; particularly so when the next tactic is `exact`
- when using it as `obtain foo : type; · proof`, there is an intermediate state with multiple goals right before the focusing dot
(This gets amplified with the in-flight "multiple goal linter", which in my perception seems generally desired - for many reasons, including teachability. Granted, the linter could be tweaked to not lint in this case... but by now, the "old" syntax is not clearly better.) 
- the old syntax *could* be slightly nicer when deferring goals: In the 30 replacements of the last PR, this occurred *twice* (i.e., very rarely). In both cases, `suffices` or `rsuffices` can be used, and would imho be clearer.

Alternatively, the `obtain` tactic in Lean core could also be changed: this change does not block this at all,
but moves forward with something that is doable within mathlib today.
dagurtomas pushed a commit that referenced this pull request Jul 2, 2024
Just the syntax replacements are split into #13219.

Most of its occurrences were removed in #11045 and #12850; #13219 removed the last instances.

**Why is this removed?** In a nutshell, my understanding is that this is preferred against for similar reasons as #10534:
- it's a Lean3-ism, which can be unlearned now
- the syntax `obtain foo : type := proof` is slightly shorter; particularly so when the next tactic is `exact`
- when using it as `obtain foo : type; · proof`, there is an intermediate state with multiple goals right before the focusing dot
(This gets amplified with the in-flight "multiple goal linter", which in my perception seems generally desired - for many reasons, including teachability. Granted, the linter could be tweaked to not lint in this case... but by now, the "old" syntax is not clearly better.) 
- the old syntax *could* be slightly nicer when deferring goals: In the 30 replacements of the last PR, this occurred *twice* (i.e., very rarely). In both cases, `suffices` or `rsuffices` can be used, and would imho be clearer.

Alternatively, the `obtain` tactic in Lean core could also be changed: this change does not block this at all,
but moves forward with something that is doable within mathlib today.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants