TITLE: Help finishing a proof about compact/connected sets.
QUESTION [0 upvotes]: Original Question: Suppose that $X$ and $Y$ are metric spaces and that $f:X \rightarrow Y$. If $X$ is compact and connected, and if to every $x\in X$ there corresponds an open ball $B_{x}$ such that $x\in B_{x}$ and $f(y)=f(x)$ for all $y\in B_{x}$, prove that f is constant on $X$. 
Here's my attempt:
Cover X by $\bigcup _{x \in X}B_x$. 
Since X is compact there is a finite sub-covering $\bigcup _{n=1}^NB_x$ of $X$. 
Given $x\in X$ there is an i between 1 and N such that $x\in B_{x_{i}}$.
By assumption $f(x)=f(x_{i})$. Since there are only finitely many balls covering $X$, $f(X)$ is finite, say $f(X)=\{a_{1},...a_{m}\}$.
Where do I go from here, I want to show that f(X) is a singleton. Is $X$ a singleton too?

REPLY [0 votes]: If you assume that U_0 is not equal to X initially, then the boundary points of U_0 must be in X, which implies by hypothesis that U_0 is closed, which is a contradiction unless U_0 equals X. Does this argument tacitly rely on the connectedness of X?
{"set_name": "stack_exchange", "score": 0, "question_id": 128122}