annotate src/CCCSets.agda @ 1068:4e58611b1fb1

fix 1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 29 Apr 2021 11:16:18 +0900
parents 40c39d3e6a75
children 849f85e543f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 {-# OPTIONS --allow-unsolved-metas #-}
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 module CCCSets where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Level
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Category
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import HomReasoning
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import cat-utility
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import Data.Product renaming (_×_ to _/\_ ) hiding ( <_,_> )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Category.Constructions.Product
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Relation.Binary.PropositionalEquality hiding ( [_] )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 open import CCC
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open Functor
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 -- ccc-1 : Hom A a 1 ≅ {*}
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 -- ccc-2 : Hom A c (a × b) ≅ (Hom A c a ) × ( Hom A c b )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 -- ccc-3 : Hom A a (c ^ b) ≅ Hom A (a × b) c
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 open import Category.Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 -- Sets is a CCC
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
1018
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1016
diff changeset
23 open import SetsCompleteness hiding (ki1)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1016
diff changeset
24
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1016
diff changeset
25 -- import Axiom.Extensionality.Propositional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1016
diff changeset
26 -- postulate extensionality : { c₁ c₂ ℓ : Level} ( A : Category c₁ c₂ ℓ ) → Axiom.Extensionality.Propositional.Extensionality c₂ c₂
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 data One {c : Level } : Set c where
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
29 ! : One -- () in Haskell ( or any one object set )
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 sets : {c : Level } → CCC (Sets {c})
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 sets = record {
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 1 = One
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
34 ; ○ = λ _ → λ _ → !
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 ; _∧_ = _∧_
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 ; <_,_> = <,>
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 ; π = π
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 ; π' = π'
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 ; _<=_ = _<=_
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 ; _* = _*
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 ; ε = ε
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 ; isCCC = isCCC
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 } where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 1 : Obj Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 1 = One
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 ○ : (a : Obj Sets ) → Hom Sets a 1
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
47 ○ a = λ _ → !
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 _∧_ : Obj Sets → Obj Sets → Obj Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 _∧_ a b = a /\ b
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 <,> : {a b c : Obj Sets } → Hom Sets c a → Hom Sets c b → Hom Sets c ( a ∧ b)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 <,> f g = λ x → ( f x , g x )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 π : {a b : Obj Sets } → Hom Sets (a ∧ b) a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 π {a} {b} = proj₁
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 π' : {a b : Obj Sets } → Hom Sets (a ∧ b) b
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 π' {a} {b} = proj₂
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 _<=_ : (a b : Obj Sets ) → Obj Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 a <= b = b → a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 _* : {a b c : Obj Sets } → Hom Sets (a ∧ b) c → Hom Sets a (c <= b)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 f * = λ x → λ y → f ( x , y )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 ε : {a b : Obj Sets } → Hom Sets ((a <= b ) ∧ b) a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 ε {a} {b} = λ x → ( proj₁ x ) ( proj₂ x )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 isCCC : CCC.IsCCC Sets 1 ○ _∧_ <,> π π' _<=_ _* ε
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 isCCC = record {
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 e2 = e2
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 ; e3a = λ {a} {b} {c} {f} {g} → e3a {a} {b} {c} {f} {g}
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 ; e3b = λ {a} {b} {c} {f} {g} → e3b {a} {b} {c} {f} {g}
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 ; e3c = e3c
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 ; π-cong = π-cong
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 ; e4a = e4a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 ; e4b = e4b
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 ; *-cong = *-cong
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 } where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 e2 : {a : Obj Sets} {f : Hom Sets a 1} → Sets [ f ≈ ○ a ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 e2 {a} {f} = extensionality Sets ( λ x → e20 x )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 e20 : (x : a ) → f x ≡ ○ a x
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 e20 x with f x
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
78 e20 x | ! = refl
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 e3a : {a b c : Obj Sets} {f : Hom Sets c a} {g : Hom Sets c b} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 Sets [ ( Sets [ π o ( <,> f g) ] ) ≈ f ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 e3a = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 e3b : {a b c : Obj Sets} {f : Hom Sets c a} {g : Hom Sets c b} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 Sets [ Sets [ π' o ( <,> f g ) ] ≈ g ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 e3b = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 e3c : {a b c : Obj Sets} {h : Hom Sets c (a ∧ b)} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 Sets [ <,> (Sets [ π o h ]) (Sets [ π' o h ]) ≈ h ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 e3c = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 π-cong : {a b c : Obj Sets} {f f' : Hom Sets c a} {g g' : Hom Sets c b} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 Sets [ f ≈ f' ] → Sets [ g ≈ g' ] → Sets [ <,> f g ≈ <,> f' g' ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 π-cong refl refl = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 e4a : {a b c : Obj Sets} {h : Hom Sets (c ∧ b) a} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 Sets [ Sets [ ε o <,> (Sets [ h * o π ]) π' ] ≈ h ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 e4a = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 e4b : {a b c : Obj Sets} {k : Hom Sets c (a <= b)} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 Sets [ (Sets [ ε o <,> (Sets [ k o π ]) π' ]) * ≈ k ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 e4b = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 *-cong : {a b c : Obj Sets} {f f' : Hom Sets (a ∧ b) c} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 Sets [ f ≈ f' ] → Sets [ f * ≈ f' * ]
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 *-cong refl = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
101 open import Relation.Nullary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
102 open import Data.Empty
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
103 open import equalizer
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
105 data Bool { c : Level } : Set c where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
106 true : Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
107 false : Bool
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
108
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
109 ¬f≡t : { c : Level } → ¬ (false {c} ≡ true )
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
110 ¬f≡t ()
1025
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1024
diff changeset
111
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1024
diff changeset
112 ¬x≡t∧x≡f : { c : Level } → {x : Bool {c}} → ¬ ((x ≡ false) /\ (x ≡ true) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1024
diff changeset
113 ¬x≡t∧x≡f {_} {true} p = ⊥-elim (¬f≡t (sym (proj₁ p)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1024
diff changeset
114 ¬x≡t∧x≡f {_} {false} p = ⊥-elim (¬f≡t (proj₂ p))
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
115
1022
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
116 data _∨_ {c c' : Level } (a : Set c) (b : Set c') : Set (c ⊔ c') where
1021
8a78ddfdaa24 ... use LEM for Topos Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1020
diff changeset
117 case1 : a → a ∨ b
8a78ddfdaa24 ... use LEM for Topos Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1020
diff changeset
118 case2 : b → a ∨ b
8a78ddfdaa24 ... use LEM for Topos Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1020
diff changeset
119
1034
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
120 ---------------------------------------------
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
121 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
122 -- a binary Topos of Sets
1024
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
123 --
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
124 -- m : b → a determins a subset of a as an image
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
125 -- b and m-image in a has one to one correspondence with an equalizer (x : b) → (y : a) ≡ m x.
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
126 -- so tchar m mono and ker (tchar m mono) is Iso.
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
127 -- Finding (x : b) from (y : a) is non constructive. Assuming LEM of image.
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
128 --
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
129 data image {c : Level} {a b : Set c} (m : Hom Sets b a) : a → Set c where
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
130 isImage : (x : b ) → image m (m x)
1022
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
131
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
132 topos : {c : Level } → ({ c : Level} → (b : Set c) → b ∨ (¬ b)) → Topos (Sets {c}) sets
1021
8a78ddfdaa24 ... use LEM for Topos Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1020
diff changeset
133 topos {c} lem = record {
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
134 Ω = Bool
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
135 ; ⊤ = λ _ → true
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 ; Ker = tker
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
137 ; char = λ m mono → tchar m mono
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 ; isTopos = record {
1018
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1016
diff changeset
139 char-uniqueness = λ {a} {b} {h} m mono → extensionality Sets ( λ x → uniq h m mono x )
1034
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
140 ; ker-m = λ m mono → equalizerIso _ _ (tker (tchar m mono)) m (isol m mono)
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 }
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 } where
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
143 --
1024
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
144 -- In Sets, equalizers exist as
1022
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
145 -- data sequ {c : Level} (A B : Set c) ( f g : A → B ) : Set c where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
146 -- elem : (x : A ) → (eq : f x ≡ g x) → sequ A B f g
1024
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
147 -- m have to be isomorphic to ker (char m).
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
148 --
1034
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
149 -- b→s ○ b
1022
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
150 -- ker (char m) ----→ b -----------→ 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
151 -- | ←---- | |
1034
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
152 -- | b←s |m | ⊤ char m : a → Ω = {true,false}
1024
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
153 -- | e ↓ char m ↓ if y : a ≡ m (∃ x : b) → true ( data char )
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
154 -- +-------------→ a -----------→ Ω else false
1022
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
155 -- h
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1021
diff changeset
156 --
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
157 tker : {a : Obj Sets} (h : Hom Sets a Bool) → Equalizer Sets h (Sets [ (λ _ → true ) o CCC.○ sets a ])
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 tker {a} h = record {
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
159 equalizer-c = sequ a Bool h (λ _ → true )
1018
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1016
diff changeset
160 ; equalizer = λ e → equ e
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1016
diff changeset
161 ; isEqualizer = SetsIsEqualizer _ _ _ _ }
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
162 tchar : {a b : Obj Sets} (m : Hom Sets b a) → (mono : Mono Sets m ) → a → Bool {c}
1024
447bbacacf64 fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1023
diff changeset
163 tchar {a} {b} m mono y with lem (image m y )
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
164 ... | case1 t = true
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
165 ... | case2 f = false
1034
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
166 -- imequ : {a b : Obj Sets} (m : Hom Sets b a) (mono : Mono Sets m) → IsEqualizer Sets m (tchar m mono) (Sets [ (λ _ → true ) o CCC.○ sets a ])
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
167 -- imequ {a} {b} m mono = equalizerIso _ _ (tker (tchar m mono)) m (isol m mono)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
168 uniq : {a : Obj (Sets {c})} {b : Obj Sets} (h : Hom Sets a Bool) (m : Hom Sets b a) (mono : Mono Sets m) (y : a) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
169 tchar (Equalizer.equalizer (tker h)) (record { isMono = λ f g → monic (tker h) }) y ≡ h y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
170 uniq {a} {b} h m mono y with h y | inspect h y | lem (image (Equalizer.equalizer (tker h)) y ) | inspect (tchar (Equalizer.equalizer (tker h)) (record { isMono = λ f g → monic (tker h) })) y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
171 ... | true | record { eq = eqhy } | case1 x | record { eq = eq1 } = eq1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
172 ... | true | record { eq = eqhy } | case2 x | record { eq = eq1 } = ⊥-elim (x (isImage (elem y eqhy)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
173 ... | false | record { eq = eqhy } | case1 (isImage (elem x eq)) | record { eq = eq1 } = ⊥-elim ( ¬x≡t∧x≡f record {fst = eqhy ; snd = eq })
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
174 ... | false | record { eq = eqhy } | case2 x | record { eq = eq1 } = eq1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1032
diff changeset
176 -- technical detail of equalizer-image isomorphism (isol) below
1031
52c98490c877 Sets Topos iso1 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1030
diff changeset
177 open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ )
52c98490c877 Sets Topos iso1 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1030
diff changeset
178 img-cong : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → (mono : Mono Sets m ) → (y y' : a) → y ≡ y' → (s : image m y ) (t : image m y') → s ≅ t
52c98490c877 Sets Topos iso1 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1030
diff changeset
179 img-cong {a} {b} m mono .(m x) .(m x₁) eq (isImage x) (isImage x₁)
52c98490c877 Sets Topos iso1 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1030
diff changeset
180 with cong (λ k → k ! ) ( Mono.isMono mono {One} (λ _ → x) (λ _ → x₁ ) ( extensionality Sets ( λ _ → eq )) )
52c98490c877 Sets Topos iso1 done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1030
diff changeset
181 ... | refl = HE.refl
1032
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
182 image-uniq : {a b : Obj (Sets {c})} (m : Hom Sets b a) → (mono : Mono Sets m ) (y : a) → (i0 i1 : image m y ) → i0 ≡ i1
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
183 image-uniq {a} {b} m mono y i0 i1 = HE.≅-to-≡ (img-cong m mono y y refl i0 i1)
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
184 tchar¬Img : {a b : Obj Sets} (m : Hom Sets b a) → (mono : Mono Sets m ) (y : a) → tchar m mono y ≡ false → ¬ image m y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
185 tchar¬Img m mono y eq im with lem (image m y)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
186 ... | case2 n = n im
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
187 b2i : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → (x : b) → image m (m x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
188 b2i m x = isImage x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
189 i2b : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → {y : a} → image m y → b
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
190 i2b m (isImage x) = x
1032
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
191 img-mx=y : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → {y : a} → (im : image m y ) → m (i2b m im) ≡ y
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
192 img-mx=y m (isImage x) = refl
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
193 b2i-iso : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → (x : b) → i2b m (b2i m x) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
194 b2i-iso m x = refl
1029
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1028
diff changeset
195 b2s : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → (mono : Mono Sets m ) → (x : b) → sequ a Bool (tchar m mono) (λ _ → true )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1028
diff changeset
196 b2s m mono x with tchar m mono (m x) | inspect (tchar m mono) (m x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1028
diff changeset
197 ... | true | record {eq = eq1} = elem (m x) eq1
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
198 ... | false | record { eq = eq1 } with tchar¬Img m mono (m x) eq1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
199 ... | t = ⊥-elim (t (isImage x))
1029
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1028
diff changeset
200 s2i : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → (mono : Mono Sets m ) → (e : sequ a Bool (tchar m mono) (λ _ → true )) → image m (equ e)
1028
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1027
diff changeset
201 s2i {a} {b} m mono (elem y eq) with lem (image m y)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1027
diff changeset
202 ... | case1 im = im
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
203 isol : {a b : Obj (Sets {c}) } (m : Hom Sets b a) → (mono : Mono Sets m ) → IsoL Sets m (λ (e : sequ a Bool (tchar m mono) (λ _ → true )) → equ e )
1025
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1024
diff changeset
204 isol {a} {b} m mono = record { iso-L = record { ≅→ = b→s ; ≅← = b←s ;
1026
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1025
diff changeset
205 iso→ = extensionality Sets ( λ x → iso1 x )
1032
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
206 ; iso← = extensionality Sets ( λ x → iso2 x) } ; iso≈L = extensionality Sets ( λ s → iso3 s ) } where
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
207 b→s : Hom Sets b (sequ a Bool (tchar m mono) (λ _ → true))
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
208 b→s x = b2s m mono x
1023
227e1fe321ea using Bool and LEM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1022
diff changeset
209 b←s : Hom Sets (sequ a Bool (tchar m mono) (λ _ → true)) b
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
210 b←s (elem y eq) = i2b m (s2i m mono (elem y eq))
1032
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
211 iso3 : (s : sequ a Bool (tchar m mono) (λ _ → true)) → m (b←s s) ≡ equ s
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
212 iso3 (elem y eq) with lem (image m y)
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
213 ... | case1 (isImage x) = refl
1026
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1025
diff changeset
214 iso1 : (x : b) → b←s ( b→s x ) ≡ x
1025
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1024
diff changeset
215 iso1 x with tchar m mono (m x) | inspect (tchar m mono ) (m x)
1028
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1027
diff changeset
216 ... | true | record { eq = eq1 } = begin
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
217 b←s ( elem (m x) eq1 ) ≡⟨⟩
1032
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
218 i2b m (s2i m mono (elem (m x ) eq1 )) ≡⟨ cong (λ k → i2b m k) (image-uniq m mono (m x) (s2i m mono (elem (m x ) eq1 )) (isImage x) ) ⟩
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
219 i2b m (isImage x) ≡⟨⟩
1026
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1025
diff changeset
220 x ∎ where open ≡-Reasoning
1030
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1029
diff changeset
221 iso1 x | false | record { eq = eq1 } = ⊥-elim ( tchar¬Img m mono (m x) eq1 (isImage x))
1025
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1024
diff changeset
222 iso2 : (x : sequ a Bool (tchar m mono) (λ _ → true) ) → (Sets [ b→s o b←s ]) x ≡ id1 Sets (sequ a Bool (tchar m mono) (λ _ → true)) x
1032
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
223 iso2 (elem y eq) = begin
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
224 b→s ( b←s (elem y eq)) ≡⟨⟩
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
225 b2s m mono ( i2b m (s2i m mono (elem y eq))) ≡⟨⟩
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
226 b2s m mono x ≡⟨ elm-cong _ _ (iso21 x ) ⟩
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
227 elem (m x) eq1 ≡⟨ elm-cong _ _ mx=y ⟩
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
228 elem y eq ∎ where
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
229 open ≡-Reasoning
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
230 x : b
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
231 x = i2b m (s2i m mono (elem y eq))
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
232 eq1 : tchar m mono (m x) ≡ true
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
233 eq1 with lem (image m (m x))
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
234 ... | case1 t = refl
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
235 ... | case2 n = ⊥-elim (n (isImage x))
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
236 mx=y : m x ≡ y
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
237 mx=y = img-mx=y m (s2i m mono (elem y eq))
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
238 iso21 : (x : b) → equ (b2s m mono x ) ≡ m x
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
239 iso21 x with tchar m mono (m x) | inspect (tchar m mono) (m x)
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
240 ... | true | record {eq = eq1} = refl
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
241 ... | false | record { eq = eq1 } with tchar¬Img m mono (m x) eq1
c3b3faa791fa topos of Sets done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1031
diff changeset
242 ... | t = ⊥-elim (t (isImage x))
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243
1068
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
244 open import Polynominal (Sets {c} ) (sets {c})
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
245 A = Sets {c}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
246 Ω = Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
247 1 = One
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
248 ⊤ = λ _ → true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
249 ○ = λ _ → λ _ → !
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
250 _⊢_ : {a b : Obj A} (p : Poly a Ω b ) (q : Poly a Ω b ) → Set (suc c )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
251 _⊢_ {a} {b} p q = {c : Obj A} (h : Hom A c b ) → A [ Poly.f p o h ≈ ⊤ o ○ c ]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
252 → A [ Poly.f q ∙ h ≈ ⊤ o ○ c ]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
253 tl01 : {a b : Obj A} (p : Poly a Ω b ) (q : Poly a Ω b )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
254 → p ⊢ q → q ⊢ p → A [ Poly.f p ≈ Poly.f q ]
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
255 tl01 {a} {b} p q p<q q<p = extensionality Sets t1011 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
256 open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
257 t1011 : (s : b ) → Poly.f p s ≡ Poly.f q s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
258 t1011 x with Poly.f p x | inspect ( Poly.f p) x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
259 ... | true | record { eq = eq1 } = sym tt1 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
260 tt1 : Poly.f q _ ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
261 tt1 = cong (λ k → k !) (p<q _ ( extensionality Sets (λ x → eq1) ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
262 ... | false | record { eq = eq1 } with Poly.f q x | inspect (Poly.f q) x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
263 ... | true | record { eq = eq2 } = ⊥-elim ( ¬x≡t∧x≡f record { fst = eq1 ; snd = tt1 } ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
264 tt1 : Poly.f p _ ≡ true
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
265 tt1 = cong (λ k → k !) (q<p _ ( extensionality Sets (λ x → eq2) ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
266 ... | false | eq2 = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1034
diff changeset
268
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 open import graph
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 module ccc-from-graph {c₁ c₂ : Level } (G : Graph {c₁} {c₂}) where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 open import Relation.Binary.PropositionalEquality renaming ( cong to ≡-cong ) hiding ( [_] )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 open Graph
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 V = vertex G
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 E : V → V → Set c₂
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 E = edge G
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 data Objs : Set c₁ where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 atom : V → Objs
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 ⊤ : Objs
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 _∧_ : Objs → Objs → Objs
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 _<=_ : Objs → Objs → Objs
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 data Arrows : (b c : Objs ) → Set (c₁ ⊔ c₂)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 data Arrow : Objs → Objs → Set (c₁ ⊔ c₂) where --- case i
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 arrow : {a b : V} → E a b → Arrow (atom a) (atom b)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 π : {a b : Objs } → Arrow ( a ∧ b ) a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 π' : {a b : Objs } → Arrow ( a ∧ b ) b
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 ε : {a b : Objs } → Arrow ((a <= b) ∧ b ) a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 _* : {a b c : Objs } → Arrows (c ∧ b ) a → Arrow c ( a <= b ) --- case v
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 data Arrows where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 id : ( a : Objs ) → Arrows a a --- case i
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 ○ : ( a : Objs ) → Arrows a ⊤ --- case i
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 <_,_> : {a b c : Objs } → Arrows c a → Arrows c b → Arrows c (a ∧ b) -- case iii
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 iv : {b c d : Objs } ( f : Arrow d c ) ( g : Arrows b d ) → Arrows b c -- cas iv
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 _・_ : {a b c : Objs } (f : Arrows b c ) → (g : Arrows a b) → Arrows a c
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 id a ・ g = g
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 ○ a ・ g = ○ _
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 < f , g > ・ h = < f ・ h , g ・ h >
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 iv f g ・ h = iv f ( g ・ h )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 identityL : {A B : Objs} {f : Arrows A B} → (id B ・ f) ≡ f
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 identityL = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 identityR : {A B : Objs} {f : Arrows A B} → (f ・ id A) ≡ f
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 identityR {a} {a} {id a} = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 identityR {a} {⊤} {○ a} = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 identityR {a} {_} {< f , f₁ >} = cong₂ (λ j k → < j , k > ) identityR identityR
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 identityR {a} {b} {iv f g} = cong (λ k → iv f k ) identityR
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 assoc≡ : {a b c d : Objs} (f : Arrows c d) (g : Arrows b c) (h : Arrows a b) →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 (f ・ (g ・ h)) ≡ ((f ・ g) ・ h)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 assoc≡ (id a) g h = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 assoc≡ (○ a) g h = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 assoc≡ < f , f₁ > g h = cong₂ (λ j k → < j , k > ) (assoc≡ f g h) (assoc≡ f₁ g h)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 assoc≡ (iv f f1) g h = cong (λ k → iv f k ) ( assoc≡ f1 g h )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 -- positive intutionistic calculus
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 PL : Category c₁ (c₁ ⊔ c₂) (c₁ ⊔ c₂)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 PL = record {
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 Obj = Objs;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 Hom = λ a b → Arrows a b ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 _o_ = λ{a} {b} {c} x y → x ・ y ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 _≈_ = λ x y → x ≡ y ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 Id = λ{a} → id a ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 isCategory = record {
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 isEquivalence = record {refl = refl ; trans = trans ; sym = sym} ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 identityL = λ {a b f} → identityL {a} {b} {f} ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 identityR = λ {a b f} → identityR {a} {b} {f} ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 o-resp-≈ = λ {a b c f g h i} → o-resp-≈ {a} {b} {c} {f} {g} {h} {i} ;
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 associative = λ{a b c d f g h } → assoc≡ f g h
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 }
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 } where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 o-resp-≈ : {A B C : Objs} {f g : Arrows A B} {h i : Arrows B C} →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 f ≡ g → h ≡ i → (h ・ f) ≡ (i ・ g)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 o-resp-≈ refl refl = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 --------
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 --
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 -- Functor from Positive Logic to Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 --
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 -- open import Category.Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 -- postulate extensionality : { c₁ c₂ ℓ : Level} ( A : Category c₁ c₂ ℓ ) → Relation.Binary.PropositionalEquality.Extensionalit y c₂ c₂
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
348
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 open import Data.List
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 C = graphtocat.Chain G
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 tr : {a b : vertex G} → edge G a b → ((y : vertex G) → C y a) → (y : vertex G) → C y b
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 tr f x y = graphtocat.next f (x y)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 fobj : ( a : Objs ) → Set (c₁ ⊔ c₂)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 fobj (atom x) = ( y : vertex G ) → C y x
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 fobj ⊤ = One
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 fobj (a ∧ b) = ( fobj a /\ fobj b)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 fobj (a <= b) = fobj b → fobj a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 fmap : { a b : Objs } → Hom PL a b → fobj a → fobj b
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 amap : { a b : Objs } → Arrow a b → fobj a → fobj b
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 amap (arrow x) y = tr x y -- tr x
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 amap π ( x , y ) = x
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 amap π' ( x , y ) = y
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 amap ε (f , x ) = f x
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 amap (f *) x = λ y → fmap f ( x , y )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 fmap (id a) x = x
1020
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1019
diff changeset
370 fmap (○ a) x = !
999
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 fmap < f , g > x = ( fmap f x , fmap g x )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 fmap (iv x f) a = amap x ( fmap f a )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
373
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 -- CS is a map from Positive logic to Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 -- Sets is CCC, so we have a cartesian closed category generated by a graph
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 -- as a sub category of Sets
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 CS : Functor PL (Sets {c₁ ⊔ c₂})
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 FObj CS a = fobj a
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 FMap CS {a} {b} f = fmap {a} {b} f
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 isFunctor CS = isf where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 _+_ = Category._o_ PL
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 ++idR = IsCategory.identityR ( Category.isCategory PL )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 distr : {a b c : Obj PL} { f : Hom PL a b } { g : Hom PL b c } → (z : fobj a ) → fmap (g + f) z ≡ fmap g (fmap f z)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 distr {a} {a₁} {a₁} {f} {id a₁} z = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 distr {a} {a₁} {⊤} {f} {○ a₁} z = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 distr {a} {b} {c ∧ d} {f} {< g , g₁ >} z = cong₂ (λ j k → j , k ) (distr {a} {b} {c} {f} {g} z) (distr {a} {b} {d} {f} {g₁} z)
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 distr {a} {b} {c} {f} {iv {_} {_} {d} x g} z = adistr (distr {a} {b} {d} {f} {g} z) x where
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 adistr : fmap (g + f) z ≡ fmap g (fmap f z) →
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 ( x : Arrow d c ) → fmap ( iv x (g + f) ) z ≡ fmap ( iv x g ) (fmap f z )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 adistr eq x = cong ( λ k → amap x k ) eq
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 isf : IsFunctor PL Sets fobj fmap
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 IsFunctor.identity isf = extensionality Sets ( λ x → refl )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 IsFunctor.≈-cong isf refl = refl
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 IsFunctor.distr isf {a} {b} {c} {g} {f} = extensionality Sets ( λ z → distr {a} {b} {c} {g} {f} z )
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396
d89f2c8cf0f4 separate CCCSets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
397