(* Title: ConcreteBicategory Author: Eugene W. Stark , 2021 Maintainer: Eugene W. Stark *) section "Concrete Bicategories" text \ The locale \concrete_bicategory\ defined in this section provides a uniform way to construct a bicategory from extrinsically specified data comprising: a set of \Obj\ of ``objects'', a ``hom-category'' \Hom A B\ for each pair of objects \A\ and \B\, an ``identity arrow'' \Id A \ Hom A A\ for each object \A\, ``horizontal composition'' functors \Comp C B A : Hom B C \ Hom A B \ Hom A C\ indexed by triples of objects, together with unit and associativity isomorphisms; the latter subject to naturality and coherence conditions. We show that the bicategory produced by the construction relates to the given data in the expected fashion: the objects of the bicategory are in bijective correspondence with the given set \Obj\, the hom-categories of the bicategory are isomorphic to the given categories \Hom A B\, the horizontal composition of the bicategory agrees with the given compositions \Comp C B A\, and the unit and associativity 2-cells of the bicategory are directly defined in terms of the given unit and associativity isomorphisms. \ theory ConcreteBicategory imports Bicategory.Bicategory begin locale concrete_bicategory = fixes Obj :: "'o set" and Hom :: "'o \ 'o \ 'a comp" and Id :: "'o \ 'a" and Comp :: "'o \ 'o \ 'o \ 'a \ 'a \'a" and Unit :: "'o \ 'a" and Assoc :: "'o \ 'o \ 'o \ 'o \ 'a \ 'a \ 'a \ 'a" assumes category_Hom: "\ A \ Obj; B \ Obj \ \ category (Hom A B)" and binary_functor_Comp: "\ A \ Obj; B \ Obj; C \ Obj \ \ binary_functor (Hom B C) (Hom A B) (Hom A C) (\(f, g). Comp C B A f g)" and ide_Id: "A \ Obj \ partial_magma.ide (Hom A A) (Id A)" and Unit_in_hom: "A \ Obj \ partial_magma.in_hom (Hom A A) (Unit A) (Comp A A A (Id A) (Id A)) (Id A)" and iso_Unit: "A \ Obj \ category.iso (Hom A A) (Unit A)" and natural_isomorphism_Assoc: "\ A \ Obj; B \ Obj; C \ Obj; D \ Obj \ \ natural_isomorphism (product_category.comp (Hom C D) (product_category.comp (Hom B C) (Hom A B))) (Hom A D) (\(f, g, h). Comp D B A (Comp D C B f g) h) (\(f, g, h). Comp D C A f (Comp C B A g h)) (\(f, g, h). Assoc D C B A f g h)" and left_unit_Id: "\A B. \ A \ Obj; B \ Obj \ \ fully_faithful_functor (Hom A B) (Hom A B) (\f. if partial_magma.arr (Hom A B) f then Comp B B A (Id B) f else partial_magma.null (Hom A B))" and right_unit_Id: "\A B. \ A \ Obj; B \ Obj \ \ fully_faithful_functor (Hom A B) (Hom A B) (\f. if partial_magma.arr (Hom A B) f then Comp B A A f (Id A) else partial_magma.null (Hom A B))" and pentagon: "\A B C D E f g h k. \ A \ Obj; B \ Obj; C \ Obj; D \ Obj; E \ Obj; partial_magma.ide (Hom D E) f; partial_magma.ide (Hom C D) g; partial_magma.ide (Hom B C) h; partial_magma.ide (Hom A B) k \ \ Hom A E (Comp E D A f (Assoc D C B A g h k)) (Hom A E (Assoc E D B A f (Comp D C B g h) k) (Comp E B A (Assoc E D C B f g h) k)) = Hom A E (Assoc E D C A f g (Comp C B A h k)) (Assoc E C B A (Comp E D C f g) h k)" begin text \ We first construct the vertical category. Arrows are terms of the form \MkCell A B \\, where \A \ Obj\, \B \ Obj\, and where \\\ is an arrow of \Hom A B\. Composition requires agreement of the ``source'' \A\ and ``target'' \B\ components, and is then defined in terms of composition within \Hom A B\. \ datatype ('oo, 'aa) cell = Null | MkCell 'oo 'oo 'aa abbreviation MkObj :: "'o \ ('o, 'a) cell" where "MkObj A \ MkCell A A (Id A)" fun Src :: "('o, 'a) cell \ 'o" where "Src (MkCell A _ _) = A" | "Src _ = undefined" fun Trg where "Trg (MkCell _ B _) = B" | "Trg _ = undefined" fun Map where "Map (MkCell _ _ F) = F" | "Map _ = undefined" abbreviation Cell where "Cell \ \ \ \ Null \ Src \ \ Obj \ Trg \ \ Obj \ partial_magma.arr (Hom (Src \) (Trg \)) (Map \)" definition vcomp where "vcomp \ \ \ if Cell \ \ Cell \ \ Src \ = Src \ \ Trg \ = Trg \ \ partial_magma.seq (Hom (Src \) (Trg \)) (Map \) (Map \) then MkCell (Src \) (Trg \) (Hom (Src \) (Trg \) (Map \) (Map \)) else Null" interpretation partial_magma vcomp by (metis partial_magma_def vcomp_def) lemma null_char: shows "null = Null" using comp_null(1) vcomp_def by metis lemma MkCell_Map: assumes "\ \ null" shows "\ = MkCell (Src \) (Trg \) (Map \)" using assms null_char by (metis Map.simps(1) Src.elims Trg.simps(1)) (* * We need to name the following fact so that it does not get * hidden when we interpret the category locale, because it is still * used in some subsequent proofs. *) lemma ide_char'': shows "ide \ \ Cell \ \ partial_magma.ide (Hom (Src \) (Trg \)) (Map \)" proof show "ide \ \ Cell \ \ partial_magma.ide (Hom (Src \) (Trg \)) (Map \)" proof assume \: "ide \" show 1: "Cell \" by (metis \ ide_def vcomp_def) interpret Hom: category "Hom (Src \) (Trg \)" using 1 category_Hom by simp let ?\ = "MkCell (Src \) (Trg \) (Hom.dom (Map \))" have "vcomp \ ?\ = MkCell (Src \) (Trg \) (Map \)" using 1 vcomp_def Hom.comp_arr_dom by simp moreover have "vcomp \ ?\ = ?\" using \ ide_def null_char by (metis MkCell_Map calculation) ultimately show "Hom.ide (Map \)" using 1 Hom.ide_dom by fastforce qed show "Cell \ \ partial_magma.ide (Hom (Src \) (Trg \)) (Map \) \ ide \" proof - assume \: "Cell \ \ partial_magma.ide (Hom (Src \) (Trg \)) (Map \)" interpret Hom: category "Hom (Src \) (Trg \)" using \ category_Hom by simp show "ide \" proof - have "vcomp \ \ \ null" using \ vcomp_def null_char by simp moreover have "\\. vcomp \ \ \ null \ vcomp \ \ = \" by (metis (full_types) Hom.comp_arr_ide \ MkCell_Map vcomp_def null_char) moreover have "\\. vcomp \ \ \ null \ vcomp \ \ = \" by (metis Hom.comp_ide_arr MkCell_Map \ null_char vcomp_def) ultimately show ?thesis unfolding ide_def by simp qed qed qed lemma MkCell_in_domains: assumes "Cell \" shows "MkCell (Src \) (Trg \) (partial_magma.dom (Hom (Src \) (Trg \)) (Map \)) \ domains \" proof - interpret Hom: category "Hom (Src \) (Trg \)" using assms category_Hom by simp let ?\ = "MkCell (Src \) (Trg \) (Hom.dom (Map \))" have "ide ?\" using assms ide_char'' Hom.arr_dom Hom.ide_dom by simp moreover have "vcomp \ ?\ = \" unfolding vcomp_def using assms Hom.comp_arr_dom MkCell_Map null_char by auto ultimately show ?thesis using domains_def by (simp add: assms null_char) qed lemma MkCell_in_codomains: assumes "Cell \" shows "MkCell (Src \) (Trg \) (partial_magma.cod (Hom (Src \) (Trg \)) (Map \)) \ codomains \" proof - interpret Hom: category "Hom (Src \) (Trg \)" using assms category_Hom by simp let ?\ = "MkCell (Src \) (Trg \) (Hom.cod (Map \))" have "ide ?\" using assms ide_char'' Hom.arr_dom Hom.ide_dom by simp moreover have "vcomp ?\ \ = \" unfolding vcomp_def using assms Hom.comp_cod_arr MkCell_Map null_char by auto ultimately show ?thesis using codomains_def by (simp add: assms null_char) qed lemma has_domain_char: shows "domains \ \ {} \ Cell \" proof - have "\ Cell \ \ domains \ = {}" using vcomp_def domains_def null_char by auto moreover have "Cell \ \ MkCell (Src \) (Trg \) (partial_magma.dom (Hom (Src \) (Trg \)) (Map \)) \ domains \" using MkCell_in_domains by simp ultimately show ?thesis by auto qed lemma has_codomain_char: shows "codomains \ \ {} \ Cell \" proof - have "\ Cell \ \ codomains \ = {}" using vcomp_def codomains_def null_char by auto moreover have "Cell \ \ MkCell (Src \) (Trg \) (partial_magma.cod (Hom (Src \) (Trg \)) (Map \)) \ codomains \" using MkCell_in_codomains by simp ultimately show ?thesis by auto qed lemma arr_char: shows "arr \ \ Cell \" using arr_def has_domain_char has_codomain_char by simp lemma ide_char''': shows "ide \ \ arr \ \ partial_magma.ide (Hom (Src \) (Trg \)) (Map \)" using ide_char'' arr_char by simp lemma seq_char: shows "seq \ \ \ Cell \ \ Cell \ \ Src \ = Src \ \ Trg \ = Trg \ \ partial_magma.seq (Hom (Src \) (Trg \)) (Map \) (Map \)" using arr_char vcomp_def by auto lemma vcomp_char: shows "vcomp \ \ = (if seq \ \ then MkCell (Src \) (Trg \) (Hom (Src \) (Trg \) (Map \) (Map \)) else null)" by (metis null_char seq_char vcomp_def) interpretation category vcomp proof show "\g f. vcomp g f \ null \ seq g f" using seq_char null_char vcomp_def by metis show "\f. (domains f \ {}) = (codomains f \ {})" using has_domain_char has_codomain_char by simp show "\h g f. \seq h g; seq (vcomp h g) f\ \ seq g f" using vcomp_def apply (unfold seq_char, intro conjI) apply auto by (meson category.match_1 category_Hom) show "\h g f. \seq h (vcomp g f); seq g f\ \ seq h g" using vcomp_def apply (unfold seq_char, intro conjI) apply auto by (meson category.match_2 category_Hom) show "\g f h. \seq g f; seq h g\ \ seq (vcomp h g) f" using vcomp_def apply (unfold seq_char, intro conjI) apply auto by (meson category.match_3 category_Hom) show "\g f h. \seq g f; seq h g\ \ vcomp (vcomp h g) f = vcomp h (vcomp g f)" proof - fix f g h assume fg: "seq g f" and gh: "seq h g" interpret Hom: category \Hom (Src f) (Trg f)\ using fg seq_char category_Hom by simp have "vcomp (vcomp h g) f = MkCell (Src f) (Trg f) (Hom (Src f) (Trg f) (Hom (Src f) (Trg f) (Map h) (Map g)) (Map f))" using fg gh vcomp_char seq_char null_char Hom.match_3 by auto also have "... = MkCell (Src f) (Trg f) (Hom (Src f) (Trg f) (Map h) (Hom (Src f) (Trg f) (Map g) (Map f)))" using fg gh seq_char Hom.comp_assoc by simp also have "... = vcomp h (vcomp g f)" using fg gh vcomp_char seq_char null_char Hom.match_4 by auto finally show "vcomp (vcomp h g) f = vcomp h (vcomp g f)" by blast qed qed lemma arr_eqI: assumes "arr f" and "arr f'" and "Src f = Src f'" and "Trg f = Trg f'" and "Map f = Map f'" shows "f = f'" using arr_char MkCell_Map assms null_char by metis lemma dom_char: shows "dom \ = (if arr \ then MkCell (Src \) (Trg \) (partial_magma.dom (Hom (Src \) (Trg \)) (Map \)) else Null)" by (metis MkCell_in_domains arr_char dom_in_domains domain_unique has_domain_iff_arr dom_def null_char) lemma cod_char: shows "cod \ = (if arr \ then MkCell (Src \) (Trg \) (partial_magma.cod (Hom (Src \) (Trg \)) (Map \)) else Null)" by (metis MkCell_in_codomains arr_char cod_def cod_in_codomains codomain_unique has_codomain_iff_arr null_char) lemma Src_vcomp [simp]: assumes "seq \ \" shows "Src (vcomp \ \) = Src \" using assms seq_char vcomp_def by auto lemma Trg_vcomp [simp]: assumes "seq \ \" shows "Trg (vcomp \ \) = Trg \" using assms seq_char vcomp_def by auto lemma Map_vcomp [simp]: assumes "seq \ \" shows "Map (vcomp \ \) = Hom (Src \) (Trg \) (Map \) (Map \)" using assms seq_char vcomp_def by auto lemma arr_MkCell [simp]: assumes "A \ Obj" and "B \ Obj" and "partial_magma.arr (Hom A B) f" shows "arr (MkCell A B f)" using assms arr_char by simp lemma dom_MkCell [simp]: assumes "arr (MkCell A B f)" shows "dom (MkCell A B f) = MkCell A B (partial_magma.dom (Hom A B) f)" using assms arr_char dom_char by simp lemma cod_MkCell [simp]: assumes "arr (MkCell A B f)" shows "cod (MkCell A B f) = MkCell A B (partial_magma.cod (Hom A B) f)" using assms arr_char cod_char by simp lemma iso_char: shows "iso \ \ arr \ \ category.iso (Hom (Src \) (Trg \)) (Map \)" proof assume \: "iso \" have 1: "arr \" using \ by blast interpret Hom: category \Hom (Src \) (Trg \)\ using 1 arr_char category_Hom by simp have 2: "Hom.iso (Map \)" proof - obtain \ where \: "inverse_arrows \ \" using \ by blast have "Hom.inverse_arrows (Map \) (Map \)" proof show "Hom.ide (Hom (Src \) (Trg \) (Map \) (Map \))" using \ ide_char'' Src_vcomp Trg_vcomp ideD(1) vcomp_char Map_vcomp by (metis inverse_arrowsE) show "Hom.ide (Hom (Src \) (Trg \) (Map \) (Map \))" proof - have 1: "ide (vcomp \ \)" using \ by auto hence "Hom.ide (Map (vcomp \ \))" using ide_char'' Src_vcomp Trg_vcomp ideD(1) seq_char by metis thus "Hom.ide (Hom (Src \) (Trg \) (Map \) (Map \))" using \ 1 vcomp_char Map.simps(1) seq_char ideD(1) by (metis (no_types, lifting)) qed qed thus ?thesis by auto qed show "arr \ \ Hom.iso (Map \)" using 1 2 by simp next assume \: "arr \ \ category.iso (Hom (Src \) (Trg \)) (Map \)" interpret Hom: category \Hom (Src \) (Trg \)\ using \ arr_char category_Hom by simp obtain f where f: "Hom.inverse_arrows (Map \) f" using \ by auto let ?\ = "MkCell (Src \) (Trg \) f" have 1: "arr ?\" using \ f arr_char by auto have "inverse_arrows \ (MkCell (Src \) (Trg \) f)" using \ f 1 arr_char ide_char'' vcomp_def apply (intro inverse_arrowsI) by auto thus "iso \" by auto qed text \ Next, we equip each arrow with a source and a target, and show that these assignments are functorial. \ definition src where "src \ \ if arr \ then MkObj (Src \) else null" definition trg where "trg \ \ if arr \ then MkObj (Trg \) else null" lemma src_MkCell [simp]: assumes "arr (MkCell A B f)" shows "src (MkCell A B f) = MkObj A" using assms src_def by simp lemma trg_MkCell [simp]: assumes "arr (MkCell A B f)" shows "trg (MkCell A B f) = MkObj B" using assms trg_def by simp lemma src_dom: assumes "arr \" shows "src (dom \) = src \" using assms dom_char src_def arr_char arr_dom by auto lemma src_cod: assumes "arr \" shows "src (cod \) = src \" using assms cod_char src_def arr_char arr_cod by auto lemma trg_dom: assumes "arr \" shows "trg (dom \) = trg \" using assms dom_char trg_def arr_char arr_dom by auto lemma trg_cod: assumes "arr \" shows "trg (cod \) = trg \" using assms cod_char trg_def arr_char arr_cod by auto lemma Src_src [simp]: assumes "arr \" shows "Src (src \) = Src \" using assms src_def by simp lemma Trg_src [simp]: assumes "arr \" shows "Trg (src \) = Src \" using assms src_def by simp lemma Map_src [simp]: assumes "arr \" shows "Map (src \) = Id (Src \)" using assms src_def by simp lemma Src_trg [simp]: assumes "arr \" shows "Src (trg \) = Trg \" using assms trg_def by simp lemma Trg_trg [simp]: assumes "arr \" shows "Trg (trg \) = Trg \" using assms trg_def by simp lemma Map_trg [simp]: assumes "arr \" shows "Map (trg \) = Id (Trg \)" using assms trg_def by simp lemma Src_dom [simp]: assumes "arr \" shows "Src (dom \) = Src \" using assms dom_char src_def arr_char arr_dom by auto lemma Src_cod [simp]: assumes "arr \" shows "Src (cod \) = Src \" using assms src_cod src_def arr_char arr_cod by auto lemma Trg_dom [simp]: assumes "arr \" shows "Trg (dom \) = Trg \" using assms dom_char trg_def arr_char arr_dom by auto lemma Trg_cod [simp]: assumes "arr \" shows "Trg (cod \) = Trg \" using assms cod_char trg_def arr_char arr_cod by auto lemma Map_dom [simp]: assumes "arr \" shows "Map (dom \) = partial_magma.dom (Hom (Src \) (Trg \)) (Map \)" using assms by (simp add: dom_char) lemma Map_cod [simp]: assumes "arr \" shows "Map (cod \) = partial_magma.cod (Hom (Src \) (Trg \)) (Map \)" using assms by (simp add: cod_char) lemma ide_MkObj: assumes "A \ Obj" shows "ide (MkObj A)" using assms ide_char' by (metis Map.simps(1) Src.simps(1) Trg.simps(1) category.ideD(1) cell.simps(2) category_Hom ide_char'' ide_Id) interpretation src: "functor" vcomp vcomp src using src_def arr_char Map.simps(1) Src.simps(1) Trg.simps(1) arr_dom category.ideD(1) ide_MkObj src_dom src_cod ide_Id apply unfold_locales apply auto[1] apply (simp add: category.ideD(1) category_Hom) apply auto[2] proof - fix g :: "('o, 'a) cell" and f :: "('o, 'a) cell" assume fg: "seq g f" thus "src (vcomp g f) = vcomp (src g) (src f)" using arr_char ide_MkObj src_dom src_cod src_def by (metis Src_vcomp comp_ide_self seqE) qed interpretation trg: "functor" vcomp vcomp trg using trg_def arr_char Map.simps(1) Src.simps(1) Trg.simps(1) arr_dom category.ideD(1) ide_MkObj trg_dom trg_cod ide_Id apply unfold_locales apply auto[1] apply (simp add: category.ideD(1) category_Hom) apply auto[2] proof - fix g :: "('o, 'a) cell" and f :: "('o, 'a) cell" assume fg: "seq g f" thus "trg (vcomp g f) = vcomp (trg g) (trg f)" using arr_char ide_MkObj trg_dom trg_cod trg_def by (metis Trg_vcomp comp_ide_self seqE) qed interpretation H: horizontal_homs vcomp src trg using ide_MkObj arr_char src_def trg_def src.preserves_arr trg.preserves_arr by unfold_locales auto lemma obj_MkObj: assumes "A \ Obj" shows "H.obj (MkObj A)" using assms src_def H.obj_def ide_MkObj by simp lemma MkCell_in_hom [intro]: assumes "A \ Obj" and "B \ Obj" and "partial_magma.arr (Hom A B) f" shows "H.in_hhom (MkCell A B f) (MkObj A) (MkObj B)" and "\MkCell A B f : MkCell A B (partial_magma.dom (Hom A B) f) \ MkCell A B (partial_magma.cod (Hom A B) f)\" using assms by auto text \ Horizontal composition of horizontally composable arrows is now defined by applying the given function \Comp\ to the ``Map'' components. \ definition hcomp where "hcomp \ \ \ if arr \ \ arr \ \ src \ = trg \ then MkCell (Src \) (Trg \) (Comp (Trg \) (Trg \) (Src \) (Map \) (Map \)) else null" lemma arr_hcomp: assumes "arr \" and "arr \" and "src \ = trg \" shows "arr (hcomp \ \)" and "dom (hcomp \ \) = hcomp (dom \) (dom \)" and "cod (hcomp \ \) = hcomp (cod \) (cod \)" proof - have 1: "hcomp \ \ = MkCell (Src \) (Trg \) (Comp (Trg \) (Trg \) (Src \) (Map \) (Map \))" using assms hcomp_def by simp have 2: "Src \ = Trg \" using assms src_def trg_def by simp interpret Hom_\: category \Hom (Src \) (Trg \)\ using assms arr_char category_Hom by simp interpret Hom_\: category \Hom (Src \) (Trg \)\ using assms arr_char category_Hom by simp interpret Hom_\\: category \Hom (Src \) (Trg \)\ using assms arr_char category_Hom by simp interpret Comp: binary_functor \Hom (Trg \) (Trg \)\ \Hom (Src \) (Trg \)\ \Hom (Src \) (Trg \)\ \\(f, g). Comp (Trg \) (Trg \) (Src \) f g\ using assms arr_char 2 binary_functor_Comp [of "Src \" "Trg \" "Trg \"] by simp have 4: "Comp.A1xA2.arr (Map \, Map \)" using assms 2 arr_char Comp.A1xA2.arr_char by simp show 3: "arr (hcomp \ \)" using assms 1 2 4 arr_char Comp.preserves_arr [of "(Map \, Map \)"] by simp show "dom (hcomp \ \) = hcomp (dom \) (dom \)" proof - have "dom (hcomp \ \) = MkCell (Src \) (Trg \) (Hom_\\.dom (Comp (Trg \) (Trg \) (Src \) (Map \) (Map \)))" using 1 3 dom_char by simp moreover have "Hom_\\.dom (Comp (Trg \) (Trg \) (Src \) (Map \) (Map \)) = Comp (Trg \) (Trg \) (Src \) (Hom_\.dom (Map \)) (Hom_\.dom (Map \))" using 2 Comp.preserves_dom \Comp.A1xA2.arr (Map \, Map \)\ by force ultimately show ?thesis using assms 2 dom_char hcomp_def arr_dom by auto metis qed show "cod (hcomp \ \) = hcomp (cod \) (cod \)" proof - have "cod (hcomp \ \) = MkCell (Src \) (Trg \) (Hom_\\.cod (Comp (Trg \) (Trg \) (Src \) (Map \) (Map \)))" using 1 3 cod_char by simp moreover have "Hom_\\.cod (Comp (Trg \) (Trg \) (Src \) (Map \) (Map \)) = Comp (Trg \) (Trg \) (Src \) (Hom_\.cod (Map \)) (Hom_\.cod (Map \))" using 2 Comp.preserves_cod \Comp.A1xA2.arr (Map \, Map \)\ by force ultimately show "cod (hcomp \ \) = hcomp (cod \) (cod \)" using assms 2 cod_char hcomp_def arr_cod by auto metis qed qed lemma src_hcomp: assumes "arr \" and "arr \" and "src \ = trg \" shows "src (hcomp \ \) = src \" using assms hcomp_def src_def arr_hcomp(1) by auto lemma trg_hcomp: assumes "arr \" and "arr \" and "src \ = trg \" shows "trg (hcomp \ \) = trg \" using assms hcomp_def trg_def arr_hcomp(1) by auto lemma Src_hcomp [simp]: assumes "arr \" and "arr \" and "src \ = trg \" shows "Src (hcomp \ \) = Src \" using assms hcomp_def by simp lemma Trg_hcomp [simp]: assumes "arr \" and "arr \" and "src \ = trg \" shows "Trg (hcomp \ \) = Trg \" using assms hcomp_def by simp lemma Map_hcomp [simp]: assumes "arr \" and "arr \" and "src \ = trg \" shows "Map (hcomp \ \) = Comp (Trg \) (Trg \) (Src \) (Map \) (Map \)" using assms hcomp_def by simp lemma hcomp_vcomp: assumes "H.VV.seq g f" shows "hcomp (fst (H.VV.comp g f)) (snd (H.VV.comp g f)) = vcomp (hcomp (fst g) (snd g)) (hcomp (fst f) (snd f))" proof - let ?f1 = "fst f" and ?f2 = "snd f" and ?g1 = "fst g" and ?g2 = "snd g" have 1: "Src ?f1 \ Obj \ Trg ?f1 \ Obj \ Src ?f2 \ Obj \ Trg ?f2 \ Obj \ Src ?g1 \ Obj \ Trg ?g1 \ Obj \ Src ?g2 \ Obj \ Trg ?g2 \ Obj" using assms arr_char H.VV.arrE by blast interpret Hom_f1: category \Hom (Src ?f1) (Trg ?f1)\ using assms 1 category_Hom by simp interpret Hom_f2: category \Hom (Src ?f2) (Trg ?f2)\ using assms 1 category_Hom by simp interpret Hom_g1: category \Hom (Src ?g1) (Trg ?g1)\ using assms 1 category_Hom by simp interpret Hom_g2: category \Hom (Src ?g2) (Trg ?g2)\ using assms 1 category_Hom by simp interpret Hom_f: category \Hom (Src ?f2) (Trg ?f1)\ using assms 1 category_Hom by simp interpret Hom_g: category \Hom (Src ?g2) (Trg ?g1)\ using assms 1 category_Hom by simp interpret Comp_f: binary_functor \Hom (Trg ?f2) (Trg ?f1)\ \Hom (Src ?f2) (Trg ?f2)\ \Hom (Src ?f2) (Trg ?f1)\ \\(fa, g). Comp (Trg ?f1) (Trg ?f2) (Src ?f2) fa g\ using assms 1 arr_char binary_functor_Comp by simp have "hcomp (fst (H.VV.comp g f)) (snd (H.VV.comp g f)) = MkCell (Src (snd (H.VV.comp g f))) (Trg (fst (H.VV.comp g f))) (Comp (Trg (fst (H.VV.comp g f))) (Trg (snd (H.VV.comp g f))) (Src (snd (H.VV.comp g f))) (Map (fst (H.VV.comp g f))) (Map (snd (H.VV.comp g f))))" using assms hcomp_def H.VV.arrE by (metis (no_types, lifting)) also have "... = MkCell (Src ?f2) (Trg ?f1) (Hom (Src ?f2) (Trg ?f1) (Comp (Trg ?f1) (Trg ?g2) (Src ?f2) (Map ?g1) (Map ?g2)) (Comp (Trg ?f1) (Trg ?f2) (Src ?f2) (Map ?f1) (Map ?f2)))" proof - have "Src (snd (H.VV.comp g f)) = Src ?f2" using assms arr_char src_def H.VV.comp_char H.VV.seq_char by (metis (no_types, lifting) H.vseq_implies_hpar(1) Src.simps(1) H.VV.arrE H.VV.inclusion H.VxV.comp_arr_dom H.VxV.dom_comp H.VxV.seqE) moreover have "Trg (fst (H.VV.comp g f)) = Trg ?f1" by (metis (no_types, lifting) H.VV.comp_arr_dom H.VV.comp_simp H.VV.seq_char H.VxV.arr_char H.VxV.cod_comp H.VxV.comp_cod_arr H.VxV.seqE H.vseq_implies_hpar(2) Src_trg assms) moreover have "Comp (Trg (fst (H.VV.comp g f))) (Trg (snd (H.VV.comp g f))) (Src (snd (H.VV.comp g f))) (Map (fst (H.VV.comp g f))) (Map (snd (H.VV.comp g f))) = Hom (Src ?f2) (Trg ?f1) (Comp (Trg ?f1) (Trg ?g2) (Src ?f2) (Map ?g1) (Map ?g2)) (Comp (Trg ?f1) (Trg ?f2) (Src ?f2) (Map ?f1) (Map ?f2))" proof - have "Comp (Trg (fst (H.VV.comp g f))) (Trg (snd (H.VV.comp g f))) (Src (snd (H.VV.comp g f))) (Map (fst (H.VV.comp g f))) (Map (snd (H.VV.comp g f))) = Comp (Trg ?g1) (Trg ?g2) (Src ?g2) (Map (vcomp ?g1 ?f1)) (Map (vcomp ?g2 ?f2))" using assms H.VV.comp_char H.VV.arr_char H.VxV.comp_char by auto (* 10 sec *) also have "... = Comp (Trg ?g1) (Trg ?g2) (Src ?g2) (Hom (Src ?g1) (Trg ?g1) (Map ?g1) (Map ?f1)) (Hom (Src ?g2) (Trg ?g2) (Map ?g2) (Map ?f2))" using assms H.VV.seq_char Map_vcomp H.VxV.seq_char by auto also have "... = Hom (Src ?f2) (Trg ?f1) (Comp (Trg ?f1) (Trg ?g2) (Src ?f2) (Map ?g1) (Map ?g2)) (Comp (Trg ?f1) (Trg ?f2) (Src ?f2) (Map ?f1) (Map ?f2))" proof - have 2: "Src ?g1 = Trg ?g2" using assms H.VV.arr_char [of g] src_def [of "?g1"] trg_def [of "?g2"] by auto have "Comp (Trg ?f1) (Trg ?f2) (Src ?f2) (Hom (Trg ?g2) (Trg ?g1) (Map ?g1) (Map ?f1)) (Hom (Src ?g2) (Trg ?g2) (Map ?g2) (Map ?f2)) = Hom (Src ?f2) (Trg ?f1) (Comp (Trg ?f1) (Trg ?f2) (Src ?f2) (Map ?g1) (Map ?g2)) (Comp (Trg ?f1) (Trg ?f2) (Src ?f2) (Map ?f1) (Map ?f2))" proof - have "Comp_f.A1xA2.seq (Map ?g1, Map ?g2) (Map ?f1, Map ?f2)" using assms 2 H.VV.seq_char by (metis (no_types, lifting) Comp_f.A1xA2.seq_char H.VxV.seqE fst_conv seq_char snd_conv) moreover have "Comp_f.A1xA2.comp (Map ?g1, Map ?g2) (Map ?f1, Map ?f2) = (Hom (Src ?g1) (Trg ?g1) (Map ?g1) (Map ?f1), Hom (Src ?g2) (Trg ?g2) (Map ?g2) (Map ?f2))" using assms 2 H.VV.seq_char H.VxV.seqE seq_char by (metis (no_types, lifting) Comp_f.A1xA2.comp_char fst_conv snd_conv) ultimately show ?thesis by (metis 2 Comp_f.as_nat_trans.preserves_comp_2 old.prod.case) qed thus ?thesis using assms 2 H.VV.seq_char H.VxV.seqE seq_char by (metis (no_types, lifting)) qed finally show ?thesis by blast qed ultimately show ?thesis by blast qed also have "... = vcomp (hcomp ?g1 ?g2) (hcomp ?f1 ?f2)" proof - have 2: "Trg ?g1 = Trg ?f1 \ Src ?g2 = Src ?f2 \ Src ?f1 = Trg ?f2" using assms seq_char H.VV.seq_char H.VxV.seqE by (metis (no_types, lifting) H.VV.arr_char Src_src Src_trg) have "Hom_f.seq (Comp (Trg ?f1) (Trg ?g2) (Src ?f2) (Map ?g1) (Map ?g2)) (Comp (Trg ?f1) (Trg ?f2) (Src ?f2) (Map ?f1) (Map ?f2))" by (metis (no_types, lifting) 2 Comp_f.A1xA2.seqI Comp_f.preserves_seq H.VV.seq_char H.VxV.seqE arr_char assms case_prod_conv vcomp_def) moreover have "?f1 \ Null \ ?f2 \ Null \ src ?f1 = trg ?f2 \ ?g1 \ Null \ ?g2 \ Null \ src ?g1 = trg ?g2" using assms H.VV.arr_char arr_char assms by blast moreover have "Hom_f1.arr (Map ?f1) \ Hom_f2.arr (Map ?f2)" using assms seq_char H.VV.arrE H.VV.seqE arr_char by fast moreover have "Hom_g1.arr (Map ?g1) \ Hom_g2.arr (Map ?g2)" using assms seq_char H.VV.arrE H.VV.seqE arr_char by meson ultimately show ?thesis using 1 2 arr_char hcomp_def vcomp_def by auto qed finally show ?thesis by simp qed interpretation H: "functor" H.VV.comp vcomp \\\\. hcomp (fst \\) (snd \\)\ using hcomp_def arr_hcomp hcomp_vcomp H.VV.arr_char H.VV.dom_char H.VV.cod_char by unfold_locales auto interpretation H: horizontal_composition vcomp hcomp src trg using src_hcomp trg_hcomp arr_char hcomp_def null_char by unfold_locales auto lemma Map_obj: assumes "H.obj a" shows "Map a = Id (Src a)" and "Map a = Id (Trg a)" using assms H.obj_def Map_src Map_trg H.obj_simps(3) by metis+ lemma MkCell_simps: assumes "A \ Obj" and "B \ Obj" and "partial_magma.arr (Hom A B) f" shows "arr (MkCell A B f)" and "src (MkCell A B f) = MkObj A" and "trg (MkCell A B f) = MkObj B" and "dom (MkCell A B f) = MkCell A B (partial_magma.dom (Hom A B) f)" and "cod (MkCell A B f) = MkCell A B (partial_magma.cod (Hom A B) f)" using assms MkCell_in_hom by auto text \ Next, define the associativities and show that they are the components of a natural isomorphism. \ definition assoc where "assoc f g h \ if H.VVV.ide (f, g, h) then MkCell (Src h) (Trg f) (Assoc (Trg f) (Trg g) (Trg h) (Src h) (Map f) (Map g) (Map h)) else null" 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 "\assoc f g h : hcomp (hcomp f g) h \ hcomp f (hcomp g h)\" proof - let ?A = "Src h" and ?B = "Trg h" and ?C = "Trg g" and ?D = "Trg f" interpret Hom_f: category \Hom ?C ?D\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_g: category \Hom ?B ?C\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_h: category \Hom ?A ?B\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_gh: product_category \Hom ?B ?C\ \Hom ?A ?B\ .. interpret Hom_f_gh: product_category \Hom ?C ?D\ Hom_gh.comp .. interpret Comp_fg: binary_functor \Hom ?C ?D\ \Hom ?B ?C\ \Hom ?B ?D\ \\(fa, g). Comp ?D ?C ?B fa g\ using assms arr_char ide_char'' binary_functor_Comp [of ?B ?C ?D] by simp interpret \: natural_isomorphism Hom_f_gh.comp \Hom (Src h) (Trg f)\ \\(fa, ga, ha). Comp ?D ?B ?A (Comp ?D ?C ?B fa ga) ha\ \\(fa, ga, ha). Comp ?D ?C ?A fa (Comp ?C ?B ?A ga ha)\ \\(fa, ga, ha). Assoc ?D ?C ?B ?A fa ga ha\ using assms ide_char arr_char natural_isomorphism_Assoc [of ?A ?B ?C ?D] by blast show ?thesis proof have 1: "Src f = Trg g \ Src g = Trg h" using assms src_def trg_def by simp have 2: "Hom_f.ide (Map f) \ Hom_g.ide (Map g) \ Hom_h.ide (Map h)" using assms 1 ide_char' [of f] arr_char [of f] by (simp add: ide_char'') show 3: "arr (assoc f g h)" unfolding assoc_def using assms arr_char ide_char'' H.VV.arr_char H.VVV.arr_char H.VVV.ide_char src_def trg_def \.preserves_reflects_arr [of "(Map f, Map g, Map h)"] Hom_f_gh.arr_char Hom_gh.arr_char by simp show "dom (assoc f g h) = hcomp (hcomp f g) h" proof - have "arr (MkCell ?B ?D (Comp ?D ?C ?B (Map f) (Map g)))" by (metis assms(1-2,4) 1 Map_hcomp Src_hcomp Trg_hcomp arr_MkCell arr_char arr_hcomp(1) ideD(1)) moreover have "MkObj ?B = trg h" using assms ide_char'' arr_char MkCell_Map null_char trg_MkCell by metis ultimately show ?thesis unfolding hcomp_def using assms 1 2 3 arr_char ide_char'' assoc_def dom_MkCell H.VV.arr_char H.VVV.arr_char H.VVV.ide_char src_MkCell trg_MkCell \.preserves_dom by force qed show "cod (assoc f g h) = hcomp f (hcomp g h)" proof - have "trg g = MkObj ?C" using assms ide_char'' arr_char MkCell_Map null_char trg_MkCell by metis thus ?thesis unfolding hcomp_def using assms 2 3 \.preserves_cod src_MkCell trg_MkCell H.hseqI' hcomp_def assms arr_char ide_char'' assoc_def cod_MkCell H.VV.arr_char H.VVV.arr_char H.VVV.ide_char by force qed qed qed 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 (assoc f g h)" and "dom (assoc f g h) = hcomp (hcomp f g) h" and "cod (assoc f g h) = hcomp f (hcomp g h)" using assms assoc_in_hom by auto lemma assoc_simps' [simp]: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "src (assoc f g h) = src h" and "trg (assoc f g h) = trg f" and "Src (assoc f g h) = Src h" and "Trg (assoc f g h) = Trg f" and "Map (assoc f g h) = Assoc (Trg f) (Trg g) (Trg h) (Src h) (Map f) (Map g) (Map h)" proof - show "src (assoc f g h) = src h" using assms src_hcomp src_dom src_def src_MkCell assoc_simps(1) assoc_def by (metis (no_types, lifting) ideD(1) not_arr_null) show "trg (assoc f g h) = trg f" using assms trg_hcomp trg_hcomp trg_cod H.hseqI' by (metis assoc_simps(1,3) ideD(1)) show "Src (assoc f g h) = Src h" using assms Src_hcomp Src_dom by (metis (no_types, lifting) Src.simps(1) arr_char assoc_def assoc_simps(1) null_char) show "Trg (assoc f g h) = Trg f" using assms Trg_hcomp Trg_dom by (metis (no_types, lifting) Trg.simps(1) arr_char assoc_def assoc_simps(1) null_char) show "Map (assoc f g h) = Assoc (Trg f) (Trg g) (Trg h) (Src h) (Map f) (Map g) (Map h)" using assms Map_hcomp Map_dom by (metis (no_types, lifting) Map.simps(1) arr_char assoc_def assoc_simps(1) null_char) qed lemma iso_assoc: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "iso (assoc f g h)" proof - let ?A = "Src h" and ?B = "Trg h" and ?C = "Trg g" and ?D = "Trg f" interpret Hom_f: category \Hom ?C ?D\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_g: category \Hom ?B ?C\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_h: category \Hom ?A ?B\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_fg: product_category \Hom ?C ?D\ \Hom ?B ?C\ .. interpret Hom_gh: product_category \Hom ?B ?C\ \Hom ?A ?B\ .. interpret Hom_f_gh: product_category \Hom ?C ?D\ Hom_gh.comp .. interpret \: natural_isomorphism Hom_f_gh.comp \Hom (Src h) (Trg f)\ \\(fa, ga, ha). Comp ?D ?B ?A (Comp ?D ?C ?B fa ga) ha\ \\(fa, ga, ha). Comp ?D ?C ?A fa (Comp ?C ?B ?A ga ha)\ \\(fa, ga, ha). Assoc ?D ?C ?B ?A fa ga ha\ using assms ide_char arr_char natural_isomorphism_Assoc [of ?A ?B ?C ?D] by blast show ?thesis using assms \.components_are_iso [of "(Map f, Map g, Map h)"] iso_char H.VV.arr_char H.VVV.arr_char H.VVV.ide_char ide_char'' by (simp add: src_def trg_def) qed lemma assoc_naturality: assumes "arr f" and "arr g" and "arr h" and "src f = trg g" and "src g = trg h" shows "vcomp (H.HoVH (f, g, h)) (assoc (dom f) (dom g) (dom h)) = vcomp (assoc (cod f) (cod g) (cod h)) (H.HoHV (f, g, h))" proof - let ?A = "Src h" and ?B = "Trg h" and ?C = "Trg g" and ?D = "Trg f" have 1: "Src f = Trg g \ Src g = Trg h" using assms src_def trg_def by simp interpret Hom_f: category \Hom ?C ?D\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_g: category \Hom ?B ?C\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_h: category \Hom ?A ?B\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Hom_fg: product_category \Hom ?C ?D\ \Hom ?B ?C\ .. interpret Hom_gh: product_category \Hom ?B ?C\ \Hom ?A ?B\ .. interpret Hom_fg_h: product_category Hom_fg.comp \Hom ?A ?B\ .. interpret Hom_f_gh: product_category \Hom ?C ?D\ Hom_gh.comp .. interpret Hom: category \Hom ?A ?D\ using assms ide_char arr_char dom_char cod_char category_Hom by simp interpret Comp_fg: binary_functor \Hom ?C ?D\ \Hom ?B ?C\ \Hom ?B ?D\ \\(f', g). Comp ?D ?C ?B f' g\ using assms arr_char ide_char'' binary_functor_Comp [of ?B ?C ?D] by simp interpret Comp_gh: binary_functor \Hom ?B ?C\ \Hom ?A ?B\ \Hom ?A ?C\ \\(f', g). Comp ?C ?B ?A f' g\ using assms arr_char ide_char'' binary_functor_Comp [of ?A ?B ?C] by simp interpret Comp_fg_h: binary_functor \Hom ?B ?D\ \Hom ?A ?B\ \Hom ?A ?D\ \\(f', g). Comp ?D ?B ?A f' g\ using assms arr_char ide_char'' binary_functor_Comp [of ?A ?B ?D] by simp interpret Comp_f_gh: binary_functor \Hom ?C ?D\ \Hom ?A ?C\ \Hom ?A ?D\ \\(f', g). Comp ?D ?C ?A f' g\ using assms arr_char ide_char'' binary_functor_Comp [of ?A ?C ?D] by simp interpret \: natural_isomorphism Hom_f_gh.comp \Hom ?A ?D\ \\(f', g', h'). Comp ?D ?B ?A (Comp ?D ?C ?B f' g') h'\ \\(f', g', h'). Comp ?D ?C ?A f' (Comp ?C ?B ?A g' h')\ \\(f', g', h'). Assoc ?D ?C ?B ?A f' g' h'\ using assms ide_char arr_char natural_isomorphism_Assoc [of ?A ?B ?C ?D] by blast have ide_Map_dom: "Hom_f.ide (Map (dom f)) \ Hom_g.ide (Map (dom g)) \ Hom_h.ide (Map (dom h))" using assms 1 ide_char'' arr_char by simp have ide_Map_cod: "Hom_f.ide (Map (cod f)) \ Hom_g.ide (Map (cod g)) \ Hom_h.ide (Map (cod h))" using assms 1 ide_char'' arr_char by simp have "vcomp (H.HoVH (f, g, h)) (assoc (dom f) (dom g) (dom h)) = vcomp (hcomp f (hcomp g h)) (MkCell (Src (dom h)) (Trg (dom f)) (Assoc (Trg (dom f)) (Trg (dom g)) (Trg (dom h)) (Src (dom h)) (Map (dom f)) (Map (dom g)) (Map (dom h))))" using assms 1 H.HoVH_def H.VV.arr_char H.VVV.arr_char H.VVV.ide_char assoc_def assoc_in_hom by simp also have "... = MkCell (Src (dom h)) (Trg (dom f)) (Hom (Src (dom h)) (Trg (dom f)) (Comp (Trg (dom f)) (Trg g) (Src (dom h)) (Map f) (Comp (Trg g) (Trg h) (Src (dom h)) (Map g) (Map h))) (Assoc (Trg (dom f)) (Trg (dom g)) (Trg (dom h)) (Src (dom h)) (Map (dom f)) (Map (dom g)) (Map (dom h))))" proof - have "Hom.seq (Comp ?D ?C ?A (Map f) (Comp ?C ?B ?A (Map g) (Map h))) (Assoc ?D (Trg (dom g)) (Trg (dom h)) ?A (Map (dom f)) (Map (dom g)) (Map (dom h)))" proof (intro Hom.seqI) show "Hom.arr (Assoc ?D (Trg (dom g)) (Trg (dom h)) ?A (Map (dom f)) (Map (dom g)) (Map (dom h)))" proof - have "Hom.arr (Assoc ?D (Trg (dom g)) (Trg (dom h)) ?A (Map (dom f)) (Map (dom g)) (Map (dom h)))" using assms 1 arr_char Trg_dom Src_dom ide_Map_dom \.preserves_reflects_arr [of "(Map (dom f), Map (dom g), Map (dom h))"] by simp thus ?thesis using assms 1 arr_char Src_dom Trg_dom assoc_simps(1-2) assoc_def H.VV.ide_char H.VV.arr_char H.VV.arr_char ide_Map_dom by simp qed show "Hom.arr (Comp ?D ?C ?A (Map f) (Comp ?C ?B ?A (Map g) (Map h)))" proof - have "Hom.arr (Comp ?D ?C ?A (Map f) (Comp ?C ?B ?A (Map g) (Map h)))" using assms 1 arr_char Comp_f_gh.preserves_reflects_arr [of "(Map f, Comp ?C ?B ?A (Map g) (Map h))"] Comp_gh.preserves_reflects_arr [of "(Map g, Map h)"] Src_dom Trg_dom by simp thus ?thesis using assms 1 arr_char Src_dom Trg_dom by simp qed show "Hom.dom (Comp ?D ?C ?A (Map f) (Comp ?C ?B ?A (Map g) (Map h))) = Hom.cod (Assoc ?D (Trg (dom g)) (Trg (dom h)) ?A (Map (dom f)) (Map (dom g)) (Map (dom h)))" proof - have "Hom.cod (Assoc ?D (Trg (dom g)) (Trg (dom h)) ?A (Map (dom f)) (Map (dom g)) (Map (dom h))) = Hom.cod (Map (assoc (dom f) (dom g) (dom h)))" using Src_dom Trg_dom assms(1-5) assoc_simps'(5) ide_dom src_dom trg_dom by presburger also have "... = Comp ?D ?C ?A (Map (dom f)) (Comp ?C ?B ?A (Map (dom g)) (Map (dom h)))" proof - have "dom f \ Null \ dom g \ Null \ dom h \ Null" using arr_dom assms not_arr_null null_char by fastforce moreover have "Hom.cod (Map (assoc (dom f) (dom g) (dom h))) = Comp ?D ?C ?A (Map (dom f)) (Comp ?C ?B ?A (Map (dom g)) (Map (dom h)))" using assms assoc_simps'(5) ide_Map_dom \.preserves_cod [of "(Map (dom f), Map (dom g), Map (dom h))"] by simp ultimately show ?thesis using assms 1 arr_char assoc_def H.VV.ide_char H.VV.arr_char H.VV.arr_char Src_dom Trg_dom ide_Map_dom null_char assoc_simps'(5) by simp qed also have "... = Hom.dom (Comp ?D ?C ?A (Map f) (Comp ?C ?B ?A (Map g) (Map h)))" proof - have "arr (MkCell ?A ?C (Comp ?C ?B ?A (Map g) (Map h)))" using assms 1 arr_char arr_MkCell Comp_gh.preserves_reflects_arr [of "(Map g, Map h)"] by simp thus ?thesis using assms arr_char 1 Map_dom Comp_f_gh.preserves_dom [of "(Map f, Comp ?C ?B ?A (Map g) (Map h))"] Comp_gh.preserves_dom [of "(Map g, Map h)"] by simp qed finally show ?thesis by argo qed qed thus ?thesis using assms(1-5) H.hseqI' arr_char vcomp_def by auto qed also have "... = MkCell (Src h) (Trg f) (Hom (Src h) (Trg f) (Assoc (Trg f) (Trg (cod g)) (Trg (cod h)) (Src h) (Map (cod f)) (Map (cod g)) (Map (cod h))) (Comp (Trg f) (Trg h) (Src h) (Comp (Trg f) (Trg g) (Src g) (Map f) (Map g)) (Map h)))" using assms 1 arr_char \.naturality [of "(Map f, Map g, Map h)"] by simp also have "... = vcomp (MkCell (Src (cod h)) (Trg (cod f)) (Assoc (Trg (cod f)) (Trg (cod g)) (Trg (cod h)) (Src (cod h)) (Map (cod f)) (Map (cod g)) (Map (cod h)))) (hcomp (hcomp f g) h)" proof - have "arr (MkCell ?B ?D (Comp ?D ?C ?B (Map f) (Map g)))" using assms 1 arr_char arr_MkCell Comp_fg.preserves_reflects_arr [of "(Map f, Map g)"] by simp moreover have "Hom.arr (Comp ?D ?B ?A (Comp ?D ?C ?B (Map f) (Map g)) (Map h))" using assms 1 arr_char Comp_fg.preserves_reflects_arr [of "(Map f, Map g)"] Comp_fg_h.preserves_reflects_arr [of "(Comp ?D ?C ?B (Map f) (Map g), Map h)"] by simp moreover have "Hom.arr (Assoc ?D (Trg (cod g)) (Trg (cod h)) ?A (Map (cod f)) (Map (cod g)) (Map (cod h)))" using assms 1 arr_char Trg_cod ide_Map_cod \.preserves_reflects_arr [of "(Map (cod f), Map (cod g), Map (cod h))"] by simp moreover have "Hom.seq (Assoc ?D (Trg (cod g)) (Trg (cod h)) ?A (Map (cod f)) (Map (cod g)) (Map (cod h))) (Comp ?D ?B ?A (Comp ?D ?C ?B (Map f) (Map g)) (Map h))" proof (intro Hom.seqI) show "Hom.arr (Comp ?D ?B ?A (Comp ?D ?C ?B (Map f) (Map g)) (Map h))" using assms 1 arr_char Comp_fg.preserves_reflects_arr [of "(Map f, Map g)"] Comp_fg_h.preserves_reflects_arr [of "(Comp ?D ?C ?B (Map f) (Map g), Map h)"] by simp show "Hom.arr (Assoc ?D (Trg (cod g)) (Trg (cod h)) ?A (Map (cod f)) (Map (cod g)) (Map (cod h)))" using assms 1 arr_char Trg_cod ide_Map_cod \.preserves_reflects_arr [of "(Map (cod f), Map (cod g), Map (cod h))"] by simp show "Hom.dom (Assoc ?D (Trg (cod g)) (Trg (cod h)) ?A (Map (cod f)) (Map (cod g)) (Map (cod h))) = Hom.cod (Comp ?D ?B ?A (Comp ?D ?C ?B (Map f) (Map g)) (Map h))" proof - have "Hom.dom (Assoc ?D (Trg (cod g)) (Trg (cod h)) ?A (Map (cod f)) (Map (cod g)) (Map (cod h))) = Hom.dom (Map (assoc (cod f) (cod g) (cod h)))" using H.cod_trg Src_cod Trg_cod assms(1-5) assoc_simps'(5) ide_cod src_cod trg.preserves_cod by presburger also have "... = Comp ?D ?B ?A (Comp ?D ?C ?B (Map (cod f)) (Map (cod g))) (Map (cod h))" proof - have "cod f \ Null \ cod g \ Null \ cod h \ Null" using arr_cod assms not_arr_null null_char by fastforce moreover have "Hom.dom (Map (assoc (cod f) (cod g) (cod h))) = Comp ?D ?B ?A (Comp ?D ?C ?B (Map (cod f)) (Map (cod g))) (Map (cod h))" using assms assoc_simps'(5) ide_Map_cod \.preserves_dom [of "(Map (cod f), Map (cod g), Map (cod h))"] by simp ultimately show ?thesis using assms 1 arr_char assoc_def H.VV.ide_char H.VV.arr_char H.VV.arr_char Src_cod Trg_cod ide_Map_cod null_char assoc_simps'(5) by simp qed also have "... = Hom.cod (Comp ?D ?B ?A (Comp ?D ?C ?B (Map f) (Map g)) (Map h))" using assms arr_char 1 Map_cod arr_MkCell Comp_fg_h.preserves_cod [of "(Comp ?D ?C ?B (Map f) (Map g), Map h)"] Comp_fg.preserves_cod [of "(Map f, Map g)"] Comp_fg.preserves_reflects_arr [of "(Map f, Map g)"] by simp finally show ?thesis by blast qed qed ultimately show ?thesis using assms arr_char vcomp_def hcomp_def Src_cod Trg_cod H.VV.ide_char H.VV.arr_char H.VV.arr_char src_def trg_def by simp qed also have "... = vcomp (assoc (cod f) (cod g) (cod h)) (H.HoHV (f, g, h))" using assms 1 H.HoHV_def H.VV.arr_char H.VVV.arr_char H.VVV.ide_char assoc_def assoc_in_hom by simp finally show "vcomp (H.HoVH (f, g, h)) (assoc (dom f) (dom g) (dom h)) = vcomp (assoc (cod f) (cod g) (cod h)) (H.HoHV (f, g, h))" by blast qed interpretation \\<^sub>0: transformation_by_components H.VVV.comp vcomp H.HoHV H.HoVH \\(f, g, h). assoc f g h\ proof fix fgh show "H.VVV.ide fgh \ \case fgh of (f, g, h) \ assoc f g h : H.HoHV fgh \ H.HoVH fgh\" using assoc_in_hom H.HoHV_def H.HoVH_def H.VV.arr_char H.VVV.arr_char H.VVV.ide_char by (cases fgh) simp assume fgh: "H.VVV.arr fgh" show "vcomp (case H.VVV.cod fgh of (f, g, h) \ assoc f g h) (H.HoHV fgh) = vcomp (H.HoVH fgh) (case H.VVV.dom fgh of (f, g, h) \ assoc f g h)" using fgh assoc_simps H.HoHV_def assoc_naturality H.VV.arr_char H.VVV.arr_char H.VVV.dom_char H.VVV.cod_char by (cases fgh) simp qed definition \ ("\[_,_,_]") where "\ f g h == \\<^sub>0.map (f, g, h)" lemma \_simp_ide: assumes "ide f" and "ide g" and "ide h" and "src f = trg g" and "src g = trg h" shows "\[f, g, h] = MkCell (Src h) (Trg f) (Assoc (Trg f) (Trg g) (Trg h) (Src h) (Map f) (Map g) (Map h))" using assms \_def assoc_def assoc_simps' MkCell_Map not_arr_null \\<^sub>0.map_simp_ide H.VVV.ide_char H.VV.arr_char H.VVV.arr_char by simp interpretation \: natural_isomorphism H.VVV.comp vcomp H.HoHV H.HoVH \\fgh. \ (fst fgh) (fst (snd fgh)) (snd (snd fgh))\ proof - interpret \: natural_isomorphism H.VVV.comp vcomp H.HoHV H.HoVH \\<^sub>0.map using \\<^sub>0.map_simp_ide iso_assoc H.VVV.ide_char H.VV.arr_char H.VVV.arr_char by unfold_locales auto show "natural_isomorphism H.VVV.comp vcomp H.HoHV H.HoVH (\fgh. \ (fst fgh) (fst (snd fgh)) (snd (snd fgh)))" using \.natural_isomorphism_axioms \_def by simp qed text \ What remains is to show that horizontal composition with source or target defines fully faithful functors. \ interpretation endofunctor vcomp H.L using H.endofunctor_L by auto interpretation endofunctor vcomp H.R using H.endofunctor_R by auto interpretation R: fully_faithful_functor vcomp vcomp H.R proof show "\f f'. \par f f'; H.R f = H.R f'\ \ f = f'" proof - fix \ \' assume par: "par \ \'" and eq: "H.R \ = H.R \'" have 1: "Src \' = Src \ \ Trg \' = Trg \" using par by (metis Src_dom Trg_dom) interpret Hom: category \Hom (Src \) (Trg \)\ using par arr_char category_Hom by simp let ?R = "\f. if Hom.arr f then Comp (Trg \) (Src \) (Src \) f (Id (Src \)) else Hom.null" interpret R: fully_faithful_functor \Hom (Src \) (Trg \)\ \Hom (Src \) (Trg \)\ ?R using par arr_char right_unit_Id by simp have R\: "H.R \ = MkCell (Src \) (Trg \) (Comp (Trg \) (Src \) (Src \) (Map \) (Id (Src \)))" unfolding hcomp_def using par src_def null_char H.trg_src src.preserves_arr by simp have R\': "H.R \' = MkCell (Src \) (Trg \) (Comp (Trg \) (Src \) (Src \) (Map \') (Id (Src \)))" unfolding hcomp_def using par 1 src_def null_char H.trg_src src.preserves_arr by simp have "Map \ = Map \'" using R\ R\' eq par arr_char eq R.is_faithful by (metis "1" Map_cod Map_dom cell.inject) thus "\ = \'" using 1 par MkCell_Map by (metis arr_char null_char) qed show "\f g \. \ide f; ide g; \\ : H.R f \ H.R g\\ \ \\. \\ : f \ g\ \ H.R \ = \" proof - fix f g \ assume f: "ide f" and g: "ide g" and \: "\\ : H.R f \ H.R g\" interpret Hom: category \Hom (Src \) (Trg \)\ using \ arr_char category_Hom by auto let ?R = "\f. if Hom.arr f then Comp (Trg \) (Src \) (Src \) f (Id (Src \)) else Hom.null" interpret R: fully_faithful_functor \Hom (Src \) (Trg \)\ \Hom (Src \) (Trg \)\ ?R using \ arr_char right_unit_Id by auto have 0: "Src f = Src \ \ Trg f = Trg \ \ Src g = Src \ \ Trg g = Trg \" proof (intro conjI) show "Trg f = Trg \" using f \ Trg_dom Trg_hcomp by fastforce show "Trg g = Trg \" using g \ Trg_cod Trg_hcomp by fastforce show "Src f = Src \" proof - have 1: "arr f \ dom f = f \ cod f = f" by (meson f ide_char) hence "hcomp f (src f) = dom \" using \ by fastforce thus ?thesis using 1 by (metis (no_types) H.trg_src Src.simps(1) Src_hcomp \ dom_char in_homE src.preserves_arr src_def) qed show "Src g = Src \" proof - have 1: "arr g \ dom g = g \ cod g = g" by (meson g ide_char) hence "hcomp g (src g) = cod \" using \ by fastforce thus ?thesis using 1 by (metis (no_types) H.trg_src Src.simps(1) Src_hcomp \ cod_char in_homE src.preserves_arr src_def) qed qed have 1: "Hom.in_hom (Map \) (?R (Map f)) (?R (Map g))" proof show "Hom.arr (Map \)" using \ arr_char by auto show "Hom.dom (Map \) = ?R (Map f)" proof - have 1: "arr f \ dom f = f \ cod f = f" using f ide_char by blast have "dom \ = MkCell (Src \) (Trg \) (Hom.dom (Map \))" by (meson \ dom_char in_homE) thus ?thesis using 1 H.trg_src \ arr_char hcomp_def src.preserves_arr src_def by fastforce qed show "Hom.cod (Map \) = ?R (Map g)" proof - have 1: "arr g \ dom g = g \ cod g = g" using g ide_char by blast have "cod \ = MkCell (Src \) (Trg \) (Hom.cod (Map \))" by (meson \ cod_char in_homE) thus ?thesis using 1 H.trg_src \ arr_char hcomp_def src.preserves_arr src_def by fastforce qed qed have 2: "Hom.ide (Map f) \ Hom.ide (Map g)" using 0 f g arr_char ide_char'' by simp obtain x where x: "Hom.in_hom x (Map f) (Map g) \ ?R x = Map \" using \ 1 2 R.is_full by blast have "\MkCell (Src \) (Trg \) x : f \ g\" proof - have "arr (MkCell (Src \) (Trg \) x)" using \ arr_char x by auto thus ?thesis by (metis 0 Hom.in_homE Map.simps(1) Src.simps(1) Trg.simps(1) cod_char dom_char f g ide_char in_homI x) qed moreover have "H.R (MkCell (Src \) (Trg \) x) = \" using MkCell_Map \ arrI arr_char hcomp_def null_char src.preserves_arr x by auto ultimately show "\\. \\ : f \ g\ \ H.R \ = \" by auto qed qed interpretation L: fully_faithful_functor vcomp vcomp H.L proof show "\f f'. \par f f'; H.L f = H.L f'\ \ f = f'" proof - fix \ \' assume par: "par \ \'" and eq: "H.L \ = H.L \'" have 1: "Src \' = Src \ \ Trg \' = Trg \" using par by (metis Src_dom Trg_dom) interpret Hom: category \Hom (Src \) (Trg \)\ using par arr_char category_Hom by simp let ?L = "\f. if Hom.arr f then Comp (Trg \) (Trg \) (Src \) (Id (Trg \)) f else Hom.null" interpret L: fully_faithful_functor \Hom (Src \) (Trg \)\ \Hom (Src \) (Trg \)\ ?L using par arr_char left_unit_Id [of "Src \" "Trg \"] by simp have L\: "H.L \ = MkCell (Src \) (Trg \) (Comp (Trg \) (Trg \) (Src \) (Id (Trg \)) (Map \))" unfolding hcomp_def using par trg_def null_char H.src_trg trg.preserves_arr by simp have L\': "H.L \' = MkCell (Src \) (Trg \) (Comp (Trg \) (Trg \) (Src \) (Id (Trg \)) (Map \'))" unfolding hcomp_def using par 1 trg_def null_char H.src_trg trg.preserves_arr by simp have "Map \ = Map \'" using L\ L\' eq par arr_char eq L.is_faithful by (metis "1" Map.simps(1) Map_cod Map_dom) thus "\ = \'" using 1 par MkCell_Map by (metis arr_char null_char) qed show "\f g \. \ide f; ide g; \\ : H.L f \ H.L g\\ \ \\. \\ : f \ g\ \ H.L \ = \" proof - fix f g \ assume f: "ide f" and g: "ide g" and \: "\\ : H.L f \ H.L g\" interpret Hom: category \Hom (Src \) (Trg \)\ using \ arr_char category_Hom by auto let ?L = "\f. if Hom.arr f then Comp (Trg \) (Trg \) (Src \) (Id (Trg \)) f else Hom.null" interpret L: fully_faithful_functor \Hom (Src \) (Trg \)\ \Hom (Src \) (Trg \)\ ?L using \ arr_char left_unit_Id by auto have 0: "Src f = Src \ \ Trg f = Trg \ \ Src g = Src \ \ Trg g = Trg \" proof (intro conjI) show "Src f = Src \" using Src_dom Src_hcomp \ f by fastforce show "Src g = Src \" using \ g Src_cod Src_hcomp by fastforce show "Trg f = Trg \" proof - have 1: "arr f \ dom f = f \ cod f = f" by (meson f ide_char) hence "hcomp (trg f) f = dom \" using \ by fastforce thus ?thesis using 1 by (metis (no_types) H.src_trg Trg.simps(1) Trg_hcomp \ dom_char in_homE trg.preserves_arr trg_def) qed show "Trg g = Trg \" proof - have 1: "arr g \ dom g = g \ cod g = g" by (meson g ide_char) hence "hcomp (trg g) g = cod \" using \ by fastforce thus ?thesis using 1 by (metis (no_types) H.src_trg Trg.simps(1) Trg_hcomp \ cod_char in_homE trg.preserves_arr trg_def) qed qed have 1: "Hom.in_hom (Map \) (?L (Map f)) (?L (Map g))" proof show "Hom.arr (Map \)" using \ arr_char by auto show "Hom.dom (Map \) = ?L (Map f)" proof - have "dom \ = MkCell (Src \) (Trg \) (Hom.dom (Map \))" using \ dom_char [of \] by auto hence "Hom.dom (Map \) = Map (dom \)" by simp also have "... = ?L (Map f)" using 0 f \ left_unit_Id [of "Src f" "Trg f"] apply (simp add: ide_char'') by (metis (no_types, lifting) H.src_trg Map.simps(1) Map_hcomp Trg.simps(1) f ide_char in_homE trg.preserves_arr trg_def) finally show ?thesis by blast qed show "Hom.cod (Map \) = ?L (Map g)" proof - have "cod \ = MkCell (Src \) (Trg \) (Hom.cod (Map \))" using \ cod_char [of \] by auto hence "Hom.cod (Map \) = Map (cod \)" by simp also have "... = ?L (Map g)" using 0 g \ left_unit_Id [of "Src g" "Trg g"] apply (simp add: ide_char'') by (metis (no_types, lifting) H.src_trg Map.simps(1) Map_hcomp Trg.simps(1) g ide_char in_homE trg.preserves_arr trg_def) finally show ?thesis by blast qed qed have 2: "Hom.ide (Map f) \ Hom.ide (Map g)" using 0 f g arr_char ide_char'' by simp obtain x where x: "Hom.in_hom x (Map f) (Map g) \ ?L x = Map \" using \ 1 2 L.is_full by blast have "\MkCell (Src \) (Trg \) x : f \ g\" proof - have "arr (MkCell (Src \) (Trg \) x)" using \ arr_char x by auto thus ?thesis by (metis 0 Hom.in_homE Map.simps(1) Src.simps(1) Trg.simps(1) cod_char dom_char f g ide_char in_homI x) qed moreover have "H.L (MkCell (Src \) (Trg \) x) = \" using MkCell_Map \ arrI arr_char hcomp_def null_char trg.preserves_arr x by auto ultimately show "\\. \\ : f \ g\ \ H.L \ = \" by auto qed qed text \ The unit isomorphisms are defined in terms of the specified function \Unit\. \ definition \ ("\[_]") where "\[a] \ MkCell (Src a) (Src a) (Unit (Src a))" lemma \_simps [simp]: assumes "H.obj a" shows "Src \[a] = Src a" and "Trg \[a] = Trg a" and "Map \[a] = Unit (Src a)" using assms \_def H.obj_def src_def trg_def apply auto by (metis Trg.simps(1)) text \ The main result: the construction produces a bicategory. \ proposition induces_bicategory: shows "bicategory vcomp hcomp \ \ src trg" proof fix a assume a: "H.obj a" have Src_a: "Src a \ Obj" using a ide_char'' by auto interpret Hom: category \Hom (Src a) (Src a)\ using Src_a category_Hom by auto show "\\ a : hcomp a a \ a\" proof - have "\\ a : MkCell (Src a) (Src a) (Hom.dom (Unit (Src a))) \ MkCell (Src a) (Src a) (Hom.cod (Unit (Src a)))\" using a Src_a MkCell_in_hom Unit_in_hom [of "Src a"] \_def by simp (metis Hom.in_homE) moreover have "MkCell (Src a) (Src a) (Hom.cod (Unit (Src a))) = a" using a MkCell_Map H.obj_def Map_obj src_def Src_a Unit_in_hom by force moreover have "MkCell (Src a) (Src a) (Hom.dom (Unit (Src a))) = hcomp a a" using a H.obj_def Map_hcomp [of a a] Map_obj Src_a Unit_in_hom Src_hcomp Trg_hcomp by (metis H.objE Hom.in_homE Trg.simps(1) calculation(2) hcomp_def) ultimately show ?thesis by simp qed show "iso (\ a)" using a Src_a iso_Unit [of "Src a"] \\\ a : hcomp a a \ a\\ iso_char \_def by auto next 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\ \ vcomp (hcomp f (\ g h k)) (vcomp (\ f (hcomp g h) k) (hcomp (\ f g h) k)) = vcomp (\ f g (hcomp h k)) (\ (hcomp f g) h k)" proof (intro arr_eqI) 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 1: "\hcomp f (\ g h k) : hcomp f (hcomp (hcomp g h) k) \ hcomp f (hcomp g (hcomp h k))\" using f g h k fg gh hk H.VV.in_hom_char H.VV.arr_char assoc_simps \\<^sub>0.map_simp_ide H.VVV.ide_char H.VVV.arr_char H.preserves_hom \_def by auto have 2: "\hcomp (\ f g h) k : hcomp (hcomp (hcomp f g) h) k \ hcomp (hcomp f (hcomp g h)) k\" using f g h k fg gh hk H.VV.in_hom_char H.VV.arr_char assoc_simps \\<^sub>0.map_simp_ide H.VVV.ide_char H.VVV.arr_char H.preserves_hom \_def by auto have 3: "\\ f (hcomp g h) k : hcomp (hcomp f (hcomp g h)) k \ hcomp f (hcomp (hcomp g h) k)\" using f g h k fg gh hk H.VV.in_hom_char H.VV.arr_char assoc_simps \\<^sub>0.map_simp_ide H.VVV.ide_char H.VVV.arr_char H.preserves_hom \_def by auto have 4: "seq (hcomp f (\ g h k)) (vcomp (\ f (hcomp g h) k) (hcomp (\ f g h) k))" using 1 2 3 by auto have 5: "seq (\ f (hcomp g h) k) (hcomp (\ f g h) k)" using 2 3 by auto have 6: "seq (\ f g (hcomp h k)) (\ (hcomp f g) h k)" using f g h k fg gh hk H.VV.in_hom_char H.VV.arr_char assoc_simps \\<^sub>0.map_simp_ide H.VVV.ide_char H.VVV.arr_char H.preserves_hom \_def by simp let ?LHS = "vcomp (hcomp f (\ g h k)) (vcomp (\ f (hcomp g h) k) (hcomp (\ f g h) k))" let ?RHS = "vcomp (\ f g (hcomp h k)) (\ (hcomp f g) h k)" show "arr ?LHS" using 4 by simp show "arr ?RHS" using 6 by simp show "Src ?LHS = Src ?RHS" using 4 6 f g h k fg gh hk Src_vcomp Src_hcomp \\<^sub>0.map_simp_ide H.VVV.ide_char H.VV.arr_char H.VVV.arr_char assoc_simps assoc_simps' assoc_def \_def by simp show "Trg ?LHS = Trg ?RHS" using 4 6 f g h k fg gh hk Trg_vcomp Trg_hcomp \\<^sub>0.map_simp_ide H.VVV.ide_char H.VV.arr_char H.VVV.arr_char assoc_simps assoc_simps' assoc_def \_def by simp show "Map ?LHS = Map ?RHS" using 4 5 6 f g h k fg gh hk \\<^sub>0.map_simp_ide H.VVV.ide_char H.VV.arr_char H.VVV.arr_char \_def apply simp using Trg_src Trg_trg pentagon ideD(1) ide_char'' by (metis (no_types, lifting)) qed qed sublocale bicategory vcomp hcomp \ \ src trg using induces_bicategory by simp end text \ We now establish some correspondences between the constructed bicategory and the originally given data, to provide some assurance that the construction really is doing what we think it is. \ context concrete_bicategory begin lemma Src_in_Obj: assumes "arr \" shows "Src \ \ Obj" using assms arr_char by simp lemma Trg_in_Obj: assumes "arr \" shows "Trg \ \ Obj" using assms arr_char by simp lemma arr_Map: assumes "arr \" shows "partial_magma.arr (Hom (Src \) (Trg \)) (Map \)" using assms arr_char by simp lemma obj_MkObj_Src: assumes "arr \" shows "obj (MkObj (Src \))" using assms by (simp add: Src_in_Obj obj_MkObj) lemma obj_MkObj_Trg: assumes "arr \" shows "obj (MkObj (Trg \))" using assms by (simp add: Trg_in_Obj obj_MkObj) lemma vcomp_MkCell [simp]: assumes "arr (MkCell A B f)" and "arr (MkCell A B g)" and "partial_magma.seq (Hom A B) f g" shows "vcomp (MkCell A B f) (MkCell A B g) = MkCell A B (Hom A B f g)" using assms(1-3) arr_char vcomp_def by fastforce lemma hcomp_MkCell [simp]: assumes "arr (MkCell B C f)" and "arr (MkCell A B g)" shows "hcomp (MkCell B C f) (MkCell A B g) = MkCell A C (Comp C B A f g)" by (simp add: assms(1-2) hcomp_def) text \ The objects of the constructed bicategory are in bijective correspondence with the originally given set \Obj\, via the inverse mappings \MkObj\ and \Src\. \ proposition bij_betw_obj_Obj: shows "MkObj \ Obj \ Collect obj" and "Src \ Collect obj \ Obj" and "A \ Obj \ Src (MkObj A) = A" and "a \ Collect obj \ MkObj (Src a) = a" and "bij_betw MkObj Obj (Collect obj)" using obj_MkObj obj_def Src_in_Obj src_def apply auto by (intro bij_betwI) auto lemma obj_char: shows "obj a \ Src a \ Obj \ a = MkCell (Src a) (Src a) (Id (Src a))" using Src_in_Obj bij_betw_obj_Obj(4) obj_MkObj by force lemma Map_in_Hom: assumes "arr \" shows "partial_magma.in_hom (Hom (Src \) (Trg \)) (Map \) (Map (dom \)) (Map (cod \))" by (simp add: Src_in_Obj Trg_in_Obj arr_Map assms category.in_homI category_Hom) text \ For each pair of objects \a\ and \b\, the hom-category \hhom a b\ of the constructed bicategory is isomorphic to the originally given category \Hom (Src a) (Src b)\. \ proposition isomorphic_hhom_Hom: assumes "obj a" and "obj b" shows "isomorphic_categories (subcategory.comp vcomp (\f. f \ hhom a b)) (Hom (Src a) (Src b))" proof - interpret hom: subcategory vcomp \\f. f \ hhom a b\ using assms by unfold_locales auto interpret Hom: category \Hom (Src a) (Src b)\ using assms category_Hom Src_in_Obj obj_def by simp let ?Map = "\\. if \ \ hhom a b then Map \ else Hom.null" let ?MkCell = "\\. if Hom.arr \ then MkCell (Src a) (Src b) \ else hom.null" interpret Map: "functor" hom.comp \Hom (Src a) (Src b)\ ?Map proof fix \ show "\ hom.arr \ \ ?Map \ = Hom.null" using hom.inclusion [of \] hom.arr_char by auto assume \: "hom.arr \" have 0: "src \ = a \ trg \ = b" using \ hom.arrE src_def trg_def by (metis in_hhomE mem_Collect_eq) have 1: "arr \" using \ hom.inclusion hom.arrE by blast have 2: "Src \ = Src a \ Trg \ = Trg b" using \ 0 by (metis Src_src Trg_trg hom.arr_char hom.inclusion) show "Hom.arr (?Map \)" using 0 1 arr_Map [of \] \ by auto show "Hom.dom (?Map \) = ?Map (hom.dom \)" proof - have "Hom.dom (?Map \) = Map (dom \)" using \ hom.arrE by fastforce thus ?thesis by (metis \ hom.arrE hom.arr_dom hom.dom_simp) qed show "Hom.cod (?Map \) = ?Map (hom.cod \)" proof - have "Hom.cod (?Map \) = Map (cod \)" using \ hom.arrE by fastforce thus ?thesis by (metis \ hom.arrE hom.arr_cod hom.cod_simp) qed next fix \ \ assume \\: "hom.seq \ \" show "?Map (hom.comp \ \) = Hom (Src a) (Src b) (?Map \) (?Map \)" proof - have 1: "hom.arr \ \ hom.arr \ \ seq \ \" using \\ hom.seq_char by blast hence 2: "hom.comp \ \ = vcomp \ \" using hom.comp_char by auto have 3: "\ \ hhom a b" using 1 hom.arrE by blast have "Src a = Src \" using 3 by (metis Trg_src in_hhomE mem_Collect_eq obj_def) moreover have "Src b = Trg \" using 3 by (metis Trg_src Trg_trg in_hhomE mem_Collect_eq obj_def) ultimately show ?thesis using 1 2 Map_vcomp \\ hom.arrE by presburger qed qed interpret MkCell: "functor" \Hom (Src a) (Src b)\ hom.comp ?MkCell proof fix \ show "\ Hom.arr \ \ ?MkCell \ = hom.null" by simp assume \: "Hom.arr \" show 1: "hom.arr (?MkCell \)" using assms obj_def \ hom.arr_char arr_MkCell src_def arr_char by auto show "hom.dom (?MkCell \) = ?MkCell (Hom.dom \)" using assms 1 \ hom.dom_char src_def arr_char obj_def Src_in_Obj by simp show "hom.cod (?MkCell \) = ?MkCell (Hom.cod \)" using assms 1 \ hom.cod_char src_def arr_char obj_def Src_in_Obj by simp next fix \ \ assume \\: "Hom.seq \ \" have 1: "hom.arr (?MkCell \)" using assms obj_def \\ hom.arr_char src_def arr_char by auto have 2: "hom.arr (?MkCell \)" using assms obj_def \\ hom.arr_char src_def arr_char by auto have 3: "hom.dom (?MkCell \) = hom.cod (?MkCell \)" using \\ 1 2 hom.dom_char dom_char hom.cod_char cod_char arr_char by auto have 4: "seq (?MkCell \) (?MkCell \)" by (metis 1 2 3 hom.arrE hom.cod_simp hom.comp_closed hom.dom_simp hom.inclusion) have "hom.comp (?MkCell \) (?MkCell \) = vcomp (MkCell (Src a) (Src b) \) (MkCell (Src a) (Src b) \)" using \\ 1 2 4 hom.comp_char by auto also have "... = MkCell (Src a) (Src b) (Hom (Src a) (Src b) \ \)" using \\ 4 vcomp_char [of "MkCell (Src a) (Src b) \" "MkCell (Src a) (Src b) \"] by auto also have "... = ?MkCell (Hom (Src a) (Src b) \ \)" using \\ by simp finally show "?MkCell (Hom (Src a) (Src b) \ \) = hom.comp (?MkCell \) (?MkCell \)" by simp qed interpret inverse_functors hom.comp \Hom (Src a) (Src b)\ ?MkCell ?Map proof show "?MkCell o ?Map = hom.map" proof fix \ have "\ \ hhom a b \ (?MkCell o ?Map) \ = hom.map \" using o_apply hom.is_extensional hom.arr_char by simp moreover have "\ \ hhom a b \ (?MkCell o ?Map) \ = hom.map \" proof - assume \: "\ \ hhom a b" have "(?MkCell o ?Map) \ = MkCell (Src a) (Src b) (Map \)" using \ arr_char src_def trg_def by auto also have "... = \" using \ MkCell_Map arr_char null_char by auto also have "... = hom.map \" using \ hom.arrI hom.map_def by presburger finally show "(?MkCell o ?Map) \ = hom.map \" by simp qed ultimately show "(?MkCell o ?Map) \ = hom.map \" by blast qed show "?Map o ?MkCell = Hom.map" proof fix \ have "\ Hom.arr \ \ (?Map o ?MkCell) \ = Hom.map \" using Hom.is_extensional hom.null_char by auto moreover have "Hom.arr \ \ (?Map o ?MkCell) \ = Hom.map \" proof - assume \: "Hom.arr \" have "in_hhom (MkCell (Src a) (Src b) \) a b" using \ MkCell.preserves_reflects_arr [of \] hom.arr_char by simp thus "(?Map o ?MkCell) \ = Hom.map \" using \ by simp qed ultimately show "(?Map o ?MkCell) \ = Hom.map \" by blast qed qed show ?thesis .. qed end end