Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions Mathlib/Data/Sum/Order.lean
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,22 @@ theorem sumLexDualAntidistrib_symm_inr :
(sumLexDualAntidistrib α β).symm (inr (toDual a)) = toDual (inl a) :=
rfl

/-- `Equiv.sumEmpty` as an `OrderIso` with the lexicographic sum. -/
def sumLexEmpty [IsEmpty β] :
Lex (α ⊕ β) ≃o α := RelIso.sumLexEmpty ..

/-- `Equiv.emptySum` as an `OrderIso` with the lexicographic sum. -/
def emptySumLex [IsEmpty β] :
Lex (β ⊕ α) ≃o α := RelIso.emptySumLex ..

@[simp]
lemma sumLexEmpty_apply_inl [IsEmpty β] (x : α) :
sumLexEmpty (β := β) (toLex <| .inl x) = x := rfl

@[simp]
lemma emptySumLex_apply_inr [IsEmpty β] (x : α) :
emptySumLex (β := β) (toLex <| .inr x) = x := rfl

end OrderIso

variable [LE α]
Expand Down
11 changes: 11 additions & 0 deletions Mathlib/Order/Hom/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,13 @@ def prodComm : α × β ≃o β × α where
toEquiv := Equiv.prodComm α β
map_rel_iff' := Prod.swap_le_swap

/-- `Equiv.prodAssoc` promoted to an order isomorphism. -/
@[simps! (attr := grind =)]
def prodAssoc (α β γ : Type*) [LE α] [LE β] [LE γ] :
(α × β) × γ ≃o α × (β × γ) where
toEquiv := .prodAssoc α β γ
map_rel_iff' := @fun ⟨⟨_, _⟩, _⟩ ⟨⟨_, _⟩, _⟩ ↦ by simp [Equiv.prodAssoc, and_assoc]

@[simp]
theorem coe_prodComm : ⇑(prodComm : α × β ≃o β × α) = Prod.swap :=
rfl
Expand Down Expand Up @@ -1069,6 +1076,10 @@ noncomputable def ofUnique
toEquiv := Equiv.ofUnique α β
map_rel_iff' := by simp

/-- `Equiv.equivOfIsEmpty` promoted to an `OrderIso`. -/
def ofIsEmpty (α β : Type*) [Preorder α] [Preorder β] [IsEmpty α] [IsEmpty β] : α ≃o β :=
⟨Equiv.equivOfIsEmpty α β, @isEmptyElim _ _ _⟩

end OrderIso

namespace Equiv
Expand Down
29 changes: 29 additions & 0 deletions Mathlib/Order/Hom/Lex.lean
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,33 @@ variable {α β} in
theorem uniqueProd_apply [Preorder α] [Unique α] [LE β] (x : α ×ₗ β) :
uniqueProd α β x = (ofLex x).2 := rfl

/-- `Equiv.prodAssoc` promoted to an order isomorphism of lexicographic products. -/
@[simps!]
def prodLexAssoc (α β γ : Type*)
[Preorder α] [Preorder β] [Preorder γ] : (α ×ₗ β) ×ₗ γ ≃o α ×ₗ β ×ₗ γ where
toEquiv := .trans ofLex <| .trans (.prodCongr ofLex <| .refl _) <|
.trans (.prodAssoc α β γ) <| .trans (.prodCongr (.refl _) toLex) <| toLex
map_rel_iff' := by
simp only [Prod.Lex.le_iff, Prod.Lex.lt_iff, Equiv.trans_apply, Equiv.prodCongr_apply,
Equiv.prodAssoc_apply]
grind [EmbeddingLike.apply_eq_iff_eq, ofLex_toLex]

/-- `Equiv.sumProdDistrib` promoted to an order isomorphism of lexicographic products.

Right distributivity doesn't hold. A counterexample is `ℕ ×ₗ (Unit ⊕ₗ Unit) ≃o ℕ`
which is not isomorphic to `ℕ ×ₗ Unit ⊕ₗ ℕ ×ₗ Unit ≃o ℕ ⊕ₗ ℕ`. -/
@[simps!]
def sumLexProdLexDistrib (α β γ : Type*)
[Preorder α] [Preorder β] [Preorder γ] : (α ⊕ₗ β) ×ₗ γ ≃o α ×ₗ γ ⊕ₗ β ×ₗ γ where
toEquiv := .trans ofLex <| .trans (.prodCongr ofLex <| .refl _) <|
.trans (.sumProdDistrib α β γ) <| .trans (.sumCongr toLex toLex) toLex
map_rel_iff' := by simp [Prod.Lex.le_iff]

/-- `Equiv.prodCongr` promoted to an order isomorphism between lexicographic products. -/
@[simps! apply]
def prodLexCongr {α β γ δ : Type*} [Preorder α] [Preorder β]
[Preorder γ] [Preorder δ] (ea : α ≃o β) (eb : γ ≃o δ) : α ×ₗ γ ≃o β ×ₗ δ where
toEquiv := ofLex.trans ((Equiv.prodCongr ea eb).trans toLex)
map_rel_iff' := by simp [Prod.Lex.le_iff]

end Prod.Lex