Skip to content

fix: redefine semiring instance on tensor product#6134

Closed
kbuzzard wants to merge 4 commits intomasterfrom
kbuzzard-kaehler-speedup
Closed

fix: redefine semiring instance on tensor product#6134
kbuzzard wants to merge 4 commits intomasterfrom
kbuzzard-kaehler-speedup

Conversation

@kbuzzard
Copy link
Copy Markdown
Member


Open in Gitpod

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

!bench

}

instance instSemiring : Semiring (A ⊗[R] B) :=
{ (by infer_instance : AddMonoidWithOne (A ⊗[R] B)),
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 worry that this discarded the natCast field, though I have no idea whether it actually does.

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.

Do you still worry given that it compiles and the benchmark results?

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.

Yes, because neither of those steps necessarily checks for diamonds problems, and previously we relied on the source code making it obvious that they didn't exist. I'll add an example to verify that it's fine.

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.

Thanks. I don't understand the issue that you're concerned about so please feel free to check this out (or explain the issue to me, either will do).

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.

The issue is

example : (algebraNat : Algebra ℕ (ℕ ⊗[ℕ] ℕ)) = leftAlgebra := rfl -- fails

but this already failed on master so you're off the hook!

@leanprover-bot
Copy link
Copy Markdown
Collaborator

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

  Benchmark                                                  Metric         Change
  ================================================================================
- build                                                      maxrss           8.1%
+ ~Mathlib.Algebra.Category.Ring.Constructions               instructions   -12.7%
+ ~Mathlib.Data.Matrix.Kronecker                             instructions   -22.6%
- ~Mathlib.RepresentationTheory.GroupCohomology.Resolution   instructions     5.2%
- ~Mathlib.RingTheory.ClassGroup                             instructions     8.8%
+ ~Mathlib.RingTheory.Etale                                  instructions    -9.6%
+ ~Mathlib.RingTheory.IntegralClosure                        instructions    -8.4%
+ ~Mathlib.RingTheory.IsTensorProduct                        instructions   -24.3%
+ ~Mathlib.RingTheory.Kaehler                                instructions   -44.9%
+ ~Mathlib.RingTheory.RingHom.Finite                         instructions   -32.4%
+ ~Mathlib.RingTheory.RingHom.Integral                       instructions   -47.7%
+ ~Mathlib.RingTheory.RingHom.Surjective                     instructions    -7.4%
+ ~Mathlib.RingTheory.RingHomProperties                      instructions   -20.9%
+ ~Mathlib.RingTheory.TensorProduct                          instructions   -14.8%

@kbuzzard kbuzzard changed the title fix: redefine semiring instance on tenspr product fix: redefine semiring instance on tensor product Jul 25, 2023
@eric-wieser
Copy link
Copy Markdown
Member

eric-wieser commented Jul 25, 2023

I just pushed 612db69 as cleanup, but it's not showing up here... Now fixed.

@kbuzzard
Copy link
Copy Markdown
Member Author

kbuzzard commented Jul 25, 2023

The six remaining maxHeartbeats seem to me to be another issue so I'm happy to mark this awaiting-review and worry about the others later; but I'm also unclear about what's happening with #6141 (just to be clear, I don't mind at all which one is merged, assuming 6141 compiles).

@eric-wieser
Copy link
Copy Markdown
Member

I'm a bit concerned that github is currently broken, and that there is no guarantee that bors will merge what we expect it to: so I think we should leave this until the commit I mention above appears!

#align kaehler_differential.total_surjective KaehlerDifferential.total_surjective

set_option maxHeartbeats 3200000 in -- 2569452
set_option maxHeartbeats 400000 in -- 2569452
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.

Suggested change
set_option maxHeartbeats 400000 in -- 2569452
set_option maxHeartbeats 400000 in

I guess this is not relevant anymore.

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've applied this change at #6141

@eric-wieser
Copy link
Copy Markdown
Member

Closing in favor of #6141, which is simpler and faster. Thanks @kbuzzard for working this one out!

mattrobball added a commit that referenced this pull request Jul 26, 2023
@YaelDillies YaelDillies deleted the kbuzzard-kaehler-speedup branch October 13, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants