In light of answers provided here (Confusion with the definition of a "Set Function" in the context of ZFC) and here (How to define a function when you are unsure if the codomain exists as a set?), which effectively established the difference between class functions and set functions, it dawns on me that I now have no idea how the concept of surjectivity finds its way into ZFC.
In the book that I have been reading (Terrance Tao's Analysis I), there is a section about functions where the author writes:
"Informally, a function $f:X \to Y$ from one set $X$ to another set $Y$ is an operation which assigns to each element $x$ in $X$, a single element $f(x)$ to $Y$."
Having learned that a "set function" is defined as the set of all ordered pairs that satisfy a class function, I think I understand why Tao uses the word "informally" in his description of $f$ (because there is no explicit concept of codomain built into a set function). However, the definition of set function has made me revisit the idea of surjectivity, which, using the basis of the above informal definition of a function, Tao defines as:
"A function $f$ is surjective if every element in $Y$ comes from applying $f$ to some element in $X$."
Clearly, Tao's definition of surjectivity is based on his informal definition of a function. For Tao's informal definition, the "codomain" is baked into the idea of the function. For the more formal definition of a set function, however, there is no codomain (only a domain for which the class function "acts" on). Later on in the book, Tao provides an alternative definition of function:
"One can define a function $f:X \to Y$ to be an ordered triple $(X,Y,G)$ [...], $G=\{(x,f(x)):x \in X\}$ that obeys the vertical line test, [...]."
For this definition of function, it seems like $G$ is actually behaving as the "set function".
So my question is basically as follows: where is the $Y$ coming from in the context of set functions? I can define the range of a set function $f$ as:
$$ \operatorname{ran}(f) = \{y\in \cup\cup f: \exists x \;(x,y)\in f \}.$$
But if I set this equal to $Y$, then my functions are always surjective. At which point, I don't understand the point of even defining surjectivity in the first place. What is the motivation / how does one decide to choose a codomain that is not equal to the range?
Cheers~