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
[Merged by Bors] - feat: refactor of solve_by_elim #856
Closed
Conversation
This file contains 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
dwrensha
reviewed
Dec 5, 2022
dwrensha
reviewed
Dec 5, 2022
dwrensha
reviewed
Dec 5, 2022
semorrison
added
the
awaiting-review
The author would like community review of the PR
label
Dec 6, 2022
semorrison
added
the
merge-conflict
The PR has a merge conflict with master, and needs manual merging.
label
Jan 4, 2023
hrmacbeth
force-pushed
the
solve_by_elim_refactor
branch
from
January 4, 2023 21:57
117af73
to
21e2682
Compare
I got rid of the merge commit, should be back to previous state. |
semorrison
removed
the
merge-conflict
The PR has a merge conflict with master, and needs manual merging.
label
Jan 5, 2023
semorrison
added
merge-conflict
The PR has a merge conflict with master, and needs manual merging.
and removed
help-wanted
The author needs attention to resolve issues
labels
Jan 6, 2023
semorrison
removed
the
merge-conflict
The PR has a merge conflict with master, and needs manual merging.
label
Jan 9, 2023
This has had plenty of review and keeps getting conflicts. I'm going to go ahead and merge. Thanks! bors r+ |
github-actions
bot
added
ready-to-merge
This PR has been sent to bors.
and removed
awaiting-review
The author would like community review of the PR
labels
Jan 9, 2023
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: |
bors
bot
changed the title
feat: refactor of solve_by_elim
[Merged by Bors] - feat: refactor of solve_by_elim
Jan 9, 2023
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>
semorrison
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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]
.symm
on hypotheses andexfalso
on the goal, as needed.MetaM
level tooling for thesymm
tactic. (rfl
andtrans
deserve 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_assumption
andapply_rules
as thin wrappers aroundsolve_by_elim
, allowing access to new features (removing hypotheses, symm and exfalso) for free.library_search using
soexample (P Q : List ℕ) (h : ℕ) : List ℕ := by library_search using P, Q -- exact P ∩ Q