# Why do we write $f : X \rightarrow Y$ as opposed to $f \in X \rightarrow Y$.

I've always been taught to write $f : X \rightarrow Y$ as opposed to $f \in X \rightarrow Y$. This seems weird though, since $X \rightarrow Y$ can be viewed as the set of all functions with source $X$ and target $Y$, in which case the notation $f \in X \rightarrow Y$ has exactly its intended meaning.

Why do we write $f : X \rightarrow Y$? Is it habit? Notational prettiness? Historical accident?

Related. In category theory, we write $\mathrm{Hom}(X,Y)$ for the set of all arrows $X \rightarrow Y.$ Why do we not write $X \rightarrow Y$ for this set? Again, is this just historical inertia, or is there something deeper going on?

-
Who is "viewing X→Y as the set of all such functions with source X and target Y"? I thought this set was $Y^X$. –  Did Nov 29 '13 at 20:44
But $X\to Y$ is not used to represent the set of functions from $X$ to $Y$, so the notation $f\in X\to Y$ can’t be justified on that basis. (I believe that there are some modern mathematical contexts in which the notation $[X\to Y]$ is used, but they’re limited.) The usual notations for that set of functions are $Y^X$ or, better, ${}^XY$. –  Brian M. Scott Nov 29 '13 at 20:45
Personally, I write $f : X \to Y$ because I'm a type theorist not a set theorist :P –  Ben Millwood Nov 29 '13 at 20:55
What kind of answer are you looking for with this question, exactly? –  Najib Idrissi Nov 29 '13 at 23:18
I don't understand what you mean. "Fails to generalize nicely": do you mean would there be problems if we wrote $X \to Y$ instead of $\mathrm{Hom}(X,Y)$? It's a bit clunky with respect to operator priority, but otherwise no, what kind of problem could there be? It's just slightly different notation –  Najib Idrissi Nov 29 '13 at 23:22

There would be at least two problems with the notation $f \in X \to Y$ instead of $f : X\to Y$ to mean "$f$ is a function from $X$ to $Y$."
1. In general it's bad for clarity to write things that have initial segments that mean unrelated things. Here "$f \in X$" is an initial segment of "$f \in X \to Y$" and if $X$ is a long expression, the reader might be surprised upon reaching the arrow and need to go back and re-interpret what came before it in light of what is ultimately claimed about the relationship between $f$ and $X$.
2. The arrow is also used sometimes for other things such as logical implication and convergence, so authors should make sure to provide contextual clues that enable the reader to resolve the ambiguity. The colon in the expression $f:X \to Y$ helps the reader understand what the arrow means. On the other hand, the notation "$f \in X \to Y$" is bad because $f \in X$ could be interpreted as a proposition, which is consistent with the use of "$\to$" to mean logical implication.
Yes, and imagine a sequence of functions from $x_n$ to $x$. $f_n\in x_n\to x$. As $n\to\infty$, $f_n\to f$ pointwise... –  Asaf Karagila Nov 29 '13 at 23:53
Or, you know, worse. Consider $\varphi$ and $\psi$ to be two sets, now consider the following: $$f\in\varphi\to\psi\leftrightarrow\forall x\in\varphi\exists!y\in\psi:\langle x,y\rangle\in f$$ It's fun to come up with ways to make this notation very hard to parse! But I'll stop here (unless I come up with an amazing example next, which is unlikely). –  Asaf Karagila Nov 29 '13 at 23:57
@Asaf Ack! Well, that's also a reason not to use $\varphi$ and $\psi$ as variable symbols in set theory. –  Trevor Wilson Nov 30 '13 at 0:01