Let $f$ be a continuous mapping of a compact metric space $(X, d)$ onto a Hausdorff space $(Y, \tau_1)$.
If $d$ is a metric on $X$, how to show that $$d_1(y_1, y_2) := \inf\{d(a, b) : a \in f^{-1}(y_1)\text{ and }b \in f^{−1}(y_2)\}$$ is a metric on Y?
I can see that it is never $0$ when $y_1$ is not equal to $y_2$. But how should I go about showing that it satisfies the triangle inequality?
I am actually reading the following page from a book.

Unfortunately, $d_1$ is not a metric in general (it would be nice if we could push forward metrics like that...)
For example, let $f:[0, 3]\to [0, 2]$ be the function that sends $0, 1, 2, 3$ to $0, 1, 1, 2$ respectively, and is linear in between. (In particular, $f\equiv 1$ on $[1, 2]$.) Then $$ d_1(0, 1) = \operatorname{dist}(f^{-1}(0), f^{-1}(1)) = \operatorname{dist}(\{0\}, [1, 2]) = 1 $$ and $$ d_1(1, 2) = \operatorname{dist}(f^{-1}(1), f^{-1}(2)) = \operatorname{dist}( [1, 2], \{2\}) = 1 $$ but $$ d_1(0, 2) = \operatorname{dist}(f^{-1}(0), f^{-1}(2)) = \operatorname{dist}(\{0\}, \{3\}) = 3 $$ violating the triangle inequality.