[Merged by Bors] - feat: refactor of solve_by_elim#856
Closed
[Merged by Bors] - feat: refactor of solve_by_elim#856
Conversation
dwrensha
reviewed
Dec 5, 2022
dwrensha
reviewed
Dec 5, 2022
dwrensha
reviewed
Dec 5, 2022
117af73 to
21e2682
Compare
Member
|
I got rid of the merge commit, should be back to previous state. |
Member
|
This has had plenty of review and keeps getting conflicts. I'm going to go ahead and merge. Thanks! bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Jan 9, 2023
This is a thorough refactor of `solve_by_elim`. * Bug fixes and additional tests. * Support for removing local hypotheses using `solve_by_elim [-h]`. * Use `symm` on hypotheses and `exfalso` on the goal, as needed. * To support that, `MetaM` level tooling for the `symm` tactic. (`rfl` and `trans` deserve the same treatment at some point.) * Additional hooks for flow control in `solve_by_elim` (suspending goals to return to the user, rejecting branches, running arbitrary procedures on the goals). * Using those hooks, reimplement `apply_assumption` and `apply_rules` as thin wrappers around `solve_by_elim`, allowing access to new features (removing hypotheses, symm and exfalso) for free. * Using those hooks, fix `library_search using` so ```example (P Q : List ℕ) (h : ℕ) : List ℕ := by library_search using P, Q -- exact P ∩ Q``` Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
|
Pull request successfully merged into master. Build succeeded: |
jcommelin
pushed a commit
that referenced
this pull request
Jan 23, 2023
This is a thorough refactor of `solve_by_elim`. * Bug fixes and additional tests. * Support for removing local hypotheses using `solve_by_elim [-h]`. * Use `symm` on hypotheses and `exfalso` on the goal, as needed. * To support that, `MetaM` level tooling for the `symm` tactic. (`rfl` and `trans` deserve the same treatment at some point.) * Additional hooks for flow control in `solve_by_elim` (suspending goals to return to the user, rejecting branches, running arbitrary procedures on the goals). * Using those hooks, reimplement `apply_assumption` and `apply_rules` as thin wrappers around `solve_by_elim`, allowing access to new features (removing hypotheses, symm and exfalso) for free. * Using those hooks, fix `library_search using` so ```example (P Q : List ℕ) (h : ℕ) : List ℕ := by library_search using P, Q -- exact P ∩ Q``` Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
bors bot
pushed a commit
that referenced
this pull request
Feb 15, 2023
…2302) Fixes a bug introduced in #856. If `solveByElim` succeeds, then we should return early. Otherwise, we look through all lemmas in the environment and find something like `namedPattern` or `Eq.mp` and unnecessarily wrap the result in that. See #2276 for an example bad output caused by this bug. Another example is this test: https://github.com/leanprover-community/mathlib4/blob/4ed65899eca4909e9b8f23a113b52ff8cb3f5d41/test/librarySearch.lean#L15 On master, it emits `exact namedPattern p p rfl`, and after this PR it correctly emits `exact p`.
mo271
pushed a commit
that referenced
this pull request
Feb 18, 2023
…2302) Fixes a bug introduced in #856. If `solveByElim` succeeds, then we should return early. Otherwise, we look through all lemmas in the environment and find something like `namedPattern` or `Eq.mp` and unnecessarily wrap the result in that. See #2276 for an example bad output caused by this bug. Another example is this test: https://github.com/leanprover-community/mathlib4/blob/4ed65899eca4909e9b8f23a113b52ff8cb3f5d41/test/librarySearch.lean#L15 On master, it emits `exact namedPattern p p rfl`, and after this PR it correctly emits `exact p`.
1 task
bors bot
pushed a commit
that referenced
this pull request
Apr 21, 2023
We had some unfortunate spaghetti code in `solve_by_elim`. When @hrmacbeth had requested additional features for `apply_rules`, the easiest way to provide them was to re-use `solve_by_elim`'s parsing and lemma handling. (See #856.) However `apply_rules` doesn't to backtracking, and `solve_by_elim` is all about it. At the time, `solve_by_elim` didn't have clean separation between its "lemma application" and "backtracking" considerations, so the solution was to add some hacks the prevented the backtracking from actually occurring, in the backtracking code... Since #2920, those considerations have been cleanly separated out. Thus it's possible to greatly simplify how we don't backtrack when we don't want to (in `apply_rules`). This PR does that. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
kbuzzard
pushed a commit
that referenced
this pull request
Apr 22, 2023
We had some unfortunate spaghetti code in `solve_by_elim`. When @hrmacbeth had requested additional features for `apply_rules`, the easiest way to provide them was to re-use `solve_by_elim`'s parsing and lemma handling. (See #856.) However `apply_rules` doesn't to backtracking, and `solve_by_elim` is all about it. At the time, `solve_by_elim` didn't have clean separation between its "lemma application" and "backtracking" considerations, so the solution was to add some hacks the prevented the backtracking from actually occurring, in the backtracking code... Since #2920, those considerations have been cleanly separated out. Thus it's possible to greatly simplify how we don't backtrack when we don't want to (in `apply_rules`). This PR does that. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
kim-em
added a commit
that referenced
this pull request
May 10, 2023
We had some unfortunate spaghetti code in `solve_by_elim`. When @hrmacbeth had requested additional features for `apply_rules`, the easiest way to provide them was to re-use `solve_by_elim`'s parsing and lemma handling. (See #856.) However `apply_rules` doesn't to backtracking, and `solve_by_elim` is all about it. At the time, `solve_by_elim` didn't have clean separation between its "lemma application" and "backtracking" considerations, so the solution was to add some hacks the prevented the backtracking from actually occurring, in the backtracking code... Since #2920, those considerations have been cleanly separated out. Thus it's possible to greatly simplify how we don't backtrack when we don't want to (in `apply_rules`). This PR does that. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
hrmacbeth
pushed a commit
that referenced
this pull request
May 10, 2023
We had some unfortunate spaghetti code in `solve_by_elim`. When @hrmacbeth had requested additional features for `apply_rules`, the easiest way to provide them was to re-use `solve_by_elim`'s parsing and lemma handling. (See #856.) However `apply_rules` doesn't to backtracking, and `solve_by_elim` is all about it. At the time, `solve_by_elim` didn't have clean separation between its "lemma application" and "backtracking" considerations, so the solution was to add some hacks the prevented the backtracking from actually occurring, in the backtracking code... Since #2920, those considerations have been cleanly separated out. Thus it's possible to greatly simplify how we don't backtrack when we don't want to (in `apply_rules`). This PR does that. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
hrmacbeth
pushed a commit
that referenced
this pull request
May 11, 2023
We had some unfortunate spaghetti code in `solve_by_elim`. When @hrmacbeth had requested additional features for `apply_rules`, the easiest way to provide them was to re-use `solve_by_elim`'s parsing and lemma handling. (See #856.) However `apply_rules` doesn't to backtracking, and `solve_by_elim` is all about it. At the time, `solve_by_elim` didn't have clean separation between its "lemma application" and "backtracking" considerations, so the solution was to add some hacks the prevented the backtracking from actually occurring, in the backtracking code... Since #2920, those considerations have been cleanly separated out. Thus it's possible to greatly simplify how we don't backtrack when we don't want to (in `apply_rules`). This PR does that. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
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.
This is a thorough refactor of
solve_by_elim.solve_by_elim [-h].symmon hypotheses andexfalsoon the goal, as needed.MetaMlevel tooling for thesymmtactic. (rflandtransdeserve the same treatment at some point.)solve_by_elim(suspending goals to return to the user, rejecting branches, running arbitrary procedures on the goals).apply_assumptionandapply_rulesas thin wrappers aroundsolve_by_elim, allowing access to new features (removing hypotheses, symm and exfalso) for free.library_search usingsoexample (P Q : List ℕ) (h : ℕ) : List ℕ := by library_search using P, Q -- exact P ∩ Q