If every real valued continuous function on $X$ is uniformly continuous , then is every continuous function to any metric space uniformly continuous?
Let $X$ be a metric space such that every continuous function $f:X \to \mathbb R$ is uniformly continuous ( here $\mathbb R$ is equipped with the standard euclidean metric ) , then is it true that for any metric space $Y$ , every continuous function $f:X \to Y$ is uniformly continuous ?
I found a lot of stuff about the subject, so this answer will be rewritten too.
It seems the following.
We can answer your question positively via the following Proposition 1. Nevertheless, I am still thinking about another characterization, which will tell us more about a structure of the space $X$. We shall need the following definitions.
A subset $A$ of a metric space $(X,\rho)$ is uniformly discrete, if there exists $\delta>0$ such that $\rho(x,y)>\delta$ for each different points $x,y\in A$. It is easy to check that a metric space $X$ is totally bounded iff $X$ contains no infinite uniformly discrete subset. In particular, each unbounded metric space $(X,\rho)$ contains a uniformly discrete subset $A=\{a_n\}$, which can be constructed by induction: pick as $a_0$ an arbitrary point of the space $X$ and for each $n$ pick as $a_n$ an arbitrary point of the space $X$ such that $\rho(a_n,a_m)\ge 1$ for every $m<n$.
A metrizable topological space $Y_0$ is called an absolute extensor, abbreviated AE, provided that for every metrizable topological space $X$ and every closed subspace $A\subset X$, every continuous function $f_0:A\to Y_0$ can be extended over $X$. In particular, by Tietze extension theorem, the real line endowed with the standard metric is an absolute extensor.
Proposition 1. Let $X$ be a metric space and $Y_0$ be a metric AE-space, which is not totally bounded. The following conditions are equivalent:
Each continuous function from the space $X$ to the space $Y_0$ is uniformly continuous.
Each continuous function from the space $X$ to an arbitrary metric space $Y$ is uniformly continuous.
Each closed discrete subset of the space $X$ is uniformly discrete.
Proof. Implication $(2 \Rightarrow 1)$ is trivial. Denote the metric of the space $X$ as $\rho$, the metric of the space $Y$ as $\sigma$, and the metric of the space $Y_0$ as $\sigma_0$.
$(1 \Rightarrow 3)$. Assume the converse. Then the space $X$ contains a closed discrete subset $A_0$ which is not uniformly discrete. Then for each $n$ there are points $x_n, y_n\in A_0$ such that $\rho(x_n,y_n)<1/n$. Put $A=\{x_n : n\in\Bbb N\}\cup \{y_n : n\in\Bbb N\}$. Since the space $Y_0$ be a not totally bounded, it contains an infinite uniformly discrete subset $B$. So there is an injective map $f_0:A\to B$. Since the set $A_0$ has the discrete topology, the function $f_0$ is continuous. Since the set $B$ is uniformly discrete, there exists $\varepsilon>0$ such that $\sigma_0(x,y)>\varepsilon$ for each different points $x,y\in B$. Thus $\rho(x_n,y_n)<1/n$ but $\sigma_0(f_0(x_n), f_0(x_n))> \varepsilon$ for each $n$. Therefore the function $f_0$ is not uniformly continuous. Since the space $Y_0$ is an absolute extensor and the set $A$ is closed in the space $X$ there exists a continuous function $f:X\to Y_0$ such that $f|A=f_0$. Clearly, that the function $f$ is not uniformly continuous.
$(3 \Rightarrow 2)$. Assume the converse. Then there are a metric space $Y$ and a continuous function $f$ from the space $X$ to the space $Y$ which is not uniformly continuous. This means that there exists a number $\varepsilon>0$ such that for each $n$ there are points $x_n, y_n\in A$ such that $\rho(x_n,y_n)<1/n$ but $\sigma(f(x_n),f(y_n))>\varepsilon$. Put $A=\{x_n : n\in\Bbb N\}\cup \{y_n : n\in\Bbb N\}$. Since the function $f$ is continuous, a set $A$ has no limit points. Hence the set $A$ is closed and discrete. But the construction of the set $A$ implies that it is not uniformly discrete, a contradiction. $\square$
We shall call a metric space $X$, satisfying the equivalent conditions of Proposition 1, a fine metric space.
In the following I shall try to investigate a structure of fine metric spaces, necessary and sufficient conditions for a metric space to be fine.
Proposition 2. Each compact metric space is fine.
Proof. Let $X$ be a compact metric space and $A$ be a closed discrete subset of the space $X$. Since a closed discrete subset of a compact space is a compact and discrete space, and, hence, finite, the set $A$ is finite, and, therefore, uniformly discrete. Thus, by Proposition 1.(3), the space $X$ is fine. $\square$.
As a corollary we obtain Theorem 4.3.32 from “General Topology” by Ryszard Engelking, which has a different proof, based on the Lebesgue covering theorem:
Corollary 1. Every continuous map $f: X\to Y$ of a compact metrizable space to a metrizable space $Y$ is uniformly continuous with respect to any metrics $\rho$ and $\sigma$ on the spaces $X$ and $Y$ respectively.
Proposition 3. Each fine metric space is complete.
Proof. Assume the converse, that is a fine metric $X$ space is not complete. Then there exists a non-convergent Cauchy sequence $A\subset X$. It is easy to check that the set $A$ has no limit points, thus it is closed and discrete in the space $X$, a contradiction. $\square$.
Proposition 4. A discrete metric space $X$ is fine iff $X$ is uniformly discrete. $\square$
Proposition 5. A closed subspace of a fine metric is fine. $\square$
To be continued ....
Suppose $f:X\to Y$ is continuous but not uniformly continuous. Then there exists $\epsilon>0$ and sequences $x_n,y_n$ in $X$ such that $d_X(x_n,y_n)\to 0$ and $d_Y(f(x_n),f(y_n))\ge \epsilon$ for all $n.$ Note that no subsequence $x_{n_k}$ can converge in $X$: If $x_{n_k} \to x,$ then $y_{n_k} \to x$ as well, hence $d_Y(f( x_{n_k}),f(y_{n_k})) \to 0$ by the continuity of $f$ at $x,$ contradicition. Similarly, no subsequence $y_{n_k}$ can converge in $X.$
Now there is a subsequence $n_k$ such that $x_{n_1},y_{n_1},x_{n_2},y_{n_2}, \dots$ are all distinct. To see this, take $n_1 = 1.$ Because $x_1,y_1$ are distinct, we're off to a good start. By the remarks above, we know $x_n\in \{x_1,y_1\}$ for only finitely many $n.$ Same for $y_n.$ Hence it's clear there is $n_2$ such that $x_{1},y_{1},x_{n_2},y_{n_2}$ are all distinct. This process can be continued, giving the desired $n_k$'s.
Let $E= \{x_{1},y_{1},x_{n_2},y_{n_2},\dots\}.$ Then $E$ has no limit points in $X.$ Otherwise we would have a subsequence of $x_n$ or $y_n$ converging to a point of $X,$ contradiction. It follows that $E $ is closed in $X.$ In its relative topology, $E$ is discrete. Thus any function $g:E \to \mathbb {R}$ whatsoever is continuous on $E.$ Let's take $g = 0$ on $\{x_{n_k}\},$ $g = 1$ on $\{y_{n_k}\}.$ By the Tietze extension theorem, $g$ extends to a function $G:X\to \mathbb {R}$ that is continuous on $X.$ Clearly the behavior of $g$ on $E$ shows $G$ is not uniformly continuous on $X.$ This is a contradiction, and proves the result.