I am not sure if the statement below is true. The statement is: Let $(M,d)$ be a connected metric space and $A, B$ be two nonempty subsets of $M.$ Assume the boundary $\partial A$ and $\partial B$ are nonempty. Suppose that $A\cap B=\emptyset.$ Then $$d(A,B)=d(\partial A, \partial B).$$ Here $d(E,F):=\inf\{d(x,y)\mid x\in E, y\in F\}, \forall E,F\subset M.$
If the statement is true, how to prove it? If it is not valid, give a counterexample, and is it valid if $(M, d)$ is complete?
The answer is no. Consider $M=(-\infty,-1)\cup (1,\infty)$ with distance $d(x,y)=|y-x|.$ Let $A=(-2,-1)$ and $B=(1,2).$ It is clear that $d(A,B)=2.$ However $\partial A=\{-2\},$ $\partial B=\{2\},$ and $d(\partial A,\partial B)=d(-2,2)=4.$