TITLE: Proving things about the function $f:\varnothing\to S$
QUESTION [5 upvotes]: If $S$ is any set, then the empty set is contained in it in a unique way. You could view the inclusion $\varnothing \subseteq S$ as the unique function from $f:\varnothing \to S$. 
The following seems true: 

The function $f$ is one-to-one, 
The function $f$ is onto if and only if $S=\varnothing$. 

Are statements 1 and 2 things that we simply believe, or can they be "proven"? Maybe I'm not formulating the question carefully. I feel like these things are easily proven from the definitions of the empty set and function, but I feel uneasy about it for some reason.
What do you think?

REPLY [4 votes]: Of course they can be proven.  
Does $f(x)=f(y)$ imply $x=y$ for each $x,y\in \emptyset$?  Yes, trivially: there are no elements and so this holds true vacuously. Hence, $f$ is injective.
$f[\emptyset]=\{ s\in S \mid \text{there exists $x\in \emptyset$ such that $f(x)=s$}\}$ is equal to the empty set because there is no $x\in \emptyset$.  Thus, $f$ is surjective only when $S=\emptyset$.
The definitions of injectivity and surjectivity continue to be well-defined no matter what the set or function.  While sometimes having things hold true (or otherwise) vacuously is a little strange, ultimately we're asking precise questions when we say "is $f$ injective or surjective" and we can apply the definitions of $\emptyset$ even if intuitively it might seem uncomfortable.
Because, as Thomas Andrews pointed out, vacuous truths are often an issue as far as intuition is concerned, perhaps some examples are in order to make it a little more comfortable.  

Suppose that I said "All the moons I own are made of cheese."  This would be a truth statement because, well, I don't own any moons, so whether or not they're made of cheese or not isn't important.  
A slightly more subtle example is the following: "every letter `z' in the last sentence is capitalized".  In this example, things are a little bit more reasonable, and the first intuition to try and deduce the truth value of this statement would be to look for capitalized z's in the mentioned sentence.  However, this isn't quite the right way: we would find that there are no capitalized z's in the sense (and so might think the statement false), but really what the sentence is saying is "if there is a z, then that z is capitalized".  There aren't any z's, so again, whether or not they are capitalized isn't necessary to consider.

Translating both of the above examples into more formal statements gives 
$$\forall \text{moons} ((\text{I own the moon})\rightarrow (\text{the moon is made of cheese}))$$
and
$$\forall \text{z} ((\text{z is in sentence})\rightarrow (\text{z is capitalized}))$$
In each case, we have a statement of the form $\forall x (P(x)\rightarrow Q(x))$.  So the issue in each of the cases is that $P(x)$ ends up being false for every $x$, and when that is the case, $\forall x (P(x)\rightarrow Q(x))$ is true.  
So essentially what's happening when we have a vacuous truth that arises from the empty set having no elements is that $P(x)$ is something like $x\in \emptyset$.  Then because this is always false, we find that $\forall x (x\in \emptyset \rightarrow Q(x))$ holds, no matter what $Q(x)$ is.  
For injectivity, we instead have 
$$\forall x (x\in \emptyset \rightarrow \forall y (((y\in \emptyset) \wedge (f(y)=f(x)))\rightarrow (y=x)))$$
so $P(x)$ is $x\in \emptyset$ and $Q(x)$ is $\forall y (((y\in \emptyset) \wedge (f(y)=f(x)))\rightarrow (y=x))$.
So really the intuition to take is that vacuous truth works because $P\rightarrow Q$ is true whenever $P$ is false, regardless of the truth of $Q$.