Repository navigation
fix: make unfold on non-recursive definitions independent of eq_def realization - #15687
Merged
Merged
Conversation
Kha
force-pushed
the
unfold-nonrec-eq-def
branch
from
November 19, 2026 08:47
53e036e to
3df1a61
Compare
…f` realization This PR makes `unfold f` on a non-recursive definition `f` always unfold by plain delta expansion. Previously, it rewrote with `f.eq_def` and reduced the resulting matcher application whenever that theorem happened to exist already, so the resulting goal depended on whether some earlier tactic such as `fun_cases f` had realized it and, across modules, on whether that realization was visible to the importing module. `getUnfoldEqnFor?` with `nonRec := false` now returns `none` for every non-recursive definition: the lookup of an existing `eq_def` is only done for recursive definitions or when `nonRec` is set. The lookup also moves behind the `shouldGenerateEqnThms` guard, so a hand-written `X.eq_def` for a constant `X` that is not a definition, where the name is not reserved, is no longer returned as the unfold theorem of `X`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kha
force-pushed
the
unfold-nonrec-eq-def
branch
from
November 19, 2026 16:17
3df1a61 to
02cc066
Compare
Kha
force-pushed
the
unfold-nonrec-eq-def
branch
from
November 20, 2026 09:05
02cc066 to
8a98cb7
Compare
Kha
force-pushed
the
unfold-nonrec-eq-def
branch
from
November 20, 2026 09:06
8a98cb7 to
1a21a14
Compare
Kha
marked this pull request as ready for review
November 20, 2026 09:09
|
The adaptation PR for this PR is leanprover/downstream-lean4#265. |
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 makes the result of
unfold ffor a non-recursive definitionfindependent of what was elaborated earlier. Previously, amatchon a constructor in the unfolded body was reduced only if an earlier tactic such asfun_cases f, possibly in another module, happened to have been run. Nowunfold fnever reduces it; proofs that relied on the reduction can do it explicitly, for example withdsimp -zeta only.The reduction happened when
unfoldrewrote withf.eq_def, which it did whenever that theorem already existed, and otherwise it fell back to delta expansion.getUnfoldEqnFor?withnonRec := falsenow returnsnonefor every non-recursive definition, sounfoldalways uses delta expansion for them: the lookup of an existingeq_defis only done for recursive definitions or whennonRecis set. The lookup also moves behind theshouldGenerateEqnThmsguard, so a hand-writtenX.eq_deffor a constantXthat is not a definition, where the name is not reserved, is no longer returned as the unfold theorem ofX.