[example: Separating Two Closed Intervals in $\mathbb{R}$]
Let $X=\mathbb{R}$ with its usual topology, and let $A=[0,1]$ and $B=[3,4]$. The sets $A$ and $B$ are closed intervals, hence closed in the usual topology, and they are disjoint because every $a\in A$ satisfies $a\leq 1$ while every $b\in B$ satisfies $b\geq 3$.
The [open set](/page/Open%20Set) $U=(-1,2)$ contains $A$, since $0>-1$ and $1<2$. The open set $V=(2,5)$ contains $B$, since $3>2$ and $4<5$. Also $U\cap V=\varnothing$: if $x\in U\cap V$, then $x<2$ from $x\in U$ and $x>2$ from $x\in V$, which is impossible.
The set-to-set distance is exactly $2$. For any $a\in[0,1]$ and $b\in[3,4]$, we have $a\leq 1<3\leq b$, so $|a-b|=b-a$. Since $b\geq 3$ and $a\leq 1$,
\begin{align*}
|a-b|=b-a\geq 3-1=2.
\end{align*}
Therefore $2$ is a lower bound for $\{|a-b|:a\in A,\ b\in B\}$. Taking $a=1$ and $b=3$ gives
\begin{align*}
|1-3|=2,
\end{align*}
so the lower bound is attained, and hence
\begin{align*}
\operatorname{dist}(A,B)=\inf\{|a-b|:a\in A,\ b\in B\}=2.
\end{align*}
This positive gap is what the open buffers $(-1,2)$ and $(2,5)$ are exploiting: each closed interval is surrounded by an open neighbourhood, and the two neighbourhoods still do not meet.
[/example]