fix: only return new mvars from refine, elabTermWithHoles, and withCollectingNewGoalsFrom#2502
Merged
kim-em merged 13 commits intoleanprover:masterfrom Sep 21, 2023
Merged
Conversation
do not collect old goals
Contributor
|
Thanks for your contribution! Please make sure to follow our Commit Convention. |
Contributor
Author
|
WIP |
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Sep 1, 2023
|
refine, elabTermWithHoles only return new mvarsrefine, elabTermWithHoles, and withCollectingNewGoalsFrom
1 task
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Sep 2, 2023
1 task
1 task
Contributor
Author
|
awaiting-review |
Collaborator
|
Could you merge your Mathlib fixes to the |
kim-em
reviewed
Sep 4, 2023
kim-em
reviewed
Sep 4, 2023
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Sep 4, 2023
ghost
pushed a commit
to leanprover-community/mathlib4
that referenced
this pull request
Sep 20, 2023
kim-em
approved these changes
Sep 21, 2023
thorimur
added a commit
to thorimur/lean4
that referenced
this pull request
Sep 30, 2023
thorimur
added a commit
to thorimur/lean4
that referenced
this pull request
Sep 30, 2023
thorimur
added a commit
to thorimur/lean4
that referenced
this pull request
Sep 30, 2023
thorimur
added a commit
to thorimur/lean4
that referenced
this pull request
Sep 30, 2023
thorimur
added a commit
to thorimur/lean4
that referenced
this pull request
Sep 30, 2023
thorimur
added a commit
to thorimur/lean4
that referenced
this pull request
Sep 30, 2023
kim-em
pushed a commit
that referenced
this pull request
Oct 2, 2023
This was referenced Jan 4, 2024
This was referenced Feb 17, 2026
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.
Fixes #2495 and #2434 by making sure that
withCollectingNewGoalsonly returns mvarIds created during elaboration. This changes the behavior ofelabTermWithHolesandrefineaccordingly:refine enow replaces the main goal only with goals that were created during elaboration ofe(and does not include goals that appear inebut existed prior to its elaboration).Consequences of this change:
refine(bug:refineduplicates goals in the infoview #2495): pre-existing goals are now excluded from the resulting tactic state, and thus don't appear twice.refinestatement manages to be included in its resulting goals unexpectedly, due to being present in e.g. an implicit argument.refinewas inconsistent in which pre-existing goals were returned; this is the content of issue bug:refineloses track of natural goals #2434, which points out that pre-existing natural mvars are not returned, while synthetic mvars are.refine's occurs check relied on all mvars appearing in the expression being returned, and so goals were erroneously closed. This renders that issue moot by uniformly not returning any old mvars, and updating the occurs check accordingly.refineandconvert(which relies onwithCollectingNewGoalsFrom). All breakages are instances of goal tunneling, and are easily fixed. These fixes are done in bump: lean4: account for leanprover/lean4#2502 leanprover-community/mathlib4#6928. Note, however, that it breaks mathlib less than an incremental fix of bug:refineloses track of natural goals #2434 alone, which required us to filter out old mvars anyway inchange.elabTermWithHolesandwithCollectingNewGoalsFromto behave in this way already—see zulip for an expression of this sentiment.Note also that this streamlines the code of
withCollectingNewGoalsFrom, replacingwith simply
(plus comments).
Changes made by this PR
prevents
withCollectingNewGoalsFrom, and thereforeelabTermWithHoles,refine, andspecializefrom returning old goalsupdates the occurs check in
refineto compensate for this change (note thatspecializedoes not have an occurs check; this is a separate issue)adds a missing docstring to
elabTermWithHolesadds tests for bug:
refineduplicates goals in the infoview #2495, goal tunneling, and bug:refineloses track of natural goals #2434changes test
run/492.lean, which made incidental use of goal tunnelingExternal Contribution Guidelines.