fix: kernel error from simp results cached with a proof that has free variables - #14965
Draft
nomeata wants to merge 1 commit into
Draft
fix: kernel error from simp results cached with a proof that has free variables#14965nomeata wants to merge 1 commit into
simp results cached with a proof that has free variables#14965nomeata wants to merge 1 commit into
Conversation
…ee variables This PR fixes `simp` producing a proof with free variables, rejected by the kernel with "declaration has free variables", when the same `match` application occurs in two branches of a `dite`. This also affected the equation lemmas generated for well-founded definitions containing such a term. `simp` caches results by expression, so the proof of a cached result must not mention local hypotheses that `simp` introduced itself while descending into the term (see `Methods.wellBehavedDischarge`). `dischargeEqnThmHypothesis?` violated this: proving a match-equation side condition substitutes a discriminant, and `subst` reverts every hypothesis depending on it, pulling e.g. the `dite` hypothesis into the proof. It now clears those hypotheses from the goal first; `tryClearMany` keeps the ones the side condition itself depends on. Closes #14961. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nk92q7cJwjqGyg8kep2Gyi
Collaborator
Author
|
Claude generated fix. Sounds plausible, but probably deserves a review of someone with better knowledge of the simp cache. Leaving it here as a draft for now. |
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Aug 29, 2026
Collaborator
|
Reference manual CI status:
|
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Aug 29, 2026
leanprover-bot
added a commit
to leanprover/reference-manual
that referenced
this pull request
Aug 29, 2026
|
Mathlib CI status (docs):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes
simpproducing a proof with free variables, rejected by the kernel with "declaration has free variables", when the samematchapplication occurs in two branches of adite. This also affected the equation lemmas generated for well-founded definitions containing such a term.simpcaches results by expression, so the proof of a cached result must not mention local hypotheses thatsimpintroduced itself while descending into the term (seeMethods.wellBehavedDischarge).dischargeEqnThmHypothesis?violated this: proving a match-equation side condition substitutes a discriminant, andsubstreverts every hypothesis depending on it, pulling e.g. theditehypothesis into the proof. It now clears those hypotheses from the goal first;tryClearManykeeps the ones the side condition itself depends on.Closes #14961.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Nk92q7cJwjqGyg8kep2Gyi