annotate CCCGraph.agda @ 860:d3cf372ac8cd

give update idempotent
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 05 Apr 2020 11:53:00 +0900
parents a115daa7d30e
children 484f19f16712 32c11e2fdf82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
779
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 open import Level
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 open import Category
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
3 module CCCgraph where
779
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import HomReasoning
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import cat-utility
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
7 open import Data.Product renaming (_×_ to _/\_ ) hiding ( <_,_> )
784
f27d966939f8 add CCC hom
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 783
diff changeset
8 open import Category.Constructions.Product
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
9 open import Relation.Binary.PropositionalEquality hiding ( [_] )
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
10 open import CCC
779
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 open Functor
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 -- ccc-1 : Hom A a 1 ≅ {*}
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 -- ccc-2 : Hom A c (a × b) ≅ (Hom A c a ) × ( Hom A c b )
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 -- ccc-3 : Hom A a (c ^ b) ≅ Hom A (a × b) c
6b4bd02efd80 CCC start
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
18 open import Category.Sets
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
19
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
20 ------------------------------------------------------
815
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
21 -- Sets is a CCC
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
22 ------------------------------------------------------
815
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
23
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
24 postulate extensionality : { c₁ c₂ ℓ : Level} ( A : Category c₁ c₂ ℓ ) → Relation.Binary.PropositionalEquality.Extensionality c₂ c₂
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
25
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
26 data One {l : Level} : Set l where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
27 OneObj : One -- () in Haskell ( or any one object set )
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
28
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
29 sets : {l : Level } → CCC (Sets {l})
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
30 sets {l} = record {
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
31 1 = One
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
32 ; ○ = λ _ → λ _ → OneObj
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
33 ; _∧_ = _∧_
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
34 ; <_,_> = <,>
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
35 ; π = π
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
36 ; π' = π'
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
37 ; _<=_ = _<=_
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
38 ; _* = _*
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
39 ; ε = ε
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
40 ; isCCC = isCCC
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
41 } where
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
42 1 : Obj Sets
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
43 1 = One
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
44 ○ : (a : Obj Sets ) → Hom Sets a 1
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
45 ○ a = λ _ → OneObj
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
46 _∧_ : Obj Sets → Obj Sets → Obj Sets
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
47 _∧_ a b = a /\ b
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
48 <,> : {a b c : Obj Sets } → Hom Sets c a → Hom Sets c b → Hom Sets c ( a ∧ b)
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
49 <,> f g = λ x → ( f x , g x )
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
50 π : {a b : Obj Sets } → Hom Sets (a ∧ b) a
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
51 π {a} {b} = proj₁
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
52 π' : {a b : Obj Sets } → Hom Sets (a ∧ b) b
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
53 π' {a} {b} = proj₂
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
54 _<=_ : (a b : Obj Sets ) → Obj Sets
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
55 a <= b = b → a
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
56 _* : {a b c : Obj Sets } → Hom Sets (a ∧ b) c → Hom Sets a (c <= b)
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
57 f * = λ x → λ y → f ( x , y )
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
58 ε : {a b : Obj Sets } → Hom Sets ((a <= b ) ∧ b) a
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
59 ε {a} {b} = λ x → ( proj₁ x ) ( proj₂ x )
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
60 isCCC : CCC.IsCCC Sets 1 ○ _∧_ <,> π π' _<=_ _* ε
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
61 isCCC = record {
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
62 e2 = e2
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
63 ; e3a = λ {a} {b} {c} {f} {g} → e3a {a} {b} {c} {f} {g}
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
64 ; e3b = λ {a} {b} {c} {f} {g} → e3b {a} {b} {c} {f} {g}
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
65 ; e3c = e3c
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
66 ; π-cong = π-cong
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
67 ; e4a = e4a
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
68 ; e4b = e4b
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
69 ; *-cong = *-cong
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
70 } where
793
f37f11e1b871 Hom a,b = Hom 1 b^a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 790
diff changeset
71 e2 : {a : Obj Sets} {f : Hom Sets a 1} → Sets [ f ≈ ○ a ]
f37f11e1b871 Hom a,b = Hom 1 b^a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 790
diff changeset
72 e2 {a} {f} = extensionality Sets ( λ x → e20 x )
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
73 where
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
74 e20 : (x : a ) → f x ≡ ○ a x
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
75 e20 x with f x
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
76 e20 x | OneObj = refl
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
77 e3a : {a b c : Obj Sets} {f : Hom Sets c a} {g : Hom Sets c b} →
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
78 Sets [ ( Sets [ π o ( <,> f g) ] ) ≈ f ]
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
79 e3a = refl
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
80 e3b : {a b c : Obj Sets} {f : Hom Sets c a} {g : Hom Sets c b} →
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
81 Sets [ Sets [ π' o ( <,> f g ) ] ≈ g ]
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
82 e3b = refl
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
83 e3c : {a b c : Obj Sets} {h : Hom Sets c (a ∧ b)} →
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
84 Sets [ <,> (Sets [ π o h ]) (Sets [ π' o h ]) ≈ h ]
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
85 e3c = refl
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
86 π-cong : {a b c : Obj Sets} {f f' : Hom Sets c a} {g g' : Hom Sets c b} →
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
87 Sets [ f ≈ f' ] → Sets [ g ≈ g' ] → Sets [ <,> f g ≈ <,> f' g' ]
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
88 π-cong refl refl = refl
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
89 e4a : {a b c : Obj Sets} {h : Hom Sets (c ∧ b) a} →
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
90 Sets [ Sets [ ε o <,> (Sets [ h * o π ]) π' ] ≈ h ]
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
91 e4a = refl
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
92 e4b : {a b c : Obj Sets} {k : Hom Sets c (a <= b)} →
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
93 Sets [ (Sets [ ε o <,> (Sets [ k o π ]) π' ]) * ≈ k ]
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
94 e4b = refl
795
030c5b87ed78 ccc to adjunction done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
95 *-cong : {a b c : Obj Sets} {f f' : Hom Sets (a ∧ b) c} →
790
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
96 Sets [ f ≈ f' ] → Sets [ f * ≈ f' * ]
1e7319868d77 Sets is CCC
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 789
diff changeset
97 *-cong refl = refl
787
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 786
diff changeset
98
830
232cea484067 graph to CCC again
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 829
diff changeset
99 module sets-from-graph where
787
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 786
diff changeset
100
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
101 ------------------------------------------------------
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
102 -- CCC generated from a graph
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
103 ------------------------------------------------------
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
104
802
7bc41fc7b563 graph with positive logic to Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
105 open import Relation.Binary.PropositionalEquality renaming ( cong to ≡-cong ) hiding ( [_] )
825
8f41ad966eaa rename discrete
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 824
diff changeset
106 open import graph
809
0976d576f5f6 <_,_> as function on Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 808
diff changeset
107 open graphtocat
799
82a8c1ab4ef5 graph to category
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 795
diff changeset
108
803
984d20c10c87 simpler graph to category
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 802
diff changeset
109 open Graph
984d20c10c87 simpler graph to category
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 802
diff changeset
110
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
111 data Objs (G : Graph {Level.zero} {Level.zero} ) : Set where -- formula
812
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
112 atom : (vertex G) → Objs G
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
113 ⊤ : Objs G
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
114 _∧_ : Objs G → Objs G → Objs G
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
115 _<=_ : Objs G → Objs G → Objs G
803
984d20c10c87 simpler graph to category
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 802
diff changeset
116
816
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
117 data Arrow (G : Graph ) : Objs G → Objs G → Set where --- proof
812
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
118 arrow : {a b : vertex G} → (edge G) a b → Arrow G (atom a) (atom b)
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
119 ○ : (a : Objs G ) → Arrow G a ⊤
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
120 π : {a b : Objs G } → Arrow G ( a ∧ b ) a
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
121 π' : {a b : Objs G } → Arrow G ( a ∧ b ) b
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
122 ε : {a b : Objs G } → Arrow G ((a <= b) ∧ b ) a
814
e4986625ddd7 add <= and <,>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 812
diff changeset
123 <_,_> : {a b c : Objs G } → Arrow G c a → Arrow G c b → Arrow G c (a ∧ b)
e4986625ddd7 add <= and <,>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 812
diff changeset
124 _* : {a b c : Objs G } → Arrow G (c ∧ b ) a → Arrow G c ( a <= b )
803
984d20c10c87 simpler graph to category
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 802
diff changeset
125
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
126 record SM {v : Level} : Set (suc v) where
806
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
127 field
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
128 graph : Graph {v} {v}
806
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
129 sobj : vertex graph → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
130 smap : { a b : vertex graph } → edge graph a b → sobj a → sobj b
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
131
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
132 open SM
803
984d20c10c87 simpler graph to category
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 802
diff changeset
133
802
7bc41fc7b563 graph with positive logic to Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
134 -- positive intutionistic calculus
811
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 810
diff changeset
135 PL : (G : SM) → Graph
812
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
136 PL G = record { vertex = Objs (graph G) ; edge = Arrow (graph G) }
806
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
137 DX : (G : SM) → Category Level.zero Level.zero Level.zero
811
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 810
diff changeset
138 DX G = GraphtoCat (PL G)
801
aa4fbd007247 using setoid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
139
802
7bc41fc7b563 graph with positive logic to Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
140 -- open import Category.Sets
7bc41fc7b563 graph with positive logic to Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
141 -- postulate extensionality : { c₁ c₂ ℓ : Level} ( A : Category c₁ c₂ ℓ ) → Relation.Binary.PropositionalEquality.Extensionality c₂ c₂
801
aa4fbd007247 using setoid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
142
812
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
143 fobj : {G : SM} ( a : Objs (graph G) ) → Set
806
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
144 fobj {G} (atom x) = sobj G x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
145 fobj {G} (a ∧ b) = (fobj {G} a ) /\ (fobj {G} b )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
146 fobj {G} (a <= b) = fobj {G} b → fobj {G} a
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
147 fobj ⊤ = One
812
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
148 amap : {G : SM} { a b : Objs (graph G) } → Arrow (graph G) a b → fobj {G} a → fobj {G} b
816
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
149 amap {G} (arrow x) = smap G x
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
150 amap (○ a) _ = OneObj
816
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
151 amap π ( x , _) = x
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
152 amap π'( _ , x) = x
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
153 amap ε ( f , x ) = f x
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
154 amap < f , g > x = (amap f x , amap g x)
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
155 amap (f *) x = λ y → amap f ( x , y )
812
4ff300e1e98c graph to CCC done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 811
diff changeset
156 fmap : {G : SM} { a b : Objs (graph G) } → Hom (DX G) a b → fobj {G} a → fobj {G} b
816
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
157 fmap {G} {a} (id a) = λ z → z
4e48b331020a simpler
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 815
diff changeset
158 fmap {G} (next x f ) = Sets [ amap {G} x o fmap f ]
805
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
159
815
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
160 -- CS is a map from Positive logic to Sets
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
161 -- Sets is CCC, so we have a cartesian closed category generated by a graph
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
162 -- as a sub category of Sets
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
163
809
0976d576f5f6 <_,_> as function on Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 808
diff changeset
164 CS : (G : SM ) → Functor (DX G) (Sets {Level.zero})
0976d576f5f6 <_,_> as function on Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 808
diff changeset
165 FObj (CS G) a = fobj a
0976d576f5f6 <_,_> as function on Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 808
diff changeset
166 FMap (CS G) {a} {b} f = fmap {G} {a} {b} f
0976d576f5f6 <_,_> as function on Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 808
diff changeset
167 isFunctor (CS G) = isf where
805
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
168 _++_ = Category._o_ (DX G)
811
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 810
diff changeset
169 ++idR = IsCategory.identityR ( Category.isCategory ( DX G ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 810
diff changeset
170 distr : {a b c : Obj (DX G)} { f : Hom (DX G) a b } { g : Hom (DX G) b c } → (z : fobj {G} a ) → fmap (g ++ f) z ≡ fmap g (fmap f z)
815
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
171 distr {a} {b} {c} {f} {next {b} {d} {c} x g} z = adistr (distr {a} {b} {d} {f} {g} z ) x where
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
172 adistr : fmap (g ++ f) z ≡ fmap g (fmap f z) →
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
173 ( x : Arrow (graph G) d c ) → fmap ( next x (g ++ f) ) z ≡ fmap ( next x g ) (fmap f z )
bb9fd483f560 simpler proof of CCC from graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 814
diff changeset
174 adistr eq x = cong ( λ k → amap x k ) eq
811
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 810
diff changeset
175 distr {a} {b} {b} {f} {id b} z = refl
805
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
176 isf : IsFunctor (DX G) Sets fobj fmap
809
0976d576f5f6 <_,_> as function on Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 808
diff changeset
177 IsFunctor.identity isf = extensionality Sets ( λ x → refl )
802
7bc41fc7b563 graph with positive logic to Sets
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
178 IsFunctor.≈-cong isf refl = refl
811
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 810
diff changeset
179 IsFunctor.distr isf {a} {b} {c} {g} {f} = extensionality Sets ( λ z → distr {a} {b} {c} {g} {f} z )
801
aa4fbd007247 using setoid
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 800
diff changeset
180
830
232cea484067 graph to CCC again
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 829
diff changeset
181
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
182 ------------------------------------------------------
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
183 -- Cart Category of CCC and CCC preserving Functor
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
184 ------------------------------------------------------
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
185
818
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
186 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
187 --- SubCategoy SC F A is a category with Obj = FObj F, Hom = FMap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
188 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
189 --- CCC ( SC (CS G)) Sets have to be proved
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
190 --- SM can be eliminated if we have
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
191 --- sobj (a : vertex g ) → {a} a set have only a
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
192 --- smap (a b : vertex g ) → {a} → {b}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
193
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
194
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
195 record CCCObj { c₁ c₂ ℓ : Level} : Set (suc (c₁ ⊔ c₂ ⊔ ℓ)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
196 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
197 cat : Category c₁ c₂ ℓ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
198 ccc : CCC cat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
199
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
200 open CCCObj
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
201
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
202 record CCCMap {c₁ c₂ ℓ : Level} (A B : CCCObj {c₁} {c₂} {ℓ} ) : Set (suc (c₁ ⊔ c₂ ⊔ ℓ )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
203 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
204 cmap : Functor (cat A ) (cat B )
820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
205 ccf : CCC (cat A) → CCC (cat B)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
206
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
207 open import Category.Cat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
208
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
209 open CCCMap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
210 open import Relation.Binary.Core
818
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
211
820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
212 Cart : {c₁ c₂ ℓ : Level} → Category (suc (c₁ ⊔ c₂ ⊔ ℓ)) (suc (c₁ ⊔ c₂ ⊔ ℓ))(suc (c₁ ⊔ c₂ ⊔ ℓ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
213 Cart {c₁} {c₂} {ℓ} = record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
214 Obj = CCCObj {c₁} {c₂} {ℓ}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
215 ; Hom = CCCMap
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
216 ; _o_ = λ {A} {B} {C} f g → record { cmap = (cmap f) ○ ( cmap g ) ; ccf = λ _ → ccf f ( ccf g (ccc A )) }
820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
217 ; _≈_ = λ {a} {b} f g → cmap f ≃ cmap g
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
218 ; Id = λ {a} → record { cmap = identityFunctor ; ccf = λ x → x }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
219 ; isCategory = record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
220 isEquivalence = λ {A} {B} → record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
221 refl = λ {f} → let open ≈-Reasoning (CAT) in refl-hom {cat A} {cat B} {cmap f}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
222 ; sym = λ {f} {g} → let open ≈-Reasoning (CAT) in sym-hom {cat A} {cat B} {cmap f} {cmap g}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
223 ; trans = λ {f} {g} {h} → let open ≈-Reasoning (CAT) in trans-hom {cat A} {cat B} {cmap f} {cmap g} {cmap h} }
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
224 ; identityL = λ {x} {y} {f} → let open ≈-Reasoning (CAT) in idL {cat x} {cat y} {cmap f} {_} {_}
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
225 ; identityR = λ {x} {y} {f} → let open ≈-Reasoning (CAT) in idR {cat x} {cat y} {cmap f}
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
226 ; o-resp-≈ = λ {x} {y} {z} {f} {g} {h} {i} → IsCategory.o-resp-≈ ( Category.isCategory CAT) {cat x}{cat y}{cat z} {cmap f} {cmap g} {cmap h} {cmap i}
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
227 ; associative = λ {a} {b} {c} {d} {f} {g} {h} → let open ≈-Reasoning (CAT) in assoc {cat a} {cat b} {cat c} {cat d} {cmap f} {cmap g} {cmap h}
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
228 }}
818
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
229
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
230 ------------------------------------------------------
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
231 -- Grph Category of Graph and Graph mapping
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
232 ------------------------------------------------------
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
233
825
8f41ad966eaa rename discrete
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 824
diff changeset
234 open import graph
818
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
235 open Graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
236
825
8f41ad966eaa rename discrete
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 824
diff changeset
237 record GMap {v v' : Level} (x y : Graph {v} {v'} ) : Set (suc (v ⊔ v') ) where
820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
238 field
818
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
239 vmap : vertex x → vertex y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
240 emap : {a b : vertex x} → edge x a b → edge y (vmap a) (vmap b)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 817
diff changeset
241
820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
242 open GMap
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
243
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
244 open import Relation.Binary.HeterogeneousEquality using (_≅_;refl ) renaming ( sym to ≅-sym ; trans to ≅-trans ; cong to ≅-cong )
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
245
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
246 data [_]_==_ {c₁ c₂ } (C : Graph {c₁} {c₂} ) {A B : vertex C} (f : edge C A B)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
247 : ∀{X Y : vertex C} → edge C X Y → Set (suc (c₁ ⊔ c₂ )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
248 mrefl : {g : edge C A B} → (eqv : f ≡ g ) → [ C ] f == g
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
249
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
250 _=m=_ : ∀ {c₁ c₂ } {C D : Graph {c₁} {c₂} }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
251 → (F G : GMap C D) → Set (suc (c₂ ⊔ c₁))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
252 _=m=_ {C = C} {D = D} F G = ∀{A B : vertex C} → (f : edge C A B) → [ D ] emap F f == emap G f
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
253
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
254 _&_ : {v v' : Level} {x y z : Graph {v} {v'}} ( f : GMap y z ) ( g : GMap x y ) → GMap x z
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
255 f & g = record { vmap = λ x → vmap f ( vmap g x ) ; emap = λ x → emap f ( emap g x ) }
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
256
829
6c5cfb9b333e fix deduction theorem
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 826
diff changeset
257 Grph : {v v' : Level} → Category (suc (v ⊔ v')) (suc (v ⊔ v')) (suc ( v ⊔ v'))
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
258 Grph {v} {v'} = record {
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
259 Obj = Graph {v} {v'}
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
260 ; Hom = GMap {v} {v'}
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
261 ; _o_ = _&_
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
262 ; _≈_ = _=m=_
820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
263 ; Id = record { vmap = λ y → y ; emap = λ f → f }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
264 ; isCategory = record {
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
265 isEquivalence = λ {A} {B} → ise
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
266 ; identityL = λ e → mrefl refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
267 ; identityR = λ e → mrefl refl
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
268 ; o-resp-≈ = m--resp-≈
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
269 ; associative = λ e → mrefl refl
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
270 }} where
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
271 msym : {v v' : Level} {x y : Graph {v} {v'} } { f g : GMap x y } → f =m= g → g =m= f
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
272 msym {_} {_} {x} {y} f=g f = lemma ( f=g f ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
273 lemma : ∀{a b c d} {f : edge y a b} {g : edge y c d} → [ y ] f == g → [ y ] g == f
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
274 lemma (mrefl Ff≈Gf) = mrefl (sym Ff≈Gf)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
275 mtrans : {v v' : Level} {x y : Graph {v} {v'} } { f g h : GMap x y } → f =m= g → g =m= h → f =m= h
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
276 mtrans {_} {_} {x} {y} f=g g=h f = lemma ( f=g f ) ( g=h f ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
277 lemma : ∀{a b c d e f} {p : edge y a b} {q : edge y c d} → {r : edge y e f} → [ y ] p == q → [ y ] q == r → [ y ] p == r
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
278 lemma (mrefl eqv) (mrefl eqv₁) = mrefl ( trans eqv eqv₁ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
279 ise : {v v' : Level} {x y : Graph {v} {v'}} → IsEquivalence {_} {suc v ⊔ suc v' } {_} ( _=m=_ {v} {v'} {x} {y})
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
280 ise = record {
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
281 refl = λ f → mrefl refl
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
282 ; sym = msym
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
283 ; trans = mtrans
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
284 }
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
285 m--resp-≈ : {v v' : Level} {A B C : Graph {v} {v'} }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
286 {f g : GMap A B} {h i : GMap B C} → f =m= g → h =m= i → ( h & f ) =m= ( i & g )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
287 m--resp-≈ {_} {_} {A} {B} {C} {f} {g} {h} {i} f=g h=i e =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
288 lemma (emap f e) (emap g e) (emap i (emap g e)) (f=g e) (h=i ( emap g e )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
289 lemma : {a b c d : vertex B } {z w : vertex C } (ϕ : edge B a b) (ψ : edge B c d) (π : edge C z w) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
290 [ B ] ϕ == ψ → [ C ] (emap h ψ) == π → [ C ] (emap h ϕ) == π
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
291 lemma _ _ _ (mrefl refl) (mrefl refl) = mrefl refl
820
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
292
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
293 ------------------------------------------------------
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
294 --- CCC → Grph Forgetful functor
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
295 ------------------------------------------------------
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
296
822
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
297 ≃-cong : {c₁ c₂ ℓ : Level} (B : Category c₁ c₂ ℓ ) → {a b a' b' : Obj B }
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
298 → { f f' : Hom B a b }
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
299 → { g g' : Hom B a' b' }
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
300 → [_]_~_ B f g → B [ f ≈ f' ] → B [ g ≈ g' ] → [_]_~_ B f' g'
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
301 ≃-cong B {a} {b} {a'} {b'} {f} {f'} {g} {g'} (refl {g2} eqv) f=f' g=g' = let open ≈-Reasoning B in refl {_} {_} {_} {B} {a'} {b'} {f'} {g'} ( begin
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
302 f'
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
303 ≈↑⟨ f=f' ⟩
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
304 f
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
305 ≈⟨ eqv ⟩
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
306 g
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
307 ≈⟨ g=g' ⟩
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
308 g'
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
309 ∎ )
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
310
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
311 fobj : {c₁ c₂ ℓ : Level} → Obj (Cart {c₁} {c₂} {ℓ} ) → Obj (Grph {c₁} {c₂})
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
312 fobj a = record { vertex = Obj (cat a) ; edge = Hom (cat a) }
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
313 fmap : {c₁ c₂ ℓ : Level} → {a b : Obj (Cart {c₁} {c₂} {ℓ} ) } → Hom (Cart {c₁} {c₂} {ℓ} ) a b → Hom (Grph {c₁} {c₂}) ( fobj a ) ( fobj b )
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
314 fmap f = record { vmap = FObj (cmap f) ; emap = FMap (cmap f) }
822
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
315
823
f57c9603d989 add ≈-to-≡ assumption
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 822
diff changeset
316 UX : {c₁ c₂ ℓ : Level} → ( ≈-to-≡ : (A : Category c₁ c₂ ℓ ) → {a b : Obj A} → {f g : Hom A a b} → A [ f ≈ g ] → f ≡ g )
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
317 → Functor (Cart {c₁} {c₂} {ℓ} ) (Grph {c₁} {c₂})
823
f57c9603d989 add ≈-to-≡ assumption
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 822
diff changeset
318 FObj (UX {c₁} {c₂} {ℓ} ≈-to-≡ ) a = fobj a
f57c9603d989 add ≈-to-≡ assumption
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 822
diff changeset
319 FMap (UX ≈-to-≡) f = fmap f
f57c9603d989 add ≈-to-≡ assumption
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 822
diff changeset
320 isFunctor (UX {c₁} {c₂} {ℓ} ≈-to-≡) = isf where
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
321 -- if we don't need ≈-cong ( i.e. f ≈ g → UX f =m= UX g ), all lemmas are not necessary
822
4c0580d9dda4 from cart to graph, hom equality to set equality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 821
diff changeset
322 open import HomReasoning
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
323 isf : IsFunctor (Cart {c₁} {c₂} {ℓ} ) (Grph {c₁} {c₂}) fobj fmap
824
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
324 IsFunctor.identity isf {a} {b} {f} e = mrefl refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
325 IsFunctor.distr isf f = mrefl refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
326 IsFunctor.≈-cong isf {a} {b} {f} {g} eq {x} {y} e = lemma (extensionality Sets ( λ z → lemma4 (
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
327 ≃-cong (cat b) (eq (id1 (cat a) z)) (IsFunctor.identity (Functor.isFunctor (cmap f))) (IsFunctor.identity (Functor.isFunctor (cmap g)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
328 ))) (eq e) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
329 lemma4 : {x y : vertex (fobj b) } → [_]_~_ (cat b) (id1 (cat b) x) (id1 (cat b) y) → x ≡ y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
330 lemma4 (refl eqv) = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
331 lemma : vmap (fmap f) ≡ vmap (fmap g) → [ cat b ] FMap (cmap f) e ~ FMap (cmap g) e → [ fobj b ] emap (fmap f) e == emap (fmap g) e
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
332 lemma refl (refl eqv) = mrefl ( ≈-to-≡ (cat b) eqv )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 823
diff changeset
333
821
fbbc9c03bfed Grp and Cart
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 820
diff changeset
334
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
335 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
336 --- open ccc-from-graph
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
337 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
338 --- sm : {v : Level } → Graph {v} → SM {v}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
339 --- SM.graph (sm g) = g
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
340 --- SM.sobj (sm g) = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
341 --- SM.smap (sm g) = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
342 ---
826
d1569e80fe0b fix comment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
343 --- HX : {v : Level } ( x : Obj (Grph {v}) ) → Obj (Grph {v})
817
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
344 --- HX {v} x = {!!} -- FObj UX ( record { cat = Sets {v} ; ccc = sets } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
345 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
346 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
347 ---
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 816
diff changeset
348 ---