Canonical: https://knowlpedia.com/algebra-category-theory/functor/

# Functor

A map between categories that preserves identities and composition.

Let \(\mathcal C,\mathcal D\) be [categories](https://knowlpedia.com/algebra-category-theory/category/).

A (covariant) **functor** \(F:\mathcal C\to\mathcal D\) consists of:
1. an assignment on [objects](https://knowlpedia.com/algebra-category-theory/object/): for each \(A\in\mathcal C\), an object \(F(A)\in\mathcal D\);
2. an assignment on [morphisms](https://knowlpedia.com/algebra-category-theory/morphism/): for each morphism \(f:A\to B\) in \(\mathcal C\), a morphism
   \[
   F(f):F(A)\to F(B)
   \]
   in \(\mathcal D\);

such that the following axioms hold:
- (**identity preservation**) for every object \(A\),
  \[
  F(\mathrm{id}_A)=\mathrm{id}_{F(A)},
  \]
  where \(\mathrm{id}_A\) is the [identity morphism](https://knowlpedia.com/algebra-category-theory/identity-morphism/);
- (**composition preservation**) for every composable pair \(A\xrightarrow{f}B\xrightarrow{g}C\) in \(\mathcal C\),
  \[
  F(g\circ f)=F(g)\circ F(f),
  \]
  where \(\circ\) denotes [composition](https://knowlpedia.com/algebra-category-theory/composition-category/) in the relevant category.

## Variants

A [contravariant functor](https://knowlpedia.com/algebra-category-theory/contravariant-functor/) \(\mathcal C\to\mathcal D\) is the same thing as a covariant functor \(\mathcal C^{\mathrm{op}}\to\mathcal D\), where \(\mathcal C^{\mathrm{op}}\) is the [opposite category](https://knowlpedia.com/algebra-category-theory/opposite-category/). Functors can be compared by [natural transformations](https://knowlpedia.com/algebra-category-theory/natural-transformation/).

## Examples

1. **Forgetful functor \(\mathbf{Grp}\to\mathbf{Set}\):**
   Send a group \(G\) to its underlying set \(U(G)\), and a group homomorphism \(\varphi:G\to H\) to the underlying [function](https://knowlpedia.com/shared-foundations/function/) \(U(\varphi):U(G)\to U(H)\).
   This preserves identity maps and composition, hence is a functor.

2. **Free abelian group functor \(\mathbf{Set}\to\mathbf{Ab}\):**
   Send a set \(X\) to the free abelian group \(\mathbb Z[X]\) generated by \(X\), and a function \(f:X\to Y\) to the induced homomorphism \(\mathbb Z[X]\to \mathbb Z[Y]\).
   This is a functor (and is left adjoint to the forgetful functor \(\mathbf{Ab}\to\mathbf{Set}\); see [adjoint functors](https://knowlpedia.com/algebra-category-theory/adjoint-functors/)).

3. **Representable hom-functor:** Fix an object \(A\in\mathcal C\).
   The assignment \(X\mapsto \mathrm{Hom}_{\mathcal C}(A,X)\) defines a functor \(\mathcal C\to\mathbf{Set}\), called a [representable functor](https://knowlpedia.com/algebra-category-theory/representable-functor/) (covariant in \(X\)).
   Dually, \(X\mapsto \mathrm{Hom}_{\mathcal C}(X,A)\) is a functor \(\mathcal C^{\mathrm{op}}\to\mathbf{Set}\).
