Skip to content

[Merged by Bors] - fix: redefine semiring instance on tensor product#6141

Closed
eric-wieser wants to merge 8 commits intomasterfrom
eric-wieser/kaehler-speedup
Closed

[Merged by Bors] - fix: redefine semiring instance on tensor product#6141
eric-wieser wants to merge 8 commits intomasterfrom
eric-wieser/kaehler-speedup

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser commented Jul 25, 2023

By providing the Mul instance up front, this seems to make future typeclass search much easier.

This comes at the expense of causing minor elaboration problem in various tensor definitions, which now require the implicit type arguments to be provided explicitly.

This also simplifies some proofs, removing a porting note.


Open in Gitpod

This is a test to try and work out what's going on in #6134.

This skips out some intermediate instances to try and answer the question of whether they matter.

@eric-wieser eric-wieser added the WIP Work in progress label Jul 25, 2023
@eric-wieser
Copy link
Copy Markdown
Member Author

!bench

left_distrib a b c := show mul a (b + c) = mul a b + mul a c by simp
right_distrib a b c := show mul (a + b) c = mul a c + mul b c by simp
zero_mul a := show mul 0 a = 0 by simp
mul_zero a := show mul a 0 = 0 by simp
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.

Are we missing simp lemmas or something? Why might this have stopped working? Note that the type of mul is LinearMap rather than just a function. Note also that this was already an issue on master.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This stopped working because these fields are about HMul.hMul, but the mul field we provide is Mul.mul. The goals can be solved with simp [HMul.hMul]. This probably comes up all over the place when building structures, and the answer is always going to be "you have to unfold HFoo.foo too".

@eric-wieser
Copy link
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

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

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit cbfe65e.
There were significant changes against commit 03720bd:

  Benchmark                                      Metric         Change
  ====================================================================
+ ~Mathlib.Algebra.Category.Ring.Constructions   instructions   -12.6%
+ ~Mathlib.Data.Matrix.Kronecker                 instructions   -22.4%
+ ~Mathlib.RingTheory.Etale                      instructions    -9.7%
+ ~Mathlib.RingTheory.IntegralClosure            instructions    -8.2%
+ ~Mathlib.RingTheory.IsTensorProduct            instructions   -24.0%
+ ~Mathlib.RingTheory.Kaehler                    instructions   -45.0%
+ ~Mathlib.RingTheory.RingHom.Finite             instructions   -31.8%
+ ~Mathlib.RingTheory.RingHom.Integral           instructions   -47.1%
+ ~Mathlib.RingTheory.RingHom.Surjective         instructions    -7.2%
+ ~Mathlib.RingTheory.RingHomProperties          instructions   -20.6%
+ ~Mathlib.RingTheory.TensorProduct              instructions   -14.8%

@eric-wieser eric-wieser changed the title Alternative to #6134 fix: redefine semiring instance on tensor product Jul 26, 2023
@eric-wieser eric-wieser added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. and removed WIP Work in progress labels Jul 26, 2023
@eric-wieser eric-wieser force-pushed the eric-wieser/kaehler-speedup branch from a157f02 to d1db49f Compare July 26, 2023 08:55
@riccardobrasca
Copy link
Copy Markdown
Member

This is much better, thanks!

bors d+

@bors
Copy link
Copy Markdown

bors bot commented Jul 26, 2023

✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed awaiting-review labels Jul 26, 2023
@eric-wieser eric-wieser removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jul 26, 2023
@eric-wieser
Copy link
Copy Markdown
Member Author

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Jul 26, 2023
bors bot pushed a commit that referenced this pull request Jul 26, 2023
By providing the `Mul` instance up front, this seems to make future typeclass search much easier.

This comes at the expense of causing minor elaboration problem in various tensor definitions, which now require the implicit type arguments to be provided explicitly.

This also simplifies some proofs, removing a porting note.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@bors
Copy link
Copy Markdown

bors bot commented Jul 26, 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: redefine semiring instance on tensor product [Merged by Bors] - fix: redefine semiring instance on tensor product Jul 26, 2023
@bors bors bot closed this Jul 26, 2023
@bors bors bot deleted the eric-wieser/kaehler-speedup branch July 26, 2023 11:43
bors bot pushed a commit that referenced this pull request Jul 27, 2023
In light of #6141, we can change the heart beats to more representantive numbers.



Co-authored-by: Matthew Robert Ballard <100034030+mattrobball@users.noreply.github.com>
adomani pushed a commit that referenced this pull request Jul 28, 2023
In light of #6141, we can change the heart beats to more representantive numbers.



Co-authored-by: Matthew Robert Ballard <100034030+mattrobball@users.noreply.github.com>
kim-em pushed a commit that referenced this pull request Aug 14, 2023
By providing the `Mul` instance up front, this seems to make future typeclass search much easier.

This comes at the expense of causing minor elaboration problem in various tensor definitions, which now require the implicit type arguments to be provided explicitly.

This also simplifies some proofs, removing a porting note.



Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
kim-em pushed a commit that referenced this pull request Aug 14, 2023
In light of #6141, we can change the heart beats to more representantive numbers.



Co-authored-by: Matthew Robert Ballard <100034030+mattrobball@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants