Skip to content

fix: reject sym apply with an unresolved instance argument#14113

Draft
sgraf812 wants to merge 1 commit into
masterfrom
sym-apply-unresolved-instance
Draft

fix: reject sym apply with an unresolved instance argument#14113
sgraf812 wants to merge 1 commit into
masterfrom
sym-apply-unresolved-instance

Conversation

@sgraf812

Copy link
Copy Markdown
Contributor

Lean.Meta.Sym.BackwardRule.apply takes its subgoals from mkResultPos, which
drops instance arguments on the assumption that type class resolution discharges
them. When trySynthInstance fails for an instance argument and unification does
not assign it, mkPreResult substitutes a fresh metavariable that is neither
returned as a subgoal nor otherwise resolved. The goal was closed with a proof
carrying that metavariable, surfacing later as a kernel unresolved-metavariable
error.

apply now checks, when handing out the subgoals, that every instance argument is
assigned (synthesized or unified). An unassigned one makes the rule inapplicable.

example : False := by sym => apply Inhabited.default

reports `apply` failed, rule is not applicable.

`BackwardRule.apply` takes its subgoals from `mkResultPos`, which drops
instance arguments on the assumption that type class resolution discharges
them. When `trySynthInstance` fails for an instance argument and unification
does not assign it, `mkPreResult` substitutes a fresh metavariable that is
neither returned as a subgoal nor otherwise resolved, so the goal was closed
with a proof carrying that metavariable. It surfaced later as a kernel
unresolved-metavariable error.

`apply` now checks, when handing out the subgoals, that every instance
argument is assigned. An unassigned one makes the rule inapplicable.
@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 Jun 18, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 518dc662d70fe6c566a0c935157690ee8ae53558 --onto 4792cd22887c8b529a351f6563b693426ff2a8f8. You can force Mathlib CI using the force-mathlib-ci label. (2026-06-18 17:21:55)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 518dc662d70fe6c566a0c935157690ee8ae53558 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using the force-manual-ci label. (2026-06-18 17:21:57)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants