What is the formal definition of a dual category?

I'm reading this book as an introduction to category and I have a problem with the definition of the dual category given on page 25. The right way to get the dual category can be described by turning around arrows and permuting the order of their composition. However I don't know how this works out with the statement

$$\text{hom}_{\bf{A^{OP}}}(A,B)=\text{hom}_{\bf{A}}(B,A).$$

The set of morphisms $\text{hom}_{\bf{A}}(B,A)$ is already defined and the category $\bf{A}^{OP}$ is sopposed to contain morphisms, which are turned around, i.e. morphisms with different domain and codomain. How can these new ones equal the one from the first category? I remember reading this before in a book, and although the english wikipedia doesn't use this expression, the russian (?) one seems to use this definition as well.

So say I have a category $\bf{C}$ with only two objects $a,b$, as well as a single morphism $f$ from $a$ to $b$. From the description I think the dual category $\bf{C}^{OP}$ is the one with $a,b$ and an arrow from $b$ to $a$. How does the formula work if this new morphism isn't contained in $\bf{C}$, so that $\text{hom}_{\bf{C}}(b,a)$ is essentially empty?

-
The equal sign means that there is a natural identification between the two hom-sets (given by reversing the arrow back). That's all. –  Qiaochu Yuan Dec 25 '11 at 21:58
Just like two sets can contain the same object, two categories can have the same morphism; and it does not have to be between the same objects. –  sdcvvc Dec 25 '11 at 22:04
@sdcvvc: I disagree. Thinking like that is not thinking categorically. The hom-sets in two different categories are two different types of mathematical objects, and it shouldn't make sense to directly compare them for equality. –  Qiaochu Yuan Dec 25 '11 at 22:05
@Qiaochu: It depends on the way of thinking. Formally you can define them to be equal (just like you can define $(x,y)=\{\{x,y\},\{y\}\}$ on formal level). You don't have to do this, but then, you have still to tell what exactly $\text{hom}_{\bf{A^{OP}}}(A,B)$ is, or what is that "natural identification" etc. –  sdcvvc Dec 25 '11 at 22:20
I hope you didn't disapprove if I interfere in your speech: I think that the objection of sdcvvc is legitimate because while is true that this is thinking categorically it is set theoretic thinking, and because the definitions used since here are think in a set theory all the objections hold. –  Giorgio Mossa Dec 25 '11 at 23:36
show 1 more comment

The point is that source and target of morphisms aren't an intrinsic property of the morphisms themselves, but are more like a property of the category.

In general you can see the same element of a set as a morphism for two different categories and this morphism can have different source and target in these categories. When you say that $\hom_{\mathbf A^\text{op}}(A,B)=\hom_\mathbf{A}(B,A)$, you're building up a new category in which the morphisms are the same elements/morphisms of $\mathbf C$ but in this new category you see these morphisms with reversed direction.

If you prefer you can think of the opposite category of category $\mathbf C$ as a new category such that for each morphism $f \colon A \to B$ in $\mathbf C$ there exists a unique $f^\text{op} \colon B \to A$ in $\mathbf C$ and such that the composition is such that $g^\text{op} \circ f^\text{op}=(f \circ g)^\text{op}$, where the composition on the left is the one in the opposite category, while the one on the right is that of the category $\mathbf C$. In this way you have defined the opposite category $\mathbf C^\text{op}$ up to isomorphism, thus you can think of the definition that you gave as a model, i.e. a concrete representation, of the opposite category.

Hope this can help.

-
I think I get the picture, but the first sentence is strange. If I have a function like $f(x,y):=e^{x-y}$ then isn't the source and target (some spaces) pretty much encoded in the function itself? And by "same element of a set" you want to point out that it's just one right? –  Nikolaj K. Dec 25 '11 at 23:03
Nikolaj: Even though $f$ might be a function $\mathbb R \times \mathbb R \to \mathbb R$, in any arbitrary category $A$ it does not have to be a morphism between those two objects. You can create a category out of any two objects $a,b$ and make $f$ a morphism between them. In fact, the morphisms need not be functions at all. In category theory the exact nature of morphisms is not important (just like in group theory, you do not care about exact nature of objects in a group, it's only up to isomorphism). –  sdcvvc Dec 25 '11 at 23:33
@sdcvvc: Yeah, they don't have to be functions, but that doesn't really answer my question. In my example, if the objects are $\mathbb{R}$ etc. as you say and if I define my function $f$ as above, it seems to me that $f$ already says everything about source and target. How is this not intrinsic to it? –  Nikolaj K. Dec 25 '11 at 23:41
As I and sdcvvc have already pointed out source and target of a morphism aren't inherently connected to the said morphism, you have to think in a more abstract way. Remeber that morphisms doesn't have to be functions (or structure preserving functions), they are simply some elements of a given collection or type on which we pose some structure (we give to each of them a source and a target, a left and right identity and composites): for instance think to monoids that are just categories with one object. –  Giorgio Mossa Dec 25 '11 at 23:47
@NikolajKunst. Even your particular function $f(x,y) = e^{x-y}$, thought as a morphism in the category of topological spaces, has no intrinsic domain and codomain. You can say that the domain is $\mathbb{R}^2$ (since it is defined over all couples of real numbers) and the codomain is $\mathbb{R}$ (as sdcvvc says). But, in fact, the range of $f$ is just the positive real numbers, isn't it? And I could thought, if I want, $f$ as a function with domain the unit disk and codomain, say, $\mathbb{R}^2$. Why not? The domain and codomain of a morphism are part of the morphism. –  a.r. Dec 26 '11 at 8:51
"To each category $\cal{C}$ we also associate the opposite category $\cal{C}^{op}$. The objects of $\cal{C}^{op}$ are the objects of $\cal{C}$, the arrows of $\cal{C}^{op}$ are arrows $f^{op}$ in one-one correspondence $f \mapsto f^{op}$ with the arrows $f$ of $\cal{C}$. For each arrow $f: a \longrightarrow b$ of $\cal{C}$, the domain and codomain of the corresponding arrow $f^{op}$ are as in $f^{op}: b \longrightarrow a$ (the direction reversed). The composite $f^{op}g^{op} = (gf)^{op}$ is defined in $\cal{C}^{op}$ exactly when the composite $gf$ is defined in $\cal{C}$.