Skip to content
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

[Merged by Bors] - feat: FastSubsingleton and FastIsEmpty to speed up congr!/convert #12495

Closed
wants to merge 1 commit into from

Conversation

kmill
Copy link
Contributor

@kmill kmill commented Apr 28, 2024

This is a PR that's a temporary measure to improve performance of congr!/convert, and the implementation may change in a future PR with a new version of congr!.

Introduces two typeclasses that are meant to quickly evaluate in common cases of Subsingleton and IsEmpty. Makes congr! use these typeclasses rather than Subsingleton.

Local Subsingleton/IsEmpty instances are included as Fast instances. To get congr!/convert to reason about subsingleton types, you can add such instances to the local context. Or, you can apply Subsingleton.elim yourself.

Zulip discussion


Open in Gitpod

…ert`

Introduces two typeclasses that are meant to quickly evaluate whether a particular type is a subsingleton.

Local `Subsingleton`/`IsEmpty` instances are included as `Fast` instances, so to get `congr!`/`convert` to reason about subsingleton types, you can add such instances to the local context.
@kmill
Copy link
Contributor Author

kmill commented Apr 29, 2024

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 741947e.
There were significant changes against commit 0b522a1:

  Benchmark                                                      Metric         Change
  ====================================================================================
+ ~Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties         instructions    -2.9%
+ ~Mathlib.Analysis.Calculus.ContDiff.Basic                      instructions    -6.8%
+ ~Mathlib.Analysis.Calculus.ContDiff.Defs                       instructions    -4.6%
+ ~Mathlib.Analysis.Calculus.FDeriv.Analytic                     instructions    -9.3%
+ ~Mathlib.Analysis.Fourier.PoissonSummation                     instructions   -31.7%
+ ~Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform   instructions   -16.4%
+ ~Mathlib.Geometry.Manifold.Instances.Sphere                    instructions   -13.4%
+ ~Mathlib.Geometry.Manifold.IntegralCurve                       instructions   -20.1%
+ ~Mathlib.LinearAlgebra.AffineSpace.Independent                 instructions   -18.4%
+ ~Mathlib.NumberTheory.Modular                                  instructions   -15.1%
+ ~Mathlib.NumberTheory.ZetaValues                               instructions   -16.9%

@kmill kmill added awaiting-review The author would like community review of the PR t-meta Tactics, attributes or user commands labels Apr 29, 2024
@fpvandoorn
Copy link
Member

Thanks, I think this great, since I've also noticed these tactics to be often slow.

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Apr 29, 2024
mathlib-bors bot pushed a commit that referenced this pull request Apr 29, 2024
…ert` (#12495)

This is a PR that's a temporary measure to improve performance of `congr!`/`convert`, and the implementation may change in a future PR with a new version of `congr!`.

Introduces two typeclasses that are meant to quickly evaluate in common cases of `Subsingleton` and `IsEmpty`. Makes `congr!` use these typeclasses rather than `Subsingleton`.

Local `Subsingleton`/`IsEmpty` instances are included as `Fast` instances. To get `congr!`/`convert` to reason about subsingleton types, you can add such instances to the local context. Or, you can `apply Subsingleton.elim` yourself.

[Zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/convert.20is.20often.20slow/near/433830798)
@mathlib-bors
Copy link

mathlib-bors bot commented Apr 29, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: FastSubsingleton and FastIsEmpty to speed up congr!/convert [Merged by Bors] - feat: FastSubsingleton and FastIsEmpty to speed up congr!/convert Apr 29, 2024
@mathlib-bors mathlib-bors bot closed this Apr 29, 2024
@mathlib-bors mathlib-bors bot deleted the kmill_congr_fastsubsingleton branch April 29, 2024 17:50
apnelson1 pushed a commit that referenced this pull request May 12, 2024
…ert` (#12495)

This is a PR that's a temporary measure to improve performance of `congr!`/`convert`, and the implementation may change in a future PR with a new version of `congr!`.

Introduces two typeclasses that are meant to quickly evaluate in common cases of `Subsingleton` and `IsEmpty`. Makes `congr!` use these typeclasses rather than `Subsingleton`.

Local `Subsingleton`/`IsEmpty` instances are included as `Fast` instances. To get `congr!`/`convert` to reason about subsingleton types, you can add such instances to the local context. Or, you can `apply Subsingleton.elim` yourself.

[Zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/convert.20is.20often.20slow/near/433830798)
callesonne pushed a commit that referenced this pull request May 16, 2024
…ert` (#12495)

This is a PR that's a temporary measure to improve performance of `congr!`/`convert`, and the implementation may change in a future PR with a new version of `congr!`.

Introduces two typeclasses that are meant to quickly evaluate in common cases of `Subsingleton` and `IsEmpty`. Makes `congr!` use these typeclasses rather than `Subsingleton`.

Local `Subsingleton`/`IsEmpty` instances are included as `Fast` instances. To get `congr!`/`convert` to reason about subsingleton types, you can add such instances to the local context. Or, you can `apply Subsingleton.elim` yourself.

[Zulip discussion](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/convert.20is.20often.20slow/near/433830798)
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. t-meta Tactics, attributes or user commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants