Skip to content

fix: don't resynthesize unwrapped nested proofs in the grind canonicalizer - #14439

Merged
leodemoura merged 1 commit into
masterfrom
grind_13655
Jul 18, 2026
Merged

fix: don't resynthesize unwrapped nested proofs in the grind canonicalizer#14439
leodemoura merged 1 commit into
masterfrom
grind_13655

Conversation

@leodemoura

Copy link
Copy Markdown
Member

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

@leodemoura leodemoura added the changelog-tactics User facing tactics label Jul 18, 2026
@leodemoura
leodemoura enabled auto-merge July 18, 2026 04:33
@leodemoura
leodemoura added this pull request to the merge queue Jul 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 Jul 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 b9c91298fc961122eadfdf4ff2a3ee4ce6c2071b --onto 79bec6d064d8672cb10864cad3d9fd054b6917ae. You can force Mathlib CI using the force-mathlib-ci label. (2026-07-18 04:55:04)

@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 b9c91298fc961122eadfdf4ff2a3ee4ce6c2071b --onto 79bec6d064d8672cb10864cad3d9fd054b6917ae. You can force reference manual CI using the force-manual-ci label. (2026-07-18 04:55:06)

Merged via the queue into master with commit 49ff957 Jul 18, 2026
24 checks passed
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)
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.

grind canonicalizer creates closed term with proof lacking nestedProof

2 participants