|
1 |
| -/- Copyright (c) 2018 Scott Morrison. All rights reserved. |
| 1 | +/- |
| 2 | +Copyright (c) 2018 Scott Morrison. All rights reserved. |
2 | 3 | Released under Apache 2.0 license as described in the file LICENSE.
|
3 |
| -Authors: Scott Morrison, Johannes Hölzl |
4 |
| -
|
5 |
| -Introduce CommRing -- the category of commutative rings. |
| 4 | +Authors: Scott Morrison, Johannes Hölzl, Yury Kudryashov |
6 | 5 | -/
|
7 | 6 |
|
8 | 7 | import algebra.category.Mon.basic
|
9 | 8 | import category_theory.fully_faithful
|
10 | 9 | import algebra.ring
|
11 | 10 | import data.int.basic
|
12 | 11 |
|
| 12 | +/-! |
| 13 | +# Category instances for semiring, ring, comm_semiring, and comm_ring. |
| 14 | +
|
| 15 | +We introduce the bundled categories: |
| 16 | +* `SemiRing` |
| 17 | +* `Ring` |
| 18 | +* `CommSemiRing` |
| 19 | +* `CommRing` |
| 20 | +along with the relevant forgetful functors between them. |
| 21 | +-/ |
| 22 | + |
13 | 23 | universes u v
|
14 | 24 |
|
15 | 25 | open category_theory
|
16 | 26 |
|
| 27 | +/-- The category of semirings. -/ |
| 28 | +@[reducible] def SemiRing : Type (u+1) := bundled semiring |
| 29 | + |
| 30 | +namespace SemiRing |
| 31 | + |
| 32 | +/-- Construct a bundled SemiRing from the underlying type and typeclass. -/ |
| 33 | +def of (R : Type u) [semiring R] : SemiRing := bundled.of R |
| 34 | + |
| 35 | +instance (R : SemiRing) : semiring R := R.str |
| 36 | + |
| 37 | +instance bundled_hom : bundled_hom @ring_hom := |
| 38 | +⟨@ring_hom.to_fun, @ring_hom.id, @ring_hom.comp, @ring_hom.ext⟩ |
| 39 | + |
| 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) |
| 42 | + |
| 43 | +end SemiRing |
| 44 | + |
17 | 45 | /-- The category of rings. -/
|
18 | 46 | @[reducible] def Ring : Type (u+1) := bundled ring
|
19 | 47 |
|
20 |
| -/-- The category of commutative rings. -/ |
21 |
| -@[reducible] def CommRing : Type (u+1) := bundled comm_ring |
22 |
| - |
23 | 48 | namespace Ring
|
24 | 49 |
|
25 |
| -instance (x : Ring) : ring x := x.str |
| 50 | +instance (R : Ring) : ring R := R.str |
26 | 51 |
|
27 |
| -instance concrete_is_ring_hom : concrete_category @is_ring_hom := |
28 |
| -⟨by introsI α ia; apply_instance, |
29 |
| - by introsI α β γ ia ib ic f g hf hg; apply_instance⟩ |
| 52 | +/-- Construct a bundled Ring from the underlying type and typeclass. -/ |
| 53 | +def of (R : Type u) [ring R] : Ring := bundled.of R |
30 | 54 |
|
31 |
| -def of (α : Type u) [ring α] : Ring := ⟨α⟩ |
| 55 | +instance bundled_hom : bundled_hom _ := |
| 56 | +SemiRing.bundled_hom.full_subcategory @ring.to_semiring |
32 | 57 |
|
33 |
| -abbreviation forget : Ring.{u} ⥤ Type u := forget |
34 |
| - |
35 |
| -instance hom_is_ring_hom {R S : Ring} (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2 |
| 58 | +instance has_forget_to_SemiRing : has_forget₂ Ring.{u} SemiRing.{u} := |
| 59 | +SemiRing.bundled_hom.full_subcategory_has_forget₂ _ |
36 | 60 |
|
37 | 61 | end Ring
|
38 | 62 |
|
39 |
| -namespace CommRing |
| 63 | +/-- The category of commutative semirings. -/ |
| 64 | +@[reducible] def CommSemiRing : Type (u+1) := bundled comm_semiring |
40 | 65 |
|
41 |
| -instance (x : CommRing) : comm_ring x := x.str |
| 66 | +namespace CommSemiRing |
42 | 67 |
|
43 |
| -abbreviation is_comm_ring_hom {α β} [comm_ring α] [comm_ring β] (f : α → β) : Prop := |
44 |
| -is_ring_hom f |
| 68 | +instance (R : CommSemiRing) : comm_semiring R := R.str |
45 | 69 |
|
46 |
| -instance concrete_is_comm_ring_hom : concrete_category @is_comm_ring_hom := |
47 |
| -⟨by introsI α ia; apply_instance, |
48 |
| - by introsI α β γ ia ib ic f g hf hg; apply_instance⟩ |
| 70 | +/-- Construct a bundled CommSemiRing from the underlying type and typeclass. -/ |
| 71 | +def of (R : Type u) [comm_semiring R] : CommSemiRing := bundled.of R |
49 | 72 |
|
50 |
| -def of (α : Type u) [comm_ring α] : CommRing := ⟨α⟩ |
| 73 | +instance bundled_hom : bundled_hom _ := |
| 74 | +SemiRing.bundled_hom.full_subcategory @comm_semiring.to_semiring |
51 | 75 |
|
52 |
| -abbreviation forget : CommRing.{u} ⥤ Type u := forget |
| 76 | +instance has_forget_to_SemiRing : has_forget₂ CommSemiRing.{u} SemiRing.{u} := |
| 77 | +bundled_hom.full_subcategory_has_forget₂ _ _ |
53 | 78 |
|
54 |
| -instance hom_is_ring_hom {R S : CommRing} (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2 |
| 79 | +/-- 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) |
55 | 85 |
|
56 |
| -variables {R S T : CommRing.{u}} |
| 86 | +end CommSemiRing |
57 | 87 |
|
58 |
| --- TODO rename the next two definitions? |
59 |
| -def Int.cast {R : CommRing} : CommRing.of ℤ ⟶ R := { val := int.cast, property := by apply_instance } |
| 88 | +/-- The category of commutative rings. -/ |
| 89 | +@[reducible] def CommRing : Type (u+1) := bundled comm_ring |
60 | 90 |
|
61 |
| -def Int.hom_unique {R : CommRing} : unique (CommRing.of ℤ ⟶ R) := |
62 |
| -{ default := Int.cast, |
63 |
| - uniq := λ f, subtype.ext.mpr $ funext $ int.eq_cast f f.2.map_one f.2.map_add } |
| 91 | +namespace CommRing |
64 | 92 |
|
65 |
| -instance forget.faithful : faithful (forget) := {} |
| 93 | +instance (R : CommRing) : comm_ring R := R.str |
66 | 94 |
|
67 |
| -instance forget_comm_ring (R : CommRing) : comm_ring (forget.obj R) := R.str |
68 |
| -instance forget_is_ring_hom {R S : CommRing} (f : R ⟶ S) : is_ring_hom (forget.map f) := f.property |
| 95 | +/-- Construct a bundled CommRing from the underlying type and typeclass. -/ |
| 96 | +def of (R : Type u) [comm_ring R] : CommRing := bundled.of R |
69 | 97 |
|
70 |
| -/-- The functor from commutative rings to rings. -/ |
71 |
| -def to_Ring : CommRing.{u} ⥤ Ring.{u} := |
72 |
| -{ obj := λ X, { α := X.1 }, |
73 |
| - map := λ X Y f, ⟨ f, by apply_instance ⟩ } |
| 98 | +instance bundled_hom : bundled_hom _ := |
| 99 | +Ring.bundled_hom.full_subcategory @comm_ring.to_ring |
74 | 100 |
|
75 |
| -instance to_Ring.faithful : faithful (to_Ring) := {} |
| 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 |
76 | 104 |
|
77 |
| -/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/ |
78 |
| -def forget_to_CommMon : CommRing.{u} ⥤ CommMon.{u} := |
79 |
| -{ obj := λ X, { α := X.1 }, |
80 |
| - map := λ X Y f, ⟨ f, by apply_instance ⟩ } |
| 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 |
81 | 109 |
|
82 |
| -instance forget_to_CommMon.faithful : faithful (forget_to_CommMon) := {} |
| 110 | +instance has_forget_to_Ring : has_forget₂ CommRing.{u} Ring.{u} := |
| 111 | +by apply bundled_hom.full_subcategory_has_forget₂ |
83 | 112 |
|
84 |
| -example : faithful (forget_to_CommMon ⋙ CommMon.forget_to_Mon) := by apply_instance |
| 113 | +/-- 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) |
85 | 119 |
|
86 | 120 | end CommRing
|
0 commit comments