Skip to content
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

fix: make sure refine preserves pre-existing natural mvars #2435

Merged
merged 8 commits into from
Aug 26, 2023

Conversation

thorimur
Copy link
Contributor

@thorimur thorimur commented Aug 19, 2023

Fixes #2434. refine currently fails to include pre-existing natural metavariables from the refined term in the resulting goal list. For example, constructor creates natural metavariables, and we can close the goals with refine alone:

example : True ∧ True := by -- (kernel) declaration has metavariables '_example'
  constructor
  · refine ?left
  · refine ?right

The source of this issue is a bug in withCollectingNewGoalsFrom in elabTermWithHoles when allowNaturalHoles is false. Metavariables are separated into natural and non-natural, and then any new unassigned natural mvars (as determined by their index) cause the tactic to be aborted. If the tactic isn't aborted here, the non-natural mvars are passed through to constitute the new goal list. However, this orphans any pre-existing "old" natural mvars.

This PR fixes this by changing the process of logging and aborting upon encountering new natural mvars into an unless allowedNaturalHoles do ...-style guard. If we pass that guard, then we don't need to filter the original list of mvars at all; it's guaranteed to be free of new natural mvars, as required.

@github-actions
Copy link
Contributor

Thanks for your contribution! Please make sure to follow our Commit Convention.

@semorrison semorrison added the awaiting-author Waiting for PR author to address issues label Aug 23, 2023
thorimur and others added 2 commits August 22, 2023 23:38
@semorrison semorrison removed the awaiting-author Waiting for PR author to address issues label Aug 24, 2023
@thorimur thorimur marked this pull request as ready for review August 24, 2023 02:11
@semorrison semorrison added the awaiting-review Waiting for someone to review the PR label Aug 24, 2023
@semorrison semorrison self-assigned this Aug 24, 2023
@leodemoura leodemoura merged commit 0b64c1e into leanprover:master Aug 26, 2023
13 checks passed
semorrison added a commit that referenced this pull request Aug 30, 2023
semorrison added a commit that referenced this pull request Aug 30, 2023
thorimur added a commit to thorimur/lean4 that referenced this pull request Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Waiting for someone to review the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: refine loses track of natural goals
3 participants