# Uniform density of Lipschitz maps is space of continuous function — for general metric spaces

Let $$X$$ and $$Y$$ be metric space, $$X$$ be compact, $$C(X,Y)$$ denote the set of continuous functions from $$X$$ to $$Y$$ with uniform convergence on compacts topology, and $$\operatorname{Lip}(X,Y)$$ denote the subspace of Lipschitz functions from $$X$$ to $$Y$$. Under what conditions is $$\operatorname{Lip}(X,Y)$$ a dense subset of $$C(X,Y)$$?

I expect that there should be some “topological compatibility condition” between $$X$$ and $$Y$$, but this is purely (and likely unfounded) intuition.

• $Lip(X,Y)$ is always dense when $Y=\mathbb{R}$ (or $\mathbb{R}^n$), by Stone Weierstrass considering the subalgebra of $C(X,\mathbb{R})$ generated by the constant function $1$ and the functions $d_x:X\to\mathbb{R};y\mapsto d(x,y)$, for each $x\in X$ Oct 25, 2022 at 15:52
• @SaúlRM that's right. Even if $X$ is not compact you can apply Stone-Weierstrass separately to all compact subsets of $X$, and this is good enough to get uniform convergence on compact subsets. Oct 25, 2022 at 17:24
• Also, if X is any convex subset of a normed space, the uniform closure of Lip(X,R) is the space of uniformly continuous functions on X. Nov 26, 2022 at 21:13
• Shouldn't "Uniform density" in the title be "Uniform closure"? Nov 26, 2022 at 22:39

Let $$(X,\rho)$$ be a compact metric space, and let $$(Y,d)$$ be a separable metric space. Then I claim that one can endow $$X$$ with a compatible metric $$d$$ such that every continuous $$f:X\rightarrow Y$$ can be uniformly approximated by a Lipschitz function.

Let $$(f_n)_{n\geq 0}$$ be a sequence of continuous functions such that every continuous $$f:X\rightarrow Y$$ can be uniformly approximated by some $$f_n$$. Let $$(\alpha_n)_{n\geq 0}$$ be a sequence of positive real numbers such that $$\alpha_n\cdot\operatorname{Diam}(f_n[X])\rightarrow 0$$. Then define a metric $$d$$ on $$X$$ by setting $$d(x,y)=\rho(x,y)+\sup_n\alpha_n\cdot d(f_n(x),f_n(y)).$$ Then the metric $$d$$ is compatible with the original topology on $$X$$. Furthermore, for each $$n$$, we have $$d(f_n(x),f_n(y))\leq\alpha_n^{-1}\cdot d(x,y)$$, so each $$f_n$$ is Lipschitz.

• This is really cool! Oct 25, 2022 at 23:22
• @NikWeaver Ya I think so too. This is perfect actually; thanks Josef :) Oct 27, 2022 at 14:15
• What if X is a cube in the Euclidean space and Y is a singleton. Why does the new metric generate the topology on X?
– ABIM
Nov 26, 2022 at 18:36
• @AIM That is a good point. I have edited the answer to cover such a situation. Nov 26, 2022 at 19:45
• Cool, now it's perfect :)
– ABIM
Nov 26, 2022 at 20:46

Let $$X$$ be the unit circle and let $$Y$$ be the Koch snowflake, both with euclidean metric inherited from $$\mathbb{R}^2$$. There is a continuous homeomorphism from $$X$$ onto $$Y$$, but there is no nonconstant Lipschitz function from $$X$$ to $$Y$$, because the image of $$X$$ under any Lipschitz function is rectifiable.

While in general one cannot expect density of Lipschitz mappings (as pointed out by Nik Weaver), the following classical result is in the positive direction. You can find a proof in Heinonen's book Lectures on analysis on metric spaces:

Theorem. If $$f:X\to\mathbb{R}$$ is a bounded and uniformly continuous function on a metric space, then there is a sequence of Lipschitz continuous functions $$f_i:X\to\mathbb{R}$$, $$i=1,2,3,\dotsc$$, such that $$f_i\to f$$ converges uniformly on $$X$$.

$$X$$ can be any metric space and compactness is not required. For that reason the argument based on the Stone–Weierstrass theorem mentioned in some comments cannot be applied here.

