Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 2db435d

Browse files
kim-emmergify[bot]
authored andcommitted
chore(category_theory): move all instances (e.g. Top, CommRing, Meas) into the root namespace (#1074)
* splitting adjunction.lean * chore(CommRing/adjunctions): refactor proofs * remove unnecessary assumptions * add helpful doc-string * cleanup * chore(category_theory): move all instances (e.g. Top, CommRing, Meas) to the root namespace * minor * breaking things, haven't finished yet * deterministic timeout * unfold_coes to the rescue * one more int.cast * yet another int.cast * fix merge * minor * merge * fix imports * fix merge * fix imports/namespaces * more namespace fixes * fixes * delete stray file
1 parent c49ac06 commit 2db435d

28 files changed

+162
-175
lines changed

docs/tutorial/category_theory/calculating_colimits_in_Top.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import category_theory.instances.Top.limits
1+
import topology.Top.limits
22
import category_theory.limits.shapes
33
import topology.instances.real
44

@@ -7,7 +7,6 @@ import topology.instances.real
77
noncomputable theory
88

99
open category_theory
10-
open category_theory.instances
1110
open category_theory.limits
1211

1312
def R : Top := Top.of ℝ

src/category_theory/instances/CommRing/adjunctions.lean renamed to src/algebra/CommRing/adjunctions.lean

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ Multivariable polynomials on a type is the left adjoint of the
66
forgetful functor from commutative rings to types.
77
-/
88

9-
import category_theory.instances.CommRing.basic
9+
import algebra.CommRing.basic
1010
import category_theory.adjunction.basic
1111
import data.mv_polynomial
1212

1313
universe u
1414

1515
open mv_polynomial
1616
open category_theory
17-
open category_theory.instances
1817

19-
namespace category_theory.instances.CommRing
18+
namespace CommRing
2019

2120
local attribute [instance, priority 0] classical.prop_decidable
2221

2322
noncomputable def polynomial_ring : Type u ⥤ CommRing.{u} :=
24-
{ obj := λ α, ⟨mv_polynomial α ℤ, by apply_instance⟩,
23+
{ obj := λ α, ⟨mv_polynomial α ℤ⟩,
2524
map := λ α β f, ⟨rename f, by apply_instance⟩ }
2625

2726
@[simp] lemma polynomial_ring_obj_α {α : Type u} :
@@ -30,15 +29,14 @@ noncomputable def polynomial_ring : Type u ⥤ CommRing.{u} :=
3029
@[simp] lemma polynomial_ring_map_val {α β : Type u} {f : α → β} :
3130
(polynomial_ring.map f).val = rename f := rfl
3231

33-
noncomputable def adj : polynomial_ring ⊣ (forget : CommRing.{u}Type u) :=
32+
noncomputable def adj : polynomial_ring ⊣ (forget : CommRing ⥤ Type u) :=
3433
adjunction.mk_of_hom_equiv
3534
{ hom_equiv := λ α R,
3635
{ to_fun := λ f, f ∘ X,
3736
inv_fun := λ f, ⟨eval₂ (λ n : ℤ, (n : R)) f, by { unfold_coes, apply_instance }⟩,
38-
left_inv := λ f, CommRing.hom.ext $ @eval₂_hom_X _ _ _ _ _ _ f _,
37+
left_inv := λ f, bundled.hom_ext (@eval₂_hom_X _ _ _ _ _ _ f.val _),
3938
right_inv := λ x, by { ext1, unfold_coes, simp only [function.comp_app, eval₂_X] } },
4039
hom_equiv_naturality_left_symm' :=
41-
λ X X' Y f g, by { ext1, dsimp, apply eval₂_cast_comp }
42-
}.
40+
λ X X' Y f g, by { ext1, dsimp, apply eval₂_cast_comp } }.
4341

44-
end category_theory.instances.CommRing
42+
end CommRing

src/category_theory/instances/CommRing/basic.lean renamed to src/algebra/CommRing/basic.lean

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Scott Morrison, Johannes Hölzl
55
Introduce CommRing -- the category of commutative rings.
66
-/
77

8-
import category_theory.instances.Mon.basic
8+
import algebra.Mon.basic
99
import category_theory.fully_faithful
1010
import algebra.ring
1111
import data.int.basic
@@ -14,85 +14,78 @@ universes u v
1414

1515
open category_theory
1616

17-
namespace category_theory.instances
18-
1917
/-- The category of rings. -/
2018
@[reducible] def Ring : Type (u+1) := bundled ring
2119

20+
/-- The category of commutative rings. -/
21+
@[reducible] def CommRing : Type (u+1) := bundled comm_ring
22+
23+
namespace Ring
24+
2225
instance (x : Ring) : ring x := x.str
2326

2427
instance concrete_is_ring_hom : concrete_category @is_ring_hom :=
2528
by introsI α ia; apply_instance,
2629
by introsI α β γ ia ib ic f g hf hg; apply_instance⟩
2730

28-
instance Ring.hom_is_ring_hom {R S : Ring} (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2
31+
def of : Type u) [ring α] : Ring := ⟨α⟩
2932

30-
/-- The category of commutative rings. -/
31-
@[reducible] def CommRing : Type (u+1) := bundled comm_ring
33+
abbreviation forget : Ring.{u} ⥤ Type u := forget
3234

33-
instance (x : CommRing) : comm_ring x := x.str
35+
instance hom_is_ring_hom {R S : Ring} (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2
3436

35-
-- Here we don't use the `concrete` machinery,
36-
-- because it would require introducing a useless synonym for `is_ring_hom`.
37-
instance : category CommRing :=
38-
{ hom := λ R S, { f : R → S // is_ring_hom f },
39-
id := λ R, ⟨ id, by resetI; apply_instance ⟩,
40-
comp := λ R S T g h, ⟨ h.1 ∘ g.1, begin haveI := g.2, haveI := h.2, apply_instance end ⟩ }
37+
end Ring
4138

4239
namespace CommRing
43-
variables {R S T : CommRing.{u}}
4440

45-
def of : Type u) [comm_ring α] : CommRing := ⟨α, by apply_instance⟩
41+
instance (x : CommRing) : comm_ring x := x.str
4642

47-
@[simp] lemma id_val : subtype.val (𝟙 R) = id := rfl
48-
@[simp] lemma comp_val (f : R ⟶ S) (g : S ⟶ T) :
49-
(f ≫ g).val = g.val ∘ f.val := rfl
43+
@[reducible] def is_comm_ring_hom {α β} [comm_ring α] [comm_ring β] (f : α → β) : Prop :=
44+
is_ring_hom f
5045

51-
instance hom_coe : has_coe_to_fun (R ⟶ S) :=
52-
{ F := λ f, R → S,
53-
coe := λ f, f.1 }
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⟩
5449

55-
@[extensionality] lemma hom.ext {f g : R ⟶ S} : (∀ x : R, f x = g x) → f = g :=
56-
λ w, subtype.ext.2 $ funext w
50+
def of (α : Type u) [comm_ring α] : CommRing := ⟨α⟩
5751

58-
@[simp] lemma hom_coe_app (val : R → S) (prop) (r : R) : (⟨val, prop⟩ : R ⟶ S) r = val r := rfl
52+
abbreviation forget : CommRing.{u} ⥤ Type u := forget
5953

60-
instance hom_is_ring_hom (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2
54+
instance hom_is_ring_hom {R S : CommRing} (f : R ⟶ S) : is_ring_hom (f : R → S) := f.2
6155

62-
def Int : CommRing := ⟨ℤ, infer_instance⟩
56+
variables {R S T : CommRing.{u}}
6357

64-
def Int.cast {R : CommRing} : Int ⟶ R := { val := int.cast, property := by apply_instance }
58+
-- TODO need to kill these
59+
@[simp] lemma id_val : subtype.val (𝟙 R) = id := rfl
60+
@[simp] lemma comp_val (f : R ⟶ S) (g : S ⟶ T) :
61+
(f ≫ g).val = g.val ∘ f.val := rfl
62+
63+
-- TODO rename the next three lemmas?
64+
def Int.cast {R : CommRing} : CommRing.of ℤ ⟶ R := { val := int.cast, property := by apply_instance }
6565

66-
def Int.hom_unique {R : CommRing} : unique (Int ⟶ R) :=
66+
def Int.hom_unique {R : CommRing} : unique (CommRing.of ℤ ⟶ R) :=
6767
{ default := Int.cast,
6868
uniq := λ f, subtype.ext.mpr $ funext $ int.eq_cast f f.2.map_one f.2.map_add }
6969

70-
/-- The forgetful functor commutative rings to Type. -/
71-
def forget : CommRing.{u} ⥤ Type u :=
72-
{ obj := λ R, R,
73-
map := λ _ _ f, f }
74-
7570
instance forget.faithful : faithful (forget) := {}
7671

7772
instance forget_comm_ring (R : CommRing) : comm_ring (forget.obj R) := R.str
7873
instance forget_is_ring_hom {R S : CommRing} (f : R ⟶ S) : is_ring_hom (forget.map f) := f.property
7974

8075
/-- The functor from commutative rings to rings. -/
8176
def to_Ring : CommRing.{u} ⥤ Ring.{u} :=
82-
{ obj := λ X, { α := X.1, str := by apply_instance },
77+
{ obj := λ X, { α := X.1 },
8378
map := λ X Y f, ⟨ f, by apply_instance ⟩ }
8479

8580
instance to_Ring.faithful : faithful (to_Ring) := {}
8681

8782
/-- The forgetful functor from commutative rings to (multiplicative) commutative monoids. -/
8883
def forget_to_CommMon : CommRing.{u} ⥤ CommMon.{u} :=
89-
{ obj := λ X, { α := X.1, str := by apply_instance },
84+
{ obj := λ X, { α := X.1 },
9085
map := λ X Y f, ⟨ f, by apply_instance ⟩ }
9186

9287
instance forget_to_CommMon.faithful : faithful (forget_to_CommMon) := {}
9388

9489
example : faithful (forget_to_CommMon ⋙ CommMon.forget_to_Mon) := by apply_instance
9590

9691
end CommRing
97-
98-
end category_theory.instances

src/category_theory/instances/CommRing/colimits.lean renamed to src/algebra/CommRing/colimits.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import category_theory.instances.CommRing.basic
1+
-- Copyright (c) 2019 Scott Morrison. All rights reserved.
2+
-- Released under Apache 2.0 license as described in the file LICENSE.
3+
-- Authors: Scott Morrison
4+
import algebra.CommRing.basic
25
import category_theory.limits.limits
36

47
universes u v
58

69
open category_theory
7-
open category_theory.instances
810
open category_theory.limits
911

1012
-- [ROBOT VOICE]:
@@ -34,7 +36,7 @@ comm_ring.left_distrib : ∀ {α : Type u} [c : comm_ring α] (a b c_1 : α), a
3436
comm_ring.right_distrib : ∀ {α : Type u} [c : comm_ring α] (a b c_1 : α), (a + b) * c_1 = a * c_1 + b * c_1
3537
-/
3638

37-
namespace category_theory.instances.CommRing.colimits
39+
namespace CommRing.colimits
3840

3941
variables {J : Type v} [small_category J] (F : J ⥤ CommRing.{v})
4042

@@ -430,4 +432,4 @@ instance has_colimits_CommRing : @has_colimits CommRing.{v} infer_instance :=
430432
{ cocone := colimit_cocone F,
431433
is_colimit := colimit_is_colimit F } } }
432434

433-
end category_theory.instances.CommRing.colimits
435+
end CommRing.colimits

src/category_theory/instances/CommRing/default.lean renamed to src/algebra/CommRing/default.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Scott Morrison
55
-/
66

7-
import category_theory.instances.CommRing.basic
8-
import category_theory.instances.CommRing.adjunctions
9-
import category_theory.instances.CommRing.colimits
7+
import algebra.CommRing.basic
8+
import algebra.CommRing.adjunctions
9+
import algebra.CommRing.colimits

src/category_theory/instances/CommRing/limits.lean renamed to src/algebra/CommRing/limits.lean

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22
-- Released under Apache 2.0 license as described in the file LICENSE.
33
-- Authors: Scott Morrison
44

5-
import category_theory.instances.CommRing.basic
5+
import algebra.CommRing.basic
66
import category_theory.limits.types
77
import category_theory.limits.preserves
88
import ring_theory.subring
99
import algebra.pi_instances
1010

1111
open category_theory
12-
open category_theory.instances
12+
open category_theory.limits
1313

1414
universe u
1515

16-
namespace category_theory.instances.CommRing
17-
18-
open category_theory.limits
16+
namespace CommRing
1917

2018
variables {J : Type u} [small_category J]
2119

22-
instance (F : J ⥤ CommRing.{u}) (j) : comm_ring ((F ⋙ CommRing.forget).obj j) :=
20+
instance comm_ring_obj (F : J ⥤ CommRing.{u}) (j) : comm_ring ((F ⋙ CommRing.forget).obj j) :=
2321
by { dsimp, apply_instance }
24-
instance (F : J ⥤ CommRing.{u}) (j j') (f : j ⟶ j') : is_ring_hom ((F ⋙ CommRing.forget).map f) :=
22+
instance is_ring_hom_map (F : J ⥤ CommRing.{u}) (j j') (f : j ⟶ j') : is_ring_hom ((F ⋙ CommRing.forget).map f) :=
2523
by { dsimp, apply_instance }
2624

2725
instance sections_submonoid (F : J ⥤ CommRing.{u}) : is_submonoid (F ⋙ forget).sections :=
@@ -112,4 +110,4 @@ instance forget_preserves_limits : preserves_limits (forget : CommRing.{u} ⥤ T
112110
by exactI preserves_limit_of_preserves_limit_cone
113111
(limit.is_limit F) (limit.is_limit (F ⋙ forget)) } }
114112

115-
end category_theory.instances.CommRing
113+
end CommRing

src/category_theory/instances/Mon/basic.lean renamed to src/algebra/Mon/basic.lean

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,29 @@ universes u v
1313

1414
open category_theory
1515

16-
namespace category_theory.instances
17-
1816
/-- The category of monoids and monoid morphisms. -/
1917
@[reducible] def Mon : Type (u+1) := bundled monoid
2018

19+
/-- The category of commutative monoids and monoid morphisms. -/
20+
@[reducible] def CommMon : Type (u+1) := bundled comm_monoid
21+
22+
namespace Mon
23+
2124
instance (x : Mon) : monoid x := x.str
2225

2326
instance concrete_is_monoid_hom : concrete_category @is_monoid_hom :=
2427
by introsI α ia; apply_instance,
2528
by introsI α β γ ia ib ic f g hf hg; apply_instance⟩
2629

27-
instance Mon_hom_is_monoid_hom {R S : Mon} (f : R ⟶ S) : is_monoid_hom (f : R → S) := f.2
30+
def of (X : Type u) [monoid X] : Mon := ⟨X⟩
2831

29-
/-- The category of commutative monoids and monoid morphisms. -/
30-
@[reducible] def CommMon : Type (u+1) := bundled comm_monoid
32+
abbreviation forget : Mon.{u} ⥤ Type u := forget
33+
34+
instance hom_is_monoid_hom {R S : Mon} (f : R ⟶ S) : is_monoid_hom (f : R → S) := f.2
35+
36+
end Mon
37+
38+
namespace CommMon
3139

3240
instance (x : CommMon) : comm_monoid x := x.str
3341

@@ -38,10 +46,13 @@ instance concrete_is_comm_monoid_hom : concrete_category @is_comm_monoid_hom :=
3846
by introsI α ia; apply_instance,
3947
by introsI α β γ ia ib ic f g hf hg; apply_instance⟩
4048

41-
instance CommMon_hom_is_comm_monoid_hom {R S : CommMon} (f : R ⟶ S) :
49+
def of (X : Type u) [comm_monoid X] : CommMon := ⟨X⟩
50+
51+
abbreviation forget : CommMon.{u} ⥤ Type u := forget
52+
53+
instance hom_is_comm_monoid_hom {R S : CommMon} (f : R ⟶ S) :
4254
is_comm_monoid_hom (f : R → S) := f.2
4355

44-
namespace CommMon
4556
/-- The forgetful functor from commutative monoids to monoids. -/
4657
def forget_to_Mon : CommMon ⥤ Mon :=
4758
concrete_functor
@@ -51,5 +62,3 @@ concrete_functor
5162
instance : faithful (forget_to_Mon) := {}
5263

5364
end CommMon
54-
55-
end category_theory.instances

src/category_theory/instances/Mon/colimits.lean renamed to src/algebra/Mon/colimits.lean

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import category_theory.instances.Mon.basic
1+
import algebra.Mon.basic
22
import category_theory.limits.limits
33

44
universes v
55

66
open category_theory
7-
open category_theory.instances
87
open category_theory.limits
98

109
/-
@@ -28,7 +27,7 @@ colimits of commutative rings.
2827
A slightly bolder claim is that we could do this with tactics, as well.
2928
-/
3029

31-
namespace category_theory.instances.Mon.colimits
30+
namespace Mon.colimits
3231

3332
variables {J : Type v} [small_category J] (F : J ⥤ Mon.{v})
3433

@@ -234,4 +233,4 @@ instance has_colimits_Mon : @has_colimits Mon.{v} infer_instance :=
234233
{ cocone := colimit_cocone F,
235234
is_colimit := colimit_is_colimit F } } }
236235

237-
end category_theory.instances.Mon.colimits
236+
end Mon.colimits

src/category_theory/instances/Mon/default.lean renamed to src/algebra/Mon/default.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Scott Morrison
55
-/
66

7-
import category_theory.instances.Mon.basic
8-
import category_theory.instances.Mon.colimits
7+
import algebra.Mon.basic
8+
import algebra.Mon.colimits

src/algebraic_geometry/presheafed_space.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
-- Copyright (c) 2019 Scott Morrison. All rights reserved.
22
-- Released under Apache 2.0 license as described in the file LICENSE.
33
-- Authors: Scott Morrison
4-
import category_theory.instances.Top.presheaf
4+
import topology.Top.presheaf
55

66
universes v u
77

88
open category_theory
9-
open category_theory.instances
10-
open category_theory.instances.Top
9+
open Top
1110
open topological_space
1211
open opposite
1312

src/algebraic_geometry/stalks.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
-- Released under Apache 2.0 license as described in the file LICENSE.
33
-- Authors: Scott Morrison
44
import algebraic_geometry.presheafed_space
5-
import category_theory.instances.Top.stalks
5+
import topology.Top.stalks
66

77
universes v u v' u'
88

99
open category_theory
10-
open category_theory.instances
1110
open category_theory.limits
1211
open algebraic_geometry
1312
open topological_space
@@ -17,7 +16,7 @@ include 𝒞
1716

1817
local attribute [tidy] tactic.op_induction'
1918

20-
open category_theory.instances.Top.presheaf
19+
open Top.presheaf
2120

2221
namespace algebraic_geometry.PresheafedSpace
2322

0 commit comments

Comments
 (0)