Skip to content

feat: use right-associativity in Level.max normalization#13366

Draft
kmill wants to merge 5 commits intomasterfrom
kmill_level_assoc
Draft

feat: use right-associativity in Level.max normalization#13366
kmill wants to merge 5 commits intomasterfrom
kmill_level_assoc

Conversation

@kmill
Copy link
Copy Markdown
Collaborator

@kmill kmill commented Apr 10, 2026

This PR changes the elaborator Level.normalize to right-associate max expressions, to match max notation itself and to match the kernel. It also fixes an issue where simplifiable imax expressions would result in unnormalized level expressions (e.g. (imax (max u v) (max v u)) + 1 would normalize to (max u v) + 1 instead of max (u + 1) (v + 1)).

Closes #5695

This PR changes the elaborator `Level.normalize` to right-associate `max` expressions, to match `max` notation itself and to match the kernel. It also fixes an issue where simplifiable `imax` expressions would result in unnormalized level expressions (e.g. `(imax (max u v) (max v u)) + 1` would normalize to `(max u v) + 1` instead of `max (u + 1) (v + 1)`).
@kmill kmill added the changelog-language Language features and metaprograms label Apr 10, 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 Apr 10, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-04-10 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. (2026-04-10 18:30:54)

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Apr 10, 2026
@github-actions github-actions bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Apr 10, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 10, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Apr 10, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Apr 10, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 10, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Apr 11, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 11, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

… simplified decLevel? implementation, add SuccMax approximation, postpone SelfMax further
mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Apr 13, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 13, 2026
@kmill
Copy link
Copy Markdown
Collaborator Author

kmill commented Apr 13, 2026

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Apr 13, 2026

Benchmark results for 293afe9 against e0a29f4 are in. Significant changes detected! @kmill

  • 🟥 build//instructions: +21.8G (+0.18%)

Small changes (3✅, 50🟥)

Too many entries to display here. View the full report on radar instead.

@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan changelog-language Language features and metaprograms mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

Universe level normalization has associativity of max backwards from parsing associativity

3 participants