Skip to content

fix: clean missing-spec error when a selected vcgen spec fails to apply - #14490

Merged
sgraf812 merged 1 commit into
masterfrom
sg/vcgen-findspec-softmiss
Jul 22, 2026
Merged

fix: clean missing-spec error when a selected vcgen spec fails to apply#14490
sgraf812 merged 1 commit into
masterfrom
sg/vcgen-findspec-softmiss

Conversation

@sgraf812

@sgraf812 sgraf812 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This PR makes vcgen report a clean missing-spec error when the spec it selects for a program turns out not to unify with it, instead of dumping the internal backward rule and its type.

The spec discrimination tree over-approximates, so a sole candidate returned by spec selection may not unify with the program. When the selected rule fails to apply, applySpec now matches the spec's pattern against the program: if the pattern does not unify, it routes through the same missing-spec handling as every other unmatched-spec case; if the pattern does unify, the rule failure is a genuine bug and the original hard error is preserved. The improvement is covered by the updated recf expectation in tests/elab/vcgenUnfoldMatchDef.lean.

@sgraf812 sgraf812 added the changelog-tactics User facing tactics label Jul 22, 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 Jul 22, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Jul 22, 2026

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 943e616509e287b7055c0571e11dba6cbb8c9b3b --onto 3259610687883ec1ea48c481aba2469f2f83facf. You can force Mathlib CI using the force-mathlib-ci label. (2026-07-22 07:48:23)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 2065c90062893508ded6433d2e2d81c33af4e761 --onto 3259610687883ec1ea48c481aba2469f2f83facf. You can force Mathlib CI using the force-mathlib-ci label. (2026-07-22 09:09:15)

@leanprover-bot

leanprover-bot commented Jul 22, 2026

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 943e616509e287b7055c0571e11dba6cbb8c9b3b --onto 49ff95727f98d43984726b26742d17a1ceea9dd5. You can force reference manual CI using the force-manual-ci label. (2026-07-22 07:48:25)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 2065c90062893508ded6433d2e2d81c33af4e761 --onto 49ff95727f98d43984726b26742d17a1ceea9dd5. You can force reference manual CI using the force-manual-ci label. (2026-07-22 09:09:17)

@sgraf812
sgraf812 force-pushed the sg/vcgen-findspec-softmiss branch from 6bb56c7 to 17b0fa8 Compare July 22, 2026 08:43
…pply

This PR makes `vcgen` report a clean missing-spec error when the spec it selects for a program turns out not to unify with it, instead of dumping the internal backward rule and its type.

The spec discrimination tree over-approximates, so a sole candidate returned by spec selection may not unify with the program. When the selected rule fails to apply, `applySpec` now matches the spec's pattern against the program: if the pattern does not unify, it routes through the same missing-spec handling as every other unmatched-spec case (naming the program and its candidates, or emitting the goal as a verification condition under `-errorOnMissingSpec`); if the pattern does unify, the rule failure is a genuine bug and the original hard error is preserved. The improvement is covered by the updated `recf` expectation in `tests/elab/vcgenUnfoldMatchDef.lean`.
@sgraf812
sgraf812 force-pushed the sg/vcgen-findspec-softmiss branch from 17b0fa8 to 13fe08b Compare July 22, 2026 09:08
@sgraf812
sgraf812 marked this pull request as ready for review July 22, 2026 09:11
@sgraf812
sgraf812 enabled auto-merge July 22, 2026 09:12
@sgraf812
sgraf812 added this pull request to the merge queue Jul 22, 2026
Merged via the queue into master with commit 7d4da39 Jul 22, 2026
21 checks passed
@sgraf812
sgraf812 deleted the sg/vcgen-findspec-softmiss branch July 27, 2026 12:21
robsimmons pushed a commit that referenced this pull request Jul 29, 2026
…pply (#14490)

This PR makes `vcgen` report a clean missing-spec error when the spec it
selects for a program turns out not to unify with it, instead of dumping
the internal backward rule and its type.

The spec discrimination tree over-approximates, so a sole candidate
returned by spec selection may not unify with the program. When the
selected rule fails to apply, `applySpec` now matches the spec's pattern
against the program: if the pattern does not unify, it routes through
the same missing-spec handling as every other unmatched-spec case; if
the pattern does unify, the rule failure is a genuine bug and the
original hard error is preserved. The improvement is covered by the
updated `recf` expectation in `tests/elab/vcgenUnfoldMatchDef.lean`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-tactics User facing tactics 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