Repository navigation
Conversation
This PR extends the kernel's `lazy_delta_reduction_step` optimization to handle
plain constants, not just applications. Previously, when comparing two constants
with the same name but different universe parameters (e.g., `c.{max u v}` vs
`c.{max v u}`), the kernel would unfold both before discovering the universes
are definitionally equal.
This caused severe performance issues when the unfolded terms are large. The fix
checks universe equality for plain constants before unfolding, matching the
existing optimization for applications.
Closes #12102
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
This was referenced Jan 27, 2026
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Jan 27, 2026
This PR switches the PR release workflow from `softprops/action-gh-release` to `gh release create`. The `softprops/action-gh-release` action enumerates all releases to check for existing ones, which fails when the repository has more than 10000 releases due to GitHub API pagination limits. The `lean4-pr-releases` repository has accumulated over 10000 releases, causing the PR release workflow to fail with: ``` Only the first 10000 results are available. ``` This is currently blocking all PR toolchain releases, including #12175. 🤖 Prepared with Claude Code --------- Co-authored-by: Claude <[email protected]>
ghost
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Jan 27, 2026
ghost
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Jan 27, 2026
leanprover-bot
added a commit
to leanprover/reference-manual
that referenced
this pull request
Jan 27, 2026
Collaborator
|
Reference manual CI status:
|
Collaborator
Author
|
!radar |
|
Benchmark results for c0d1025 against 0e28043 are in! @kim-em
Small changes (4✅)
|
|
kim-em
added a commit
to kim-em/lean4
that referenced
this pull request
Jan 27, 2026
This extends the kernel fix from PR leanprover#12175 to the elaborator. In isDefEqDeltaStep.unfoldBoth, when comparing two plain constants with the same name but different universe parameters (e.g., c.{max u v} vs c.{max v u}), check if the universes are definitionally equal before unfolding. This avoids expensive unfolding when the terms are defeq modulo universe ordering. On the test case from leanprover#12102, this reduces elaboration time from 3.7M heartbeats to 7.3K heartbeats (499x speedup). Related: leanprover#12175 (kernel fix), leanprover#12102 (issue)
kim-em
added a commit
to kim-em/lean4
that referenced
this pull request
Jan 27, 2026
This extends the kernel fix from PR leanprover#12175 to the elaborator. In isDefEqDeltaStep.unfoldBoth, when comparing two plain constants with the same name but different universe parameters (e.g., c.{max u v} vs c.{max v u}), check if the universes are definitionally equal before unfolding. This avoids expensive unfolding when the terms are defeq modulo universe ordering. On the test case from leanprover#12102, this reduces elaboration time from 3.7M heartbeats to 7.3K heartbeats (499x speedup). Related: leanprover#12175 (kernel fix), leanprover#12102 (issue)
kim-em
added a commit
that referenced
this pull request
Jan 27, 2026
When comparing two projections like `bar.toA` vs `bar.toA` where `bar` has universe `max u v` on one side and `max v u` on the other, check universe equality early before entering the lazy_delta_proj_reduction loop. This is a more aggressive optimization than #12175, which adds the check inside the delta reduction loop. By checking in the projection handler itself, we can potentially skip expensive work that happens before reaching the delta step. Related: #12102, #12175
Collaborator
Author
|
Closing: this PR doesn't help the real Mathlib slowdown pattern (tested with KaehlerDifferential universe ordering issue). |
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 extends the kernel's
lazy_delta_reduction_stepoptimization to handle plain constants, not just applications. Previously, when comparing two constants with the same name but different universe parameters (e.g.,c.{max u v}vsc.{max v u}), the kernel would unfold both before discovering the universes are definitionally equal. This caused severe performance issues when the unfolded terms are large (600x slowdown reported in #12102).The fix checks universe equality for plain constants before unfolding, matching the existing optimization for applications.
The test in
tests/lean/run/issue12102.leanverifies:[kernel] bar ↦ 2Closes #12102
🤖 Prepared with Claude Code