|
1 | | - |
2 | 1 | -- The category of elements of a functor to Set |
| 2 | +module Cubical.Categories.Constructions.Elements where |
3 | 3 |
|
| 4 | +open import Cubical.Foundations.Prelude |
4 | 5 | open import Cubical.Foundations.Equiv |
5 | 6 | open import Cubical.Foundations.Isomorphism |
6 | | -open import Cubical.Foundations.Function |
7 | 7 | open import Cubical.Foundations.HLevels |
8 | | -open import Cubical.Foundations.Path |
9 | | -open import Cubical.Foundations.Prelude |
10 | 8 |
|
11 | 9 | open import Cubical.Data.Sigma |
12 | 10 |
|
13 | 11 | open import Cubical.Categories.Category |
14 | | -import Cubical.Categories.Constructions.Slice.Base as Slice |
15 | 12 | open import Cubical.Categories.Functor |
16 | 13 | open import Cubical.Categories.Instances.Sets |
17 | 14 | open import Cubical.Categories.Isomorphism |
18 | | -import Cubical.Categories.Morphism as Morphism |
19 | | - |
20 | 15 |
|
21 | | -module Cubical.Categories.Constructions.Elements where |
22 | | - |
23 | | --- some issues |
24 | | --- * always need to specify objects during composition because can't infer isSet |
25 | 16 | open Category |
26 | 17 | open Functor |
27 | 18 |
|
28 | 19 | module Covariant {ℓ ℓ'} {C : Category ℓ ℓ'} where |
| 20 | + |
| 21 | + open Category C |
| 22 | + |
| 23 | + private |
29 | 24 | getIsSet : ∀ {ℓS} (F : Functor C (SET ℓS)) → (c : C .ob) → isSet (fst (F ⟅ c ⟆)) |
30 | 25 | getIsSet F c = snd (F ⟅ c ⟆) |
31 | 26 |
|
32 | | - Element : ∀ {ℓS} (F : Functor C (SET ℓS)) → Type (ℓ-max ℓ ℓS) |
33 | | - Element F = Σ[ c ∈ C .ob ] fst (F ⟅ c ⟆) |
34 | | - |
35 | | - infix 50 ∫_ |
36 | | - ∫_ : ∀ {ℓS} → Functor C (SET ℓS) → Category (ℓ-max ℓ ℓS) (ℓ-max ℓ' ℓS) |
37 | | - -- objects are (c , x) pairs where c ∈ C and x ∈ F c |
38 | | - (∫ F) .ob = Element F |
39 | | - -- morphisms are f : c → c' which take x to x' |
40 | | - (∫ F) .Hom[_,_] (c , x) (c' , x') = fiber (λ (f : C [ c , c' ]) → (F ⟪ f ⟫) x) x' |
41 | | - (∫ F) .id {x = (c , x)} = C .id , funExt⁻ (F .F-id) x |
42 | | - (∫ F) ._⋆_ {c , x} {c₁ , x₁} {c₂ , x₂} (f , p) (g , q) |
43 | | - = (f ⋆⟨ C ⟩ g) , ((F ⟪ f ⋆⟨ C ⟩ g ⟫) x |
44 | | - ≡⟨ funExt⁻ (F .F-seq _ _) _ ⟩ |
45 | | - (F ⟪ g ⟫) ((F ⟪ f ⟫) x) |
46 | | - ≡⟨ cong (F ⟪ g ⟫) p ⟩ |
47 | | - (F ⟪ g ⟫) x₁ |
48 | | - ≡⟨ q ⟩ |
49 | | - x₂ |
50 | | - ∎) |
51 | | - (∫ F) .⋆IdL o@{c , x} o1@{c' , x'} f'@(f , p) i |
52 | | - = (cIdL i) , isOfHLevel→isOfHLevelDep 1 (λ a → isS' ((F ⟪ a ⟫) x) x') p' p cIdL i |
53 | | - where |
54 | | - isS = getIsSet F c |
55 | | - isS' = getIsSet F c' |
56 | | - cIdL = C .⋆IdL f |
57 | | - |
58 | | - -- proof from composition with id |
59 | | - p' : (F ⟪ C .id ⋆⟨ C ⟩ f ⟫) x ≡ x' |
60 | | - p' = snd ((∫ F) ._⋆_ ((∫ F) .id) f') |
61 | | - (∫ F) .⋆IdR o@{c , x} o1@{c' , x'} f'@(f , p) i |
62 | | - = (cIdR i) , isOfHLevel→isOfHLevelDep 1 (λ a → isS' ((F ⟪ a ⟫) x) x') p' p cIdR i |
63 | | - where |
64 | | - cIdR = C .⋆IdR f |
65 | | - isS' = getIsSet F c' |
66 | | - |
67 | | - p' : (F ⟪ f ⋆⟨ C ⟩ C .id ⟫) x ≡ x' |
68 | | - p' = snd ((∫ F) ._⋆_ f' ((∫ F) .id)) |
69 | | - (∫ F) .⋆Assoc o@{c , x} o1@{c₁ , x₁} o2@{c₂ , x₂} o3@{c₃ , x₃} f'@(f , p) g'@(g , q) h'@(h , r) i |
70 | | - = (cAssoc i) , isOfHLevel→isOfHLevelDep 1 (λ a → isS₃ ((F ⟪ a ⟫) x) x₃) p1 p2 cAssoc i |
71 | | - where |
72 | | - cAssoc = C .⋆Assoc f g h |
73 | | - isS₃ = getIsSet F c₃ |
74 | | - |
75 | | - p1 : (F ⟪ (f ⋆⟨ C ⟩ g) ⋆⟨ C ⟩ h ⟫) x ≡ x₃ |
76 | | - p1 = snd ((∫ F) ._⋆_ ((∫ F) ._⋆_ {o} {o1} {o2} f' g') h') |
77 | | - |
78 | | - p2 : (F ⟪ f ⋆⟨ C ⟩ (g ⋆⟨ C ⟩ h) ⟫) x ≡ x₃ |
79 | | - p2 = snd ((∫ F) ._⋆_ f' ((∫ F) ._⋆_ {o1} {o2} {o3} g' h')) |
80 | | - (∫ F) .isSetHom {x} {y} = isSetΣSndProp (C .isSetHom) λ _ → (F ⟅ fst y ⟆) .snd _ _ |
81 | | - |
82 | | - ElementHom≡ : ∀ {ℓS} (F : Functor C (SET ℓS)) → {c,f c',f' : Element F} |
83 | | - → {χ1,ef1 χ2,ef2 : (∫ F) [ c,f , c',f' ]} → (fst χ1,ef1 ≡ fst χ2,ef2) → (χ1,ef1 ≡ χ2,ef2) |
84 | | - ElementHom≡ F {c1 , f1} {c2 , f2} {χ1 , ef1} {χ2 , ef2} eχ = cong₂ _,_ eχ |
85 | | - (fst (isOfHLevelPathP' 0 (snd (F ⟅ c2 ⟆) _ _) ef1 ef2)) |
86 | | - |
87 | | - ForgetElements : ∀ {ℓS} → (F : Functor C (SET ℓS)) → Functor (∫ F) C |
88 | | - F-ob (ForgetElements F) = fst |
89 | | - F-hom (ForgetElements F) = fst |
90 | | - F-id (ForgetElements F) = refl |
91 | | - F-seq (ForgetElements F) _ _ = refl |
92 | | - |
93 | | - module _ (isUnivC : isUnivalent C) {ℓS} (F : Functor C (SET ℓS)) where |
94 | | - open isUnivalent |
95 | | - isUnivalent∫ : isUnivalent (∫ F) |
96 | | - isUnivalent∫ .univ (c , f) (c' , f') = isIsoToIsEquiv |
97 | | - ( isoToPath∫ |
98 | | - , (λ f≅f' → CatIso≡ _ _ |
99 | | - (Σ≡Prop (λ _ → (F ⟅ _ ⟆) .snd _ _) |
100 | | - (cong fst |
101 | | - (secEq (univEquiv isUnivC _ _) (F-Iso {F = ForgetElements F} f≅f'))))) |
102 | | - , λ f≡f' → ΣSquareSet (λ x → snd (F ⟅ x ⟆)) |
103 | | - ( cong (CatIsoToPath isUnivC) (F-pathToIso {F = ForgetElements F} f≡f') |
104 | | - ∙ retEq (univEquiv isUnivC _ _) (cong fst f≡f'))) where |
105 | | - |
106 | | - isoToPath∫ : ∀ {c c' f f'} |
107 | | - → CatIso (∫ F) (c , f) (c' , f') |
108 | | - → (c , f) ≡ (c' , f') |
109 | | - isoToPath∫ {f = f} f≅f' = ΣPathP |
110 | | - ( CatIsoToPath isUnivC (F-Iso {F = ForgetElements F} f≅f') |
111 | | - , toPathP ( (λ j → transport (λ i → fst |
112 | | - (F-isoToPath isUnivC isUnivalentSET F |
113 | | - (F-Iso {F = ForgetElements F} f≅f') (~ j) i)) f) |
114 | | - ∙ univSetβ (F-Iso {F = F ∘F ForgetElements F} f≅f') f |
115 | | - ∙ f≅f' .fst .snd)) |
116 | | - |
| 27 | + Element : ∀ {ℓS} (F : Functor C (SET ℓS)) → Type (ℓ-max ℓ ℓS) |
| 28 | + Element F = Σ[ c ∈ C .ob ] fst (F ⟅ c ⟆) |
| 29 | + |
| 30 | + infix 50 ∫_ |
| 31 | + |
| 32 | + ∫_ : ∀ {ℓS} → Functor C (SET ℓS) → Category (ℓ-max ℓ ℓS) (ℓ-max ℓ' ℓS) |
| 33 | + -- objects are (c , x) pairs where c ∈ C and x ∈ F c |
| 34 | + (∫ F) .ob = Element F |
| 35 | + -- morphisms are f : c → c' which take x to x' |
| 36 | + (∫ F) .Hom[_,_] (c , x) (c' , x') = fiber (λ (f : C [ c , c' ]) → F .F-hom f x) x' |
| 37 | + (∫ F) .id .fst = id C |
| 38 | + (∫ F) .id {x} .snd = funExt⁻ (F .F-id) (x .snd) |
| 39 | + (∫ F) ._⋆_ (f , p) (g , q) .fst = f ⋆⟨ C ⟩ g |
| 40 | + (∫ F) ._⋆_ (f , p) (g , q) .snd = funExt⁻ (F .F-seq _ _) _ ∙∙ cong (F ⟪ g ⟫) p ∙∙ q |
| 41 | + (∫ F) .⋆IdL _ = Σ≡Prop (λ _ → getIsSet F _ _ _) (⋆IdL C _) |
| 42 | + (∫ F) .⋆IdR _ = Σ≡Prop (λ _ → getIsSet F _ _ _) (⋆IdR C _) |
| 43 | + (∫ F) .⋆Assoc _ _ _ = Σ≡Prop (λ _ → getIsSet F _ _ _) (⋆Assoc C _ _ _) |
| 44 | + (∫ F) .isSetHom {x} {y} = isSetΣSndProp (C .isSetHom) λ _ → (F ⟅ fst y ⟆) .snd _ _ |
| 45 | + |
| 46 | + ElementHom≡ : ∀ {ℓS} (F : Functor C (SET ℓS)) → {x y : Element F} |
| 47 | + → {f g : (∫ F) [ x , y ]} → fst f ≡ fst g → f ≡ g |
| 48 | + ElementHom≡ F = Σ≡Prop (λ _ → getIsSet F _ _ _) |
| 49 | + |
| 50 | + ForgetElements : ∀ {ℓS} → (F : Functor C (SET ℓS)) → Functor (∫ F) C |
| 51 | + F-ob (ForgetElements F) = fst |
| 52 | + F-hom (ForgetElements F) = fst |
| 53 | + F-id (ForgetElements F) = refl |
| 54 | + F-seq (ForgetElements F) _ _ = refl |
| 55 | + |
| 56 | + module _ (isUnivC : isUnivalent C) {ℓS} (F : Functor C (SET ℓS)) where |
| 57 | + open isUnivalent |
| 58 | + isUnivalent∫ : isUnivalent (∫ F) |
| 59 | + isUnivalent∫ .univ (c , f) (c' , f') = isIsoToIsEquiv |
| 60 | + ( isoToPath∫ |
| 61 | + , (λ f≅f' → CatIso≡ _ _ |
| 62 | + (Σ≡Prop (λ _ → (F ⟅ _ ⟆) .snd _ _) |
| 63 | + (cong fst |
| 64 | + (secEq (univEquiv isUnivC _ _) (F-Iso {F = ForgetElements F} f≅f'))))) |
| 65 | + , λ f≡f' → ΣSquareSet (λ x → snd (F ⟅ x ⟆)) |
| 66 | + ( cong (CatIsoToPath isUnivC) (F-pathToIso {F = ForgetElements F} f≡f') |
| 67 | + ∙ retEq (univEquiv isUnivC _ _) (cong fst f≡f'))) where |
| 68 | + |
| 69 | + isoToPath∫ : ∀ {c c' f f'} |
| 70 | + → CatIso (∫ F) (c , f) (c' , f') |
| 71 | + → (c , f) ≡ (c' , f') |
| 72 | + isoToPath∫ {f = f} f≅f' = ΣPathP |
| 73 | + ( CatIsoToPath isUnivC (F-Iso {F = ForgetElements F} f≅f') |
| 74 | + , toPathP ( (λ j → transport (λ i → fst |
| 75 | + (F-isoToPath isUnivC isUnivalentSET F |
| 76 | + (F-Iso {F = ForgetElements F} f≅f') (~ j) i)) f) |
| 77 | + ∙ univSetβ (F-Iso {F = F ∘F ForgetElements F} f≅f') f |
| 78 | + ∙ f≅f' .fst .snd)) |
117 | 79 |
|
118 | 80 | module Contravariant {ℓ ℓ'} {C : Category ℓ ℓ'} where |
119 | | - open Covariant {C = C ^op} |
| 81 | + open Covariant {C = C ^op} |
120 | 82 |
|
121 | | - -- same thing but for presheaves |
122 | | - ∫ᴾ_ : ∀ {ℓS} → Functor (C ^op) (SET ℓS) → Category (ℓ-max ℓ ℓS) (ℓ-max ℓ' ℓS) |
123 | | - ∫ᴾ F = (∫ F) ^op |
| 83 | + -- same thing but for presheaves |
| 84 | + ∫ᴾ_ : ∀ {ℓS} → Functor (C ^op) (SET ℓS) → Category (ℓ-max ℓ ℓS) (ℓ-max ℓ' ℓS) |
| 85 | + ∫ᴾ F = (∫ F) ^op |
124 | 86 |
|
125 | | - Elementᴾ : ∀ {ℓS} → Functor (C ^op) (SET ℓS) → Type (ℓ-max ℓ ℓS) |
126 | | - Elementᴾ F = (∫ᴾ F) .ob |
| 87 | + Elementᴾ : ∀ {ℓS} → Functor (C ^op) (SET ℓS) → Type (ℓ-max ℓ ℓS) |
| 88 | + Elementᴾ F = (∫ᴾ F) .ob |
127 | 89 |
|
128 | | - -- helpful results |
| 90 | + -- helpful results |
129 | 91 |
|
130 | | - module _ {ℓS} {F : Functor (C ^op) (SET ℓS)} where |
| 92 | + module _ {ℓS} {F : Functor (C ^op) (SET ℓS)} where |
131 | 93 |
|
132 | | - -- morphisms are equal as long as the morphisms in C are equal |
133 | | - ∫ᴾhomEq : ∀ {o1 o1' o2 o2'} (f : (∫ᴾ F) [ o1 , o2 ]) (g : (∫ᴾ F) [ o1' , o2' ]) |
134 | | - → (p : o1 ≡ o1') (q : o2 ≡ o2') |
135 | | - → (eqInC : PathP (λ i → C [ fst (p i) , fst (q i) ]) (fst f) (fst g)) |
136 | | - → PathP (λ i → (∫ᴾ F) [ p i , q i ]) f g |
137 | | - ∫ᴾhomEq _ _ _ _ = ΣPathPProp (λ f → snd (F ⟅ _ ⟆) _ _) |
| 94 | + -- morphisms are equal as long as the morphisms in C are equal |
| 95 | + ∫ᴾhomEq : ∀ {o1 o1' o2 o2'} (f : (∫ᴾ F) [ o1 , o2 ]) (g : (∫ᴾ F) [ o1' , o2' ]) |
| 96 | + → (p : o1 ≡ o1') (q : o2 ≡ o2') |
| 97 | + → (eqInC : PathP (λ i → C [ fst (p i) , fst (q i) ]) (fst f) (fst g)) |
| 98 | + → PathP (λ i → (∫ᴾ F) [ p i , q i ]) f g |
| 99 | + ∫ᴾhomEq _ _ _ _ = ΣPathPProp (λ f → snd (F ⟅ _ ⟆) _ _) |
138 | 100 |
|
139 | | - ∫ᴾhomEqSimpl : ∀ {o1 o2} (f g : (∫ᴾ F) [ o1 , o2 ]) |
140 | | - → fst f ≡ fst g → f ≡ g |
141 | | - ∫ᴾhomEqSimpl f g p = ∫ᴾhomEq f g refl refl p |
| 101 | + ∫ᴾhomEqSimpl : ∀ {o1 o2} (f g : (∫ᴾ F) [ o1 , o2 ]) |
| 102 | + → fst f ≡ fst g → f ≡ g |
| 103 | + ∫ᴾhomEqSimpl f g p = ∫ᴾhomEq f g refl refl p |
0 commit comments