# Is the function constant given these constraints2

This question is inspired by this question.

Let $f\colon S_1\rightarrow S_2$ for some topological spaces $S_1,S_2$. Suppose that for every $x_0\in S_1$ there exists an open set $U\subset S_1$, such that $\forall x\in U, f(x)=f(x_0)$.

What are the sufficient and necessary conditions on $S_1$, that $f$ is constant?

As shown in the previous question:

Necessary conditions are: $S_1$ is connected

Sufficient condition: $S_1$ is pathconnected

$S_1$ being connected is both, sufficient and necessary. That it's necessary has already been showed.
Let $y_0\in f(S_1)$. Consider the set $$A = \bigcup_{x\in f^{-1}(y_0)}U_x$$ Where $U_x$ is the open set containing $x$, s.t. $f|_U$ is constant. $A$ is open, as it's the union of open sets. Furthermore note $A=f^{-1}(y_0)$. A similar set can be constructed: $$B = \bigcup_{x\notin f^{-1}(y_0)}U_x$$ By construction $y_0\notin f(B)$. Furthermore $A\cup B=S_1$ and both are open. Which is a contradiction.