|
| 1 | +/- |
| 2 | +Copyright (c) 2020 Scott Morrison. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Scott Morrison |
| 5 | +-/ |
| 6 | +import algebra.category.Algebra.basic |
| 7 | +import algebra.category.Module.limits |
| 8 | +import algebra.category.CommRing.limits |
| 9 | + |
| 10 | +/-! |
| 11 | +# The category of R-algebras has all limits |
| 12 | +
|
| 13 | +Further, these limits are preserved by the forgetful functor --- that is, |
| 14 | +the underlying types are just the limits in the category of types. |
| 15 | +-/ |
| 16 | + |
| 17 | +open category_theory |
| 18 | +open category_theory.limits |
| 19 | + |
| 20 | +universe u |
| 21 | + |
| 22 | +namespace Algebra |
| 23 | + |
| 24 | +variables {R : Type u} [comm_ring R] |
| 25 | +variables {J : Type u} [small_category J] |
| 26 | + |
| 27 | +instance semiring_obj (F : J ⥤ Algebra R) (j) : |
| 28 | + semiring ((F ⋙ forget (Algebra R)).obj j) := |
| 29 | +by { change semiring (F.obj j), apply_instance } |
| 30 | + |
| 31 | +instance algebra_obj (F : J ⥤ Algebra R) (j) : |
| 32 | + algebra R ((F ⋙ forget (Algebra R)).obj j) := |
| 33 | +by { change algebra R (F.obj j), apply_instance } |
| 34 | + |
| 35 | +/-- |
| 36 | +The flat sections of a functor into `Algebra R` form a submodule of all sections. |
| 37 | +-/ |
| 38 | +def sections_subalgebra (F : J ⥤ Algebra R) : |
| 39 | + subalgebra R (Π j, F.obj j) := |
| 40 | +{ carrier := SemiRing.sections_subsemiring (F ⋙ forget₂ (Algebra R) Ring ⋙ forget₂ Ring SemiRing), |
| 41 | + algebra_map_mem' := λ r j j' f, (F.map f).commutes r, } |
| 42 | + |
| 43 | + |
| 44 | +instance limit_semiring (F : J ⥤ Algebra R) : |
| 45 | + ring (limit (F ⋙ forget (Algebra R))) := |
| 46 | +begin |
| 47 | + change ring (sections_subalgebra F), |
| 48 | + apply_instance, |
| 49 | +end |
| 50 | + |
| 51 | +instance limit_algebra (F : J ⥤ Algebra R) : |
| 52 | + algebra R (limit (F ⋙ forget (Algebra R))) := |
| 53 | +begin |
| 54 | + change algebra R (sections_subalgebra F), |
| 55 | + apply_instance, |
| 56 | +end |
| 57 | + |
| 58 | +/-- `limit.π (F ⋙ forget (Algebra R)) j` as a `alg_hom`. -/ |
| 59 | +def limit_π_alg_hom (F : J ⥤ Algebra R) (j) : |
| 60 | + limit (F ⋙ forget (Algebra R)) →ₐ[R] (F ⋙ forget (Algebra R)).obj j := |
| 61 | +{ commutes' := λ r, rfl, |
| 62 | + ..SemiRing.limit_π_ring_hom (F ⋙ forget₂ (Algebra R) Ring ⋙ forget₂ Ring SemiRing) j } |
| 63 | + |
| 64 | +namespace has_limits |
| 65 | +-- The next two definitions are used in the construction of `has_limits (Algebra R)`. |
| 66 | +-- After that, the limits should be constructed using the generic limits API, |
| 67 | +-- e.g. `limit F`, `limit.cone F`, and `limit.is_limit F`. |
| 68 | + |
| 69 | +/-- |
| 70 | +Construction of a limit cone in `Algebra R`. |
| 71 | +(Internal use only; use the limits API.) |
| 72 | +-/ |
| 73 | +def limit (F : J ⥤ Algebra R) : cone F := |
| 74 | +{ X := Algebra.of R (limit (F ⋙ forget _)), |
| 75 | + π := |
| 76 | + { app := limit_π_alg_hom F, |
| 77 | + naturality' := λ j j' f, |
| 78 | + alg_hom.coe_fn_inj ((limit.cone (F ⋙ forget _)).π.naturality f) } } |
| 79 | + |
| 80 | +/-- |
| 81 | +Witness that the limit cone in `Algebra R` is a limit cone. |
| 82 | +(Internal use only; use the limits API.) |
| 83 | +-/ |
| 84 | +def limit_is_limit (F : J ⥤ Algebra R) : is_limit (limit F) := |
| 85 | +begin |
| 86 | + refine is_limit.of_faithful |
| 87 | + (forget (Algebra R)) (limit.is_limit _) |
| 88 | + (λ s, { .. }) (λ s, rfl), |
| 89 | + { simp only [forget_map_eq_coe, alg_hom.map_one, functor.map_cone_π], refl, }, |
| 90 | + { intros x y, simp only [forget_map_eq_coe, alg_hom.map_mul, functor.map_cone_π], refl, }, |
| 91 | + { simp only [forget_map_eq_coe, alg_hom.map_zero, functor.map_cone_π], refl, }, |
| 92 | + { intros x y, simp only [forget_map_eq_coe, alg_hom.map_add, functor.map_cone_π], refl, }, |
| 93 | + { intros r, ext j, dsimp, erw (s.π.app j).commutes r, refl, }, |
| 94 | +end |
| 95 | + |
| 96 | +end has_limits |
| 97 | + |
| 98 | +open has_limits |
| 99 | + |
| 100 | +/-- The category of R-algebras has all limits. -/ |
| 101 | +instance has_limits : has_limits (Algebra R) := |
| 102 | +{ has_limits_of_shape := λ J 𝒥, |
| 103 | + { has_limit := λ F, by exactI |
| 104 | + { cone := limit F, |
| 105 | + is_limit := limit_is_limit F } } } |
| 106 | + |
| 107 | +/-- |
| 108 | +The forgetful functor from R-algebras to rings preserves all limits. |
| 109 | +-/ |
| 110 | +instance forget₂_Ring_preserves_limits : preserves_limits (forget₂ (Algebra R) Ring) := |
| 111 | +{ preserves_limits_of_shape := λ J 𝒥, |
| 112 | + { preserves_limit := λ F, |
| 113 | + by exactI preserves_limit_of_preserves_limit_cone |
| 114 | + (limit.is_limit F) (limit.is_limit (F ⋙ forget₂ (Algebra R) Ring)) } } |
| 115 | + |
| 116 | +/-- |
| 117 | +The forgetful functor from R-algebras to R-modules preserves all limits. |
| 118 | +-/ |
| 119 | +instance forget₂_Module_preserves_limits : preserves_limits (forget₂ (Algebra R) (Module R)) := |
| 120 | +{ preserves_limits_of_shape := λ J 𝒥, |
| 121 | + { preserves_limit := λ F, |
| 122 | + by exactI preserves_limit_of_preserves_limit_cone |
| 123 | + (limit.is_limit F) (limit.is_limit (F ⋙ forget₂ (Algebra R) (Module R))) } } |
| 124 | + |
| 125 | +/-- |
| 126 | +The forgetful functor from R-algebras to types preserves all limits. |
| 127 | +-/ |
| 128 | +instance forget_preserves_limits : preserves_limits (forget (Algebra R)) := |
| 129 | +{ preserves_limits_of_shape := λ J 𝒥, |
| 130 | + { preserves_limit := λ F, |
| 131 | + by exactI preserves_limit_of_preserves_limit_cone |
| 132 | + (limit.is_limit F) (limit.is_limit (F ⋙ forget _)) } } |
| 133 | + |
| 134 | +end Algebra |
0 commit comments