Topology - continuous functions I am answering the question:
Let $X = \{1, 2, 3, 4, 5\}$ with topology $\{\emptyset, X, \{1\}, \{3, 4\}, \{1, 3, 4\}\}$, and let $Y = \{A, B\}$ with topology $\{\emptyset, Y, \{A\}\}$. Find all continuous functions from $X$ to $Y$. How many functions from $X$ to $Y$ are there altogether?
This is what I have thus far:
Let $(X,\tau)$ and $(Y,\tau^\prime)$ be topological spaces. A function from $X$ to $Y$ is said to be continuous if given any open subset $U$ of $Y$, then $f^{-1}(U)$ is an open subset of $X$.
a.
Continuous functions from $X$ to $Y$ can be characterized as those that map open subsets of $X$ to open subsets to $Y$. In total, there exist $8$ continuous functions from $X$ to $Y$:
\begin{align*}
f&: \{{1}\} \rightarrow A\\
f&: \{{3, 4}\} \rightarrow A \\
f&: \{{1, 3, 4}\} \rightarrow A \\
f&: X \rightarrow A \\
f&: \{{1}\} \rightarrow Y \\
f&: \{{3, 4}\} \rightarrow Y \\
f&: \{{1, 3, 4}\} \rightarrow Y \\
f&: X \rightarrow Y
\end{align*}
My question is: how do I handle the empty set? I know that if I am mapping to or from the empty set, $X \times Y = \emptyset$, i.e. $\emptyset$ is the only subset of $X \times Y$. So, we shouldn't be able to map $\emptyset$ to a nonempty set, correct? And, should we be able to map a nonempty set to $\emptyset$? Thanks for the help y'all!
 A: The fact that the preimage of an open is open IS NOT equivalent to the fact that $f$ maps open sets to open sets. Such maps are called open maps. There exist continuous maps that are not open, open maps that are not continuous, open continuous maps and maps which are neither continuous nor open!
To find continuous maps from $X$ to $Y$ in your case amounts exactly to find all the possible preimages of $A$. Since $Y$ has only two elements, the preimage of $A$ determines uniquely the map. So there are exactly 5 continuous maps $X\to Y$. Two of them are the constant ones, the third is the one mapping $1$ to $A$ (and everything else to $B$), the fourth is the one mapping $3$ and $4$ to $A$ and the fifth maps $1$,$3$ and $4$ to $A$.
You don't have to care about $\varnothing$, because its preimage under any map is again $\varnothing$ which has to be open by definition of topology. In the same way, you don't have to care about the preimage of $Y$, which is always $X$.
A: Edit: First, let me clarify some notation and definitions that I will be using here. Suppose we have a set $X$ and a set $Y.$ Then we say that a subset $f$ of $X\times Y$ is a function from $X$ into $Y$--denoted $f:X\to Y$--if and only if for each $x\in X$ there is a unique $y\in Y$ such that $\langle x,y\rangle\in f$--and we call this unique $y$ by the name $f(x).$ Given $S\subseteq Y,$ the preimage of $S$ under $f$ will be denoted and defined by $$f^{-1}[S]:=\{x\in X:f(y)\in S\}.$$
If $X$ and $Y$ have been given topologies--say $\mathcal T_X$ and $\mathcal T_Y$, respectively--then we say that $f:X\to Y$ is continuous if and only if for each $U\in\mathcal T_Y$ we have $f^{-1}[U]\in\mathcal T_X.$ A few nice facts about preimages that will help for this problem (I leave them to you to verify, by definition of preimage and function):

Given any sets $X,Y$ and any function $f:X\to Y,$ we have $f^{-1}[\emptyset]=\emptyset$ and $f^{-1}[Y]=X.$

As a consequence of these facts, a function $f:X\to Y$ (where $X$ and $Y$ have been given topologies) will be continuous if and only if each non-trivial open subset of $Y$ has an open preimage under $f.$ For this particular example, this means that $f:X\to Y$ is continuous if and only if $$f^{-1}\bigl[\{A\}\bigr]\in\bigl\{\emptyset,X,\{1\},\{3,4\},\{1,3,4\}\bigr\}.$$
Now, as a rule, if we have some sets $X$ and $Y$ and some $f:X\to Y,$ and if $S$ is a proper subset of $Y,$ then knowing what $f^{-1}[S]$ is won't be enough to tell us how $f$ is defined. In fact, it will be enough if and only if $Y$ has at most two elements, and exactly one element more than $S.$ (Why? It's a nice exercise to prove this result.) Fortunately, in your particular example, $Y$ has exactly two elements, and exactly one element more than $\{A\}\subsetneq Y.$ So, determining the preimage of $\{A\}$ under $f$ is identical to determining $f.$
For instance, in order to have $f:X\to Y$ such that $f^{-1}\bigl[\{A\}\bigr]=\{1,3,4\},$ we must have $$f(x):=\begin{cases}A & \text{if }x=1,3,\text{ or }4\\B & \text{if }x=2\text{ or }5.\end{cases}$$ It should be clear that this function gives us the desired preimage, but why can't any other function $X\to Y$ give us the same preimage? Well, note that if $g:X\to Y,$ then $$g^{-1}\bigl[\{A\}\bigr]:=\bigl\{x\in X:g(x)\in\{A\}\bigr\}=\{x\in X:g(x)=A\}.$$ Thus, in order to have $g^{-1}\bigl[\{A\}\bigr]=\{1,3,4\},$ we need to know that $g(x)=A$ if and only if $x\in\{1,3,4\}.$ Knowing that $g(x)=A$ for all $x\in\{1,3,4\}$ determines $g(x)$ for most of our $x\in X,$ and knowing that $B$ is the only element of $Y$ that isn't equal to $A$ tells us that $g(x)=B$ for all $x\in X\setminus\{1,3,4\}=\{2,5\}.$ Hence, $g(x)=f(x)$ (where $f$ is as defined above) for all $x\in X.$
The other $4$ continuous functions $f:X\to Y$ are as follows:
$$f(x):=\begin{cases}A & \text{if }x=3\text{ or }4\\B & \text{if }x=1,2\text{ or }5\end{cases}$$
$$f(x):=\begin{cases}A & \text{if }x=1\\B & \text{if }x=2,3,4,\text{ or }5\end{cases}$$
$$f(x):=A\: (\text{for all }x\in X)$$
$$f(x):=B\: (\text{for all }x\in X)$$
I leave it to you to verify that $f^{-1}\bigl[\{A\}\bigr]$ is indeed open in each case.
