@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Scott Morrison, Johannes Hölzl, Yury Kudryashov
5
5
-/
6
6
7
- import algebra.category.Mon.basic
7
+ import algebra.category.Group
8
8
import category_theory.fully_faithful
9
9
import algebra.ring
10
10
import data.int.basic
@@ -18,103 +18,117 @@ We introduce the bundled categories:
18
18
* `CommSemiRing`
19
19
* `CommRing`
20
20
along with the relevant forgetful functors between them.
21
+
22
+ ## Implementation notes
23
+
24
+ See the note [locally reducible category instances].
25
+
21
26
-/
22
27
23
28
universes u v
24
29
25
30
open category_theory
26
31
27
32
/-- The category of semirings. -/
28
- @[reducible] def SemiRing : Type (u+1 ) := bundled semiring
33
+ def SemiRing : Type (u+1 ) := bundled semiring
29
34
30
35
namespace SemiRing
31
36
32
37
/-- Construct a bundled SemiRing from the underlying type and typeclass. -/
33
38
def of (R : Type u) [semiring R] : SemiRing := bundled.of R
34
39
40
+ local attribute [reducible] SemiRing
41
+
42
+ instance : has_coe_to_sort SemiRing := infer_instance
43
+
35
44
instance (R : SemiRing) : semiring R := R.str
36
45
37
46
instance bundled_hom : bundled_hom @ring_hom :=
38
47
⟨@ring_hom.to_fun, @ring_hom.id, @ring_hom.comp, @ring_hom.coe_inj⟩
39
48
40
- instance has_forget_to_Mon : has_forget₂ SemiRing.{u} Mon.{u} :=
41
- bundled_hom.mk_has_forget₂ @semiring.to_monoid (λ R₁ R₂ f, f.to_monoid_hom) (λ _ _ _, rfl)
49
+ instance : concrete_category SemiRing := infer_instance
50
+
51
+ instance has_forget_to_Mon : has_forget₂ SemiRing Mon :=
52
+ bundled_hom.mk_has_forget₂ @semiring.to_monoid (λ R₁ R₂, ring_hom.to_monoid_hom) (λ _ _ _, rfl)
53
+ instance has_forget_to_AddCommMon : has_forget₂ SemiRing AddCommMon :=
54
+ -- can't use bundled_hom.mk_has_forget₂, since AddCommMon is an induced category
55
+ { forget₂ :=
56
+ { obj := λ R, AddCommMon.of R,
57
+ map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }
42
58
43
59
end SemiRing
44
60
45
61
/-- The category of rings. -/
46
- @[reducible] def Ring : Type (u+1 ) := bundled ring
62
+ def Ring : Type (u+1 ) := induced_category SemiRing ( bundled.map @ ring.to_semiring)
47
63
48
64
namespace Ring
49
65
50
- instance (R : Ring) : ring R := R.str
51
-
52
66
/-- Construct a bundled Ring from the underlying type and typeclass. -/
53
67
def of (R : Type u) [ring R] : Ring := bundled.of R
54
68
55
- instance bundled_hom : bundled_hom _ :=
56
- SemiRing.bundled_hom.full_subcategory @ring.to_semiring
69
+ local attribute [reducible] Ring
70
+
71
+ instance : has_coe_to_sort Ring := infer_instance
72
+
73
+ instance (R : Ring) : ring R := R.str
74
+
75
+ instance : concrete_category Ring := infer_instance
57
76
58
- instance has_forget_to_SemiRing : has_forget₂ Ring.{u} SemiRing.{u} :=
59
- SemiRing.bundled_hom.full_subcategory_has_forget₂ _
77
+ instance has_forget_to_SemiRing : has_forget₂ Ring SemiRing := infer_instance
78
+ instance has_forget_to_AddCommGroup : has_forget₂ Ring AddCommGroup :=
79
+ -- can't use bundled_hom.mk_has_forget₂, since AddCommGroup is an induced category
80
+ { forget₂ :=
81
+ { obj := λ R, AddCommGroup.of R,
82
+ map := λ R₁ R₂ f, ring_hom.to_add_monoid_hom f } }
60
83
61
84
end Ring
62
85
63
86
/-- The category of commutative semirings. -/
64
- @[reducible] def CommSemiRing : Type (u+1 ) := bundled comm_semiring
87
+ def CommSemiRing : Type (u+1 ) := induced_category SemiRing ( bundled.map comm_semiring.to_semiring)
65
88
66
89
namespace CommSemiRing
67
90
68
- instance (R : CommSemiRing) : comm_semiring R := R.str
69
-
70
91
/-- Construct a bundled CommSemiRing from the underlying type and typeclass. -/
71
92
def of (R : Type u) [comm_semiring R] : CommSemiRing := bundled.of R
72
93
73
- instance bundled_hom : bundled_hom _ :=
74
- SemiRing.bundled_hom.full_subcategory @comm_semiring.to_semiring
94
+ local attribute [reducible] CommSemiRing
95
+
96
+ instance : has_coe_to_sort CommSemiRing := infer_instance
97
+
98
+ instance (R : CommSemiRing) : comm_semiring R := R.str
75
99
76
- instance has_forget_to_SemiRing : has_forget₂ CommSemiRing.{u} SemiRing.{u} :=
77
- bundled_hom.full_subcategory_has_forget₂ _ _
100
+ instance : concrete_category CommSemiRing := infer_instance
101
+
102
+ instance has_forget_to_SemiRing : has_forget₂ CommSemiRing SemiRing := infer_instance
78
103
79
104
/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/
80
- instance has_forget_to_CommMon : has_forget₂ CommSemiRing.{u} CommMon.{u} :=
81
- bundled_hom.mk_has_forget₂
82
- @comm_semiring.to_comm_monoid
83
- (λ R₁ R₂ f, f.to_monoid_hom)
84
- (by intros; refl)
105
+ instance has_forget_to_CommMon : has_forget₂ CommSemiRing CommMon :=
106
+ has_forget₂.mk'
107
+ (λ R : CommSemiRing, CommMon.of R) (λ R, rfl)
108
+ (λ R₁ R₂ f, f.to_monoid_hom) (by tidy)
85
109
86
110
end CommSemiRing
87
111
88
112
/-- The category of commutative rings. -/
89
- @[reducible] def CommRing : Type (u+1 ) := bundled comm_ring
113
+ def CommRing : Type (u+1 ) := induced_category Ring ( bundled.map comm_ring.to_ring)
90
114
91
115
namespace CommRing
92
116
93
- instance (R : CommRing) : comm_ring R := R.str
94
-
95
117
/-- Construct a bundled CommRing from the underlying type and typeclass. -/
96
118
def of (R : Type u) [comm_ring R] : CommRing := bundled.of R
97
119
98
- instance bundled_hom : bundled_hom _ :=
99
- Ring.bundled_hom.full_subcategory @comm_ring.to_ring
120
+ local attribute [reducible] CommRing
100
121
101
- @[simp] lemma id_eq (R : CommRing) : 𝟙 R = ring_hom.id R := rfl
102
- @[simp] lemma comp_eq {R₁ R₂ R₃ : CommRing} (f : R₁ ⟶ R₂) (g : R₂ ⟶ R₃) :
103
- f ≫ g = g.comp f := rfl
122
+ instance : has_coe_to_sort CommRing := infer_instance
123
+
124
+ instance (R : CommRing) : comm_ring R := R.str
104
125
105
- @[simp] lemma forget_obj_eq_coe {R : CommRing} : (forget CommRing).obj R = R := rfl
106
- @[simp] lemma forget_map_eq_coe {R₁ R₂ : CommRing} (f : R₁ ⟶ R₂) :
107
- (forget CommRing).map f = f :=
108
- rfl
126
+ instance : concrete_category CommRing := infer_instance
109
127
110
- instance has_forget_to_Ring : has_forget₂ CommRing.{u} Ring.{u} :=
111
- by apply bundled_hom.full_subcategory_has_forget₂
128
+ instance has_forget_to_Ring : has_forget₂ CommRing Ring := infer_instance
112
129
113
130
/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/
114
- instance has_forget_to_CommSemiRing : has_forget₂ CommRing.{u} CommSemiRing.{u} :=
115
- bundled_hom.mk_has_forget₂
116
- @comm_ring.to_comm_semiring
117
- (λ _ _, id)
118
- (by intros; refl)
131
+ instance has_forget_to_CommSemiRing : has_forget₂ CommRing CommSemiRing :=
132
+ has_forget₂.mk' (λ R : CommRing, CommSemiRing.of R) (λ R, rfl) (λ R₁ R₂ f, f) (by tidy)
119
133
120
134
end CommRing
0 commit comments