Module docstring
{"# Concrete categories
A concrete category is a category C where the objects and morphisms correspond with types and
(bundled) functions between these types. We define concrete categories using
class ConcreteCategory. To convert an object to a type, write ToHom. To convert a morphism
to a (bundled) function, write hom.
Each concrete category C comes with a canonical faithful functor forget C : C ⥤ Type*,
see class HasForget. In particular, we impose no restrictions on the category C, so Type
has the identity forgetful functor.
We say that a concrete category C admits a forgetful functor to a concrete category D, if it
has a functor forget₂ C D : C ⥤ D such that (forget₂ C D) ⋙ (forget D) = forget C, see
class HasForget₂. Due to Faithful.div_comp, it suffices to verify that forget₂.obj and
forget₂.map agree with the equality above; then forget₂ will satisfy the functor laws
automatically, see HasForget₂.mk'.
Two classes helping construct concrete categories in the two most
common cases are provided in the files BundledHom and
UnbundledHom, see their documentation for details.
Implementation notes
We are currently switching over from HasForget to a new class ConcreteCategory,
see Zulip thread: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Concrete.20category.20class.20redesign
Previously, ConcreteCategory had the same definition as now HasForget; the coercion of
objects/morphisms to types/functions was defined as (forget C).obj and (forget C).map
respectively. This leads to defeq issues since existing CoeFun and FunLike instances provide
their own casts. We replace this with a less bundled ConcreteCategory that does not directly
use these coercions.
We do not use CoeSort to convert objects in a concrete category to types, since this would lead
to elaboration mismatches between results taking a [ConcreteCategory C] instance and specific
types C that hold a ConcreteCategory C instance: the first gets a literal CoeSort.coe and
the second gets unfolded to the actual coe field.
ToType and ToHom are abbrevs so that we do not need to copy over instances such as Ring
or RingHomClass respectively.
Since X → Y is not a FunLike, the category of types is not a ConcreteCategory, but it does
have a HasForget instance.
References
See [Ahrens and Lumsdaine, Displayed Categories][ahrens2017] for related work. "}