Skip to content
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

Universe normalization associates max suboptimally #6760

Closed
3 tasks done
eric-wieser opened this issue Jan 24, 2025 · 1 comment
Closed
3 tasks done

Universe normalization associates max suboptimally #6760

eric-wieser opened this issue Jan 24, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@eric-wieser
Copy link
Contributor

eric-wieser commented Jan 24, 2025

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

When working with terms containing max u v w level parameters, Lean.Level.normalize often normalizes these to max (max u v) w.
Recall that `(level| max $u $v $w) refers to max u (max v w), so this choice is inconsistent with the associativity of the notation

Context

Explicit universe arguments frequently appear in the goal state in Mathlib's Cardinal library, and it is frustrating when the shorter max u v w x is replaced with the long max (max (max u v) w) x.

Discovered in this Zulip thread.

Steps to Reproduce

Run the following:

universe u v w
set_option pp.all true
example (x y : ULift.{max u v w} Nat) : x = y := by
  sorry

Expected behavior: State is

x y : ULift.{max u v w, 0} Nat
⊢ @Eq.{max (u + 1) (v + 1) (w + 1)} (ULift.{max u v w, 0} Nat) x y

Actual behavior: State is

x y : ULift.{max u v w, 0} Nat
⊢ @Eq.{max (max (u + 1) (v + 1)) (w + 1)} (ULift.{max u v w, 0} Nat) x y

Either changing the normalization or changing the associativity of the notation would fix this.

Versions

[Output of #version or #eval Lean.versionString]
[OS version, if not using live.lean-lang.org.]

Additional Information

[Additional information, configuration or data that might be necessary to reproduce the issue]

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@eric-wieser eric-wieser added the bug Something isn't working label Jan 24, 2025
@kmill
Copy link
Collaborator

kmill commented Jan 24, 2025

#5695

@Kha Kha closed this as completed Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants