Skip to content

[Merged by Bors] - fix (RingTheory.Kaehler): short cut instances to remove timeouts#6149

Closed
mattrobball wants to merge 35 commits intomasterfrom
mrb/kaehler_speedup
Closed

[Merged by Bors] - fix (RingTheory.Kaehler): short cut instances to remove timeouts#6149
mattrobball wants to merge 35 commits intomasterfrom
mrb/kaehler_speedup

Conversation

@mattrobball
Copy link
Copy Markdown
Contributor

@mattrobball mattrobball commented Jul 26, 2023

This obviates the need for bumping timeout limits in RingTheory.Kaehler at the expense of explicit instances that Lean should easily be finding.


Open in Gitpod

@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 27, 2023
@riccardobrasca
Copy link
Copy Markdown
Member

Can you please fix the conflicts? Thanks!

@mattrobball
Copy link
Copy Markdown
Contributor Author

Can you please fix the conflicts? Thanks!

Modulo the Rust errors (lol), it should build fine now though maybe not lint. I am still working on removing the hacky instances. If I don't succeed by early tomorrow, I will clean this up and mark it awaiting-review.

@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 27, 2023
@mattrobball
Copy link
Copy Markdown
Contributor Author

!bench

@mattrobball
Copy link
Copy Markdown
Contributor Author

Run cancelled. This is the only instances now.

@mattrobball
Copy link
Copy Markdown
Contributor Author

One can compare this run for the whole package to this one for the foundational instances.

Taking a set difference, it looks like this will speed up Kaehler by ~40% and not do much else. Do we need another speed run before merging?

Comment on lines +394 to +397
theorem isScalarTower_S_right : IsScalarTower S (S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2)
(S ⊗[R] S ⧸ KaehlerDifferential.ideal R S ^ 2) := IsScalarTower.right

attribute [local instance] isScalarTower_S_right
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why a theorem and not local instance?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

defLemma complained. Is there a better fix?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That sounds like a bug in local instance that we should report somewhere. I think a minimal repro is

local instance : Fact True := sorry

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It isn't making that easy for me. But local is definitely the trigger. I am going to try to minimize in a bit. This has occurred for me before with Fact deep into the library. Maybe the import is messing things up? We'll see.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the problem is that instance is just always a def

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like a mwe:

namespace OhNo
local instance : Fact True := sorry
end OhNo
#lint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed that is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is a def with or without the local. Should this

    if (← isAutoDecl declName) || isGlobalInstance (← getEnv) declName then

be

    if (← isAutoDecl declName) || (← isInstance declName) then

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Probably out of scope regardless

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't figure out how to read local instances in the scope that #lint works in. For now, it seems better just to nolint and bring the issue up on Zulip.

@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 10, 2023
@bors bors bot changed the base branch from master to ScottCarnahan/BinomialRing2 September 17, 2023 03:25
@kim-em kim-em changed the base branch from ScottCarnahan/BinomialRing2 to master September 17, 2023 12:14
@mattrobball mattrobball removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 21, 2023
@mattrobball
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 066a706.
The entire run failed.
Found no significant differences.

@mattrobball
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit ea8b9af.
There were significant changes against commit a526f3e:

  Benchmark                     Metric         Change
  ===================================================
+ ~Mathlib.RingTheory.Kaehler   instructions   -33.4%

@jcommelin
Copy link
Copy Markdown
Member

Great work! Thanks 🎉

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Sep 22, 2023
bors bot pushed a commit that referenced this pull request Sep 22, 2023
This obviates the need for bumping timeout limits in `RingTheory.Kaehler` at the expense of explicit instances that Lean should easily be finding. 



Co-authored-by: Kevin Buzzard <k.buzzard@imperial.ac.uk>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@bors
Copy link
Copy Markdown

bors bot commented Sep 22, 2023

Pull request successfully merged into master.

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot changed the title fix (RingTheory.Kaehler): short cut instances to remove timeouts [Merged by Bors] - fix (RingTheory.Kaehler): short cut instances to remove timeouts Sep 22, 2023
@bors bors bot closed this Sep 22, 2023
@bors bors bot deleted the mrb/kaehler_speedup branch September 22, 2023 04:37
kodyvajjha pushed a commit that referenced this pull request Sep 22, 2023
This obviates the need for bumping timeout limits in `RingTheory.Kaehler` at the expense of explicit instances that Lean should easily be finding. 



Co-authored-by: Kevin Buzzard <k.buzzard@imperial.ac.uk>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
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.

7 participants