-
Notifications
You must be signed in to change notification settings - Fork 251
/
ChosenFiniteProducts.lean
192 lines (152 loc) · 6.21 KB
/
ChosenFiniteProducts.lean
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
/-
Copyright (c) 2024 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import Mathlib.CategoryTheory.Monoidal.OfChosenFiniteProducts.Symmetric
import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts
/-!
# Categories with chosen finite products
We introduce a class, `ChosenFiniteProducts`, which bundles explicit choices
for a terminal object and binary products in a category `C`.
This is primarily useful for categories which have finite products with good
definitional properties, such as the category of types.
Given a category with such an instance, we also provide the associated
symmetric monoidal structure so that one can write `X ⊗ Y` for the explicit
binary product and `𝟙_ C` for the explicit terminal object.
# Projects
- Construct an instance of chosen finite products in the category of affine scheme, using
the tensor product.
- Construct chosen finite products in other categories appearing "in nature".
-/
namespace CategoryTheory
universe v u
/--
An instance of `ChosenFiniteProducts C` bundles an explicit choice of a binary
product of two objects of `C`, and a terminal object in `C`.
Users should use the monoidal notation: `X ⊗ Y` for the product and `𝟙_ C` for
the terminal object.
-/
class ChosenFiniteProducts (C : Type u) [Category.{v} C] where
/-- A choice of a limit binary fan for any two objects of the category. -/
product : (X Y : C) → Limits.LimitCone (Limits.pair X Y)
/-- A choice of a terminal object. -/
terminal : Limits.LimitCone (Functor.empty.{0} C)
namespace ChosenFiniteProducts
instance (priority := 100) (C : Type u) [Category.{v} C] [ChosenFiniteProducts C] :
MonoidalCategory C :=
monoidalOfChosenFiniteProducts terminal product
instance (priority := 100) (C : Type u) [Category.{v} C] [ChosenFiniteProducts C] :
SymmetricCategory C :=
symmetricOfChosenFiniteProducts _ _
variable {C : Type u} [Category.{v} C] [ChosenFiniteProducts C]
open MonoidalCategory
/--
The unique map to the terminal object.
-/
def toUnit (X : C) : X ⟶ 𝟙_ C :=
terminal.isLimit.lift <| .mk _ <| .mk (fun x => x.as.elim) fun x => x.as.elim
instance (X : C) : Unique (X ⟶ 𝟙_ C) where
default := toUnit _
uniq _ := terminal.isLimit.hom_ext fun ⟨j⟩ => j.elim
/--
This lemma follows from the preexisting `Unique` instance, but
it is often convenient to use it directly as `apply toUnit_unique` forcing
lean to do the necessary elaboration.
-/
lemma toUnit_unique {X : C} (f g : X ⟶ 𝟙_ _) : f = g :=
Subsingleton.elim _ _
/--
Construct a morphism to the product given its two components.
-/
def lift {T X Y : C} (f : T ⟶ X) (g : T ⟶ Y) : T ⟶ X ⊗ Y :=
(product X Y).isLimit.lift <| Limits.BinaryFan.mk f g
/--
The first projection from the product.
-/
def fst (X Y : C) : X ⊗ Y ⟶ X :=
letI F : Limits.BinaryFan X Y := (product X Y).cone
F.fst
/--
The second projection from the product.
-/
def snd (X Y : C) : X ⊗ Y ⟶ Y :=
letI F : Limits.BinaryFan X Y := (product X Y).cone
F.snd
@[reassoc (attr := simp)]
lemma lift_fst {T X Y : C} (f : T ⟶ X) (g : T ⟶ Y) : lift f g ≫ fst _ _ = f := by
simp [lift, fst]
@[reassoc (attr := simp)]
lemma lift_snd {T X Y : C} (f : T ⟶ X) (g : T ⟶ Y) : lift f g ≫ snd _ _ = g := by
simp [lift, snd]
@[ext 1050]
lemma hom_ext {T X Y : C} (f g : T ⟶ X ⊗ Y)
(h_fst : f ≫ fst _ _ = g ≫ fst _ _)
(h_snd : f ≫ snd _ _ = g ≫ snd _ _) :
f = g :=
(product X Y).isLimit.hom_ext fun ⟨j⟩ => j.recOn h_fst h_snd
@[reassoc (attr := simp)]
lemma tensorHom_fst {X₁ X₂ Y₁ Y₂ : C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂) :
(f ⊗ g) ≫ fst _ _ = fst _ _ ≫ f := lift_fst _ _
@[reassoc (attr := simp)]
lemma tensorHom_snd {X₁ X₂ Y₁ Y₂ : C} (f : X₁ ⟶ X₂) (g : Y₁ ⟶ Y₂) :
(f ⊗ g) ≫ snd _ _ = snd _ _ ≫ g := lift_snd _ _
@[reassoc (attr := simp)]
lemma whiskerLeft_fst (X : C) {Y₁ Y₂ : C} (g : Y₁ ⟶ Y₂) :
(X ◁ g) ≫ fst _ _ = fst _ _ :=
(tensorHom_fst _ _).trans (by simp)
@[reassoc (attr := simp)]
lemma whiskerLeft_snd (X : C) {Y₁ Y₂ : C} (g : Y₁ ⟶ Y₂) :
(X ◁ g) ≫ snd _ _ = snd _ _ ≫ g :=
tensorHom_snd _ _
@[reassoc (attr := simp)]
lemma whiskerRight_fst {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) :
(f ▷ Y) ≫ fst _ _ = fst _ _ ≫ f :=
tensorHom_fst _ _
@[reassoc (attr := simp)]
lemma whiskerRight_snd {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) :
(f ▷ Y) ≫ snd _ _ = snd _ _ :=
(tensorHom_snd _ _).trans (by simp)
@[reassoc (attr := simp)]
lemma associator_hom_fst (X Y Z : C) :
(α_ X Y Z).hom ≫ fst _ _ = fst _ _ ≫ fst _ _ := lift_fst _ _
@[reassoc (attr := simp)]
lemma associator_hom_snd_fst (X Y Z : C) :
(α_ X Y Z).hom ≫ snd _ _ ≫ fst _ _ = fst _ _ ≫ snd _ _ := by
erw [lift_snd_assoc, lift_fst]
rfl
@[reassoc (attr := simp)]
lemma associator_hom_snd_snd (X Y Z : C) :
(α_ X Y Z).hom ≫ snd _ _ ≫ snd _ _ = snd _ _ := by
erw [lift_snd_assoc, lift_snd]
rfl
@[reassoc (attr := simp)]
lemma associator_inv_fst (X Y Z : C) :
(α_ X Y Z).inv ≫ fst _ _ ≫ fst _ _ = fst _ _ := by
erw [lift_fst_assoc, lift_fst]
rfl
@[reassoc (attr := simp)]
lemma associator_inv_fst_snd (X Y Z : C) :
(α_ X Y Z).inv ≫ fst _ _ ≫ snd _ _ = snd _ _ ≫ fst _ _ := by
erw [lift_fst_assoc, lift_snd]
rfl
@[reassoc (attr := simp)]
lemma associator_inv_snd (X Y Z : C) :
(α_ X Y Z).inv ≫ snd _ _ = snd _ _ ≫ snd _ _ := lift_snd _ _
/--
Construct an instance of `ChosenFiniteProducts C` given an instance of `HasFiniteProducts C`.
-/
noncomputable
def ofFiniteProducts
(C : Type u) [Category.{v} C] [Limits.HasFiniteProducts C] :
ChosenFiniteProducts C where
product X Y := Limits.getLimitCone (Limits.pair X Y)
terminal := Limits.getLimitCone (Functor.empty C)
instance (priority := 100) : Limits.HasFiniteProducts C :=
letI : ∀ (X Y : C), Limits.HasLimit (Limits.pair X Y) := fun _ _ =>
.mk <| ChosenFiniteProducts.product _ _
letI : Limits.HasBinaryProducts C := Limits.hasBinaryProducts_of_hasLimit_pair _
letI : Limits.HasTerminal C := Limits.hasTerminal_of_unique (𝟙_ _)
hasFiniteProducts_of_has_binary_and_terminal
end ChosenFiniteProducts
end CategoryTheory