[Math] The empty function and constants

category-theoryelementary-set-theory

On Wikipedia and also after searching this forum there is stated that for each $A$ there exists a unique function $f : \emptyset \to A$ called the empty function for $A$.

In the theory of Algebraic Data Types (ADT's) and in functional programming languages (like Haskell) where one paradigma is "everything is a function" it is common to interpret constants as $0$-ary functions. A nullary function is just a function of the form $f : \emptyset \to A$, and so for every $A$ there must be such a function under this interpretation (so $|A|$ such functions) and this contradicts the uniques of one empty function for every $A$.

Also on Wikipedia I read.

The n-ary cartesian power of a set X is isomorphic to the space of functions from an n-element set to X. As a special case, the 0-ary cartesian power of X may be taken to be a singleton set, corresponding to the empty function with codomain X.

So $X^0 = \{ x \}$, but otherwise if I interpret $Y^X$ as the set of functions from $X$ to $Y$ and interpret $X^n$ as $X^{\{1,\ldots,n\}}$ then $X^0 = X^{\emptyset} = \{ f : \emptyset \to X \}$? Could someone please clarify, I am confused…

EDIT: Okay guess I got it now, but still confused. For every $A$ there is a unique $f : \emptyset \to A$, but that is not equal to $f : A^0 \to A$, with $A^0 = \{ f : \emptyset \to A \}$ there are exactly $|A|$ functions $f : A^0 \to A$. But then I guess the following one statement about the nullary product on Wikipedia is wrong, that if the index set $I$ is empty, that
$$
\prod_{\emptyset} = \{ f_{\emptyset} : \emptyset \to \emptyset \}.
$$
because there the set over which the product is built is lost?

Best Answer

An $n$-any function on a set $X$ is a function $X^n\to X$, where $X$ is the $n$-fold cartesian product of $X$ with itself. Thus, a $0$-ary function is a function $X^0\to X$, not $\emptyset \to X$. So the question is to figure out what $X^0$ is. One way to reason about what it should be is to note that $X^n\times X^m$ is essentially the same as $X^{n+m}$ (as most people will agree is true for all $m,n>0$. To make this true also for $n=0$, we need, e.g., that $X^0\times X^m$ is essentially the same as $X^m$. Which set has $Y$ has the property that $Y\times X^m$ is essentially just $X^m$ (for $X\ne \emptyset$)? Well, a moment's thought should reveal that the answer is that $Y$ can be any singleton set.

So, to preserve some basic realizations about the cartesian product of sets, it makes sense to define $X^0$ (for nonempty $X$) to be a singleton set (whichever one you want).

Another way to argue is categorically. The cartesian product of sets is a special case of the notion of categorical product, and $X^0$ corresponds to an empty product. The universal property for the empty product is just a terminal object in the category. The terminal objects in the category of sets are precisely the singletons.

I just saw your edit: Notice that the conventions agree: $X^0=X^\emptyset =\{\emptyset \to X\}$ is a singleton set.