theory SetsCat imports Category3.SetCat Category3.CategoryWithPullbacks Category3.CartesianClosedCategory
Category3.EquivalenceOfCategories Category3.Colimit Universe begin
text‹
In this section we consider the category of small sets and functions between
them as an exemplifying instance of the pattern we propose for working with large categories
in HOL. We define a locale ‹sets_cat›, which axiomatizes a category with terminal object,
such that each object determines a ``small'' set (the set of its global elements),
there is an object corresponding to any externally given small set, and such that
the hom-sets between objects are in bijection with the small extensional functions
between sets of global elements. We show that this locale characterizes the category
of small sets and functions, in the sense that, for a fixed notion of smallness,
any two interpretations of the ‹sets_cat› locale are equivalent as categories.
We then proceed to derive various familiar properties of a category of sets; assuming
in each case that the notion of ``smallness'' satisfies suitable conditions as defined
in the theory ‹Smallness›, and that the collection of all arrows of the
category satisfies suitable closure conditions as defined in the theory ‹Universe›. In particular, we show if the collection of arrows
forms a ``universe'', then the category is well-pointed, small-complete and small co-complete,
cartesian closed, has a subobject classifier and a natural numbers object,
and splits all epimorphisms. ›
section"Basic Definitions and Properties"
text‹
We will describe the category of small sets and functions as a certain kind of category
with terminal object, which has been equipped with a notion of ``smallness'' that
specifies what sets will correspond to objects in the category. ›
locale sets_cat_base =
smallness sml +
category_with_terminal_object C for sml :: "'V set ==> bool" and C :: "'U comp" (infixr‹⋅›55) begin
sublocale embedding ‹Collect arr› .
text‹
Every object in the category determines a set: its set of global elements
(we make an arbitrary choice of terminal object). ›
abbreviation Set where"Set ≡ hom 1?"
text‹
Every arrow in the category determines an extensional function between
sets of global elements. ›
definitionFun where"Fun f x ≡ if x ∈ Set (dom f) then f ⋅ x else null"
abbreviation Hom where"Hom a b ≡ (Set a → Set b) ∩ {F. ∀x. x ∉ Set a ⟶ F x = null}"
lemma Fun_in_Hom: assumes"«f : a → b¬" shows"Fun f ∈ Hom a b" using assms Fun_def by auto
lemma Set_some_terminal: shows"Set some_terminal = {some_terminal}" using ide_in_hom terminal_def terminal_some_terminal by auto
lemma Fun_some_terminator: assumes"ide a" shows"Fun t?[a] = (λx. if x ∈ Set a then 1? else null)" unfolding Fun_def using assms elementary_category_with_terminal_object.trm_naturality
elementary_category_with_terminal_object.trm_one
extends_to_elementary_category_with_terminal_object by fastforce
text‹
The following function will allow us to obtain an object corresponding to an
externally given set. The set of global elements of the object is to be
equipollent with the given set. We give the definition here, but of course
it will be necessary to prove that this function actually does produce such
an object under suitable conditions. ›
definition mkide :: "'a set ==> 'U" where"mkide A ≡ SOME a. ide a ∧ Set a ≈ A"
end
text‹
The following locale states our axioms for the category of small sets and functions.
The axioms assert: (1) that the set of global elements of every object is small;
(2) that the mapping from hom-sets to extensional functions between small sets
of global elements is injective and surjective; and (3) that the category is ``replete''
in the sense that for every small set of arrows of the category there exists an object
whose set of elements is equipollent with it. ›
locale sets_cat =
sets_cat_base sml C for sml :: "'V set ==> bool" and C :: "'U comp" (infixr‹⋅›55) + assumes small_Set: "ide a ==> small (Set a)" and inj_Fun: "[ide a; ide b]==> inj_on Fun (hom a b)" and surj_Fun: "[ide a; ide b]==> Hom a b ⊆ Fun ` (hom a b)" and repleteness_ax: "[small A; A ⊆ Collect arr]==>∃a. ide a ∧ Set a ≈ A" begin
text‹
It is convenient to extend the repleteness property to apply to any small set,
at any type, which happens to have an embedding into the collection of arrows of
the category. ›
lemma repleteness: assumes"small A"and"embeds A" shows"∃a. ide a ∧ Set a ≈ A" by (metis assms(1,2) eqpoll_trans inj_on_image_eqpoll_self repleteness_ax small_image_iff)
text‹
We obtain a pair of inverse comparison maps between an externally given small set ‹A›
and the set of global elements of the object ‹mkide a› corresponding to it.
The map ‹IN› encodes each element of ‹A› as a global element of ‹mkide A›.
The inverse map ‹OUT› decodes global elements of ‹mkide A› to the corresponding
elements of ‹A›.
We will need to pay attention to these comparison maps when relating notions internal
to the category to notions external to it. However, when working completely internally
to the category these maps do not appear at all. ›
definition OUT :: "'a set ==> 'U ==> 'a" where"OUT A ≡ SOME F. bij_betw F (Set (mkide A)) A"
abbreviationIN :: "'a set ==> 'a ==> 'U" where"IN A ≡ inv_into (Set (mkide A)) (OUT A)"
text‹
The following is the main fact that allows us to produce objects of the category.
It states that, given any small set ‹A› for which there is some embedding into the
collection of arrows of the category, there exists a corresponding object ‹mkide A›
whose set of global elements is equipollent to ‹A›. ›
lemma ide_mkide: assumes"small A"and"embeds A" shows [intro]: "ide (mkide A)" and"Set (mkide A) ≈ A" proof - have"ide (mkide A) ∧ Set (mkide A) ≈ A" using assms repleteness mkide_def someI_ex by (metis (lifting) HOL.ext) thus"ide (mkide A)"and"Set (mkide A) ≈ A" using assms by auto qed
lemma bij_OUT: assumes"small A"and"embeds A" shows"bij_betw (OUT A) (Set (mkide A)) A" unfolding OUT_def using assms ide_mkide(2) someI_ex [of "λF. bij_betw F (Set (mkide A)) A"] eqpoll_def by blast
lemma bij_IN: assumes"small A"and"embeds A" shows"bij_betw (IN A) A (Set (mkide A))" using assms bij_OUT bij_betw_inv_into by blast
lemma OUT_elem_of: assumes"small A"and"embeds A"and"«x : 1?→ mkide A¬" shows"OUT A x ∈ A" by (metis CollectI assms(1,2,3) bij_betw_apply bij_OUT)
lemma IN_in_hom: assumes"small A"and"embeds A"and"x ∈ A"and"a = mkide A" shows"«IN A x : 1?→ a¬" by (metis (mono_tags, lifting) Ball_Collect assms(1,2,3,4) bij_betw_def bij_OUT
inv_into_into set_eq_subset)
lemma IN_OUT: assumes"small A"and"embeds A" shows"x ∈ Set (mkide A) ==> IN A (OUT A x) = x" using assms bij_OUT(1) by (metis bij_betw_inv_into_left)
lemma OUT_IN: assumes"small A"and"embeds A" shows"x ∈ A ==> OUT A (IN A x) = x" using assms bij_OUT(1) by (metis bij_betw_inv_into_right)
lemma Fun_IN: assumes"small A"and"embeds A"and"y ∈ A" shows"Fun (IN A y) = (λx. if x = 1? then IN A y else null)" proof fix x show"Fun (IN A y) x = (if x = 1? then IN A y else null)" proof (cases "x ∈ Set 1?") case False show ?thesis using False Fun_def by (metis IN_in_hom Set_some_terminal assms(1,2,3) in_homE singleton_iff) next case True have x: "x = 1?" using True Set_some_terminal by blast have"Fun (IN A y) x = IN A y ⋅1?" using Fun_def dom_eqI ide_some_terminal ext x by auto alsohave"... = (if x = 1? then IN A y else null)" by (metis (lifting) HOL.ext IN_in_hom assms(1,2,3) comp_arr_dom in_homE x) finallyshow ?thesis by blast qed qed
text‹
The following function enables us to obtain an arrow of the category by specifying
an extensional function between sets of global objects. ›
definition mkarr :: "'U ==> 'U ==> ('U ==> 'U) ==> 'U" where"mkarr a b F ≡ if ide a ∧ ide b ∧ F ∈ Hom a b then SOME f. «f : a → b¬∧ Fun f = F else null"
lemma mkarr_in_hom [intro]: assumes"ide a"and"ide b"and"F ∈ Hom a b" shows"«mkarr a b F : a → b¬" proof - have"∃f. «f : a → b¬∧ Fun f = F" using assms surj_Fun [of a b] by blast thus ?thesis unfolding mkarr_def using assms someI_ex [of "λf. «f : a → b¬∧ Fun f = F"] by auto qed
lemma arr_mkarr [intro, simp]: assumes"ide a"and"ide b"and"F ∈ Hom a b" shows"arr (mkarr a b F)" using assms mkarr_in_hom by blast
lemma arr_mkarrD [dest]: assumes"arr (mkarr a b F)" shows"ide a"and"ide b"and"F ∈ Hom a b" by (metis (lifting) assms mkarr_def not_arr_null)+
lemma arr_mkarrE [elim]: assumes"arr (mkarr a b F)" and"[ide a; ide b; F ∈ Hom a b]==> T" shows T using assms by auto
lemma dom_mkarr [simp]: assumes"arr (mkarr a b F)" shows"dom (mkarr a b F) = a" by (meson arr_mkarrE assms in_homE mkarr_in_hom)
lemma cod_mkarr [simp]: assumes"arr (mkarr a b F)" shows"cod (mkarr a b F) = b" by (meson arr_mkarrE assms in_homE mkarr_in_hom)
lemma Fun_mkarr [simp]: assumes"arr (mkarr a b F)" shows"Fun (mkarr a b F) = F" proof - have"∃f. «f : a → b¬∧ Fun f = F" using assms surj_Fun [of a b] by blast thus ?thesis unfolding mkarr_def using assms someI_ex [of "λf. «f : a → b¬∧ Fun f = F"] by auto qed
lemma mkarr_Fun: assumes"«f : a → b¬" shows"mkarr a b (Fun f) = f" proof - have"«mkarr a b (Fun f) : a → b¬∧ Fun (mkarr a b (Fun f)) = Fun f" by (metis (lifting) Fun_in_Hom Fun_mkarr assms ide_cod ide_dom in_homE mkarr_in_hom) thus ?thesis using assms inj_Fun inj_onD [of Fun"hom a b""mkarr a b (Fun f)" f] by blast qed
text‹
The locale assumptions ensure that, for any two objects ‹a› and ‹b›,
there is a bijection between the hom-set ‹hom a b› and the set ‹Hom a b›
of extensional functions from ‹Set a› to ‹Set b›. ›
lemma bij_Fun: assumes"ide a"and"ide b" shows"bij_betw Fun (hom a b) (Hom a b)" and"bij_betw (mkarr a b) (Hom a b) (hom a b)" proof - have1: "Fun ∈ hom a b → Hom a b" using Fun_in_Hom by blast have2: "mkarr a b ∈ Hom a b → hom a b" using assms mkarr_in_hom by auto have3: "∧F. F ∈ Hom a b ==> Fun (mkarr a b F) = F" using Fun_mkarr assms(1,2) mkarr_in_hom by auto have4: "∧f. f ∈ hom a b ==> mkarr a b (Fun f) = f" using assms mkarr_Fun by auto show"bij_betw Fun (hom a b) (Hom a b)" using1234 by (intro bij_betwI) auto show"bij_betw (mkarr a b) (Hom a b) (hom a b)" using1234 by (intro bij_betwI) auto qed
lemma arr_eqI: assumes"par t u"and"Fun t = Fun u" shows"t = u" using assms by (metis (lifting) arr_iff_in_hom mkarr_Fun)
lemma arr_eqI': assumes"in_hom f a b"and"in_hom g a b" and"∧x. in_hom x 1? a ==> f ⋅ x = g ⋅ x" shows"f = g" using assms arr_eqI [of f g] in_homE Fun_def by fastforce
lemma Fun_arr: assumes"«f : a → b¬" shows"Fun f = (λx. if x ∈ Set a then f ⋅ x else null)" using assms Fun_def by auto
lemma Fun_ide: assumes"ide a" shows"Fun a = (λx. if x ∈ Set a then x else null)" by (metis (lifting) CollectD CollectI assms comp_cod_arr in_homE ide_char Fun_def)
lemma Fun_comp: assumes"seq t u" shows"Fun (t ⋅ u) = Fun t ∘ Fun u" unfolding Fun_def using assms comp_assoc by force
lemma mkarr_comp: assumes"seq g f" shows"mkarr (dom f) (cod g) (Fun g ∘ Fun f) = g ⋅ f" by (metis (lifting) Fun_comp assms cod_comp dom_comp in_homI mkarr_Fun)
lemma comp_mkarr: assumes"arr (mkarr a b F)"and"arr (mkarr b c G)" shows"mkarr b c G ⋅ mkarr a b F = mkarr a c (G ∘ F)" using assms Fun_mkarr mkarr_comp [of "mkarr b c G""mkarr a b F"] by simp
lemma app_mkarr: assumes"in_hom (mkarr a b F) a b"and"in_hom x 1? a" shows"mkarr a b F ⋅ x = F x" using assms Fun_mkarr by (metis Fun_def in_homE mem_Collect_eq)
lemma ide_as_mkarr: assumes"ide a" shows"mkarr a a (λx. if x ∈ Set a then x else null) = a" using assms Fun_ide Fun_mkarr by (intro arr_eqI) auto
text‹
An object ‹a› is terminal if and only if its set of global elements ‹Set a›
is a singleton set. ›
lemma terminal_char: shows"terminal a ⟷ ide a ∧ (∃!x. x ∈ Set a)" proof show"terminal a ==> ide a ∧ (∃!x. x ∈ Set a)" using terminal_def terminal_some_terminal by auto assume a: "ide a ∧ (∃!x. x ∈ Set a)" show"terminal a" proof show"ide a" using a by blast show"∧b. ide b ==>∃!f. «f : b → a¬" proof - fix b assume b: "ide b" have"«mkarr b a (λx. if x ∈ Set b then THE y. y ∈ Set a else null) : b → a¬" using a b theI [of "λy. y ∈ Set a"] by (intro mkarr_in_hom) fastforce+ moreoverhave"∧t u. [«t : b → a¬; «u : b → a¬]==> t = u" using a Fun_def by (intro arr_eqI) fastforce+ ultimatelyshow"∃!f. «f : b → a¬"by blast qed qed qed
text‹
An object ‹a› is initial if and only if its set of global elements ‹Set a›
is the empty set, except in the degenerate situation in which every object
is both an initial and a terminal object. ›
lemma initial_char: shows"initial a ⟷ ide a ∧ (Set a = {} ∨ (∀b. ide b ⟶ terminal b))" proof - have"∀b. ide b ⟶ terminal b ==>∀b. ide b ⟶ initial b" by (simp add: initialI terminal_def) moreoverhave"∃b. ide b ∧¬ terminal b ==>∀a. initial a ⟷ ide a ∧ Set a = {}" proof - assume1: "∃b. ide b ∧¬ terminal b" obtain b where b: "ide b ∧¬ terminal b" using1by blast show"∀a. initial a ⟷ ide a ∧ Set a = {}" proof (intro allI iffI conjI) fix a assume a: "initial a" show"ide a" using a initial_def by blast show"Set a = {}" proof (cases "Set b = {}") case True show ?thesis using a b True by blast next case False have"Set a ≠ {} ==>¬ (∃!f. «f : a → b¬)" proof - assume2: "Set a ≠ {}" obtain x y where3: "x ∈ Set b ∧ y ∈ Set b ∧ x ≠ y" using b False terminal_char by auto show ?thesis proof - have"«mkarr a b (λz. if z ∈ Set a then x else null) : a → b¬" using‹ide a› b 3by auto moreoverhave"«mkarr a b (λz. if z ∈ Set a then y else null) : a → b¬" using‹ide a› b 3by auto moreoverhave"mkarr a b (λz. if z ∈ Set a then x else null) ≠ mkarr a b (λz. if z ∈ Set a then y else null)" by (metis (full_types, lifting) 23 Fun_mkarr arrI calculation(2) ex_in_conv) ultimatelyshow ?thesis by auto qed qed thus ?thesis using a b initial_def by auto qed next fix a assume a: "ide a ∧ Set a = {}" show"initial a" proof - have"∧b. ide b ==>∃!f. «f : a → b¬" proof - fix b assume b: "ide b" have"«mkarr a b (λ_. null) : a → b¬" by (simp add: a b mkarr_in_hom) moreoverhave"∧f g. [«f : a → b¬; «g : a → b¬]==> f = g" using a arr_eqI' by fastforce ultimatelyshow"∃!f. «f : a → b¬"by blast qed thus ?thesis using a initial_def by blast qed qed qed ultimatelyshow ?thesis by (metis initial_def) qed
text‹
An arrow is a monomorphism if and only if the corresponding function is injective. ›
lemma mono_char: shows"mono f ⟷ arr f ∧ inj_on (Fun f) (Set (dom f))" proof assume f: "mono f" have"arr f" using f mono_implies_arr by simp moreoverhave"inj_on (Fun f) (Set (dom f))" by (intro inj_onI)
(metis Fun_def calculation f in_homE mem_Collect_eq mono_cancel seqI) ultimatelyshow"arr f ∧ inj_on (Fun f) (Set (dom f))"by blast next assume f: "arr f ∧ inj_on (Fun f) (Set (dom f))" show"mono f" proof show"arr f" using f by blast fix g h assume seq: "seq f g"and eq: "f ⋅ g = f ⋅ h" show"g = h" proof (intro arr_eqI) show par: "par g h" by (metis dom_comp eq seq seqE) show"Fun g = Fun h" proof - have"∧x. x ∈ Set (dom g) ==> Fun g x = Fun h x" proof - fix x assume x: "x ∈ Set (dom g)" have"f ⋅ (g ⋅ x) = f ⋅ (h ⋅ x)" using eq by (metis comp_assoc) moreoverhave"g ⋅ x ∈ Set (dom f) ∧ h ⋅ x ∈ Set (dom f)" by (metis seq par comp_in_homI in_homI mem_Collect_eq seq seqE x) ultimatelyhave"g ⋅ x = h ⋅ x" using f inj_on_def [of "Fun f""Set (dom f)"] Fun_def by auto thus"Fun g x = Fun h x" using par Fun_def by presburger qed thus ?thesis using par Fun_def by force qed qed qed qed
text‹
An arrow is a retraction if and only if the corresponding function is surjective. ›
lemma retraction_char: shows"retraction f ⟷ arr f ∧ Fun f ` Set (dom f) = Set (cod f)" proof (intro iffI conjI) assume f: "retraction f" show1: "arr f" using f by blast obtain g where g: "f ⋅ g = cod f" using f by blast show"Fun f ` Set (dom f) = Set (cod f)" proof show"Fun f ` Set (dom f) ⊆ Set (cod f)" using‹arr f› Fun_def by auto show"Set (cod f) ⊆ Fun f ` Set (dom f)" proof - have"Set (cod f) ⊆ Fun f ` Fun g ` Set (cod f)" proof - have"Set (cod f) ⊆ Fun (cod f) ` Set (cod f)" using1 Fun_ide by auto alsohave"... = (Fun f ∘ Fun g) ` Set (cod f)" using1 g Fun_comp by (metis (no_types, lifting) arr_cod) alsohave"... = Fun f ` Fun g ` Set (cod f)" by (metis image_comp) finallyshow ?thesis by blast qed alsohave"... ⊆ Fun f ` Set (dom f)" proof - have"«g : cod f → dom f¬" using g by (metis 1 arr_iff_in_hom ide_cod ide_compE seqE) thus ?thesis using Fun_def by auto qed finallyshow ?thesis by blast qed qed next assume f: "arr f ∧ Fun f ` Set (dom f) = Set (cod f)" let ?G = "λy. if y ∈ Set (cod f) then inv_into (Set (dom f)) (Fun f) y else null" let ?g = "mkarr (cod f) (dom f) ?G" have"f ⋅ ?g = cod f" proof (intro arr_eqI) have seq: "seq f ?g" proof show"«f : dom f → cod f¬" using f by blast show"«?g : cod f → dom f¬" proof (intro mkarr_in_hom) show"ide (cod f)"and"ide (dom f)" using f by auto show"?G ∈ (Set (cod f) → Set (dom f)) ∩ {F. ∀x. x ∉ Set (cod f) ⟶ F x = null}" proof show"?G ∈ Set (cod f) → Set (dom f)" proof fix x assume x: "x ∈ Set (cod f)" show"?G x ∈ Set (dom f)" by (metis f inv_into_into x) qed show"?G ∈ {F. ∀x. x ∉ Set (cod f) ⟶ F x = null}" using f by auto qed qed qed thus par: "par (f ⋅ ?g) (cod f)"by auto show"Fun (f ⋅ ?g) = Fun (cod f)" proof - have"Fun (f ⋅ ?g) = Fun f ∘ ?G" using par Fun_comp Fun_mkarr by fastforce alsohave"... = Fun (cod f)" proof fix y show"(Fun f ∘ ?G) y = Fun (cod f) y" proof (cases "y ∈ Set (cod f)") case False show ?thesis using False Fun_def dom_cod by auto next case True show ?thesis proof - have"Fun f (inv_into (Set (dom f)) (Fun f) y) = y" by (metis (no_types) True f f_inv_into_f) thus ?thesis using Fun_ide True f by force qed qed qed finallyshow ?thesis by blast qed qed thus"retraction f" by (metis (lifting) f ide_cod retraction_def) qed
text‹
An arrow is a isomorphism if and only if the corresponding function is a bijection. ›
lemma iso_char: shows"iso f ⟷ arr f ∧ bij_betw (Fun f) (Set (dom f)) (Set (cod f))" using retraction_char mono_char bij_betw_def by (metis (no_types, lifting) iso_iff_mono_and_retraction)
lemma isomorphic_char: shows"isomorphic a b ⟷ ide a ∧ ide b ∧ Set a ≈ Set b" proof assume1: "isomorphic a b" show"ide a ∧ ide b ∧ Set a ≈ Set b" using1 isomorphic_def iso_char eqpoll_def [of "Set a""Set b"] by auto next assume1: "ide a ∧ ide b ∧ Set a ≈ Set b" obtain F where F: "bij_betw F (Set a) (Set b)" using1 eqpoll_def by blast let ?F' = "λx. if x ∈ Set a then F x else null" let ?f = "mkarr a b (λx. if x ∈ Set a then F x else null)" have f: "«?f : a → b¬" proof show"ide a"and"ide b" using1by auto show"(λx. if x ∈ Set a then F x else null) ∈ Hom a b" using F Pi_mem bij_betw_imp_funcset by fastforce qed moreoverhave"bij_betw (Fun ?f) (Set a) (Set b)" using F Fun_mkarr arrI bij_betw_cong f apply (unfold bij_betw_def) by (auto simp add: inj_on_def) ultimatelyhave"iso ?f ∧ dom ?f = a ∧ cod ?f = b" using iso_char Fun_mkarr by auto thus"isomorphic a b" using isomorphicI by force qed
end
section"Categoricity"
text‹
The following is a kind of ``categoricity in power'' result which states that,
for a fixed notion of smallness, if ‹C› and ‹D› are ``sets categories'' whose collections
of arrows are equipollent, then in fact ‹C› and ‹D› are equivalent categories. ›
lemma categoricity: assumes"sets_cat sml C"and"sets_cat sml D" and"Collect (partial_composition.arr C) ≈ Collect (partial_composition.arr D)" shows"equivalent_categories C D" proof interpret smallness sml using assms(1) sets_cat_def sets_cat_base_def by blast interpret C: sets_cat sml C using assms(1) by blast
tsml using assms(2) by blast have D_embeds_C_Set: "∧ using assms(3) D.embeds_subset [of "Collect C.arr"] by (metis (no_types, liftiusingFun_d b a let ?Fo = "λa. D.mkide (C.Set a)" have Fo: "∧a. C.ide a ==> D.ide (?Fo a)" by (simp add: C.small_Set D.ide_mkide(1) D_embeds_C_Set) have bij_OUT: "∧ by (simp add: C.small_Set D.bij_OUT(1) D_embeds_C_Set) let ?FFu<^ qed then (D.IN (C.Set (C.cod f)) ∘ C.Fun f ∘ D.OUT (C.Set (C.dom f))) x
else D.null" have FFun: "∧f. C.arr f ==> ?FFuproof( mkarr_in_hom proof fix f assume f: "C.arr f" show java.lang.NullPointerException by simp show "?FF<>x<notin proof fix x assume x: "x ∈ D.Set (?Fo (C.dom f))" show"?FFun f x ∈ D.Set (D.mkide (C.Set (C.cod f)))" proof - have"D.in_hom (D.IN (C.Set (C.cod f)) (C f (D.OUT (C.Set (C.dom f)) x))) D.some_terminal (D.mkide (C.Set (C.cod f)))" proof - have"«proof using x f C.ide_dom bij_betwE bij_OUT by blast moreoverhave " CSet )" using C.small_Set f by force moreover have "D.embeds (C.Set (C.cod f))" by (simp add: D_embeds_C_Set f) ultimately show ?thesis using x f D.bij_IN [of "C.Set (C.cod f)"] bij_betwE by auto qed moreover have "«D.OUT (C.Set (C.dom f)) x : 1?→ C.dom f¬" using x f C.ide_dom bij_betwE bij_OUT by blast ultimately show ?thesis using x f C.Fun_def by force qed qed qed let ?F = "λf. if C.arr f then D.mkarr (?Fo (C.dom f)) (?Fjava.lang.NullPointerException interpret"functor" C D ?F proof show"∧f. ¬ by simp show arrF: "∧ using Fjava.lang.NullPointerException show domF: "∧f. C.arr f ==> D.dom (?F f) = ?F (C.dom f)" proof - fix f assume f: "C.arr f" have"D.dom (?F f) = D.mkide (C.Set (C.dom f))" using f arrF by auto alsohave"... = ?F (C.dom f)" proof have java.lang.NullPointerException (λx. if x ∈ D.Set (D.mkide (C.Set (C.dom f))) then x else D.null)" proof fix x have"x ∈ D.Set (D.mkide (C.Set (C.dom f))) ==>
java.lang.NullPointerException using f C.ide_dom bij_betwE bij_OUT by blast thus "?FFun (C.dom f) x =
(if x ∈ D.Set (D.mkide (C.Set (C.dom f))) then x else D.null)" using f C.ide_dom bij_betwE bij_OUT arrF Fo C.Fun_ide D.IN_OUT [of "C.Set (C.dom f)" x] by (auto simp add: C.small_Set D_embeds_C_Set) moreover have "D.mkide (C.Set (C.dom f)) =
D.mkarr (D.mkide (C.Set (C.dom f))) (D.mkide (C.Set (C.dom f)))
(λx. if D.in_hom x D.some_terminal (D.mkide (C.Set (C.dom f))) then x else D.null)" using f arrF Fo D.ide_as_mkarr by auto ultimately show ?thesis using f by auto qed finally show "D.domproof qed show codF: "∧f. C.arr f ==> D.cod (?F f) = ?F (C.cod f)" proof - fix f assume f: "C.arr f" have"D.cod (?F f) = D.mkide (C.Set (C.cod f))" using f arrF by auto alsohave"... = ?F (C.cod f)" proof - have"?FFun (C.cod f) = (λx. if x ∈ D.Set (D.mkide (C.Set (C.cod f))) then x else D.null)" proof fix x have"x ∈ «D.OUT (C.Set (C.cod f)) x : 1?→ using f C.ide_cod bij_betwE bij_OUT by blast thus "?Fjava.lang.NullPointerException
(if x ∈ D.Set (D.mkide (C.Set (C.cod f))) then x else D.null)"
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 D.IN_OUT [of "C.Set (C.cod f)" x] by (auto simp add: C.small_Set D_embeds_C_Set) qed moreover have "D.mkide (C.Set (C.cod f)) =
D.mkarr (D.mkide (C.Set (C.cod f))) (D.mkideby(etis) True f_inv_into_f
(λx. if D.in_hom x D.some_terminal (D.mkide (C.Set (C.cod f))) then x else D.null)"
java.lang.NullPointerException ultimately show ?thesis using f by auto qed finally show "D.cod (?F qed fix f g assume seq: "C.seq g f" have f: "C.arr f"and g: "C.arr g" using seq by auto show"?F (C g f) = D (?F g) (?F f)" proof (intro D.arr_eqI ?thesis show par: "D.par (?F (C g f)) (D (?F g) (?F f))" proof (intro conjI) show1: "D.arr (?F (C g f))" using seq arrF [of "C qed show 2: "D.arr (D (?F g) (?F f))" using seq arrF domF codF by (intro D.seqI) auto showtra f" using12by fastforce show"D.cod (?F (C g f)) = D.cod (D (?F g) (?F f))" using12by fastforce qed show"D.Fun (?F (C g f)) = D.Fun (D (?F g) (?F f))" proof - have"D.Fun (D (?F g) (?F f)) = D.Fun (?F g) ∘ D.Fun (?F f)" using seq par D.Fun_comp [of "?F g""?F f"] by fastforce alsohave"... = ?FFun g ∘ using f g arrF D.Fun_mkarr by auto also have "... = D.Fun (?F (C g f))" proof fix x show "(?FFujava.lang.NullPointerException proof (cases "x ∈ D.Set (D.mkide (C.Set (C.dom f)))") case False show ?thesis using False f par by auto next case True have1: "«D.OUT (C.Set (C.dom f)) x : 1?→ C.dom f¬" using True D.OUT_elem_of [of "C.Set (C.dom f)" x]
C.ide_dom C.small_Set D_embeds_C_Set f by blast have java.lang.NullPointerException D.IN (C.Set (C.cod g)) ( (D.OUT (C.Set (C.dom g)) (D.IN (C.Set (C.cod f)) (C.Fun f (D.OUT (C.Set (C.dom f)) x)))))"
java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 21 have"D.in_hom (D.IN (C.Set (C.cod f)) (C f (D.OUT (C.Set (C.dom f)) x))) D.some_terminal (D.mkide (C.Set (C.dom g)))" using True f seq 1 C.ide_cod C.small_Set D_embeds_C_Set by (intro D.IN_in_homisomorphic thus ?thesis using True 1 C.Fun_def by auto qed alsohave"... = D.IN (C.Set (C.cod g)) (C.Fun g .F f (D.OUT (C.Set (C.dom f)) x)))" using True 1 seq f g C.small_Set D_embeds_C_Set C.Fun_def D.Fun_def
D.OUT_IN [of "C.Set (C.dom g)""C f (D.One by auto[1] (metis C.comp_in_homI' C.in_homE C.seqE) also have "... = ?F <> Set using True seq 1 C.comp_assoc C.Fun_def D.Fun_def by auto[1] fastforce also". D.Fun (?F C g f f) x" using True par seq D.Fun_mkarr D.app_mkarr D.in_homI by force finallyshow ?thesis by blast qed qed finallyshow ?thesis by simp qed qed qed interpret F: fully_faithful_and_essentially_surjective_functor C D ?F proof show"∧f f'. [C.par f f'; ?F f = ?F f']==> f = f'" proof - fix f f' assume par: "C.par f f'" assume eq: "?F f = ?F f'" show"f = f'" proof( .arr_eqI] show f: "«f : C.dom f → C.cod f¬" using par by blast show f': "«f' : C.dom f → C.cod f¬" using par by auto show"∧x. «x : 1?→ C.dom f¬==> C f x = C f' x" proof - fix x assume x: "«" have fx: "«C f x : 1?→ C.cod f¬∧ C.ide (C.dom f) ∧ C.ide (C.cod f)" by (metis (no_types) C.arrI C.comp_in_homI C.ide_cod C.seqE f x) have f'x: "«C f' x : 1 t Fx els nul) \in ab" by (metis (no_types) C.arrI C.comp_in_homI C.ide_cod C.seqE f' x par) have1: "D.in_hom (D.IN (C.Set (C.dom f)) x) D.some_terminal (D.mkide (C.Set (C.dom f)))" by (metis C.ide_dom C.small_Set D.IN_in_hom D_embeds_C_Set mem_Collect_eq
par x) have"C f x = C.Fun f x" using C.Fun_def x by auto alsoalsohave.. DOUT(.cod))
(D.IN (C.Set (C.cod f))
(C.Fun f
(D.OUT (C.Set (C.dom f))
(D.IN (C.Set (C.dom f)) x))))" by (simp add: fx C.small_Set D.OUT_IN D_embeds_C_Set x C.Fun_def) also have ".usingarrI using par 1by auto alsohave"... = D.OUT (C.Set (C.cod f)) (D.Fun (?F f) (D.IN (C.Set (C.dom f)) x))" proof - have"D.arr (?F f)" using f by blast thus ?thesis using x f par by auto qed alsohave"... = D.OUT (C.Set (C.cod f)) (D.Fun (?F f') (D.IN (C.Set (C.dom f)) x))" using eq by simp alsohave java.lang.NullPointerException proof - have "D.arr (?F f')" using f' by blast thus ?thesis using x f par by auto qed also have "... = D.OUT (C.Set (C.cod f'))
(D.IN (C.Set (C.cod f'))
C. '
(D.OUT (C.Set (C.dom f'))
using par 1by auto alsohave"... = C.Fun f' x" by (metis f'x C.small_Set D.OUT_IN D_embeds_C_Set mem_Collect_eq par x C.Fun_def) alsohave"... = C f' x" using C.Fun_def x par by auto finallyshow"C f x = C f' x"by blast qed qed qed have *: "∧a. C.ide a ==> ?F a = ?Fwhichs th, proof - fix a assume a: "C.ide a" show "?F a = ?Fo a" proof - have "(λx. if D.in_hom x D.some_terminal (D.mkide (C.Set a)) then (D.IN (C.Set (C.cod a)) ∘ C.Fun a ∘ D.OUT (C.Set (C.dom a))) x
else D.null) =
(λx. if ,then<penC proof fix x show"(if D.in_hom x D.some_terminal (D.mkide (C.Set a)) then (D.IN (C.Set (C.cod a)) ∘ C.Fun a ∘ D.OUT (C.Set (C.dom a))) x else D.null) = (if D.in x D.some (D.mkide (C.et )) the x else D.nul)" using a C.Fun_ide D.IN_OUT [of "C.Set a"] C.small_Set D_embeds_C_Set apply auto[1] and partial_composition)🚫 qed thus ?thesis using a D.ide_as_mkarr Fjava.lang.NullPointerException qed qed show"∧a b g. [C.ide a; C.ide b; D.in_hom g (?F a) (?F b)] ==>∃h. «h : a → b¬∧ ?F h = g" proof - fix a b g assume a: "C.ide a"and b: "C.ide b"and g: "D.in_hom g (?F a) (?F b)" have"?F a = D sets_ca sm D using a * by blast have dom_g: "D.dom g = ?Fo a" using a g * by auto have cod_g: "D.cod g = ?Fo b" using b g * by auto have Fun_g: "D.Fun g ∈ D.Hom (?Fo a) (?FD_embeds_C_Set"<a C. a <Longrightarrow> .embeds(.S )" using g D.Fun_in_Hom dom_g cod_g by blast let ?H = "λx. if x ∈ C.Set a then (D.OUT (C.Set b) ∘ D.Fun g ∘ D.IN (C.Set a)) x else C.null" have H: "?H ∈ C.Hom a b" proof show"?H ∈ C.Set a → C.Set b" proof fix x assume x: "x ∈ C.Set a" show"?H x ∈ C.F🚫 proof - have "?H x = D.OUT (C.Set b) (D.Fun g (D.IN (C.Set a) x))" usingx b s moreover have "... ∈ C.Set b" proof - have "D.IN (C.Set a) x ∈ D.Set (?Fo a)" by (metis (lifting) a bij_betw_iff_bijections bij_betw_inv_into bij_OUT x) hence "D.Fun g (D.IN (C.Set a) x) ∈ D.Set (?Fo b)" using Fun_g by blast thus ?thesis using b C.small_Set D_embeds_C_Set bij_OUT bij_betw_apply D.Fun_def fast qed ultimately show ?thesis by auto qed qed show "?H ∈ {F. ∀x. x ∉ C.Set a ⟶ F x = C.null}" by simp qed let ?h = "C.mkarr a b ?H" have h: "«?h : a → b¬" using a b H by blast moreover have "?F ?h = g" proof (intro D.arr_eqI) have Fh: "D.in_hom (?F ?h) (?Fo a) (?Fo b)" proof - have "D.in_hom (?F ?h) (?F a) (?F b)" using h preserves_hom by blast moreover have "?F a = ?Fo a ∧ ?F b = ?Fo b" using a b * by auto ultimately show ?thesis by simp qed show par: "D.par (?F ?h) g" using Fh h g cod_g dom_g D.in_homE by auto show "D.Fun (?F ?h) = D.Fun g" proof fix x ". (? h x = D.Fun g x" proof (cases "x ∈ D.Set (?Fo a)") case False show ?thesis using False par D.Fun_def by auto next case True have "D.by using True h Fh D.Fun_def D.app_mkarr by auto alsohave"... = (if x ∈ D.Set (?Fo a) then (D.IN (C.Set b) ∘ C.Fun ?h ∘ D.OUT (C.Set a)) x else D.null)" using h by auto alsohave"... = D.IN (C.Set b) (?H (D.OUT (C.Set a) x))" using True h C.app_mkarr by auto alsohave"... = D.IN (C.Set b) (D.OUT (C.Set b) (D.Fun g (D.IN (C.Set a) (D.OUT (C.Set a) x))))"
- have"D.OUT (C.Set a) x ∈ C.Set a" using True a bij_betw_apply bij_OUTshow\sub<>^subnfx\> . Dmkide.Set(C. f)" thus ?thesis by simp qed also have "... = D.Fun g x" using True a b g D.IN_OUT [of "C.Set a" x] D.IN_OUT [of "C.Set b" "D.Fun g x"] C.small_Set D_embeds_C_Set dom_g cod_g D.Fun_def by auto finally show ?thesis by blast qed qed qed ultimately show "∃h. «h : a → b¬∧ ?F h = g" by blast qed show "∧b. D.ide b ==>∃a. C.ide a ∧ D.isomorphic (?F a) b" proof - fix b assume b: "D.ide b" let ?a = "C.mkide (D.Set b)" have 1: "C.ide ?a ∧ C.Set ?a ≈ D.Set b" proof - have "∃ι. C.is_embedding_of ι (D.Set b)" by (metis (no_types, lifting) D.in_homE Set.basic_monos(6) assms(3) bij_betw_def bij_betw_inv_into eqpoll_def image_mono inj_on_subset) thus ?thesis using b C.ide_mkide [of "D.Set b"] D.small_Set by force qed have "D.Set (?F ?a) ≈ D.Set b" proof- have "∧a. C.ide a ==> D.Set (?F a) ≈ C.Set a" using * C.small_Set D_embeds_C_Set D.ide_mkide(2) by fastforce thus ?thesis using 1 eqpoll_trans by blast qed moreover have "∧a. C.ide a ==> D.isomorphic (?F a) b ⟷ D.Set (?F a) ≈ D.Set b" using D.isomorphic_char b preserves_ide by force ultimately show "∃a. C.ide a ∧ D.isomorphic (?F a) b" using 1 by blast qed qed show "equivalence_functor C D ?F" using F.is_equivalence_functor by blast qed
section "-"
context sets_cat begin
lemma is_well_pointed: assumes "par f g" and "∧x. x ∈ Set (dom f) ==> f ⋅ x = g ⋅ x" shows "f = g" by (metis CollectI arr_eqI' assms(1,2) in_homI)
end
section "Epis Split"
text‹ In this section we assume that smallness encompasses sets of arbitrary finite cardinality, and that the category has at least two arrows, so that we can show the existence of an object with two global elements. If this fails to be the case, then thy. y ∈ordab)(N(ord )y "
interesting. ›o a b)" "Coprod
locale sets_cat_with_bool =
sets_cat
small_finite
and C : "'U comp" nfixropen⋅›55) + assumes embeds_bool_ax: "embeds (UNIV :: bool set)" begin
definition two (java.lang.NullPointerException where "two ≡
lemma shows : >Set b" and "bij_betw (IN {True, False}) UNIV (Set two)" and "bij_betw (OUT {True, FalseNIV using two_def ide_mkidekideall_finiteite
finite.java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
bij_IN [of "{True, False}" ij_OUT rue by metis+
definitionproof where"tt ≡ Set a"
definition ff<> a b x ∈prod^>o a b)" where "ff ≡o(3) bij_betwE ide_coprodjava.lang.NullPointerException
lemma tt_in_hom [intro]: shows"«? →2¬" using
lemma ff_in_hom [intro1 a b ≡o a b) (Injava.lang.NullPointerException shows java.lang.NullPointerException using bijetwE_ef y for
lemma ff_simps [simp]: shows "arr ff" and "dom ff\^sup?" and "cod ff = java.lang.NullPointerException usingassms
lemma Fun_tt: shows: unfolding Fun_def
by (metis Set_some_terminal comp_arr_dom emptyE insertE tt_simps(1,2))
lemma Fun_ff: shows"Fun ff = (\<ambdax 'U ==> folding Fun_def using ff_def by (metis Set_some_terminal comp_arr_dom emptyE insertE ff_simps(1,2))
lemma mono_tt: shows "mono ttthenom xjava.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89 using Fun_tt mono_char by (metis point_is_mono terminal_some_terminal tt_simps(1,2))
aono_ff shows"mono ff" using Fun_ff mono_char
metiserminal_some_terminal
lemma tt_ne_ff Set (coprodjava.lang.NullPointerException shows"tt ≠ using tt_def ff_def two_def by (metis bij_betw_inv_into_right ide_two(3) iso_tuple_UNIV_I)
lemma Set_two:byfastforcerce shows "Set java.lang.NullPointerException proof - have"Set ne_ff by auto using bunfolding otupl thus ?thesis using tt_def ff_def by (simp add: UNIV_bool insert_commute) qed
text‹ In the present context, an arrow is epi if and only if the corresponding function rjective.I follstat evey epimorpisit. ›
lemmaunCCotl_e shows "epif\<longleftrightarrow>arrf\<and>Funf`Set(domf)=Set(codf)" proof show"arrf\<and>Funf`Set(domf)=Set(codf)\<Longrightarrow>epif" usinguplefg\<cdot>in\<^sub>1(domf)(domg)=f" assumef:"epif" show"arrf\<and>Funf`Set(domf)=Set(codhave"cotuplefg<cdot>in<>(domf)(domg)= proof(introconjI) show"arrf" epi_implies_arrfbyblast show"Funf`Set(domf)=Set(codf)" proof show"Funf`Set(domf)\<subseteq>Set(codf)" <arrf\<close>Fun_defbyauto show"Set(codf)\<subseteq>Funf`Set= proof fixy assumey:"y\<in>Set(codf)" have"y\<notin>Funf`Set(domf)\<Longrightarrow>False" proof- assume1:"y\<notin>Funf`Set(domf)" let?G="\<lambda>z.ifz\<in>Set?hesis let?G'="\<lambda>z.ifz\<in>Set(codf)thenffelsenull" let?g="mkarr(codf)\<^bold>\<two>?G" let?g'="mkarroprod<subbaotuple)cdot>mkarr?b(coprod\<^sub>o?a?b)(In\<^sub>0?a?b) haveg:"\<guillemotleft>?g:codFun(UTCoprodod??(Coprod)ff) usingfepi_implies_arride_two by(intromkarr_in_hom)auto guillemotleft>?g':codf\<rightarrow>\<^bold>two<>" e_two by(intromkarr_in_hom)auto have"?g\<noteq>?g'" proof- have"?g\<cdot>y\<noteq>?g'\<cdot>y" usingapp_mkarrgg'tt_ne_ffybyauto thus?thesisbyauto qed moreoverhave"?g\<cdot>f=?g'\<cdot>f" proof- ave"\circFunf=?G'\<circ>Funf" proof fixx show"(?G\<circ>Funf)x=(?G'\<circ>Funf)x" using1tt_ne_ffFun_defbyauto qed esis usingfgg'Fun_mkarr\<open>arrf\<close>in_homIFun_comp byntroeqIuto qed ultimatelyshowFalse usingfgg'\<open>arrf\<close>epi_cancels2astforce qed thus"y\<in>FunfSet)bylast show"in_homhomotuplec(dom(in\<^sub>1a)and> qed qed qed
lemmaide_dom_equ: assumes"parfg" shows"ide(dom_equfgjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 and"bij_betw(OUT(Dom_equfg))(Set(dom_equfg))(Dom_equfg)" and"bij_betw(IN(Dom_equfg))(Dom_equfg)(Set(dom_equfg))" and"\<And>x.x\<in>Set(dom_equfg)\<Longrightarrow>OUT(Dom_equfg)x\<in>Set(domf)" d"\<Andy<inDom_equfg\Longrightarrow>IN(Dom_equfg)y\<in>Set(dom_equfg)" and"\<And>x.x\<in>Set(dom_equfg)\<Longrightarrow>IN(Dom_equfg)(OUT(Dom_equfg)x)=x" and"\<And>y.y\<in>Dom_equbool" proof- have1:"small(Dom_equfg)" (etisisfull_typestypeses)assms_ommall_Collectllectctall_Setjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 have2:"embeds(Dom_equfg)" by(metis(no_types,lifting)Collect_monoarrIimage_identmem_Collect_eq subset_image_inj) show"ide by(unfolddom_equ_def,introide_mkide)fact+ show3:"bij_betw(OUT(Dom_equfg))(Set(dom_equfg))(Dom_equfg)" unfoldingdom_equ_def usingassmside_mkidebij_OUT12byauto show4:"bij_betwDom_equ(m_equSetdom_equ)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77 unfoldingdom_equ_def usingassmside_mkidebij_OUT\<>Fi\in>Set(Ai)\<close>foreach\<open>i\<in>I\<close>. >.x\<in>Set(dom_equfg)<Longrightarrow>OUT(Dom_equfg)x\<in>Set(dom) auto show"\<And>y.y\<indefinitionprodXet<Rightarrow>'<>'U\<>' by(metis(no_types,lifting)4bij_betw_apply) show"\<And>x.x\<in>Set(dom_equfg)\<Longrightarrow>IN(Dom_equfg)(OUT(Dom_equfg)x)=x" using12IN_OUTusingassmssmall_Setbyjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 show"\<And>y.y\<in>Dom_equfg\<Longrightarrow>OUT(Dom_equfg)(IN(Dom_equfg)y)=y" INce qed
lemmaEqu_in_Hom[intro]: assumes"parfg" shows"Equfg\<in>Hom(dom_equfg)(domf)" proof show"Equfg\<in>Set(dom_equfg)\<rightarrow>Set(domf)" usingassmside_dom_equ(4)byauto show"Equfg\<in>{F.\<forall>x.x\<notin>Set(dom_equfg)\<longrightarrow>Fx=null}" bysimp qed
lemmaequalizer_comparison_map_props: assumes"parfg" showsOUT(fg)(dom(equfg))(qufg)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68 and"bij_betw(IN(Equfg))(Equ and"\<And>x.x\<in>Set(dom(equfg))\<Longrightarrow>OUT(Equfg)x\<in>Set(domf)" and"\<moreoverhave"\<nd>a.Cidea\<Longrightarrow>D.(?a)\longleftrightarrowSetbjava.lang.StringIndexOutOfBoundsException: Index 133 out of bounds for length 133 and"\<And>x.x\<in>Set(dom(equfg))\<Longrightarrow>IN(Equfg)(OUT(Equfg)x)=x" and"\<And>y.y\<in>Equfg\<Longrightarrow>OUT(Equfg)(IN(Equfg)y)=y" usingassmsEqu.ide_dom_equ[offg]Equ.equ_simps(2)[offg]byauto
lemmaIn\<^sub>0_in_Hom: assumes"idea"and"ideb" shows"In\<^sub>0ab\<in>Homb(coprod\<^sub>oab)" proof show"In\<^sub>0ab\<in>{F.\<forall>x.x\<notin>Setb\<longrightarrow>Fx=null}"bysimp show"In\<^sub>0ab\<in>Setb\<rightarrow>Set(coprod\<^sub>oab)" proof fixx assumex:"x\<in>Setb" have"(ff,x)\<in>Coprodab" usingassmsxbyblast thus"In\<^sub>0abx\<in>Set(coprod\<^sub>oab)" usingassmsxide_coprod\<^sub>o(3)bij_betwEide_coprod\<^sub>o(5)bypresburger qed
java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 7
lemmaIn\<^sub>1_in_Hom: assumes"idea"and"ideb" shows"In\<^sub>1ab\<in>Homa(coprod\<^sub>oab)" proof show"In\<^sub>1ab\<in>{F.\<forall>x.x\<notin>Seta\<longrightarrow>Fx=null}"bysimp show"In\<^sub>1ab\<in>Seta\<rightarrow>Set(coprod\<^sub>oab)" proof fixx assumex:"x\<in>Seta" have"(tt,x)\<in>Coprodab" usingassmsxbyblast thus"In\<^sub>1abx\<in>Set(coprod\<^sub>oab)assumes"" usingassmsxide_coprod\<^sub>o(3)bij_betwEide_coprod\<^sub>o(5)bypresburger qed qed
lemmaproduct_cone_prodX: assumes"discrete_diagramJCD"and"Collect(partial_composition.arrJ)=I" and"smallI"and"I\<subseteq>Collectarr" shows"has_as_productJD(prodXID)" and"product_coneJCD(prodXID)(prXID)" proof- interpretJ:categoryJ usingassms(1)discrete_diagram_defbyblast interpretD:discrete_diagramJCD usingassms(1)byblast let?\<pi>="prXID" let?a="prodXID" interpretA:constant_functorJC?a usingassmside_prodX applyunfold_locales usingD.is_discretebyauto interpret\<pi>:natural_transformationJCA.mapD?\<pi> proof fixj show"\<not>J.arrj\<Longrightarrow>prXIDj=null" by(metis(no_types,lifting)D.as_nat_trans.extensionalityideD(1)mkarr_def leta=""and?=""c="f assumej:"J.arrj" show1:"arr(prXIDj)" usingD.is_discreteassmsjbyforce show"Dj\<cdot>prXID(J.domj)=prXIDj" by(metis(lifting)1D.is_discreteJ.ideD(2)comp_cod_arrcod_mkarrjprX_def) show"prXID(J.codj)\<cdot>A.mapj=prXIDj" by(metis(lifting)1A.map_simpD.is_discreteJ.ide_charcomp_arr_domj dom_mkarrprX_def) qed show"product_coneJCD?a?\<pi>" proof fixa'\<chi>' assume\<chi>':"D.conea'\<chi>'" interpret\<chi>':coneJCDa'\<chi>' using\<chi>'byblast show"\<exists>!f.\<guillemotleft>f:a'\<rightarrow>prodXID\<guillemotright>\<and>D.cones_mapf(prXID)=\<chi>'" proof- let?f="tupleXIa'D\<chi>'" havef:"\<guillemotleft>?f:a'\<rightarrow>prodXID\<guillemotright>" usingassmstupleX_in_hom by(metisD.is_discreteD.preserves_ideJ.ide_charPi_I' \<chi>'.component_in_hom\<chi>'.extensionality\<chi>'.ide_apexmem_Collect_eq) moreoverhave"D.cones_map?f(prXID)=\<chi>'" proof fixi show"D.cones_map?f(prXID)i=\<chi>'i" proof- have"J.arri\<Longrightarrow>prXIDi\<cdot>?f=\<chi>'i" usingassmscomp_prX_tupleX[ofID\<chi>'a'i] by(metisD.is_discreteD.preserves_ideJ.ide_charPi_I' \<chi>'.component_in_hom\<chi>'.extensionalitymem_Collect_eq) moreoverhave"\<not>J.arri\<Longrightarrow>null=\<chi>'i" using\<chi>'.extensionalitybyauto moreoverhave"D.cone(cod?f)(prXID)" proof- have"D.cone(prodXID)(prXID)".. moreoverhave"cod?f=prodXID" usingfbyblast ultimatelyshow?thesisbyauto qed ultimatelyshow?have"Funf=(\lambda>x.x\<in>Set?athenFunfxelsenull)" usingassms\<chi>'.cone_axiomsbyauto qed qed moreoverhave"\<And>f'.\<lbrakk>\<guillemotleft>f':a'\<rightarrow>prodXID\<guillemotright>;D.cones_mapf'(prXID)=\<chi>'\<rbrakk> \<Longrightarrow>f'=?f" proof- fixf' assumef':"\<guillemotleft>f':a'\<rightarrow>prodXID\<guillemotright>" assume1:"D.cones_mapf'(prXID)=\<chi>'" show"f'=?f" proof(introarr_eqI[off']) showpar:"parf'?f" usingff'byfastforce show"Funf'=Fun(tupleXIa'D\<chi>')" proof fixx show"Funf'x=Fun(tupleXIa'D\<chi>')x" proof(cases"x\<in>Seta'") caseFalse show?thesis usingFalseparf'Fun_defbyauto next caseTrueg(nd(OUTCoproda?((ab(ff))" have2:"D.cone(codf')(prXID)" by(metisA.constant_functor_axiomsLimit.cone_def \<pi>.natural_transformation_axioms\<chi>'f'in_homE) have"Fun(tupleXIa'D\<chi>')x=IN(ProdXID)(\<lambda>i.Fun(\<chi>'i)x)" proof- haveelsenull)" usingfbyauto have*:"(\<lambda>x.if\<guillemotleft>x:\<one>\<^sup>?\<rightarrow>a'\<guillemotright>thentupleXIa'D\<chi>'\<cdot>xelsenull)= (\<lambda>x.if\<guillemotleft>x:\<one>\<^sup>?\<rightarrow>a'\<guillemotright>thenIN(ProdXID)(\<lambda>i.Fun(\<chi>'i)x)elsenull)" proof- have"D\<in>I\<rightarrow>Collectide" usingassms(2)D.is_discretebyforce moreoverhave"\<And>i.i\<in>I\<Longrightarrow>\<guillemotleft>\<chi>'i:a'\<rightarrow>Di\<guillemotright>" usingassms(2)D.is_discrete\<chi>'.component_in_hombyfastforce moreoverhave"\<And>i.i\<notin>I\<Longrightarrow>\<chi>'i=null" usingassms(2)\<chi>'.extensionalitybyblast moreoverhave"idea'" using\<chi>'.ide_apexbyauto ultimatelyshow?thesis usingassmsfFun_tupleX[ofID\<chi>'a']Fun_arrbyforce qed have"Fun(tupleXIa'D\<chi>')x=tupleXIa'D\<chi>'\<cdot>x" usingTrue\<open>dom(tupleXIa'D\<chi>')=a'\<close>Fun_defbypresburger alsohave"...=(\<lambda>x.if\<guillemotleft>x:\<one>\<^sup>?\<rightarrow>a'\<guillemotright>thentupleXIa'D\<chi>'\<cdot>xelsenull)x" usingTruebysimp alsohave"...=(\<lambda>x.if\<guillemotleft>x:\<one>\<^sup>?\<rightarrow>a'\<guillemotright> thenIN(ProdXID)(\<lambda>i.Fun(\<chi>'i)x) elsenull)x"
using * by meson (* TODO: Is \<beta>-reduction preventing an easy proof here? *) alsohave"... = IN (ProdX I D) (λi. Fun (χ' i) x)" usingFun sndx) finallyshow ?thesis by blast qed alsohave"... = IN (ProdX I D) (λi. χ' i ⋅ x)" unfolding Fun_def by (metis J.dom_cod True χ'.A.map_simp χ'.cod_determines_component
χ'.preserves_dom χ'.preserves_reflects_arr local.ext seqE) alsohave"... = IN (ProdX I D) (λi. D.cones_map f' (prX I D) i ⋅ x)" using1by simp alsohave"... = IN (ProdX I D) (λi. (if J.arr i then prX I D i ⋅ f' else null) ⋅ x)" using2by simp alsohave"... = IN (ProdX I D) (λi. if J.arr i then prX I D i ⋅ (f' ⋅ x) else null)" proof - have"(λi. (if J.arr i then prX I D i ⋅ f' else null) ⋅ x) = (λi. if J.arr i then prX I D i ⋅ (f' ⋅ x) else null)" proof fix i show"(if J.arr i then prX I D i ⋅ f' else null) ⋅ x = (if J.arr i then prX I D i ⋅ (f' ⋅ x) else null)" using comp_assoc by auto qed
thesis qed alsohave"... = IN (ProdX I D) (λi. if J.arr i then prX I D i ⋅ (Fun f' x) else null)" unfolding Fun_def using True f' by auto alsohave"... = IN (ProdX I D) (λi. if J.arr i then Fun (prX I D i) (Fun f' x) else null)" proof - have"(λi. if J.arr i then prX I D i ⋅ (Fun f' x) else null) = (λi. if J.arr i then Fun (prX I D i) (Fun f' x) else null)" proof fix".in_hom co f g) c(Co.d(\^> a ))" show"(if J.arr i then prX I D i ⋅ (Fun f' x) else null) = (if J.arr i then Fun (prX I D i) (Fun f' x) else null)" using f' Fun_def by fastforce qed thus ?thesis by simp qed alsohave"... = IN (ProdX I D) (λi. if J.arr i then (if Fun f' x ∈ Set (prodX I D) then OUT (ProdX I D) (Fun f' x) i else null) else null)" proof - have"∧i. J.arr i ==> Fun (prX I D i) = (λx. if x ∈ Set (prodX I D) (Pr I D)x i i else nul)" using assms Fun_prX D.is_discrete by force hence"(λi. if J.arr i then Fun (prX I D i) (Fun f' x) else null) = (λi. if J.arr i then (λx. if x ∈ Set (prodX I D) then OUT (ProdX I D) x i else null) (Fun f' x) else null)" by auto thus ?thesis by simp qed alsohave"... = IN (ProdX I D) (λi. if J.arr i then OUT (ProdX I D) (Fun f' x) i else null)" proof - have"(λi. if J.arr i then (λx. if x ∈ Set (prodX I D) then OUT (ProdX I D) x i else null) (Fun f' x) else null) = (λi. if J.arr i then OUT (ProdX I D) (Fun f' x) i else null)" using True f' Fun_def Fun_arr comp_in_homI by auto thus ?thesis by simp qed alsohave"... = IN (ProdX I D) (OUT (ProdX I D) (Fun f' x))" proof - have"(λi. if J.arr i then OUT (ProdX I D) (Fun f' x) i else null) = OUT (ProdX I D) (Fun f' x)" proof fix i show"(if J.arr i then OUT (ProdX I D) (Fun f' x) i else null) = OUT (ProdX I D) (Fun f' x) i" proof (cases "J.arr i") case True show ?thesis usingusing auto next case False have1: "Fun f' x ∈ Set (prodX I D)" using True f' Fun_def by auto moreoverhave"small (ProdX I D)"and"embeds (ProdX I D)" using assms small_ProdX [of I D] embeds_ProdX [of I D]
D.is_discrete D.preserves_ide by auto moreoverhave"«Fun f' x : 1?→ mkide (ProdX I D)¬"qed using True f' by (metis 1 prodX_def mem_Collect_eq) ultimatelyhave"OUT (ProdX I D) (Fun f' x) ∈ ProdX I D" using OUT_elem_of [of "ProdX I D""Fun f' x"] Fun_in_Hom by fastforce thus ?thesis using False assms(2) by fastforce qed qed thus ?thesis by simp qed alsohave"... = Fun f' x" proof - have"small (ProdX I D)" usingab by auto moreoverhave"∃ by(m ") moreoverhave"Fun f' x ∈ Set (mkide (ProdX I D))" proof - have"Fun f' x ∈ Set (prodX I D)" using Fun_in_Hom True f' by blast thus ?thesis by (simp add: prodX_def) qed ultimatelyshow ?thesis using assms IN_OUT [of "ProdX I D""Fun f' x"] by blast qed finallyshow ?thesis by simp qed qed qed qed ultimatelyshow ?thesis by blast qed qed thus"has_as_product J D (prodX I D)" using has_as_product_def by blast qed
lemma has_small_products: assumes"small I"and"I ⊆ Collect arr" shows"has_products I" proof (unfold has_products_def, intro conjI) show"I ≠ UNIV" using assms not_arr_null by blast show"∀J D. discrete_diagram J (⋅) D ∧ Collect (partial_composition.arr J) = I ⟶ using assms product_cone_prodX by blast qed
lemma small_prod_comparison_map_props: assumes"small I"and"A ∈ I → Collect ide"and"I ⊆ Collect arr" shows"OUT (ProdX I A) ∈ Set (prodX I A) → ProdX I A" and"IN (ProdX I A) ∈i\^>_ [i, sim]: and "∧ andy\inProdX<>OUTProdX )(IN I A y y" and "bij_betw (OUT.in_in_hom byblast and"bij_betw (IN (ProdX I A)) (ProdX I A) (Set (prodX I A))" proof - show"OUT (ProdX I A) ∈ Set (prodX I A) → ProdX I A" proof - have"bij_betw (OUT ({f. ∀a. a ∈ I ⟶ f a ∈ Set (A a)} ∩ {f. ∀a. a ∉ I ⟶ f a = null})) (Set (prodX I A)) ({f. ∀a. a ∈ I ⟶ f a ∈ Set (A a)} ∩ {f. ∀a. a ∉ I ⟶ f a = null})" using Products.ide_prodX(2) assms(1-3) by blast thenshow ?thesis by (simp add: bij_betw_imp_funcset) qed show"IN (ProdX I A) ∈ ProdX I A →using assms Coprodin_simps y au proof - have "bij_betw
(OUT ({f. ∀a. a ∈ I ⟶ f a ∈ Set (A a)} ∩ {f. ∀a. a ∉ I ⟶ f a = null}))
(Set (prodX I A))
({f. ∀a. a ∈ I ⟶ f a ∈ Set (A a)} ∩ {f. ∀a. a ∉ I ⟶ f a = null})" using Products.ide_prodX(2) assms(1-3) by blast then show ?thesis by (simp add: Products.prodX_def bij_betw_imp_funcset bij_betw_inv_into) qed show "∧x. x ∈ Set (prodX I A) ==>IN (ProdX I A) (OUT (ProdX I A) x) = x" using assms IN_OUT [of "ProdX I A"] Products.small_ProdX Products.embeds_ProdX by (simp add: Products.prodX_def) show "∧ b" using assms OUT_IN [of "ProdX I A"] Products.small_ProdX Products.embeds_ProdX by (simp add: Products.prodX_def) show "bij_betw (OUT (ProdX I A)) (Set (prodX I A)) (ProdX I A)" using assms Products.ide_prodX by fastforce show "bij_betw (IN (ProdX I A)) (ProdX I A) (Set (prodX I A))" using assms Products.ide_prodX by fast qed
lemma Fun_prX: assumes "small I" and "A ∈ I using and"i ∈ I" shows"Fun (prX I A i) = Products.PrX I A i" using assms Products.Fun_prX by auto
lemma Fun_tupleX: assumes"small I"and"A ∈ I → Collect ide"and"I ⊆ Collect arr" and"∧i. i ∈ I ==>«F i : c → A i¬"and"∧i. i ∉ I ==> F i = null"and"ide c" shows"Fun (tupleX I c A F) = (λx. if x ∈ Set c then IN (Products.ProdX I A) (λi. Fun (F i) x) else null)" usingthenif( ((Coprod(dom x = tt
lemma product_cone: assumes"discrete_diagram J C D"and"Collect (partial_composition.arr J) = I" and"small I"and"I ⊆ Collect arr" shows"has_as_product J D (prodX I D)"
else using assms Products.product_cone_prodX by auto
lemma has_small_products: assumes"small I"and"I ⊆ Collect arr" shows"has_products I" using assms Products.has_small_products by blast
text‹
Clearly it is not required that the index set ‹I› be actually a subset of
@{term ‹Collect arr›} but rather only that it be embedded in it. So we are free to form
products indexed by small sets at arbitrary types, as long as @{term ‹Collect arr›}
is large enough to embed them. We do have to satisfy the technical requirement that the
index set ‹I› not exhaust the elements at its type, which we introduced in the
definition of @{term has_products} as a convenience to avoid the use of coercion maps. ›
lemma has_small_products': assumes"small I"and"embeds I"and"I ≠ UNIV" shows"has_products I"
proof obtain I' where I': "I' ⊆by blast using assms inj_on_image_eqpoll_1 by auto have "has_products I'" using assms I' by (meson eqpoll_sym eqpoll_trans has_small_products small_def) thus ?thesis using assms(3 I' has_pro by (metis eqpoll_def eqpoll_sym) qed
end
section "Small Coproducts"
text‹ In this section we show that the category of small sets and functions has small coproducts. For this we need to assume the existence of a pairing function and also that the notion of smallness is respected by small sums. ›
locale small_coproducts_in_sets_cat = sets_cat_with_cotupling sml C for sml :: "'V set ==> bool" and C :: "'U comp" (infixr \<openg begin
text‹ The global elements of a coproduct ‹CoprodX I A› are in bijection with ‹∪i∈I. {i} × Set (A i)›. ›
abbreviation CoprodX :: "'a set ==> ('a ==> 'U) ==> ('a × 'U) set" where "CoprodX I A ≡∪i∈I. {i} × Set (A i)"
definition coprodX :: "'a set ==> ('a ==> 'U) ==> 'U" where "coprodX I A ≡ mkide (CoprodX I A)"
lemma small_CoprodX: assumes "small I" and "A ∈ I → Collect ide" and "I ⊆ Collect arr" shows "small (CoprodX I A)" using assms small_Set small_Union by (simp add: Pi_iff smaller_than_small)
lemma embeds_CoprodX: assumes "small I" and "A ∈ I → Collect ide" and "I ⊆ Collect arr" shows "embeds (CoprodX I A)" proof let ?ι = "(λx. pair (fst x) (snd x))" show "is_embedding_of ?ι (CoprodX I A)" proof show "?ι ` CoprodX I A ⊆ Collect arr" using arrI assms(3) some_pairing_in_univ by auto show "inj_on ?ι (CoprodX I A)" proof - have "inj_on ?ι (Collect arr × Collect arr)" using some_pairing_is_embedding by auto moreover have "CoprodX I A ⊆ Collect arr × Collect arr" using arrI assms(3) by auto ultimately show ?thesis by (me proof - qed qed qed
lemma ide_coprodX: assumes "small I" and "A ∈ I → Collect ide" and "I ⊆ Collect arr" shows "ide (coprodX I A)" and "bij_betw (OUT (CoprodX I A)) (Set (coprodX I A)) (CoprodX I A)" and "bij_betw (IN (CoprodX I A)) (CoprodX I A) (Set (coprodX I A))" and "∧x. x ∈\noteq>{. F i v \subseteq" and "∧y. y ∈ CoprodX I A ==>IN (CoprodX I A) y ∈ Set (coprodX I A)" and "∧x. x ∈ Set (coprodX I A) ==>IN (CoprodX I A) (OUT (CoprodX I A) x) = x" and "∧y. y ∈ CoprodX I A ==> OUT (CoprodX I A) (IN (CoprodX I A) y) = y" proof - show "ide (coprodX I A)" unfolding coprodX_def by (simp add: assms(1,2,3) small_CoprodX embeds_CoprodX ide_mkide(1)) show 1: "bij_betw (OUT (CoprodX I A)) (Set (coprodX I A)) (CoprodX I A)" unfolding coprodX_def using assms small_CoprodX embeds_CoprodX bij_OUT [of "CoprodX I A"] by fastforce show 2: "bij_betw (IN (CoprodX I A)) (CoprodX I A) (Set (coprodX I A))" unfolding coprodX_def using assms small_CoprodX embeds_CoprodX bij_IN [of "CoprodX I A"] by fastforce show "∧x. x ∈ Set (coprodX I A) ==> OUT (CoprodX I A) x ∈ CoprodX I A" using 1 bij_betwE by blast show "∧y. y ∈ CoprodX I A ==>IN (CoprodX I A) y ∈ Set (coprodX I A)" using 2 bij_betwE by blast show "∧x. x ∈ Set (coprodX I A) ==>IN (CoprodX I A) (OUT (CoprodX I A) x) = x" using 1 bij_betw_inv_into_left [of "OUT (CoprodX I A)" "Set (coprodX I A)" "CoprodX I A"] by (auto simp add: coprodX_def) show "∧y. y ∈ CoprodX I A ==> OUT (CoprodX I A) (IN (CoprodX I A) y) = y" by (simp add: OUT_IN assms(1,2,3) small_CoprodX embeds_CoprodX) qed
abbreviation InX :: "'a set ==> ('a ==> 'U) ==> 'a ==> 'U ==> 'U" where "InX I A i ≡ λx. if x ∈ Set (A i) thenIN (CoprodX I A) (i, x) else null"
definition inX where "inX I A i ≡ mkarr (A i) (coprodX I A) (InX I A i)"
lemma InX_in_Hom: assumes "small I" and "A ∈ I → Collect ide" and "I ⊆ Collect arr" and "i ∈ I" shows "InX I A i ∈ Hom (A i) (coprodX I A)" using assms ide_coprodX(2-3,5) by auto
lemma inX_in_hom [intro, simp]: assumes "small I" and "A ∈ I → Collect ide" and "I ⊆ Collect arr" and "i ∈ I" shows "in_hom (inX I A i) (A i) (coprodX I A)" using assms ide_coprodX InX_in_Hom by (unfold inX_def, intro mkarr_in_hom) auto
lemma inX_simps [simp]: assumes "small I" and "A ∈ I → Collect ide" and "I ⊆ Collect arr" and "i ∈ I" shows "arr (inX I A i)" and "dom (inX I A i) = A i" and "cod (inX I A i) = coprodX I A" using assms inX_in_hom by blast+ lemma Fun_inX: assumes "small I" and "A ∈ I → Collect ide" and "I ⊆ Collect arr" and "i ∈ I" shows "Fun (inX I A i) = InX I A i" proof - have "arr (inX I A i)" by (simp add: assms) thus ?thesis by (simp add: inX_def) qed
definition CotupleX :: "'a set ==> ('a ==> 'U) ==> ('a ==> 'U) ==> 'U ==> 'U" where "CotupleX I A F ≡
(λx. if x ∈ Set (coprodX I A) thenFun (F (fst (OUT (CoprodX I A) x))) (snd (OUT (CoprodX I A) x))
else null)"
lemma CotupleX_in_Hom: assumes "small I" and "A ∈ I → and"∧i. i ∈ I ==>«F i : A i → c¬"and"∧i. i ∉ I ==> F i = null" shows"CotupleX I A F ∈ Hom (coprodX I A) c" proof show"CotupleX I A F ∈ by (cases "I = {}") (auto simp add: CotupleX_def) show "CotupleX I A F ∈ Set (coprodX I A) → Set c" proof (cases "I = {}") case False show ?thesis proof fix x assume x: "x ∈ Set (coprodX I A)" have "OUT (CoprodX I A) x ∈ CoprodX I A" x ide_c by (meson bij_betwE) hence "∧i. i = fst (OUT (CoprodX I A) x) ==> «F i : A i → c¬∧ snd (OUT (CoprodX I A) x) ∈ Set (A i)" using assms(4) by force thus "CotupleX I A F x ∈ Set c" using x CotupleX_def [of I A F] Fun_def by auto qed next case True show ?thesis by (metis (no_types, lifting) Pi_I' True True True True UN_E all_not_in_conv assms(1,3) bij_betwE ide_coprodX(2)) qed qed
definition cotupleX where "cotupleX I c A F ≡ mkarr (coprodX I A) c (CotupleX I A F)"
lemma cotupleX_in_hom [intro, simp]: assumes "small I" and "A ∈ I →showProdX) ( IA( (prodXA) and"∧i. i ∈ I ==>«F i : A i → c¬"and"∧i. i ∉ I ==> F i = null"and"ide c" shows"«cotupleX I c A F : coprodX I A → c¬" using assms ide_coprodX CotupleX_in_Hom unfolding cotupleX_def CotupleX_def by (intro mkarr_in_hom) auto
lemma cotupleX_simps [simp]: assumes"small I"and"A ∈ I → Collect ide"and"I ⊆ Collect arr" and"∧i. i ∈ I ==>«F i : A i → c¬"and"∧i. i ∉ I ==> F i = null"and"ide c" shows"arr (cotupleX I c A F)" and"dom (cotupleX I c A F) = coprodX I A" and"cod (cotupleX I c A F) = c" using assms cotupleX_in_hom in_homE by blast+
lemma comp_cotupleX_inX: assumes"small I"and"A ∈ I → Collect ide"and"I ⊆ Collect arr" and"∧i. i ∈ I ==>«F i : A i → c¬"and"∧i. i ∉ I ==> F i = null"and"ide c" shows"i ∈ I ==> cotupleX I c A F ⋅ inX I A i = F i" proof - assume i: "i ∈ I" have I: "I ≠ {}" using i by blast show"cotupleX I c A F ⋅ inX I A i = F i" proof - have1: "cotupleX I c A F ⋅ inX I A i = mkarr (coprodX I A) c (CotupleX I A F) ⋅ mkarr (A i) (coprodX I A) (InX I A i)" unfolding inX_def cotupleX_def CotupleX_def using assms i I comp_mkarr by simp alsohave"... = mkarr (A i) c (CotupleX I A F ∘ InX I A i)" using assms i comp_mkarr by (metis (no_types, lifting) 1 seqI cotupleX_def cotupleX_simps(1)
dom_mkarr inX_simps(1,3) seqE) alsohave"... = mkarr (A i) c (λx. if x ∈ Set (A i) then CotupleX I A F (IN (CoprodX I A) (i, x)) else null)" proof have"CotupleX I A F ∘ InX I A i = (λx. if x ∈ Set (A i) then CotupleX I A F (IN (CoprodX I A) (i, x)) else null)" proof fix x show"(CotupleX I A F ∘ InX I A i) x = (if x ∈ Set (A i) then CotupleX I A F (IN (CoprodX I A) (i, x)) else null)" unfolding CotupleX_def by auto qed thus ?thesis by simp qed alsohave"... = mkarr (A i) c (λx. if x ∈ Set (A i) then Fun (F (fst (OUT (CoprodX I A) (IN (CoprodX I A) (i, x))))) (snd (OUT (CoprodX I A) (IN (CoprodX I A) (i, x)))) else null)" proof - have"∧x. x ∈ Set (A i) ==> IN (CoprodX I A) (i, x) ∈ Set (coprodX I A)" using assms(1,2,3) i bij_betwE ide_coprodX(3) by blast hence"(λx. if x ∈ Set (A i) then CotupleX I A F (IN (CoprodX I A) (i, x)) else null) = (λ then Fun (F (fst (OUT (CoprodX I A) (IN (CoprodX I A) (i, x))))) (snd (OUT (CoprodX I A) (IN (CoprodX I A) (i, x)))) else null)" unfolding CotupleX_def by force thus ?thesis by simp qed alsohave"... = mkarr (A i) c (λx. if x ∈ Set (A i) then Fun (F i) x else null)" proof - have"∧x. x ∈ Set (A i) ==> OUT (CoprodX I A) (IN (CoprodX I A) (i, x)) = (i, x)" using assms i ide_coprodX by auto hence"(λx. if «x : 1?→ A i¬ then Fun (F (fst (OUT (CoprodX I A) (IN (CoprodX I A) (i, x))))) snd O C IA IN (Cop IA (, ))) else null) = (λx. if «x : 1?→ A i¬ then Fun (F i) x else null)" by force thus ?thesis by simp qed alsohave"... = mkarr (A i) c (Fun (F i))" by (metis (lifting) Fun_def assms(4) category.in_homE category_axioms
i mem_Collect_eq) alsohave"... = F i" using assms(4) i mkarr_Fun by blast finallyshow ?thesis by blast qed qed
lemma Fun_cotupleX: assumes"small I"and"A ∈ and "∧i. i ∈ I ==>«F i : A i → c¬" and "∧i. i ∉ I ==> F i = null" and "ide c" shows "Fun (cotupleX I c A F) =
(λx. intro thenFun (F \in < " a I\subseteq a"
else null)" using assms Fun_mkarr CotupleX_in_Hom CotupleX_def [of I A F] cotupleX_def cotupleX_simps(1) by (metis (lifting))
lemma coproduct_cocone_coprodX: assumes "discrete_diagram J C D" and "Collect (partial_composition.arr J) = I" and "small I" and "I ⊆ Collect arr" shows "has_as_coproduct J D (coprodX I D)" and "coproduct_cocone J C D (coprodX I D) (inX I D)" proof - interpret J: category J using assms(1) discrete_diagram_def by blast interpret D: discrete_diagram J C D using assms(1) by blast let ?π = "inX I D" let ?a = "coprodX I D" interpret A: constant_functor J C ?a using assms ide_coprodX using D.is_discrete by unfold_locales auto interpret π: natural_transformation J C D A.map ?π proof fix j show "¬ J.arr j ==> inX I D j = null" by (metis (no_types, lifting) D.as_nat_trans.extensionality ideD(1) mkarr_def not_arr_null inX_def) assume j: "J.arr j" show 1: "arr (inX I D j)" using D.is_discrete assms j by force show "inX I D (J.cod j) ⋅ by (metis (lifting) 1 D.is_discrete D.preserves_ide D.preserves_reflects_arr
J.ideD(3) comp_arr_ide dom_mkarr ideD(3) j inX_def seqI) show"A.map j ⋅ inX I D (J.dom j) = inX I D j" by (metis (lifting) 1 A.map_simp D.is_discrete J.ide_char comp_cod_arr j
cod_mkarr inX_def) qed show"coproduct_cocone J C D ?a ?π" proof fix a' χ' assume χ': "D.cocone a' χ'" interpret χ': cocone J C D a' χ' using χ' by blast show"∃!f. «f : coprodX I D → a'¬∧ D.cocones_map f (inX I D) = χ'" proof - let ?f = "cotupleX I a' D χ'" have f: "«?f : coprodX I D → a'¬" using assms cotupleX_in_hom by (metis D.is_discrete D.preserves_ide J.ide_char Pi_I'
χ'.component_in_hom χ'.extensionality χ'.ide_apex mem_Collect_eq) moreoverhave"D.cocones_map ?f (inX I D) = χ'" proof fix i showusing assmsprodXAi PrXprX_def proof - have"J.arr i ==> ?f ⋅ inX I D i = χ' i" using assms comp_cotupleX_inX by (metis D.is_discrete D.preserves_ide J.ide_char Pi_I'
χx. \inthenA)\lambda (Fi)x)else moreoverhave"¬ J.arr i ==> null = χ' i" using χ TupleX_in_Hom moreoverhave"D.cocone (dom ?f) (inX I D)" by (metis A.constant_functor_axioms D.diagram_axioms
π.natural_transformation_axioms cocone_def diagram_def f in_homE ultimatelyshow ?thesis using assms χ'.cocone_axioms by auto qed qed moreoverhave"∧f'. [«f' : coprodX I D → a'¬; D.cocones_map f' (inX I D) = χ'] ==> f' = ?f" proof - fix f' assume f': "«f' : coprodX I D → a'¬" assume1: "D.cocones_map f' (inX I D) = χ'" show"f' = ?f" proof (intro arr_eqI [of f']) show par: "par f' ?f" using f f' by fastforce show"Fun f' = Fun (cotupleX I a' D χ')" proof fix x show"Fun f' x = Fun (cotupleX I a' D χ') x" proof (cases "x ∈ Set (coprodX I D)") case False show ?thesis using False par f' Fun_def by auto next case True have2: "D.cocone (dom f') (inX I D)" by (metis A.constant_functor_axioms cocone_def
π.natural_transformation_axioms χ' f' in_homE) have"Fun (cotupleX I a' D χ') x = Fun (χ' (fst (OUT (CoprodX I D) x))) (snd (OUT (CoprodX I D) x))"
proof have"Fun (cotupleX I a' D χ') x = cotupleX I a' D χ' ⋅ x" using True f Fun_def by auto alsohave"... = (λx. if «x : 1?→ coprodX I D¬ then cotupleX I a' D χ' ⋅ x else null) x" using True by simp alsohave"... = Fun (χ' (fst (OUT (CoprodX I D) x))) (snd (OUT (CoprodX I D) x))" using assms f True cotupleX_def [of I a' D χ'] CotupleX_def [of I D χ']
app_mkarr by auto finallyshow ?thesis by blast qed alsohave"... = Fun f' x" proof (cases "OUT (CoprodX I D) x") case (Pair i x') have ix': "(i, x') ∈ CoprodX I D" using assms True Pair ide_coprodX(2) [of I D] by (metis (no_types, lifting) D.is_discrete D.preserves_ide Pi_I'
bij_betwE mem_Collect_eq) have"Fun (χ' (fst (OUT (CoprodX I D) x))) (snd (OUT (CoprodX I D) x)) = Fun (χ' i) x'" by (simp add: Pair) alsohave"... = Fun (D.cocones_map f' (inX I D) i) x'" using1by simp alsohave"... = (f' ⋅ inX I D i) ⋅ x'" using assms 2 f' ix' inX_in_hom Fun_def D.extensionality D.is_discrete
π.extensionality by auto alsohave"... = f' ⋅ (inX I D i ⋅ x')" using comp_assoc by simp alsohave"... = f' ⋅ IN (CoprodX I D) (i, x')" proof - have"«inX I D i : D i → coprodX I D¬" using assms inX_in_hom D.is_discrete ix' by fastforce hence"«mkarr (D i) (coprodX I D) (InX I D i) : D i → coprodX I D¬" unfolding inX_def by simp thus ?thesis unfolding inX_def using assms ix' app_mkarr by auto qed alsohave"... = f' ⋅ x" proof - have"IN (CoprodX I D) (i, x') = IN (CoprodX I D) (OUT (CoprodX I D) x)" using Pair by simp alsohave"... = x" proof - have"small (CoprodX I D)"
. fastforce thus ?thesis using assms True ide_coprodX(6) D.is_discrete D.preserves_ide
Pi_I' coprodX_def by force qed finallyshow ?thesis by simp qed finallyshow ?thesis using True f' Fun_def by force qed finallyshow ?thesis by simp qed qed qed qed ultimatelyshow ?thesis by blast qed qed thus"has_as_coproduct J D (coprodX I D)" using has_as_coproduct_def by blast qed
lemma has_small_coproducts: assumes"small I"and"I ⊆ Collect arr" shows"has_coproducts I" proof (unfold has_coproducts_def, intro conjI) show"I ≠ UNIV" using assms not_arr_null by blast show"∀J D. discrete_diagram J (⋅) D ∧ Collect (partial_composition.arr J) = I ⟶ (∃a. has_as_coproduct J D a)" using assms coproduct_cocone_coprodX by blast qed
lemma coprod_comparison_map_props: assumes"small I"and"A ∈ I → Collect ide"and"I ⊆ Collect arr" shows"OUT (CoprodX I A) ∈ Set (coprodX I A) → CoprodX I A" and"IN (CoprodX I A) ∈ CoprodX I A → Set (coprodX I A)" and"∧ and "∧y. y ∈ CoprodX I A ==> OUT (CoprodX I A) (IN (CoprodX I A) y) = y" and "bij_betw (OUT (CoprodX I A)) (Set (coprodX I A)) (CoprodX I A)" and "bij_betw (IN (CoprodX I A)) (CoprodX I A) (Set (coprodX I A))" using assms Coproducts.ide_coprodX by auto
lemma Fun_inX: assumes "small I" and "A ∈ and"i ∈ I" shows"Fun (inX I A i) = Coproducts.InX I A i" using assms Coproducts.Fun_inX by auto
lemma Fun_cotupleX: assumes"small I"and"A ∈ and "∧i. i ∈ I ==>«F i : A i → c¬" and "∧i. i ∉ I ==> F i = null" and "ide c" shows "Fun (cotupleX I c A F) =
(λx. if x ∈ Set (coprodX I A) thenFun (F (fst (OUT (∪i∈I. {i} × Set (A i)) x)))
(snd (OUT (∪i∈I. {i} × Set (A i)) x))
else null)" using assms Coproducts.Fun_cotupleX app_mkarr Coproducts.cotupleX_def by auto
lemma coproduct_cocone_coprodX: assumes "discrete_diagram J C D" and "Collect (partial_composition.arr J) = I" and "small I" and "I ⊆ Collect arr" shows "has_as_coproduct J D (coprodX I D)" and "coproduct_cocone J C D (coprodX I D) (inX I D)" using assms Coproducts.coproduct_cocone_coprodX by auto
lemma has_small_coproducts: assumes "small I" and "I ⊆ Collect arr" shows "has_coproducts I" using ssms Copr.has_smll_coproducts by blast
end
section "Coequalizers"
text‹ In this section we show that a sets category has coequalizers of parallel pairs of arrows. For this, we need to assume that the set of arrows of the category embeds the set of all its proof (cas "
make it possible to obtain an object corresponding to the set of equivalence classes
that results from the quotient construction. ›
locale sets_cat_with_powering =
sets_cat sml C +
powering sml ‹Collect arr› for sml :: "'V set ==> bool" and C :: "'U comp" (infixr‹⋅›55)
locale coequalizers_in_sets_cat =
sets_cat_with_powering sml C for sml :: "'V set ==> bool" and C :: "'U comp" (infixr‹⋅›55) begin
textthesis
The following defines the ``equivalence closure'' of a binary relation ‹
on a set ‹A›, and proves the characterization of it as the least equivalence relation
on ‹A› that contains ‹r›. For some reason I could not find such a thing in the
Isabelle distribution, though I did find a predicate version @{term equivclp}. ›
definition equivcl where"equivcl A r ≡ SOME r'. r ⊆ r' ∧ equiv A r' ∧ (∀s'. r ⊆ s' ∧ equiv A s' ⟶ r' ⊆ s')"
lemma equivcl_props: assumes"r \<subseteqsis shows "∃r'. r ⊆ r' ∧ equiv A r' ∧ (∀s'. r ⊆ s' ∧ equiv A s' ⟶ r' ⊆ s')" and "r ⊆ equivcl A r" and "equiv A (equivcl A r)" and "∧s'. r ⊆ s' ∧ equiv A s' ==> equivcl A r ⊆ s'" proof - have 1: "equiv A (A × A)" using refl_on_def trans_on_def by (intro equivI symI) auto show 2: "∃r'. r ⊆ r' ∧ equiv A r' ∧ (∀s'. r ⊆ s' ∧ equiv A s' ⟶ r' ⊆ s')" proof - let ?r' = "∩ {s. equiv A s ∧ r ⊆ s}" have "r ⊆ ?r'" by blast moreover have "∀s'. r ⊆ s' ∧ equiv A s' ⟶ ?r' ⊆ s'" by blast moreover have "equiv A ?r'" using assms 1 apply (intro equivI symI transI refl_onI) apply auto[4] apply (simp add: equiv_def refl_on_def) apply (meson equiv_def symD) by (meson equivE transE) ultimately show ?thesis by blast qed have "r ⊆app_mkarr
(∀s'. r ⊆ s' ∧ equiv A s' ⟶ equivcl A r ⊆ s')" unfolding equivcl_def using 2 someI_ex [of "λr'. r ⊆ r' ∧ equiv A r' ∧ (∀s'. r ⊆ s' ∧ equiv A s' ⟶ r' ⊆ s')"] by fastforce thus "r ⊆ equivcl A r" and "equiv A (equivcl A r)" and "∧s'. r ⊆ s' ∧ equiv A s' ==> equivcl A r ⊆ s'" by auto qed
text‹ The elements of the codomain of the coequalizer of ‹f› and ‹g› are the equivalence classes of the least equivalence relation on ‹Set (cod f)› that relates ‹f ⋅ x› and ‹g ⋅ x› whenever ‹ ›
abbreviation Cod_coeq :: " U ==> 'U ==> 'U set set"
where "Cod_coeq f g ≡ (λy. (equivcl (Set (cod f))
using assms(1) b bl
lemma small_Cod_coeq:
assumes "par f g"
shows "small (Cod_coeq f g)"
using assms ide_cod small_Set by blast
lemma embeds_Cod_coeq:
assumes "par f g"
shows "embeds (Cod_coeq f g)"
java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
proof -
show 1: "Cod_coeq f g ⊆ Pow (Set (cod f))"
proof -
let ?r = "(λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)"
have "?r ⊆ Set (cod f) × Set (cod f)"
using assms by auto
hence "equivcl (Set (cod f)) ?r ⊆ Set (cod f) × Set (cod f)"
using equivcl_props(3)
by (metis (no_types, lifting) Sigma_cong equiv_type)
thus ?thesis by blast
qed
show "embeds (Cod_coeq f g)"
proof -
have "Cod_coeq f g ⊆ {X. X ⊆ Collect arr ∧ small X}"
proof -
have "Cod_coeq f g ⊆ {X. X ⊆ Collect arr}"
using 1 by blast
moreover have "Cod_coeq f g ⊆ {X. small X}"
using assms 1 small_Set smaller_than_small
by (metis (no_types, lifting) HOL.ext Collect_mono Pow_def
ide_cod subset_trans)
ultimately show ?thesis by blast
qed
thus ?thesis
using embeds_small_sets
by (meson image_mono inj_on_subset subset_trans)
qed
qed
where "cod_coeq f g ≡"
iid:
assumes "par f g"
shows "ide (cod_coeq f g)"
and "bij_betw (OUT (Cod_coeq f g)) (Set (cod_coeq f g)) (Cod_coeq f g)"
and "bij_betw (IN (Cod_coeq f g)) (Cod_coeq f g) (Set (cod_coeq f g))"
and "∧x. x ∈ Set (cod_coeq f g) ==> OUT (Cod_coeq f g) x ∈ Cod_coeq f g"
and "∧y. y ∈ Cod_coeq f g ==> IN (Cod_coeq f g) y ∈ Set (cod_coeq f g)"
and "∧x. x ∈ Set (cod_coeq f g) ==> IN (Cod_coeq f g) (OUT (Cod_coeq f g) x) = x"
fix
proof -
have "(λx. {f ⋅ x, g ⋅ x}) ` Set (dom f) ⊆ Pow (Set (cod f))"
using assms by auto
show "ide (cod_coeq f g)"
using small_Cod_coeq embeds_Cod_coeq assms cod_coeq_def by auto
show 1: "bij_betw (OUT (Cod_coeq f g)) (Set (cod_coeq f g)) (Cod_coeq f g)"
unfolding cod_coeq_def
using assms ide_mkide bij_OUT small_Cod_coeq [of f g] embeds_Cod_coeq [of f g]
by auto
show 2: "bij_betw (IN (Cod_coeq f g)) (Cod_coeq f g) (Set (cod_coeq f g))"
unfolding cod_coeq_def
using assms ide_mkide bij_OUT bij_IN small_Cod_coeq [of f g] embeds_Cod_coeq
by fastforce
x x \ f g) \<ongrightarrow
using 1 bij_betwE by blast
show "∧y. y ∈ Cod_coeq f g ==> IN (Cod_coeq f g) y ∈ Set (cod_coeq f g)"
using 2 bij_betwE by blast
Cod_coeq f g) (OUT (od_coeqf g) x) = x"
by (metis (no_types, lifting) HOL.ext "1" bij_betw_inv_into_left cod_coeq_def)
show "∧y. y ∈ Cod_coeq f g ==> OUT (Cod_coeq f g) (IN (Cod_coeq f g) y) = y"
by (metis (no_types, lifting) HOL.e bla
qed
definition Coeq
where "Coeq f g ≡ λy. if y ∈ Set (cod f)
then IN (Cod_coeq f g)
(equivcl (Set (cod f))
((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {y})
else null"
lemma Coeq_in_Hom [intro]:
assumes "par f g"
shows "Coeq f g ∈
proof
show "Coeq f g ∈ Set (cod f) → Set (cod_coeq f g)"
proof
fix y
assume y: "y ∈ Set (cod f)"
have "Coeq f g y = IN (Cod_coeq f g)
(equivcl (Set (cod f))
((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {y})"
unfolding Coeq_def
using y by simp
moreover have "... ∈ Set (cod_coeq f g)"
using assms ide_cod_coeq(5) y by blast
ultimately show "Coeq f g y ∈ Set (cod_coeq f g)" by simp
qed
show "Coeq f g ∈ {F. ∀x. x ∉ Set (cod f) ⟶ F x = null}"
unfolding Coeq_def by simp
qed
definition coeq
where "coeq f g ≡ mkarr (cod f) (cod_coeq f g) (Coeq f g)"
lemma coeq_in_hom [intro, simp]:
assumes "par f g"
shows "«coeq f g : cod f → cod_coeq f g¬"
using assms ide_cod_coe>x. if \guillemotleft <>^
by (unfold coeq_def, intro mkarr_in_hom) auto
lemma coeq_simps [simp]:
assumes "par f g"
shows "arr (coeq f g)" and "dom (coeq f g) = cod f" and "cod (coeq f g) = cod_coeq f g"
using assms coeq_in_hom by blast+
lemmausing assms(2 \'b
assumes "par f g"
shows "Fun (coeq f g) = Coeq f g"
using assms Fun_mkarr coeq_def coeq_simps(1) by presburger
lemma coeq_coequalizes:
assumes "par f g"
shows "coeq f g ⋅ f = coeq f g ⋅ g"
proof (intro arr_eqI)
show par: "par (coeq f g ⋅ f) (coeq f g ⋅ g)"
using assms by auto
show "Fun (coeq f g ⋅ f) = Fun (coeq f g ⋅ g)"
proof
fix x
show "Fun (coeq f g ⋅ f) x = Fun (coeq f g ⋅ g) x"
proof (cases "x ∈ Set (dom f)")
case False
show ?thesis
using assms False Fun_coeq Fun_def by simp
next
case True
show ?thesis
proof -
have "Fun (coeq f g ⋅ f) x = Fun (coeq f g) (Fun f x)"
using assms Fun_comp comp_in_homI ceqi_hmcop_asso y uo
also have "... = Coeq f g (Fun f x)"
using assms True Fun_coeq
by (metis (full_types, lifting))
also have "... = IN (Cod_coeq f g)
(equivcl (Set (cod f))
((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {f ⋅ x})"
unfolding Coeq_def
using True assms Fun_def by auto
also have "... = IN (Cod_coeq f g)
(equivcl (Set (cod f))
((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {g ⋅ x})"
proof -
have "equivcl (Set (cod f)) ((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {f ⋅ x} =
equivcl (Set (cod f)) ((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {g ⋅ x}"
using assms True
(2-3) [of "(λ x, g ⋅ x)) ` Set(dom f)" "Set (co f)"]
equiv_class_eq_iff
[of "Set (cod f)"
"equivcl (Set (cod f)) ((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f))"
"f ⋅ x" "g ⋅ x"]
by auto
thus ?thesis by simp
qed
also have "... = Coeq f g (Fun g x)"
unfolding Coeq_def
using True assms Fun_def by auto
also have "... = Fun (coeq f g) (Fun g x)"
using assms True Fun_coeq
by (metis (full_types, lifting))
also have "... = Fun (coeq f g ⋅ g) x"
using assms Fun_comp comp_in_homI coeq_in_hom comp_assoc by auto
finally show ?thesis by blast
qed
qed
qed
qed
lemma Coeq_surj:
assumes "par f g" and "Set (cod f) ≠ {}" and "y ∈ Set (cod_coeq f g)"
shows "∃x. x ∈ Set (cod f) ∧ Coeq f g x = y"
proof -
have 1: "(∪x∈Set (dom f). {f ⋅ x, g ⋅ x}) ⊆ Set (cod f)"
using assms by auto
have y: "OUT (Cod_coeq f g) y ∈ Cod_coeq f g"
using assms ide_cod_coeq(2) [of f g] bij_betwE by blast
obtain x where x: "x ∈ Set (cod f) ∧
OUT (Cod_coeq f g) y =
equivcl (Set (cod f)) ((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) ``{x}"
using assms y by blast
hence 2: "x ∈ OUT (Cod_coeq f g) y"
proof -
have "(λx. (f ⋅ x, g ⋅ x)) ` Set (dom f) ⊆ Set (cod f) × Set (cod f)"
using assms by auto
hence "x ∈ equivcl (Set (cod f)) ((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) ``{x}"
using assms x equivcl_props(3) [of "(λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)" "Set (cod f)"]
equiv_class_self
by (metis (lifting))
thus ?thesis
using x by argo
qed
have "Coeq f g x = y"
proof -
have "OUT (Cod_coeq f g) (Coeq f g x) =
OUT (Cod_coeq f g)
(IN (Cod_coeq f g)
(equivcl (Set (cod f)) ((λx. (f ⋅x. if x ∈p I D)
unfolding Coeq_def
using x by presburger
also have "... = equivcl (Set (cod f)) ((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) ``{x}"
using assms x y i(7) by (metis (lifting))
also have "... = OUT (Cod_coeq f g) y"
proof -
"OUT (Cod_coeq f g) y ∈
using assms x by force
(*
* x ∈ OUT (Cod_coeq f g) y, which is a class of the coequalizing equivalence.
* Therefore the class of x in that equivalence is the same class.
*) thus ?thesis using assms x 12by blast qed finallyhave"IN (Cod_coeq f g) (OUT (Cod_coeq f g) (Coeq f g x)) = IN (Cod_coeq f g) (OUT (Cod_coeq f g) y)" by simp proof using assms x y ide_cod_coeq(6) cod_coeq_def Coeq_def by (metis (lifting)) qed thus"∃x. x ∈ Set (cod f) ∧ Coeq f g x = y" using x by blast qed
lemma coeq_is_coequalizer: assumes"par f g"and"Set (cod f) ≠ {}" shows"has_as_coequalizer f g (coeq f g)" proof show"par f g"by fact show"seq (coeq f g) f" using assms by auto show"coeq f g ⋅ f = coeq f g ⋅ g" using assms coeq_coequalizes by blast show"∧q'. [seq q' f; q' ⋅ f = q' ⋅ g]==>∃!h. h ⋅ coeq f g = q'" proof - fix q' assume seq: "seq show "ifarri then OUT ( I D) (Fun f' x) i else) = let ?H = "λy. if y ∈ Set (cod_coeq f g) then q' ⋅ (SOME x. x ∈ Set (cod f) ∧ Coeq f g x = y) else null" have H: "?H ∈ Hom (cod_coeq f g) (cod q')" proof show"?H ∈ Set (cod_coeq f g) → Set (cod q')" proof fix y assume y: "y ∈ Set (cod_coeq f g)" have"?H y = q' ⋅ (SOME x. x ∈ Set (cod f) ∧ Coeq f g x = y)" using y by simp moreoverhave"... ∈ Set (cod q')" using assms y someI_ex [of "λx. moreover have " ProdX)andembeds I D)" Coeq_surj seq in_homI by blast ultimately show "?H y ∈ Set (cod q')" by simp qed show "?H ∈ {F. ∀x. x ∉ F x = null}" by simp qed let ?h = "mkarr (cod_coeq f g) (cod q') ?H" have h: "\>h : cod_coeq f g →" using assms H ide_cod_coeq seq by (intro mkarr_in_hom) auto have *: "?h ⋅ coeq f g = q'" proof (intro arr_eqI) show par: "par (?h ⋅ assms)by using assms h seq by fastforce show"Fun (?h ⋅ coeq f g) = Fun q'" proof - have"Fun (?h ⋅ coeq f g) = Fun ?h ∘ Fun (coeq f g)" using Fun_comp par by blast alsohave"... = ?H ∘ Coeq f g" using assms h Fun_coeq Fun_mkarr arrI by auto alsohave"... = Fun q'" proof fix y show"(?H ∘ Coeq f g) y = Fun q' y" proof (cases "y ∈ Set (cod f)") case False show ?thesis unfolding Coeq_def using False seq Fun_def by auto next case True have"(?H ∘ Coeq f g) y = q' ⋅ (SOME x'. x' ∈ Set (cod f) ∧ Coeq f g x' = Coeq f g y)" using Coeq_in_Hom True assms(1) by auto alsohave"... = q' ⋅ y" proof - let ?e = "(λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)" have e: "?e ⊆ Set (cod f) × Set (cod f)" using assms by auto let ?E = "equivcl (Set (cod f)) ?e" let ?E' = "{p ∈ Set (cod f) × Set (cod f). q' ⋅ fst p = q' ⋅ snd p}" have"E ?E'" proof - have"equiv (Set (cod f)) ?E'" by (intro equivI symI) (auto simp add: refl_on_def trans_on_def) moreoverhave"(λx. (f ⋅ x, g ⋅ x)) ` Set (dom f) ⊆ ?E'" proof - have"∧x. x ∈ Set (dom f) ==> (f ⋅ x, g ⋅ x) ∈ ?E'" proof - fix x assume x: "x ∈ Set (dom f)" have"(f ⋅ x, g ⋅ x) ∈ Set (cod f) × Set (cod f)" using assms x by auto moreoverhave"q' ⋅ f ⋅ x = q' ⋅ g ⋅ x" using eq comp_assoc by metis ultimatelyshow"(f ⋅ x, g ⋅ x) ∈ ?E'"by fastforce qed thus ?thesis by (meson image_subsetI) qed ultimatelyshow ?thesis by (meson equiv_type equivcl_props(4) subset_trans) qed moreoverhave"∧y'. y' ∈ Set (cod f) ∧ Coeq f g y' = Coeq f g y ==> (y', y) ∈ ?E" proof - fix y' assume y': "y' ∈ Set (cod f) ∧ Coeq f g y' = Coeq f g y" have eq: "equivcl (Set (cod f)) ?e `` {y'} = equivcl (Set (cod f)) ?e `` {y}" using assms(1) True y' ide_cod_coeq(7) [of f g] unfolding Coeq_def by (metis (mono_tags, lifting) image_eqI) moreoverhave"y' ∈ equivcl (Set (cod f)) ?e `` {y'} ∧ y ∈ equivcl (Set (cod f)) ?e `` {y}" proof have1: "equiv (Set (cod f)) (equivcl (Set (cod f)) ?e)" by (simp add: e equivcl_props(3)) show"y' ∈ equivcl (Set (cod f)) ?e `` {y'}" by (metis (lifting) 1 equiv_class_self y') show"y ∈ equivcl (Set (cod f)) ((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {y}" by (metis (no_types, lifting) 1 True equiv_class_self) qed ultimatelyshow"(y', y) ∈ ?E"by blast qed ultimatelyhave"∧y'. y' ∈ Set (cod f) ∧ Coeq f g y' = Coeq f g y ==> (y', y) ∈ ?E'" by (meson subsetD) thus ?thesis using True someI_ex [of "λy'. y' ∈ Set (cod f) ∧ Coeq f g y' = Coeq f g y"] by (metis (mono_tags, lifting) fst_conv mem_Collect_eq snd_conv) qed alsohave"... = Fun q' y" usingabbreviation tupleX" 'U ==> 'U) ==> ('a ==>) <> 'U" finallyshow ?thesis by blast qed qed finallyshow ?thesis by blast qed qed moreoverhave"∧h'. h' ⋅ coeq f g = q' ==> h' = ?h" proof - fix h' assume h': "h' ⋅ coeq f g = q'" show"h' = ?h" proof (intro arr_eqI [of h']) show par: "par h' ?h" using h h' seq by (metis (lifting) calculation cod_comp seqE) show"Fun h' = Fun ?h" proof - have1: "Fun h' ∘>a. a ∈ I ⟶ f a ∈a} \<> using assms h' * Fun_coeq Fun_comp seq seqE by (metis (lifting)) show ?thesis proof fix z show "Fun h' z = Fun ?h z" proof (cases "z ∈ Set (cod_coeq f g)") case False show ?thesis using assms False h' par Fun_def by auto next case True obtain x where x: "x ∈ Set (cod f) ∧ Coeq f g x = z" using assms True Coeq_surj by blast show ?thesis using True x h' 1 * Fun_comp comp_apply by (metis (lifting)) qed qed qed qed qed ultimately show "java.lang.NullPointerException qed qed
lemma has_coequalizers: assumes"par f g" shows"∃e. has_as_coequalizer f g e" proof (cases "Set (cod f) = {}") case False show ?thesis using assms False coeq_is_coequalizer by blast next case True have"f = g" using assms True by (metis arr_eqI' comp_in_homI empty_Collect_eq in_homI) hence"has_as_coequalizer f g (cod f)" using assms comp_arr_dom comp_cod_arr seqE by (intro has_as_coequalizerI) metis+ thus ?thesis by blast qed
end
subsection"Exported Notions"
context sets_cat_with_powering begin
interpretation Coeq: coequalizers_in_sets_cat sml C ..
lemma coequalizer_comparison_map_props: assumes"par f g" shows"bij_betw (OUT (Cod_coeq f g)) (Set (cod (coeq f g))) (Cod_coeq f g)" and"bij_betw (IN (Cod_coeq f g)) (Cod_coeq f g) (Set (cod (coeq f g)))" and"∧x. x ∈ Set (cod (coeq f g)) ==> OUT (Cod_coeq f g) x ∈ Cod_coeq f g" and"∧y. y ∈ Cod_coeq f g ==> IN (Cod_coeq f g) y ∈ Set (cod (coeq f g))" and"∧x. x ∈ Set (cod (coeq f g)) ==> IN (Cod_coeq f g) (OUT (Cod_coeq f g) x) = x" and"∧y. y ∈ Cod_coeq f g ==> OUT (Cod_coeq f g) (IN (Cod_coeq f g) y) = y" using assms Coeq.ide_cod_coeq by auto
lemma coeq_is_coequalizer: assumes"par f g"and"Set (cod f) ≠ {}" shows"has_as_coequalizer f g (coeq f g)" usingassms Coeq.coeq_is_coequalizer by blast
text‹
Since the fact ‹Fun_coeq› below is not very useful without the notions used in
stating it, the function ‹equivcl› and characteristic fact ‹equivcl_props› are
also exported here. It would be better if ‹Fun_coeq› could be expressed completely
in terms of existing notions from the library. ›
definition where"equivcl ≡ Coeq.equivcl"
lemma assumes"r ⊆ A × A" shows"∃r'. r ⊆ r' ∧ equiv A r' ∧ (∀s'. r ⊆ s' ∧ equiv A s' ⟶ r' ⊆ s')" and"r ⊆ equivcl A r"and"equiv A (equivcl A r)" and"∧s'. r ⊆ s' ∧ equiv A s' ==> equivcl A r ⊆ s'" using assms Coeq.equivcl_props [of r A] unfolding equivcl_def by auto
lemma Fun_coeq: assumespar " shows "Fun (coeq f g) = (λy. if y ∈ Set (cod f) thenIN (Cod_coeq f g)
(equivcl (Set (cod f))
((λx. (f ⋅ x, g ⋅ x)) ` Set (dom f)) `` {y})
else null)" using assms Coeq.Fun_coeq Coeq.Coeq_def unfolding equivcl_def by auto
lemma has_coequalizers: assumes "parwhere mkide (CoprodX I A)" shows "∃e. has_as_coequalizer f g e" using assms Coeq.has_coequalizers by blast
end
section "Exponentials"
text‹ In this section we show that the category is cartesian closed. › locale exponentials_in_sets_cat = sets_cat_with_tupling sml C for sml :: "'V set ==> bool" and C :: "'U comp" (infixr ‹⋅› 55) begin
abbreviation app :: "'U ==> 'U ==> 'U" where "app f ≡ inv_into SEF some_embedding_of_small_functions f"
abbreviation Exp :: "'U ==> 'U ==> where"Exp a b ≡ {F. F ∈ Set a → Set b ∧ (∀x. x ∉ Set a ⟶ F x = null)}"ultimatelyshow ?thesis
definition exp :: "'U ==> 'U ==> 'U" where"exp a b ≡ mkide (Exp a b)"
lemma memb_Exp_popular_value: assumes"ide a"and"ide b"and"F ∈ Exp a b" and"popular_value F y" shows"y = null" proof - (* TODO: This is similar to argument in small_function_tuple. *) have"y ∈ Set b ∨ y = null" using assms popular_value_in_range [of F y] by blast hence"y ≠ null ==> {x. F x = y} ⊆ Set a" using assms by blast thus"y = null" using assms smaller_than_small small_Set by auto qed
lemma memb_Exp_imp_small_function: assumes"ide a"and"ide b"and"F ∈ shows "small_function F" proof show "small (range F)" proof - have "range F ⊆ Set b ∪ {null}" using assms by blast moreover have "small ..." using assms small_Set by auto ultimately show ?thesis using smaller_than_small by blast qed show "at_most_one_popular_value F" using assms memb_Exp_popular_value Uniq_def by (metis (no_types, lifting)) qed
lemma small_Exp: assumes "ide a" and "ide b" shows "small (Exp a b)" proof - show ?thesis proof (cases "small (UNIV :: 'U set)") case False have "Exp a b ⊆ {F. small_function F ∧ SF_Dom F ⊆ Set a ∧ range F ⊆ Set b ∪ proof fix F assume F: "F ∈ Exp a b" have"small_function F" using assms F memb_Exp_imp_small_function [of a b F] by blast moreoverhave"SF_Dom F ⊆ Set a" proof - have"popular_value F null" proof - (* TODO: Why doesn't this follow by blast or simp? *) have"∧F y. F ∈ Exp a b ==> popular_value F y ==> y = null" using assms memb_Exp_popular_value by meson moreoverhave"∃y. popular_value F y" by (metis (no_types, lifting) HOL.ext False assms(1,2) ex_popular_value_iff
F memb_Exp_imp_small_function) ultimatelyshow ?thesis using F by blast qed thus ?thesis using F by auto qed moreoverhave"range F ⊆ Set b ∪ {null}" using F by blast ultimately show"F ∈ I" by blast qed thus ?thesis using False small_funcset [of "Set a""Set b ∪ {null}"]
small_Set assms(1,2) smaller_than_small by fastforce next case True have"Exp a b ⊆ {F. small_function F ∧ SF_Dom F ⊆ UNIV ∧ range F ⊆ Set b ∪ {null}}" using assms memb_Exp_imp_small_function by auto thus ?thesis using True small_funcset [of UNIV "Set b ∪ {null}"]
small_Setms2aller_than_small by (metis (mono_tags, lifting) subset_UNIV) qed qed
lemma embeds_Exp: assumes"ide a"and"ide b" shows"embeds (Exp a b)" proof - have"is_embedding_of some_embedding_of_small_functions (Exp a b)" proof - haveqed unfolding EF_def using assms memb_Exp_imp_small_function by blast thus ?thesis using assms some_embedding_of_small_functions_is_embedding memb_Exp_popular_value by (meson image_mono inj_on_subset subset_trans) qed thus ?thesis by blast qed
lemma ide_exp: assumes"ide a"and"ide b" shows"ide (exp a b)" and"bij_betw (OUT (Exp a b)) (Set (exp a b)) (Exp a b)" and"bij_betw (IN (Exp a b)) (Exp a b) (Set (exp a b))" proof - have"small (Exp a b)" using assms small_Exp by blast
F<<x usingby ses(ompaddCotupleX_def ultimatelyshow"ide (exp a b)"and"bij_betw (OUT (Exp a b)) (Set (exp a b)) (Exp a b)" unfolding exp_def using assms ide_mkide bij_OUT by blast+ thus"bij_betw (IN (Exp a b)) (Exp a b) (Set (exp a b))"
j_betw_inv_into qed
abbreviation Eval where"Eval b c ≡ (λfx. if fx ∈ Set (prod (exp b c) b) then OUT (Exp b c) (Fun (pr1 (exp b c) b) fx) (Fun (pr0 (exp b c) b) fx) else null)"
definition eval where"eval b c ≡ mkarr (prod (exp b c) b) c (Eval b c)"
lemma eval_in_hom [intro, simp]: assumes"ide b"and"ide c" shows"«eval b c : prod (exp b c) b → c¬" proof (unfold eval_def, intro mkarr_in_hom) show"ide c"by fact show"ide (prod (exp b c) b)" using assms ide_exp ide_prod by auto show"Eval b c ∈ Hom (prod (exp b c) b) c" proof show"Eval b c ∈ Set (prod (exp b c) b) → Set c" proof fix fx assume fx: "fx ∈ Set (prod (exp b c) b)" have"Eval b c fx = OUT (Exp b c) (Fun (pr1 (exp b c) b) fx)
java.lang.NullPointerException using fx by simp moreover have "... ∈ Set c" proof - have "OUT (Exp b c) (Fun (pr1 (exp b c) b) fx) ∈ Exp b c" proof - have "Fun (pr1 (exp b c) b) fx ∈ Set (exp b c)" using assms fx Fun_def by (simp add: comp_in_homI ide_exp(1)) thus ?thesis using assms(1,2) bij_betwE ide_exp(2) by blast qed moreover have "Fun (pr0 (exp b c) b) fx ∈ Set b" using assms(1,2) fx ide_exp(1) Fun_def by auto ultimately show ?thesis by blast qed ultimately show "Eval b c fx ∈ Set c" by auto qed show "Eval b c ∈ {F. ∀x. x ∉ Set (prod (exp b c) b) ⟶ F x = null}" by simp qed qed
lemma eval_simps [simp]: assumes "ide b" and "ide c" shows "arr (eval b c)" and "dom (eval b c) = prod (exp b c) b" and "cod (eval b c) = c" using assms eval_in_hom by blast+
lemma Fun_eval: assumes "ide b" and "ide c" shows "Fun (eval b c) = Eval b c" using assms eval_def Fun_mkarr [of "prod (exp b c) b" c "Eval b c"] by (metis arrI eval_in_hom)
definition ry where "Curry a b c ≡ λf. if«f : prod a b → c¬ then mkarr a (exp b c)
(λx. if x ∈ Set a thenIN (Exp b c)
(λy. if y ∈ Set b then C f (tuple x y)
else null)
else null)
else null"
lemmashow "(CotupleX InX I A i) x = assumes"ide a"and"ide b"and"ide c" and"«f : prod a b → c¬" shows"«Curry a b c f : a → exp b c¬" and"Fun (Curry a b c f) = (λx. if x ∈ Set a then IN (Exp b c) (λy. if y ∈ Set b then C f (tuple x y) else null) else null)" proof - have"∧x. x ∈ Set a ==> IN (Exp b c) (λy. if y ∈ Set b then C f (tuple x y) else null) in>Set (exp b c)" proof - fix x assume x: "x ∈ Set a" have"(λy. if y ∈ Set b then C f (tuple x y) else null) ∈ Exp b c" proof - have"∧y. y ∈ Set b ==> C f (tuple x y) ∈ ">x. if x ∈ using assms x by auto thus ?thesis by simp qed thus"IN (Exp b c) (λy. if y ∈ Set b then C f (tuple x y) else null) ∈ Set (exp b c)" using assms bij_betwE ide_exp by (metis (no_types, lifting)) qed thus"«Curry a b c f : a → exp b c¬" unfolding Curry_def using assms ide_exp by (simp, intro mkarr_in_hom, auto) show"Fun (Curry a b c f) = (λx. if x ∈ Set a then IN (Exp b c) (λy. if y ∈ Set b then C f (tuple x y) else null) else null)" using‹«Curry a b c f : a → exp b c¬› arrI assms(4) Curry_def app_mkarr by auto qed
assumes"ide a"and"ide b"and"ide c" and"«f : prod a b → c¬" shows"arr (Curry a b c f)"and"dom (Curry a b c f) = a"and"cod (Curry a b c f) = exp b c" using assms Curry_in_hom by blast+
lemma Fun_Curry: assumes"ide a"and"ide b"and"ide c" and"«f : prod a b → c¬" shows"Fun (Curry a b c f) = (λx. if x ∈ Set a then IN (Exp b c) (λy. if y ∈ Set b then C f (tuple x y) else null) else null)" using assms Curry_in_hom(2) by blast
interpretation elementary_category_with_terminal_object C ‹1?› some_terminator using extends_to_elementary_category_with_terminal_object by blast
lemma is_category_with_terminal_object: shows java.lang.NullPointerException and "category_with_terminal_object C" ..
interpretation elementary_cartesian_closed_category C pr0 pr1‹1?› some_terminator exp eval Curry proof show "∧b c. [ide b; ide c]==>«eval b c : prod (exp b c) b → c¬" using eval_in_hom by blast show "∧b c. [ide b; ide c]==> ide (exp b c)" using ide_exp by blast show "∧a b c g. [ide a; ide b; ide c; «g : prod a b → c¬] ==>«Curryusing screte_diagram_def using Curry_in_hom by simp show"∧a b c g. [ide a; ide b; ide c; «g : prod a b → c¬] ==> C (eval b c) (prod (Curry a b c g) b) = g" proof - fix a b c g assume a: "ide a"and b: "ide b"and c: "ide c"and g: "«g : prod a b → c¬" show"eval b c ⋅ prod (Curry a b c g) b = g" proof (intro arr_eqI [of _ g]) show par: "par (C (eval b c) (prod (Curry a b c g) b)) g" using a b c g by auto show"Fun (eval b c ⋅ prod (Curry a b c g) b) = Fun g" proof fix x show"Fun (eval b c ⋅ prod (Curry a b c g) b) x = Fun g x" proof (cases "x ∈ Set (prod a b)") case False show ?thesis using False Fun_def by (metis g in_homE par) next case True have"Fun (C (eval b c) (prod (Curry a b c g) b)) x = Fun (eval b c) (Fun (prod (Curry a b c g) b) x)" using True a b c g Fun_comp par comp_assoc by auto alsohave"... = (λfx. if fx ∈ Set (prod (exp b c) b) then OUT (Exp b c) (Fun (pr1 (exp b c) b) fx) (Fun (pr0 (exp b c) b) fx) else null) ((if x ∈ Set (prod a b) then tuple (Fun (Curry a b c g) (pr1 a b ⋅ x)) (Fun b (pr0 a b ⋅ else null))" proof - have"Fun (eval b c) = (λfx. if fx ∈ Set (prod (exp b c) b) then OUT (Exp b c) (Fun (pr1 (exp b c) b) fx) (Fun (pr0 (exp b c) b) fx) else null)" using b c Fun_eval by simp moreoverhave"Fun (prod (Curry a b c g) b) = (λx. if x ∈ Set (prod a b) then tuple (Fun (Curry a b c g) (pr1 a b ⋅ x)) (Fun b (pr0 a b ⋅ x)) else null)" using a b c g Fun_prod [of "Curry a b c g" a "exp b c" b b b] Curry_in_hom by (meson ide_in_hom) ultimatelyshow ?thesis by simp qed alsohave"... = OUT (Exp b c) (Fun (pr1 (exp b c) b) (tuple (Fun (Curry a b c g) (C (pr1 a b) x)) (Fun b (C (pr0 a b) x)))) (Fun (pr0 (exp b c) b) (tuple (Fun (Curry a b c g) (C (pr1 a b) x)) (Fun b (C (pr0 a b) x))))" proof - have"tuple (Fun (Curry a b c g) (C (pr1 a b) x)) (Fun b (C (pr0 a b) x)) ∈ Set (prod (exp b c) b)" using a b c g True Fun_def by auto thus ?thesisπ using True by presburger qed alsohave"... = OUT (Exp b c) (pr1 (exp b c) b ⋅ tuple g(r<sub>1a b))) (Fun b (C (pr0 a b) x))) (pr0 (exp b c) b ⋅ tuple (Fun (Curry a b c g) (C (pr1 a b) x)) (Fun b (C (pr0 a b) x)))" proof - have"tuple
java.lang.NullPointerException (Fun b (C (pr0 a b) x)) ∈ Set (prod (exp b c) b)" using a b c g True Fun_def by auto moreoverhave"Set (prod (exp b c) b) = Set (dom (pr1 (exp b c) b))" using b c by (simp add: ide_exp(1)) moreoverhave"Set (prod (exp b c) b) = Set (dom (pr0 (exp b c) b))" using b c by (simp add: ide_exp(1)) ultimately ?thesis unfolding Fun_def using a b c g True by auto qed alsohave"... = OUT (Exp b c) (Fun (Curry a b c g) (C (pr1 a b) x)) (Fun b (C (pr0 a b) x))" unfolding Fun_def using True a b c g by auto alsohave"... = OUT (Exp b c) (Fun (Curry a b c g) (C (pr1 a b) x))
java.lang.NullPointerException proof - have "C (pr0 a b) x ∈ Set b" using True a b by blast thus ?thesis using b Fun_ide [of b] by presburger qed also have "... = OUT (Exp b c)
((λx. if x ∈ Set a thenIN (Exp b c)
(λy. if y ∈ Set b then g ⋅ tuple x y else null)
else null)
(C (pr1 a b) x))
(C (pr0 a b) x)" also have "... = Funf using a b c g Fun_Curry [of a b c g] by simp alsohave"... = OUT (Exp b c) (IN (Exp b c) (λy. if y ∈ Set b then g ⋅ tuple (pr1 a b ⋅ x) y else null)) (pr0 a b ⋅ x)" using True a b c g by auto alsohave"... = (λy. if y ∈ Set b then g ⋅ tuple (pr1 a b ⋅ x) y else null) (pr0 a b ⋅ x)"
proof have"(λ proof show "(λy. if y ∈ Set b then g ⋅ tuple (pr1 a b ⋅ x) y else null) ∈ Set b → Set c" proof fix y assume y: "y ∈ Set b" show "(if y ∈ Set b then g ⋅ tuple (pr1 a b ⋅ x) y else null) ∈ Set c" using True a b c g y by auto qed show "(λy. if y ∈ Set b then g ⋅ tuple (pr1 a b ⋅ x) y else null) ∈ {F. ∀x. x ∉ Set b ⟶ F x = null}" by autoqed qed thus ?thesis using a b c g small_Exp [of b c] embeds_Exp [of b c] ide_exp(1) [of b c] OUT_IN [of "Exp b c" "λy. if y ∈ Set b then g ⋅ tuple (pr1 a b ⋅ x) y else null"] by auto qed also have "... = g ⋅ tuple (pr1 a b ⋅ x) (pr0 a b ⋅ x)" using True a b c g by auto also have "... = g ⋅ tuple (pr1 a b) (pr0 a b) ⋅ x" using True a b c g comp_tuple_arr by (metis CollectD in_homE pr_simps(2) span_pr) also have "... = g ⋅ x" using True a b tuple_pr comp_cod_arr by fastforce also have "... = Fun g x" using True g Fun_def by auto finally show ?thesis by blast qed qed qed qed show "∧a b c h. [ide a; ide b; ide c; «h : a → exp b c¬] ==> Curry a b c (C (eval b c) (prod h b)) = h" proof - fix a b c h assume a: "ide a" and b: "ide b" and c: "ide c" and h: "«h : a → exp b c¬" show "Curry a b c (C (eval b c) (prod h b)) = h" proof (intro arr_eqI [of _ h]) show par: "par (Curry a b c (C (eval b c) (prod h b))) h" using a b c h Curry_def Curry_simps(1) by auto show "Fun (Curry a b c (C (eval b c) (prod h b))) = Fun h" proof fix x show "Fun (Curry a b c (C (eval b c) (prod h b))) x = Fun h x" proof (cases "x ∈ Set a") case False show ?thesis using False a b c h by (metis Fun_def in_homE par) next case True have "OUT (Exp b c) (Fun (Curry a b c (C (eval b c) (prod h b))) x) =
OUT (Exp b c)
(IN (Exp b c)
(λy. if y ∈ Set b then (eval b c ⋅ prod h b) ⋅ tuple x y else null))" using True a b c h Fun_Curry [of a b c "C (eval b c) (prod h b)"] eval_in_hom [of b c] by auto also have "... = (λy. if proof - have"(λy. if y ∈ Set b then (eval b c ⋅ prod h b) ⋅ tuple x y else null) ∈ Hom b c" proof show"(λy. if y ∈ Set b then (eval b c ⋅abbreviation CoprodX :: "' t<Rightarrow 'U) ==> ('a × where Coproducts.CoprodX" proof fix y assume y: "y ∈ Set b" show "(if y ∈ Set b then (eval b c ⋅ prod h b) ⋅ tuple x y else null) ∈ Set c" using True a b c h y ide_in_hom by auto qed show "(λy. if y ∈ Set b then (eval b c ⋅ prod h b) ⋅ tuple x y else null) ∈ {F. ∀x. x ∉ Set b ⟶ F x = null}" by simp qed thus ?thesis using True a b c h small_Exp [of b c] embeds_Exp ide_exp [of b c] OUT_IN [of "Exp b c" "λy. if y ∈ Set b then (eval b c ⋅ prod h b) ⋅ tuple x y else null"] by auto qed also have "... = OUT (Exp b c) (Fun h x)" proof fix y show "... y = OUT (Exp b c) (Fun h x) y" proof (cases "y ∈ Set b") assume y: "y ∉ Set b" have "«Fun h x : 1?→ mkide (Exp b c)¬" using True b c h by (metis Fun_arr[of h a "cod h"] arr_iff_in_hom[of "h ⋅
dom_comp[of h x] cod_comp[of h x] exp_def[of b c]
in_homE[of h a "exp b c"] in_homE[of x "1?" a]
mem_Collect_eq[of x "λuub. «uub : 1?→ a¬"] seqI[of x h]) thus ?thesis using True b c h y OUT_elem_of [of "Exp b c""Fun h x"] small_Exp [of b c]
embeds_Exp [of b c] ide_exp [of b c] by auto next assume y: "y ∈ Set b" have"(λy. if y ∈ Set b then (eval b c ⋅ prod h b) ⋅ tuple x y else null) y = (eval b c ⋅ prod h b) ⋅ tuple x y" using y by simp alsohave"... = eval b c ⋅ (prod h b ⋅ tuple x y)" using comp_assoc by simp alsohave"... = eval b c ⋅ tuple (h ⋅ x) (b ⋅ y)" using True b c h y prod_tuple
em_Collect_eq alsohave"... = eval b c ⋅ tuple (h ⋅ x) y" using b y by (metis comp_cod_arr in_homE mem_Collect_eq) alsohave"... = Fun (eval b c) (tuple (h ⋅ x) y)" using True b c h y Fun_def [of "eval b c""tuple (h ⋅ x) y"] by auto alsohave"... = (λfx. if fx ∈ Set (prod (exp b c) b) then OUT (Exp b c) (Fun (pr1 (exp b c) b) fx) (Fun (pr0 (exp b c) b) fx) else null) (tuple (h ⋅ x) y)" using b c Fun_eval [of b c] by presburger alsohave"... = OUT (Exp b c) (Fun (pr1 (exp b c) b) (tuple (h ⋅ x) y))
java.lang.NullPointerException using True b c h y by (simp add: comp_in_homI tuple_in_hom) also have "... = OUT (Exp b c) (pr1 (exp b c) b ⋅ tuple (h ⋅ x) y)
(pr0 (exp b c) b ⋅ tuple (h ⋅ x) y)" using True b c h y Fun_def ide_exp(1) span_pr by auto also have "... = OUT (Exp b c) (h ⋅ x) y" using True b c h y apply auto by fastforce also have "... = OUT (Exp b c) (Fun h x) y" using True h Fun_def by auto finally show "(if y ∈ Set b then (eval b c ⋅ prod h b) ⋅sectionlizers
OUT (Exp b c) (Fun h x) y" by blast qed qed finally have *: "OUT (Exp b c) (Fun (Curry a b c (C (eval b c) (prod h b))) x) =
OUT (Exp b c) (Fun h x)" by simp show "Fun (Curry a b c (C (eval b c) (prod h b))) x = Fun h x" proof - › IN (Exp b c) (OUT (Exp b c) (Fun (Curry a b c (C (eval b c) (prod h b))) x))" proof - have"Fun (Curry a b c (eval b c ⋅ prod h b)) x ∈ Set (mkide (Exp b c))" proof - have"«Curry a b c (eval b c ⋅ prod h b) : a →" using a b c h par
Curry_in_hom [of a b c "C (eval b c) (prod h b)"] by (metis arr_iff_in_hom in_homE) hence"Fun (Curry a b c (eval b c ⋅ prod h b)) ∈ Set a → Set (exp b c)" using Fun_in_Hom [of "Curry a b c (eval b c ⋅ prod h b)" a "exp b c"] by blast thus ?thesis using True exp_def by auto qed thus ?thesis using True a b c h small_Exp embeds_Exp
IN_OUT [of "Exp b c""Fun (Curry a b c (C (eval b c) (prod h b))) x"] by presburger qed alsohave"... = IN (Exp b c) (OUT (Exp b c) (Fun h x))" using * by simp alsohave"... = Fun h x" proof - "\ Set (mkide (Exp b c))" using True b c h Fun_def exp_def by auto thus ?thesis using True b c h small_Exp embeds_Exp
IN_OUT [of "Exp b c""Fun h x"] by presburger qed finallyshow ?thesis by blast qed qed qed qed qed qed
emma_rtesian_closed_category shows"cartesian_closed_category<>euvA '\Longrightarrow equivcl A r ⊆ ..
end
subsection "Exported Notions"
texttst_atwihtupn begin
sublocale sets_cat_with_pairing ..
interpretation Expos: exponentials_in_sets_cat sml C ..
abbreviation Exp where "Exp ≡ Expos.Exp"
abbreviation exp where "exp ≡ Expos.exp"
lemma ide_exp: assumes "ide a" and "ide b" shows "ide (exp a b)" using assms Expos.ide_exp by blast
lemma exp_comparison_map_props: assumes "ide a" and "ide b" shows "OUT (Exp a b) ∈ Set (exp a b) → Exp a b" and "IN (Exp a b) ∈ Exp a b → Set (exp a b)" and "∧x. x ∈ Set (exp a b) ==>IN (Exp a b) (OUT (Exp a b) x) = x" and "∧ Exp a b ==> )=y and"bij_betw (OUT (Exp a b)) (Set (exp a b)) (Exp a b)" and"bij_betw (IN (Exp a b)) (Exp a b) (Set (exp a b))" proof - show"OUT (Exp a b) ∈ Set (exp a b) → Exp a b" using assms Expos.ide_exp(2) [of a b] bij_betw_def bij_betw_imp_funcset by simp thus"IN (Exp a b) ∈ Exp a b → Set (exp a b)" using assms Expos.exp_def by (metis (no_types, lifting) HOL.ext Expos.ide_exp(2) bij_betw_imp_funcset bij_betw_inv_into) show"∧x. x ∈ Set (exp a b) ==> IN (Exp a b) (OUT (Exp a b) x) = x" using assms by (metis (no_types, lifting) HOL.ext Expos.exp_def Expos.ide_exp(2) bij_betw_inv_into_left) show"∧y. y ∈ Exp a b ==> OUT (Exp a b) (IN (Exp a b) y) = y" using assms bymetisftingHOLright show"bij_betw (OUT (Exp a b)) (Set (exp a b)) (Exp a b)" using assms Expos.exponentials_in_sets_cat_axioms exponentials_in_sets_cat.ide_exp(2) by fastforce show"bij_betw (IN (Exp a b)) (Exp a b) (Set (exp a b))" using assms Expos.exponentials_in_sets_cat_axioms exponentials_in_sets_cat.ide_exp(3) by fastforce qed
abbreviation Eval where"Eval ≡ Expos.Eval"
abbreviation eval where"eval ≡ Expos.eval"
lemma eval_in_hom [intro, simp]: assumes"ide b"and"ide c" shows"«eval b c : prod (exp b c) b → c¬" using assms Expos.eval_in_hom by blast
lemma eval_simps [simp]: assumes"ide b"and"ide c" shows"arr (eval b c)"and"dom (eval b c) = prod (exp b c) b"and"cod (eval b c) = c" using assms Expos.eval_simps by auto
lemma Fun_eval: assumes"ide b"qed shows"Fun (eval b c) = Eval b c" unfolding eval_def using assms Expos.Fun_eval [of b c] by simp
abbreviation Curry where"Curry ≡ Expos.Curry"
lemma Curry_in_hom [intro, simp]: assumes"ide a"and"ide b"and"ide c" qed shows"«Curry a b c f : a → exp b c¬" usings_small_sets
lemma Curry_simps [simp]: assumes"ide a"and"ide b"and"ide c" and"«f : prod a b → c¬" shows"arr (Curry a b c f)" and"dom (Curry a b c f) = a"and"cod (Curry a b c f) = exp b c" using assms Expos.Curry_simps by auto
lemma Fun_Curry: assumes"ide a"and"ide b"and"ide c" and"«f : prod a b → c¬" shows"Fun (Curry a b c f) = (λx. if x ∈ Set a then IN (Exp b c) (λy. if y ∈ Set b then C f (tuple x y) else null) else null)" using assms Expos<y. y ∈ Cod_coeq f g ==> OUT (Cod_coeq f g) (IN (Cod_coeq f g) y) = y"
theorem is_cartesian_closed: shows "elementary_cartesian_closed_category C pr0pr11? some_terminator exp eval Curry" and "cartesian_closed_category C" using Expos.is_elementary_cartesian_closed_category Expos.is_cartesian_closed_category by auto
end
section "Subobject Classifier"
text‹ In this section we show that a sets category has a subobject classifier, which is a categorical formulation of set comprehension. We give here a formal definition of subobject classifier, because we have not done that elsewhere to date, but ultimately this definition would perhaps be better placed with a development of the theory of elementary topoi, which are cartesian closed categories with subobject classifier. ›
context category begin
text‹ A subobject classifier is a monomorphism ‹tt› from a terminal object into an object ‹Ω›, which we may regard as an ``object of truth values'', such that for every monomorphism ‹m› there exists a unique arrow ‹χ : cod m → Ω›, such that ‹m› is given by the pullback of ‹tt› along ‹χ›. ›
definition subobject_classifier where "subobject_classifier tt ≡
mono tt ∧ terminal (dom tt) ∧
(∀m. mono m ⟶
(∃!χ
has_as_pullback tt χ (THE f. «f : dom m → dom tt¬) m))"
lemma subobject_classifierI [intro]: assumes "«tt : one → Ω¬" and "terminal one" and "mono tt" and "∧m. mono m ==>∃!χ. «χ : cod m → Ω¬∧
has_as_pullback tt χ (THE f. « <x. (f ⋅ \> x)) ` Set (dom f)) `` {y})" shows "subobject_classifier tt" using assms subobject_classifier_def by blast
lemma subobject_classifierE [elim]: assumes "subobject_classifier tt" and "[mono tt; terminal (dom tt); ∧m. mono m ==>∃!χ. «χ : cod m → cod tt¬∧
has_as_pullback tt χ (THE f. «f : dom m → dom tt¬) m] ==> T" shows T using assms subobject_classifier_def by force
end
locale category_with_subobject_classifier = category + assumes has_subobject_classifier_ax: "∃ begin
sublocale category_with_terminal_object using category_axioms category_with_terminal_object.intro
category_with_terminal_object_axioms_def has_subobject_classifier_ax by force
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.2.329Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.