Skip to content

fix: add a missing case to Level.geq - #2689

Merged
leodemoura merged 3 commits into
leanprover:masterfrom
digama0:level_geq
Nov 19, 2024
Merged

leodemoura merged 3 commits into
leanprover:masterfrom
digama0:level_geq

Conversation

@digama0

@digama0 digama0 commented Oct 15, 2023 •

Copy link
Copy Markdown
Collaborator

This PR adds a case to Level.geq that is present in the kernel's level is_geq procedure, making them consistent with one another.

This came up during testing of lean4lean. Currently Level.geq differs from level::is_geq in the case of max u v >= imax u v. The elaborator function is overly pessimistic and yields false on this while the kernel function yields true. This comes up concretely in the Trans class:

class Trans (r : α → β → Sort u) (s : β → γ → Sort v) (t : outParam (α → γ → Sort w)) where
  trans : r a b → s b c → t a c

The type of this class is Sort (max (max (max (max (max (max 1 u) u_1) u_2) u_3) v) w) (where u_1 u_2 u_3 are the levels of α β γ), but if you try writing that type explicitly then the class command fails. Omitting the type leaves the class to infer the universe level (the command assumes the level is correct, and the kernel agrees it is), but including the type then the elaborator checks the level inequality with Level.geq and fails.

@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 Oct 15, 2023
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Oct 15, 2023
@ghost ghost added the builds-mathlib CI has verified that Mathlib builds against this PR label Oct 15, 2023
@ghost

ghost commented Oct 15, 2023 •

Copy link
Copy Markdown
  • ✅ Mathlib branch lean-pr-testing-2689 has successfully built against this PR. (2023-10-15 17:59:22) View Log
  • ❗ Std/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e4daca8d6b02677115282abff8515a9afb6a2a29 --onto 62cdb51ed5b9d8487877d5a4adbcd4659d81fc6a. (2024-04-22 03:10:38)
  • 🟡 Mathlib branch lean-pr-testing-2689 build this PR didn't complete normally. (2024-11-19 20:32:28) View Log

@kim-em kim-em added the awaiting-review Waiting for someone to review the PR label Oct 16, 2023
@Kha
Kha requested review from Kha and leodemoura as code owners November 20, 2023 08:15
@kim-em

kim-em commented Mar 17, 2024

Copy link
Copy Markdown
Collaborator

Just noting there's a conflict here now.

Would it be possible to include the Trans example as a test?

@digama0

digama0 commented Apr 22, 2024

Copy link
Copy Markdown
Collaborator Author

Ping @leodemoura on this since apparently #2750 was missed so probably this long standing bug was too.

@kmill kmill changed the title fix: Level.geq is missing a case fix: add a missing case to Level.geq Nov 19, 2024
@kmill kmill added the changelog-no Do not include this PR in the release changelog label Nov 19, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Nov 19, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 19, 2024
@leodemoura
leodemoura added this pull request to the merge queue Nov 19, 2024
@leodemoura leodemoura removed the awaiting-review Waiting for someone to review the PR label Nov 19, 2024
@ghost

ghost commented Nov 19, 2024

Copy link
Copy Markdown

Mathlib CI status (docs):

Merged via the queue into leanprover:master with commit a00cf63 Nov 19, 2024
kmill added a commit to kmill/lean4 that referenced this pull request Nov 19, 2024
This PR adds a case to `Level.geq` that is present in the kernel's level
`is_geq` procedure, making them consistent with one another.

This came up during testing of `lean4lean`. Currently `Level.geq`
differs from `level::is_geq` in the case of `max u v >= imax u v`. The
elaborator function is overly pessimistic and yields `false` on this
while the kernel function yields true. This comes up concretely in the
`Trans` class:
```lean
class Trans (r : α → β → Sort u) (s : β → γ → Sort v) (t : outParam (α → γ → Sort w)) where
  trans : r a b → s b c → t a c
```
The type of this class is `Sort (max (max (max (max (max (max 1 u) u_1)
u_2) u_3) v) w)` (where `u_1 u_2 u_3` are the levels of `α β γ`), but if
you try writing that type explicitly then the `class` command fails.
Omitting the type leaves the `class` to infer the universe level (the
command assumes the level is correct, and the kernel agrees it is), but
including the type then the elaborator checks the level inequality with
`Level.geq` and fails.

---------

Co-authored-by: Kyle Miller <[email protected]>
JovanGerb pushed a commit to JovanGerb/lean4 that referenced this pull request Jan 21, 2025
This PR adds a case to `Level.geq` that is present in the kernel's level
`is_geq` procedure, making them consistent with one another.

This came up during testing of `lean4lean`. Currently `Level.geq`
differs from `level::is_geq` in the case of `max u v >= imax u v`. The
elaborator function is overly pessimistic and yields `false` on this
while the kernel function yields true. This comes up concretely in the
`Trans` class:
```lean
class Trans (r : α → β → Sort u) (s : β → γ → Sort v) (t : outParam (α → γ → Sort w)) where
  trans : r a b → s b c → t a c
```
The type of this class is `Sort (max (max (max (max (max (max 1 u) u_1)
u_2) u_3) v) w)` (where `u_1 u_2 u_3` are the levels of `α β γ`), but if
you try writing that type explicitly then the `class` command fails.
Omitting the type leaves the `class` to infer the universe level (the
command assumes the level is correct, and the kernel agrees it is), but
including the type then the elaborator checks the level inequality with
`Level.geq` and fails.

---------

Co-authored-by: Kyle Miller <[email protected]>
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-no Do not include this PR in the release changelog 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.

4 participants