Skip to content

fix: instantiate metavariables when collecting a goal's constants#13748

Merged
kim-em merged 2 commits into
masterfrom
fix-mepo-instantiate-mvars
May 18, 2026
Merged

fix: instantiate metavariables when collecting a goal's constants#13748
kim-em merged 2 commits into
masterfrom
fix-mepo-instantiate-mvars

Conversation

@kim-em
Copy link
Copy Markdown
Collaborator

@kim-em kim-em commented May 15, 2026

This PR fixes premise selection silently dropping relevant premises when the goal was reached via induction.

MVarId.getRelevantConstants and MVarId.getConstants walked the raw goal type returned by getType, which after induction is ?motive arg with ?motive an assigned-but-unsubstituted metavariable. The constant fold treats the metavariable as an opaque leaf, so every constant in the goal predicate is lost. Instantiating metavariables first recovers them.

Thanks to Xavier Généreux for the report.

🤖 Prepared with Claude Code

This PR fixes premise selection silently dropping relevant premises when the
goal was reached via `induction`.

`MVarId.getRelevantConstants` and `MVarId.getConstants` walked the raw goal
type returned by `getType`, which after `induction` is `?motive arg` with
`?motive` an assigned-but-unsubstituted metavariable. The constant fold treats
the metavariable as an opaque leaf, so every constant in the goal predicate is
lost. Instantiating metavariables first recovers them. Thanks to Xavier
Généreux for the report.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kim-em kim-em added the changelog-library Library label May 15, 2026
@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 May 16, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-04-29 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-05-16 00:26:37)

@github-actions github-actions Bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label May 16, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label May 16, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@kim-em kim-em added this pull request to the merge queue May 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 17, 2026
@nomeata
Copy link
Copy Markdown
Collaborator

nomeata commented May 17, 2026

This will not see constants behind non-ground delayed assigned meta variables. It may be even more robust to walk the mvar graph and collect constants from there, without instantiations. Not sure if that's relevant in practice.

…bles

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kim-em
Copy link
Copy Markdown
Collaborator Author

kim-em commented May 18, 2026

This will not see constants behind non-ground delayed assigned meta variables. It may be even more robust to walk the mvar graph and collect constants from there, without instantiations. Not sure if that's relevant in practice.

I'm inclined to avoid this complexity for now, but I've left a comment in the code.

@kim-em kim-em enabled auto-merge May 18, 2026 15:09
@kim-em kim-em added this pull request to the merge queue May 18, 2026
Merged via the queue into master with commit 6d5ec05 May 18, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan changelog-library Library mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

3 participants