Skip to content

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

Closed
leodemoura wants to merge 6 commits intomasterfrom
simpIssues
Closed

perf: simplifier performance issues on match and if-then-else terms#3118
leodemoura wants to merge 6 commits intomasterfrom
simpIssues

Conversation

@leodemoura
Copy link
Copy Markdown
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
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
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
@ghost
Copy link
Copy Markdown

ghost commented Dec 27, 2023

  • ❗ 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
Copy Markdown
Member Author

!bench

@leanprover-bot
Copy link
Copy Markdown
Collaborator

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

joehendrix pushed 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
Copy Markdown
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.

2 participants