chore: make RingHom.comp implicit_reducible#38315
chore: make RingHom.comp implicit_reducible#38315sgouezel wants to merge 2 commits intoleanprover-community:masterfrom
Conversation
|
This pull request is now in draft mode. No active bors state needed cleanup. While this PR remains draft, bors will ignore commands on this PR. Mark it ready for review before using commands like |
PR summary 79540a76d4Import changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diffNo declarations were harmed in the making of this PR! 🐙 You can run this locally as follows## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/pr_summary/declarations_diff.sh long <optional_commit>The doc-module for No changes to technical debt.This script lives in the
|
🚨 PR Title Needs FormattingPlease update the title to match our commit style conventions. Errors from script: Details on the required title formatThe title should fit the following format:
|
|
!radar |
|
Benchmark results for 64837c4 against 79540a7 are in. There are significant results. @sgouezel
Large changes (1✅)
Medium changes (2✅)
Small changes (11✅, 3🟥)
|
|
Can you add some context as to what is happening in the PR description? Namely, is there a good explanation for why this gives such a speedup? (But really nice!!) |
|
Should |
|
I tried this because I need it to fix diamonds in #38451 (around Algebra structures, which are often constructed composing ring homs). I expected a performance hit, not a performance gain. My guess is that when Lean can unfold the ring homs, it realizes much more quickly that some instances are defeq -- and also maybe it helps for some unification questions. But that's just a guess, I haven't investigated the traces in detail. Two experiments I've done is try making LinearMap.comp implicit-reducible, and try making ContinuousLinearMap.comp implicit-reducible. For both, the outcome was a minor performance hit. We could try with other classes as well, but it seems to me that it's quite specific to composition of ring homs because they show up in Algebra instances. |
|
I think we want a principled solution here; either we:
|
|
Note that this has already been discussed twice on Zulip, it would be best to find those discussions before re-hashing them here. |
|
Here's a diagnosis of the speedup in algebraic geometry. This line (around line 300 of the which is an extremely long failure. On this branch we have |
|
The big speed-up in and is much better on this branch (note in particular the two last proofs are typechecking 40x faster). This is the sort of problem where it's very hard for me to go any further and if you ask a core person what's going on they'll ask for a mathlib-free minimisation, which is extremely difficult to pull off. In particular, I think this is a rather bad explanation for why this gives such a speedup. Edit: apparently a monoidal category is some data and then ten axioms, all of whose proofs are omitted in this instance, so all of which are being solved by Edit: replacing the proof of Probably one reason for the speedup in this branch is that on master we have |
|
I think that the conclusion here is that the change in this PR generally has a negligible effect on mathlib (which is not a reason either for or against merging) except that there happen to be two or three slow definitions in mathlib for which the change has a huge effect; hence if it is decided not to merge this PR then one could make the transparency change locally for these declarations and still reap the speed benefits. The declaration affected in and on this branch , an over 10x speedup. |
Co-authored-by: Monica Omar <23701951+themathqueen@users.noreply.github.com>
This change is useful to solve diamonds in #38451, and doesn't have bad performance impact (in fact, a noticeable improvement, but that's not the main reason for the PR).
Discussion at #mathlib4 > backward.isDefEq.respectTransparency: bundled homomorphisms @ 💬