(* Title: Bicategory Author: Eugene W. Stark , 2019 Maintainer: Eugene W. Stark *) theory Bicategory imports Prebicategory Category3.Subcategory Category3.DiscreteCategory MonoidalCategory.MonoidalCategory begin section "Bicategories" text \ A \emph{bicategory} is a (vertical) category that has been equipped with a horizontal composition, an associativity natural isomorphism, and for each object a ``unit isomorphism'', such that horizontal composition on the left by target and on the right by source are fully faithful endofunctors of the vertical category, and such that the usual pentagon coherence condition holds for the associativity. \ locale bicategory = horizontal_composition V H src trg + \: natural_isomorphism VVV.comp V HoHV HoVH \\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))\ + L: fully_faithful_functor V V L + R: fully_faithful_functor V V R for V :: "'a comp" (infixr "\" 55) and H :: "'a \ 'a \ 'a" (infixr "\" 53) and \ :: "'a \ 'a \ 'a \ 'a" ("\[_, _, _]") and \ :: "'a \ 'a" ("\[_]") and src :: "'a \ 'a" and trg :: "'a \ 'a" + assumes unit_in_vhom: "obj a \ \\[a] : a \ a \ a\" and iso_unit: "obj a \ iso \[a]" and pentagon: "\ ide f; ide g; ide h; ide k; src f = trg g; src g = trg h; src h = trg k \ \ (f \ \[g, h, k]) \ \[f, g \ h, k] \ (\[f, g, h] \ k) = \[f, g, h \ k] \ \[f \ g, h, k]" begin (* * TODO: the mapping \ is not currently assumed to be extensional. * It might be best in the long run if it were. *) definition \ where "\ \\\ \ \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))" lemma assoc_in_hom': assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "in_hhom \[\, \, \] (src \) (trg \)" and "\\[\, \, \] : (dom \ \ dom \) \ dom \ \ cod \ \ cod \ \ cod \\" proof - show "\\[\, \, \] : (dom \ \ dom \) \ dom \ \ cod \ \ cod \ \ cod \\" proof - have 1: "VVV.in_hom (\, \, \) (dom \, dom \, dom \) (cod \, cod \, cod \)" using assms VVV.in_hom_char VVV.arr_char VV.arr_char by auto have "\\[\, \, \] : HoHV (dom \, dom \, dom \) \ HoVH (cod \, cod \, cod \)\" using 1 \.preserves_hom by auto moreover have "HoHV (dom \, dom \, dom \) = (dom \ \ dom \) \ dom \" using 1 HoHV_def by (simp add: VVV.in_hom_char) moreover have "HoVH (cod \, cod \, cod \) = cod \ \ cod \ \ cod \" using 1 HoVH_def by (simp add: VVV.in_hom_char) ultimately show ?thesis by simp qed thus "in_hhom \[\, \, \] (src \) (trg \)" using assms src_cod trg_cod vconn_implies_hpar(1) vconn_implies_hpar(2) by auto qed lemma assoc_is_natural_1: assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "\[\, \, \] = (\ \ \ \ \) \ \[dom \, dom \, dom \]" using assms \.is_natural_1 [of "(\, \, \)"] VVV.arr_char VV.arr_char VVV.dom_char HoVH_def src_dom trg_dom by simp lemma assoc_is_natural_2: assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "\[\, \, \] = \[cod \, cod \, cod \] \ ((\ \ \) \ \)" using assms \.is_natural_2 [of "(\, \, \)"] VVV.arr_char VV.arr_char VVV.cod_char HoHV_def src_dom trg_dom by simp lemma assoc_naturality: assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "\[cod \, cod \, cod \] \ ((\ \ \) \ \) = (\ \ \ \ \) \ \[dom \, dom \, dom \]" using assms \.naturality VVV.arr_char VV.arr_char HoVH_def HoHV_def VVV.dom_char VVV.cod_char by auto lemma assoc_in_hom [intro]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "in_hhom \[f, g, h] (src h) (trg f)" and "\\[f, g, h] : (dom f \ dom g) \ dom h \ cod f \ cod g \ cod h\" using assms assoc_in_hom' apply auto[1] using assms assoc_in_hom' ideD(1) by metis lemma assoc_simps [simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "arr \[f, g, h]" and "src \[f, g, h] = src h" and "trg \[f, g, h] = trg f" and "dom \[f, g, h] = (dom f \ dom g) \ dom h" and "cod \[f, g, h] = cod f \ cod g \ cod h" using assms assoc_in_hom apply auto using assoc_in_hom(1) by auto lemma iso_assoc [intro, simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "iso \[f, g, h]" using assms \.components_are_iso [of "(f, g, h)"] VVV.ide_char VVV.arr_char VV.arr_char by simp end subsection "Categories Induce Bicategories" text \ In this section we show that a category becomes a bicategory if we take the vertical composition to be discrete, we take the composition of the category as the horizontal composition, and we take the vertical domain and codomain as \src\ and \trg\. \ (* * It is helpful to make a few local definitions here, but I don't want them to * clutter the category locale. Using a context and private definitions does not * work as expected. So we have to define a new locale just for the present purpose. *) locale category_as_bicategory = category begin interpretation V: discrete_category \Collect arr\ null using not_arr_null by (unfold_locales, blast) abbreviation V where "V \ V.comp" interpretation src: "functor" V V dom using V.null_char by (unfold_locales, simp add: has_domain_iff_arr dom_def, auto) interpretation trg: "functor" V V cod using V.null_char by (unfold_locales, simp add: has_codomain_iff_arr cod_def, auto) interpretation H: horizontal_homs V dom cod by (unfold_locales, auto) interpretation H: "functor" H.VV.comp V \\\\. fst \\ \ snd \\\ apply (unfold_locales) using H.VV.arr_char V.null_char ext apply force using H.VV.arr_char V.null_char H.VV.dom_char H.VV.cod_char apply auto[3] proof - show "\g f. H.VV.seq g f \ fst (H.VV.comp g f) \ snd (H.VV.comp g f) = V (fst g \ snd g) (fst f \ snd f)" proof - have 0: "\f. H.VV.arr f \ V.arr (fst f \ snd f)" using H.VV.arr_char by auto have 1: "\f g. V.seq g f \ V.ide f \ g = f" using V.arr_char V.dom_char V.cod_char V.not_arr_null by force have 2: "\f g. H.VxV.seq g f \ H.VxV.ide f \ g = f" using 1 H.VxV.seq_char by (metis H.VxV.dom_eqI H.VxV.ide_Ide) fix f g assume fg: "H.VV.seq g f" have 3: "H.VV.ide f \ f = g" using fg 2 H.VV.seq_char H.VV.ide_char by blast show "fst (H.VV.comp g f) \ snd (H.VV.comp g f) = V (fst g \ snd g) (fst f \ snd f)" using fg 0 1 3 H.VV.comp_char H.VV.arr_char H.VV.ide_char V.arr_char V.comp_char H.VV.comp_arr_ide by (metis (no_types, lifting)) qed qed interpretation H: horizontal_composition V C dom cod by (unfold_locales, auto) abbreviation \ where "\ f g h \ f \ g \ h" interpretation \: natural_isomorphism H.VVV.comp V H.HoHV H.HoVH \\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))\ apply unfold_locales using V.null_char ext apply fastforce using H.HoHV_def H.HoVH_def H.VVV.arr_char H.VV.arr_char H.VVV.dom_char H.VV.dom_char H.VVV.cod_char H.VV.cod_char H.VVV.ide_char comp_assoc by auto interpretation fully_faithful_functor V V H.R using comp_arr_dom by (unfold_locales, auto) interpretation fully_faithful_functor V V H.L using comp_cod_arr by (unfold_locales, auto) abbreviation \ where "\ \ \x. x" proposition induces_bicategory: shows "bicategory V C \ \ dom cod" apply (unfold_locales, auto simp add: comp_assoc) using comp_arr_dom by fastforce end subsection "Monoidal Categories induce Bicategories" text \ In this section we show that our definition of bicategory directly generalizes our definition of monoidal category: a monoidal category becomes a bicategory when equipped with the constant-\\\ functors as src and trg and \\\ as the unit isomorphism from \\ \ \\ to \\\. There is a slight mismatch because the bicategory locale assumes that the associator is given in curried form, whereas for monoidal categories it is given in tupled form. Ultimately, the monoidal category locale should be revised to also use curried form, which ends up being more convenient in most situations. \ context monoidal_category begin interpretation I: constant_functor C C \ using \_in_hom by unfold_locales auto interpretation horizontal_homs C I.map I.map by unfold_locales auto lemma CC_eq_VV: shows "CC.comp = VV.comp" proof - have "\g f. CC.comp g f = VV.comp g f" proof - fix f g show "CC.comp g f = VV.comp g f" proof - have "CC.seq g f \ CC.comp g f = VV.comp g f" using VV.comp_char VV.arr_char CC.seq_char by (elim CC.seqE seqE, simp) moreover have "\ CC.seq g f \ CC.comp g f = VV.comp g f" using VV.seq_char VV.ext VV.null_char CC.ext by (metis (no_types, lifting)) ultimately show ?thesis by blast qed qed thus ?thesis by blast qed lemma CCC_eq_VVV: shows "CCC.comp = VVV.comp" proof - have "\g f. CCC.comp g f = VVV.comp g f" proof - fix f g show "CCC.comp g f = VVV.comp g f" proof - have "CCC.seq g f \ CCC.comp g f = VVV.comp g f" by (metis (no_types, lifting) CC.arrE CCC.seqE CC_eq_VV I.map_simp I.preserves_reflects_arr VV.seq_char VVV.arrI VVV.comp_simp VVV.seq_char trg_vcomp vseq_implies_hpar(1)) moreover have "\ CCC.seq g f \ CCC.comp g f = VVV.comp g f" using VVV.seq_char VVV.ext VVV.null_char CCC.ext by (metis (no_types, lifting)) ultimately show ?thesis by blast qed qed thus ?thesis by blast qed interpretation H: "functor" VV.comp C \\\\. fst \\ \ snd \\\ using CC_eq_VV T.functor_axioms by simp interpretation H: horizontal_composition C tensor I.map I.map by (unfold_locales, simp_all) lemma HoHV_eq_ToTC: shows "H.HoHV = T.ToTC" using H.HoHV_def T.ToTC_def CCC_eq_VVV by presburger lemma HoVH_eq_ToCT: shows "H.HoVH = T.ToCT" using H.HoVH_def T.ToCT_def CCC_eq_VVV by presburger interpretation \: natural_isomorphism VVV.comp C H.HoHV H.HoVH \ using \.natural_isomorphism_axioms CCC_eq_VVV HoHV_eq_ToTC HoVH_eq_ToCT by simp lemma R'_eq_R: shows "H.R = R" using H.is_extensional CC_eq_VV CC.arr_char by force lemma L'_eq_L: shows "H.L = L" using H.is_extensional CC_eq_VV CC.arr_char by force interpretation R': fully_faithful_functor C C H.R using R'_eq_R R.fully_faithful_functor_axioms unity_def by auto interpretation L': fully_faithful_functor C C H.L using L'_eq_L L.fully_faithful_functor_axioms unity_def by auto lemma obj_char: shows "obj a \ a = \" using obj_def [of a] \_in_hom by fastforce proposition induces_bicategory: shows "bicategory C tensor (\\ \ \. \ (\, \, \)) (\_. \) I.map I.map" using obj_char \_in_hom \_is_iso pentagon \.is_extensional \.is_natural_1 \.is_natural_2 by unfold_locales simp_all end subsection "Prebicategories Extend to Bicategories" text \ In this section, we show that a prebicategory with homs and units extends to a bicategory. The main work is to show that the endofunctors \L\ and \R\ are fully faithful. We take the left and right unitor isomorphisms, which were obtained via local constructions in the left and right hom-subcategories defined by a specified weak unit, and show that in the presence of the chosen sources and targets they are the components of a global natural isomorphisms \\\ and \\\ from the endofunctors \L\ and \R\ to the identity functor. A consequence is that functors \L\ and \R\ are endo-equivalences, hence fully faithful. \ context prebicategory_with_homs begin text \ Once it is equipped with a particular choice of source and target for each arrow, a prebicategory determines a horizontal composition. \ lemma induces_horizontal_composition: shows "horizontal_composition V H src trg" proof - interpret H: "functor" VV.comp V \\\\. fst \\ \ snd \\\ proof - have "VV.comp = VoV.comp" using composable_char\<^sub>P\<^sub>B\<^sub>H by meson thus "functor VV.comp V (\\\. fst \\ \ snd \\)" using functor_axioms by argo qed show "horizontal_composition V H src trg" using src_hcomp' trg_hcomp' composable_char\<^sub>P\<^sub>B\<^sub>H not_arr_null by (unfold_locales; metis) qed end sublocale prebicategory_with_homs \ horizontal_composition V H src trg using induces_horizontal_composition by auto locale prebicategory_with_homs_and_units = prebicategory_with_units + prebicategory_with_homs begin no_notation in_hom ("\_ : _ \ _\") text \ The next definitions extend the left and right unitors that were defined locally with respect to a particular weak unit, to globally defined versions using the chosen source and target for each arrow. \ definition lunit ("\[_]") where "lunit f \ left_hom_with_unit.lunit V H \ \[trg f] (trg f) f" definition runit ("\[_]") where "runit f \ right_hom_with_unit.runit V H \ \[src f] (src f) f" lemma lunit_in_hom: assumes "ide f" shows "\\[f] : src f \\<^sub>W\<^sub>C trg f\" and "\\[f] : trg f \ f \ f\" proof - interpret Left: subcategory V \left (trg f)\ using assms left_hom_is_subcategory by simp interpret Left: left_hom_with_unit V H \ \\[trg f]\ \trg f\ using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) have 0: "Left.ide f" using assms Left.ide_char Left.arr_char left_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto show 1: "\\[f] : trg f \ f \ f\" unfolding lunit_def using assms 0 Left.lunit_char(1) Left.hom_char H\<^sub>L_def by auto show "\\[f] : src f \\<^sub>W\<^sub>C trg f\" using 1 src_cod trg_cod src_in_sources trg_in_targets by (metis arrI vconn_implies_hpar) qed lemma runit_in_hom: assumes "ide f" shows "\\[f] : src f \\<^sub>W\<^sub>C trg f\" and "\\[f] : f \ src f \ f\" proof - interpret Right: subcategory V \right (src f)\ using assms right_hom_is_subcategory weak_unit_self_composable by force interpret Right: right_hom_with_unit V H \ \\[src f]\ \src f\ using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) have 0: "Right.ide f" using assms Right.ide_char Right.arr_char right_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto show 1: "\\[f] : f \ src f \ f\" unfolding runit_def using assms 0 Right.runit_char(1) Right.hom_char H\<^sub>R_def by auto show "\\[f] : src f \\<^sub>W\<^sub>C trg f\" using 1 src_cod trg_cod src_in_sources trg_in_targets by (metis arrI vconn_implies_hpar) qed text \ The characterization of the locally defined unitors yields a corresponding characterization of the globally defined versions, by plugging in the chosen source or target for each arrow for the unspecified weak unit in the the local versions. \ lemma lunit_char: assumes "ide f" shows "\\[f] : src f \\<^sub>W\<^sub>C trg f\" and "\\[f] : trg f \ f \ f\" and "trg f \ \[f] = (\[trg f] \ f) \ inv \[trg f, trg f, f]" and "\!\. \\ : trg f \ f \ f\ \ trg f \ \ = (\[trg f] \ f) \ inv \[trg f, trg f, f]" proof - let ?a = "src f" and ?b = "trg f" interpret Left: subcategory V \left ?b\ using assms left_hom_is_subcategory weak_unit_self_composable by force interpret Left: left_hom_with_unit V H \ \\[?b]\ ?b using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) have 0: "Left.ide f" using assms Left.ide_char Left.arr_char left_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto show "\\[f] : src f \\<^sub>W\<^sub>C trg f\" using assms lunit_in_hom by simp show A: "\\[f] : trg f \ f \ f\" using assms lunit_in_hom by simp show B: "?b \ \[f] = (\[?b] \ f) \ inv \[?b, ?b, f]" unfolding lunit_def using 0 Left.lunit_char(2) H\<^sub>L_def by (metis Left.comp_simp Left.characteristic_iso(1-2) Left.seqI') show "\!\. \\ : trg f \ f \ f\ \ trg f \ \ = (\[?b] \ f) \ inv \[?b, ?b, f]" proof - have 1: "hom (trg f \ f) f = Left.hom (Left.L f) f" proof have 1: "Left.L f = ?b \ f" using 0 H\<^sub>L_def by simp show "Left.hom (Left.L f) f \ hom (?b \ f) f" using assms Left.hom_char [of "?b \ f" f] H\<^sub>L_def by simp show "hom (?b \ f) f \ Left.hom (Left.L f) f" using assms 1 ide_in_hom composable_char\<^sub>P\<^sub>B\<^sub>H hom_connected left_def Left.hom_char by auto qed let ?P = "\\. Left.in_hom \ (Left.L f) f" let ?P' = "\\. \\ : ?b \ f \ f\" let ?Q = "\\. Left.L \ = (\[?b] \ f) \ (inv \[?b, ?b, f])" let ?R = "\\. ?b \ \ = (\[?b] \ f) \ (inv \[?b, ?b, f])" have 2: "?P = ?P'" using 0 1 H\<^sub>L_def Left.hom_char by blast moreover have "\\. ?P \ \ (?Q \ \ ?R \)" using 2 Left.lunit_eqI H\<^sub>L_def by presburger moreover have "(\!\. ?P \ \ ?Q \)" using 0 2 A B Left.lunit_char(3) Left.ide_char Left.arr_char by (metis (no_types, lifting) Left.lunit_char(2) calculation(2) lunit_def) ultimately show ?thesis by metis qed qed lemma runit_char: assumes "ide f" shows "\\[f] : src f \\<^sub>W\<^sub>C trg f\" and "\\[f] : f \ src f \ f\" and "\[f] \ src f = (f \ \[src f]) \ \[f, src f, src f]" and "\!\. \\ : f \ src f \ f\ \ \ \ src f = (f \ \[src f]) \ \[f, src f, src f]" proof - let ?a = "src f" and ?b = "trg f" interpret Right: subcategory V \right ?a\ using assms right_hom_is_subcategory weak_unit_self_composable by force interpret Right: right_hom_with_unit V H \ \\[?a]\ ?a using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) have 0: "Right.ide f" using assms Right.ide_char Right.arr_char right_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto show "\\[f] : src f \\<^sub>W\<^sub>C trg f\" using assms runit_in_hom by simp show A: "\\[f] : f \ src f \ f\" using assms runit_in_hom by simp show B: "\[f] \ ?a = (f \ \[?a]) \ \[f, ?a, ?a]" unfolding runit_def using 0 Right.runit_char(2) H\<^sub>R_def using Right.comp_simp Right.characteristic_iso(4) Right.iso_is_arr by auto show "\!\. \\ : f \ src f \ f\ \ \ \ ?a = (f \ \[?a]) \ \[f, ?a, ?a]" proof - have 1: "hom (f \ ?a) f = Right.hom (Right.R f) f" proof have 1: "Right.R f = f \ ?a" using 0 H\<^sub>R_def by simp show "Right.hom (Right.R f) f \ hom (f \ ?a) f" using assms Right.hom_char [of "f \ ?a" f] H\<^sub>R_def by simp show "hom (f \ ?a) f \ Right.hom (Right.R f) f" using assms 1 ide_in_hom composable_char\<^sub>P\<^sub>B\<^sub>H hom_connected right_def Right.hom_char by auto qed let ?P = "\\. Right.in_hom \ (Right.R f) f" let ?P' = "\\. \\ : f \ ?a \ f\" let ?Q = "\\. Right.R \ = (f \ \[?a]) \ \[f, ?a, ?a]" let ?R = "\\. \ \ ?a = (f \ \[?a]) \ \[f, ?a, ?a]" have 2: "?P = ?P'" using 0 1 H\<^sub>R_def Right.hom_char by blast moreover have "\\. ?P \ \ (?Q \ \ ?R \)" using 2 Right.runit_eqI H\<^sub>R_def by presburger moreover have "(\!\. ?P \ \ ?Q \)" using 0 2 A B Right.runit_char(3) Right.ide_char Right.arr_char by (metis (no_types, lifting) Right.runit_char(2) calculation(2) runit_def) ultimately show ?thesis by metis qed qed lemma lunit_eqI: assumes "ide f" and "\\ : trg f \ f \ f\" and "trg f \ \ = (\[trg f] \ f) \ (inv \[trg f, trg f, f])" shows "\ = \[f]" using assms lunit_char(2-4) by blast lemma runit_eqI: assumes "ide f" and "\\ : f \ src f \ f\" and "\ \ src f = (f \ \[src f]) \ \[f, src f, src f]" shows "\ = \[f]" using assms runit_char(2-4) by blast lemma iso_lunit: assumes "ide f" shows "iso \[f]" proof - let ?b = "trg f" interpret Left: subcategory V \left ?b\ using assms left_hom_is_subcategory weak_unit_self_composable by force interpret Left: left_hom_with_unit V H \ \\[?b]\ ?b using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) show ?thesis proof - have 0: "Left.ide f" using assms Left.ide_char Left.arr_char left_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto thus ?thesis unfolding lunit_def using Left.iso_lunit Left.iso_char by blast qed qed lemma iso_runit: assumes "ide f" shows "iso \[f]" proof - let ?a = "src f" interpret Right: subcategory V \right ?a\ using assms right_hom_is_subcategory weak_unit_self_composable by force interpret Right: right_hom_with_unit V H \ \\[?a]\ ?a using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) show ?thesis proof - have 0: "Right.ide f" using assms Right.ide_char Right.arr_char right_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto thus ?thesis unfolding runit_def using Right.iso_runit Right.iso_char by blast qed qed lemma lunit_naturality: assumes "arr \" shows "\ \ \[dom \] = \[cod \] \ (trg \ \ \)" proof - let ?a = "src \" and ?b = "trg \" interpret Left: subcategory V \left ?b\ using assms obj_trg left_hom_is_subcategory weak_unit_self_composable by force interpret Left: left_hom_with_unit V H \ \\[?b]\ ?b using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) interpret Left.L: endofunctor \Left ?b\ Left.L using assms endofunctor_H\<^sub>L [of ?b] weak_unit_self_composable obj_trg obj_is_weak_unit by blast have 1: "Left.in_hom \ (dom \) (cod \)" using assms Left.hom_char Left.arr_char left_def composable_char\<^sub>P\<^sub>B\<^sub>H obj_trg by auto have 2: "Left.in_hom \[Left.dom \] (?b \ dom \) (dom \)" unfolding lunit_def using assms 1 Left.in_hom_char trg_dom Left.lunit_char(1) H\<^sub>L_def Left.arr_char Left.dom_char Left.ide_dom by force have 3: "Left.in_hom \[Left.cod \] (?b \ cod \) (cod \)" unfolding lunit_def using assms 1 Left.in_hom_char trg_cod Left.lunit_char(1) H\<^sub>L_def Left.cod_char Left.ide_cod by force have 4: "Left.in_hom (Left.L \) (?b \ dom \) (?b \ cod \)" using 1 Left.L.preserves_hom [of \ "dom \" "cod \"] H\<^sub>L_def by auto show ?thesis proof - have "\ \ \[dom \] = Left.comp \ \[Left.dom \]" using 1 2 Left.comp_simp by fastforce also have "... = Left.comp \ (Left.lunit (Left.dom \))" using assms 1 lunit_def by auto also have "... = Left.comp (Left.lunit (Left.cod \)) (Left.L \)" using 1 Left.lunit_naturality Left.cod_simp by auto also have "... = Left.comp (lunit (Left.cod \)) (Left.L \)" using assms 1 lunit_def by auto also have "... = \[cod \] \ Left.L \" using 1 3 4 Left.comp_char Left.cod_char Left.in_hom_char by auto also have "... = \[cod \] \ (trg \ \ \)" using 1 by (simp add: H\<^sub>L_def) finally show ?thesis by simp qed qed lemma runit_naturality: assumes "arr \" shows "\ \ \[dom \] = \[cod \] \ (\ \ src \)" proof - let ?a = "src \" and ?b = "trg \" interpret Right: subcategory V \right ?a\ using assms right_hom_is_subcategory weak_unit_self_composable by force interpret Right: right_hom_with_unit V H \ \\[?a]\ ?a using assms obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by (unfold_locales, auto) interpret Right.R: endofunctor \Right ?a\ Right.R using assms endofunctor_H\<^sub>R [of ?a] weak_unit_self_composable obj_src obj_is_weak_unit by blast have 1: "Right.in_hom \ (dom \) (cod \)" using assms Right.hom_char Right.arr_char right_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto have 2: "Right.in_hom \[Right.dom \] (dom \ \ ?a) (dom \)" unfolding runit_def using 1 Right.in_hom_char trg_dom Right.runit_char(1) [of "Right.dom \"] H\<^sub>R_def Right.arr_char Right.dom_char Right.ide_dom assms by force have 3: "\[Right.cod \] \ Right.hom (cod \ \ ?a) (cod \)" unfolding runit_def using 1 Right.in_hom_char trg_cod Right.runit_char(1) [of "Right.cod \"] H\<^sub>R_def Right.cod_char Right.ide_cod assms by force have 4: "Right.R \ \ Right.hom (dom \ \ ?a) (cod \ \ ?a)" using 1 Right.R.preserves_hom [of \ "dom \" "cod \"] H\<^sub>R_def by auto show ?thesis proof - have "\ \ \[dom \] = Right.comp \ \[Right.dom \]" by (metis 1 2 Right.comp_char Right.in_homE Right.seqI' Right.seq_char) also have "... = Right.comp \ (Right.runit (Right.dom \))" using assms 1 src_dom trg_dom Right.hom_char runit_def by auto also have "... = Right.comp (Right.runit (Right.cod \)) (Right.R \)" using 1 Right.runit_naturality Right.cod_simp by auto also have "... = Right.comp (runit (Right.cod \)) (Right.R \)" using assms 1 runit_def by auto also have "... = \[cod \] \ Right.R \" using 1 3 4 Right.comp_char Right.cod_char Right.in_hom_char by auto also have "... = \[cod \] \ (\ \ ?a)" using 1 by (simp add: H\<^sub>R_def) finally show ?thesis by simp qed qed interpretation L: endofunctor V L using endofunctor_L by auto interpretation \: transformation_by_components V V L map lunit using lunit_in_hom lunit_naturality by unfold_locales auto interpretation \: natural_isomorphism V V L map \.map using iso_lunit by unfold_locales auto lemma natural_isomorphism_\: shows "natural_isomorphism V V L map \.map" .. interpretation L: equivalence_functor V V L using L.isomorphic_to_identity_is_equivalence \.natural_isomorphism_axioms by simp lemma equivalence_functor_L: shows "equivalence_functor V V L" .. lemma lunit_commutes_with_L: assumes "ide f" shows "\[L f] = L \[f]" proof - have "seq \[f] (L \[f])" using assms lunit_char(2) L.preserves_hom by fastforce moreover have "seq \[f] \[L f]" using assms lunit_char(2) lunit_char(2) [of "L f"] L.preserves_ide by auto ultimately show ?thesis using assms lunit_char(2) [of f] lunit_naturality [of "\[f]"] iso_lunit iso_is_section section_is_mono monoE [of "\[f]" "L \[f]" "\[L f]"] by auto qed interpretation R: endofunctor V R using endofunctor_R by auto interpretation \: transformation_by_components V V R map runit using runit_in_hom runit_naturality by unfold_locales auto interpretation \: natural_isomorphism V V R map \.map using iso_runit by unfold_locales auto lemma natural_isomorphism_\: shows "natural_isomorphism V V R map \.map" .. interpretation R: equivalence_functor V V R using R.isomorphic_to_identity_is_equivalence \.natural_isomorphism_axioms by simp lemma equivalence_functor_R: shows "equivalence_functor V V R" .. lemma runit_commutes_with_R: assumes "ide f" shows "\[R f] = R \[f]" proof - have "seq \[f] (R \[f])" using assms runit_char(2) R.preserves_hom by fastforce moreover have "seq \[f] \[R f]" using assms runit_char(2) runit_char(2) [of "R f"] R.preserves_ide by auto ultimately show ?thesis using assms runit_char(2) [of f] runit_naturality [of "\[f]"] iso_runit iso_is_section section_is_mono monoE [of "\[f]" "R \[f]" "\[R f]"] by auto qed definition \ where "\ \ \ \ \ if VVV.arr (\, \, \) then (\ \ \ \ \) \ \[dom \, dom \, dom \] else null" lemma \_ide_simp [simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "\ f g h = \[f, g, h]" proof - have "\ f g h = (f \ g \ h) \ \[dom f, dom g, dom h]" using assms \_def VVV.arr_char [of "(f, g, h)"] by auto also have "... = (f \ g \ h) \ \[f, g, h]" using assms by simp also have "... = \[f, g, h]" using assms \_def assoc_in_hom\<^sub>A\<^sub>W\<^sub>C hcomp_in_hom\<^sub>P\<^sub>B\<^sub>H VVV.arr_char VoV.arr_char comp_cod_arr composable_char\<^sub>P\<^sub>B\<^sub>H by auto finally show ?thesis by simp qed (* TODO: Figure out how this got reinstated. *) no_notation in_hom ("\_ : _ \ _\") lemma natural_isomorphism_\: shows "natural_isomorphism VVV.comp V HoHV HoVH (\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\)))" proof - interpret \: transformation_by_components VVV.comp V HoHV HoVH \\f. \[fst f, fst (snd f), snd (snd f)]\ proof show 1: "\x. VVV.ide x \ \\[fst x, fst (snd x), snd (snd x)] : HoHV x \ HoVH x\" proof - fix x assume x: "VVV.ide x" show "\\[fst x, fst (snd x), snd (snd x)] : HoHV x \ HoVH x\" proof - have "ide (fst x) \ ide (fst (snd x)) \ ide (snd (snd x)) \ fst x \ fst (snd x) \ null \ fst (snd x) \ snd (snd x) \ null" using x VVV.ide_char VVV.arr_char VV.arr_char composable_char\<^sub>P\<^sub>B\<^sub>H by simp hence "\[fst x, fst (snd x), snd (snd x)] \ hom ((fst x \ fst (snd x)) \ snd (snd x)) (fst x \ fst (snd x) \ snd (snd x))" using x assoc_in_hom\<^sub>A\<^sub>W\<^sub>C by simp thus ?thesis unfolding HoHV_def HoVH_def using x VVV.ideD(1) by simp qed qed show "\f. VVV.arr f \ \[fst (VVV.cod f), fst (snd (VVV.cod f)), snd (snd (VVV.cod f))] \ HoHV f = HoVH f \ \[fst (VVV.dom f), fst (snd (VVV.dom f)), snd (snd (VVV.dom f))]" unfolding HoHV_def HoVH_def using assoc_naturality\<^sub>A\<^sub>W\<^sub>C VVV.arr_char VV.arr_char VVV.dom_char VVV.cod_char composable_char\<^sub>P\<^sub>B\<^sub>H by simp qed interpret \: natural_isomorphism VVV.comp V HoHV HoVH \.map proof fix f assume f: "VVV.ide f" show "iso (\.map f)" proof - have "fst f \ fst (snd f) \ null \ fst (snd f) \ snd (snd f) \ null" using f VVV.ideD(1) VVV.arr_char [of f] VV.arr_char composable_char\<^sub>P\<^sub>B\<^sub>H by auto thus ?thesis using f \.map_simp_ide iso_assoc\<^sub>A\<^sub>W\<^sub>C VVV.ide_char VVV.arr_char by simp qed qed have "(\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))) = \.map" proof fix \\\ have "\ VVV.arr \\\ \ \ (fst \\\) (fst (snd \\\)) (snd (snd \\\)) = \.map \\\" using \_def \.map_def by simp moreover have "VVV.arr \\\ \ \ (fst \\\) (fst (snd \\\)) (snd (snd \\\)) = \.map \\\" proof - assume \\\: "VVV.arr \\\" have "\ (fst \\\) (fst (snd \\\)) (snd (snd \\\)) = (fst \\\ \ fst (snd \\\) \ snd (snd \\\)) \ \[dom (fst \\\), dom (fst (snd \\\)), dom (snd (snd \\\))]" using \\\ \_def by simp also have "... = \[cod (fst \\\), cod (fst (snd \\\)), cod (snd (snd \\\))] \ ((fst \\\ \ fst (snd \\\)) \ snd (snd \\\))" using \\\ HoHV_def HoVH_def VVV.arr_char VV.arr_char assoc_naturality\<^sub>A\<^sub>W\<^sub>C composable_char\<^sub>P\<^sub>B\<^sub>H by simp also have "... = \[fst (VVV.cod \\\), fst (snd (VVV.cod \\\)), snd (snd (VVV.cod \\\))] \ ((fst \\\ \ fst (snd \\\)) \ snd (snd \\\))" using \\\ VVV.arr_char VVV.cod_char VV.arr_char by simp also have "... = \.map \\\" using \\\ \.map_def HoHV_def composable_char\<^sub>P\<^sub>B\<^sub>H by auto finally show ?thesis by blast qed ultimately show "\ (fst \\\) (fst (snd \\\)) (snd (snd \\\)) = \.map \\\" by blast qed thus ?thesis using \.natural_isomorphism_axioms by simp qed proposition induces_bicategory: shows "bicategory V H \ \ src trg" proof - interpret VxVxV: product_category V VxV.comp .. interpret VoVoV: subcategory VxVxV.comp \\\\\. arr (fst \\\) \ VV.arr (snd \\\) \ src (fst \\\) = trg (fst (snd \\\))\ using subcategory_VVV by blast interpret HoHV: "functor" VVV.comp V HoHV using functor_HoHV by blast interpret HoVH: "functor" VVV.comp V HoVH using functor_HoVH by blast interpret \: natural_isomorphism VVV.comp V HoHV HoVH \\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))\ using natural_isomorphism_\ by blast interpret L: equivalence_functor V V L using equivalence_functor_L by blast interpret R: equivalence_functor V V R using equivalence_functor_R by blast show "bicategory V H \ \ src trg" proof show "\a. obj a \ \\[a] : a \ a \ a\" using obj_is_weak_unit unit_in_vhom\<^sub>P\<^sub>B\<^sub>U by blast show "\a. obj a \ iso \[a]" using obj_is_weak_unit iso_unit\<^sub>P\<^sub>B\<^sub>U by blast show "\f g h k. \ ide f; ide g; ide h; ide k; src f = trg g; src g = trg h; src h = trg k \ \ (f \ \ g h k) \ \ f (g \ h) k \ (\ f g h \ k) = \ f g (h \ k) \ \ (f \ g) h k" proof - fix f g h k assume f: "ide f" and g: "ide g" and h: "ide h" and k: "ide k" and fg: "src f = trg g" and gh: "src g = trg h" and hk: "src h = trg k" have "sources f \ targets g \ {}" using f g fg src_in_sources [of f] trg_in_targets ideD(1) by auto moreover have "sources g \ targets h \ {}" using g h gh src_in_sources [of g] trg_in_targets ideD(1) by auto moreover have "sources h \ targets k \ {}" using h k hk src_in_sources [of h] trg_in_targets ideD(1) by auto moreover have "\ f g h = \[f, g, h] \ \ g h k = \[g, h, k]" using f g h k fg gh hk \_ide_simp by simp moreover have "\ f (g \ h) k = \[f, g \ h, k] \ \ f g (h \ k) = \[f, g, h \ k] \ \ (f \ g) h k = \[f \ g, h, k]" using f g h k fg gh hk \_ide_simp preserves_ide hcomp_in_hom\<^sub>P\<^sub>B\<^sub>H(1) by simp ultimately show "(f \ \ g h k) \ \ f (g \ h) k \ (\ f g h \ k) = \ f g (h \ k) \ \ (f \ g) h k" using f g h k fg gh hk pentagon\<^sub>A\<^sub>W\<^sub>C [of f g h k] \_ide_simp by presburger qed qed qed end text \ The following is the main result of this development: Every prebicategory extends to a bicategory, by making an arbitrary choice of representatives of each isomorphism class of weak units and using that to define the source and target mappings, and then choosing an arbitrary isomorphism in \hom (a \ a) a\ for each weak unit \a\. \ context prebicategory begin interpretation prebicategory_with_homs V H \ some_src some_trg using extends_to_prebicategory_with_homs by auto interpretation prebicategory_with_units V H \ some_unit using extends_to_prebicategory_with_units by auto interpretation prebicategory_with_homs_and_units V H \ some_unit some_src some_trg .. theorem extends_to_bicategory: shows "bicategory V H \ some_unit some_src some_trg" using induces_bicategory by simp end section "Bicategories as Prebicategories" subsection "Bicategories are Prebicategories" text \ In this section we show that a bicategory determines a prebicategory with homs, whose weak units are exactly those arrows that are isomorphic to their chosen source, or equivalently, to their chosen target. Moreover, the notion of horizontal composability, which in a bicategory is determined by the coincidence of chosen sources and targets, agrees with the version defined for the induced weak composition in terms of nonempty intersections of source and target sets, which is not dependent on any arbitrary choices. \ context bicategory begin (* TODO: Why does this get re-introduced? *) no_notation in_hom ("\_ : _ \ _\") interpretation \': inverse_transformation VVV.comp V HoHV HoVH \\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))\ .. abbreviation \' where "\' \ \'.map" definition \' ("\\<^sup>-\<^sup>1[_, _, _]") where "\\<^sup>-\<^sup>1[\, \, \] \ \'.map (\, \, \)" lemma assoc'_in_hom': assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "in_hhom \\<^sup>-\<^sup>1[\, \, \] (src \) (trg \)" and "\\\<^sup>-\<^sup>1[\, \, \] : dom \ \ dom \ \ dom \ \ (cod \ \ cod \) \ cod \\" proof - show "\\\<^sup>-\<^sup>1[\, \, \] : dom \ \ dom \ \ dom \ \ (cod \ \ cod \) \ cod \\" proof - have 1: "VVV.in_hom (\, \, \) (dom \, dom \, dom \) (cod \, cod \, cod \)" using assms VVV.in_hom_char VVV.arr_char VV.arr_char by auto have "\\\<^sup>-\<^sup>1[\, \, \] : HoVH (dom \, dom \, dom \) \ HoHV (cod \, cod \, cod \)\" using 1 \'_def \'.preserves_hom by auto moreover have "HoVH (dom \, dom \, dom \) = dom \ \ dom \ \ dom \" using 1 HoVH_def by (simp add: VVV.in_hom_char) moreover have "HoHV (cod \, cod \, cod \) = (cod \ \ cod \) \ cod \" using 1 HoHV_def by (simp add: VVV.in_hom_char) ultimately show ?thesis by simp qed thus "in_hhom \\<^sup>-\<^sup>1[\, \, \] (src \) (trg \)" using assms vconn_implies_hpar(1) vconn_implies_hpar(2) by auto qed lemma assoc'_is_natural_1: assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "\\<^sup>-\<^sup>1[\, \, \] = ((\ \ \) \ \) \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" using assms \'.is_natural_1 [of "(\, \, \)"] VVV.arr_char VV.arr_char VVV.dom_char HoHV_def src_dom trg_dom \'_def by simp lemma assoc'_is_natural_2: assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "\\<^sup>-\<^sup>1[\, \, \] = \\<^sup>-\<^sup>1[cod \, cod \, cod \] \ (\ \ \ \ \)" using assms \'.is_natural_2 [of "(\, \, \)"] VVV.arr_char VV.arr_char VVV.cod_char HoVH_def src_dom trg_dom \'_def by simp lemma assoc'_naturality: assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "\\<^sup>-\<^sup>1[cod \, cod \, cod \] \ (\ \ \ \ \) = ((\ \ \) \ \) \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" using assms assoc'_is_natural_1 assoc'_is_natural_2 by metis lemma assoc'_in_hom [intro]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "in_hhom \\<^sup>-\<^sup>1[f, g, h] (src h) (trg f)" and "\\\<^sup>-\<^sup>1[f, g, h] : dom f \ dom g \ dom h \ (cod f \ cod g) \ cod h\" using assms assoc'_in_hom'(1-2) ideD(1) by meson+ lemma assoc'_simps [simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "arr \\<^sup>-\<^sup>1[f, g, h]" and "src \\<^sup>-\<^sup>1[f, g, h] = src h" and "trg \\<^sup>-\<^sup>1[f, g, h] = trg f" and "dom \\<^sup>-\<^sup>1[f, g, h] = dom f \ dom g \ dom h" and "cod \\<^sup>-\<^sup>1[f, g, h] = (cod f \ cod g) \ cod h" using assms assoc'_in_hom by blast+ lemma assoc'_eq_inv_assoc [simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "\\<^sup>-\<^sup>1[f, g, h] = inv \[f, g, h]" using assms VVV.ide_char VVV.arr_char VV.ide_char VV.arr_char \'.map_ide_simp \'_def by auto lemma inverse_assoc_assoc' [intro]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "inverse_arrows \[f, g, h] \\<^sup>-\<^sup>1[f, g, h]" using assms VVV.ide_char VVV.arr_char VV.ide_char VV.arr_char \'.map_ide_simp \'.inverts_components \'_def by auto lemma iso_assoc' [intro, simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "iso \\<^sup>-\<^sup>1[f, g, h]" using assms by simp lemma comp_assoc_assoc' [simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "\[f, g, h] \ \\<^sup>-\<^sup>1[f, g, h] = f \ g \ h" and "\\<^sup>-\<^sup>1[f, g, h] \ \[f, g, h] = (f \ g) \ h" using assms comp_arr_inv' comp_inv_arr' by auto lemma unit_in_hom [intro, simp]: assumes "obj a" shows "\\[a] : a \ a\" and "\\[a] : a \ a \ a\" proof - show "\\[a] : a \ a \ a\" using assms unit_in_vhom by simp thus "\\[a] : a \ a\" using assms by (metis arrI in_hhom_def obj_simps(2-3) vconn_implies_hpar(1-4)) qed interpretation weak_composition V H using is_weak_composition by auto lemma seq_if_composable: assumes "\ \ \ \ null" shows "src \ = trg \" using assms H.is_extensional [of "(\, \)"] VV.arr_char by auto lemma obj_self_composable: assumes "obj a" shows "a \ a \ null" and "isomorphic (a \ a) a" proof - show 1: "isomorphic (a \ a) a" using assms unit_in_hom iso_unit isomorphic_def by blast obtain \ where \: "iso \ \ \\ : a \ a \ a\" using 1 isomorphic_def by blast have "ide (a \ a)" using 1 \ ide_dom [of \] by fastforce thus "a \ a \ null" using ideD(1) not_arr_null by metis qed lemma obj_is_weak_unit: assumes "obj a" shows "weak_unit a" proof - interpret Left_a: subcategory V \left a\ using assms left_hom_is_subcategory by force interpret Right_a: subcategory V \right a\ using assms right_hom_is_subcategory by force text \ We know that \H\<^sub>L a\ is fully faithful as a global endofunctor, but the definition of weak unit involves its restriction to a subcategory. So we have to verify that the restriction is also a fully faithful functor. \ interpret La: endofunctor \Left a\ \H\<^sub>L a\ using assms obj_self_composable endofunctor_H\<^sub>L [of a] by force interpret La: fully_faithful_functor \Left a\ \Left a\ \H\<^sub>L a\ proof show "\f f'. Left_a.par f f' \ H\<^sub>L a f = H\<^sub>L a f' \ f = f'" proof - fix \ \' assume par: "Left_a.par \ \'" assume eq: "H\<^sub>L a \ = H\<^sub>L a \'" have 1: "par \ \'" using par Left_a.arr_char Left_a.dom_char Left_a.cod_char left_def composable_implies_arr null_agreement by metis moreover have "L \ = L \'" using par eq H\<^sub>L_def Left_a.arr_char left_def preserves_arr assms 1 seq_if_composable [of a \] not_arr_null seq_if_composable [of a \'] by auto ultimately show "\ = \'" using L.is_faithful by blast qed show "\f g \. \ Left_a.ide f; Left_a.ide g; Left_a.in_hom \ (H\<^sub>L a f) (H\<^sub>L a g) \ \ \\. Left_a.in_hom \ f g \ H\<^sub>L a \ = \" proof - fix f g \ assume f: "Left_a.ide f" and g: "Left_a.ide g" and \: "Left_a.in_hom \ (H\<^sub>L a f) (H\<^sub>L a g)" have 1: "a = trg f \ a = trg g" using assms f g Left_a.ide_char Left_a.arr_char left_def seq_if_composable [of a f] seq_if_composable [of a g] by auto show "\\. Left_a.in_hom \ f g \ H\<^sub>L a \ = \" proof - have 2: "\\. \\ : f \ g\ \ L \ = \" using f g \ 1 Left_a.ide_char H\<^sub>L_def L.preserves_reflects_arr Left_a.arr_char Left_a.in_hom_char L.is_full by force obtain \ where \: "\\ : f \ g\ \ L \ = \" using 2 by blast have "Left_a.arr \" using \ 1 trg_dom Left_a.arr_char left_def hseq_char' by fastforce moreover have "H\<^sub>L a \ = \" using \ 1 trg_dom H\<^sub>L_def by auto ultimately show ?thesis using \ Left_a.dom_simp Left_a.cod_simp by blast qed qed qed interpret Ra: endofunctor \Right a\ \H\<^sub>R a\ using assms obj_self_composable endofunctor_H\<^sub>R [of a] by force interpret Ra: fully_faithful_functor \Right a\ \Right a\ \H\<^sub>R a\ proof show "\f f'. Right_a.par f f' \ H\<^sub>R a f = H\<^sub>R a f' \ f = f'" proof - fix \ \' assume par: "Right_a.par \ \'" assume eq: "H\<^sub>R a \ = H\<^sub>R a \'" have 1: "par \ \'" using par Right_a.arr_char Right_a.dom_char Right_a.cod_char right_def composable_implies_arr null_agreement by metis moreover have "R \ = R \'" using par eq H\<^sub>R_def Right_a.arr_char right_def preserves_arr assms 1 seq_if_composable [of \ a] not_arr_null seq_if_composable [of \' a] by auto ultimately show "\ = \'" using R.is_faithful by blast qed show "\f g \. \ Right_a.ide f; Right_a.ide g; Right_a.in_hom \ (H\<^sub>R a f) (H\<^sub>R a g) \ \ \\. Right_a.in_hom \ f g \ H\<^sub>R a \ = \" proof - fix f g \ assume f: "Right_a.ide f" and g: "Right_a.ide g" and \: "Right_a.in_hom \ (H\<^sub>R a f) (H\<^sub>R a g)" have 1: "a = src f \ a = src g" using assms f g Right_a.ide_char Right_a.arr_char right_def seq_if_composable by auto show "\\. Right_a.in_hom \ f g \ H\<^sub>R a \ = \" proof - have 2: "\\. \\ : f \ g\ \ R \ = \" using f g \ 1 Right_a.ide_char H\<^sub>R_def R.preserves_reflects_arr Right_a.arr_char Right_a.in_hom_char R.is_full by force obtain \ where \: "\\ : f \ g\ \ R \ = \" using 2 by blast have "Right_a.arr \" using \ 1 src_dom Right_a.arr_char right_def hseq_char' by fastforce moreover have "H\<^sub>R a \ = \" using \ 1 src_dom H\<^sub>R_def by auto ultimately show ?thesis using \ Right_a.dom_simp Right_a.cod_simp by blast qed qed qed have "isomorphic (a \ a) a \ a \ a \ null" using assms obj_self_composable unit_in_hom iso_unit isomorphic_def by blast thus ?thesis using La.fully_faithful_functor_axioms Ra.fully_faithful_functor_axioms weak_unit_def by blast qed lemma src_in_sources: assumes "arr \" shows "src \ \ sources \" using assms obj_is_weak_unit R.preserves_arr hseq_char' by auto lemma trg_in_targets: assumes "arr \" shows "trg \ \ targets \" using assms obj_is_weak_unit L.preserves_arr hseq_char' by auto lemma weak_unit_cancel_left: assumes "weak_unit a" and "ide f" and "ide g" and "a \ f \ a \ g" shows "f \ g" proof - have 0: "ide a" using assms weak_unit_def by force interpret Left_a: subcategory V \left a\ using 0 left_hom_is_subcategory by simp interpret Left_a: left_hom V H a using assms weak_unit_self_composable by unfold_locales auto interpret La: fully_faithful_functor \Left a\ \Left a\ \H\<^sub>L a\ using assms weak_unit_def by fast obtain \ where \: "iso \ \ \\ : a \ f \ a \ g\" using assms by blast have 1: "Left_a.iso \ \ Left_a.in_hom \ (a \ f) (a \ g)" proof have "a \ \ \ null" proof - have "a \ dom \ \ null" using assms \ weak_unit_self_composable by (metis arr_dom_iff_arr hseq_char' in_homE match_4) thus ?thesis using hom_connected by simp qed thus "Left_a.in_hom \ (a \ f) (a \ g)" using \ Left_a.hom_char left_def by auto thus "Left_a.iso \" using \ Left_a.iso_char by auto qed hence 2: "Left_a.ide (a \ f) \ Left_a.ide (a \ g)" using Left_a.ide_dom [of \] Left_a.ide_cod [of \] Left_a.dom_simp Left_a.cod_simp by auto hence 3: "Left_a.ide f \ Left_a.ide g" by (metis Left_a.ideI Left_a.ide_def Left_a.null_char assms(2) assms(3) left_def) obtain \ where \: "\ \ Left_a.hom f g \ a \ \ = \" using assms 1 2 3 La.is_full [of g f \] H\<^sub>L_def by auto have "Left_a.iso \" using \ 1 H\<^sub>L_def La.reflects_iso by auto hence "iso \ \ \\ : f \ g\" using \ Left_a.iso_char Left_a.in_hom_char by auto thus ?thesis by auto qed lemma weak_unit_cancel_right: assumes "weak_unit a" and "ide f" and "ide g" and "f \ a \ g \ a" shows "f \ g" proof - have 0: "ide a" using assms weak_unit_def by force interpret Right_a: subcategory V \right a\ using 0 right_hom_is_subcategory by simp interpret Right_a: right_hom V H a using assms weak_unit_self_composable by unfold_locales auto interpret R: fully_faithful_functor \Right a\ \Right a\ \H\<^sub>R a\ using assms weak_unit_def by fast obtain \ where \: "iso \ \ in_hom \ (f \ a) (g \ a)" using assms by blast have 1: "Right_a.iso \ \ \ \ Right_a.hom (f \ a) (g \ a)" proof have "\ \ a \ null" proof - have "dom \ \ a \ null" using assms \ weak_unit_self_composable by (metis arr_dom_iff_arr hseq_char' in_homE match_3) thus ?thesis using hom_connected by simp qed thus "\ \ Right_a.hom (f \ a) (g \ a)" using \ Right_a.hom_char right_def by simp thus "Right_a.iso \" using \ Right_a.iso_char by auto qed hence 2: "Right_a.ide (f \ a) \ Right_a.ide (g \ a)" using Right_a.ide_dom [of \] Right_a.ide_cod [of \] Right_a.dom_simp Right_a.cod_simp by auto hence 3: "Right_a.ide f \ Right_a.ide g" using assms Right_a.ide_char Right_a.arr_char right_def Right_a.ide_def Right_a.null_char by metis obtain \ where \: "\ \ Right_a.hom f g \ \ \ a = \" using assms 1 2 3 R.is_full [of g f \] H\<^sub>R_def by auto have "Right_a.iso \" using \ 1 H\<^sub>R_def R.reflects_iso by auto hence "iso \ \ \\ : f \ g\" using \ Right_a.iso_char Right_a.in_hom_char by auto thus ?thesis by auto qed text \ All sources of an arrow ({\em i.e.}~weak units composable on the right with that arrow) are isomorphic to the chosen source, and similarly for targets. That these statements hold was somewhat surprising to me. \ lemma source_iso_src: assumes "arr \" and "a \ sources \" shows "a \ src \" proof - have 0: "ide a" using assms weak_unit_def by force have 1: "src a = trg a" using assms ide_dom sources_def weak_unit_iff_self_target seq_if_composable weak_unit_self_composable by simp obtain \ where \: "iso \ \ \\ : a \ a \ a\" using assms weak_unit_def by blast have "a \ src a \ src a \ src a" proof - have "src a \ src a \ src a" using 0 obj_is_weak_unit weak_unit_def isomorphic_symmetric by auto moreover have "a \ src a \ src a" proof - have "a \ a \ src a \ a \ src a" proof - have "iso (\ \ src a) \ \\ \ src a : (a \ a) \ src a \ a \ src a\" using 0 1 \ ide_in_hom(2) by auto moreover have "iso \\<^sup>-\<^sup>1[a, a, src a] \ \\\<^sup>-\<^sup>1[a, a, src a] : a \ a \ src a \ (a \ a) \ src a\" using 0 1 iso_assoc' by force ultimately show ?thesis using isos_compose isomorphic_def by auto qed thus ?thesis using assms 0 weak_unit_cancel_left by auto qed ultimately show ?thesis using isomorphic_transitive by meson qed hence "a \ src a" using 0 weak_unit_cancel_right [of "src a" a "src a"] obj_is_weak_unit by auto thus ?thesis using assms seq_if_composable 1 by auto qed lemma target_iso_trg: assumes "arr \" and "b \ targets \" shows "b \ trg \" proof - have 0: "ide b" using assms weak_unit_def by force have 1: "trg \ = src b" using assms seq_if_composable by auto obtain \ where \: "iso \ \ \\ : b \ b \ b\" using assms weak_unit_def by blast have "trg b \ b \ trg b \ trg b" proof - have "trg b \ trg b \ trg b" using 0 obj_is_weak_unit weak_unit_def isomorphic_symmetric by auto moreover have "trg b \ b \ trg b" proof - have "(trg b \ b) \ b \ trg b \ b" proof - have "iso (trg b \ \) \ \trg b \ \ : trg b \ b \ b \ trg b \ b\" using assms 0 1 \ ide_in_hom(2) targetsD(1) weak_unit_self_composable apply (intro conjI hcomp_in_vhom) by auto moreover have "iso \[trg b, b, b] \ \\[trg b, b, b] : (trg b \ b) \ b \ trg b \ b \ b\" using assms(2) 0 1 seq_if_composable targetsD(1-2) weak_unit_self_composable by auto ultimately show ?thesis using isos_compose isomorphic_def by auto qed thus ?thesis using assms 0 weak_unit_cancel_right by auto qed ultimately show ?thesis using isomorphic_transitive by meson qed hence "b \ trg b" using 0 weak_unit_cancel_left [of "trg b" b "trg b"] obj_is_weak_unit by simp thus ?thesis using assms 0 1 seq_if_composable weak_unit_iff_self_source targetsD(1-2) source_iso_src by simp qed lemma is_weak_composition_with_homs: shows "weak_composition_with_homs V H src trg" using src_in_sources trg_in_targets seq_if_composable composable_implies_arr by (unfold_locales, simp_all) interpretation weak_composition_with_homs V H src trg using is_weak_composition_with_homs by auto text \ In a bicategory, the notion of composability defined in terms of the chosen sources and targets coincides with the version defined for a weak composition, which does not involve particular choices. \ lemma connected_iff_seq: assumes "arr \" and "arr \" shows "sources \ \ targets \ \ {} \ src \ = trg \" proof show "src \ = trg \ \ sources \ \ targets \ \ {}" using assms src_in_sources [of \] trg_in_targets [of \] by auto show "sources \ \ targets \ \ {} \ src \ = trg \" proof - assume 1: "sources \ \ targets \ \ {}" obtain a where a: "a \ sources \ \ targets \" using assms 1 by blast have \: "arr \" using a composable_implies_arr by auto have \: "arr \" using a composable_implies_arr by auto have 1: "\a'. a' \ sources \ \ src a' = src a \ trg a' = trg a" proof fix a' assume a': "a' \ sources \" have 1: "a' \ a" using a a' \ src_dom sources_dom source_iso_src isomorphic_transitive isomorphic_symmetric by (meson IntD1) obtain \ where \: "iso \ \ \ \ hom a' a" using 1 by auto show "src a' = src a" using \ src_dom src_cod by auto show "trg a' = trg a" using \ trg_dom trg_cod by auto qed have 2: "\a'. a' \ targets \ \ src a' = src a \ trg a' = trg a" proof fix a' assume a': "a' \ targets \" have 1: "a' \ a" using a a' \ trg_dom targets_dom target_iso_trg isomorphic_transitive isomorphic_symmetric by (meson IntD2) obtain \ where \: "iso \ \ \ \ hom a' a" using 1 by auto show "src a' = src a" using \ src_dom src_cod by auto show "trg a' = trg a" using \ trg_dom trg_cod by auto qed have "src \ = src (src \)" using \ by simp also have "... = src (trg \)" using \ 1 [of "src \"] src_in_sources a weak_unit_self_composable seq_if_composable by auto also have "... = trg (trg \)" using \ by simp also have "... = trg \" using \ by simp finally show "src \ = trg \" by blast qed qed lemma is_associative_weak_composition: shows "associative_weak_composition V H \" proof - have 1: "\\ \. \ \ \ \ null \ src \ = trg \" using H.is_extensional VV.arr_char by force show "associative_weak_composition V H \" proof show "\f g h. ide f \ ide g \ ide h \ f \ g \ null \ g \ h \ null \ \\[f, g, h] : (f \ g) \ h \ f \ g \ h\" using 1 by auto show "\f g h. ide f \ ide g \ ide h \ f \ g \ null \ g \ h \ null \ iso \[f, g, h]" using 1 iso_assoc by presburger show "\\ \ \. \ \ \ \ null \ \ \ \ \ null \ \[cod \, cod \, cod \] \ ((\ \ \) \ \) = (\ \ \ \ \) \ \[dom \, dom \, dom \]" using 1 assoc_naturality hseq_char hseq_char' by metis show "\f g h k. ide f \ ide g \ ide h \ ide k \ sources f \ targets g \ {} \ sources g \ targets h \ {} \ sources h \ targets k \ {} \ (f \ \[g, h, k]) \ \[f, g \ h, k] \ (\[f, g, h] \ k) = \[f, g, h \ k] \ \[f \ g, h, k]" using 1 connected_iff_seq pentagon ideD(1) by auto qed qed interpretation associative_weak_composition V H \ using is_associative_weak_composition by auto theorem is_prebicategory: shows "prebicategory V H \" using src_in_sources trg_in_targets by (unfold_locales, auto) interpretation prebicategory V H \ using is_prebicategory by auto corollary is_prebicategory_with_homs: shows "prebicategory_with_homs V H \ src trg" .. interpretation prebicategory_with_homs V H \ src trg using is_prebicategory_with_homs by auto text \ In a bicategory, an arrow is a weak unit if and only if it is isomorphic to its chosen source (or to its chosen target). \ lemma weak_unit_char: shows "weak_unit a \ a \ src a" and "weak_unit a \ a \ trg a" proof - show "weak_unit a \ a \ src a" using isomorphism_respects_weak_units isomorphic_symmetric by (meson ideD(1) isomorphic_implies_ide(2) obj_is_weak_unit obj_src source_iso_src weak_unit_iff_self_source weak_unit_self_composable(1)) show "weak_unit a \ a \ trg a" using isomorphism_respects_weak_units isomorphic_symmetric by (metis \weak_unit a = isomorphic a (src a)\ ideD(1) isomorphic_implies_hpar(3) isomorphic_implies_ide(1) src_trg target_iso_trg weak_unit_iff_self_target) qed interpretation H: partial_magma H using is_partial_magma by auto text \ Every arrow with respect to horizontal composition is also an arrow with respect to vertical composition. The converse is not necessarily true. \ lemma harr_is_varr: assumes "H.arr \" shows "arr \" proof - have "H.domains \ \ {} \ arr \" proof - assume 1: "H.domains \ \ {}" obtain a where a: "H.ide a \ \ \ a \ null" using 1 H.domains_def by auto show "arr \" using a hseq_char' H.ide_def by blast qed moreover have "H.codomains \ \ {} \ arr \" proof - assume 1: "H.codomains \ \ {}" obtain a where a: "H.ide a \ a \ \ \ null" using 1 H.codomains_def by auto show "arr \" using a hseq_char' ide_def by blast qed ultimately show ?thesis using assms H.arr_def by auto qed text \ An identity for horizontal composition is also an identity for vertical composition. \ lemma horizontal_identity_is_ide: assumes "H.ide \" shows "ide \" proof - have \: "arr \" using assms H.ide_def composable_implies_arr(2) by auto hence 1: "\ \ dom \ \ null" using assms hom_connected H.ide_def by auto have "\ \ dom \ = dom \" using assms 1 H.ide_def by simp moreover have "\ \ dom \ = \" using assms 1 H.ide_def [of \] null_agreement by (metis \ cod_cod cod_dom hcomp_simps\<^sub>W\<^sub>C(3) ideD(2) ide_char' paste_1) ultimately have "dom \ = \" by simp thus ?thesis using \ by (metis ide_dom) qed text \ Every identity for horizontal composition is a weak unit. \ lemma horizontal_identity_is_weak_unit: assumes "H.ide \" shows "weak_unit \" using assms weak_unit_char by (metis H.ide_def comp_target_ide horizontal_identity_is_ide ideD(1) isomorphism_respects_weak_units null_agreement targetsD(2-3) trg_in_targets) end subsection "Vertically Discrete Bicategories are Categories" text \ In this section we show that if a bicategory is discrete with respect to vertical composition, then it is a category with respect to horizontal composition. To obtain this result, we need to establish that the set of arrows for the horizontal composition coincides with the set of arrows for the vertical composition. This is not true for a general bicategory, and even with the assumption that the vertical category is discrete it is not immediately obvious from the definitions. The issue is that the notion ``arrow'' for the horizontal composition is defined in terms of the existence of ``domains'' and ``codomains'' with respect to that composition, whereas the axioms for a bicategory only relate the notion ``arrow'' for the vertical category to the existence of sources and targets with respect to the horizontal composition. So we have to establish that, under the assumption of vertical discreteness, sources coincide with domains and targets coincide with codomains. We also need the fact that horizontal identities are weak units, which previously required some effort to show. \ locale vertically_discrete_bicategory = bicategory + assumes vertically_discrete: "ide = arr" begin interpretation prebicategory_with_homs V H \ src trg using is_prebicategory_with_homs by auto interpretation H: partial_magma H using is_partial_magma(1) by auto lemma weak_unit_is_horizontal_identity: assumes "weak_unit a" shows "H.ide a" proof - have "a \ a \ H.null" using assms weak_unit_self_composable by simp moreover have "\f. f \ a \ H.null \ f \ a = f" proof - fix f assume "f \ a \ H.null" hence "f \ a \ f" using assms comp_ide_source composable_implies_arr(2) sourcesI vertically_discrete by auto thus "f \ a = f" using vertically_discrete isomorphic_def by auto qed moreover have "\f. a \ f \ H.null \ a \ f = f" proof - fix f assume "a \ f \ H.null" hence "a \ f \ f" using assms comp_target_ide composable_implies_arr(1) targetsI vertically_discrete by auto thus "a \ f = f" using vertically_discrete isomorphic_def by auto qed ultimately show "H.ide a" using H.ide_def by simp qed lemma sources_eq_domains: shows "sources \ = H.domains \" using weak_unit_is_horizontal_identity H.domains_def sources_def horizontal_identity_is_weak_unit by auto lemma targets_eq_codomains: shows "targets \ = H.codomains \" using weak_unit_is_horizontal_identity H.codomains_def targets_def horizontal_identity_is_weak_unit by auto lemma arr_agreement: shows "arr = H.arr" using arr_def H.arr_def arr_iff_has_src arr_iff_has_trg sources_eq_domains targets_eq_codomains by auto interpretation H: category H proof show "\g f. g \ f \ H.null \ H.seq g f" using arr_agreement hcomp_simps\<^sub>W\<^sub>C(1) by auto show "\f. (H.domains f \ {}) = (H.codomains f \ {})" using sources_eq_domains targets_eq_codomains arr_iff_has_src arr_iff_has_trg by simp fix f g h show "H.seq h g \ H.seq (h \ g) f \ H.seq g f" using null_agreement arr_agreement H.not_arr_null preserves_arr VoV.arr_char by (metis hseq_char' match_1) show "H.seq h (g \ f) \ H.seq g f \ H.seq h g" using null_agreement arr_agreement H.not_arr_null preserves_arr VoV.arr_char by (metis hseq_char' match_2) show "H.seq g f \ H.seq h g \ H.seq (h \ g) f" using arr_agreement match_3 hseq_char(1) by auto show "H.seq g f \ H.seq h g \ (h \ g) \ f = h \ g \ f" proof - assume hg: "H.seq h g" assume gf: "H.seq g f" have "iso \[h, g, f] \ \\[h, g, f] : (h \ g) \ f \ h \ g \ f\" using hg gf vertically_discrete arr_agreement hseq_char assoc_in_hom iso_assoc by auto thus ?thesis using arr_agreement vertically_discrete by auto qed qed proposition is_category: shows "category H" .. end subsection "Obtaining the Unitors" text \ We now want to exploit the construction of unitors in a prebicategory with units, to obtain left and right unitors in a bicategory. However, a bicategory is not \emph{a priori} a prebicategory with units, because a bicategory only assigns unit isomorphisms to each \emph{object}, not to each weak unit. In order to apply the results about prebicategories with units to a bicategory, we first need to extend the bicategory to a prebicategory with units, by extending the mapping \\\, which provides a unit isomorphism for each object, to a mapping that assigns a unit isomorphism to all weak units. This extension can be made in an arbitrary way, as the values chosen for non-objects ultimately do not affect the components of the unitors at objects. \ context bicategory begin interpretation prebicategory V H \ using is_prebicategory by auto definition \' where "\' a \ SOME \. iso \ \ \ \ hom (a \ a) a \ (obj a \ \ = \[a])" lemma \'_extends_\: assumes "weak_unit a" shows "iso (\' a)" and "\\' a : a \ a \ a\" and "obj a \ \' a = \[a]" proof - let ?P = "\a \. iso \ \ \\ : a \ a \ a\ \ (obj a \ \ = \[a])" have "\\. ?P a \" by (metis assms iso_some_unit(1) iso_some_unit(2) iso_unit unit_in_vhom) hence 1: "?P a (\' a)" using \'_def someI_ex [of "?P a"] by simp show "iso (\' a)" using 1 by simp show "\\' a : a \ a \ a\" using 1 by simp show "obj a \ \' a = \[a]" using 1 by simp qed proposition extends_to_prebicategory_with_units: shows "prebicategory_with_units V H \ \'" using \'_extends_\ by unfold_locales auto interpretation PB: prebicategory_with_units V H \ \' using extends_to_prebicategory_with_units by auto interpretation PB: prebicategory_with_homs V H \ src trg using is_prebicategory_with_homs by auto interpretation PB: prebicategory_with_homs_and_units V H \ \' src trg .. proposition extends_to_prebicategory_with_homs_and_units: shows "prebicategory_with_homs_and_units V H \ \' src trg" .. definition lunit ("\[_]") where "\[a] \ PB.lunit a" definition runit ("\[_]") where "\[a] \ PB.runit a" abbreviation lunit' ("\\<^sup>-\<^sup>1[_]") where "\\<^sup>-\<^sup>1[a] \ inv \[a]" abbreviation runit' ("\\<^sup>-\<^sup>1[_]") where "\\<^sup>-\<^sup>1[a] \ inv \[a]" text \ \sloppypar The characterizations of the left and right unitors that we obtain from locale @{locale prebicategory_with_homs_and_units} mention the arbitarily chosen extension \\'\, rather than the given \\\. We want ``native versions'' for the present context. \ lemma lunit_char: assumes "ide f" shows "\\[f] : L f \ f\" and "L \[f] = (\[trg f] \ f) \ \\<^sup>-\<^sup>1[trg f, trg f, f]" and "\!\. \\ : L f \ f\ \ L \ = (\[trg f] \ f) \ \\<^sup>-\<^sup>1[trg f, trg f, f]" proof - have 1: "trg (PB.lunit f) = trg f" using assms PB.lunit_char [of f] vconn_implies_hpar(2) vconn_implies_hpar(4) by metis show "\\[f] : L f \ f\" unfolding lunit_def using assms PB.lunit_char by simp show "L \[f] = (\[trg f] \ f) \ \\<^sup>-\<^sup>1[trg f, trg f, f]" unfolding lunit_def using assms 1 PB.lunit_char obj_is_weak_unit \'_extends_\ by simp let ?P = "\\. \\ : L f \ f\ \ L \ = (\[trg f] \ f) \ \\<^sup>-\<^sup>1[trg f, trg f, f]" have "?P = (\\. \\ : trg f \ f \ f\ \ trg f \ \ = (\' (trg f) \ f) \ inv \[trg f, trg f, f])" proof - have "\\. \\ : L f \ f\ \ \\ : trg f \ f \ f\" using assms by simp moreover have "\\. \\ : L f \ f\ \ L \ = (\[trg f] \ f) \ \\<^sup>-\<^sup>1[trg f, trg f, f] \ trg f \ \ = (\' (trg f) \ f) \ inv \[trg f, trg f, f]" using calculation obj_is_weak_unit \'_extends_\ by auto ultimately show ?thesis by blast qed thus "\!\. \\ : L f \ f\ \ L \ = (\[trg f] \ f) \ \\<^sup>-\<^sup>1[trg f, trg f, f]" using assms PB.lunit_char by simp qed lemma lunit_in_hom [intro]: assumes "ide f" shows "\\[f] : src f \ trg f\" and "\\[f] : trg f \ f \ f\" proof - show "\\[f] : trg f \ f \ f\" using assms lunit_char by auto thus "\\[f] : src f \ trg f\" by (metis arrI in_hhomI vconn_implies_hpar(1-4)) qed lemma lunit_in_vhom [simp]: assumes "ide f" and "trg f = b" shows "\\[f] : b \ f \ f\" using assms by auto lemma lunit_simps [simp]: assumes "ide f" shows "arr \[f]" and "src \[f] = src f" and "trg \[f] = trg f" and "dom \[f] = trg f \ f" and "cod \[f] = f" using assms lunit_in_hom apply auto using assms lunit_in_hom apply blast using assms lunit_in_hom by blast lemma runit_char: assumes "ide f" shows "\\[f] : R f \ f\" and "R \[f] = (f \ \[src f]) \ \[f, src f, src f]" and "\!\. \\ : R f \ f\ \ R \ = (f \ \[src f]) \ \[f, src f, src f]" proof - have 1: "src (PB.runit f) = src f" using assms PB.runit_char [of f] vconn_implies_hpar(1) vconn_implies_hpar(3) by metis show "\\[f] : R f \ f\" unfolding runit_def using assms PB.runit_char by simp show "R \[f] = (f \ \[src f]) \ \[f, src f, src f]" unfolding runit_def using assms 1 PB.runit_char obj_is_weak_unit \'_extends_\ by simp let ?P = "\\. \\ : R f \ f\ \ R \ = (f \ \[src f]) \ \[f, src f, src f]" have "?P = (\\. \\ : f \ src f \ f\ \ \ \ src f = (f \ \' (src f)) \ \[f, src f, src f])" proof - have "\\. \\ : R f \ f\ \ \\ : f \ src f \ f\" using assms by simp moreover have "\\. \\ : R f \ f\ \ R \ = (f \ \[src f]) \ \[f, src f, src f] \ \ \ src f = (f \ \' (src f)) \ \[f, src f, src f]" using calculation obj_is_weak_unit \'_extends_\ by auto ultimately show ?thesis by blast qed thus "\!\. \\ : R f \ f\ \ R \ = (f \ \[src f]) \ \[f, src f, src f]" using assms PB.runit_char by simp qed lemma runit_in_hom [intro]: assumes "ide f" shows "\\[f] : src f \ trg f\" and "\\[f] : f \ src f \ f\" proof - show "\\[f] : f \ src f \ f\" using assms runit_char by auto thus "\\[f] : src f \ trg f\" by (metis arrI in_hhom_def vconn_implies_hpar(1-4)) qed lemma runit_in_vhom [simp]: assumes "ide f" and "src f = a" shows "\\[f] : f \ a \ f\" using assms by auto lemma runit_simps [simp]: assumes "ide f" shows "arr \[f]" and "src \[f] = src f" and "trg \[f] = trg f" and "dom \[f] = f \ src f" and "cod \[f] = f" using assms runit_in_hom apply auto using assms runit_in_hom apply blast using assms runit_in_hom by blast lemma lunit_eqI: assumes "ide f" and "\\ : trg f \ f \ f\" and "trg f \ \ = (\[trg f] \ f) \ \\<^sup>-\<^sup>1[trg f, trg f, f]" shows "\ = \[f]" unfolding lunit_def using assms PB.lunit_eqI \'_extends_\ trg.preserves_ide obj_is_weak_unit by simp lemma runit_eqI: assumes "ide f" and "\\ : f \ src f \ f\" and "\ \ src f = (f \ \[src f]) \ \[f, src f, src f]" shows "\ = \[f]" unfolding runit_def using assms PB.runit_eqI \'_extends_\ src.preserves_ide obj_is_weak_unit by simp lemma lunit_naturality: assumes "arr \" shows "\ \ \[dom \] = \[cod \] \ (trg \ \ \)" unfolding lunit_def using assms PB.lunit_naturality by auto lemma runit_naturality: assumes "arr \" shows "\ \ \[dom \] = \[cod \] \ (\ \ src \)" unfolding runit_def using assms PB.runit_naturality by auto lemma iso_lunit [simp]: assumes "ide f" shows "iso \[f]" unfolding lunit_def using assms PB.iso_lunit by blast lemma iso_runit [simp]: assumes "ide f" shows "iso \[f]" unfolding runit_def using assms PB.iso_runit by blast lemma iso_lunit' [simp]: assumes "ide f" shows "iso \\<^sup>-\<^sup>1[f]" using assms iso_lunit by blast lemma iso_runit' [simp]: assumes "ide f" shows "iso \\<^sup>-\<^sup>1[f]" using assms iso_runit by blast lemma lunit'_in_hom [intro]: assumes "ide f" shows "\\\<^sup>-\<^sup>1[f] : src f \ trg f\" and "\\\<^sup>-\<^sup>1[f] : f \ trg f \ f\" proof - show "\\\<^sup>-\<^sup>1[f] : f \ trg f \ f\" using assms lunit_char iso_lunit by simp thus "\\\<^sup>-\<^sup>1[f] : src f \ trg f\" using assms src_dom trg_dom by simp qed lemma lunit'_in_vhom [simp]: assumes "ide f" and "trg f = b" shows "\\\<^sup>-\<^sup>1[f] : f \ b \ f\" using assms by auto lemma lunit'_simps [simp]: assumes "ide f" shows "arr \\<^sup>-\<^sup>1[f]" and "src \\<^sup>-\<^sup>1[f] = src f" and "trg \\<^sup>-\<^sup>1[f] = trg f" and "dom \\<^sup>-\<^sup>1[f] = f" and "cod \\<^sup>-\<^sup>1[f] = trg f \ f" using assms lunit'_in_hom by auto lemma runit'_in_hom [intro]: assumes "ide f" shows "\\\<^sup>-\<^sup>1[f] : src f \ trg f\" and "\\\<^sup>-\<^sup>1[f] : f \ f \ src f\" proof - show "\\\<^sup>-\<^sup>1[f] : f \ f \ src f\" using assms runit_char iso_runit by simp thus "\\\<^sup>-\<^sup>1[f] : src f \ trg f\" using src_dom trg_dom by (simp add: assms) qed lemma runit'_in_vhom [simp]: assumes "ide f" and "src f = a" shows "\\\<^sup>-\<^sup>1[f] : f \ f \ a\" using assms by auto lemma runit'_simps [simp]: assumes "ide f" shows "arr \\<^sup>-\<^sup>1[f]" and "src \\<^sup>-\<^sup>1[f] = src f" and "trg \\<^sup>-\<^sup>1[f] = trg f" and "dom \\<^sup>-\<^sup>1[f] = f" and "cod \\<^sup>-\<^sup>1[f] = f \ src f" using assms runit'_in_hom by auto interpretation L: endofunctor V L .. interpretation \: transformation_by_components V V L map lunit using lunit_in_hom lunit_naturality by unfold_locales auto interpretation \: natural_isomorphism V V L map \.map using iso_lunit by (unfold_locales, auto) lemma natural_isomorphism_\: shows "natural_isomorphism V V L map \.map" .. abbreviation \ where "\ \ \.map" lemma \_ide_simp: assumes "ide f" shows "\ f = \[f]" using assms by simp interpretation L: equivalence_functor V V L using L.isomorphic_to_identity_is_equivalence \.natural_isomorphism_axioms by simp lemma equivalence_functor_L: shows "equivalence_functor V V L" .. lemma lunit_commutes_with_L: assumes "ide f" shows "\[L f] = L \[f]" unfolding lunit_def using assms PB.lunit_commutes_with_L by blast interpretation R: endofunctor V R .. interpretation \: transformation_by_components V V R map runit using runit_in_hom runit_naturality by unfold_locales auto interpretation \: natural_isomorphism V V R map \.map using iso_runit by (unfold_locales, auto) lemma natural_isomorphism_\: shows "natural_isomorphism V V R map \.map" .. abbreviation \ where "\ \ \.map" lemma \_ide_simp: assumes "ide f" shows "\ f = \[f]" using assms by simp interpretation R: equivalence_functor V V R using R.isomorphic_to_identity_is_equivalence \.natural_isomorphism_axioms by simp lemma equivalence_functor_R: shows "equivalence_functor V V R" .. lemma runit_commutes_with_R: assumes "ide f" shows "\[R f] = R \[f]" unfolding runit_def using assms PB.runit_commutes_with_R by blast lemma lunit'_naturality: assumes "arr \" shows "(trg \ \ \) \ \\<^sup>-\<^sup>1[dom \] = \\<^sup>-\<^sup>1[cod \] \ \" using assms iso_lunit lunit_naturality invert_opposite_sides_of_square L.preserves_arr L.preserves_cod arr_cod ide_cod ide_dom lunit_simps(1) lunit_simps(4) seqI by presburger lemma runit'_naturality: assumes "arr \" shows "(\ \ src \) \ \\<^sup>-\<^sup>1[dom \] = \\<^sup>-\<^sup>1[cod \] \ \" using assms iso_runit runit_naturality invert_opposite_sides_of_square R.preserves_arr R.preserves_cod arr_cod ide_cod ide_dom runit_simps(1) runit_simps(4) seqI by presburger lemma isomorphic_unit_right: assumes "ide f" shows "f \ src f \ f" using assms runit'_in_hom iso_runit' isomorphic_def isomorphic_symmetric by blast lemma isomorphic_unit_left: assumes "ide f" shows "trg f \ f \ f" using assms lunit'_in_hom iso_lunit' isomorphic_def isomorphic_symmetric by blast end subsection "Further Properties of Bicategories" text \ Here we derive further properties of bicategories, now that we have the unitors at our disposal. This section generalizes the corresponding development in theory @{theory MonoidalCategory.MonoidalCategory}, which has some diagrams to illustrate the longer calculations. The present section also includes some additional facts that are now nontrivial due to the partiality of horizontal composition. \ context bicategory begin lemma unit_simps [simp]: assumes "obj a" shows "arr \[a]" and "src \[a] = a" and "trg \[a] = a" and "dom \[a] = a \ a" and "cod \[a] = a" using assms unit_in_hom by blast+ lemma triangle: assumes "ide f" and "ide g" and "src g = trg f" shows "(g \ \[f]) \ \[g, src g, f] = \[g] \ f" proof - let ?b = "src g" have *: "(g \ \[?b \ f]) \ \[g, ?b, ?b \ f] = \[g] \ ?b \ f" proof - have 1: "((g \ \[?b \ f]) \ \[g, ?b, ?b \ f]) \ \[g \ ?b, ?b, f] = (\[g] \ ?b \ f) \ \[g \ ?b, ?b, f]" proof - have "((g \ \[?b \ f]) \ \[g, ?b, ?b \ f]) \ \[g \ ?b, ?b, f] = (g \ \[?b \ f]) \ \[g, ?b, ?b \ f] \ \[g \ ?b, ?b, f]" using HoVH_def HoHV_def comp_assoc by auto also have "... = (g \ \[?b \ f]) \ (g \ \[?b, ?b, f]) \ \[g, ?b \ ?b, f] \ (\[g, ?b, ?b] \ f)" using assms pentagon by force also have "... = ((g \ \[?b \ f]) \ (g \ \[?b, ?b, f])) \ \[g, ?b \ ?b, f] \ (\[g, ?b, ?b] \ f)" using assms assoc_in_hom HoVH_def HoHV_def comp_assoc by auto also have "... = ((g \ ?b \ \[f]) \ (g \ \[?b, ?b, f])) \ \[g, ?b \ ?b, f] \ (\[g, ?b, ?b] \ f)" using assms lunit_commutes_with_L lunit_in_hom by force also have "... = ((g \ (\[?b] \ f) \ \\<^sup>-\<^sup>1[?b, ?b, f]) \ (g \ \[?b, ?b, f])) \ \[g, ?b \ ?b, f] \ (\[g, ?b, ?b] \ f)" using assms lunit_char(2) by force also have "... = (g \ ((\[?b] \ f) \ \\<^sup>-\<^sup>1[?b, ?b, f]) \ \[?b, ?b, f]) \ \[g, ?b \ ?b, f] \ (\[g, ?b, ?b] \ f)" using assms interchange [of g g "(\[?b] \ f) \ \\<^sup>-\<^sup>1[?b, ?b, f]" "\[?b, ?b, f]"] by auto also have "... = ((g \ \[?b] \ f) \ \[g, ?b \ ?b, f]) \ (\[g, ?b, ?b] \ f)" using assms comp_arr_dom comp_assoc_assoc' comp_assoc by auto also have "... = (\[g, ?b, f] \ ((g \ \[?b]) \ f)) \ (\[g, ?b, ?b] \ f)" using assms assoc_naturality [of g "\[?b]" f] by simp also have "... = \[g, ?b, f] \ ((g \ \[?b]) \ \[g, ?b, ?b] \ f)" using assms interchange [of "g \ \[?b]" "\[g, ?b, ?b]" f f] comp_assoc by simp also have "... = \[g, ?b, f] \ ((\[g] \ ?b) \ f)" using assms runit_char(2) by force also have "... = (\[g] \ ?b \ f) \ \[g \ ?b, ?b, f]" using assms assoc_naturality [of "\[g]" ?b f] by auto finally show ?thesis by blast qed show "(g \ \[?b \ f]) \ \[g, ?b, ?b \ f] = \[g] \ ?b \ f" proof - have "epi \[g \ ?b, ?b, f]" using assms preserves_ide iso_assoc iso_is_retraction retraction_is_epi by force thus ?thesis using assms 1 by auto qed qed have "(g \ \[f]) \ \[g, ?b, f] = ((g \ \[f]) \ (g \ \[?b \ f]) \ (g \ ?b \ \\<^sup>-\<^sup>1[f])) \ (g \ ?b \ \[f]) \ \[g, ?b, ?b \ f] \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f])" proof - have "\[g, ?b, f] = (g \ ?b \ \[f]) \ \[g, ?b, ?b \ f] \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f])" proof - have "\[g, ?b, f] = (g \ ?b \ f) \ \[g, ?b, f]" using assms comp_cod_arr by simp have "\[g, ?b, f] = ((g \ ?b \ \[f]) \ (g \ ?b \ \\<^sup>-\<^sup>1[f])) \ \[g, ?b, f]" using assms comp_cod_arr comp_arr_inv' whisker_left [of g] whisker_left [of ?b "\[f]" "\\<^sup>-\<^sup>1[f]"] by simp also have "... = (g \ ?b \ \[f]) \ \[g, ?b, ?b \ f] \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f])" using assms iso_lunit assoc_naturality [of g ?b "\\<^sup>-\<^sup>1[f]"] comp_assoc by force finally show ?thesis by blast qed moreover have "g \ \[f] = (g \ \[f]) \ (g \ \[?b \ f]) \ (g \ ?b \ \\<^sup>-\<^sup>1[f])" proof - have "(g \ \[?b \ f]) \ (g \ ?b \ \\<^sup>-\<^sup>1[f]) = g \ ?b \ f" proof - have "(g \ \[?b \ f]) \ (g \ ?b \ \\<^sup>-\<^sup>1[f]) = (g \ ?b \ \[f]) \ (g \ ?b \ \\<^sup>-\<^sup>1[f])" using assms lunit_in_hom lunit_commutes_with_L by simp also have "... = g \ ?b \ f" using assms comp_arr_inv' whisker_left [of g] whisker_left [of ?b "\[f]" "\\<^sup>-\<^sup>1[f]"] by simp finally show ?thesis by blast qed thus ?thesis using assms comp_arr_dom by auto qed ultimately show ?thesis by simp qed also have "... = (g \ \[f]) \ (g \ \[?b \ f]) \ ((g \ ?b \ \\<^sup>-\<^sup>1[f]) \ (g \ ?b \ \[f])) \ \[g, ?b, ?b \ f] \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f])" using comp_assoc by simp also have "... = (g \ \[f]) \ (g \ \[?b \ f]) \ ((g \ ?b \ (?b \ f)) \ \[g, ?b, ?b \ f]) \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f])" using assms iso_lunit comp_inv_arr' interchange [of g g "?b \ \\<^sup>-\<^sup>1[f]" "?b \ \[f]"] interchange [of ?b ?b "\\<^sup>-\<^sup>1[f]" "\[f]"] comp_assoc by auto also have "... = (g \ \[f]) \ ((g \ \[?b \ f]) \ \[g, ?b, ?b \ f]) \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f])" using assms comp_cod_arr comp_assoc by auto also have "... = \[g] \ f" proof - have "\[g] \ f = (g \ \[f]) \ (\[g] \ ?b \ f) \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f])" proof - have "(g \ \[f]) \ (\[g] \ ?b \ f) \ ((g \ ?b) \ \\<^sup>-\<^sup>1[f]) = (g \ \[f]) \ (\[g] \ (g \ ?b) \ (?b \ f) \ \\<^sup>-\<^sup>1[f])" using assms iso_lunit interchange [of "\[g]" "g \ ?b" "?b \ f" "\\<^sup>-\<^sup>1[f]"] by force also have "... = (g \ \[f]) \ (\[g] \ \\<^sup>-\<^sup>1[f])" using assms comp_arr_dom comp_cod_arr by simp also have "... = \[g] \ \[f] \ \\<^sup>-\<^sup>1[f]" using assms interchange [of g "\[g]" "\[f]" "\\<^sup>-\<^sup>1[f]"] comp_cod_arr by simp also have "... = \[g] \ f" using assms iso_lunit comp_arr_inv' by simp finally show ?thesis by argo qed thus ?thesis using assms * by argo qed finally show ?thesis by blast qed lemma lunit_hcomp_gen: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "(f \ \[g \ h]) \ (f \ \[trg g, g, h]) = f \ \[g] \ h" proof - have "((f \ \[g \ h]) \ (f \ \[trg g, g, h])) \ \[f, trg g \ g, h] \ (\[f, trg g, g] \ h) = (f \ (\[g] \ h)) \ \[f, trg g \ g, h] \ (\[f, trg g, g] \ h)" proof - have "((f \ \[g \ h]) \ (f \ \[trg g, g, h])) \ (\[f, trg g \ g, h] \ (\[f, trg g, g] \ h)) = ((f \ \[g \ h]) \ \[f, trg g, g \ h]) \ \[f \ trg g, g, h]" using assms pentagon comp_assoc by simp also have "... = (\[f] \ (g \ h)) \ \[f \ trg g, g, h]" using assms triangle [of "g \ h" f] by auto also have "... = \[f, g, h] \ ((\[f] \ g) \ h)" using assms assoc_naturality [of "\[f]" g h] by simp also have "... = (\[f, g, h] \ ((f \ \[g]) \ h)) \ (\[f, trg g, g] \ h)" using assms triangle interchange [of "f \ \[g]" "\[f, trg g, g]" h h] comp_assoc by auto also have "... = (f \ (\[g] \ h)) \ (\[f, trg g \ g, h] \ (\[f, trg g, g] \ h))" using assms assoc_naturality [of f "\[g]" h] comp_assoc by simp finally show ?thesis by blast qed moreover have "iso (\[f, trg g \ g, h] \ (\[f, trg g, g] \ h))" using assms iso_assoc isos_compose by simp ultimately show ?thesis using assms iso_is_retraction retraction_is_epi epiE [of "\[f, trg g \ g, h] \ (\[f, trg g, g] \ h)" "(f \ \[g \ h]) \ (f \ \[trg g, g, h])" "f \ \[g] \ h"] by auto qed lemma lunit_hcomp: assumes "ide f" and "ide g" and "src f = trg g" shows "\[f \ g] \ \[trg f, f, g] = \[f] \ g" and "\\<^sup>-\<^sup>1[trg f, f, g] \ \\<^sup>-\<^sup>1[f \ g] = \\<^sup>-\<^sup>1[f] \ g" and "\[f \ g] = (\[f] \ g) \ \\<^sup>-\<^sup>1[trg f, f, g]" and "\\<^sup>-\<^sup>1[f \ g] = \[trg f, f, g] \ (\\<^sup>-\<^sup>1[f] \ g)" proof - show 1: "\[f \ g] \ \[trg f, f, g] = \[f] \ g" proof - have "L (\[f \ g] \ \[trg f, f, g]) = L (\[f] \ g)" using assms interchange [of "trg f" "trg f" "\[f \ g]" "\[trg f, f, g]"] lunit_hcomp_gen by fastforce thus ?thesis using assms L.is_faithful [of "\[f \ g] \ \[trg f, f, g]" "\[f] \ g"] by force qed show "\\<^sup>-\<^sup>1[trg f, f, g] \ \\<^sup>-\<^sup>1[f \ g] = \\<^sup>-\<^sup>1[f] \ g" proof - have "\\<^sup>-\<^sup>1[trg f, f, g] \ \\<^sup>-\<^sup>1[f \ g] = inv (\[f \ g] \ \[trg f, f, g])" using assms by (simp add: inv_comp) also have "... = inv (\[f] \ g)" using 1 by simp also have "... = \\<^sup>-\<^sup>1[f] \ g" using assms by simp finally show ?thesis by simp qed show 2: "\[f \ g] = (\[f] \ g) \ \\<^sup>-\<^sup>1[trg f, f, g]" using assms 1 invert_side_of_triangle(2) by auto show "\\<^sup>-\<^sup>1[f \ g] = \[trg f, f, g] \ (\\<^sup>-\<^sup>1[f] \ g)" proof - have "\\<^sup>-\<^sup>1[f \ g] = inv ((\[f] \ g) \ \\<^sup>-\<^sup>1[trg f, f, g])" using 2 by simp also have "... = \[trg f, f, g] \ inv (\[f] \ g)" using assms inv_comp by simp also have "... = \[trg f, f, g] \ (\\<^sup>-\<^sup>1[f] \ g)" using assms by simp finally show ?thesis by simp qed qed lemma runit_hcomp_gen: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "\[f \ g] \ h = ((f \ \[g]) \ h) \ (\[f, g, src g] \ h)" proof - have "\[f \ g] \ h = ((f \ g) \ \[h]) \ \[f \ g, src g, h]" using assms triangle by simp also have "... = (\\<^sup>-\<^sup>1[f, g, h] \ (f \ g \ \[h]) \ \[f, g, src g \ h]) \ \[f \ g, src g, h]" using assms assoc_naturality [of f g "\[h]"] invert_side_of_triangle(1) by simp also have "... = \\<^sup>-\<^sup>1[f, g, h] \ (f \ g \ \[h]) \ \[f, g, src g \ h] \ \[f \ g, src g, h]" using comp_assoc by simp also have "... = (\\<^sup>-\<^sup>1[f, g, h] \ (f \ (\[g] \ h))) \ (f \ \\<^sup>-\<^sup>1[g, src g, h]) \ \[f, g, src g \ h] \ \[f \ g, src g, h]" using assms interchange [of f f] triangle comp_assoc invert_side_of_triangle(2) [of "\[g] \ h" "g \ \[h]" "\[g, src g, h]"] by simp also have "... = ((f \ \[g]) \ h) \ \\<^sup>-\<^sup>1[f, g \ src g, h] \ (f \ \\<^sup>-\<^sup>1[g, src g, h]) \ \[f, g, src g \ h] \ \[f \ g, src g, h]" using assms assoc'_naturality [of f "\[g]" h] comp_assoc by simp also have "... = ((f \ \[g]) \ h) \ (\[f, g, src g] \ h)" using assms pentagon [of f g "src g" h] iso_assoc inv_hcomp invert_side_of_triangle(1) [of "\[f, g, src g \ h] \ \[f \ g, src g, h]" "f \ \[g, src g, h]" "\[f, g \ src g, h] \ (\[f, g, src g] \ h)"] invert_side_of_triangle(1) [of "(f \ \\<^sup>-\<^sup>1[g, src g, h]) \ \[f, g, src g \ h] \ \[f \ g, src g, h]" "\[f, g \ src g, h]" "\[f, g, src g] \ h"] by auto finally show ?thesis by blast qed lemma runit_hcomp: assumes "ide f" and "ide g" and "src f = trg g" shows "\[f \ g] = (f \ \[g]) \ \[f, g, src g]" and "\\<^sup>-\<^sup>1[f \ g] = \\<^sup>-\<^sup>1[f, g, src g] \ (f \ \\<^sup>-\<^sup>1[g])" and "\[f \ g] \ \\<^sup>-\<^sup>1[f, g, src g] = f \ \[g]" and "\[f, g, src g] \ \\<^sup>-\<^sup>1[f \ g] = f \ \\<^sup>-\<^sup>1[g]" proof - show 1: "\[f \ g] = (f \ \[g]) \ \[f, g, src g]" using assms interchange [of "f \ \[g]" "\[f, g, src g]" "src g" "src g"] runit_hcomp_gen [of f g "src g"] R.is_faithful [of "(f \ \[g]) \ (\[f, g, src g])" "\[f \ g]"] by simp show "\\<^sup>-\<^sup>1[f \ g] = \\<^sup>-\<^sup>1[f, g, src g] \ (f \ \\<^sup>-\<^sup>1[g])" using assms 1 inv_comp inv_hcomp by auto show 2: "\[f \ g] \ \\<^sup>-\<^sup>1[f, g, src g] = f \ \[g]" using assms 1 comp_arr_dom comp_cod_arr comp_assoc hseqI' comp_assoc_assoc' by auto show "\[f, g, src g] \ \\<^sup>-\<^sup>1[f \ g] = f \ \\<^sup>-\<^sup>1[g]" proof - have "\[f, g, src g] \ \\<^sup>-\<^sup>1[f \ g] = inv (\[f \ g] \ \\<^sup>-\<^sup>1[f, g, src g])" using assms inv_comp by simp also have "... = inv (f \ \[g])" using 2 by simp also have "... = f \ \\<^sup>-\<^sup>1[g]" using assms inv_hcomp [of f "\[g]"] by simp finally show ?thesis by simp qed qed lemma unitor_coincidence: assumes "obj a" shows "\[a] = \[a]" and "\[a] = \[a]" proof - have "R \[a] = R \[a] \ R \[a] = R \[a]" proof - have "R \[a] = (a \ \[a]) \ \[a, a, a]" using assms lunit_hcomp [of a a] lunit_commutes_with_L [of a] by auto moreover have "(a \ \[a]) \ \[a, a, a] = R \[a]" using assms triangle [of a a] by auto moreover have "(a \ \[a]) \ \[a, a, a] = R \[a]" proof - have "(a \ \[a]) \ \[a, a, a] = ((\[a] \ a) \ \\<^sup>-\<^sup>1[a, a, a]) \ \[a, a, a]" using assms lunit_char(2) by force also have "... = R \[a]" using assms comp_arr_dom comp_assoc comp_assoc_assoc' apply (elim objE) by (simp add: assms) finally show ?thesis by blast qed ultimately show ?thesis by argo qed moreover have "par \[a] \[a] \ par \[a] \[a]" using assms by auto ultimately have 1: "\[a] = \[a] \ \[a] = \[a]" using R.is_faithful by blast show "\[a] = \[a]" using 1 by auto show "\[a] = \[a]" using 1 by auto qed lemma unit_triangle: assumes "obj a" shows "\[a] \ a = (a \ \[a]) \ \[a, a, a]" and "(\[a] \ a) \ \\<^sup>-\<^sup>1[a, a, a] = a \ \[a]" proof - show 1: "\[a] \ a = (a \ \[a]) \ \[a, a, a]" using assms triangle [of a a] unitor_coincidence by auto show "(\[a] \ a) \ \\<^sup>-\<^sup>1[a, a, a] = a \ \[a]" using assms 1 invert_side_of_triangle(2) [of "\[a] \ a" "a \ \[a]" "\[a, a, a]"] assoc'_eq_inv_assoc by (metis hseqI' iso_assoc objE obj_def' unit_simps(1) unit_simps(2)) qed lemma hcomp_assoc_isomorphic: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "(f \ g) \ h \ f \ g \ h" using assms assoc_in_hom [of f g h] iso_assoc isomorphic_def by auto lemma hcomp_arr_obj: assumes "arr \" and "obj a" and "src \ = a" shows "\ \ a = \\<^sup>-\<^sup>1[cod \] \ \ \ \[dom \]" and "\[cod \] \ (\ \ a) \ \\<^sup>-\<^sup>1[dom \] = \" proof - show "\ \ a = \\<^sup>-\<^sup>1[cod \] \ \ \ \[dom \]" using assms iso_runit runit_naturality comp_cod_arr by (metis ide_cod ide_dom invert_side_of_triangle(1) runit_simps(1) runit_simps(5) seqI) show "\[cod \] \ (\ \ a) \ \\<^sup>-\<^sup>1[dom \] = \" using assms iso_runit runit_naturality [of \] comp_cod_arr by (metis ide_dom invert_side_of_triangle(2) comp_assoc runit_simps(1) runit_simps(5) seqI) qed lemma hcomp_obj_arr: assumes "arr \" and "obj b" and "b = trg \" shows "b \ \ = \\<^sup>-\<^sup>1[cod \] \ \ \ \[dom \]" and "\[cod \] \ (b \ \) \ \\<^sup>-\<^sup>1[dom \] = \" proof - show "b \ \ = \\<^sup>-\<^sup>1[cod \] \ \ \ \[dom \]" using assms iso_lunit lunit_naturality comp_cod_arr by (metis ide_cod ide_dom invert_side_of_triangle(1) lunit_simps(1) lunit_simps(5) seqI) show "\[cod \] \ (b \ \) \ \\<^sup>-\<^sup>1[dom \] = \" using assms iso_lunit lunit_naturality [of \] comp_cod_arr by (metis ide_dom invert_side_of_triangle(2) comp_assoc lunit_simps(1) lunit_simps(5) seqI) qed lemma hcomp_reassoc: assumes "arr \" and "arr \" and "arr \" and "src \ = trg \" and "src \ = trg \" shows "(\ \ \) \ \ = \\<^sup>-\<^sup>1[cod \, cod \, cod \] \ (\ \ \ \ \) \ \[dom \, dom \, dom \]" and "\ \ \ \ \ = \[cod \, cod \, cod \] \ ((\ \ \) \ \) \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" proof - show "(\ \ \) \ \ = \\<^sup>-\<^sup>1[cod \, cod \, cod \] \ (\ \ \ \ \) \ \[dom \, dom \, dom \]" proof - have "(\ \ \) \ \ = (\\<^sup>-\<^sup>1[cod \, cod \, cod \] \ \[cod \, cod \, cod \]) \ ((\ \ \) \ \)" using assms comp_assoc_assoc'(2) comp_cod_arr by simp also have "... = \\<^sup>-\<^sup>1[cod \, cod \, cod \] \ \[cod \, cod \, cod \] \ ((\ \ \) \ \)" using comp_assoc by simp also have "... = \\<^sup>-\<^sup>1[cod \, cod \, cod \] \ (\ \ \ \ \) \ \[dom \, dom \, dom \]" using assms assoc_naturality by simp finally show ?thesis by simp qed show "\ \ \ \ \ = \[cod \, cod \, cod \] \ ((\ \ \) \ \) \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" proof - have "\ \ \ \ \ = (\ \ \ \ \) \ \[dom \, dom \, dom \] \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" using assms comp_assoc_assoc'(1) comp_arr_dom by simp also have "... = ((\ \ \ \ \) \ \[dom \, dom \, dom \]) \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" using comp_assoc by simp also have "... = (\[cod \, cod \, cod \] \ ((\ \ \) \ \)) \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" using assms assoc_naturality by simp also have "... = \[cod \, cod \, cod \] \ ((\ \ \) \ \) \ \\<^sup>-\<^sup>1[dom \, dom \, dom \]" using comp_assoc by simp finally show ?thesis by simp qed qed lemma triangle': assumes "ide f" and "ide g" and "src f = trg g" shows "(f \ \[g]) = (\[f] \ g) \ \\<^sup>-\<^sup>1[f, src f, g]" proof - have "(\[f] \ g) \ \\<^sup>-\<^sup>1[f, src f, g] = ((f \ \[g]) \ \[f, src f, g]) \ \\<^sup>-\<^sup>1[f, src f, g]" using assms triangle by auto also have "... = (f \ \[g])" using assms comp_arr_dom comp_assoc comp_assoc_assoc' by auto finally show ?thesis by auto qed lemma pentagon': assumes "ide f" and "ide g" and "ide h" and "ide k" and "src f = trg g" and "src g = trg h" and "src h = trg k" shows "((\\<^sup>-\<^sup>1[f, g, h] \ k) \ \\<^sup>-\<^sup>1[f, g \ h, k]) \ (f \ \\<^sup>-\<^sup>1[g, h, k]) = \\<^sup>-\<^sup>1[f \ g, h, k] \ \\<^sup>-\<^sup>1[f, g, h \ k]" proof - have "((\\<^sup>-\<^sup>1[f, g, h] \ k) \ \\<^sup>-\<^sup>1[f, g \ h, k]) \ (f \ \\<^sup>-\<^sup>1[g, h, k]) = inv ((f \ \[g, h, k]) \ (\[f, g \ h, k] \ (\[f, g, h] \ k)))" proof - have "inv ((f \ \[g, h, k]) \ (\[f, g \ h, k] \ (\[f, g, h] \ k))) = inv (\[f, g \ h, k] \ (\[f, g, h] \ k)) \ inv (f \ \[g, h, k])" using assms inv_comp [of "\[f, g \ h, k] \ (\[f, g, h] \ k)" "f \ \[g, h, k]"] by force also have "... = (inv (\[f, g, h] \ k) \ inv \[f, g \ h, k]) \ inv (f \ \[g, h, k])" using assms iso_assoc inv_comp by simp also have "... = ((\\<^sup>-\<^sup>1[f, g, h] \ k) \ \\<^sup>-\<^sup>1[f, g \ h, k]) \ (f \ \\<^sup>-\<^sup>1[g, h, k])" using assms inv_hcomp by simp finally show ?thesis by simp qed also have "... = inv (\[f, g, h \ k] \ \[f \ g, h, k])" using assms pentagon by simp also have "... = \\<^sup>-\<^sup>1[f \ g, h, k] \ \\<^sup>-\<^sup>1[f, g, h \ k]" using assms inv_comp by simp finally show ?thesis by auto qed end text \ The following convenience locale extends @{locale bicategory} by pre-interpreting the various functors and natural transformations. \ locale extended_bicategory = bicategory + L: equivalence_functor V V L + R: equivalence_functor V V R + \: natural_isomorphism VVV.comp V HoHV HoVH \\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))\ + \': inverse_transformation VVV.comp V HoHV HoVH \\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))\ + \: natural_isomorphism V V L map \ + \': inverse_transformation V V L map \ + \: natural_isomorphism V V R map \ + \': inverse_transformation V V R map \ sublocale bicategory \ extended_bicategory V H \ \ src trg proof - interpret L: equivalence_functor V V L using equivalence_functor_L by auto interpret R: equivalence_functor V V R using equivalence_functor_R by auto interpret \': inverse_transformation VVV.comp V HoHV HoVH \\\\\. \ (fst \\\) (fst (snd \\\)) (snd (snd \\\))\ .. interpret \: natural_isomorphism V V L map \ using natural_isomorphism_\ by auto interpret \': inverse_transformation V V L map \ .. interpret \: natural_isomorphism V V R map \ using natural_isomorphism_\ by auto interpret \': inverse_transformation V V R map \ .. interpret extended_bicategory V H \ \ src trg .. show "extended_bicategory V H \ \ src trg" .. qed end