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

Commit d074b51

Browse files
rwbartonjohoelzl
authored andcommitted
refactor(category_theory/concrete_category): move bundled to own file
1 parent 50398e5 commit d074b51

File tree

8 files changed

+99
-69
lines changed

8 files changed

+99
-69
lines changed

src/category_theory/category.lean

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -80,49 +80,6 @@ A `small_category` has objects and morphisms in the same universe level.
8080
-/
8181
abbreviation small_category (C : Type u) : Type (u+1) := category.{u} C
8282

83-
structure bundled (c : Type u → Type v) :=
84-
(α : Type u)
85-
(str : c α)
86-
87-
instance (c : Type u → Type v) : has_coe_to_sort (bundled c) :=
88-
{ S := Type u, coe := bundled.α }
89-
90-
def mk_ob {c : Type u → Type v} (α : Type u) [str : c α] : bundled c :=
91-
@bundled.mk c α str
92-
93-
/-- `concrete_category hom` collects the evidence that a type constructor `c` and a morphism
94-
predicate `hom` can be thought of as a concrete category.
95-
In a typical example, `c` is the type class `topological_space` and `hom` is `continuous`. -/
96-
structure concrete_category {c : Type u → Type v}
97-
(hom : out_param $ ∀{α β : Type u}, c α → c β → (α → β) → Prop) :=
98-
(hom_id : ∀{α} (ia : c α), hom ia ia id)
99-
(hom_comp : ∀{α β γ} (ia : c α) (ib : c β) (ic : c γ) {f g},
100-
hom ia ib f → hom ib ic g → hom ia ic (g ∘ f))
101-
attribute [class] concrete_category
102-
103-
section
104-
variables {c : Type u → Type v} (hom : ∀{α β : Type u}, c α → c β → (α → β) → Prop)
105-
variables [h : concrete_category @hom]
106-
include h
107-
108-
instance : category (bundled c) :=
109-
{ hom := λa b, subtype (hom a.2 b.2),
110-
id := λa, ⟨@id a.1, h.hom_id a.2⟩,
111-
comp := λa b c f g, ⟨g.1 ∘ f.1, h.hom_comp a.2 b.2 c.2 f.2 g.2⟩ }
112-
113-
@[simp] lemma concrete_category_id (X : bundled c) : subtype.val (𝟙 X) = id := rfl
114-
@[simp] lemma concrete_category_comp {X Y Z : bundled c} (f : X ⟶ Y) (g : Y ⟶ Z) :
115-
subtype.val (f ≫ g) = g.val ∘ f.val := rfl
116-
117-
instance {X Y : bundled c} : has_coe_to_fun (X ⟶ Y) :=
118-
{ F := λ f, X → Y,
119-
coe := λ f, f.1 }
120-
121-
@[simp] lemma bundled_hom_coe {X Y : bundled c} (val : X → Y) (prop) (x : X) :
122-
(⟨val, prop⟩ : X ⟶ Y) x = val x := rfl
123-
124-
end
125-
12683
section
12784
variables {C : Type u} [𝒞 : category.{v} C] {X Y Z : C}
12885
include 𝒞
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/-
2+
Copyright (c) 2018 Scott Morrison. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Scott Morrison, Johannes Hölzl, Reid Barton, Sean Leather
5+
6+
Bundled type and structure.
7+
-/
8+
import category_theory.functor
9+
import category_theory.types
10+
11+
universes u v
12+
13+
namespace category_theory
14+
variables {c d : Type u → Type v} {α : Type u}
15+
16+
/--
17+
`concrete_category @hom` collects the evidence that a type constructor `c` and a
18+
morphism predicate `hom` can be thought of as a concrete category.
19+
20+
In a typical example, `c` is the type class `topological_space` and `hom` is
21+
`continuous`.
22+
-/
23+
structure concrete_category (hom : out_param $ ∀ {α β}, c α → c β → (α → β) → Prop) :=
24+
(hom_id : ∀ {α} (ia : c α), hom ia ia id)
25+
(hom_comp : ∀ {α β γ} (ia : c α) (ib : c β) (ic : c γ) {f g}, hom ia ib f → hom ib ic g → hom ia ic (g ∘ f))
26+
27+
attribute [class] concrete_category
28+
29+
/-- `bundled` is a type bundled with a type class instance for that type. Only
30+
the type class is exposed as a parameter. -/
31+
structure bundled (c : Type u → Type v) : Type (max (u+1) v) :=
32+
(α : Type u)
33+
(str : c α)
34+
35+
def mk_ob {c : Type u → Type v} (α : Type u) [str : c α] : bundled c := ⟨α, str⟩
36+
37+
namespace bundled
38+
39+
instance : has_coe_to_sort (bundled c) :=
40+
{ S := Type u, coe := bundled.α }
41+
42+
/-- Map over the bundled structure -/
43+
def map (f : ∀ {α}, c α → d α) (b : bundled c) : bundled d :=
44+
⟨b.α, f b.str⟩
45+
46+
section concrete_category
47+
variables (hom : ∀ {α β : Type u}, c α → c β → (α → β) → Prop)
48+
variables [h : concrete_category @hom]
49+
include h
50+
51+
instance : category (bundled c) :=
52+
{ hom := λ a b, subtype (hom a.2 b.2),
53+
id := λ a, ⟨@id a.1, h.hom_id a.2⟩,
54+
comp := λ a b c f g, ⟨g.1 ∘ f.1, h.hom_comp a.2 b.2 c.2 f.2 g.2⟩ }
55+
56+
variables {X Y Z : bundled c}
57+
58+
@[simp] lemma concrete_category_id (X : bundled c) : subtype.val (𝟙 X) = id :=
59+
rfl
60+
61+
@[simp] lemma concrete_category_comp (f : X ⟶ Y) (g : Y ⟶ Z) :
62+
subtype.val (f ≫ g) = g.val ∘ f.val :=
63+
rfl
64+
65+
instance : has_coe_to_fun (X ⟶ Y) :=
66+
{ F := λ f, X → Y,
67+
coe := λ f, f.1 }
68+
69+
@[simp] lemma bundled_hom_coe {X Y : bundled c} (val : X → Y) (prop) (x : X) :
70+
(⟨val, prop⟩ : X ⟶ Y) x = val x := rfl
71+
72+
end concrete_category
73+
74+
end bundled
75+
76+
def concrete_functor
77+
{C : Type u → Type v} {hC : ∀{α β}, C α → C β → (α → β) → Prop} [concrete_category @hC]
78+
{D : Type u → Type v} {hD : ∀{α β}, D α → D β → (α → β) → Prop} [concrete_category @hD]
79+
(m : ∀{α}, C α → D α) (h : ∀{α β} {ia : C α} {ib : C β} {f}, hC ia ib f → hD (m ia) (m ib) f) :
80+
bundled C ⥤ bundled D :=
81+
{ obj := bundled.map @m,
82+
map := λ X Y f, ⟨ f, h f.2 ⟩}
83+
84+
section forget
85+
variables {C : Type u → Type v} {hom : ∀α β, C α → C β → (α → β) → Prop} [i : concrete_category hom]
86+
include i
87+
88+
/-- The forgetful functor from a bundled category to `Type`. -/
89+
def forget : bundled C ⥤ Type u := { obj := bundled.α, map := λa b h, h.1 }
90+
91+
instance forget.faithful : faithful (forget : bundled C ⥤ Type u) := {}
92+
93+
end forget
94+
95+
end category_theory

