I am teaching a course in basic differential topology, and, following e.g. Milnor, I defined functions of class $C^k$ on subsets of the Euclidean space $\mathbb{R}^n$ as follows.


Let $f\colon X\to \mathbb{R}$ be a function, where $X\subseteq \mathbb{R}^n$. Then $f$ is of class $C^k$ if for every point $x\_0\in X$ there exist an open neighbourhood $U$ of $x\_0$ in $\mathbb{R}^n$ and a function $F\colon U\to\mathbb{R}$ of class $C^k$ such that $f|\_{X\cap U}=F|\_{X\cap U}$.


A student in the audience asked the following question:


Is it true that a function $f\colon X\to\mathbb{R}$ is $C^\infty$ if and only if it is $C^k$ for every $k\in\mathbb{N}$? (The ``only if'' statement of course is trivial). Well, I was not able to answer to the question...



Smooth functions on subsets of $\mathbb{R}^n$
The answer is yes for functions defined on closed sets $X\subset\mathbb{R}^n$.
In Section 1.5.5 in [1] we have a necessary and a sufficient condition of the existence of an extension to a $C^m$ function for a finite $m$ and in Section 1.5.6 in [1] we have a necessary and sufficient condition for the existence of an extension to $C^\infty$. It turns out that if the condition for the existence of an extension to $C^m$ is satisfied for all finite $m$, then it is precisely the condition for the existence of an extension to $C^\infty$.


[1] Narasimhan, R. Analysis on real and complex manifolds, North-Holland Mathematical Library, 35. North-Holland Publishing Co., Amsterdam, 1985.


