[Merged by Bors] - fix(Order): fix simp lemma for with{Top/Bot}{Map/Congr}#26787
[Merged by Bors] - fix(Order): fix simp lemma for with{Top/Bot}{Map/Congr}#26787wwylele wants to merge 4 commits intoleanprover-community:masterfrom
Conversation
The existing @[simps!] lemma on withTopCongr sends expression to Equiv.optionCongr, which is hard to work with because it losts WithTop/WithBot tags and Option has fewer lemmas. Add these to preserve WithTop/WithBot tags.
PR summary 063d2e5dacImport changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diffNo declarations were harmed in the making of this PR! 🐙 You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>The doc-module for No changes to technical debt.You can run this locally as
|
|
Please do try to replace the existing lemmas, I can't imagine them being used often. Thanks! |
|
After playing around a bit, I decided to instead change the existing I don't know about the deprecation policy for this kind of issue. The new good one will take the the name |
Ruben-VandeVelde
left a comment
There was a problem hiding this comment.
Thanks!
maintainer merge
|
🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde. |
Mathlib/Order/Hom/WithTopBot.lean
Outdated
| def withTopCongr (e : α ≃o β) : WithTop α ≃o WithTop β := | ||
| { e.toOrderEmbedding.withTopMap with | ||
| toEquiv := e.toEquiv.optionCongr } |
There was a problem hiding this comment.
I'd argue we should redefine this so that simps does do the right thing; I think in practice that would look like
| def withTopCongr (e : α ≃o β) : WithTop α ≃o WithTop β := | |
| { e.toOrderEmbedding.withTopMap with | |
| toEquiv := e.toEquiv.optionCongr } | |
| def withTopCongr (e : α ≃o β) : WithTop α ≃o WithTop β where | |
| toFun := WithTop.map e | |
| invFun := WithTop.map e.symm | |
| __ := e.toOrderEmbedding.withTopMap | |
| __ := e.toEquiv.optionCongr |
There was a problem hiding this comment.
I like it! Just did a quick test that the new simp from this can still correctly simplify e.withTopCongr (WithTop.some ...), so I am using the code as-is
There was a problem hiding this comment.
I said it too fast... this leaded to a rabbit hole in OrderEmbedding.withTop/BotCongr's bad def. Currently their generated apply simp don't even have the same signature:
- OrderEmbedding.withBotMap_apply simps to Option.map
- OrderEmbedding.withTopMap_apply simps to WithTop.map
Guess there is more to fix
|
I pushed a change to unify the four simp lemmas across OrderEmbedding and OrderIso (see PR description) |
Ruben-VandeVelde
left a comment
There was a problem hiding this comment.
Thanks!
maintainer merge
|
🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde. |
|
Thanks! |
This change includes the following in generated simp lemmas:
```diff
-@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) :
- ⇑f.withBotMap = Option.map ⇑f
+@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) :
+ ⇑f.withBotMap = WithBot.map ⇑f
@[simp] theorem OrderEmbedding.withTopMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) :
⇑f.withTopMap = WithTop.map ⇑f -- unchanged
-@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) :
- e.withBotCongr a✝ = Option.map (⇑e) a✝
+@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) :
+ ⇑e.withBotCongr = WithBot.map ⇑e
-@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) :
- e.withTopCongr a✝ = Option.map (⇑e) a✝
+@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) :
+ ⇑e.withTopCongr = WithTop.map ⇑e
```
|
Pull request successfully merged into master. Build succeeded: |
…ommunity#26787) This change includes the following in generated simp lemmas: ```diff -@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : - ⇑f.withBotMap = Option.map ⇑f +@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : + ⇑f.withBotMap = WithBot.map ⇑f @[simp] theorem OrderEmbedding.withTopMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : ⇑f.withTopMap = WithTop.map ⇑f -- unchanged -@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) : - e.withBotCongr a✝ = Option.map (⇑e) a✝ +@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) : + ⇑e.withBotCongr = WithBot.map ⇑e -@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) : - e.withTopCongr a✝ = Option.map (⇑e) a✝ +@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) : + ⇑e.withTopCongr = WithTop.map ⇑e ```
…ommunity#26787) This change includes the following in generated simp lemmas: ```diff -@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : - ⇑f.withBotMap = Option.map ⇑f +@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : + ⇑f.withBotMap = WithBot.map ⇑f @[simp] theorem OrderEmbedding.withTopMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : ⇑f.withTopMap = WithTop.map ⇑f -- unchanged -@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) : - e.withBotCongr a✝ = Option.map (⇑e) a✝ +@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) : + ⇑e.withBotCongr = WithBot.map ⇑e -@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) : - e.withTopCongr a✝ = Option.map (⇑e) a✝ +@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) : + ⇑e.withTopCongr = WithTop.map ⇑e ```
…ommunity#26787) This change includes the following in generated simp lemmas: ```diff -@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : - ⇑f.withBotMap = Option.map ⇑f +@[simp] theorem OrderEmbedding.withBotMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : + ⇑f.withBotMap = WithBot.map ⇑f @[simp] theorem OrderEmbedding.withTopMap_apply {α : Type u_1} {β : Type u_2} [Preorder α] [Preorder β] (f : α ↪o β) : ⇑f.withTopMap = WithTop.map ⇑f -- unchanged -@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) : - e.withBotCongr a✝ = Option.map (⇑e) a✝ +@[simp] theorem OrderIso.withBotCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) : + ⇑e.withBotCongr = WithBot.map ⇑e -@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) (a✝ : Option α) : - e.withTopCongr a✝ = Option.map (⇑e) a✝ +@[simp] theorem OrderIso.withTopCongr_apply {α : Type u_1} {β : Type u_2} [PartialOrder α] [PartialOrder β] (e : α ≃o β) : + ⇑e.withTopCongr = WithTop.map ⇑e ```
This change includes the following in generated simp lemmas:
The existing @[simps!] lemma onwithTopCongrsends the expression to Equiv.optionCongr, which is hard to work with because it losts WithTop/WithBot tags and Option has fewer lemmas. Add these to preserve WithTop/WithBot tags.I didn't tag these as@[simp]because it would conflict with existing@[simps!]. But to be honest I don't like the existing simps. Can I remove@[simps! apply]fromwithTopCongrand promote the new lemma as simp normal form?