Skip to content

fix: reject non-propositions in Sym.simp theorem lists - #14814

Merged
leodemoura merged 1 commit into
masterfrom
sym_simp_issue
Aug 18, 2026
Merged

leodemoura merged 1 commit into
masterfrom
sym_simp_issue

Conversation

@leodemoura

Copy link
Copy Markdown
Member

This PR fixes an internal error (unexpected bound variable #3) when a declaration that is not a proposition is used as a Sym.simp theorem, as in sym => simp [HAdd.hAdd]. It now produces a proper error message.

The root cause was in selectEqKey: it received the conclusion of the candidate theorem after all leading binders had been stripped into loose bound variables, and its fallback isProp check invoked inferType on an open term. The fix moves the check to mkTheoremFromDecl and mkTheoremFromExpr. This also fixes the same crash for valid theorems whose conclusion is a bound Prop variable, such as ∀ (p : Prop), p → p.

This PR fixes an internal error (`unexpected bound variable #3`) when
a declaration that is not a proposition is used as a `Sym.simp` theorem,
as in `sym => simp [HAdd.hAdd]`. It now produces a proper error message.

The root cause was in `selectEqKey`: it received the conclusion of the
candidate theorem after all leading binders had been stripped into loose bound variables,
and its fallback `isProp` check invoked `inferType` on an open term.
The fix moves the check to `mkTheoremFromDecl` and `mkTheoremFromExpr`.
This also fixes the same crash for valid theorems whose conclusion is a bound `Prop` variable,
such as `∀ (p : Prop), p → p`.
@leodemoura leodemoura added the changelog-tactics User facing tactics label Aug 18, 2026
@leodemoura
leodemoura enabled auto-merge August 18, 2026 09:42
@leodemoura
leodemoura added this pull request to the merge queue Aug 18, 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 Aug 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 a3c115771a3e9d5ec426a68d9782a80311d914b5 --onto 6e91fff236ea9c68465989c1ecdf79b60e2f6bff. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-18 10:09:17)

@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 a3c115771a3e9d5ec426a68d9782a80311d914b5 --onto 3fc29d37a70f8fd904ebab848557c12383543008. You can force reference manual CI using the force-manual-ci label. (2026-08-18 10:09:19)

Merged via the queue into master with commit 8426679 Aug 18, 2026
25 checks passed
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