-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathBasic.lean
More file actions
198 lines (160 loc) · 6.86 KB
/
Basic.lean
File metadata and controls
198 lines (160 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/-
Copyright (c) 2024 Christian Merten. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christian Merten
-/
import Mathlib.Algebra.Category.Ring.Colimits
import Mathlib.Algebra.Category.Ring.Constructions
import Mathlib.CategoryTheory.Comma.Over.Pullback
/-!
# Under `CommRingCat`
In this file we provide basic API for `Under R` when `R : CommRingCat`. `Under R` is
(equivalent to) the category of commutative `R`-algebras. For not necessarily commutative
algebras, use `AlgebraCat R` instead.
-/
noncomputable section
universe u
open TensorProduct CategoryTheory Limits
variable {R S : CommRingCat.{u}}
namespace CommRingCat
instance : CoeSort (Under R) (Type u) where
coe A := A.right
instance algebra (A : Under R) : Algebra R A := RingHom.toAlgebra A.hom.hom
/-- Turn a morphism in `Under R` into an algebra homomorphism. -/
def toAlgHom {A B : Under R} (f : A ⟶ B) : A →ₐ[R] B where
__ := f.right.hom
commutes' a := by
have : (A.hom ≫ f.right) a = B.hom a := by simp
simpa only [Functor.const_obj_obj, Functor.id_obj, CommRingCat.comp_apply] using this
@[simp]
lemma toAlgHom_id (A : Under R) : toAlgHom (𝟙 A) = AlgHom.id R A := rfl
@[simp]
lemma toAlgHom_comp {A B C : Under R} (f : A ⟶ B) (g : B ⟶ C) :
toAlgHom (f ≫ g) = (toAlgHom g).comp (toAlgHom f) := rfl
@[simp]
lemma toAlgHom_apply {A B : Under R} (f : A ⟶ B) (a : A) :
toAlgHom f a = f.right a :=
rfl
variable (R) in
/-- Make an object of `Under R` from an `R`-algebra. -/
@[simps! hom, simps! -isSimp right]
def mkUnder (A : Type u) [CommRing A] [Algebra R A] : Under R :=
Under.mk (CommRingCat.ofHom <| algebraMap R A)
@[ext]
lemma mkUnder_ext {A : Type u} [CommRing A] [Algebra R A] {B : Under R}
{f g : mkUnder R A ⟶ B} (h : ∀ a : A, f.right a = g.right a) :
f = g := by
ext x
exact h x
@[simp]
lemma mkUnder_eq (A : Type u) [CommRing A] [inst : Algebra R A] :
algebra (R.mkUnder A) = inst := Algebra.algebra_ext _ _ (congrFun rfl)
end CommRingCat
namespace AlgHom
/-- Make a morphism in `Under R` from an algebra map. -/
def toUnder {A B : Type u} [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
(f : A →ₐ[R] B) : CommRingCat.mkUnder R A ⟶ CommRingCat.mkUnder R B :=
Under.homMk (CommRingCat.ofHom f.toRingHom) <| by
ext a
exact f.commutes' a
@[simp]
lemma toUnder_right {A B : Type u} [CommRing A] [CommRing B] [Algebra R A]
[Algebra R B] (f : A →ₐ[R] B) (a : A) :
f.toUnder.right a = f a :=
rfl
@[simp]
lemma toUnder_comp {A B C : Type u} [CommRing A] [CommRing B] [CommRing C]
[Algebra R A] [Algebra R B] [Algebra R C] (f : A →ₐ[R] B) (g : B →ₐ[R] C) :
(g.comp f).toUnder = f.toUnder ≫ g.toUnder :=
rfl
@[simp]
lemma toUnder_eq {A B : Type u} [CommRing A] [CommRing B]
[instA : Algebra R A] [instB : Algebra R B] (f : A →ₐ[R] B) : CommRingCat.toAlgHom f.toUnder =
(cast <| congr_arg₂ (fun instA instB => @AlgHom R A B _ _ _ instA instB)
(CommRingCat.mkUnder_eq A).symm (CommRingCat.mkUnder_eq B).symm) f :=
have [instA : Algebra R A] [instB : Algebra R B] [instA' : Algebra R A] [instB' : Algebra R B]
(eqA : instA = instA') (eqB : instB = instB') (f : @AlgHom R A B _ _ _ instA instB) :
@OneHom.toFun A B _ _ f = @OneHom.toFun A B _ _ (
(cast <| congr_arg₂ (fun instA instB => @AlgHom R A B _ _ _ instA instB) eqA eqB) f
) := by
subst eqA eqB
rfl
ext <| congrFun <| this (instA := instA) (instB := instB)
(instA' := CommRingCat.algebra (R.mkUnder A)) (instB' := CommRingCat.algebra (R.mkUnder B))
(CommRingCat.mkUnder_eq A).symm (CommRingCat.mkUnder_eq B).symm f
end AlgHom
namespace AlgEquiv
/-- Make an isomorphism in `Under R` from an algebra isomorphism. -/
def toUnder {A B : Type u} [CommRing A] [CommRing B] [Algebra R A] [Algebra R B]
(f : A ≃ₐ[R] B) :
CommRingCat.mkUnder R A ≅ CommRingCat.mkUnder R B where
hom := f.toAlgHom.toUnder
inv := f.symm.toAlgHom.toUnder
hom_inv_id := by
ext (a : (CommRingCat.mkUnder R A).right)
simp
inv_hom_id := by
ext a
simp
@[simp]
lemma toUnder_hom_right_apply {A B : Type u} [CommRing A] [CommRing B] [Algebra R A]
[Algebra R B] (f : A ≃ₐ[R] B) (a : A) :
f.toUnder.hom.right a = f a := rfl
@[simp]
lemma toUnder_inv_right_apply {A B : Type u} [CommRing A] [CommRing B] [Algebra R A]
[Algebra R B] (f : A ≃ₐ[R] B) (b : B) :
f.toUnder.inv.right b = f.symm b := rfl
@[simp]
lemma toUnder_trans {A B C : Type u} [CommRing A] [CommRing B] [CommRing C]
[Algebra R A] [Algebra R B] [Algebra R C] (f : A ≃ₐ[R] B) (g : B ≃ₐ[R] C) :
(f.trans g).toUnder = f.toUnder ≪≫ g.toUnder :=
rfl
end AlgEquiv
namespace CommRingCat
variable [Algebra R S]
variable (R S) in
/-- The base change functor `A ↦ S ⊗[R] A`. -/
@[simps! map_right]
def tensorProd : Under R ⥤ Under S where
obj A := mkUnder S (S ⊗[R] A)
map f := Algebra.TensorProduct.map (AlgHom.id S S) (toAlgHom f) |>.toUnder
map_comp {X Y Z} f g := by simp [Algebra.TensorProduct.map_id_comp]
variable (S) in
/-- The natural isomorphism `S ⊗[R] A ≅ pushout A.hom (algebraMap R S)` in `Under S`. -/
def tensorProdObjIsoPushoutObj (A : Under R) :
mkUnder S (S ⊗[R] A) ≅ (Under.pushout (ofHom <| algebraMap R S)).obj A :=
Under.isoMk (CommRingCat.isPushout_tensorProduct R S A).flip.isoPushout <| by
simp only [Functor.const_obj_obj, Under.pushout_obj, Functor.id_obj, Under.mk_right,
mkUnder_hom, AlgHom.toRingHom_eq_coe, IsPushout.inr_isoPushout_hom, Under.mk_hom]
rfl
@[reassoc (attr := simp)]
lemma pushout_inl_tensorProdObjIsoPushoutObj_inv_right (A : Under R) :
pushout.inl A.hom (ofHom <| algebraMap R S) ≫ (tensorProdObjIsoPushoutObj S A).inv.right =
(ofHom <| Algebra.TensorProduct.includeRight.toRingHom) := by
simp [tensorProdObjIsoPushoutObj]
@[reassoc (attr := simp)]
lemma pushout_inr_tensorProdObjIsoPushoutObj_inv_right (A : Under R) :
pushout.inr A.hom (ofHom <| algebraMap R S) ≫
(tensorProdObjIsoPushoutObj S A).inv.right =
(CommRingCat.ofHom <| Algebra.TensorProduct.includeLeftRingHom) := by
simp [tensorProdObjIsoPushoutObj]
variable (R S) in
/-- `A ↦ S ⊗[R] A` is naturally isomorphic to `A ↦ pushout A.hom (algebraMap R S)`. -/
def tensorProdIsoPushout : tensorProd R S ≅ Under.pushout (ofHom <| algebraMap R S) :=
NatIso.ofComponents (fun A ↦ tensorProdObjIsoPushoutObj S A) <| by
intro A B f
dsimp
rw [← cancel_epi (tensorProdObjIsoPushoutObj S A).inv]
ext : 1
apply pushout.hom_ext
· rw [← cancel_mono (tensorProdObjIsoPushoutObj S B).inv.right]
ext x
simp [mkUnder_right]
· rw [← cancel_mono (tensorProdObjIsoPushoutObj S B).inv.right]
ext (x : S)
simp [mkUnder_right]
@[simp]
lemma tensorProdIsoPushout_app (A : Under R) :
(tensorProdIsoPushout R S).app A = tensorProdObjIsoPushoutObj S A :=
rfl
end CommRingCat