**This is a development version of this entry. It might change over time and is not stable. Please refer to release versions for citations.**

### Abstract

This article attempts to develop a usable framework for doing category theory in Isabelle/HOL. Our point of view, which to some extent differs from that of the previous AFP articles on the subject, is to try to explore how category theory can be done efficaciously within HOL, rather than trying to match exactly the way things are done using a traditional approach. To this end, we define the notion of category in an "object-free" style, in which a category is represented by a single partial composition operation on arrows. This way of defining categories provides some advantages in the context of HOL, including the ability to avoid the use of records and the possibility of defining functors and natural transformations simply as certain functions on arrows, rather than as composite objects. We define various constructions associated with the basic notions, including: dual category, product category, functor category, discrete category, free category, functor composition, and horizontal and vertical composite of natural transformations. A "set category" locale is defined that axiomatizes the notion "category of all sets at a type and all functions between them," and a fairly extensive set of properties of set categories is derived from the locale assumptions. The notion of a set category is used to prove the Yoneda Lemma in a general setting of a category equipped with a "hom embedding," which maps arrows of the category to the "universe" of the set category. We also give a treatment of adjunctions, defining adjunctions via left and right adjoint functors, natural bijections between hom-sets, and unit and counit natural transformations, and showing the equivalence of these definitions. We also develop the theory of limits, including representations of functors, diagrams and cones, and diagonal functors. We show that right adjoint functors preserve limits, and that limits can be constructed via products and equalizers. We characterize the conditions under which limits exist in a set category. We also examine the case of limits in a functor category, ultimately culminating in a proof that the Yoneda embedding preserves limits.

Revisions made subsequent to the first version of this article added material on equivalence of categories, cartesian categories, categories with pullbacks, categories with finite limits, and cartesian closed categories. A construction was given of the category of hereditarily finite sets and functions between them, and it was shown that this category is cartesian closed. Using "ZFC_in_HOL", a construction was also given of the (large) category of small sets and functions between them, and it was shown that this category is small-complete.

### License

### History

- July 22, 2021
- Minor changes to sublocale declarations related to functor/natural transformation to
avoid issues with global interpretations reported 2/2/2021 by Filip Smola.
(revision 49d3aa43c180)
- November 4, 2020
- Minor modifications and extensions made in conjunction with the addition
of new material to Bicategory.
(revision 472cb2268826)

- July 10, 2020
- Added new material, mostly centered around cartesian categories.
(revision 06640f317a79)

- February 15, 2020
- Move ConcreteCategory.thy from Bicategory to Category3 and use it systematically.
Make other minor improvements throughout.
(revision a51840d36867)

- May 29, 2018
- Revised axioms for the category locale. Introduced notation for composition and "in hom".
(revision 8318366d4575)

### Topics

### Session Category3

- Category
- DualCategory
- ConcreteCategory
- EpiMonoIso
- InitialTerminal
- Functor
- Subcategory
- SetCategory
- SetCat
- ProductCategory
- NaturalTransformation
- BinaryFunctor
- FunctorCategory
- Yoneda
- Adjunction
- EquivalenceOfCategories
- FreeCategory
- DiscreteCategory
- Limit
- CategoryWithPullbacks
- CartesianCategory
- CategoryWithFiniteLimits
- CartesianClosedCategory
- HFSetCat
- ZFC_SetCat