Let $(X,d)$ be a compact metric space. Let $f:X \rightarrow X$ be continuous. Fix a point $x_0 \in X$, and assume that $d(f(x),x_0) \geq 1$ whenever $x \in X$ is such that $d(x,x_0)=1$. Prove that $U\backslash f(U)$ is an open set in $X$, where $U=\{x \in X: d(x,x_0)<1\}$.
My attempt: We want to show that $U \backslash f(U)$ is an open set in $X$.
So, $U\cap f(U)= U \cap f(\bar{U})\implies U^c\cup f(U)^c= U^c \cup f(\bar{U})^c \implies U \cap (U^c\cup f(U)^c)=U \cap( U^c \cup f(\bar{U})^c)$.
This implies, $U \cap (f(U)^c)=U \cap(f(\bar{U})^c)$.
Since, $U$ is an open set, and $\bar{U}$ is compact set. Since function $f$ is continuous; this implies $f(\bar{U})$ is compact. (because, continuous image of compact set is compact).
This implies, $f(\bar{U})^c$ is open. Hence, $U \backslash f(U)$ is open.
Is my attempt correct?
It looks like a nice proof to me.
If you are planning to submit this (for example if it's homework) then I suggest some improvements:
Clarify the details around Berci's question. This is a subtlety that could be missed.
Make a note when you use "compact implies closed".
Clarify the sentence "Since, $U$ is an open set, and $\bar{U}$ is compact set." It's not clear what the purpose of this sentence is. If you are just noting that $\bar{U}$ is compact then saying $U$ is open is irrelevant. You also should clarify how you know $\bar{U}$ is compact. It should be clear in your proof where you use the assumption that $X$ is compact.