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: add instantiateMVars to replaceLocalDecl #2712

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

thorimur
Copy link
Contributor

@thorimur thorimur commented Oct 19, 2023

First half of fixing #2711. (Second half is #2728.) Makes replaceLocalDecl more robust by inserting an instantiateMVars. It should now be less possible to introduce an unknown free variable by replaceLocalDecl alone. This affects many at tactics.

However, this might not safeguard against all errors—in particular, mvars can still be synthesized to later-occurring fvars after the fact. See issue #2727.


This was benched on mathlib against nightly testing here. There didn't seem to be significant changes.

To find the relevant mathlib4 branches on speedcenter manually, search "2712" and compare the branch bench-nightly-testing-for-2712 (baseline) to lean-pr-testing-2712.

Note: it took a while to get mathlib and std synced up to the current lean changes; the mathlib build failures were unrelated to this PR. This PR doesn't require any changes to mathlib or std.

@thorimur thorimur force-pushed the replaceLocalDecl-instantiateMVars branch 2 times, most recently from 09a2ff9 to 80017dd Compare October 19, 2023 08:34
@kim-em
Copy link
Collaborator

kim-em commented Oct 19, 2023

!bench

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 80017dd.
There were no significant changes against commit fb0d024.

@thorimur
Copy link
Contributor Author

WIP

@github-actions github-actions bot added the WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet. label Oct 19, 2023
@thorimur thorimur force-pushed the replaceLocalDecl-instantiateMVars branch 2 times, most recently from 4ddc3bb to c95cf65 Compare October 21, 2023 07:42
@thorimur thorimur mentioned this pull request Oct 21, 2023
2 tasks
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Oct 21, 2023
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 21, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Oct 21, 2023
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Oct 21, 2023

kim-em added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 22, 2023
@thorimur thorimur force-pushed the replaceLocalDecl-instantiateMVars branch from c95cf65 to e56563d Compare October 22, 2023 01:24
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 22, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Oct 22, 2023
@thorimur thorimur marked this pull request as ready for review October 23, 2023 03:39
@thorimur
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot added awaiting-review Waiting for someone to review the PR and removed WIP This is work in progress, and only a PR for the sake of CI or sharing. No review yet. labels Oct 23, 2023
Comment on lines 19 to 23
However, if it encounters a metavariable during this traversal, it simply continues traversing,
even if this metavariable is assigned to an expression which contains an `FVarId` occurring after
`fvarId`. This can lead to `replaceLocalDecl` inserting a local declaration with a type which
depends on `FVarId`s which come after it in the local context, thus creating unknown `FVarId`s (the
`FVarId`s of the local declarations after the insertion are modified).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify that this is describing the previous behaviour (which would have caused this test to fail)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, done in fbc8de6.

@kim-em kim-em self-assigned this Oct 24, 2023
@thorimur thorimur force-pushed the replaceLocalDecl-instantiateMVars branch from e56563d to fbc8de6 Compare October 24, 2023 21:33
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 24, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan and removed builds-mathlib CI has verified that Mathlib builds against this PR labels Oct 24, 2023
@kim-em kim-em merged commit 291e95e into leanprover:master Oct 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 breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants