@@ -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]. *)
225261Definition fmap11_uncurry {A B C : Type} `{IsGraph A, IsGraph B, IsGraph C}
226262 (F : A -> B -> C) {H2 : Is0Functor (uncurry F)}
0 commit comments