src/category_theory/examples/measurable_space.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Basic setup for measurable spaces.
66
-/
77

88
import category_theory.examples.topological_spaces
9-
import category_theory.types
109
import measure_theory.borel_space
1110

1211
open category_theory

src/category_theory/examples/monoids.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Introduce Mon -- the category of monoids.
77
Currently only the basic setup.
88
-/
99

10+
import category_theory.concrete_category
1011
import category_theory.fully_faithful
11-
import category_theory.types
1212
import category_theory.adjunction
1313
import data.finsupp
1414

src/category_theory/examples/rings.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Introduce CommRing -- the category of commutative rings.
77
Currently only the basic setup.
88
-/
99

10+
import category_theory.concrete_category
1011
import category_theory.examples.monoids
1112
import category_theory.fully_faithful
1213
import category_theory.adjunction

src/category_theory/examples/topological_spaces.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-- Released under Apache 2.0 license as described in the file LICENSE.
33
-- Authors: Patrick Massot, Scott Morrison, Mario Carneiro
44

5+
import category_theory.concrete_category
56
import category_theory.full_subcategory
67
import category_theory.functor_category
78
import category_theory.adjunction
@@ -135,4 +136,4 @@ nat_iso.of_components (λ U, eq_to_iso (congr_fun (congr_arg _ (congr_arg _ h))
135136

136137
@[simp] def map_iso_id {X : Top.{u}} (h) : map_iso (𝟙 X) (𝟙 X) h = iso.refl (map _) := rfl
137138

138-
end topological_space.opens
139+
end topological_space.opens

src/category_theory/functor.lean

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,4 @@ end
9797

9898
end functor
9999

100-
def bundled.map {c : Type u → Type v} {d : Type u → Type v} (f : Π{a}, c a → d a) (s : bundled c) :
101-
bundled d :=
102-
{ α := s.α, str := f s.str }
103-
104-
def concrete_functor
105-
{C : Type u → Type v} {hC : ∀{α β}, C α → C β → (α → β) → Prop} [concrete_category @hC]
106-
{D : Type u → Type v} {hD : ∀{α β}, D α → D β → (α → β) → Prop} [concrete_category @hD]
107-
(m : ∀{α}, C α → D α) (h : ∀{α β} {ia : C α} {ib : C β} {f}, hC ia ib f → hD (m ia) (m ib) f) :
108-
bundled C ⥤ bundled D :=
109-
{ obj := bundled.map @m,
110-
map := λ X Y f, ⟨ f, h f.2 ⟩}
111-
112100
end category_theory

src/category_theory/types.lean

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,4 @@ instance ulift_functor_faithful : fully_faithful ulift_functor :=
5454
injectivity' := λ X Y f g p, funext $ λ x,
5555
congr_arg ulift.down ((congr_fun p (ulift.up x)) : ((ulift.up (f x)) = (ulift.up (g x)))) }
5656

57-
section forget
58-
variables {C : Type u → Type v} {hom : ∀α β, C α → C β → (α → β) → Prop} [i : concrete_category hom]
59-
include i
60-
61-
/-- The forgetful functor from a bundled category to `Type`. -/
62-
def forget : bundled C ⥤ Type u := { obj := bundled.α, map := λa b h, h.1 }
63-
64-
instance forget.faithful : faithful (forget : bundled C ⥤ Type u) := {}
65-
66-
end forget
67-
6857
end category_theory

0 commit comments

Comments
 (0)