fix: don't resynthesize unwrapped nested proofs in the grind canonicalizer - #14439
Merged
Conversation
leodemoura
enabled auto-merge
July 18, 2026 04:33
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
robsimmons
pushed a commit
that referenced
this pull request
Jul 29, 2026
…lizer (#14439) This PR fixes a `grind` bug where the canonicalizer could resynthesize a propositional instance (e.g. `Nonempty α`) occurring in a binder body skipped by preprocessing, producing a closed nested proof lacking the `Grind.nestedProof` wrapper. Congruence closure then treated the term as distinct from correctly wrapped occurrences of the same application, and `grind` missed valid contradictions. Closes #13655. The preprocessing step `markNestedSubsingletons` wraps every closed nested proof with `Grind.nestedProof`, but skips forall bodies with loose bound variables; such bodies are re-preprocessed by `propagateForallPropUp` when instantiated. Resynthesizing an unwrapped proof inside such a body could remove the dependency on the bound variable, and the now-closed body was then internalized via the non-dependent fast path without re-preprocessing. The fix makes `canonInst'` keep unwrapped `Prop`-typed instances unchanged in term positions: the forall stays dependent, and the slow path re-preprocesses the instantiated body consistently. Behavior inside types is unchanged, where instances are deliberately unwrapped and resynthesized for structural agreement. Thanks to @datokrat for the detailed analysis in the issue report. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 a
grindbug where the canonicalizer could resynthesize a propositional instance (e.g.Nonempty α) occurring in a binder body skipped by preprocessing, producing a closed nested proof lacking theGrind.nestedProofwrapper. Congruence closure then treated the term as distinct from correctly wrapped occurrences of the same application, andgrindmissed valid contradictions. Closes #13655.The preprocessing step
markNestedSubsingletonswraps every closed nested proof withGrind.nestedProof, but skips forall bodies with loose bound variables; such bodies are re-preprocessed bypropagateForallPropUpwhen instantiated. Resynthesizing an unwrapped proof inside such a body could remove the dependency on the bound variable, and the now-closed body was then internalized via the non-dependent fast path without re-preprocessing. The fix makescanonInst'keep unwrappedProp-typed instances unchanged in term positions: the forall stays dependent, and the slow path re-preprocesses the instantiated body consistently. Behavior inside types is unchanged, where instances are deliberately unwrapped and resynthesized for structural agreement.Thanks to @datokrat for the detailed analysis in the issue report.
🤖 Generated with Claude Code