• Thanks Piotr. But this follows from Stone-Weirstrass no? Oct 27, 2022 at 14:16
• @PiotrK No it does not. Stone-Weierstrass requires compactness and here we have an arbitrary metric space. I will edit my answer mention that. Thank you for pointing this out. Oct 27, 2022 at 15:02

I claim that $$X,Y$$ are metric spaces with $$X$$ compact, and if $$X$$ or $$Y$$ is zero-dimensional, then every continuous function $$f:X\rightarrow Y$$ can be uniformly approximated by a locally constant function, and every locally constant function $$f:X\rightarrow Y$$ is Lipschitz.

Locally constant functions are Lipschitz

I claim that every locally constant function $$f:X\rightarrow Y$$ is Lipschitz whenever $$X$$ is compact. If $$f:X\rightarrow Y$$ is locally constant, then let $$\mathcal{P}=\{f^{-1}[\{y\}]:y\in Y\}\setminus\{\emptyset\}$$. Let $$V=\bigcup_{C,D\in\mathcal{P},C\neq D}C\times D$$. Then $$V$$ is compact, so $$d|_V:V\rightarrow\mathbb{R}$$ has a minimum value $$\delta$$, and necessarily $$\delta>0$$, and the function $$d$$ has a maximum value $$M$$.

If $$x,y\in X$$ and $$x,y$$ belong to different blocks of $$\mathcal{P}$$, then $$d(x,y)\geq\delta$$ while $$d(f(x),f(y))\leq M$$, so $$d(f(x),f(y))\leq d(x,y)\cdot\frac{M}{\delta}$$ in this case. In fact, $$d(f(x),f(y))\leq d(x,y)\cdot\frac{M}{\delta}$$ whenever $$x,y\in X$$.

When $$X$$ is zero-dimensional.

Let $$f:X\rightarrow Y$$ be a continuous function. Let $$\epsilon>0$$. Then the cover $$\{f^{-1}(B_\epsilon(y))|y\in Y\}$$ has a refinement $$\mathcal{P}$$ which is a partition of $$X$$ into clopen sets. Now, for each $$C\in\mathcal{P}$$, let $$y_C\in Y$$ be an element with $$C\subseteq f^{-1}(B_\epsilon(y_C))$$. Then let $$g:X\rightarrow Y$$ be the function where $$g[C]=\{y_C\}$$ whenever $$C\in\mathcal{P}$$.

Then whenever $$x\in C\in\mathcal{P}$$, we have $$g(x)=y_C$$ while $$f(x)\in B_\epsilon(y_C)$$, so $$d(f(x),g(x))<\epsilon$$ while $$g$$ is locally constant.

when $$Y$$ is zero-dimensional

Suppose that $$Y$$ is zero-dimensional. Let $$f:X\rightarrow Y$$ be continuous. Then $$f[Y]$$ is compact. Therefore let $$\epsilon>0$$. Consider the cover $$\{f[Y]\cap B_{\epsilon/2}(y)\mid y\in Y\}$$. Then there is a partition $$\mathcal{P}$$ of $$f[Y]$$ into sets that are clopen in $$f[Y]$$ but where $$\mathcal{P}$$ refined the cover $$\{f[Y]\cap B_{\epsilon/2}(y)\mid y\in Y\}$$. In particular, each set in $$\mathcal{P}$$ has diameter less than $$\epsilon$$.

For each $$C\in\mathcal{P}$$, let $$y_C\in Y$$, and let $$g:X\rightarrow Y$$ be the function where $$g(x)=y_C$$ whenever $$f(x)\in C$$. Then whenever $$f(x)\in C$$, we have $$g(x)=y_C\in C$$ as well, so $$d(f(x),g(y))<\epsilon$$. Therefore, $$g$$ is a locally constant continuous function with $$d(f,g)<\epsilon$$.

• would you want to merge your answers into one post? I can then pick that one as the winner :) Oct 27, 2022 at 14:16
• @PiotrK I would choose as a winner the answer of Joseph Van Name with a higher number of votes. It is a much nicer and a much more general result. Oct 27, 2022 at 15:09
• @PiotrHajlasz I agree tbh. But, let me just say, that both results are very insightful :) Oct 27, 2022 at 17:34
• I usually consider merging ideas into one post if they are closely enough related. And I agree that results about spaces in general should be preferred over zero-dimensional spaces. Oct 27, 2022 at 23:10