Two subsets A and B of a topological space X are said to be separated by neighbourhoods if there are neighbourhoods U of A and V of B that are disjoint. In particular A and B are necessarily disjoint. Two plain subsets A and B are said to be separated by a function if there exists a continuous function f from X into the unit interval such that f = 0 for all a in A and f = 1 for all b in B. Any such function is called a Urysohn function for A and B. In particular A and B are necessarily disjoint. It follows that if two subsets A and B are separated by a function then so are their closures. Also it follows that if two subsets A and B are separated by a function then A and B are separated by neighbourhoods. 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. The sets A and B need not be precisely separated by f, i.e., we do not, and in general cannot, require that f ≠ 0 and ≠ 1 for x outside of A and B. The spaces in which this property holds are the perfectly normal spaces. 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 = 1 if x ∉ U for any r; otherwise f = inf 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 ⊆ and f ⊆. In order to construct the sets U, we actually do a little bit more: we construct sets U and V such that
A ⊆ U and B ⊆ V for all r,
U and V are open and disjoint for all r,
For r < s, V is contained in the complement of U and the complement of V is contained in U.
Since the complement of V is closed and contains U, the latter condition then implies condition from above. This construction proceeds by mathematical induction. First define U = X \ B and V = X \ A. Since X is normal, we can find two disjoint open sets U and V which contain A and B, respectively. Now assume that n ≥ 1 and the sets U and V have already been constructed for k = 1,..., 2n−1. Since X is normal, for any a ∈, we can find two disjoint open sets which contain X \ V and X \ U, respectively. Call these two open sets U and V, and verify the above three conditions. The Mizar project has completely formalized and automatically checked a proof of Urysohn's lemma in the .