Mercurial > hg > Members > kono > Proof > category
annotate HomReasoning.agda @ 766:c30ca91f3a76
Applicative all done
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Dec 2017 09:25:44 +0900 |
parents | 984518c56e96 |
children | 340708e8d54f |
rev | line source |
---|---|
56 | 1 module HomReasoning where |
31 | 2 |
3 -- Shinji KONO <kono@ie.u-ryukyu.ac.jp> | |
4 | |
5 open import Category -- https://github.com/konn/category-agda | |
6 open import Level | |
7 open Functor | |
8 | |
9 | |
10 -- F(f) | |
11 -- F(a) ---→ F(b) | |
12 -- | | | |
13 -- |t(a) |t(b) G(f)t(a) = t(b)F(f) | |
14 -- | | | |
15 -- v v | |
16 -- G(a) ---→ G(b) | |
17 -- G(f) | |
18 | |
19 record IsNTrans {c₁ c₂ ℓ c₁′ c₂′ ℓ′ : Level} (D : Category c₁ c₂ ℓ) (C : Category c₁′ c₂′ ℓ′) | |
20 ( F G : Functor D C ) | |
21 (TMap : (A : Obj D) → Hom C (FObj F A) (FObj G A)) | |
22 : Set (suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁′ ⊔ c₂′ ⊔ ℓ′)) where | |
23 field | |
130 | 24 commute : {a b : Obj D} {f : Hom D a b} |
31 | 25 → C [ C [ ( FMap G f ) o ( TMap a ) ] ≈ C [ (TMap b ) o (FMap F f) ] ] |
26 | |
130 | 27 record NTrans {c₁ c₂ ℓ c₁′ c₂′ ℓ′ : Level} (domain : Category c₁ c₂ ℓ) (codomain : Category c₁′ c₂′ ℓ′) |
28 (F G : Functor domain codomain ) | |
31 | 29 : Set (suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁′ ⊔ c₂′ ⊔ ℓ′)) where |
30 field | |
31 TMap : (A : Obj domain) → Hom codomain (FObj F A) (FObj G A) | |
32 isNTrans : IsNTrans domain codomain F G TMap | |
33 | |
34 | |
35 module ≈-Reasoning {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) where | |
36 open import Relation.Binary.Core | |
37 | |
38 _o_ : {a b c : Obj A } ( x : Hom A a b ) ( y : Hom A c a ) → Hom A c b | |
39 x o y = A [ x o y ] | |
40 | |
41 _≈_ : {a b : Obj A } → Rel (Hom A a b) ℓ | |
42 x ≈ y = A [ x ≈ y ] | |
43 | |
44 infixr 9 _o_ | |
45 infix 4 _≈_ | |
46 | |
47 refl-hom : {a b : Obj A } { x : Hom A a b } → x ≈ x | |
48 refl-hom = IsEquivalence.refl (IsCategory.isEquivalence ( Category.isCategory A )) | |
49 | |
50 trans-hom : {a b : Obj A } { x y z : Hom A a b } → | |
51 x ≈ y → y ≈ z → x ≈ z | |
52 trans-hom b c = ( IsEquivalence.trans (IsCategory.isEquivalence ( Category.isCategory A ))) b c | |
53 | |
54 -- some short cuts | |
55 | |
56 car : {a b c : Obj A } {x y : Hom A a b } { f : Hom A c a } → | |
57 x ≈ y → ( x o f ) ≈ ( y o f ) | |
58 car {f} eq = ( IsCategory.o-resp-≈ ( Category.isCategory A )) ( refl-hom ) eq | |
59 | |
60 cdr : {a b c : Obj A } {x y : Hom A a b } { f : Hom A b c } → | |
61 x ≈ y → f o x ≈ f o y | |
62 cdr {f} eq = ( IsCategory.o-resp-≈ ( Category.isCategory A )) eq (refl-hom ) | |
63 | |
64 id : (a : Obj A ) → Hom A a a | |
65 id a = (Id {_} {_} {_} {A} a) | |
66 | |
479
a5034bdf6f38
Comma Category with A B C
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
460
diff
changeset
|
67 idL : {a b : Obj A } { f : Hom A a b } → id b o f ≈ f |
31 | 68 idL = IsCategory.identityL (Category.isCategory A) |
69 | |
70 idR : {a b : Obj A } { f : Hom A a b } → f o id a ≈ f | |
71 idR = IsCategory.identityR (Category.isCategory A) | |
72 | |
73 sym : {a b : Obj A } { f g : Hom A a b } → f ≈ g → g ≈ f | |
74 sym = IsEquivalence.sym (IsCategory.isEquivalence (Category.isCategory A)) | |
75 | |
455 | 76 sym-hom = sym |
77 | |
299
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
78 -- working on another cateogry |
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
79 idL1 : { c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) {a b : Obj A } { f : Hom A b a } → A [ A [ Id {_} {_} {_} {A} a o f ] ≈ f ] |
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
80 idL1 A = IsCategory.identityL (Category.isCategory A) |
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
81 |
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
82 idR1 : { c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) {a b : Obj A } { f : Hom A a b } → A [ A [ f o Id {_} {_} {_} {A} a ] ≈ f ] |
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
83 idR1 A = IsCategory.identityR (Category.isCategory A) |
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
84 |
693 | 85 ≈←≡ : {a b : Obj A } { x y : Hom A a b } → (x≈y : x ≡ y ) → x ≈ y |
86 ≈←≡ refl = refl-hom | |
75 | 87 |
693 | 88 -- Ho← to prove this? |
89 -- ≡←≈ : {a b : Obj A } { x y : Hom A a b } → (x≈y : x ≈ y ) → x ≡ y | |
90 -- ≡←≈ x≈y = irr x≈y | |
91 | |
75 | 92 ≡-cong : { c₁′ c₂′ ℓ′ : Level} {B : Category c₁′ c₂′ ℓ′} {x y : Obj B } { a b : Hom B x y } {x' y' : Obj A } → |
420
3e44951b9bdb
refl in free-monoid trouble
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
299
diff
changeset
|
93 (f : Hom B x y → Hom A x' y' ) → a ≡ b → f a ≈ f b |
693 | 94 ≡-cong f refl = ≈←≡ refl |
75 | 95 |
67 | 96 -- cong-≈ : { c₁′ c₂′ ℓ′ : Level} {B : Category c₁′ c₂′ ℓ′} {x y : Obj B } { a b : Hom B x y } {x' y' : Obj A } → |
97 -- B [ a ≈ b ] → (f : Hom B x y → Hom A x' y' ) → f a ≈ f b | |
75 | 98 -- cong-≈ eq f = {!!} |
67 | 99 |
69
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
100 assoc : {a b c d : Obj A } {f : Hom A c d} {g : Hom A b c} {h : Hom A a b} |
299
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
101 → f o ( g o h ) ≈ ( f o g ) o h |
31 | 102 assoc = IsCategory.associative (Category.isCategory A) |
103 | |
299
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
104 -- working on another cateogry |
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
105 assoc1 : { c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) {a b c d : Obj A } {f : Hom A c d} {g : Hom A b c} {h : Hom A a b} |
69
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
106 → A [ A [ f o ( A [ g o h ] ) ] ≈ A [ ( A [ f o g ] ) o h ] ] |
299
8c72f5284bc8
remove module parameter from yoneda functor
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
253
diff
changeset
|
107 assoc1 A = IsCategory.associative (Category.isCategory A) |
69
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
108 |
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
109 distr : { c₁ c₂ ℓ : Level} {A : Category c₁ c₂ ℓ} |
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
110 { c₁′ c₂′ ℓ′ : Level} {D : Category c₁′ c₂′ ℓ′} (T : Functor D A) → {a b c : Obj D} {g : Hom D b c} { f : Hom D a b } |
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
111 → A [ FMap T ( D [ g o f ] ) ≈ A [ FMap T g o FMap T f ] ] |
75 | 112 distr T = IsFunctor.distr ( isFunctor T ) |
113 | |
114 resp : {a b c : Obj A} {f g : Hom A a b} {h i : Hom A b c} → f ≈ g → h ≈ i → (h o f) ≈ (i o g) | |
115 resp = IsCategory.o-resp-≈ (Category.isCategory A) | |
116 | |
117 fcong : { c₁ c₂ ℓ : Level} {C : Category c₁ c₂ ℓ} | |
118 { c₁′ c₂′ ℓ′ : Level} {D : Category c₁′ c₂′ ℓ′} {a b : Obj C} {f g : Hom C a b} → (T : Functor C D) → C [ f ≈ g ] → D [ FMap T f ≈ FMap T g ] | |
119 fcong T = IsFunctor.≈-cong (isFunctor T) | |
31 | 120 |
121 open NTrans | |
69
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
122 nat : { c₁ c₂ ℓ : Level} {A : Category c₁ c₂ ℓ} { c₁′ c₂′ ℓ′ : Level} {D : Category c₁′ c₂′ ℓ′} |
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
123 {a b : Obj D} {f : Hom D a b} {F G : Functor D A } |
31 | 124 → (η : NTrans D A F G ) |
69
84a150c980ce
generalized distr and assco1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
67
diff
changeset
|
125 → A [ A [ FMap G f o TMap η a ] ≈ A [ TMap η b o FMap F f ] ] |
130 | 126 nat η = IsNTrans.commute ( isNTrans η ) |
31 | 127 |
460 | 128 nat1 : { c₁ c₂ ℓ : Level} {A : Category c₁ c₂ ℓ} { c₁′ c₂′ ℓ′ : Level} {D : Category c₁′ c₂′ ℓ′} |
129 {a b : Obj D} {F G : Functor D A } | |
130 → (η : NTrans D A F G ) → (f : Hom D a b) | |
131 → A [ A [ FMap G f o TMap η a ] ≈ A [ TMap η b o FMap F f ] ] | |
132 nat1 η f = IsNTrans.commute ( isNTrans η ) | |
133 | |
606 | 134 infix 3 _∎ |
31 | 135 infixr 2 _≈⟨_⟩_ _≈⟨⟩_ |
168 | 136 infixr 2 _≈↑⟨_⟩_ |
31 | 137 infix 1 begin_ |
138 | |
139 ------ If we have this, for example, as an axiom of a category, we can use ≡-Reasoning directly | |
140 -- ≈-to-≡ : {a b : Obj A } { x y : Hom A a b } → A [ x ≈ y ] → x ≡ y | |
141 -- ≈-to-≡ refl-hom = refl | |
142 | |
143 data _IsRelatedTo_ { a b : Obj A } ( x y : Hom A a b ) : | |
144 Set (suc (c₁ ⊔ c₂ ⊔ ℓ )) where | |
145 relTo : (x≈y : x ≈ y ) → x IsRelatedTo y | |
146 | |
147 begin_ : { a b : Obj A } { x y : Hom A a b } → | |
148 x IsRelatedTo y → x ≈ y | |
149 begin relTo x≈y = x≈y | |
150 | |
151 _≈⟨_⟩_ : { a b : Obj A } ( x : Hom A a b ) → { y z : Hom A a b } → | |
152 x ≈ y → y IsRelatedTo z → x IsRelatedTo z | |
153 _ ≈⟨ x≈y ⟩ relTo y≈z = relTo (trans-hom x≈y y≈z) | |
154 | |
168 | 155 _≈↑⟨_⟩_ : { a b : Obj A } ( x : Hom A a b ) → { y z : Hom A a b } → |
156 y ≈ x → y IsRelatedTo z → x IsRelatedTo z | |
157 _ ≈↑⟨ y≈x ⟩ relTo y≈z = relTo (trans-hom ( sym y≈x ) y≈z) | |
158 | |
31 | 159 _≈⟨⟩_ : { a b : Obj A } ( x : Hom A a b ) → { y : Hom A a b } → x IsRelatedTo y → x IsRelatedTo y |
160 _ ≈⟨⟩ x∼y = x∼y | |
161 | |
162 _∎ : { a b : Obj A } ( x : Hom A a b ) → x IsRelatedTo x | |
163 _∎ _ = relTo refl-hom | |
164 | |
56 | 165 -- an example |
166 | |
167 Lemma61 : {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) → | |
168 { a : Obj A } ( b : Obj A ) → | |
169 ( f : Hom A a b ) | |
170 → A [ A [ (Id {_} {_} {_} {A} b) o f ] ≈ f ] | |
171 Lemma61 c b g = -- IsCategory.identityL (Category.isCategory c) | |
606 | 172 let open ≈-Reasoning (c) in begin |
173 c [ ( Id {_} {_} {_} {c} b ) o g ] | |
56 | 174 ≈⟨ IsCategory.identityL (Category.isCategory c) ⟩ |
175 g | |
176 ∎ | |
253 | 177 |
178 Lemma62 : {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) → | |
179 { a b : Obj A } → | |
180 ( f g : Hom A a b ) | |
181 → A [ A [ (Id {_} {_} {_} {A} b) o f ] ≈ A [ (Id {_} {_} {_} {A} b) o g ] ] | |
182 → A [ g ≈ f ] | |
183 Lemma62 A {a} {b} f g 1g=1f = let open ≈-Reasoning A in | |
184 begin | |
185 g | |
186 ≈↑⟨ idL ⟩ | |
187 id b o g | |
188 ≈↑⟨ 1g=1f ⟩ | |
189 id b o f | |
190 ≈⟨ idL ⟩ | |
191 f | |
192 ∎ |