Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7b03e85
chore(Algebra/Order/Hom): initliaze simps for Order(Add)MonoidFoo
pechersky Feb 28, 2025
506bc5f
feat(Order/Prod/Lex/{Hom,Monoid,GroupWithZero}): ordered inclusoins a…
pechersky Mar 1, 2025
a8463c8
remove simp
pechersky Mar 2, 2025
b14da2a
shake thanks to explicit types
pechersky Mar 3, 2025
6bc9a81
switch to OrderedMonoidWithZeroHom
pechersky Mar 3, 2025
88d7332
spec lemmas
pechersky Mar 3, 2025
7ea6195
Merge branch 'master' into pechersky/lin-ord-g-w-zero-prod
pechersky Apr 7, 2025
315bd58
rename
pechersky May 13, 2025
74f79be
direct lemma
pechersky May 13, 2025
9ab6eda
lex syntax
pechersky May 13, 2025
6cba8eb
Merge branch 'master' into pechersky/lin-ord-g-w-zero-prod
pechersky May 13, 2025
3059eef
generalize with unbundled
pechersky May 13, 2025
a397cba
Prod.one_eq_mk
pechersky May 13, 2025
c769623
explicit mono lemmas
pechersky May 13, 2025
6a66db7
rfl proofs
pechersky May 13, 2025
e9e206d
feat(GroupWithZero): monoid with zero homs to (co)products
pechersky Jun 5, 2025
76121f8
Merge branch 'pechersky/g-w-zero-prod' into pechersky/lin-ord-g-w-zer…
pechersky Jun 5, 2025
1f4bc08
missing file
pechersky Jun 5, 2025
46b87ff
inl inr interaction
pechersky Jun 5, 2025
cbaa7c5
mk_all
pechersky Jun 5, 2025
318579b
Merge branch 'pechersky/g-w-zero-prod' into pechersky/lin-ord-g-w-zer…
pechersky Jun 5, 2025
fc240da
shake
pechersky Jun 5, 2025
233d2b2
shake
pechersky Jun 5, 2025
fdd05a3
injectivity and surjectivity
pechersky Jun 5, 2025
9763c9c
Merge branch 'pechersky/g-w-zero-prod' into pechersky/lin-ord-g-w-zer…
pechersky Jun 5, 2025
36f1598
simp of coes
pechersky Jun 5, 2025
cfbe5a0
use group with zero homs
pechersky Jun 5, 2025
80c2d38
simp of coes
pechersky Jun 5, 2025
1e3f448
remove noncomputable
pechersky Jun 5, 2025
c90d29a
remove commute_zero repeats
pechersky Jun 5, 2025
1e8d5d9
rename
pechersky Jun 5, 2025
63d0e73
types with 0
pechersky Jun 5, 2025
2edc2b8
rename and absorbing
pechersky Jun 6, 2025
866cafe
clarify category theory todo
pechersky Jun 6, 2025
7e0fbce
dot notation shortening
pechersky Jun 6, 2025
b2bb4c8
move lemmas up
pechersky Jun 6, 2025
8406ba3
instance as 1
pechersky Jun 6, 2025
266fde2
spacing
pechersky Jun 6, 2025
c6e0c28
remove parens
pechersky Jun 6, 2025
fecaea9
Merge branch 'pechersky/g-w-zero-prod' into pechersky/lin-ord-g-w-zer…
pechersky Jun 6, 2025
d5355f3
coe lemmas
pechersky Jun 6, 2025
f52b692
clarify absorbing
pechersky Jun 6, 2025
d943088
move lemmas to use map_eq_zero, and generalize it to nontrivial mulze…
pechersky Jun 6, 2025
39d3d7a
Merge branch 'master' into pechersky/g-w-zero-prod
pechersky Jun 6, 2025
eb84758
variable rename
pechersky Jun 8, 2025
29beaa7
Merge branch 'pechersky/g-w-zero-prod' into pechersky/lin-ord-g-w-zer…
pechersky Jun 9, 2025
88f6a0c
Merge branch 'master' into pechersky/lin-ord-g-w-zero-prod
pechersky Jun 9, 2025
a4035ef
feat(GroupWithZero/WithZero): injectivity and monotonicity of WithZer…
pechersky Jun 10, 2025
827132b
Merge branch 'pechersky/with-zero-map-api' into pechersky/lin-ord-g-w…
pechersky Jun 10, 2025
bcf598a
renames
pechersky Jun 10, 2025
9be70f5
move files
pechersky Jun 10, 2025
badf618
Merge remote-tracking branch 'origin/master' into pechersky/lin-ord-g…
pechersky Jun 11, 2025
a30753b
feedback
pechersky Jun 15, 2025
1b61419
cleanup
pechersky Jun 16, 2025
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
3 changes: 3 additions & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ import Mathlib.Algebra.Order.GroupWithZero.Action.Synonym
import Mathlib.Algebra.Order.GroupWithZero.Bounds
import Mathlib.Algebra.Order.GroupWithZero.Canonical
import Mathlib.Algebra.Order.GroupWithZero.Finset
import Mathlib.Algebra.Order.GroupWithZero.Lex
import Mathlib.Algebra.Order.GroupWithZero.Submonoid
import Mathlib.Algebra.Order.GroupWithZero.Synonym
import Mathlib.Algebra.Order.GroupWithZero.Unbundled
Expand Down Expand Up @@ -859,6 +860,7 @@ import Mathlib.Algebra.Order.Monoid.Basic
import Mathlib.Algebra.Order.Monoid.Canonical.Basic
import Mathlib.Algebra.Order.Monoid.Canonical.Defs
import Mathlib.Algebra.Order.Monoid.Defs
import Mathlib.Algebra.Order.Monoid.Lex
import Mathlib.Algebra.Order.Monoid.NatCast
import Mathlib.Algebra.Order.Monoid.OrderDual
import Mathlib.Algebra.Order.Monoid.Prod
Expand Down Expand Up @@ -4869,6 +4871,7 @@ import Mathlib.Order.Preorder.Chain
import Mathlib.Order.Preorder.Finite
import Mathlib.Order.PrimeIdeal
import Mathlib.Order.PrimeSeparator
import Mathlib.Order.Prod.Lex.Hom
import Mathlib.Order.PropInstances
import Mathlib.Order.Radical
import Mathlib.Order.Rel.GaloisConnection
Expand Down
159 changes: 159 additions & 0 deletions Mathlib/Algebra/Order/GroupWithZero/Lex.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/-
Copyright (c) 2025 Yakov Pechersky. All rights reserved.
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.Monoid
import Mathlib.Algebra.Order.Monoid.Lex
import Mathlib.Data.Prod.Lex

/-!
# Order homomorphisms for products of linearly ordered groups with zero

This file defines order homomorphisms for products of linearly ordered groups with zero,
which is identified with the `WithZero` of the lexicographic product of the units of the groups.

The product of linearly ordered groups with zero `WithZero (αˣ ×ₗ βˣ)` is a
linearly ordered group with zero itself with natural inclusions but only one projection.
One has to work with the lexicographic product of the units `αˣ ×ₗ βˣ` since otherwise,
the plain product `αˣ × βˣ` would not be linearly ordered.

## TODO

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*}

lemma inl_mono [LinearOrderedCommGroupWithZero M₀] [GroupWithZero N₀] [Preorder N₀]
[DecidablePred fun x : M₀ ↦ x = 0] : Monotone (inl M₀ N₀) := by
refine (WithZero.map'_mono MonoidHom.inl_mono).comp ?_
intro x y
obtain rfl | ⟨x, rfl⟩ := GroupWithZero.eq_zero_or_unit x <;>
obtain rfl | ⟨y, rfl⟩ := GroupWithZero.eq_zero_or_unit y <;>
· simp [WithZero.zero_le, WithZero.withZeroUnitsEquiv]

lemma inl_strictMono [LinearOrderedCommGroupWithZero M₀] [GroupWithZero N₀] [PartialOrder N₀]
[DecidablePred fun x : M₀ ↦ x = 0] : StrictMono (inl M₀ N₀) :=
inl_mono.strictMono_of_injective inl_injective

lemma inr_mono [GroupWithZero M₀] [Preorder M₀] [LinearOrderedCommGroupWithZero N₀]
[DecidablePred fun x : N₀ ↦ x = 0] : Monotone (inr M₀ N₀) := by
refine (WithZero.map'_mono MonoidHom.inr_mono).comp ?_
intro x y
obtain rfl | ⟨x, rfl⟩ := GroupWithZero.eq_zero_or_unit x <;>
obtain rfl | ⟨y, rfl⟩ := GroupWithZero.eq_zero_or_unit y <;>
· simp [WithZero.zero_le, WithZero.withZeroUnitsEquiv]

lemma inr_strictMono [GroupWithZero M₀] [PartialOrder M₀] [LinearOrderedCommGroupWithZero N₀]
[DecidablePred fun x : N₀ ↦ x = 0] : StrictMono (inr M₀ N₀) :=
inr_mono.strictMono_of_injective inr_injective

lemma fst_mono [LinearOrderedCommGroupWithZero M₀] [GroupWithZero N₀] [Preorder N₀] :
Monotone (fst M₀ N₀) := by
refine WithZero.forall.mpr ?_
simp +contextual [WithZero.forall, Prod.le_def]


lemma snd_mono [GroupWithZero M₀] [Preorder M₀] [LinearOrderedCommGroupWithZero N₀] :
Monotone (snd M₀ N₀) := by
refine WithZero.forall.mpr ?_
simp [WithZero.forall, Prod.le_def]

end MonoidWithZeroHom

namespace LinearOrderedCommGroupWithZero

variable (α β : Type*) [LinearOrderedCommGroupWithZero α] [LinearOrderedCommGroupWithZero β]

open MonoidWithZeroHom

/-- Given linearly ordered groups with zero M, N, the natural inclusion ordered homomorphism from
M to `WithZero (Mˣ ×ₗ Nˣ)`, which is the linearly ordered group with zero that can be identified
as their product. -/
@[simps!]
nonrec def inl : α →*₀o WithZero (αˣ ×ₗ βˣ) where
__ := (WithZero.map' (toLexMulEquiv ..).toMonoidHom).comp (inl α β)
monotone' := by simpa using (WithZero.map'_mono (Prod.Lex.toLex_mono)).comp inl_mono

/-- Given linearly ordered groups with zero M, N, the natural inclusion ordered homomorphism from
N to `WithZero (Mˣ ×ₗ Nˣ)`, which is the linearly ordered group with zero that can be identified
as their product. -/
@[simps!]
nonrec def inr : β →*₀o WithZero (αˣ ×ₗ βˣ) where
__ := (WithZero.map' (toLexMulEquiv ..).toMonoidHom).comp (inr α β)
monotone' := by simpa using (WithZero.map'_mono (Prod.Lex.toLex_mono)).comp inr_mono

/-- Given linearly ordered groups with zero M, N, the natural projection ordered homomorphism from
`WithZero (Mˣ ×ₗ Nˣ)` to M, which is the linearly ordered group with zero that can be identified
as their product. -/
@[simps!]
nonrec def fst : WithZero (αˣ ×ₗ βˣ) →*₀o α where
__ := (fst α β).comp (WithZero.map' (toLexMulEquiv ..).symm.toMonoidHom)
monotone' := by
-- this can't rely on `Monotone.comp` since `ofLex` is not monotone
intro x y
cases x <;>
cases y
· simp
· simp
· simp [WithZero.zero_lt_coe]
· simpa using Prod.Lex.monotone_fst _ _

@[simp]
theorem fst_comp_inl : (fst _ _).comp (inl α β) = .id α := by
ext x
obtain rfl | ⟨_, rfl⟩ := GroupWithZero.eq_zero_or_unit x <;>
simp

variable {α β}

lemma inl_eq_coe_inlₗ {m : α} (hm : m ≠ 0) :
inl α β m = OrderMonoidHom.inlₗ αˣ βˣ (Units.mk0 _ hm) := by
lift m to αˣ using isUnit_iff_ne_zero.mpr hm
simp

lemma inr_eq_coe_inrₗ {n : β} (hn : n ≠ 0) :
inr α β n = OrderMonoidHom.inrₗ αˣ βˣ (Units.mk0 _ hn) := by
lift n to βˣ using isUnit_iff_ne_zero.mpr hn
simp

theorem inl_mul_inr_eq_coe_toLex {m : α} {n : β} (hm : m ≠ 0) (hn : n ≠ 0) :
inl α β m * inr α β n = toLex (Units.mk0 _ hm, Units.mk0 _ hn) := by
rw [inl_eq_coe_inlₗ hm, inr_eq_coe_inrₗ hn,
← WithZero.coe_mul, OrderMonoidHom.inlₗ_mul_inrₗ_eq_toLex]

end LinearOrderedCommGroupWithZero
16 changes: 16 additions & 0 deletions Mathlib/Algebra/Order/Hom/Monoid.lean
Original file line number Diff line number Diff line change
Expand Up @@ -926,15 +926,31 @@ end Mul
section LinearOrderedCommMonoidWithZero

variable {hα : Preorder α} {hα' : MulZeroOneClass α} {hβ : Preorder β} {hβ' : MulZeroOneClass β}
{hγ : Preorder γ} {hγ' : MulZeroOneClass γ}

@[simp]
theorem toMonoidWithZeroHom_eq_coe (f : α →*₀o β) : f.toMonoidWithZeroHom = f := by
rfl

@[simp]
theorem toMonoidWithZeroHom_mk (f : α →*₀ β) (hf : Monotone f) :
((OrderMonoidWithZeroHom.mk f hf) : α →*₀ β) = f := by
rfl

@[simp]
lemma toMonoidWithZeroHom_coe (f : β →*₀o γ) (g : α →*₀o β) :
(f.comp g : α →*₀ γ) = (f : β →*₀ γ).comp g :=
rfl

@[simp]
theorem toOrderMonoidHom_eq_coe (f : α →*₀o β) : f.toOrderMonoidHom = f :=
rfl

@[simp]
lemma toOrderMonoidHom_comp (f : β →*₀o γ) (g : α →*₀o β) :
(f.comp g : α →*o γ) = (f : β →*o γ).comp g :=
rfl

end LinearOrderedCommMonoidWithZero

end OrderMonoidWithZeroHom
Expand Down
154 changes: 154 additions & 0 deletions Mathlib/Algebra/Order/Monoid/Lex.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/-
Copyright (c) 2025 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Algebra.Group.Prod
import Mathlib.Algebra.Order.Hom.Monoid
import Mathlib.Data.Prod.Lex
import Mathlib.Order.Prod.Lex.Hom

/-!
# Order homomorphisms for products of ordered monoids

This file defines order homomorphisms for products of ordered monoids, for both the plain product
and the lexicographic product.

The product of ordered monoids `α × β` is an ordered monoid itself with both natural inclusions
and projections, making it the coproduct as well.

## TODO

Create the "OrdCommMon" category.

-/

namespace MonoidHom

variable {α β : Type*} [Monoid α] [Preorder α] [Monoid β] [Preorder β]

@[to_additive]
lemma inl_mono : Monotone (MonoidHom.inl α β) :=
fun _ _ ↦ by simp

@[to_additive]
lemma inl_strictMono : StrictMono (MonoidHom.inl α β) :=
fun _ _ ↦ by simp

@[to_additive]
lemma inr_mono : Monotone (MonoidHom.inr α β) :=
fun _ _ ↦ by simp

@[to_additive]
lemma inr_strictMono : StrictMono (MonoidHom.inr α β) :=
fun _ _ ↦ by simp

@[to_additive]
lemma fst_mono : Monotone (MonoidHom.fst α β) :=
fun _ _ ↦ by simp +contextual [Prod.le_def]

@[to_additive]
lemma snd_mono : Monotone (MonoidHom.snd α β) :=
fun _ _ ↦ by simp +contextual [Prod.le_def]

end MonoidHom

namespace OrderMonoidHom

variable (α β : Type*) [Monoid α] [PartialOrder α] [Monoid β] [Preorder β]

/-- Given ordered monoids M, N, the natural inclusion ordered homomorphism from M to M × N. -/
@[to_additive (attr := simps!) "Given ordered additive monoids M, N, the natural inclusion ordered
homomorphism from M to M × N."]
def inl : α →*o α × β where
__ := MonoidHom.inl _ _
monotone' := MonoidHom.inl_mono

/-- Given ordered monoids M, N, the natural inclusion ordered homomorphism from N to M × N. -/
@[to_additive (attr := simps!) "Given ordered additive monoids M, N, the natural inclusion ordered
homomorphism from N to M × N."]
def inr : β →*o α × β where
__ := MonoidHom.inr _ _
monotone' := MonoidHom.inr_mono

/-- Given ordered monoids M, N, the natural projection ordered homomorphism from M × N to M. -/
@[to_additive (attr := simps!) "Given ordered additive monoids M, N, the natural projection ordered
homomorphism from M × N to M."]
def fst : α × β →*o α where
__ := MonoidHom.fst _ _
monotone' := MonoidHom.fst_mono

/-- Given ordered monoids M, N, the natural projection ordered homomorphism from M × N to N. -/
@[to_additive (attr := simps!) "Given ordered additive monoids M, N, the natural projection ordered
homomorphism from M × N to N."]
def snd : α × β →*o β where
__ := MonoidHom.snd _ _
monotone' := MonoidHom.snd_mono

/-- Given ordered monoids M, N, the natural inclusion ordered homomorphism from M to the
lexicographic M ×ₗ N. -/
@[to_additive (attr := simps!) "Given ordered additive monoids M, N, the natural inclusion ordered
homomorphism from M to the lexicographic M ×ₗ N."]
def inlₗ : α →*o α ×ₗ β where
__ := (Prod.Lex.toLexOrderHom).comp (inl α β)
map_one' := rfl
map_mul' := by simp [← toLex_mul]

/-- Given ordered monoids M, N, the natural inclusion ordered homomorphism from N to the
lexicographic M ×ₗ N. -/
@[to_additive (attr := simps!) "Given ordered additive monoids M, N, the natural inclusion ordered
homomorphism from N to the lexicographic M ×ₗ N."]
def inrₗ : β →*o (α ×ₗ β) where
__ := Prod.Lex.toLexOrderHom.comp (inr α β)
map_one' := rfl
map_mul' := by simp [← toLex_mul]

/-- Given ordered monoids M, N, the natural projection ordered homomorphism from the
lexicographic M ×ₗ N to M. -/
@[to_additive (attr := simps!) "Given ordered additive monoids M, N, the natural projection ordered
homomorphism from the lexicographic M ×ₗ N to M."]
def fstₗ : (α ×ₗ β) →*o α where
toFun p := (ofLex p).fst
map_one' := rfl
map_mul' := by simp
monotone' := Prod.Lex.monotone_fst_ofLex

@[to_additive (attr := simp)]
theorem fst_comp_inl : (fst α β).comp (inl α β) = .id α :=
rfl

@[to_additive (attr := simp)]
theorem fstₗ_comp_inlₗ : (fstₗ α β).comp (inlₗ α β) = .id α :=
rfl

@[to_additive (attr := simp)]
theorem snd_comp_inl : (snd α β).comp (inl α β) = 1 :=
rfl

@[to_additive (attr := simp)]
theorem fst_comp_inr : (fst α β).comp (inr α β) = 1 :=
rfl

@[to_additive (attr := simp)]
theorem snd_comp_inr : (snd α β).comp (inr α β) = .id β :=
rfl

@[to_additive]
theorem inl_mul_inr_eq_mk (m : α) (n : β) : inl α β m * inr α β n = (m, n) := by
simp

@[to_additive]
theorem inlₗ_mul_inrₗ_eq_toLex (m : α) (n : β) : inlₗ α β m * inrₗ α β n = toLex (m, n) := by
simp [← toLex_mul]

variable {α β}

@[to_additive]
theorem commute_inl_inr (m : α) (n : β) : Commute (inl α β m) (inr α β n) :=
Commute.prod (.one_right m) (.one_left n)

@[to_additive]
theorem commute_inlₗ_inrₗ (m : α) (n : β) : Commute (inlₗ α β m) (inrₗ α β n) :=
Commute.prod (.one_right m) (.one_left n)

end OrderMonoidHom
18 changes: 18 additions & 0 deletions Mathlib/Order/Prod/Lex/Hom.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/-
Copyright (c) 2025 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.Prod.Lex
import Mathlib.Order.Hom.Basic

/-!
# Order homomorphism for `Prod.Lex`
-/

/-- `toLex` as an `OrderHom`. -/
@[simps]
def Prod.Lex.toLexOrderHom {α β : Type*} [PartialOrder α] [Preorder β] :
α × β →o α ×ₗ β where
toFun := toLex
monotone' := Prod.Lex.toLex_mono