Question about composition of categories

45 Views Asked by At

I'm reading the following to get a high-level overview of categories.

http://en.wikibooks.org/wiki/Haskell/Category_theory

In this, they have this image:

the category

and the author makes this claim:

So which is the morphism $f \circ g?$ The only option is $\mathit{id}_A$. Similarly, we see that $g \circ f = \mathit{id}_B$.

Shouldn't this be the other way around? if $f: B \to A$ and $g: A \to B$ the result of $(f \circ g)(B)$ would be $\mathit{id}_B(B)$ right?

2

There are 2 best solutions below

1
On BEST ANSWER

If $f : B \to A$ and $g : A \to B$, then $f \circ g : A \to B \to A$. It's the usual convention for composition, there is nothing wrong here. Reread this line of the book:

  • A notion of composition of these morphisms. If $g:A \to B$ and $f:B \to C$ are two morphisms, they can be composed, resulting in a morphism $f\circ g:A \to C$.

Plug in $C = A$ and you find back that $f \circ g : A \to A$, not $B \to B$.

If you want to remember the order: in sets, $(f \circ g)(x)$ is defined to be $f(g(x))$ (easy to remember formula). So if $x \in A$, then $g$ must have domain $A$; and the codomain of $g$ must coincide with the domain of $f$, because $g(x)$ is taken as an input of $f$; finally the output is in the codomain of $f$. If you take all this into account, then $f \circ g$ has the same domain as $g$ and the same codomain as $f$.

0
On

It depends on the composition convention - in looks as if your source is composing functions from right to left, so $g\circ f$ means "first $f$ then $g$". You should try to find this explicitly stated, or look at some other examples in the book, to confirm this.

You shouldn't write $(f\circ g)(B)$; it makes it look like $B$ is an argument of the "function" $f\circ g$. Even if this was a category in which the objects are sets, and the morphisms are maps of sets, you would need to write $(f\circ g)(b)$ for $b\in B$, not $(f\circ g)(B)$.