Skip to content

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

Merged
leodemoura merged 8 commits into
leanprover:masterfrom
thorimur:refine-natural-fix
Aug 26, 2023
Merged

leodemoura merged 8 commits into
leanprover:masterfrom
thorimur:refine-natural-fix

Conversation

@thorimur

@thorimur thorimur commented Aug 19, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@thorimur thorimur mentioned this pull request Aug 19, 2023
1 task done
Comment thread src/Lean/Elab/Tactic/ElabTerm.lean Resolved
@kim-em kim-em added the awaiting-author Waiting for PR author to address issues label Aug 23, 2023
@kim-em kim-em 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
@kim-em kim-em added the awaiting-review Waiting for someone to review the PR label Aug 24, 2023
@kim-em kim-em self-assigned this Aug 24, 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