779
|
1 open import Level
|
950
|
2 open import Category
|
779
|
3 module CCC where
|
|
4
|
950
|
5
|
779
|
6 open import HomReasoning
|
|
7 open import cat-utility
|
780
|
8 open import Relation.Binary.PropositionalEquality
|
779
|
9
|
783
|
10
|
|
11 open import HomReasoning
|
|
12
|
784
|
13 record IsCCC {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ)
|
783
|
14 ( 1 : Obj A )
|
|
15 ( ○ : (a : Obj A ) → Hom A a 1 )
|
|
16 ( _∧_ : Obj A → Obj A → Obj A )
|
|
17 ( <_,_> : {a b c : Obj A } → Hom A c a → Hom A c b → Hom A c (a ∧ b) )
|
|
18 ( π : {a b : Obj A } → Hom A (a ∧ b) a )
|
|
19 ( π' : {a b : Obj A } → Hom A (a ∧ b) b )
|
|
20 ( _<=_ : (a b : Obj A ) → Obj A )
|
|
21 ( _* : {a b c : Obj A } → Hom A (a ∧ b) c → Hom A a (c <= b) )
|
|
22 ( ε : {a b : Obj A } → Hom A ((a <= b ) ∧ b) a )
|
|
23 : Set ( c₁ ⊔ c₂ ⊔ ℓ ) where
|
|
24 field
|
|
25 -- cartesian
|
793
|
26 e2 : {a : Obj A} → ∀ { f : Hom A a 1 } → A [ f ≈ ○ a ]
|
783
|
27 e3a : {a b c : Obj A} → { f : Hom A c a }{ g : Hom A c b } → A [ A [ π o < f , g > ] ≈ f ]
|
|
28 e3b : {a b c : Obj A} → { f : Hom A c a }{ g : Hom A c b } → A [ A [ π' o < f , g > ] ≈ g ]
|
|
29 e3c : {a b c : Obj A} → { h : Hom A c (a ∧ b) } → A [ < A [ π o h ] , A [ π' o h ] > ≈ h ]
|
785
|
30 π-cong : {a b c : Obj A} → { f f' : Hom A c a }{ g g' : Hom A c b } → A [ f ≈ f' ] → A [ g ≈ g' ] → A [ < f , g > ≈ < f' , g' > ]
|
783
|
31 -- closed
|
|
32 e4a : {a b c : Obj A} → { h : Hom A (c ∧ b) a } → A [ A [ ε o < A [ (h *) o π ] , π' > ] ≈ h ]
|
|
33 e4b : {a b c : Obj A} → { k : Hom A c (a <= b ) } → A [ ( A [ ε o < A [ k o π ] , π' > ] ) * ≈ k ]
|
787
|
34 *-cong : {a b c : Obj A} → { f f' : Hom A (a ∧ b) c } → A [ f ≈ f' ] → A [ f * ≈ f' * ]
|
967
|
35 open ≈-Reasoning A
|
|
36 e'2 : ○ 1 ≈ id1 A 1
|
|
37 e'2 = begin
|
783
|
38 ○ 1
|
793
|
39 ≈↑⟨ e2 ⟩
|
783
|
40 id1 A 1
|
|
41 ∎
|
967
|
42 e''2 : {a b : Obj A} {f : Hom A a b } → ( ○ b o f ) ≈ ○ a
|
|
43 e''2 {a} {b} {f} = begin
|
783
|
44 ○ b o f
|
793
|
45 ≈⟨ e2 ⟩
|
783
|
46 ○ a
|
|
47 ∎
|
967
|
48 π-id : {a b : Obj A} → < π , π' > ≈ id1 A (a ∧ b )
|
|
49 π-id {a} {b} = begin
|
789
|
50 < π , π' >
|
|
51 ≈↑⟨ π-cong idR idR ⟩
|
|
52 < π o id1 A (a ∧ b) , π' o id1 A (a ∧ b) >
|
|
53 ≈⟨ e3c ⟩
|
|
54 id1 A (a ∧ b )
|
|
55 ∎
|
967
|
56 distr-π : {a b c d : Obj A} {f : Hom A c a }{g : Hom A c b } {h : Hom A d c } → ( < f , g > o h ) ≈ < ( f o h ) , ( g o h ) >
|
|
57 distr-π {a} {b} {c} {d} {f} {g} {h} = begin
|
783
|
58 < f , g > o h
|
|
59 ≈↑⟨ e3c ⟩
|
|
60 < π o < f , g > o h , π' o < f , g > o h >
|
785
|
61 ≈⟨ π-cong assoc assoc ⟩
|
|
62 < ( π o < f , g > ) o h , (π' o < f , g > ) o h >
|
|
63 ≈⟨ π-cong (car e3a ) (car e3b) ⟩
|
783
|
64 < f o h , g o h >
|
|
65 ∎
|
794
|
66 _×_ : { a b c d : Obj A } ( f : Hom A a c ) (g : Hom A b d ) → Hom A (a ∧ b) ( c ∧ d )
|
967
|
67 f × g = < ( f o π ) , (g o π' ) >
|
|
68 π-exchg : {a b c : Obj A} {f : Hom A c a }{g : Hom A c b } → < π' , π > o < f , g > ≈ < g , f >
|
|
69 π-exchg {a} {b} {c} {f} {g} = begin
|
|
70 < π' , π > o < f , g >
|
|
71 ≈⟨ distr-π ⟩
|
|
72 < π' o < f , g > , π o < f , g > >
|
|
73 ≈⟨ π-cong e3b e3a ⟩
|
|
74 < g , f >
|
|
75 ∎
|
|
76 π'π : {a b : Obj A} → < π' , π > o < π' , π > ≈ id1 A (a ∧ b)
|
|
77 π'π = trans-hom π-exchg π-id
|
|
78 exchg-π : {a b c d : Obj A} {f : Hom A c a }{g : Hom A d b } → < f o π , g o π' > o < π' , π > ≈ < f o π' , g o π >
|
|
79 exchg-π {a} {b} {c} {d} {f} {g} = begin
|
|
80 < f o π , g o π' > o < π' , π >
|
|
81 ≈⟨ distr-π ⟩
|
|
82 < (f o π) o < π' , π > , (g o π' ) o < π' , π > >
|
|
83 ≈↑⟨ π-cong assoc assoc ⟩
|
|
84 < f o (π o < π' , π > ) , g o (π' o < π' , π >)>
|
|
85 ≈⟨ π-cong (cdr e3a) (cdr e3b) ⟩
|
|
86 < f o π' , g o π >
|
|
87 ∎
|
979
|
88 π≈ : {a b c : Obj A} {f f' : Hom A c a }{g g' : Hom A c b } → < f , g > ≈ < f' , g' > → f ≈ f'
|
|
89 π≈ {_} {_} {_} {f} {f'} {g} {g'} eq = begin
|
|
90 f ≈↑⟨ e3a ⟩
|
|
91 π o < f , g > ≈⟨ cdr eq ⟩
|
|
92 π o < f' , g' > ≈⟨ e3a ⟩
|
|
93 f'
|
|
94 ∎
|
|
95 π'≈ : {a b c : Obj A} {f f' : Hom A c a }{g g' : Hom A c b } → < f , g > ≈ < f' , g' > → g ≈ g'
|
|
96 π'≈ {_} {_} {_} {f} {f'} {g} {g'} eq = begin
|
|
97 g ≈↑⟨ e3b ⟩
|
|
98 π' o < f , g > ≈⟨ cdr eq ⟩
|
|
99 π' o < f' , g' > ≈⟨ e3b ⟩
|
|
100 g'
|
|
101 ∎
|
967
|
102 distr-* : {a b c d : Obj A } { h : Hom A (a ∧ b) c } { k : Hom A d a } → ( h * o k ) ≈ ( h o < ( k o π ) , π' > ) *
|
794
|
103 distr-* {a} {b} {c} {d} {h} {k} = begin
|
|
104 h * o k
|
|
105 ≈↑⟨ e4b ⟩
|
|
106 ( ε o < (h * o k ) o π , π' > ) *
|
|
107 ≈⟨ *-cong ( begin
|
|
108 ε o < (h * o k ) o π , π' >
|
|
109 ≈↑⟨ cdr ( π-cong assoc refl-hom ) ⟩
|
|
110 ε o ( < h * o ( k o π ) , π' > )
|
|
111 ≈↑⟨ cdr ( π-cong (cdr e3a) e3b ) ⟩
|
|
112 ε o ( < h * o ( π o < k o π , π' > ) , π' o < k o π , π' > > )
|
|
113 ≈⟨ cdr ( π-cong assoc refl-hom) ⟩
|
|
114 ε o ( < (h * o π) o < k o π , π' > , π' o < k o π , π' > > )
|
|
115 ≈↑⟨ cdr ( distr-π ) ⟩
|
|
116 ε o ( < h * o π , π' > o < k o π , π' > )
|
|
117 ≈⟨ assoc ⟩
|
|
118 ( ε o < h * o π , π' > ) o < k o π , π' >
|
|
119 ≈⟨ car e4a ⟩
|
|
120 h o < k o π , π' >
|
|
121 ∎ ) ⟩
|
|
122 ( h o < k o π , π' > ) *
|
967
|
123 ∎
|
794
|
124 α : {a b c : Obj A } → Hom A (( a ∧ b ) ∧ c ) ( a ∧ ( b ∧ c ) )
|
967
|
125 α = < ( π o π ) , < ( π' o π ) , π' > >
|
794
|
126 α' : {a b c : Obj A } → Hom A ( a ∧ ( b ∧ c ) ) (( a ∧ b ) ∧ c )
|
967
|
127 α' = < < π , ( π o π' ) > , ( π' o π' ) >
|
|
128 β : {a b c d : Obj A } { f : Hom A a b} { g : Hom A a c } { h : Hom A a d } → ( α o < < f , g > , h > ) ≈ < f , < g , h > >
|
794
|
129 β {a} {b} {c} {d} {f} {g} {h} = begin
|
|
130 α o < < f , g > , h >
|
|
131 ≈⟨⟩
|
|
132 ( < ( π o π ) , < ( π' o π ) , π' > > ) o < < f , g > , h >
|
|
133 ≈⟨ distr-π ⟩
|
|
134 < ( ( π o π ) o < < f , g > , h > ) , ( < ( π' o π ) , π' > o < < f , g > , h > ) >
|
|
135 ≈⟨ π-cong refl-hom distr-π ⟩
|
|
136 < ( ( π o π ) o < < f , g > , h > ) , ( < ( ( π' o π ) o < < f , g > , h > ) , ( π' o < < f , g > , h > ) > ) >
|
|
137 ≈↑⟨ π-cong assoc ( π-cong assoc refl-hom ) ⟩
|
|
138 < ( π o (π o < < f , g > , h >) ) , ( < ( π' o ( π o < < f , g > , h > ) ) , ( π' o < < f , g > , h > ) > ) >
|
|
139 ≈⟨ π-cong (cdr e3a ) ( π-cong (cdr e3a ) e3b ) ⟩
|
|
140 < ( π o < f , g > ) , < ( π' o < f , g > ) , h > >
|
|
141 ≈⟨ π-cong e3a ( π-cong e3b refl-hom ) ⟩
|
|
142 < f , < g , h > >
|
967
|
143 ∎
|
794
|
144
|
783
|
145
|
784
|
146 record CCC {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) : Set ( c₁ ⊔ c₂ ⊔ ℓ ) where
|
781
|
147 field
|
783
|
148 1 : Obj A
|
|
149 ○ : (a : Obj A ) → Hom A a 1
|
|
150 _∧_ : Obj A → Obj A → Obj A
|
|
151 <_,_> : {a b c : Obj A } → Hom A c a → Hom A c b → Hom A c (a ∧ b)
|
|
152 π : {a b : Obj A } → Hom A (a ∧ b) a
|
|
153 π' : {a b : Obj A } → Hom A (a ∧ b) b
|
|
154 _<=_ : (a b : Obj A ) → Obj A
|
|
155 _* : {a b c : Obj A } → Hom A (a ∧ b) c → Hom A a (c <= b)
|
|
156 ε : {a b : Obj A } → Hom A ((a <= b ) ∧ b) a
|
784
|
157 isCCC : IsCCC A 1 ○ _∧_ <_,_> π π' _<=_ _* ε
|
781
|
158
|
1011
|
159 open Functor
|
|
160
|
|
161 record CCCFunctor {c₁ c₂ ℓ c₁' c₂' ℓ' : Level} (A : Category c₁ c₂ ℓ) (B : Category c₁' c₂' ℓ')
|
|
162 (ca : CCC A) (cb : CCC B) (functor : Functor A B)
|
|
163 : Set (suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁' ⊔ c₂' ⊔ ℓ')) where
|
|
164 field
|
|
165 f1 : FObj functor (CCC.1 ca) ≡ CCC.1 cb
|
|
166 f○ : {a : Obj A} → B [ FMap functor (CCC.○ ca a) ≈
|
|
167 subst (λ k → Hom B (FObj functor a) k) (sym f1) (CCC.○ cb (FObj functor a)) ]
|
|
168 f∧ : {a b : Obj A} → FObj functor ( CCC._∧_ ca a b ) ≡ CCC._∧_ cb (FObj functor a ) (FObj functor b)
|
|
169 f<= : {a b : Obj A} → FObj functor ( CCC._<=_ ca a b ) ≡ CCC._<=_ cb (FObj functor a ) (FObj functor b)
|
|
170 f<> : {a b c : Obj A} → (f : Hom A c a ) → (g : Hom A c b )
|
|
171 → B [ FMap functor (CCC.<_,_> ca f g ) ≈
|
|
172 subst (λ k → Hom B (FObj functor c) k ) (sym f∧ ) ( CCC.<_,_> cb (FMap functor f ) ( FMap functor g )) ]
|
|
173 fπ : {a b : Obj A} → B [ FMap functor (CCC.π ca {a} {b}) ≈
|
|
174 subst (λ k → Hom B k (FObj functor a) ) (sym f∧ ) (CCC.π cb {FObj functor a} {FObj functor b}) ]
|
|
175 fπ' : {a b : Obj A} → B [ FMap functor (CCC.π' ca {a} {b}) ≈
|
|
176 subst (λ k → Hom B k (FObj functor b) ) (sym f∧ ) (CCC.π' cb {FObj functor a} {FObj functor b}) ]
|
|
177 f* : {a b c : Obj A} → (f : Hom A (CCC._∧_ ca a b) c ) → B [ FMap functor (CCC._* ca f) ≈
|
|
178 subst (λ k → Hom B (FObj functor a) k) (sym f<=) (CCC._* cb ((subst (λ k → Hom B k (FObj functor c) ) f∧ (FMap functor f) ))) ]
|
|
179 fε : {a b : Obj A} → B [ FMap functor (CCC.ε ca {a} {b} )
|
|
180 ≈ subst (λ k → Hom B k (FObj functor a)) (trans (cong (λ k → CCC._∧_ cb k (FObj functor b)) (sym f<=)) (sym f∧))
|
|
181 (CCC.ε cb {FObj functor a} {FObj functor b}) ]
|
|
182
|
952
|
183 ----
|
|
184 --
|
|
185 -- Sub Object Classifier as Topos
|
954
|
186 -- pull back on
|
1016
|
187 --
|
|
188 -- iso ○ b
|
|
189 -- e ⇐====⇒ b -----------→ 1
|
|
190 -- | | |
|
|
191 -- | m | | ⊤
|
|
192 -- | ↓ char m ↓
|
|
193 -- + ------→ a -----------→ Ω
|
|
194 -- ker h h
|
952
|
195 --
|
950
|
196 open Equalizer
|
963
|
197 open import equalizer
|
950
|
198
|
952
|
199 record Mono {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) {b a : Obj A} (mono : Hom A b a) : Set (c₁ ⊔ c₂ ⊔ ℓ) where
|
|
200 field
|
|
201 isMono : {c : Obj A} ( f g : Hom A c b ) → A [ A [ mono o f ] ≈ A [ mono o g ] ] → A [ f ≈ g ]
|
|
202
|
|
203 open Mono
|
|
204
|
1016
|
205 open import equalizer
|
|
206
|
975
|
207 record IsTopos {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) (c : CCC A)
|
952
|
208 ( Ω : Obj A )
|
975
|
209 ( ⊤ : Hom A (CCC.1 c) Ω )
|
|
210 (Ker : {a : Obj A} → ( h : Hom A a Ω ) → Equalizer A h (A [ ⊤ o (CCC.○ c a) ]))
|
952
|
211 (char : {a b : Obj A} → (m : Hom A b a) → Mono A m → Hom A a Ω) : Set ( suc c₁ ⊔ suc c₂ ⊔ suc ℓ ) where
|
950
|
212 field
|
986
|
213 char-uniqueness : {a b : Obj A } {h : Hom A a Ω} (m : Hom A b a) → (mono : Mono A m)
|
1016
|
214 → A [ char (equalizer (Ker h)) (record { isMono = λ f g → monic (Ker h)}) ≈ h ]
|
986
|
215 ker-iso : {a b : Obj A} → (m : Hom A b a) → (mono : Mono A m) → IsoL A m (equalizer (Ker ( char m mono )))
|
1016
|
216 ker : {a : Obj A} → ( h : Hom A a Ω ) → Hom A ( equalizer-c (Ker h) ) a
|
|
217 ker h = equalizer (Ker h)
|
|
218 mm : {a b : Obj A} → (m : Hom A b a) → (mono : Mono A m ) → A [ A [ equalizer (Ker (char m mono)) o Iso.≅→ (IsoL.iso-L (ker-iso m mono)) ] ≈ m ]
|
|
219 mm m mono = IsoL.L≈iso (ker-iso m mono)
|
|
220 mequ : {a b : Obj A} → (m : Hom A b a) → (mono : Mono A m ) → Equalizer A (char m mono) (A [ ⊤ o (CCC.○ c a) ])
|
|
221 mequ {a} {b} m mono = record { equalizer-c = b ; equalizer = m ; isEqualizer =
|
|
222 subst (λ k → IsEqualizer A k _ _ ) {!!} --
|
|
223 ( equalizer+iso (Ker (char m mono)) (Iso.≅→ (IsoL.iso-L (ker-iso m mono)))
|
|
224 (Iso.≅← (IsoL.iso-L (ker-iso m mono))) (Iso.iso→ (IsoL.iso-L (ker-iso m mono))) (Iso.iso← (IsoL.iso-L (ker-iso m mono))) ) }
|
|
225 char-m=⊤ : {a b : Obj A} → (m : Hom A b a) → (mono : Mono A m) → A [ A [ char m mono o m ] ≈ A [ ⊤ o CCC.○ c b ] ]
|
|
226 char-m=⊤ {a} {b} m mono = begin
|
|
227 char m mono o m ≈⟨ {!!} ⟩
|
|
228 char (ker (char m mono) ) {!!} o m ≈⟨ {!!} ⟩
|
|
229 char m mono o (ker (char m mono) o Iso.≅→ (IsoL.iso-L (ker-iso m mono))) ≈⟨ {!!} ⟩
|
|
230 (char m mono o ker (char m mono) ) o Iso.≅→ (IsoL.iso-L (ker-iso m mono)) ≈⟨ {!!} ⟩
|
|
231 {!!} ≈⟨ {!!} ⟩
|
|
232 (⊤ o CCC.○ c a) o m ≈↑⟨ assoc ⟩
|
|
233 ⊤ o (CCC.○ c a o m ) ≈⟨ cdr (IsCCC.e2 (CCC.isCCC c)) ⟩
|
|
234 ⊤ o CCC.○ c b ∎ where open ≈-Reasoning A
|
950
|
235
|
975
|
236 record Topos {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) (c : CCC A) : Set ( suc c₁ ⊔ suc c₂ ⊔ suc ℓ ) where
|
952
|
237 field
|
950
|
238 Ω : Obj A
|
975
|
239 ⊤ : Hom A (CCC.1 c) Ω
|
|
240 Ker : {a : Obj A} → ( h : Hom A a Ω ) → Equalizer A h (A [ ⊤ o (CCC.○ c a) ])
|
952
|
241 char : {a b : Obj A} → (m : Hom A b a ) → Mono A m → Hom A a Ω
|
975
|
242 isTopos : IsTopos A c Ω ⊤ Ker char
|
973
|
243 Monik : {a : Obj A} (h : Hom A a Ω) → Mono A (equalizer (Ker h))
|
|
244 Monik h = record { isMono = λ f g → monic (Ker h ) }
|
783
|
245
|
963
|
246 record NatD {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) ( 1 : Obj A) : Set ( suc c₁ ⊔ suc c₂ ⊔ suc ℓ ) where
|
|
247 field
|
|
248 Nat : Obj A
|
|
249 nzero : Hom A 1 Nat
|
|
250 nsuc : Hom A Nat Nat
|
|
251
|
|
252 open NatD
|
|
253
|
986
|
254 record IsToposNat {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) ( 1 : Obj A) (iNat : NatD A 1 )
|
|
255 ( initialNat : (nat : NatD A 1 ) → Hom A (Nat iNat) (Nat nat) )
|
963
|
256 : Set ( suc c₁ ⊔ suc c₂ ⊔ suc ℓ ) where
|
|
257 field
|
986
|
258 izero : (nat : NatD A 1 ) → A [ A [ initialNat nat o nzero iNat ] ≈ nzero nat ]
|
|
259 isuc : (nat : NatD A 1 ) → A [ A [ initialNat nat o nsuc iNat ] ≈ A [ nsuc nat o initialNat nat ] ]
|
963
|
260
|
|
261 record ToposNat {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) ( 1 : Obj A) : Set ( suc c₁ ⊔ suc c₂ ⊔ suc ℓ ) where
|
|
262 field
|
986
|
263 iNat : NatD A 1
|
|
264 initialNat : (nat : NatD A 1 ) → Hom A (Nat iNat) (Nat nat)
|
|
265 nat-unique : (nat : NatD A 1 ) → {g : Hom A (Nat iNat) (Nat nat) }
|
|
266 → A [ A [ g o nzero iNat ] ≈ nzero nat ]
|
|
267 → A [ A [ g o nsuc iNat ] ≈ A [ nsuc nat o g ] ]
|
|
268 → A [ g ≈ initialNat nat ]
|
|
269 isToposN : IsToposNat A 1 iNat initialNat
|
783
|
270
|