Distance function to a closed set is differentiable (and $C^1$ class) defined in the complement Let $E$ be a nonempty open set in $\mathbb{R}^n$. Then, the distance function to its complement,
$$d(x)=dist(x,\mathbb{R}^n-E),$$ is differentiable and $C^1$ class in $E$.
It is well-known that $d(x)$ is continuous in $E$, but I need to prove a little more. Any help?
 A: What you want to prove is NOT true, even the weaker "differentiable" part.
First, it is easy to see the result is not true when $x \in {\mathbb R}^n - E.$ The function $d:{\mathbb R}^n \rightarrow {\mathbb R}$ is Lipschitz continuous with Lipschitz constant $1,$ but $d(x)$ can fail to be differentiable at some points not in $E.$
Example 1: Let $n=1$ and $E = \{0,\,2\}.$ Then $d(x)$ is not differentiable at $x=1.$ You can see this by observing that, between $x=0$ and $x=2,$ the graph of the function $d(x)$ consists of a triangular tent over the interval $[0,2]$ on the $x$-axis.
Example 2: Let $n=1$ and $E$ be the Cantor middle thirds set. Then $d(x)$ is not differentiable at each of the midpoints of the bounded complementary open intervals of $E.$ You can see this by observing that, between $x=0$ and $x=1,$ the graph of $d(x)$ consists of a triangular tent over each of the bounded complementary open intervals of $E$ on the $x$-axis.
However, you asked about differentiability at points in $E.$ In fact, in the case of Example 2 above, $d(x)$ is not differentiable at EACH point in $E.$ To see this, let $x_0 \in E.$ I will show that $d(x)$ has zero as a derived number at $x=x_0$ and that $d(x)$ has a positive number as a derived number at $x=x_0.$
(zero is a derived number) There exists a sequence of distinct points in $E$ approaching $x_0,$ because every point of $E$ is a limit point of $E.$ Therefore, there exists a sequence of difference quotients for $x_0$ and these distinct points such that each of these difference quotients has the value $0.$ Thus, at $x=x_0$ the function $d(x)$ has zero as a derived number.
(a positive number is a derived number) It is not difficult to see that there exists a sequence $\{I_n\}$ of bounded complementary open intervals converging to $x_0$ such that the ratios "length of $I_n$" to "distance between $x_0$ and midpoint of $I_n$" are all bounded above zero. Therefore, there exists a sequence of difference quotients for $x_0$ and the midpoints of $I_n$ such that each these difference quotients is bounded above zero. Thus, at $x=x_0$ the function $d(x)$ has a positive number as a derived number. (The idea is that, for this sequence, the ratios of the heights of the tents over $I_n$ to the distances between $x_0$ and the midpoints are bounded above zero.)
In general, I believe that the points in $E \subseteq {\mathbb R}^n$ at which $d(x)$ is not differentiable is characterized as the limit points of $E$ at which the upper porosity of $E$ is positive. See the first sentence of this paper for the definition of what is now called “upper porosity” when $n=1.$ When the idea is clear to you, see this paper more general spaces.
