From Distance to Continuous Separation
In a metric space, the metric measures how far a point is from a set. When the set is closed, distance vanishes exactly at its points. This makes distance a natural source of continuous functions that distinguish closed sets. In fact, two disjoint nonempty closed sets can be separated by a single formula, even when points of the two sets can come arbitrarily close.
Throughout, \((X,d)\) is a metric space with its metric topology. A set is closed if its complement is open. For a nonempty subset \(A\subseteq X\), define the distance from \(x\in X\) to \(A\) by
The infimum is a finite nonnegative real number: the set of distances is nonempty and bounded below by \(0\), and choosing any \(a\in A\) shows that its infimum is at most \(d(x,a)\). We define \(d(x,A)\) here only for nonempty \(A\); formulas involving it will state that requirement.
Proof. For any \(x,y\in X\) and \(a\in A\), the triangle inequality gives \(d(x,a)\le d(x,y)+d(y,a)\). Taking the infimum over \(a\in A\) gives \(d(x,A)\le d(x,y)+d(y,A)\). Interchanging \(x\) and \(y\) gives \(d(y,A)\le d(x,y)+d(x,A)\). Together these inequalities give \(|d(x,A)-d(y,A)|\le d(x,y)\). Thus the distance function is \(1\)-Lipschitz, which implies continuity: if \(d(x,y)<\varepsilon\), then \(|d(x,A)-d(y,A)|<\varepsilon\).
Suppose \(d(x,A)=0\). Every open ball \(B(x,r)\), with \(r>0\), meets \(A\): otherwise every \(a\in A\) would have \(d(x,a)\ge r\), contradicting \(d(x,A)=0\). By the neighborhood test for closure, \(x\in\overline{A}\). Conversely, if \(x\in\overline{A}\), then every ball \(B(x,r)\) meets \(A\). For each \(r>0\), some \(a\in A\) therefore satisfies \(d(x,a)<r\), so \(d(x,A)\le r\). Since this holds for every positive \(r\), \(d(x,A)=0\). Finally, a closed set equals its closure, so for closed \(A\), the condition is equivalent to \(x\in A\). \(\square\)
The Distance Formula for Two Closed Sets
Proof. The distance functions \(x\mapsto d(x,A)\) and \(x\mapsto d(x,B)\) are continuous by the proposition. Their sum is continuous. At any \(x\in X\), this sum is positive: if it were zero, both nonnegative terms would be zero. Since \(A\) and \(B\) are closed, the proposition would imply \(x\in A\) and \(x\in B\), contrary to disjointness. Thus the quotient is defined at every point and is continuous, as a quotient of continuous real-valued functions with a nowhere-zero denominator. Its numerator is nonnegative and no larger than the denominator, so \(0\le f(x)\le1\). If \(x\in A\), then \(d(x,A)=0\); disjointness and closedness give \(d(x,B)>0\), so \(f(x)=0\). If \(x\in B\), then \(d(x,B)=0\) and \(d(x,A)>0\), so \(f(x)=1\). \(\square\)
The hypotheses explain exactly why the formula works. Both sets must be nonempty for these distance functions to be finite real-valued functions, and closedness ensures that a point outside either set has strictly positive distance from it. If one of the sets is empty, the formula is not being used; separation by constants is then immediate, with the required value on the nonempty set and no condition to check on the empty set. If both are empty, any constant function suffices.
Worked Example: Two Points on the Real Line
Take \(X=\mathbb{R}\) with its standard topology, \(A=\{0\}\), and \(B=\{2\}\). These finite subsets are closed, nonempty, and disjoint. Their distance functions are \(d(x,A)=|x|\) and \(d(x,B)=|x-2|\), so the separator is \(f(x)=|x|/(|x|+|x-2|)\). Its denominator is positive for every real \(x\), since a real number cannot equal both \(0\) and \(2\).
At \(x=0\), \(d(0,A)=0\) and \(d(0,B)=|0-2|=2\), giving \(f(0)=0/(0+2)=0\). At \(x=2\), \(d(2,A)=|2|=2\) and \(d(2,B)=0\), giving \(f(2)=2/(2+0)=1\). At \(x=1/2\), the distances are \(|1/2|=1/2\) and \(|1/2-2|=3/2\), so \(f(1/2)=(1/2)/(1/2+3/2)=1/4\).
Check: Substituting the prescribed-set points back into the formula gives \(f(0)=0\) and \(f(2)=1\), as required. The value \(1/4\) at \(1/2\) lies in \([0,1]\), also as the theorem predicts.
Worked Example: Two Closed Half-Lines
In \(\mathbb{R}\) with the standard topology, let \(A=(-\infty,0]\) and \(B=[2,\infty)\). Both are nonempty, closed, and disjoint. The distance to \(A\) is \(0\) when \(x\le0\), and \(x\) when \(x>0\); hence \(d(x,A)=\max(x,0)\). Likewise, \(d(x,B)=\max(2-x,0)\).
If \(x\le0\), the first distance is \(0\) and the second is \(2-x>0\), so \(f(x)=0\). If \(0<x<2\), the distances are \(x\) and \(2-x\), whose sum is \(2\); thus \(f(x)=x/2\). If \(x\ge2\), the second distance is \(0\) and the first is \(x>0\), so \(f(x)=1\). Therefore
At the joining points, the middle formula approaches \(0/2=0\) as \(x\) approaches \(0\), and \(2/2=1\) as \(x\) approaches \(2\). The endpoint values agree with the adjoining pieces. Check: for \(x=1\), the distances are \(1\) and \(1\), so the original formula gives \(1/(1+1)=1/2\), which agrees with the piece \(x/2\).
Disjoint Does Not Mean Positively Separated
For nonempty subsets \(A,B\) of a metric space, their mutual distance is \(\inf\{d(a,b):a\in A,\ b\in B\}\). Disjoint closed sets need not have positive mutual distance. The formula still works: its denominator must be positive at each individual point, but it need not have a positive lower bound that works uniformly over all of \(X\).
Worked Example: Closed Sets with Mutual Distance Zero
Let \(X=\mathbb{R}^2\) with its Euclidean metric, and set \(A=\{(n,0):n\in\mathbb{N}\}\) and \(B=\{(n,1/n):n\in\mathbb{N}\}\). These sets are disjoint because \(1/n>0\) for every \(n\). They are closed: every bounded region meets each set in only finitely many points, so neither set has a finite accumulation point; any point outside either set has a sufficiently small ball missing that set. For each \(n\), the distance between \((n,0)\in A\) and \((n,1/n)\in B\) is \(\sqrt{(n-n)^2+(0-1/n)^2}=1/n\). Since \(1/n\) tends to \(0\), the mutual distance of \(A\) and \(B\) is \(0\).
Nevertheless, the separation formula is defined everywhere by the theorem. At \(x_n=(n,0)\), \(d(x_n,A)=0\), while \(d(x_n,B)=1/n\): the point \((n,1/n)\) is that far away, and every point of \(B\) with a different first coordinate is at least \(1\) away horizontally. Thus the denominator at \(x_n\) is \(1/n>0\), and \(f(x_n)=0/(0+1/n)=0\). These denominators approach \(0\) as \(n\) grows, but each is positive. This verifies concretely why a uniform positive lower bound is not needed.
Check: The computed pairwise distances \(1/n\) are positive, so the sets do not meet; they become arbitrarily small, so no positive number is a lower bound for all pairwise distances.
How This Relates to Urysohn’s Lemma
Urysohn’s lemma states that if \(X\) is a normal topological space and \(A,B\) are disjoint closed subsets, there is a continuous function \(g:X\to[0,1]\) with \(g=0\) on \(A\) and \(g=1\) on \(B\). Its dyadic, nested-open-set construction applies to normal spaces without requiring a metric. Metric spaces are normal, as shown in the earlier material on separating closed sets in metric spaces, so Urysohn’s lemma applies to the present setting as well.
The distance formula gives more explicit data when a metric is available: it specifies the function directly from the two sets. Urysohn’s construction instead builds a function using a sequence of open neighborhoods. The two approaches have the same prescribed values on \(A\) and \(B\), but they need not produce the same function. The metric formula is not a replacement for Urysohn’s lemma in spaces where no metric is given. Conversely, the formula makes visible a feature the general construction does not require: the distance functions themselves are \(1\)-Lipschitz.
Check Your Understanding
Use the definitions and the distance formula to justify each answer.
- For \(A=\{-1,1\}\subseteq\mathbb{R}\), compute \(d(0,A)\) and \(d(2,A)\).
- In \(\mathbb{R}\), use the formula to separate \(A=\{0\}\) and \(B=\{4\}\). What value does it give at \(x=1\)?
- Explain why the formula in the theorem is not defined as a real-valued distance quotient if \(A=\varnothing\).
- Can two disjoint closed subsets of a metric space have mutual distance zero? Explain using the example in this tutorial.
- Why does closedness matter for the denominator in the separation formula?