Proof (Urysohn's lemma)
Let $A$ and $B$ be disjoint closed sets.
Constructing layers of open and closed sets
Enumerate $\Q \cap [0,1] = \set{q_0 = 0, q_1 = 1, q_2, q_3, \ldots}$.
We will construct a sequence $(A_n)_{n\geq 0}$ of closed sets and a sequence $(U_n)_{n\geq 0}$ of open sets such that
-
$U_0 = \emptyset$, $A_0 = A$;
-
$U_1 = X \setminus B$, $A_1 = X$; and
-
if $q_i<q_j$, then $U_i \subseteq A_i \subseteq U_j \subseteq A_j$.
Set $U_0, A_0, U_1, A_1$ as specified in properties 1 and 2, which then satisfies property 3.
Having constructed $U_0, \ldots, U_{n-1}$ and $A_0, \ldots, A_{n-1}$ satisfying property 3, find $k, l < n$ such that $q_k$ is maximal and $q_l$ is minimal satisfying $q_k < q_n < q_l$. Then by the definition of a normal space, as $A_k \subseteq U_l$, find $A_n$ closed and $U_n$ open such that $A_k \subseteq U_n \subseteq A_n \subseteq U_l$.
Defining separating function
Define $$ \begin{align*} f: X &\to [0,1] \\ x &\mapsto \inf\sb{q_n}{x\in A_n}. \end{align*} $$
$f$ is well-defined, since $A_1 = X$ so $\sb{q_n}{x\in A_n}$ is never empty.
Note $f = 0$ on $A$ (since $A_0 = A$) and $f = 1$ on $B$ (since $B \cap A_q = \emptyset$ for $q<1$).
To show continuity of $f$ at $x_0$:
-
If $0\leq q_k<f(x_0)$, then $X \setminus A_k$ is an open neighbourhood of $x_0$ contained within $f\inv([q_k, 1])$.
-
If $f(x_0)<q_l\leq 1$, then $U_l$ is an open neighbourhood of $x_0$ contained within $f\inv([0, q_l])$.
Therefore for any $(a,b)\ni f(x_0)$, find $k,l$ such that $a<q_k<f(x_0)<q_l<b$. Then $(X \setminus A_k) \cap U_l$ is an open neighbourhood of $x_0$ contained within $[q_k, q_l] \subseteq (a,b)$.