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

perf: simplifier performance issues on match and if-then-else terms #3118

Closed
wants to merge 6 commits into from

Conversation

leodemoura
Copy link
Member

No description provided.

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.
@leodemoura leodemoura requested a review from Kha as a code owner December 27, 2023 01:04
@leodemoura leodemoura changed the title Simplifier performance issues: match and if-then-else terms perf: Simplifier performance issues: match and if-then-else terms Dec 27, 2023
@leodemoura leodemoura changed the title perf: Simplifier performance issues: match and if-then-else terms perf: simplifier performance issues on match and if-then-else terms Dec 27, 2023
@leodemoura leodemoura marked this pull request as draft December 27, 2023 01:06
@leodemoura
Copy link
Member Author

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 6110405.
The entire run failed.
Found no significant differences.

@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 Dec 27, 2023
@leanprover-community-mathlib4-bot
Copy link
Collaborator

  • ❗ Mathlib CI can not be attempted yet, as the 'nightly-testing-2023-12-24' branch does not exist there yet. We will retry when you push more commits. It may be necessary to rebase onto 'nightly' tomorrow. (2023-12-27 01:20:09)

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)
==> ...
```
leodemoura added a commit to leanprover-community/batteries that referenced this pull request Dec 27, 2023
Using `simp [forIn]` may cause nontermination with different `simp`
reduction strategies. We have the following theorem
```
@[simp] theorem forIn_eq_forIn [Monad m] : @List.forIn α β m _ = forIn := rfl
```
Then, executing `simp [forIn]` in a term containing `forIn` iterating
over a `List` may cause nontermination since the theorem above will fold it again.

Remark: the reduction strategy implemented
leanprover/lean4#3118 triggers nontermination.
@leodemoura
Copy link
Member Author

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 308942c.
There were no significant changes against commit 13d41f8.

joehendrix added a commit to leanprover-community/batteries that referenced this pull request Dec 28, 2023
Using `simp [forIn]` may cause nontermination with different `simp`
reduction strategies. We have the following theorem
```
@[simp] theorem forIn_eq_forIn [Monad m] : @List.forIn α β m _ = forIn := rfl
```
Then, executing `simp [forIn]` in a term containing `forIn` iterating
over a `List` may cause nontermination since the theorem above will fold it again.

Remark: the reduction strategy implemented
leanprover/lean4#3118 triggers nontermination.

Co-authored-by: Joe Hendrix <joe@lean-fro.org>
@leodemoura
Copy link
Member Author

Subsumed by #3124

@leodemoura leodemoura closed this Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants