Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ import Mathlib.Algebra.Order.Group.Cyclic
import Mathlib.Algebra.Order.Group.Defs
import Mathlib.Algebra.Order.Group.DenselyOrdered
import Mathlib.Algebra.Order.Group.End
import Mathlib.Algebra.Order.Group.Equiv
import Mathlib.Algebra.Order.Group.Finset
import Mathlib.Algebra.Order.Group.Indicator
import Mathlib.Algebra.Order.Group.InjSurj
Expand Down Expand Up @@ -874,6 +875,7 @@ import Mathlib.Algebra.Order.Kleene
import Mathlib.Algebra.Order.Module.Algebra
import Mathlib.Algebra.Order.Module.Basic
import Mathlib.Algebra.Order.Module.Defs
import Mathlib.Algebra.Order.Module.Equiv
import Mathlib.Algebra.Order.Module.Field
import Mathlib.Algebra.Order.Module.OrderedSMul
import Mathlib.Algebra.Order.Module.Pointwise
Expand Down
47 changes: 47 additions & 0 deletions Mathlib/Algebra/Order/Group/Equiv.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/-
Copyright (c) 2025 Weiyi Wang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Weiyi Wang
-/
import Mathlib.Algebra.Group.Equiv.Defs
import Mathlib.Algebra.Order.Group.Synonym

/-!
# Add/Mul equivalence for order type synonyms
-/

variable (α : Type*)

/-- `toLex` as a `MulEquiv`. -/
@[to_additive "`toLex` as a `AddEquiv`."]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
@[to_additive "`toLex` as a `AddEquiv`."]
@[to_additive (attr := simps toEquiv) "`toLex` as a `AddEquiv`."]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This produces toLexMulEquiv_toEquiv, which is basically renaming toEquiv_toLexMulEquiv. (toEquiv_toLexMulEquiv was introduced in #22420). This is where I don't know what our naming convention is and I found both examples in the library. toEquiv can be seen as a function application so the function name should appear first; but there are also example where a dot member is written the other way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For things which ""are clearly projections"", the name tends to come last. At any rate, simps producing that name is good authority to follow

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Got it. I have applied the change and removed toEquiv_toLexMulEquiv

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Welp, the simp normal form checker rejected this

-- Mathlib.Algebra.Order.Group.Equiv
Error: /home/lean/actions-runner/_work/mathlib4/mathlib4/pr-branch/Mathlib/Algebra/Order/Group/Equiv.lean:16:24: error: toLexMulEquiv_toEquiv Left-hand side simplifies from
  (toLexMulEquiv α).toEquiv
to
  ↑(toLexMulEquiv α)
using
  dsimp only [*, @MulEquiv.toEquiv_eq_coe]
Try to change the left-hand side to the simplified term!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ugh, I'm so sorry my suggestion depends on #21031

def toLexMulEquiv [Mul α] : α ≃* Lex α where
__ := toLex
map_mul' _ _ := by simp

@[to_additive (attr := simp)]
theorem coe_toLexMulEquiv [Mul α] : ⇑(toLexMulEquiv α) = toLex := rfl

@[to_additive (attr := simp)]
theorem coe_symm_toLexMulEquiv [Mul α] : ⇑(toLexMulEquiv α).symm = ofLex := rfl

/-- `ofLex` as a `MulEquiv`. -/
@[to_additive "`ofLex` as a `AddEquiv`."]
def ofLexMulEquiv [Mul α] : Lex α ≃* α where
__ := ofLex
map_mul' _ _ := by simp

@[to_additive (attr := simp)]
theorem coe_ofLexMulEquiv [Mul α] : ⇑(ofLexMulEquiv α) = ofLex := rfl

@[to_additive (attr := simp)]
theorem coe_symm_ofLexMulEquiv [Mul α] : ⇑(ofLexMulEquiv α).symm = toLex := rfl

@[to_additive (attr := simp)]
lemma toEquiv_toLexMulEquiv [Mul α] :
(toLexMulEquiv α : α ≃ Lex α) = toLex :=
rfl

@[to_additive (attr := simp)]
lemma toEquiv_symm_toLexMulEquiv [Mul α] :
((toLexMulEquiv α).symm : Lex α ≃ α) = ofLex :=
rfl
32 changes: 2 additions & 30 deletions Mathlib/Algebra/Order/GroupWithZero/Lex.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Algebra.GroupWithZero.ProdHom
import Mathlib.Algebra.Order.Hom.MonoidWithZero
import Mathlib.Algebra.Order.Group.Equiv
import Mathlib.Algebra.Order.Monoid.Lex
import Mathlib.Algebra.Order.Hom.MonoidWithZero
import Mathlib.Data.Prod.Lex

/-!
Expand All @@ -25,35 +26,6 @@ Create the "LinOrdCommGrpWithZero" category.

-/

-- TODO: find a better place
/-- `toLex` as a monoid isomorphism. -/
def toLexMulEquiv (G H : Type*) [MulOneClass G] [MulOneClass H] : G × H ≃* G ×ₗ H where
toFun := toLex
invFun := ofLex
left_inv := ofLex_toLex
right_inv := toLex_ofLex
map_mul' := toLex_mul

@[simp]
lemma coe_toLexMulEquiv (G H : Type*) [MulOneClass G] [MulOneClass H] :
⇑(toLexMulEquiv G H) = toLex :=
rfl

@[simp]
lemma coe_symm_toLexMulEquiv (G H : Type*) [MulOneClass G] [MulOneClass H] :
⇑(toLexMulEquiv G H).symm = ofLex :=
rfl

@[simp]
lemma toEquiv_toLexMulEquiv (G H : Type*) [MulOneClass G] [MulOneClass H] :
⇑(toLexMulEquiv G H : G × H ≃ G ×ₗ H) = toLex :=
rfl

@[simp]
lemma toEquiv_symm_toLexMulEquiv (G H : Type*) [MulOneClass G] [MulOneClass H] :
⇑((toLexMulEquiv G H).symm : G ×ₗ H ≃ G × H) = ofLex :=
rfl

namespace MonoidWithZeroHom

variable {M₀ N₀ : Type*}
Expand Down
33 changes: 33 additions & 0 deletions Mathlib/Algebra/Order/Module/Equiv.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/-
Copyright (c) 2025 Weiyi Wang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Weiyi Wang
-/
import Mathlib.Algebra.Module.Equiv.Basic
import Mathlib.Algebra.Order.Group.Equiv
import Mathlib.Algebra.Order.Module.Synonym

/-!
# Linear equivalence for order type synonyms
-/

variable (α β : Type*)
variable [Semiring α] [AddCommMonoid β] [Module α β]

/-- `toLex` as a linear equivalence -/
def toLexLinearEquiv : β ≃ₗ[α] Lex β := (toLexAddEquiv β).toLinearEquiv toLex_smul

@[simp]
theorem coe_toLexLinearEquiv : ⇑(toLexLinearEquiv α β) = toLex := rfl

@[simp]
theorem coe_symm_toLexLinearEquiv : ⇑(toLexLinearEquiv α β).symm = ofLex := rfl

/-- `ofLex` as a linear equivalence -/
def ofLexLinearEquiv : Lex β ≃ₗ[α] β := (ofLexAddEquiv β).toLinearEquiv ofLex_smul

@[simp]
theorem coe_ofLexLinearEquiv : ⇑(ofLexLinearEquiv α β) = ofLex := rfl

@[simp]
theorem coe_symm_ofLexLinearEquiv : ⇑(ofLexLinearEquiv α β).symm = toLex := rfl