Skip to content

chore: protect Prod.Lex#1895

Merged
gebner merged 1 commit intoleanprover:masterfrom
kim-em:protect_Prod_Lex
Nov 29, 2022
Merged

chore: protect Prod.Lex#1895
gebner merged 1 commit intoleanprover:masterfrom
kim-em:protect_Prod_Lex

Conversation

@kim-em
Copy link
Copy Markdown
Collaborator

@kim-em kim-em commented Nov 29, 2022

mathlib4 also defines a Lex, and in porting people have encountered collisions with this one when Prod is open. Protecting Prod.Lex in core is not essential, but would be convenient for mathlib4.

Copy link
Copy Markdown
Member

@gebner gebner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, in mathlib Lex α is a type wrapper. Lex (α × β) is the type of lexicographically ordered pairs (with a global LT instance, etc.).

@gebner
Copy link
Copy Markdown
Member

gebner commented Nov 29, 2022

@gebner gebner enabled auto-merge (rebase) November 29, 2022 18:13
@gebner gebner merged commit 1b50292 into leanprover:master Nov 29, 2022
bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 29, 2022
mathlib3 SHA: 1fc36cc9c8264e6e81253f88be7fb2cb6c92d76a

porting notes: there are several issues here that should probably be fixed before this gets merged
1. `Prod.Lex` is not protect in core, so when you have this namespace open and try to refer to `Lex`, Lean finds `Prod.Lex` instead of `_root_.Lex`. This is not a huge deal since we have notation `α ×ₗ β`, but we should probably ask for it to be protected in core. See leanprover/lean4#1895
2. on the declarations `toLex_mono` and `toLex_strictMono`, Lean sees right through the type synonym `α ×ₗ β` to `α × β` and uses the wrong `Preorder` instance, which is why I had to provide them manually. I think this is a bug and should be fixed, otherwise it will cause loads of other issues down the road (for other type synonyms) and the errors will be hard to diagnose. EDIT: Hopefully leanprover/lean4#1891 will provide a fix.
3. I had to provide the definitions of `min` and `max` for the `LinearOrder` instance manually because in Lean 4 we have the classes `Min` and `Max` which have no counterpart in Lean 3. In this case it's a bit annoying because `ite` requires decidability, so I effectively had to provide that three times in this instance declaration. Surely there should be a better way?

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 29, 2022
mathlib3 SHA: 1fc36cc9c8264e6e81253f88be7fb2cb6c92d76a

porting notes: there are several issues here that should probably be fixed before this gets merged
1. `Prod.Lex` is not protect in core, so when you have this namespace open and try to refer to `Lex`, Lean finds `Prod.Lex` instead of `_root_.Lex`. This is not a huge deal since we have notation `α ×ₗ β`, but we should probably ask for it to be protected in core. See leanprover/lean4#1895
2. on the declarations `toLex_mono` and `toLex_strictMono`, Lean sees right through the type synonym `α ×ₗ β` to `α × β` and uses the wrong `Preorder` instance, which is why I had to provide them manually. I think this is a bug and should be fixed, otherwise it will cause loads of other issues down the road (for other type synonyms) and the errors will be hard to diagnose. EDIT: Hopefully leanprover/lean4#1891 will provide a fix.
3. I had to provide the definitions of `min` and `max` for the `LinearOrder` instance manually because in Lean 4 we have the classes `Min` and `Max` which have no counterpart in Lean 3. In this case it's a bit annoying because `ite` requires decidability, so I effectively had to provide that three times in this instance declaration. Surely there should be a better way?

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants