From my text book, it says that for a constant function $f(x)=c,x\in E, c\in\mathbb{R}\cup \{-\infty,+\infty\} $ is measurable.
The prove is saying that if $a>c$ then $\forall x\in E\rightarrow f(x)=c<a$, so $f^{-1}((a,+\infty])=\varnothing$, and $\varnothing$ is definitely an element of borel set in $E$.
On the contrary, it can be prove that $f^{-1}((a,+\infty])=E$.
Combining the above 2, we can say that it is measurable function.
However, this prove based on a condition that $E$ is the full set of its topology.
So if $E\subset X$ and $<X,T>$ is an topology, then $\varnothing, X$ has to be an open set, but $E$ does not have to be.
Thus $E$ can be out side of borel set of $X$, which actually make $f(x)=c$ not measurable??
Thus I would like to ask if I'm right and if yes, then why the text book commit the fact that constant function is measurable??
When people say $f : X \to Y$, by definition of this notation, $\text{dom}(f) = X$. With that being said, the definition of a measurable function $f: X \to \mathbb{R}$ has nothing to do with the topology on $X$ (you do not need any topology of $X$). All you need is a $\sigma$-algebra $\mathcal{A}$ on $X$. $f$ is measurable if for every $a \in \mathbb{R}$, $f^{-1}((a, \infty)) \in \mathcal{A}.$
What is true is that if $X$ does happen to have a topology, one natural $\sigma$-algebra is the Borel. But you can totally have others.
The book is correct. No matter what $\sigma$-algebra you have on $X$, a constant function will be measurable.