Skip to content

fix: let simp apply autogenerated congruence theorems #9493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Jul 23, 2025

This PR fixes a simp issue where arguments to partially-applied functions that were depended-upon by proof/subsingleton arguments were not being simplified. In particular, the congruence lemma generator mkCongrSimp? did not take into account the number of arguments in an application, instead assuming all functions were fully applied.

Closes #2128

Implementation note: now the congruence lemma cache is keyed by the expected arity as well.

Mathlib note: the only breakage is a handful of simp_rws that started to loop because this PR unlocked some rewrites. They were using rules of the form x = f x, so the remediation was to either use rw or to add the +singlePass option.

The PR doesn't address congruence lemmas for overapplied functions.

This PR modifies `mkCongrSimp?` to take the number of arguments in an application into account when generating congruence lemmas. This fixes an issue where partially applied functions with proof/subsingleton dependencies were not being simplified.

Closes leanprover#2128

This does not yet help `simp` handle over-applied functions.
@kmill kmill added the changelog-language Language features, tactics, and metaprograms label Jul 23, 2025
@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 23, 2025
@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2025-07-18 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2025-07-23 19:41:15)

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jul 23, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jul 23, 2025
@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Jul 23, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Jul 23, 2025

Mathlib CI status (docs):

@kmill kmill marked this pull request as ready for review July 24, 2025 14:38
@kmill kmill requested a review from leodemoura as a code owner July 24, 2025 14:38
@leanprover-community-bot leanprover-community-bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features, tactics, and metaprograms 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.

Congruence lemmas are not used for partially applied functions
3 participants