Skip to content

Commit 8dce154

Browse files
authored
Merge pull request #1583 from Alizter/wc-misc-prod
Product functors, swap functor
2 parents 27e93b2 + 35510ac commit 8dce154

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

theories/WildCat/Prod.v

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Require Import Basics.
44
Require Import WildCat.Core.
55
Require Import WildCat.Equiv.
6+
Require Import Types.Prod.
67

78
(** * Product categories *)
89

@@ -116,3 +117,71 @@ Definition emap11 {A B C : Type} `{HasEquivs A} `{HasEquivs B} `{HasEquivs C}
116117
{a1 a2 : A} {b1 b2 : B} (fe1 : a1 $<~> a2)
117118
(fe2 : b1 $<~> b2) : (F a1 b1) $<~> (F a2 b2)
118119
:= @emap _ _ _ _ _ _ _ _ _ _ _ _ (uncurry F) _ _ (a1, b1) (a2, b2) (fe1, fe2).
120+
121+
(** ** Product functors *)
122+
123+
Global Instance is0functor_prod_functor {A B C D : Type}
124+
(F : A -> B) (G : C -> D) `{Is0Functor _ _ F, Is0Functor _ _ G}
125+
: Is0Functor (functor_prod F G).
126+
Proof.
127+
apply Build_Is0Functor.
128+
intros [a1 c1] [a2 c2] [f g].
129+
exact (fmap F f , fmap G g).
130+
Defined.
131+
132+
Global Instance is1functor_prod_functor {A B C D : Type}
133+
(F : A -> B) (G : C -> D) `{Is1Functor _ _ F, Is1Functor _ _ G}
134+
: Is1Functor (functor_prod F G).
135+
Proof.
136+
apply Build_Is1Functor.
137+
- intros [a1 c1] [a2 c2] [f1 g1] [f2 g2] [p q].
138+
exact (fmap2 F p , fmap2 G q).
139+
- intros [a c].
140+
exact (fmap_id F a, fmap_id G c).
141+
- intros [a1 c1] [a2 c2] [a3 c3] [f1 g1] [f2 g2].
142+
exact (fmap_comp F f1 f2 , fmap_comp G g1 g2).
143+
Defined.
144+
145+
Global Instance is0functor_fst {A B : Type} `{!IsGraph A, !IsGraph B}
146+
: Is0Functor (@fst A B).
147+
Proof.
148+
apply Build_Is0Functor.
149+
intros ? ? f; exact (fst f).
150+
Defined.
151+
152+
Global Instance is0functor_snd {A B : Type} `{!IsGraph A, !IsGraph B}
153+
: Is0Functor (@snd A B).
154+
Proof.
155+
apply Build_Is0Functor.
156+
intros ? ? f; exact (snd f).
157+
Defined.
158+
159+
(** Swap functor *)
160+
161+
Definition prod_swap {A B : Type} : A * B -> B * A
162+
:= fun '(a , b) => (b , a).
163+
164+
Global Instance isequiv_prod_swap {A B}
165+
: IsEquiv (@prod_swap A B)
166+
:= Build_IsEquiv _ _ prod_swap prod_swap
167+
(fun _ => idpath) (fun _ => idpath) (fun _ => idpath).
168+
169+
Global Instance is0functor_prod_swap {A B : Type} `{IsGraph A, IsGraph B}
170+
: Is0Functor (@prod_swap A B).
171+
Proof.
172+
snrapply Build_Is0Functor.
173+
intros a b.
174+
apply prod_swap.
175+
Defined.
176+
177+
Global Instance is1functor_prod_swap {A B : Type} `{Is1Cat A, Is1Cat B}
178+
: Is1Functor (@prod_swap A B).
179+
Proof.
180+
snrapply Build_Is1Functor.
181+
- intros a b f g.
182+
apply prod_swap.
183+
- intros a.
184+
reflexivity.
185+
- reflexivity.
186+
Defined.
187+

0 commit comments

Comments
 (0)