This is an interesting theorem which holds in arbitrary normal topological spaces. In particular it holds in metric space and this is the context in which it will be discussed. First, here is a useful lemma.
Lemma B.2.1 Let X be a metric space and let S be a nonempty subset of X.

Then

Proof: Say dist

Then


Since ε is arbitrary,

It is similar if dist
Then this shows that x → dist
Lemma B.2.2 Let H,K be two nonempty disjoint closed subsets of X. Then there exists a continuous function, g : X →
Proof: Let

The denominator is never equal to zero because if dist
Definition B.2.3 For f : M ⊆ X → ℝ, define
Lemma B.2.4 Suppose M is a closed set in X and suppose f : M →
Proof: Let H = f^{−1}
Lemma B.2.5 Suppose M is a closed set in X and suppose f : M →
Proof: Using Lemma B.2.4, let g_{1} be such that g_{1}

Suppose g_{1},
 (2.6) 
This has been done for m = 1. Then

and so

Hence

It follows there exists a sequence,

It follows

and

so the Weierstrass M test applies and shows convergence is uniform. Therefore g must be continuous by Theorem 11.1.45. The estimate 2.6 implies f = g on M. ■
The following is the Tietze extension theorem.
Theorem B.2.6 Let M be a closed nonempty subset of X and let f : M →
Proof: Let f_{1}
With the Tietze extension theorem, here is a better version of the Weierstrass approximation theorem.
Theorem B.2.7 Let K be a closed and bounded subset of ℝ^{n} and let f : K → ℝ be continuous. Then there exists a sequence of polynomials

In other words, the sequence of polynomials converges uniformly to f on K.
Proof: By the Tietze extension theorem, there exists an extension of f to a continuous function g defined on all ℝ^{n} such that g = f on K. Now since K is bounded, there exist intervals,

Then by the Weierstrass approximation theorem, Theorem B.1.6 there exists a sequence of polynomials
By considering the real and imaginary parts of a function which has values in ℂ one can generalize the above theorem.
Corollary B.2.8 Let K be a closed and bounded subset of ℝ^{n} and let f : K → F be continuous. Then there exists a sequence of polynomials

In other words, the sequence of polynomials converges uniformly to f on K.
More generally, the function f could have values in ℝ^{n}. There is no change in the proof. You just use norm symbols rather than absolute values and nothing at all changes in the theorem where the function is defined on a rectangle. Then you apply the Tietze extension theorem to each component in the case the function has values in ℝ^{n}.
The purpose of this appendix is to prove the equivalence between the axiom of choice, the Hausdorff maximal theorem, and the wellordering principle. The Hausdorff maximal theorem and the wellordering principle are very useful but a little hard to believe; so, it may be surprising that they are equivalent to the axiom of choice. First it is shown that the axiom of choice implies the Hausdorff maximal theorem, a remarkable theorem about partially ordered sets.
A nonempty set is partially ordered if there exists a partial order, ≺, satisfying

and

An example of a partially ordered set is the set of all subsets of a given set and ≺≡⊆. Note that two elements in a partially ordered sets may not be related. In other words, just because x, y are in the partially ordered set, it does not follow that either x ≺ y or y ≺ x. A subset of a partially ordered set, C, is called a chain if x, y ∈C implies that either x ≺ y or y ≺ x. If either x ≺ y or y ≺ x then x and y are described as being comparable. A chain is also called a totally ordered set. C is a maximal chain if whenever
Lemma C.0.1 Let ℱ be a nonempty partially ordered set with partial order ≺. Then assuming the axiom of choice, there exists a maximal chain in ℱ.
Proof: Let X be the set of all chains from ℱ. For C∈X, let

If S_{C} = ∅ for any C, then C is maximal. Thus, assume S_{C}≠∅ for all C∈X. Let f(C) ∈ S_{C}. (This is where the axiom of choice is being used.) Let

Thus g(C) ⊋ C and g(C) ∖C ={f(C)} = {a single element of ℱ}. A subset T of X is called a tower if


and if S⊆T is totally ordered with respect to set inclusion, then

Here S is a chain with respect to set inclusion whose elements are chains.
Note that X is a tower. Let T_{0} be the intersection of all towers. Thus, T_{0} is a tower, the smallest tower. Are any two sets in T_{0} comparable in the sense of set inclusion so that T_{0} is actually a chain? Let C_{0} be a set of T_{0} which is comparable to every set of T_{0}. Such sets exist, ∅ being an example. Let

The picture represents sets of ℬ. As illustrated in the picture, D is a set of ℬ when D is larger than C_{0} but fails to be comparable to g
This will be accomplished by showing
Claim:
Proof of the claim: It is clear that ∅∈
Case 1: f
Case 2: f
Hence if f
Now suppose S is a totally ordered subset of
Define T_{1} to be the set of all elements of T_{0} which are comparable to every element of T_{0}. (Recall the elements of T_{0} are chains from the original partial order.)
Claim: T_{1} is a tower.
Proof of the claim: It is clear that ∅∈T_{1} because ∅ is a subset of every set. Suppose C_{0} ∈T_{1}. It is necessary to verify that g
This shows T_{1} is a tower and proves therefore, that T_{0} = T_{1}. Thus every set of T_{0} compares with every other set of T_{0} showing T_{0} is a chain in addition to being a tower.
Now ∪T_{0},g

a contradiction. Hence there must exist a maximal chain after all. This proves the lemma.
If X is a nonempty set,≤ is an order on X if

and if x, y ∈ X, then

and

≤ is a well order and say that
Proof: Let X be a nonempty set and let a ∈ X. Then {a} is a wellordered subset of X. Let
