Skip to content

Commit 225a9a8

Browse files
committed
WildCat: generalize a couple of proofs from Bifunctor.v to Prod.v
1 parent 7c5ce31 commit 225a9a8

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

theories/WildCat/Bifunctor.v

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,8 @@ Definition Build_Is0Bifunctor'' {A B C : Type}
3131
`{!forall a, Is0Functor (F a), !forall b, Is0Functor (flip F b)}
3232
: Is0Bifunctor F.
3333
Proof.
34-
snrapply Build_Is0Bifunctor.
35-
2,3: exact _.
36-
snrapply Build_Is0Functor.
37-
intros [a b] [a' b'] [f g].
38-
change (F a b $-> F a' b').
39-
exact (fmap (flip F b') f $o fmap (F a) g).
34+
(* The first condition follows from [is0functor_prod_is0functor]. *)
35+
rapply Build_Is0Bifunctor.
4036
Defined.
4137

4238
(** *** 1-functorial action *)
@@ -109,16 +105,7 @@ Definition Build_Is1Bifunctor'' {A B C : Type}
109105
: Is1Bifunctor F.
110106
Proof.
111107
snrapply Build_Is1Bifunctor.
112-
- snrapply Build_Is1Functor.
113-
+ intros [a b] [a' b'] [f g] [f' g'] [p p']; unfold fst, snd in * |- .
114-
exact (fmap2 (F a) p' $@@ fmap2 (flip F b') p).
115-
+ intros [a b].
116-
exact ((fmap_id (F a) b $@@ fmap_id (flip F b) _) $@ cat_idr _).
117-
+ intros [a b] [a' b'] [a'' b''] [f g] [f' g']; unfold fst, snd in * |- .
118-
refine ((fmap_comp (F a) g g' $@@ fmap_comp (flip F b'') f f') $@ _).
119-
nrefine (cat_assoc_opp _ _ _ $@ (_ $@R _) $@ cat_assoc _ _ _).
120-
refine (cat_assoc _ _ _ $@ (_ $@L _^$) $@ cat_assoc_opp _ _ _).
121-
nrapply bifunctor_coh.
108+
- exact _. (* [is1functor_prod_is1functor]. *)
122109
- exact _.
123110
- exact _.
124111
- intros a0 a1 f b0 b1 g.

theories/WildCat/Prod.v

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,42 @@ Global Instance is1functor_functor_uncurried10 {A B C : Type}
221221
: Is1Functor (fun a => F (a, b))
222222
:= is1functor_compose (fun a => (a, b)) F.
223223

224+
(** Conversely, if [F : A * B -> C] is a 0-functor in each variable, then it is a 0-functor. *)
225+
Definition is0functor_prod_is0functor {A B C : Type}
226+
`{IsGraph A, IsGraph B, Is01Cat C} (F : A * B -> C)
227+
`{!forall a, Is0Functor (fun b => F (a,b)), !forall b, Is0Functor (fun a => F (a,b))}
228+
: Is0Functor F.
229+
Proof.
230+
snrapply Build_Is0Functor.
231+
intros [a b] [a' b'] [f g].
232+
exact (fmap (fun a0 => F (a0,b')) f $o fmap (fun b0 => F (a,b0)) g).
233+
Defined.
234+
(** TODO: If we make this an instance, will it cause typeclass search to spin? *)
235+
Hint Immediate is0functor_prod_is0functor : typeclass_instances.
236+
237+
(** And if [F : A * B -> C] is a 1-functor in each variable and satisfies a coherence, then it is a 1-functor. *)
238+
Definition is1functor_prod_is1functor {A B C : Type}
239+
`{Is1Cat A, Is1Cat B, Is1Cat C} (F : A * B -> C)
240+
`{!forall a, Is0Functor (fun b => F (a,b)), !forall b, Is0Functor (fun a => F (a,b))}
241+
`{!forall a, Is1Functor (fun b => F (a,b)), !forall b, Is1Functor (fun a => F (a,b))}
242+
(bifunctor_coh : forall a0 a1 (f : a0 $-> a1) b0 b1 (g : b0 $-> b1),
243+
fmap (fun b => F (a1,b)) g $o fmap (fun a => F (a,b0)) f
244+
$== fmap (fun a => F(a,b1)) f $o fmap (fun b => F (a0,b)) g)
245+
: Is1Functor F.
246+
Proof.
247+
snrapply Build_Is1Functor.
248+
- intros [a b] [a' b'] [f g] [f' g'] [p p']; unfold fst, snd in * |- .
249+
exact (fmap2 (fun b0 => F (a,b0)) p' $@@ fmap2 (fun a0 => F (a0,b')) p).
250+
- intros [a b].
251+
exact ((fmap_id (fun b0 => F (a,b0)) b $@@ fmap_id (fun a0 => F (a0,b)) _) $@ cat_idr _).
252+
- intros [a b] [a' b'] [a'' b''] [f g] [f' g']; unfold fst, snd in * |- .
253+
refine ((fmap_comp (fun b0 => F (a,b0)) g g' $@@ fmap_comp (fun a0 => F (a0,b'')) f f') $@ _).
254+
nrefine (cat_assoc_opp _ _ _ $@ (_ $@R _) $@ cat_assoc _ _ _).
255+
refine (cat_assoc _ _ _ $@ (_ $@L _^$) $@ cat_assoc_opp _ _ _).
256+
nrapply bifunctor_coh.
257+
Defined.
258+
Hint Immediate is1functor_prod_is1functor : typeclass_instances.
259+
224260
(** Applies a two variable functor via uncurrying. Note that the precondition on [C] is slightly weaker than that of [Bifunctor.fmap11]. *)
225261
Definition fmap11_uncurry {A B C : Type} `{IsGraph A, IsGraph B, IsGraph C}
226262
(F : A -> B -> C) {H2 : Is0Functor (uncurry F)}

0 commit comments

Comments
 (0)