Commit 2026-04-14 15:27 438f1347

View on Github →

refactor(CategoryTheory): one-field structure morphisms in the category of types (#36613) This PR refactors the category structure on types as follows: We define the one-field structure TypeCat.Fun to wrap a function between types, and a FunLike instance on it. Then we define a one-field structure TypeCat.Hom which wraps a Fun. The morphisms in the category Type u are defined to be TypeCat.Hom, and the FC parameter of the ConcreteCategory instance is TypeCat.Fun. This double nesting allows us to avoid defining a FunLike instance on bare functions, which would give two non-reducibly-defeq coercions from morphisms in Type u to functions. To promote a function to a morphism in this category, we provide the abbreviation TypeCat.ofHom f, as well as a corresponding notation ↾ f. (Entered as \upr.) In the process, we deprecate some declarations that were written specifically for the category of types, such as FunctorToType.map_comp_apply and others, which can now be generated by elementwise. We add a new file Mathlib/CategoryTheory/ConcreteCategory/Representable.lean, which provides some API for the situation when a functor postcomposed by a forgetful functor is representable (the general RepresentableBy API was already unpleasant to work with in this situation, and this PR made this worse, which is the reason for adding the file). We add a new file Mathlib/CartegoryTheory/Limits/ConcreteCategory/Filtered.lean, which provides analogues to some of the API in the CategoryTheory.Limits.Types.FilteredColimit namespace, for concrete categories for which the forgetful functor preserves filtered colimits.

Estimated changes

modified theorem CategoryTheory.types_comp
deleted theorem CategoryTheory.types_ext
deleted theorem CategoryTheory.types_hom
modified theorem CategoryTheory.types_id
deleted theorem Equiv.toIso_hom
deleted theorem Equiv.toIso_inv
added theorem TypeCat.Fun.coe_mk
added def TypeCat.Fun.comp
added def TypeCat.Fun.id
added theorem TypeCat.Fun.mk_apply
added structure TypeCat.Fun
added structure TypeCat.Hom
added theorem TypeCat.congr_arg
added def TypeCat.homEquiv
added theorem TypeCat.homEquiv_apply
added theorem TypeCat.hom_ofHom
added theorem TypeCat.ofHom_apply
added theorem TypeCat.ofHom_eq
added theorem TypeCat.ofHom_hom
modified def equivIsoIso