39

As it is, what is the difference between functor and function? As far as I know, they look really similar.

And is functor used in set theory? I know that function is used in set theory.

Thanks.

Asaf Karagila
  • 393,674
user30272
  • 959
  • 6
  • 8
  • 27
    A function assigns to every element of a set $X$ an element of a set $Y$. A functor assigns to every object of a category $C$ an object of a category $D$ and also assigns to every morphism in $C$ a morphism in $D$ in a way compatible with sources, targets, and composition. – Qiaochu Yuan May 07 '12 at 05:14

2 Answers2

33

To elaborate on Qiaochu's comment:

  • A set $X$, barren of additional structure, is comprised solely of elements $x\in X$. A function from one set to another merely sends elements of the first to elements of the second.
  • A category $\cal C$ is comprised of a class of objects $\mathrm{ob}(\cal C)$, and between any two objects $A,B$ a class of morphisms (or "arrows") denoted $\hom(A,B)$. These classes can be "bigger" than sets too. The objects $A,B$ need not be distinct; there is always the identity morphism $\mathrm{id}_A\in\hom(A,A)$, which is defined so that $f\circ\mathrm{id}_A=f$ and $\mathrm{id}_A\circ g=g$ for any $f\in\hom(A,\cdot)$ and $g\in\hom(\cdot,A)$.

A (covariant) functor $F:\cal C\to D$ of categories sends objects of $\cal C$ to those of $\cal D$, and similarly morphisms in $\cal C$ to morphisms of $\cal D$, such that the following three hold true:

  1. Identities are preserved: $F\,\mathrm{id}_A=\mathrm{id}_{FA}$.
  2. Sources and targets are preserved: If $A\xrightarrow{f}B$, then $FA\xrightarrow{Ff}FB$.
  3. Composition is preserved: If $A\xrightarrow{f}B\xrightarrow{g}C$, then $FA\xrightarrow{Ff}FB\xrightarrow{Fg}FC$.

Note that the functor sends an object $A$ to $FA$ and morphism $f$ to $Ff$; this is our given notational convention. Alternatively, the latter two may be stated non-diagramatically:

$~~$ 2. If $f\in\hom(A,B)$ then $Ff\in\hom(FA,FB)$.

$~~$ 3. If $f\in\hom(A,B)$ and $g\in\hom(B,C)$, then $F(g\circ f)=Fg\circ Ff$ inside $\cal D$. (Note the order.)

These properties ensure that commutative diagrams are preserved by functors. A contra${}$variant functor is defined similarly, except order of composition is reversed, ie $F(g\circ f)=Ff\circ Fg$ in $\cal D$.

So, like functions between sets, functors map the entities inside one category to another. The difference is that categories have more structure than sets, and indeed can be "bigger" than sets, and further that functors must preserve the internal structure of the categories.

anon
  • 151,657
  • I always wondered... Thanks for illuminating. – MathematicalOrchid May 07 '12 at 09:32
  • Could you give an example of how the first can be violated? I'm having trouble seeing how that can ever be false, regardless of the mapping. – fpf3 Jun 14 '19 at 13:45
  • 1
    @FredFrey The "identities are preserved" rule? Consider the category with exactly one object $A$ and exactly one non-identity arrow $a$, with $a \circ a = a$. Then the mapping which sends $A$ to $A$, and sends both $\text{id}_A$ and $a$ to $a$, fails to preserve identities, but satisfies the other two rules. – Tanner Swett Aug 02 '19 at 20:53
  • Does $f\circ\mathrm{id}_A$ mean "the composition of $f$ and $\mathrm{id}_A$"? 2. Does the $\cdot$ in $g\in\hom(\cdot,A)$ mean "any object?"
  • – jchook Sep 02 '19 at 00:06
  • 1
    @jchook Yes. ${}$ – anon Dec 09 '19 at 20:44
  • Very clear explanations. – maoyang Aug 05 '22 at 05:21