TITLE: Does there exist a function $f : X \to Y$ such that $f \in Y$?
QUESTION [7 upvotes]: Does there exist a function $f : X \to Y$ such that $f \in Y$? 

I think this is related to Russell's paradox, but I'm not exactly sure how.

Added Later: As Brian points out, given any function $f : X \to Y_0$, we can just add $f$ to the codomain, that is $f : X \to Y_0\cup\{f\}$ is a function which satisfies my initial request.
However, what if we try to find a surjective function $f : X \to Y$ such that $f \in Y$?

REPLY [11 votes]: Let $V_\omega$ be the set of hereditarily finite sets (i.e. sets which are finite, and all their elements are finite, and so on). It is immediate from this definition that if $x\in V_\omega$ and $y\in x$ then $y\in V_\omega$, and if $x\subseteq V_\omega$ is finite, then $x\in V_\omega$.
It's not hard to show that if $X\in V_\omega$ then $\mathcal P(X)\in V_\omega$, and if $X,Y\in V_\omega$ then $X\times Y\in V_\omega$.
Take any set $X\in V_\omega$, then any function $f$ from $X$ into $V_\omega$ is actually a function into a finite subset of $V_\omega$, therefore there exists a finite $Y\in V_\omega$, such that $f\subseteq X\times Y$. Therefore $f\in V_\omega$.

For the addition, suppose that $f\colon X\to Y$ and $f\in Y$. If there exists some $x\in X$ such that $\langle x,f\rangle\in f$, then this a contradiction to the axiom of regularity because $\langle x,f\rangle =\{\{x\},\{x,f\}\}$ by the Kuratowski definition of an ordered pair, because this  means that $$f\in\{x,f\}\in\langle x,f\rangle\in f.$$
In particular $f$ cannot be surjective.
Note that regularity is necessary for this proof, otherwise we can have a set $X=\{X\}$. Note that in this case: $$\langle X,X\rangle=\{\{X\},\{X,X\}\}=\{\{X\}\}=\{X\}=X.$$
Therefore $X\times X=X$ which is the identity function from $X$ onto itself.