$\varnothing$ in the category of sets

Everything you said is correct. The only mistake is the final sentence, "$g$ is a morphism with two targets". Remember that a function of sets is a specified domain, codomain, and subset of their product. Most important for us here is that the codomain is specified too. For example, consider two maps $h\colon\mathbb{R}\to\mathbb{R}$ given by $x\mapsto x^2$, and $k\colon\mathbb{R}\to\mathbb{R}^{\geq 0}$ also given by $x\mapsto x^2.$ When viewed as subsets of $\mathbb{R}\times\mathbb{R}^{\geq0}$ (actually, $h$ is a subset of $\mathbb{R}\times\mathbb{R}$, but its inclusion factors through $\mathbb{R}\times\mathbb{R}^{\geq0}$), $h$ and $k$ are equal. However when viewed as functions they are distinct, because they have different codomains.

Similarly your function $g\colon\varnothing\to A$ is a subset (the empty subset) of $\varnothing\times A$, along with specified domain $\varnothing$, and specified codomain $A$. It is a morphism $\varnothing \to A$, not $\varnothing\to\varnothing.$ There is another map $\varnothing\to\varnothing$, but it not equal to $g$, since its codomain doesn't match, even though $g\subseteq A\times\varnothing=\varnothing$ and $1_\varnothing\subset\varnothing\times\varnothing=\varnothing$ are both just the empty set, hence equal as sets. The empty map $\varnothing\to\varnothing$ is however equal to the identity on $\varnothing,$ as you pointed out.


Categorical foundations are fundamentally different from set theoretic foundations (if you'll pardon the pun). Specifically, while in set theoretic foundations, every object is a set, in a category theoretic foundations, there are different classes of foundational objects, notably objects and morphisms.

Every morphism has a designated domain and codomain, so the fact that in $\mathbf{Set}$ the empty function is the empty set is largely irrelevant; the morphism from $\emptyset$ to $\{a\}$ is different to the morphism from $\emptyset$ to $\{0,1\}$ (even though they consist of the same sets of ordered pairs) since they have different codomains.

The same thing arises in many other contexts too. For example, the embedding of $\{a\}$ into $\{a,b\}$ is not the same categorical object as the identity map from $\{a\}$ to itself.

The question of when two morphisms are equal is central to category theory. Every diagram chase is essentially an argument that two compositions are in fact different representations of the same morphism. But the approach is genuinely different from the set theoretic setting.


Another way to think about it is that in a set theoretic foundations, it is the domain and range of a function that are most important. The codomain is more or less tacked on for convenience, and there is nothing stopping one function from having many possible codomains. In category theory, by contrast, it is the domain and codomain that are primitive.


The situation is very simple really and you already half-guessed it yourself.

A morphism $A \to B$ of the category $\mathrm{Set}$ is simply defined as the triple $\langle A,f,B \rangle$ where $f$ is a subset of $A \times B$ with total-functional properties (to each element of $A$ corresponds exactly one of $B$). If you omit the total-functional properties, then you define the category $\mathrm{Rel}$ of sets and relations. These are just definitions. You can easily check that these structures are indeed categories according to the definition of category. You may call the morphisms of $\mathrm{Set}$ functions if you like and probably nobody will shoot you, but bear in mind that they are different – yet related – things than the functions you learned before

So $\varnothing \to A$ is really $\langle \varnothing,\varnothing,A \rangle$ and $\varnothing \to B$ is really $\langle \varnothing,\varnothing,B \rangle$ and thus can be different.

Category theory can and usually is based on some set theory. Categories are just another type of mathematical structures like groups, rings, ect. They just happen to be more general.

You can find slightly different set theories on the market. Tarski-Grothendieck (TG) set theory is the one which gives you the most bang for your dollar, in my opinion. It is successfully used in the Mizar project to build (ie. express and prove) the whole edifice of mathematics in a formal and computer-checked way. Who can ask for more?

TG set theory has basically the usual axioms of other set theories (ZFC, NBG) with the addition of the TG axiom claiming (roughly) that any collection you can come up with, is contained in a larger collection called a universe.

Other foundations of mathematics are alternative, still experimental and certainly not mainstream. I would not bother with them as a beginner in category theory.