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

feat: add simp configuration option Simp.Config.instances #3151

Closed
wants to merge 54 commits into from

Conversation

leodemoura
Copy link
Member

@leodemoura leodemoura commented Jan 9, 2024

Depends on #3124

Mathlib adaptation PR is at leanprover-community/mathlib4#9572

The new test exposes a performance problem found in software
verification applications.
See new test for example that takes exponential time without new simp
theorems.
TODO: replace auxiliary theorems with simprocs as soon as we implement them.
The example was looping with the new `simp` reduction strategy. Here
is the looping trace.
```
List.reverseAux (List.reverseAux as []) bs
==> rewrite using reverseAux_reverseAux
List.reverseAux [] (List.reverseAux (List.reverseAux as []) bs)
==> unfold reverseAux
List.reverseAux (List.reverseAux as []) bs
==> rewrite using reverseAux_reverseAux
List.reverseAux [] (List.reverseAux (List.reverseAux as []) bs)
==> ...
```
Motivations:
- We can simplify the big mutual recursion and the implementation.
- We can implement the support for `match`-expressions in the `pre` method.
- It is easier to define and simplify `Simprocs`.
TODO:
- `builtin_simproc` attribute
- more tests
Allow `simproc`s to be declared without setting the `[simproc]`
attribute. A `simproc` declaration is function + pattern.

Motivation: allow them to be provided as arguments to `simp` **and** `simp only`.

TODO: track their use in `simp`.
TODO: builtin simprocs
`Origin.decl` constructor has an extra field.
It is true by default. Packages can set it to false to disable
simplification procedue support for backward compatibility.
We can now disable `simproc`s using the same notation we use to
disable rewriting rules in the simplifier.
Motivation: better `simp` cache behavior. Recall that `simp` cache
uses `dischargeDepth`.
@leodemoura
Copy link
Member Author

!bench

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jan 9, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Jan 9, 2024

  • ❗ Mathlib CI can not be attempted yet, as the 'nightly-testing-2024-01-06' branch does not exist there yet. We will retry when you push more commits. It may be necessary to rebase onto 'nightly' tomorrow. (2024-01-09 00:39:23)
  • 💥 Mathlib branch lean-pr-testing-3151 build failed against this PR. (2024-01-09 02:15:34) View Log
  • 💥 Mathlib branch lean-pr-testing-3151 build failed against this PR. (2024-01-09 04:59:06) View Log
  • 🟡 Mathlib branch lean-pr-testing-3151 build against this PR was cancelled. (2024-01-09 06:22:08) View Log
  • ✅ Mathlib branch lean-pr-testing-3151 has successfully built against this PR. (2024-01-09 07:25:47) View Log
  • ✅ Mathlib branch lean-pr-testing-3151 has successfully built against this PR. (2024-01-09 11:34:16) View Log
  • ✅ Mathlib branch lean-pr-testing-3151 has successfully built against this PR. (2024-01-09 12:00:53) View Log

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 9be86b5.
There were significant changes against commit 9034937:

  Benchmark                  Metric             Change
  ===============================================================
- import Lean                branches             1.8%  (105.8 σ)
- import Lean                instructions         1.8%  (136.9 σ)
- import Lean                maxrss               1.5%   (53.7 σ)
- lake startup               instructions         1.5%   (54.6 σ)
- libleanshared.so           binary size          2.0%
- reduceMatch                maxrss               1.3%  (101.8 σ)
- stdlib                     instructions         1.4% (1184.2 σ)
- stdlib                     wall-clock           1.6%   (18.8 σ)
- stdlib size                bytes .olean         1.4%
- stdlib size                lines C              2.5%
- tests/bench/ interpreted   maxrss               1.3%   (56.7 σ)
- tests/compiler             sum binary sizes     1.9%
- workspaceSymbols           instructions         2.2% (3266.8 σ)
- workspaceSymbols           maxrss               1.5%   (88.3 σ)

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc January 9, 2024 01:02 Inactive
semorrison added a commit to leanprover-community/mathlib4 that referenced this pull request Jan 9, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Jan 9, 2024
@semorrison
Copy link
Collaborator

semorrison commented Jan 9, 2024

This does cause a variety of Mathlib failures. Can we start out with this defaulting to true?

Maybe it's not so bad. I think we could proceed with this.

@semorrison
Copy link
Collaborator

I've created a discussion on zulip to forewarn users about this, and to discuss impact.

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Jan 9, 2024
@semorrison
Copy link
Collaborator

This PR was superseded by #3507.

@semorrison semorrison closed this Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants