Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 4bcba0d

Browse files
committed
chore(algebra/order/group/defs): split file (#17787)
Splits: * algebra/order/group/defs.lean * algebra/group/with_one.lean * algebra/order/monoid/with_zero.lean This will get us unstuck on the mathlib4 port, moving some of the files (about algebraic morphisms and equivalences) that are currently waiting for fixes in Lean 4 off the critical path. Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent 1c9ea25 commit 4bcba0d

File tree

17 files changed

+293
-174
lines changed

17 files changed

+293
-174
lines changed

counterexamples/linear_order_with_pos_mul_pos_eq_zero.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
55
Authors: Johan Commelin, Damiano Testa, Kevin Buzzard
66
-/
77
import algebra.order.monoid.defs
8-
import algebra.order.monoid.with_zero
8+
import algebra.order.monoid.with_zero.defs
99

1010
/-!
1111
An example of a `linear_ordered_comm_monoid_with_zero` in which the product of two positive

src/algebra/category/Mon/adjunctions.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Julian Kuelshammer
55
-/
66
import algebra.category.Mon.basic
77
import algebra.category.Semigroup.basic
8-
import algebra.group.with_one
8+
import algebra.group.with_one.basic
99
import algebra.free_monoid.basic
1010

1111
/-!

src/algebra/free.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Kenny Lau
55
-/
66
import algebra.hom.group
7+
import algebra.hom.equiv.basic
78
import control.applicative
89
import control.traversable.basic
910
import logic.equiv.defs

src/algebra/group/default.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Jeremy Avigad, Leonardo de Moura, Michael Howes
55
-/
66
import algebra.group.conj
77
import algebra.group.type_tags
8-
import algebra.group.with_one
8+
import algebra.group.with_one.basic
99
import algebra.hom.units
1010

1111
/-!
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/-
2+
Copyright (c) 2018 Mario Carneiro. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Mario Carneiro, Johan Commelin
5+
-/
6+
import algebra.group.with_one.defs
7+
import algebra.hom.equiv.basic
8+
9+
/-!
10+
# More operations on `with_one` and `with_zero`
11+
12+
This file defines various bundled morphisms on `with_one` and `with_zero`
13+
that were not available in `algebra/group/with_one/defs`.
14+
15+
## Main definitions
16+
17+
* `with_one.lift`, `with_zero.lift`
18+
* `with_one.map`, `with_zero.map`
19+
-/
20+
21+
universes u v w
22+
variables {α : Type u} {β : Type v} {γ : Type w}
23+
24+
namespace with_one
25+
26+
section
27+
-- workaround: we make `with_one`/`with_zero` irreducible for this definition, otherwise `simps`
28+
-- will unfold it in the statement of the lemma it generates.
29+
local attribute [irreducible] with_one with_zero
30+
/-- `coe` as a bundled morphism -/
31+
@[to_additive "`coe` as a bundled morphism", simps apply]
32+
def coe_mul_hom [has_mul α] : α →ₙ* (with_one α) :=
33+
{ to_fun := coe, map_mul' := λ x y, rfl }
34+
35+
end
36+
37+
section lift
38+
39+
local attribute [semireducible] with_one with_zero
40+
41+
variables [has_mul α] [mul_one_class β]
42+
43+
/-- Lift a semigroup homomorphism `f` to a bundled monoid homorphism. -/
44+
@[to_additive "Lift an add_semigroup homomorphism `f` to a bundled add_monoid homorphism."]
45+
def lift : (α →ₙ* β) ≃ (with_one α →* β) :=
46+
{ to_fun := λ f,
47+
{ to_fun := λ x, option.cases_on x 1 f,
48+
map_one' := rfl,
49+
map_mul' := λ x y,
50+
with_one.cases_on x (by { rw one_mul, exact (one_mul _).symm }) $ λ x,
51+
with_one.cases_on y (by { rw mul_one, exact (mul_one _).symm }) $ λ y,
52+
f.map_mul x y },
53+
inv_fun := λ F, F.to_mul_hom.comp coe_mul_hom,
54+
left_inv := λ f, mul_hom.ext $ λ x, rfl,
55+
right_inv := λ F, monoid_hom.ext $ λ x, with_one.cases_on x F.map_one.symm $ λ x, rfl }
56+
57+
variables (f : α →ₙ* β)
58+
59+
@[simp, to_additive]
60+
lemma lift_coe (x : α) : lift f x = f x := rfl
61+
62+
@[simp, to_additive]
63+
lemma lift_one : lift f 1 = 1 := rfl
64+
65+
@[to_additive]
66+
theorem lift_unique (f : with_one α →* β) : f = lift (f.to_mul_hom.comp coe_mul_hom) :=
67+
(lift.apply_symm_apply f).symm
68+
69+
end lift
70+
71+
section map
72+
73+
variables [has_mul α] [has_mul β] [has_mul γ]
74+
75+
/-- Given a multiplicative map from `α → β` returns a monoid homomorphism
76+
from `with_one α` to `with_one β` -/
77+
@[to_additive "Given an additive map from `α → β` returns an add_monoid homomorphism
78+
from `with_zero α` to `with_zero β`"]
79+
def map (f : α →ₙ* β) : with_one α →* with_one β :=
80+
lift (coe_mul_hom.comp f)
81+
82+
@[simp, to_additive] lemma map_coe (f : α →ₙ* β) (a : α) : map f (a : with_one α) = f a :=
83+
lift_coe _ _
84+
85+
@[simp, to_additive]
86+
lemma map_id : map (mul_hom.id α) = monoid_hom.id (with_one α) :=
87+
by { ext, induction x using with_one.cases_on; refl }
88+
89+
@[to_additive]
90+
lemma map_map (f : α →ₙ* β) (g : β →ₙ* γ) (x) :
91+
map g (map f x) = map (g.comp f) x :=
92+
by { induction x using with_one.cases_on; refl }
93+
94+
@[simp, to_additive]
95+
lemma map_comp (f : α →ₙ* β) (g : β →ₙ* γ) :
96+
map (g.comp f) = (map g).comp (map f) :=
97+
monoid_hom.ext $ λ x, (map_map f g x).symm
98+
99+
/-- A version of `equiv.option_congr` for `with_one`. -/
100+
@[to_additive "A version of `equiv.option_congr` for `with_zero`.", simps apply]
101+
def _root_.mul_equiv.with_one_congr (e : α ≃* β) : with_one α ≃* with_one β :=
102+
{ to_fun := map e.to_mul_hom,
103+
inv_fun := map e.symm.to_mul_hom,
104+
left_inv := λ x, (map_map _ _ _).trans $ by induction x using with_one.cases_on; { simp },
105+
right_inv := λ x, (map_map _ _ _).trans $ by induction x using with_one.cases_on; { simp },
106+
.. map e.to_mul_hom }
107+
108+
@[simp]
109+
lemma _root_.mul_equiv.with_one_congr_refl : (mul_equiv.refl α).with_one_congr = mul_equiv.refl _ :=
110+
mul_equiv.to_monoid_hom_injective map_id
111+
112+
@[simp]
113+
lemma _root_.mul_equiv.with_one_congr_symm (e : α ≃* β) :
114+
e.with_one_congr.symm = e.symm.with_one_congr := rfl
115+
116+
@[simp]
117+
lemma _root_.mul_equiv.with_one_congr_trans (e₁ : α ≃* β) (e₂ : β ≃* γ) :
118+
e₁.with_one_congr.trans e₂.with_one_congr = (e₁.trans e₂).with_one_congr :=
119+
mul_equiv.to_monoid_hom_injective (map_comp _ _).symm
120+
121+
end map
122+
123+
end with_one

src/algebra/group/with_one.lean renamed to src/algebra/group/with_one/defs.lean

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Mario Carneiro, Johan Commelin
55
-/
66
import order.with_bot
7-
import algebra.hom.equiv.basic
8-
import algebra.group_with_zero.units.basic
97
import algebra.ring.defs
108

119
/-!
@@ -134,103 +132,8 @@ instance [comm_semigroup α] : comm_monoid (with_one α) :=
134132
{ mul_comm := (option.lift_or_get_comm _).1,
135133
..with_one.monoid }
136134

137-
section
138-
-- workaround: we make `with_one`/`with_zero` irreducible for this definition, otherwise `simps`
139-
-- will unfold it in the statement of the lemma it generates.
140-
local attribute [irreducible] with_one with_zero
141-
/-- `coe` as a bundled morphism -/
142-
@[to_additive "`coe` as a bundled morphism", simps apply]
143-
def coe_mul_hom [has_mul α] : α →ₙ* (with_one α) :=
144-
{ to_fun := coe, map_mul' := λ x y, rfl }
145-
146-
end
147-
148-
section lift
149-
150-
variables [has_mul α] [mul_one_class β]
151-
152-
/-- Lift a semigroup homomorphism `f` to a bundled monoid homorphism. -/
153-
@[to_additive "Lift an add_semigroup homomorphism `f` to a bundled add_monoid homorphism."]
154-
def lift : (α →ₙ* β) ≃ (with_one α →* β) :=
155-
{ to_fun := λ f,
156-
{ to_fun := λ x, option.cases_on x 1 f,
157-
map_one' := rfl,
158-
map_mul' := λ x y,
159-
with_one.cases_on x (by { rw one_mul, exact (one_mul _).symm }) $ λ x,
160-
with_one.cases_on y (by { rw mul_one, exact (mul_one _).symm }) $ λ y,
161-
f.map_mul x y },
162-
inv_fun := λ F, F.to_mul_hom.comp coe_mul_hom,
163-
left_inv := λ f, mul_hom.ext $ λ x, rfl,
164-
right_inv := λ F, monoid_hom.ext $ λ x, with_one.cases_on x F.map_one.symm $ λ x, rfl }
165-
166-
variables (f : α →ₙ* β)
167-
168-
@[simp, to_additive]
169-
lemma lift_coe (x : α) : lift f x = f x := rfl
170-
171-
@[simp, to_additive]
172-
lemma lift_one : lift f 1 = 1 := rfl
173-
174-
@[to_additive]
175-
theorem lift_unique (f : with_one α →* β) : f = lift (f.to_mul_hom.comp coe_mul_hom) :=
176-
(lift.apply_symm_apply f).symm
177-
178-
end lift
179-
180135
attribute [irreducible] with_one
181136

182-
section map
183-
184-
variables [has_mul α] [has_mul β] [has_mul γ]
185-
186-
/-- Given a multiplicative map from `α → β` returns a monoid homomorphism
187-
from `with_one α` to `with_one β` -/
188-
@[to_additive "Given an additive map from `α → β` returns an add_monoid homomorphism
189-
from `with_zero α` to `with_zero β`"]
190-
def map (f : α →ₙ* β) : with_one α →* with_one β :=
191-
lift (coe_mul_hom.comp f)
192-
193-
@[simp, to_additive] lemma map_coe (f : α →ₙ* β) (a : α) : map f (a : with_one α) = f a :=
194-
lift_coe _ _
195-
196-
@[simp, to_additive]
197-
lemma map_id : map (mul_hom.id α) = monoid_hom.id (with_one α) :=
198-
by { ext, induction x using with_one.cases_on; refl }
199-
200-
@[to_additive]
201-
lemma map_map (f : α →ₙ* β) (g : β →ₙ* γ) (x) :
202-
map g (map f x) = map (g.comp f) x :=
203-
by { induction x using with_one.cases_on; refl }
204-
205-
@[simp, to_additive]
206-
lemma map_comp (f : α →ₙ* β) (g : β →ₙ* γ) :
207-
map (g.comp f) = (map g).comp (map f) :=
208-
monoid_hom.ext $ λ x, (map_map f g x).symm
209-
210-
/-- A version of `equiv.option_congr` for `with_one`. -/
211-
@[to_additive "A version of `equiv.option_congr` for `with_zero`.", simps apply]
212-
def _root_.mul_equiv.with_one_congr (e : α ≃* β) : with_one α ≃* with_one β :=
213-
{ to_fun := map e.to_mul_hom,
214-
inv_fun := map e.symm.to_mul_hom,
215-
left_inv := λ x, (map_map _ _ _).trans $ by induction x using with_one.cases_on; { simp },
216-
right_inv := λ x, (map_map _ _ _).trans $ by induction x using with_one.cases_on; { simp },
217-
.. map e.to_mul_hom }
218-
219-
@[simp]
220-
lemma _root_.mul_equiv.with_one_congr_refl : (mul_equiv.refl α).with_one_congr = mul_equiv.refl _ :=
221-
mul_equiv.to_monoid_hom_injective map_id
222-
223-
@[simp]
224-
lemma _root_.mul_equiv.with_one_congr_symm (e : α ≃* β) :
225-
e.with_one_congr.symm = e.symm.with_one_congr := rfl
226-
227-
@[simp]
228-
lemma _root_.mul_equiv.with_one_congr_trans (e₁ : α ≃* β) (e₂ : β ≃* γ) :
229-
e₁.with_one_congr.trans e₂.with_one_congr = (e₁.trans e₂).with_one_congr :=
230-
mul_equiv.to_monoid_hom_injective (map_comp _ _).symm
231-
232-
end map
233-
234137
@[simp, norm_cast, to_additive]
235138
lemma coe_mul [has_mul α] (a b : α) : ((a * b : α) : with_one α) = a * b := rfl
236139

@@ -441,14 +344,6 @@ instance [semiring α] : semiring (with_zero α) :=
441344
..with_zero.mul_zero_class,
442345
..with_zero.monoid_with_zero }
443346

444-
/-- Any group is isomorphic to the units of itself adjoined with `0`. -/
445-
def units_with_zero_equiv [group α] : (with_zero α)ˣ ≃* α :=
446-
{ to_fun := λ a, unzero a.ne_zero,
447-
inv_fun := λ a, units.mk0 a coe_ne_zero,
448-
left_inv := λ _, units.ext $ by simpa only [coe_unzero],
449-
right_inv := λ _, rfl,
450-
map_mul' := λ _ _, coe_inj.mp $ by simpa only [coe_unzero, coe_mul] }
451-
452347
attribute [irreducible] with_zero
453348

454349
end with_zero
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/-
2+
Copyright (c) 2018 Mario Carneiro. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Mario Carneiro, Johan Commelin
5+
-/
6+
import algebra.group.with_one.basic
7+
import algebra.group_with_zero.units.basic
8+
9+
/-!
10+
# Isomorphism between a group and the units of itself adjoined with `0`
11+
12+
## Notes
13+
This is here to keep `algebra.group_with_zero.units.basic` out of the import requirements of
14+
`algebra.order.field.defs`.
15+
-/
16+
17+
namespace with_zero
18+
19+
/-- Any group is isomorphic to the units of itself adjoined with `0`. -/
20+
def units_with_zero_equiv {α : Type*} [group α] : (with_zero α)ˣ ≃* α :=
21+
{ to_fun := λ a, unzero a.ne_zero,
22+
inv_fun := λ a, units.mk0 a coe_ne_zero,
23+
left_inv := λ _, units.ext $ by simpa only [coe_unzero],
24+
right_inv := λ _, rfl,
25+
map_mul' := λ _ _, coe_inj.mp $ by simpa only [coe_unzero, coe_mul] }
26+
27+
end with_zero

src/algebra/order/field/defs.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ class linear_ordered_field (α : Type*) extends linear_ordered_comm_ring α, fie
4242
instance linear_ordered_field.to_linear_ordered_semifield [linear_ordered_field α] :
4343
linear_ordered_semifield α :=
4444
{ ..linear_ordered_ring.to_linear_ordered_semiring, ..‹linear_ordered_field α› }
45+
46+
-- Guard against import creep.
47+
assert_not_exists monoid_hom

src/algebra/order/group/abs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl
55
-/
66
import algebra.abs
7-
import algebra.order.group.defs
7+
import algebra.order.group.order_iso
88
import order.min_max
99

1010
/-!

0 commit comments

Comments
 (0)