-
Notifications
You must be signed in to change notification settings - Fork 259
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
refactor: make charP_to_charZero an instance #6548
base: master
Are you sure you want to change the base?
Conversation
I've seen those build errors before, when changing unrelated files. Typeclass inference spends a long time doing a stupid thing (it's |
!bench |
Here are the benchmark results for commit 5629904. Benchmark Metric Change
=============================================================
- build native linking 11.1%
- ~Mathlib.NumberTheory.SumTwoSquares instructions 5.8% |
Empirically typeclass cycles are still bad, at least in my experience. I recently tried to promote two theorems to instances and ran into non-trivial problems (to say nothing of performance hits). I mentioned this here: IMHO, the situation is better than Lean 3 but I think typeclass inference still has a lot of room for improvement in Lean 4 (which is actually pretty exciting, as I believe we'll see it happen). So unfortunately I think we should not make this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have this but I think Mathlib / Lean is not yet ready.
@@ -75,6 +75,9 @@ local macro "map_simp" : tactic => | |||
|
|||
universe u v w | |||
|
|||
-- Disabled locally for performance reasons | |||
attribute [-instance] StrictOrderedSemiring.to_charZero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the disappointing benchmark results I think this is a pretty big red flag.
I just came across this PR again (tidying my notifications) and it occurs to me that the right fix would be to change the definition of the class CharP [AddMonoidWithOne R] (p : ℕ) : Prop where
cast_eq_iff' : ∀ x y : ℕ, (x : R) = (y : R) ↔ (x : ZMod p) = (y : ZMod p) and then delete For bonus points one could even rename |
This should be safe now that instance cycles are allowed in Lean4