Functor (source code)

= Functor
{title2=$F:\mathcal C\to\mathcal D$}
{wiki}

A functor assigns an <object of a category> $F(A)$ to each object $A$ and a <categorical morphism> $F(f):F(A)\to F(B)$ to each arrow $f:A\to B$. It preserves the rules for composing arrows:
$$
F(1_A)=1_{F(A)},\qquad F(g\circ f)=F(g)\circ F(f).
$$
For example, the <forgetful functor> from the <category of groups> to the <Category of sets> keeps the underlying <sets> and maps of elements while forgetting the group operations. A <group homomorphism> remains a <function>, and composing the underlying <functions> gives the underlying map of the composite <group homomorphism>.

Another example sends a <set> $X$ to its <power set> $\mathcal P(X)$. It sends a <function> $f:X\to Y$ to the <function> $\mathcal P(f):\mathcal P(X)\to\mathcal P(Y)$ defined by $S\mapsto f(S)$, the <image> of the <subset> $S$. For $f(x)=x+1$ and $g(x)=2x$, the subset $\{0,2\}$ goes to $\{1,3\}$ and then $\{2,6\}$; applying the composite $g\circ f$ directly also gives $\{2,6\}$. The equality of these routes expresses preservation of <composition in a category>.