refactor: simplify SimpM recursive definitions#3120
Closed
leodemoura wants to merge 11 commits intomasterfrom
Closed
refactor: simplify SimpM recursive definitions#3120leodemoura wants to merge 11 commits intomasterfrom
SimpM recursive definitions#3120leodemoura wants to merge 11 commits intomasterfrom
Conversation
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Dec 27, 2023
|
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Dec 27, 2023
Merged
nomeata
reviewed
Dec 29, 2023
src/Lean/Expr.lean
Outdated
| loop : Nat → Expr → Array Expr → Array Expr | ||
| | 0, _, as => as | ||
| | i+1, .app f a, as => loop i f (as.set! i a) | ||
| | _, _, as => as |
Collaborator
There was a problem hiding this comment.
This will return an array with dummy entries if there aren't enough arguments, will it? Maybe worth pointing out in the docs, also on which side the dummies are? Or maybe just panic instead, its probably misuse if n is too small?
| match n, e with | ||
| | 0, _ => e | ||
| | n+1, .app f _ => extractNumArgs f n | ||
| | _, _ => e |
Collaborator
There was a problem hiding this comment.
I'm a bit confused by the naming; this doesn't extract the args, but extracts the function, or strips the args, doesn't it?
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`.
8b2efea to
4caa2f4
Compare
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Dec 30, 2023
eric-wieser
reviewed
Dec 30, 2023
Comment on lines
+87
to
+90
| @[simp ↓] theorem ite_cond_true {_ : Decidable c} (a b : α) (h : c) : (if c then a else b) = a := by simp [h] | ||
| @[simp ↓] theorem ite_cond_false {_ : Decidable c} (a b : α) (h : ¬ c) : (if c then a else b) = b := by simp [h] | ||
| @[simp ↓] theorem dite_cond_true {α : Sort u} {_ : Decidable c} {t : c → α} {e : ¬ c → α} (h : c) : (dite c t e) = t h := by simp [h] | ||
| @[simp ↓] theorem dite_cond_false {α : Sort u} {_ : Decidable c} {t : c → α} {e : ¬ c → α} (h : ¬ c) : (dite c t e) = e h := by simp [h] |
Contributor
There was a problem hiding this comment.
What's the intended difference between these lemmas and if_pos/if_neg/dif_pos/dif_neg?
Member
Author
|
Subsumed by #3124 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #3118.
It breaks
Std, but it is an easy fix.