Show that the distance is a continuous function and property on the metric topology 
*

*Let $(X,d)$ be a metric space. Prove that the distance function $d\colon X\times X\to\mathbb{R}$ is a continuous function.

*Show that the metric topology is the less finer topology on $X$ such that $d\colon X\times X\to\mathbb{R}$ is continuous.

 A: Question 1: For the first question, let $U \subset \mathbb{R}$ be open and let $A = d^{-1}(U) \subset X \times X$. We must show that $A$ is open. To do so, let's pick an arbitrary point, $(x_1, x_2)$, of $A$. We know that $A$ is open if we can find an open neighbourhood, $V$, of $(x_1, x_2)$.
At this point, we need to look at the topology on $X \times X$. This has a basis given by "open rectangles": sets of the form $U_1 \times U_2 \subset X \times X$ such that both $U_1$ and $U_2$ are open in $X$. While there are open sets other than the basis sets (you can take arbitrary unions), the basis sets are open, and we can use one of them as our open neighbourhood.
But what do $U_1$ and $U_2$ look like? Well, the topology on $X$ came from a metric, so it has a basis of open balls. Let's write $B_\varepsilon(x)$ for the ball of radius $\varepsilon$ about $x$. Again, the basis is a special subset of all the open sets in $X$, but it contains the open sets we need. We're going to find $\varepsilon_1 > 0$ and $\varepsilon_2 > 0$ such that we can set $V = B_{\varepsilon_1}(x_1) \times B_{\varepsilon_2}(x_2)$ and see that it is an open neighbourhood of $(x_1, x_2)$ in $A$.
We've just seen that $V$ is open in $X \times X$. Also, since $x_i \in B_{\varepsilon_i}(x_i)$ for each $i$, we know that $(x_1, x_2) \in V$. The hard bit is picking $\varepsilon_1$ and $\varepsilon_2$ such that $V \subset A$. At this point, we'd better use the fact that $U$ was open in $\mathbb{R}$.
Since this is a helpful explanation (rather than the slick book proof), let's pretend that we don't know what to do next. Scribble two dots on a piece of paper (representing $x_1$ and $x_2$) then draw circles around them with radius $\varepsilon_1$ and $\varepsilon_2$. An element of $V$ is exactly the same thing as a point from each of the circles we've drawn. You can see that if the circles are small, the distance between those two points must be roughly the same as the distance between the centres of the circles. That's the intuition that we need to capture.
To do that formally, we'll need to use the triangle inequality. Pick $(y_1, y_2) \in V$. First, let's show the upper bound. Look at the triangle formed by $x_1$, $y_1$ and $y_2$ to see that $d(y_1, y_2) \le d(y_1, x_1) + d(x_1, y_2)$. But then look at the triangle formed by $x_1$, $x_2$ and $y_2$ to see that $d(x_1, y_2) \le d(x_1, x_2) + d(x_2, y_2)$. Combining these two inequalities gives $d(y_1, y_2) \le d(x_1, x_2) + d(x_1, y_1) + d(x_2, y_2)$. But the latter two distances are bounded because of how we picked $y_1$, $y_2$, giving: $d(y_1, y_2) < d(x_1, x_2) + \varepsilon_1 + \varepsilon_2$. In words: "The distance between the $y$'s isn't much more than that between the $x$'s".
There is a corresponding lower bound that you get by swapping the $y$'s and $x$'s in the argument above, ending up with: $d(x_1, x_2) < d(y_1, y_2) + \varepsilon_1 + \varepsilon_2$. Switching that around and combining the two gives:
$d(x_1, x_2) - \varepsilon_1 - \varepsilon_2 < d(y_1, y_2) < d(x_1, x_2) + \varepsilon_1 + \varepsilon_2$
How can we use that? Well, because $(x_1, x_2) \in A$, we know that $d((x_1, x_2))$ (more conventionally written $d(x_1,x_2)$, without the extra parentheses) must lie in $U$. Let's call that point $\Delta$. Openness of $U$ means that there is some $\delta > 0$ such that $(\Delta-\delta, \Delta+\delta) \subset U$. What if we take $\varepsilon_1 = \varepsilon_2 = \delta / 2$? Then the inequalities above become
$d(x_1, x_2) - \delta < d(y_1, y_2) < d(x_1, x_2) + \delta$
Writing $d(x_1, x_2)$ as $\Delta$ (which is how we defined $\Delta$ above) and writing the inequalities as membership of an interval, you get: $d(y_1, y_2) \in (\Delta - \delta, \Delta + \delta)$. But we know that $(\Delta - \delta, \Delta + \delta) \subset U$. Ahah! We've picked an arbitrary element of $V$ and showed that after applying $d$ we end up with an element of $U$. That is, we've shown that $V \subset d^{-1}(U)$. But that's what we wanted: we're done!
Question 2: We've just show that the distance function is continuous, so it remains to show that the metric topology on $X$ induces the coarsest topology where that is true. To show that, we need to show that every open set "has to be there": its openness in the metric topology must be forced by requiring that the distance function is continuous.
Pick an open set, $U \subset X$, in the metric topology. Then $U$ can be written as a union of open balls, $B_{\varepsilon_i}(x_i)$. We are done if we can show that each of those balls must be open for $d$ to be continuous. But what is the definition of an open ball?
$B_{\varepsilon}(x) = \{ y \,|\, d(x, y) < \varepsilon \}$
That is exactly the preimage of $I = (-1, \varepsilon)$ under the function $y \mapsto d(x, y)$. But notice that the function $f_x: X \to X \times X$ given by $f_x(y) = (x, y)$ is continuous. (This is true no matter what topology you take on $X$). Combining with $d$, you get:
$B_{\varepsilon}(x) = (d \circ f_x)^{-1}(I)$
which must be continuous.
