I'm trying to build a continuous map that separates $2$ disjoint closed subsets of a metric space. Moreover, if the distance between them is positive, then the map is uniformly continuous.
Let $(E, d)$ be a metric space and $A,B$ closed subsets of $E$ with positive distance, i.e., $$ d(A,B) := \inf \{d(x,y) \mid x \in A, y\in B\} >0. $$ Let $$ d(x, A) := \inf_{y\in A} d(x,y) \quad \text{and} \quad d(x, B) := \inf_{y\in B} d(x,y) \quad \forall x \in E. $$ We adopt the convention that $d(x, \emptyset) = +\infty$. We define a continuous map $f:E \to [0, 1]$ by $$ f (x) := \frac{d(x, A)}{d(x, A) + d(x, B)} \quad \forall x \in E. $$ Then $f$ is uniformly continuous.
Could you verify if my attempt is fine?
I post my proof separately as below answer. This allows me to subsequently remove this question from unanswered list.