A normal space is a topological space in which any two disjoint closed sets can be separated by neighbourhoods. Urysohn's lemma states that a topological space is normal if and only if any two disjoint closed sets can be separated by a continuous function.

Urysohn's lemma has led to the formulation of other topological properties such as the 'Tychonoff property' and 'completely Hausdorff spaces'. For example, a corollary of the lemma is that normal T1 spaces are Tychonoff.

Once we have these sets, we define f(x) = 1 if x ∉ U(r) for any r; otherwise f(x) = inf { r : x ∈ U(r) } for every x ∈ X. Using the fact that the dyadic rationals are dense, it is then not too hard to show that f is continuous and has the property f(A) ⊆ {0} and f(B) ⊆ {1}.

In order to construct the sets U(r), we actually do a little bit more: we construct sets U(r) and V(r) such that

A ⊆ U(r) and B ⊆ V(r) for all r

U(r) and V(r) are open and disjoint for all r

for r < s, V(s) is contained in the complement of U(r) and the complement of V(r) is contained in U(s).

Since the complement of V(r) is closed and contains U(r), the latter condition then implies condition (2) from above.

This construction proceeds by mathematical induction. First define U(1) = X \ B and V(0) = X \ A. Since X is normal, we can find two disjoint open sets U(1/2) and V(1/2) which contain A and B, respectively. Now assume that n≥1 and the sets U(k/2n) and V(k/2n) have already been constructed for k = 1,...,2n-1. Since X is normal, for any a ∈ { 0,1,...,2n-1 }, we can find two disjoint open sets which contain X \ V(a/2n) and X \ U((a+1)/2n), respectively. Call these two open sets U((2a+1)/2n+1) and V((2a+1)/2n+1), and verify the above three conditions.