1 Introduction

The Calderón-Zygmund theorem on regularization of the distance function asserts that for any closed subset \(W\subset {\mathbb {R}}^n\) there exists a \({\mathcal {C}}^\infty \)-function \(f: {\mathbb {R}}^n{\setminus } W\longrightarrow (0, \infty )\) equivalent to the distance function from W; i.e. there exists a constant \(A > 0\) such that

$$\begin{aligned} A^{-1}d(x, W)\le f(x) \le Ad(x, W), \quad \text {for each }x\in {\mathbb {R}}^n\setminus W \end{aligned}$$

and, moreover, there are constants \(B_{\alpha } > 0\)   \((\alpha \in {\mathbb {N}}^n)\),   such that

$$\begin{aligned} |D^\alpha f(x)|\le B_\alpha (d(x, W))^{1-|\alpha |}, \quad \text {for each }x\in {\mathbb {R}}^n\setminus W\text { and each }\alpha \in {\mathbb {N}}^n. \end{aligned}$$

It was introduced in connection with a study of elliptic partial differential equations (cf. [2]) and appears a useful tool in analysis (cf. [14, Chapter VI]).

Since semialgebraic geometry (cf. [1]) together with its generalizations (subanalytic geometry (cf. [13]), o-minimal geometry (cf. [3])) appears very valuable in areas of applied mathematics such as robotics and CAD, it was an interesting open question if the Calderón-Zygmund theorem has a counterpart in the semialgebraic category. Our aim is to give a positive answer; namely, we prove the following.

Theorem 1.1

For any closed semialgebraic subset W of \({\mathbb {R}}^n\) and any positive integer p, there exists a Nash function (i.e. semialgebraic and \({\mathcal {C}}^\infty \) ) \(f:{\mathbb {R}}^n{\setminus } W\longrightarrow (0, \infty )\) and positive constants AB such that, for each \(x\in {\mathbb {R}}^n\setminus W\)

$$\begin{aligned} A^{-1}d(x, W)\le f(x) \le Ad(x, W), \end{aligned}$$
(1.1)

and

$$\begin{aligned} |D^\alpha f(x)|\le B(d(x, W))^{1-|\alpha |}, \, \text {where}~ \alpha \in {\mathbb {N}}^n\text { and }|\alpha |\le p. \end{aligned}$$
(1.2)

The proof of Theorem 1.1 is based on \(\Lambda _p\)-regular stratifications (see Sect. 2) introduced by the second author with Krzysztof Kurdyka in [7], in connection with a subanalytic version of the Whitney extension theorem, combined with a version of the Efroymson-Shiota approximation theorem, cited below (see Theorem 1.4). In fact, we will need the following generalization of the notion of \(\Lambda _p\)-regular function considered in [7].

Definition 1.2

Let \(W\subset {\mathbb {R}}^n\) be a closed semialgebraic subset, let \(p, k\in {\mathbb {Z}}\), where \(p > 0\). Let \(\varOmega \subset {\mathbb {R}}^n\) be an open semialgebraic subset disjoint from W. We say that a semialgebraic \({\mathcal {C}}^p\)-function \(f:\varOmega \longrightarrow {\mathbb {R}}\) is \(\Lambda ^k_p(W)\)-regular if there exists a constant \(M > 0\) such that

$$\begin{aligned} |D^\alpha f(x)|\le Md(x, W)^{k-|\alpha |}, \end{aligned}$$

for each \(x\in \varOmega \) and \(\alpha \in {\mathbb {N}}^n\) such that \(1\le |\alpha |\le p\).

When f is \(\Lambda ^1_p(\partial \varOmega )\)-regular we say that f is \(\Lambda _p\)-regular (as in [7]).

Our main effort in this paper is focused on proving the following approximation theorem for Lipschitz functions (notice that the distance function is a particular case).

Theorem 1.3

Let \(W\subset {\mathbb {R}}^n\) be any closed semialgebraic subset and let p be a positive integer. Let \(g:{\mathbb {R}}^n\longrightarrow {\mathbb {R}}\) be any semialgebraic Lipschitz function vanishing on W. Then, for any \(\kappa > 0\), there exists a \(\Lambda ^1_p(W)\)-regular function \(f:{\mathbb {R}}^n\setminus W\longrightarrow {\mathbb {R}}\) such that, for each \(x\in {\mathbb {R}}^n\setminus W\),

$$\begin{aligned} |f(x) - g(x)|\le \kappa d(x, W). \end{aligned}$$

The proof of Theorem 1.3 is based on a special \(\Lambda ^0_p(W)\) partition of unity, which we establish in Section 3, and we believe has its own interest. It is also worth noting that Theorem 1.3 with the given proof holds true in the setting of any o-minimal structure on the field of real numbers \({\mathbb {R}}\).

We will use a special case of the Efroymson-Shiota approximation theorem. To quote this, we first recall the definition of the semialgebraic \({\mathcal {C}}^p\)-topology.Let G and H be open semialgebraic subsets in \({\mathbb {R}}^n\) and in \({\mathbb {R}}^m\), respectively. Let p be a non-negative integer. Denote by \(\mathcal N^p(G, H)\) the set of all semialgebraic \({\mathcal {C}}^p\)-mappings from G to H; i.e. \({\mathcal {C}}^p\)-mappings with semialgebraic graphs. Let \(f\in {\mathcal {N}}^p(G, H)\). Then basic neighborhoods of f in \({\mathcal {N}}^p(G, H)\) in the semialgebraic \({\mathcal {C}}^p\)-topology are of the form

$$\begin{aligned} U_\varepsilon (f) = \{h\in {\mathcal {N}}^p(G, H): \, |D^\alpha f(x) - D^\alpha h(x)|\le \varepsilon (x), \end{aligned}$$

whenever \(\alpha \in {\mathbb {N}}^n\), \(|\alpha |\le p\) and \(x\in G\)},

where \(\varepsilon : G\longrightarrow (0, \infty )\) is any semialgebraic positive continuous function on G.

Theorem 1.4

(Efroymson-Shiota approximation theorem) Nash mappings (i.e. semialgebraic and \({\mathcal {C}}^\infty \) ) from G to H are dense in \({\mathcal {N}}^p(G, H)\) in the semialgebraic \({\mathcal {C}}^p\)-topology.

This deep result originating in the paper of Efroymson [4] for \(p = 0\) (compare also [11]), was completed and generalized, for any non-negative p, by Shiota in [12]. In fact, Shiota’s formulation is stronger than Theorem 1.4; namely, the sets G and H above can be any Nash submanifolds embedded in \({\mathbb {R}}^n\) and in \({\mathbb {R}}^m\), respectively.

It is now a simple matter to see that Theorem 1.1 is a consequence of first applying Theorem 1.3, where we put \(g(x) = d(x, W)\), followed by Theorem 1.4, applied to a resulting f. Hence, the rest of our paper is devoted to proving Theorem 1.3.

2 \(\Lambda _p\)-regular cells

We recall after [7] (see also [8, 9] and [10]), the definition of \(\Lambda _p\)-regular cells in \({\mathbb {R}}^n\).

Definition 2.1

Let p be a positive integer. We say that S is an open \(\Lambda _p\)-regular cell in \({\mathbb {R}}^n\) if

$$\begin{aligned}&S\text { is any open interval in }{\mathbb {R}},\text { when }n = 1; \end{aligned}$$
(2.1)
$$\begin{aligned}&S = \{(x', x_n): x'\in T, \psi _1(x')< x_n < \psi _2(x')\}, \end{aligned}$$
(2.2)

where \(x' = (x_1,\dots , x_{n-1})\), T is an open \(\Lambda _p\)-regular cell in \({\mathbb {R}}^{n-1}\) and every \(\psi _i\)   \((i\in \{1, 2\})\)   is either a semialgebraic \(\Lambda _p\)-regular function on T (see Definition 1.2) with values in \({\mathbb {R}}\), or identically equal to \(-\infty \), or identically equal to \(+\infty \), and \(\psi _1(x') < \psi _2(x')\), for each \(x'\in T\), when \(n > 1\).

Extending the above definition, we say that S is an m-dimensional \(\Lambda _p\)-regular cell in \({\mathbb {R}}^n\), where \(m\in \{0,\dots , n-1\}\), if

$$\begin{aligned} S = \{(u, w): \, u\in T, w = \varphi (u)\}, \end{aligned}$$
(2.3)

where \(u = (x_1,\dots , x_m)\), \(w = (x_{m+1},\dots , x_n)\),   T is an open \(\Lambda _p\)-regular cell in \({\mathbb {R}}^m\), and \(\varphi : T\longrightarrow {\mathbb {R}}^{n-m}\) is a semialgebraic \(\Lambda _p\)-regular mapping.

Remark 2.2

One easily checks by induction that every \(\Lambda _p\)-regular cell is Lipschitz in the sense that each of the functions \(\psi _i\) in (2.2), if finite, as well as the mapping \(\varphi \) in (2.3), are Lipschitz. Besides, every \(\Lambda _p\)-regular cell in \({\mathbb {R}}^n\) is a semialgebraic connected \({\mathcal {C}}^p\)-submanifold of \({\mathbb {R}}^n\).

Definition 2.3

Let us recall that a (semialgebraic) \(\mathcal C^p\)-stratification of a (semialgebraic) subset E of \({\mathbb {R}}^n\) is a finite decomposition \({\mathcal {S}}\) of E into (semialgebraic) connected \({\mathcal {C}}^p\)-submanifolds of \({\mathbb {R}}^n\), called strata, such that for each stratum \(S\in {\mathcal {S}}\), its boundary in E; i.e. \(\partial _ES:= (\overline{S}{\setminus } S)\cap E\) is the union of some strata of dimensions \(< \dim S\). If \(A_1,\dots , A_k\)   \((k\in {\mathbb {N}})\)   are subsets of E, we call a stratification \({\mathcal {S}}\) compatible with the subsets \(A_1,\dots , A_k\), if each \(A_j\) is a union of some strata.

The following proposition is crucial in the proof of Theorem 2.6 below, which is a fundamental theorem on \(\Lambda _p\)-stratifications.

Proposition 2.4

([8, Corollary to Proposition 4 ]) Let \(\varPhi :\varOmega \longrightarrow {\mathbb {R}}\) be a semialgebraic \({\mathcal {C}}^1\)-function defined on a semialgebraic open subset \(\varOmega \) of \({\mathbb {R}}^n\) such that

$$\begin{aligned} \Big |\frac{\partial \varPhi }{\partial x_j}\Big |\le M \qquad (j\in \{1,\dots , n\}), \end{aligned}$$

where M is a positive constant, and let p be a positive integer. Then there exists a closed semialgebraic nowhere dense subset Z of \(\varOmega \) such that \(\Phi \) is of class \({\mathcal {C}}^p\) on \(\varOmega \setminus Z\) and

$$\begin{aligned} |D^\alpha \varPhi (u)|\le C(n,p)Md(u, Z\cup \partial \Omega ), \end{aligned}$$

whenever \(u\in \varOmega \setminus Z\), \(\alpha \in {\mathbb {N}}^n\), \(1\le |\alpha |\le p\), and where C(np) is a positive integer depending only on n and p.

Remark 2.5

If \(\varPhi :\varOmega \longrightarrow {\mathbb {R}}\) is a semialgebraic Lipschitz function with a constant M defined on a semialgebraic open subset \(\varOmega \) of \({\mathbb {R}}^n\), then there exists a closed semialgebraic nowhere dense subset \(Z'\) of \(\varOmega \) such that \(\varPhi \) is of class \({\mathcal {C}}^1\) on \(\varOmega \setminus Z'\) and

$$\begin{aligned} \Big |\frac{\partial \varPhi }{\partial x_j}\Big |\le M \quad \text {on}\quad \varOmega \setminus Z'. \end{aligned}$$

Theorem 2.6

Let p be a positive integer. Given any finite number \(A_1,\dots , A_k\) of semialgebraic subsets of a semialgebraic subset E of \({\mathbb {R}}^n\), and a semialgebraic Lipschitz mapping \(g: E\longrightarrow {\mathbb {R}}^d\), where \(d\in {\mathbb {N}}\), there exists a semialgebraic \({\mathcal {C}}^p\)-stratification \({\mathcal {S}}\) of E compatible with sets \(A_1,\dots , A_k\) and such that every stratum \(S\in {\mathcal {S}}\), after an orthogonal linear change of coordinatesFootnote 1 in \({\mathbb {R}}^n\), is a \(\Lambda _p\)-regular cell in \({\mathbb {R}}^n\) and if S is open then g|S is \(\Lambda _p\)-regular, while in the case \(\dim S = m < n\), when S is of the form (2.3),

$$\begin{aligned} \text {the mapping }T\ni u\longmapsto g(u, \varphi (u))\in {\mathbb {R}}^d\text { is } \Lambda _p\text {-regular.} \end{aligned}$$
(2.4)

Proof

The proof follows the inductive procedure as in the proof of Proposition 4 in [7] (or that of Theorem 3 in [8]); i.e. the induction on \(\dim E\). The only difference is that, at each inductive step, constructing strata of dimension \(< m\), we have to take into account the Lipschitz mapping g restricted to strata of dimension m making use of Remark 2.5 and Proposition 2.4. \(\square \)

3 A partition of unity

Definition 3.1

Let W be a closed semialgebraic subset of \({\mathbb {R}}^n\) and let \(Z\subset {\mathbb {R}}^n\setminus W\). We will consider the following open neighborhoods of Z in \({\mathbb {R}}^n\)

$$\begin{aligned} G_\eta (Z, W):=\{x\in {\mathbb {R}}^n\setminus W: \, d(x, Z) < \eta d(x, W)\}, \end{aligned}$$

where \(\eta > 0\). (We adopt the convention that \(d(x, \emptyset ) = \infty \).)

The main result of this section is the following theorem on \(\Lambda ^0_p(W)\)-partition of unity, which can be considered as a semialgebraic counterpart of the famous Whitney partition of unity.

Theorem 3.2

Let W be a closed semialgebraic subset of \({\mathbb {R}}^n\) and let \(U_1,\dots , U_s\) be any finite covering of \({\mathbb {R}}^n\setminus W\) by semialgebraic subsets. Then, for any positive integer p and any \(\eta > 0\), there exist \(\Lambda ^0_p(W)\)-regular functions \(\omega _i: {\mathbb {R}}^n\setminus W\longrightarrow [0, 1]\)    \((i\in \{1,\dots , s\})\)   such that   \(\omega _1 + \dots + \omega _s \equiv 1\)   on \({\mathbb {R}}^n\setminus W\)   and   \(\mathrm supp\) \(\omega _i \subset G_{\eta }(U_i, W)\)   \((i\in \{1,\dots , s\})\), where \(\mathrm supp\) \(\omega _i\) denotes the closure of \(\{x\in {\mathbb {R}}^n{\setminus } W: \, \omega _i(x)\ne 0\}\) in \({\mathbb {R}}^n\setminus W\).

Before starting the proof of Theorem 3.2, we will prove a few simple lemmas.

Lemma 3.3

Let W be a closed semialgebraic subset of \({\mathbb {R}}^n\) and let \(\varOmega \) be an open semialgebraic subset of \({\mathbb {R}}^n\) disjoint from W. If \(f:\varOmega \longrightarrow {\mathbb {R}}\) is a \(\Lambda ^k_p(W)\)-regular function and \(g:\varOmega \longrightarrow {\mathbb {R}}\) is a \(\Lambda ^l_p(W)\)-regular function, where \(k, l, p\in {\mathbb {Z}}\), \(p > 0\) and if there exists \(A > 0\) such that \(|f(x)|\le Ad(x, W)^k\) and \(|g(x)|\le Ad(x, W)^l\), for each \(x\in \varOmega \), then the function fg is \(\Lambda ^{k+l}_p(W)\)-regular.

Proof

Directly from the Leibnitz formula. \(\square \)

Lemma 3.4

Let W be a closed semialgebraic subset of \({\mathbb {R}}^n\) and let \(\varOmega \) be an open semialgebraic subset of \({\mathbb {R}}^n\) disjoint from W. If \(f:\varOmega \longrightarrow {\mathbb {R}}\) is a \(\Lambda ^k_p(W)\)-regular function, where \(k, p\in {\mathbb {Z}}\), \(p > 0\), and there exists \(a > 0\) such that \(ad(x, W)^k \le |f(x)|\), for each \(x\in \varOmega \), then the function 1/f is \(\Lambda ^{-k}_p(W)\)-regular.

Proof

Observe that \(D^\alpha (1/f)\)   \((\alpha \in {\mathbb {N}}^n {\setminus } \{0\})\), is a linear combination, with integral coefficients independent of f, of products of the form

$$\begin{aligned} f^{-(m + 1)}(D^{\beta _1}f)\dots (D^{\beta _m}f), \end{aligned}$$

where \(1\le m \le |\alpha |\), \(\beta _1,\dots , \beta _m\in {\mathbb {N}}^n{\setminus } \{0\}\), and \(\sum _{i=1}^m \beta _i = \alpha \). Hence, we get

$$\begin{aligned}{} & {} |D^\alpha (1/f)(x))|\le C d(x, W)^{-k(m+1)}d(x, W)^{k-|\beta _1|}\dots d(x, W)^{k - |\beta _m|} =\\{} & {} Cd(x, W)^{-k-|\alpha |}, \end{aligned}$$

where \(C > 0\). \(\square \)

Lemma 3.5

Let W be a closed semialgebraic subset of \({\mathbb {R}}^n\), let \(\varOmega \) be an open semialgebraic subset of \({\mathbb {R}}^n\) disjoint from W and let p be a positive integer. If \(f:\varOmega \longrightarrow {\mathbb {R}}\) is a bounded \(\Lambda ^0_p(W)\)-regular function and \(\varPhi : {\mathbb {R}}\longrightarrow {\mathbb {R}}\) is a semialgebraic \({\mathcal {C}}^p\)-function, then \(\varPhi \circ f\) is a \(\Lambda ^0_p(W)\)-regular function.

Proof

Observe that if \(\alpha \in {\mathbb {N}}^n\) and \(1\le |\alpha |\le p\), then \(D^\alpha (\varPhi \circ f)\) can be represented as a linear combination, with integral coefficients independent of \(\varPhi \) and f, of products of the form

$$\begin{aligned} \varPhi ^{(i)}(f)(D^{\beta _1}f) \dots (D^{\beta _i}f), \end{aligned}$$

where \(1\le i \le |\alpha |\) and \(\beta _1,\dots , \beta _i\in {\mathbb {N}}^n{\setminus } \{0\}\) are such that \(\beta _1 + \dots + \beta _i = \alpha \). Hence, for some constant \(C > 0\)

$$\begin{aligned} |D^\alpha (\varPhi \circ f)(x)|\le C d(x, W)^{-|\beta _1|}\dots d(x, W)^{-|\beta _i|} = Cd(x, W)^{-|\alpha |}. \end{aligned}$$

\(\square \)

Definition 3.6

Let W be a closed semialgebraic subset of \({\mathbb {R}}^n\) and let \(Z\subset {\mathbb {R}}^n\setminus W\). We will say that the property \({\mathcal {B}}_n(Z, W)\) holds, if for any positive integer p and for any \(\eta > 0\) there exists a \(\Lambda ^0_p(W)\)-regular function \(\psi : {\mathbb {R}}^n\setminus W\longrightarrow [0, 1]\) such that

$$\begin{aligned}&\psi \equiv 1 \text { on }G_\rho (Z, W),\text { with some }\rho \in (0, \eta ),\text { and} \end{aligned}$$
(3.1)
$$\begin{aligned}&\mathrm supp\psi \subset { G}_\eta (Z, W). \end{aligned}$$
(3.2)

Lemma 3.7

If W is a closed semialgebraic subset of \({\mathbb {R}}^n\), \(Z_1, Z_2, Z\subset {\mathbb {R}}^n\setminus W\) and \(\varepsilon , \eta \in (0, +\infty )\), then

$$\begin{aligned}{} & {} G_\eta (Z_1\cup Z_2, W) = G_\eta (Z_1, W)\cup G_\eta (Z_2, W) \quad \text {and} \quad \\{} & {} G_\varepsilon (G_\eta (Z, W), W)\subset G_{\varepsilon + \eta + \varepsilon \eta }(Z, W). \end{aligned}$$

Proof

The first being straightforward, we will check the second inclusion. Let \(x\in G_\varepsilon (G_\eta (Z, W), W)\). Hence, \(d(x, G_\eta (Z, W)) < \varepsilon d(x, W)\). It follows that there exists \(y\in G_\eta (Z, W)\) such that \(|x - y| < \varepsilon d(x, W)\). On the other hand \(d(y, Z)< \eta d(y, W)\); thus,

$$\begin{aligned}{} & {} d(x, Z)\le |x - y| + d(y, Z)< \varepsilon d(x, W) \\ {}{} & {} \quad + \eta d(y, W)\le \varepsilon d(x, W) + \eta [|x - y| + d(x, W)] \\{} & {} < \varepsilon d(x, W) + \eta \varepsilon d(x, W) + \eta d(x, W) = (\varepsilon + \eta + \varepsilon \eta ) d(x, W). \end{aligned}$$

\(\square \)

Lemma 3.8

If W is a closed semialgebraic subset of \({\mathbb {R}}^n\) and \(Z_1,\dots , Z_k\subset {\mathbb {R}}^n{\setminus } W\) and if \({\mathcal {B}}_n(Z_i, W)\) holds for every \(i\in \{1,\dots , k\}\), then \({\mathcal {B}}_n(\bigcup _{i = 1}^k Z_i, W)\) holds.

Proof

Take a piecewise polynomial \({\mathcal {C}}^p\)-function \(P: {\mathbb {R}}\longrightarrow [0, 1]\) such that \(P(t) = 1\), when \(t\le 1/3\), and \(P(t) = 0\), when \(t\ge 2/3\). For any given \(\eta > 0\), let \(\psi _i: {\mathbb {R}}^n{\setminus } W\longrightarrow [0, 1]\)   \((i\in \{1,\dots , k\})\)   be a \(\Lambda ^0_p(W)\)-regular function such that \(\psi _i = 1\) on \(G_\rho (Z_i, W)\), where \(\rho \in (0, \eta )\), and \(\mathrm supp\) \(\psi _i\subset G_\eta (Z_i, W)\). Since, by Lemma 3.7, \(G_\eta (\bigcup _{i=1}^k Z_i, W) = \bigcup _{i=1}^k G_\eta (Z_i, W)\), the function

$$\begin{aligned} \psi : {\mathbb {R}}^n\setminus W\ni x \longmapsto 1 - P\left( \sum _{i=1}^k \psi _i(x)\right) \in [0, 1] \end{aligned}$$

is a \(\Lambda ^0_p(W)\)-regular function (by Lemma 3.5) corresponding to \(\bigcup _{i=1}^k Z_i\). \(\square \)

Proposition 3.9

For any closed semialgebraic subset W of \({\mathbb {R}}^n\) and any semialgebraic \(Z\subset {\mathbb {R}}^n\setminus W\), the property \(\mathcal B_n(Z, W)\) holds.

Proof

We argue by induction on \(m = \dim Z\). If \(m = 0\), in view of Lemma 3.8, one can assume that \(Z = \{z\}\) is a singleton. If \(\eta > 0\), then there exists \(\rho \in (0, \eta )\) and \(0< r < R\) such that

$$\begin{aligned} G_\rho (\{z\}, W)\subset B(z, r)\subset B(z, R)\subset G_\eta (\{z\}, W), \end{aligned}$$

where \(B(z, r):= \{x\in {\mathbb {R}}^n: \, |x - z|\le r\}\). Now, it is enough to take a semialgebraic \({\mathcal {C}}^p\)-function \(\psi :{\mathbb {R}}^n\longrightarrow [0, 1]\) such that \(\psi = 0\) on \({\mathbb {R}}^n{\setminus } B(z, R)\) and \(\psi = 1\) on B(zr).

Let now \(m\in \{1,\dots , n-1\}\) and assume that \({\mathcal {B}}_n(Z', W)\) holds for any semialgebraic subset \(Z'\subset {\mathbb {R}}^n\setminus W\), such that \(\dim Z' < m\).

By Theorem 2.6 applied to the sets Z and W and to the Lipschitz function \(g(x):= d(x, W)\), combined with Lemma 3.8 and the induction hypothesis, we reduce the general case to that where Z is a \(\Lambda _p\)-regular cell (2.3);

$$\begin{aligned} Z = \{(u, w): \, u\in T, w = \varphi (u)\}, \end{aligned}$$

where \(u = (x_1,\dots , x_m)\), \(w = (x_{m+1},\dots , x_n)\),   T is an open \(\Lambda _p\)-regular cell in \({\mathbb {R}}^m\), and \(\varphi : T\longrightarrow {\mathbb {R}}^{n-m}\) is a semialgebraic \(\Lambda _p\)-regular mapping, and moreover, the function

$$\begin{aligned} T\ni u \longmapsto d\big ((u,\varphi (u)), W\big )\in {\mathbb {R}}\end{aligned}$$

is \(\Lambda _p\)-regular.

It is elementary that if \(M\ge 0\) is a Lipschitz constant of the mapping \(\varphi \), then putting \(L:= 1/\sqrt{1 + M^2}\), we have

$$\begin{aligned} \forall x = (u, w)\in T\times {\mathbb {R}}^{n-m}: \, L|w - \varphi (u)| \le d(x, Z) \le |w - \varphi (u)| \end{aligned}$$
(3.3)

and

$$\begin{aligned} \forall \, x\in {\mathbb {R}}^n\setminus (T\times {\mathbb {R}}^{n-m}): \, d(x, Z) \ge L d(x, \partial Z). \end{aligned}$$
(3.4)

Take any \(\eta \) such that

$$\begin{aligned} 0< \eta < L. \end{aligned}$$
(3.5)

Fix any \(\eta '\in (0, \eta )\). By the induction hypothesis applied to \(Z':= \partial Z {\setminus } W\), where \(\partial Z:= \overline{Z}{\setminus } Z\), there exists a \(\Lambda ^0_p(W)\)-regular function \(\lambda : {\mathbb {R}}^n\setminus W\longrightarrow [0, 1]\)   such that \(\mathrm supp\) \(\lambda \subset G_{\eta '}(Z', W)\)   and   \(\lambda \equiv 1\)   on \(G_{\rho '}(Z', W)\),   for some \(\rho '\in (0, \eta ')\).

Put

$$\begin{aligned} \psi (x) = \psi (u, w):= \big (1 - \lambda (x)\big )P\left( \frac{|w - \varphi (u)|^2}{\gamma d\big ((u,\varphi (u)), W\big )^2}\right) + \lambda (x), \end{aligned}$$

where \(x = (u, w)\in T\times {\mathbb {R}}^{n-m}\), P is a function from the proof of Lemma 3.8 and \(\gamma > 0\) is a constant to be carefully chosen. We will show that the function \(\psi \) extends by means of \(\lambda \) to a \(\Lambda ^0_p(W)\)-regular function \(\psi : {\mathbb {R}}^n{\setminus } W\longrightarrow [0, 1]\), provided that \(\gamma > 0\) is sufficiently small.

Fix any \(\delta \in (0, L)\). According to (3.4), the set

$$\begin{aligned} H:= \{x\in {\mathbb {R}}^n\setminus W: \, d(x, Z) > \delta d(x, \partial Z)\}\cup G_{\rho '}(Z', W) \end{aligned}$$

is an open neighborhood of the set \(\big [{\mathbb {R}}^n{\setminus } (T\times {\mathbb {R}}^{n-m})\big ]{\setminus } W\) in the set \({\mathbb {R}}^n\setminus W\).

Lemma 3.10

We claim that if \(\gamma > 0\) is sufficiently small, then \(\psi = \lambda \) on \((T\times {\mathbb {R}}^{n-m})\cap H\).

Indeed, let \(x\in (T\times {\mathbb {R}}^{n-m})\cap H\). If \(x\in G_{\rho '}(Z', W)\), then clearly \(\psi (x) = \lambda (x)\), so let us assume that \(x\not \in G_{\rho '}(Z', W)\); i.e.

$$\begin{aligned} d(x, \partial Z\setminus W) \ge {\rho '} d(x, W). \end{aligned}$$
(3.6)

The following two cases are possible: \(d(x, \partial Z) = d(x, (\partial Z){\setminus } W)\), or

\(d(x, \partial Z) = d(x, (\partial Z)\cap W)\).

In the first case, we have in view of (3.6)

$$\begin{aligned} d\big ((u, \varphi (u)), W\big ){} & {} \le |(u, \varphi (u)) - x| + d(x, W)\\{} & {} \le |w - \varphi (u)| + (1/\rho ')d(x, \partial Z) \le |w - \varphi (u)| + \big (1/(\rho '\delta )\big )d(x, Z)\\{} & {} \le |w - \varphi (u)| + \big (1/(\rho '\delta )\big )|w - \varphi (u)|. \end{aligned}$$

Hence

$$\begin{aligned} \frac{|w - \varphi (u)|^2}{\gamma d\big ((u, \varphi (u)), W\big )^2} \ge \frac{(\rho '\delta )^2}{\gamma (1 + \rho '\delta )^2} > 2/3, \end{aligned}$$

if only

$$\begin{aligned} 0< \gamma < \frac{3(\rho '\delta )^2}{2(1 + \rho '\delta )^2}. \end{aligned}$$
(3.7)

In the second case, we have

$$\begin{aligned} d\big ((u, \varphi (u)), W\big ){} & {} \le |(u, \varphi (u)) - x| + d(x, W)\\{} & {} \le |w - \varphi (u)| + d(x, (\partial Z)\cap W) = |w - \varphi (u)| + d(x, \partial Z)\\{} & {} < |w - \varphi (u)| + (1/\delta )d(x, Z) \le |w - \varphi (u)| + (1/\delta )|w - \varphi (u)|. \end{aligned}$$

Hence, if \(\gamma \) satisfies (3.7), then we have again

$$\begin{aligned} \frac{|w - \varphi (u)|^2}{\gamma d\big ((u, \varphi (u)), W\big )^2} \ge \frac{\delta ^2}{\gamma (1 + \delta )^2}> \frac{(\rho '\delta )^2}{\gamma ( 1 + \rho '\delta )^2} > 2/3, \end{aligned}$$

since \(\rho ' < 1\).

It follows that if \(\gamma \) satisfies (3.7), then

$$\begin{aligned} P\left( \frac{|w - \varphi (u)|^2}{\gamma d\big ((u,\varphi (u)), W\big )^2}\right) = 0, \end{aligned}$$

hence \(\psi (x) = \lambda (x)\), which ends the proof of Lemma 3.10.

Now, we will show that, if \(\gamma > 0\) satisfies (3.7), then \(\mathrm supp\) \(\psi \subset G_\eta (Z, W)\). Let \(x\in {\mathbb {R}}^n\setminus W\) and \(x\not \in G_{\eta '}(Z, W)\), so

$$\begin{aligned} d(x, Z) \ge \eta ' d(x, W). \end{aligned}$$
(3.8)

In the case when \(x\in H\), we have \(d(x, Z')\ge d(x, Z) \ge \eta ' d(x, W)\); hence, \(\psi (x) = \lambda (x) = 0\). In the case when \(x\not \in H\), we have in particular that \(x\in T\times {\mathbb {R}}^{n-m}\). As before, \(d(x, Z')\ge d(x, Z) \ge \eta ' d(x, W)\); hence, \(\lambda (x) = 0\). Moreover,

$$\begin{aligned} d\big ((u,\varphi (u)), W\big ){} & {} \le |(u, \varphi (u)) - x| + d(x, W)\\{} & {} \le |w - \varphi (u)| + (1/\eta ')d(x, Z) \le |w - \varphi (u)|\frac{\eta ' + 1}{\eta '}; \end{aligned}$$

hence, if \(\gamma \) satisfies (3.7),

$$\begin{aligned} \frac{|w - \varphi (u)|^2}{\gamma d\big ((u, \varphi (u)), W\big )^2} \ge \frac{(\eta ')^2}{\gamma (1 + \eta ')^2}> \frac{(\rho '\delta )^2}{\gamma (1 + \rho '\delta )^2)} > 2/3, \end{aligned}$$

consequently

$$\begin{aligned} P\left( \frac{|w - \varphi (u)|^2}{\gamma d\big ((u,\varphi (u)), W\big )^2}\right) = 0,\quad \text {thus }\psi (x) = \lambda (x) = 0. \end{aligned}$$

It follows that \(\mathrm supp\) \(\psi \subset G_\eta (Z, W)\).

Now we will find \(\rho \in (0, \eta )\) such that \(\psi \equiv 1\) on \(G_\rho (Z, W)\). Assume first that

$$\begin{aligned} 0< \rho < \rho '\delta \end{aligned}$$
(3.9)

and take any \(x\in G_\rho (Z, W)\); i.e. \(d(x, Z) < \rho d(x, W)\).

If \(x\in G_{\rho '}(Z', W)\), then \(\psi (x) = \lambda (x) = 1\), so in what follows we can assume that \(x\not \in G_{\rho '}(Z', W)\); i.e.

$$\begin{aligned} d(x, Z')\ge \rho ' d(x, W). \end{aligned}$$
(3.10)

Consider two possible cases exactly as in the proof of Lemma 3.10. If \(d(x, \partial Z) = d(x, Z')\), then by (3.9) and (3.10)

$$\begin{aligned} d(x, Z)< \rho d(x, W) < \rho '\delta d(x, W) \le \delta d(x, Z') = \delta d(x, \partial Z), \end{aligned}$$

which implies that \(x\not \in H\). If \(d(x, \partial Z) = d(x, (\partial Z)\cap W)\), then

$$\begin{aligned} d(x, Z)< \rho d(x, W)< \rho '\delta d(x, W) < \delta d(x, W) \le \delta d(x, (\partial Z)\cap W) = \delta d(x, \partial Z), \end{aligned}$$

which again implies that \(x\not \in H\).

Consider now \(x\in G_\rho (Z, W)\setminus H\). Then in particular \(x = (u, w)\in T\times {\mathbb {R}}^{n-m}\) and, according to (3.3),

$$\begin{aligned} L|w -\varphi (u)|{} & {} \le d(x, Z) < \rho d(x, W) \le \rho |x - (u, \varphi (u))| + \rho d\big ((u, \varphi (u)), W\big )\\{} & {} = \rho |w - \varphi (u)| + \rho d\big ((u, \varphi (u)), W\big ). \end{aligned}$$

Hence, if we assume that

$$\begin{aligned} 0< \rho < L\frac{\sqrt{\gamma }}{\sqrt{3} + \sqrt{\gamma }}, \end{aligned}$$
(3.11)

then

$$\begin{aligned} \frac{|w - \varphi (u)|^2}{\gamma d\big ((u, \varphi (u)), W\big )^2}\le \frac{\rho ^2}{\gamma (L - \rho )^2} < 1/3; \end{aligned}$$

consequently,

$$\begin{aligned} P\left( \frac{|w - \varphi (u)|^2}{\gamma d\big ((u,\varphi (u)), W\big )^2}\right) = 1, \quad \hbox { thus \,\,}\ \psi (x) = 1. \end{aligned}$$

We conclude that \(\psi \equiv 1\) on \(G_\rho (Z, W)\), if only \(\rho \) satisfies (3.9) and (3.11).

Now we will check that \(\psi : {\mathbb {R}}^n\longrightarrow [0, 1]\) is \(\Lambda ^0_p(W)\) regular. Since \(\psi = \lambda \) on H and \(\lambda \) is \(\Lambda ^0_p(W)\)-regular, due to induction hypothesis, it suffices to check \(\Lambda ^0_p(W)\)-regularity on \({\mathbb {R}}^n\setminus (\overline{H}\cup W)\). Moreover, since \(\mathrm supp\) \(\psi \subset G_\eta (Z, W)\) and \(\psi \equiv 1\) on \(G_\rho (Z, W)\), it suffices to check \(\Lambda ^0_p(W)\)-regularity, assuming that

$$\begin{aligned} x\in {\mathbb {R}}^n\setminus (\overline{H}\cup W),\, d(x, Z) < \eta d(x, W), \end{aligned}$$
(3.12)

\( \text {and} \,\, d(x, Z') > \rho 'd(x, W).\)

For \(x = (u, w)\in T\times {\mathbb {R}}^{n-m}\) satisfying (3.12), we have by (3.3) and (3.5) that

$$\begin{aligned} d(x, W){} & {} \le d\big ((u, \varphi (u)), W\big ) + |x - (u, \varphi (u))|\\{} & {} \le d\big ((u, \varphi (u)), W\big ) + (1/L)d(x, Z) < d\big ((u, \varphi (u)), W\big ) + (\eta /L)d(x, W); \end{aligned}$$

consequently,

$$\begin{aligned} d(x, W) < \frac{L}{L - \eta }d\big ((u, \varphi (u)), W). \end{aligned}$$
(3.13)

Since by (3.3), (3.12) and (3.13)

$$\begin{aligned} \frac{|w - \varphi (u)|}{d\big ((u, \varphi (u)), W\big )} \le \frac{(1/L) d(x, Z)}{\big (1 - (\eta /L)\big )d(x, W)} < \frac{\eta }{L - \eta }, \end{aligned}$$

and

$$\begin{aligned} \frac{|w - \varphi (u)|^2}{d\big ((u, \varphi (u)), W\big )^2} = \sum _{j = m+1}^n\Big [\frac{x_j - \varphi _j(u)}{d\big ((u, \varphi (u)), W\big )}\Big ]^2, \end{aligned}$$

where \(\varphi = (\varphi _{m+1},\dots , \varphi _n)\), it follows from Lemmas 3.4, 3.3 and 3.5 consecutively applied, that it suffices to check that every function \(f_j(x) = f_j(u, w):= \varphi _j(u)\) and the function \(g(x) = g(u, w):=d\big ((u, \varphi (u)), W\big )\) are \(\Lambda ^1_p(W)\)-regularFootnote 2 on the set (3.12).

To this end, take any \(\alpha \in {\mathbb {N}}^n\setminus \{0\}\) such that \(|\alpha |\le p\). Then for any \(x = (u, w)\) satisfying (3.12),

$$\begin{aligned} |D^\alpha f_j(x)|{} & {} \le C d(u, \partial T)^{1 - |\alpha |} \le C L^{1-|\alpha |}d\big ((u, \varphi (u)),\partial Z)^{1-|\alpha |}\\{} & {} \le C L^{1-|\alpha |}\max \Big [d\big ((u,\varphi (u)), Z'\big )^{1-|\alpha |}, d\big ((u, \varphi (u)), (\partial Z)\cap W\big )^{1-|\alpha |}\Big ], \end{aligned}$$

where C is a positive constant.

On the other hand, by (3.3) and (3.12),

$$\begin{aligned} d\big ((u, \varphi (u)), Z'\big ){} & {} \ge d(x, Z') - |w - \varphi (u)|\ge d(x, Z') - (1/L)d(x, Z)\\{} & {} \ge d(x, Z') - (\delta /L)d(x, \partial Z) \ge d(x, Z') - (\delta /L)d(x, Z')\\{} & {} \ge \rho '\Big (1 - \frac{\delta }{L}\Big )d(x, W), \end{aligned}$$

and, by (3.13),

$$\begin{aligned} d\big ((u, \varphi (u)), (\partial Z)\cap W\big )\ge d\big ((u, \varphi (u)), W\big ) > \Big (1 - \frac{\eta }{L}\Big )d(x, W). \end{aligned}$$

It follows that \(|D^\alpha f_j(x)|\le \tilde{C}d(x, W)^{1- |\alpha |}\), where \(\tilde{C}\) is a positive constant. The same estimate holds for g, which ends the proof that \(\psi \) is \(\Lambda ^0_p(W)\)-regular.

To finish the proof of Proposition 3.9, it remains to consider the case \(m = n\); i.e. Z is an open semialgebraic subset of \({\mathbb {R}}^n{\setminus } W\). Let \(\eta > 0\). By induction hypothesis applied to \(Z':= \partial Z\setminus W\), there exists a \(\Lambda ^0_p(W)\)-regular function \(\lambda : {\mathbb {R}}^n{\setminus } W\longrightarrow [0, 1]\) such that \(\mathrm supp\) \(\lambda \subset G_\eta (Z', W)\) and \(\lambda \equiv 1\) on \(G_\rho (Z', W)\), for some \(\rho \in (0, \eta )\). Now, we define

$$\begin{aligned} \psi (x):= {\left\{ \begin{array}{ll} 1, &{}\text {when }x\in Z\\ \lambda (x), &{}\text {when }x\in \big [({\mathbb {R}}^n\setminus W)\setminus \overline{Z}\big ]\cup G_\rho (Z', W). \end{array}\right. } \end{aligned}$$

Clearly, \(\psi : {\mathbb {R}}^n\setminus W\longrightarrow [0, 1]\) is \(\Lambda ^0_p(W)\)-regular,   \(\mathrm supp\) \(\psi \subset G_\eta (Z, W)\)   and   \(\psi \equiv 1\) on \(G_\rho (Z, W)\). \(\square \)

Proof of Theorem 3.2

By Proposition 3.9, for each \(i\in \{1,\dots , s\}\), there exists a \(\Lambda ^0_p(W)\)-regular function \(\psi _i: {\mathbb {R}}^n{\setminus } W\longrightarrow [0, 1]\) such that \(\mathrm supp\) \(\psi _i\subset G_\eta (U_i, Z)\) and \(\psi _i \equiv 1\) on \(G_{\rho _i}(U_i, W)\), for some \(\rho _i\in (0, \eta )\). By Lemmas 3.4 and 3.3, the functions

$$\begin{aligned} \omega _i:= \frac{\psi _i}{\psi _1 + \dots + \psi _s} \quad (i\in \{1,\dots , s\}) \end{aligned}$$

are the required partition of unity.

4 Proof of Theorem 1.3

By Theorem 2.6, applied to g and the set W, we obtain a \(\Lambda _p\)-regular stratification \({\mathbb {R}}^n{\setminus } W = C_1\cup \dots \cup C_s\) of the set \({\mathbb {R}}^n\setminus W\), such that, for each \(i\in \{1,\dots , s\}\), the stratum \(C_i\), after an orthogonal linear change of coordinates in \({\mathbb {R}}^n\), is a \(\Lambda _p\)-regular cell in \({\mathbb {R}}^n\) and if \(C_i\) is open then \(g|C_i\) is \(\Lambda _p\)-regular, while in the case \(\dim C_i = m < n\), when \(C_i\) is of the form

$$\begin{aligned} C_i = \{(u, w)\in D_i\times {\mathbb {R}}^{n-m}:w = \varphi _i(u)\}, \end{aligned}$$
(4.1)

where \(D_i\) is open in \({\mathbb {R}}^m\) and \(\varphi _i: D_i\longrightarrow {\mathbb {R}}^{n-m}\) is \(\Lambda _p\)-regular, then

$$\begin{aligned} \text {the mapping }D_i\ni u\longmapsto g(u, \varphi _i(u))\in {\mathbb {R}}^d\text { is }\Lambda _p\text {-regular.} \end{aligned}$$
(4.2)

Additionally, without any loss in generality, we can assume that

$$\begin{aligned} \dim C_1 \le \dim C_2 \le \dots \le \dim C_s. \end{aligned}$$
(4.3)

If \(C_i\) is of the form (4.1) and \(M_i\) is a Lipschitz constant of \(\varphi _i\), then we put \(L_i:= 1/\sqrt{1 + M_i^2}\). If \(\dim C_i = n\), we put \(L_i:= 1\). Let A be a Lipschitz constant of g.

To simplify the notation, we will write in this section \(G_\eta (Z)\) in the place of \(G_\eta (Z, W)\), for any \(\eta > 0\) and any semialgebraic subset \(Z\subset {\mathbb {R}}^n\setminus W\). This will not lead to a confusion because the set W is fixed in this section.

Given any \(\kappa >0\) as in Theorem 1.3, fix any \(\theta \in (0, 1)\) so small that \(A(\theta /L_i) <\kappa \), for each \(i\in \{1,\dots , s\}\). We define by induction on \(i\in \{1,\dots , s\}\), a sequence of semialgebraic sets \(Z_1\subset C_1, \dots , Z_s\subset C_s\), and two sequences of positive numbers \(\eta _s< \delta _s< \eta _{s-1}< \delta _{s-1}< \dots< \eta _1< \delta _1 < \theta \) such that

$$\begin{aligned} d(x, C_1\cup \dots \cup C_i) < \eta _id(x, W) \Longrightarrow \end{aligned}$$
(4.4)

\( x\in G_{\eta _i}(Z_i)\cup G_{\eta _i}(G_{\eta _{i-1}}(Z_{i-1}))\cup \dots \cup G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _1}(Z_1))\dots ));\)

$$\begin{aligned} \text {there exists a }\Lambda ^1_p(W)\text {-regular function }f_i: G_{\delta _i}(Z_i)\longrightarrow {\mathbb {R}}\end{aligned}$$
(4.5)

\(\text {such that} \quad \forall \, x\in G_{\delta _i}(Z_i): \, |f_i(x) - g(x)|\le A(\delta _i/L_i) d(x, W)\);

$$\begin{aligned} \text {for every }j\in \{1,\dots , i\}\text { there exists }\varepsilon _{ij} \in (0, \delta _j)\text { such that } \end{aligned}$$
(4.6)

\( G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _j}(Z_j))\dots ))\subset G_{\varepsilon _{ij}}(Z_j).\)

To begin the inductive definition, we put \(Z_1:= C_1\). Since \(C_1\) is the first stratum, its boundary \(\partial Z_1:= \overline{Z_1}{\setminus } Z_1\) is contained in W. Take any \(\delta _1 < \min \{\theta , L_1\}\). Then, for each \(x\in G_{\delta _1}(Z_1)\), we have

$$\begin{aligned} d(x, Z_1)< \delta _1 d(x, W) \le \delta _1 d(x, \partial Z_1); \end{aligned}$$

hence, by (3.4), \(x = (u, w)\in D_1\times {\mathbb {R}}^{n- m_1}\),   where   \(m_1 = \dim C_1\). Therefore, we can define

$$\begin{aligned} f_1(x) = f_1(u, w):= g(u, \varphi _1(u)). \end{aligned}$$

Then, by (3.3),

$$\begin{aligned}{} & {} |f_1(x) - g(x)| = |g(u, \varphi _1(u)) - g(u, w)|\le A|w - \varphi _1(u)|\\{} & {} \quad \le AL_1^{-1}d(x, C_1)\le A(\delta _1/L_1)d(x, W). \end{aligned}$$

To check that \(f_1\) is \(\Lambda ^1_p(W)\)-regular, we take any \(\alpha \in {\mathbb {N}}^n\setminus \{0\}\) such that \(|\alpha |\le p\). Then we have by (4.2)

$$\begin{aligned} |D^\alpha f_1(x)|{} & {} \le B_1d(u, \partial D_1)^{1-|\alpha |}\le B_1(L_1)^{1-|\alpha |}d\big ((u, \varphi _1(u)), \partial Z_1\big )^{1-|\alpha |}\\{} & {} \le B_1(L_1)^{1-|\alpha |}\Big [d(x, \partial Z_1) - |w - \varphi _1(u)|\Big ]^{1-|\alpha |}\\{} & {} \le B_1(L_1)^{1-|\alpha |}\Big [d(x, \partial Z_1) - L_1^{-1}d(x, Z_1)\Big ]^{1-|\alpha |}\\{} & {} \le B_1(L_1)^{1-|\alpha |}\Big (1 - \frac{\delta _1}{L_1}\Big )^{1-|\alpha |}d(x, W)^{1 - |\alpha |}, \end{aligned}$$

where \(B_1\) is a positive constant. Fix any \(\eta _1\in (0, \delta _1)\) and put \(\varepsilon _{11}:=\eta _1\).

To define \(Z_{i+1}\), where \(i < s\), observe that, due to (4.3) and (4.4),

$$\begin{aligned} (\partial C_{i+1})\setminus W \subset C_1\cup \dots \cup C_i\subset G_{\eta _i}(Z_i)\cup \dots \cup G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _1}(Z_1))\dots )). \end{aligned}$$

Put

$$\begin{aligned} Z_{i+1}:= C_{i+1}\setminus \Big [G_{\eta _i}(Z_i)\cup \dots \cup G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _1}(Z_1))\dots ))\Big ]. \end{aligned}$$

By (4.4)

$$\begin{aligned} \forall \, z&\in Z_{i+1}: \,\, d(z, \partial C_{i+1}) = \min \big \{d(z, (\partial C_{i+1})\setminus W), d(z, (\partial C_{i+1})\cap W)\big \}\nonumber \\&\ge \min \big \{d(z, C_1\cup \dots \cup C_i), d(z, W)\big \} \ge \eta _id(z, W). \end{aligned}$$
(4.7)

Assume first that \(\dim C_{i+1} < n\). Then we choose \(\delta _{i+1}\in (0, \eta _i/(1 + \eta _i))\) in such a way that

$$\begin{aligned} \frac{\delta _{i+1}}{\eta _i - \delta _{i+1}(\eta _i + 1)} < L_{i+1}. \end{aligned}$$
(4.8)

We will now check that

$$\begin{aligned} G_{\delta _{i+1}}(Z_{i+1}) \subset D_{i+1}\times {\mathbb {R}}^{n- m_{i+1}}. \end{aligned}$$
(4.9)

Indeed, take any \(x\in G_{\delta _{i+1}}(Z_{i+1})\). There exists \(z\in Z_{i+1}\) such that \(|x - z|< \delta _{i+1}d(x, W)\). By (4.7), we have

$$\begin{aligned} |x - z|{} & {} < \delta _{i+1}\big (|x - z| + d(z, W)\big )\le \delta _{i+1}|x - z| + \frac{\delta _{i+1}}{\eta _i}d(z, \partial C_{i+1})\\{} & {} \le \big (\delta _{i+1} + \frac{\delta _{i+1}}{\eta _i}\big )|x - z| + \frac{\delta _{i+1}}{\eta _i}d(x, \partial C_{i+1}) \end{aligned}$$

hence,

$$\begin{aligned} d(x, C_{i+1}) \le |x - z| < \frac{\delta _{i+1}}{\eta _i - \delta _{i+1}(\eta _i + 1)}d(x, \partial C_{i+1}) \end{aligned}$$

which, in view of (4.8) and (3.4), implies that \(x\in D_{i+1}\times {\mathbb {R}}^{n - m_{i+1}}\).

In view of (4.9), the following definition of \(f_{i+1}: G_{\delta _{i+1}}(Z_{i+1})\longrightarrow {\mathbb {R}}\) is possible

$$\begin{aligned} f_{i+1}(x) = f_{i+1}(u, w):= g(u,\varphi _{i+1}(u)). \end{aligned}$$

Then, we have

$$\begin{aligned}{} & {} |f_{i+1}(x) - g(x)|\le A|w - \varphi _{i+1}(u)|\le (A/L_{i+1})d(x, C_{i+1})\\{} & {} \quad \le (A/L_{i+1})d(x, Z_{i+1})< A(\delta _{i+1}/L_{i+1})d(x, W). \end{aligned}$$

Now we want to check that \(f_{i+1}\) is \(\Lambda ^1_p(W)\)-regular. Let \(\alpha \in {\mathbb {N}}^n\setminus \{0\}\) be such that \(|\alpha |\le p\) and let \(x\in G_{\delta _{i+1}}(Z_{i+1})\). Then there exists \(z\in Z_{i+1}\) such that \(|x - z| < \delta _{i+1}d(x, W)\). By (4.2) and (4.7), we get

$$\begin{aligned}{} & {} |D^\alpha f_{i+1}(x)|\le B_{i+1}d(u, \partial D_{i+1})^{1 - |\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1-|\alpha |}d\big ((u, \varphi _{i+1}(u)), \partial C_{i+1}\big )^{1-|\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1 - |\alpha |}\Big [d(z, \partial C_{i+1}) - |(u, \varphi _{i+1}(u)) - z|\Big ]^{1 - |\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1 - |\alpha |}\Big [\eta _id(z, W) - |(u, \varphi _{i+1}(u)) - z|\Big ]^{1 - |\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1 - |\alpha |}\Big [\eta _i d(x, W) - \eta _i|x - z| - |x - z| - |(u, \varphi _{i+1}(u)) - x|\Big ]^{1 - |\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1 - |\alpha |}\Big [\eta _i d(x, W) - (\eta _i + 1)|x - z| - |w - \varphi _{i+1}(u)|\Big ]^{1 - |\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1 - |\alpha |}\Big [\eta _i d(x, W) - (\eta _i + 1)\delta _{i+1}d(x, W) - (1/L_{i+1})d(x, C_{i+1})\Big ]^{1 - |\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1 - |\alpha |}\Big [\eta _i d(x, W) - (\eta _i + 1)\delta _{i+1}d(x, W) - (1/L_{i+1})d(x, Z_{i+1})\Big ]^{1 - |\alpha |}\\{} & {} \quad \le B_{i+1}(L_{i+1})^{1 - |\alpha |}\Big [\eta _i d(x, W) - (\eta _i + 1)\delta _{i+1}d(x, W) - (\delta _{i+1}/L_{i+1})d(x, W)\Big ]^{1 - |\alpha |}\\{} & {} \quad = B_{i+1}[\eta _i - \delta _{i+1}(\eta _i +1)]^{1- |\alpha |}\Big (L_{i+1} - \frac{\delta _{i+1}}{\eta _i - \delta _{i+1}(\eta _i + 1)}\Big )^{1-|\alpha |}d(x, W)^{1-|\alpha |}, \end{aligned}$$

where \(B_{i+1}\) is a positive constant.

Assume now that \(\dim C_{i+1} = n\). Then we fix any \(\delta _{i+1} \in (0, \eta _i/(1+\eta _i))\). If \(x\in G_{\delta _{i+1}}(Z_{i+1})\), then there exists \(z\in Z_{i+1}\) such that \(|x - z|< \delta _{i+1}d(x, W)\), and by (4.7)

$$\begin{aligned} |x - z| < \delta _{i+1}|x - z| + \delta _{i+1}d(z, W)\le \delta _{i+1}|x - z| + \frac{\delta _{i+1}}{\eta _i}d(z, \partial C_{i+1}); \end{aligned}$$

thus,

$$\begin{aligned} |x - z|< \frac{\delta _{i+1}}{(1 - \delta _{i+1})\eta _i}d(z, \partial C_{i+1}) < d(z, \partial C_{i+1}). \end{aligned}$$

It follows that

$$\begin{aligned} G_{\delta _{i+1}}(Z_{i+1})\subset C_{i+1}; \end{aligned}$$
(4.10)

hence we can define \(f_{i+1}\) as the restriction \(g|C_{i+1}\) of g to \(C_{i+1}\). Clearly, \(f_{i+1}\) is \(\varLambda _p^1(W)\)-regular and corresponding condition (4.5) is trivially satisfied, since then the left-hand side is identically zero.

Now we will need to specify \(\eta _{i+1}\in (0, \delta _{i+1})\). To this end we will need the properties of the operation \(G_\delta \) expressed in Lemma 3.7. We take any \(\eta _{i+1}\in (0, \delta _{i+1})\) so small that

$$\begin{aligned} \varepsilon _{i+1,j}:= \varepsilon _{ij} + \eta _{i+1} + \eta _{i+1}\varepsilon _{ij} < \delta _j \qquad (j\in \{1,\dots ,i\}) \end{aligned}$$

and \(\varepsilon _{i+1,i+1}:=\eta _{i+1}\), both in the case \(\dim C_{i+1} < n\) as well as when \(\dim C_{i+1} = n\). This choice ensures (4.6) for \(i+1\) in the place of i, according to Lemma 3.7.

Now we will check the property (4.4) for \(i+1\) in the place of i.

Let \(d(x, C_1\cup \dots \cup C_i\cup C_{i+1}) < \eta _{i+1}d(x, W)\).

If \(d(x, C_1\cup \dots \cup C_i\cup C_{i+1}) = d(x, C_1\cup \dots \cup C_i)\), then by (4.4), \(x\in G_{\eta _i}(Z_i)\cup G_{\eta _i}(G_{\eta _{i-1}}(Z_{i-1}))\cup \dots \cup G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _1}(Z_1))\dots ))\).

If \(d(x, C_1\cup \dots \cup C_i\cup C_{i+1}) = d(x, Z_{i+1})\), then certainly \(d(x, Z_{i+1}) < \eta _{i+1}d(x, W)\); thus, \(x\in G_{\eta _{i+1}}(Z_{i+1})\).

It remains the case, when \(d(x, C_1\cup \dots \cup C_i\cup C_{i+1}) = \)

$$\begin{aligned} d\Big (x, C_{i+1}\cap \big [G_{\eta _i}(Z_i)\cup G_{\eta _i}(G_{\eta _{i-1}}(Z_{i-1}))\cup \dots \cup G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _1}(Z_1))\dots ))\big ]\Big ). \end{aligned}$$

Then

$$\begin{aligned} d\Big (x, G_{\eta _i}(Z_i)\cup G_{\eta _i}(G_{\eta _{i-1}}(Z_{i-1}))\cup \dots \cup G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _1}(Z_1))\dots ))\Big ) \end{aligned}$$

\(< \eta _{i+1}d(x, W)\); thus,

$$\begin{aligned}{} & {} x\in G_{\eta _{i+1}}(G_{\eta _i}(Z_i))\cup G_{\eta _{i+1}}(G_{\eta _i}(G_{\eta _{i-1}}(Z_{i-1})))\cup \dots \\{} & {} \dots \cup G_{\eta _{i+1}}(G_{\eta _i}(G_{\eta _{i-1}}(\dots (G_{\eta _1}(Z_1))\dots ))). \end{aligned}$$

To finish the proof of Theorem 1.3, we put

$$\begin{aligned} U_i:= G_{\eta _s}(\dots (G_{\eta _i}(Z_i))\dots ),\quad \text {for }i\in \{1,\dots ,s\}, \end{aligned}$$

and choose \(\eta > 0\) so small that \(G_\eta (U_i)\subset G_{\delta _i}(Z_i)\), for each \(i\in \{1,\dots , s\}\) (see (4.6) and Lemma 3.7). It follows from (4.4) that \(U_1,\dots , U_s\) is a covering of \({\mathbb {R}}^n\setminus W\). We take now the partition of unity \(\{\omega _i\}\)    \((i\in \{1,\dots , s\})\) adapted to this covering and to \(\eta \) according to Theorem 3.2. In virtue of Lemma 3.3, for each \(i\in \{1,\dots , s\}\), the function \(f_i\omega _i\) is \(\varLambda _p^1(W)\)-regular on \(G_{\delta _i}(Z_i)\) and obviously extends by zero to a \(\varLambda _p^1(W)\)-regular function defined on \({\mathbb {R}}^n\setminus W\) and, by (4.5), for each \(x\in {\mathbb {R}}^n{\setminus } W\),

$$\begin{aligned} |f_i(x)\omega _i(x) - g(x)\omega _i(x)|\le & {} A(\delta _i/L_i)d(x, W)\omega _i(x)\\\le & {} A(\theta /L_i)d(x, W)\omega _i(x)< \kappa d(x, W)\omega _i(x). \end{aligned}$$

Hence the function

$$\begin{aligned} f:= f_1\omega _1 + \dots + f_s\omega _s, \end{aligned}$$

is \(\varLambda _p^1(W)\)-regular on \({\mathbb {R}}^n\setminus W\) and for each \(x\in {\mathbb {R}}^n\setminus W\)

$$\begin{aligned} |f(x) - g(x)|\le \sum _{i=1}^s|f_i(x)\omega _i(x) - g(x)\omega _i(x)|\le \sum _{i=1}^s\kappa d(x, W)\omega _i(x) = \kappa d(x, W), \end{aligned}$$

which ends the proof of Theorem 1.3.

5 Two applications

We give here two almost immediate consequences of Theorem 1.1. The first one is another proof of a theorem of Bierstone, Milman and Pawłucki (cf. [3, C.11]) that, given any positive integer p, any closed semialgebraic (or, more generally, definable in some o-minimal structure \({\mathcal {S}}\)) subset W of \({\mathbb {R}}^n\) is the zero-set of some semialgebraic (respectively, definable in \(\mathcal S\)) \({\mathcal {C}}^p\)-function defined on \({\mathbb {R}}^n\). We will prove the following.

Theorem 5.1

Let W be a closed semialgebraic subset of \({\mathbb {R}}^n\) and let p be a positive integer. Then there exists a semialgebraic function \(h: {\mathbb {R}}^n \longrightarrow [0, \infty )\) of class \({\mathcal {C}}^p\), which is Nash on \({\mathbb {R}}^n\setminus W\) and such that \(W = h^{-1}(0)\). Moreover, h is equivalent to the \((p+1)\)-th power of the distance function from the set W.

In the proof we will use the following elementary Hestenes Lemma (cf. [15, Lemme 4.3]).

Lemma 5.2

Let W be a closed subset of an open subset \(\varOmega \) of \({\mathbb {R}}^n\). If \(h: \varOmega {\setminus } W\longrightarrow {\mathbb {R}}\) is a \({\mathcal {C}}^p\)-function and

$$\begin{aligned} \lim _{x \rightarrow a}D^\alpha h(x) = 0, \end{aligned}$$

for each \(a\in W\cap \overline{\varOmega \setminus W}\) and each \(\alpha \in {\mathbb {N}}^n\) such that \(|\alpha |\le p\), then h extends by zero to a \({\mathcal {C}}^p\)-function on \(\varOmega \), p-flat on W.

Proof of Theorem 5.1

By Theorem 1.1 there exists a semialgebraic \(\Lambda ^1_p(W)\)-regular Nash function \(f:{\mathbb {R}}^n\setminus W \longrightarrow (0, \infty )\) equivalent to the function \({\mathbb {R}}^n{\setminus } W\ni x \longmapsto d(x, W)\). When we put \(h:=f^{p+1}\), we have, for any \(\alpha \in {\mathbb {N}}^n\) such that \(|\alpha |\le p\) and any \(x\in \varOmega \setminus W\)

$$\begin{aligned} D^\alpha h(x) = \sum _{\beta _1 +\dots + \beta _{p+1} = \alpha }\frac{\alpha !}{\beta _1!\dots \beta _{p+1}!}D^{\beta _1}f(x)\dots D^{\beta _{p+1}}f(x). \end{aligned}$$
(5.1)

It follows that

$$\begin{aligned}{} & {} |D^\alpha h(x)|\le \sum _{\beta _1 +\dots + \beta _{p+1} = \alpha }C\big (d(x, W)\big )^{1-|\beta _1|}\dots \big (d(x, W)\big )^{1-|\beta _{p+1}|}\\{} & {} \quad \le \tilde{C}\big (d(x, W)\big )^{p+1-|\alpha |}, \quad \text {where } C\text { and }\tilde{C}\text { are positive constants,} \end{aligned}$$

which implies that \(\lim _{x\rightarrow a}D^\alpha h(x) = 0\), for each \(a\in W\cap \overline{{\mathbb {R}}^n{\setminus } W}\). \(\square \)

Our second application concerns approximation of semialgebraic subsets by Nash compact hypersurfaces in the Hausdorff metric. To formulate the result let us denote by \({\mathcal {K}}_n\) the set of all nonempty compact subsets of \({\mathbb {R}}^n\). Recall that the Hausdorff metric on \({\mathcal {K}}_n\) is defined by the formula

$$\begin{aligned} d_{{\mathcal {H}}}(A, B):=\max \{\sup _{x\in A}d(x, B), \sup _{y\in B}d(y, A)\}. \end{aligned}$$

Theorem 5.3

Let W be a non-empty, compact, nowhere dense semialgebraic subset of \({\mathbb {R}}^n\). Then there exists a semialgebraic family of Nash compact hypersurfaces \(\{H_t\}\)   \((0< t < \theta )\) such that

$$\begin{aligned} \lim _{t\rightarrow 0}d_{{\mathcal {H}}}(H_t, W) = 0. \end{aligned}$$

Proof

Let \(f:{\mathbb {R}}^n\setminus W\longrightarrow (0, \infty )\) be a Nash function such that for some positive constant A

$$\begin{aligned} \forall \, x\in {\mathbb {R}}^n\setminus W: \,\, A^{-1}d(x, W) \le f(x) \le Ad(x, W). \end{aligned}$$
(5.2)

By Sard’s theorem, the function f has only finitely many critical values; hence, the set \(H_t:= f^{-1}(t)\) is a Nash hypersurface in \({\mathbb {R}}^n\), for all \(t > 0\) sufficiently small. We will show that \(H_t\) are compact and their Hausdorff limit is W, when t tends to 0. For any subset X of \({\mathbb {R}}^n\) and any \(\eta > 0\) put

$$\begin{aligned} X^\eta := \{x\in {\mathbb {R}}^n: \, d(x, X) < \eta \}. \end{aligned}$$

To this end, it is enough to show that, for any positive \(\eta \) there exists \(\delta > 0\) such that for each \(t\in (0, \delta )\)

$$\begin{aligned} H_t \subset W^\eta \qquad \text {and}\qquad W\subset H_t^\eta . \end{aligned}$$
(5.3)

As for the first inclusion (5.3), let \(x\in H_t\). Then by (5.2), \(A^{-1}d(x, W) \le t\); hence, if \(t < A^{-1}\eta \), then \(x\in W^\eta \).

As for the second inclusion (5.3), let us define function

$$\begin{aligned} \lambda (\varepsilon ) := \sup _{a\in W}d(a, \partial W^\varepsilon ), \quad \text {for any }\varepsilon > 0. \end{aligned}$$
(5.4)

We claim that

$$\begin{aligned} \lim _{\varepsilon \rightarrow 0} \lambda (\varepsilon ) = 0. \end{aligned}$$
(5.5)

Otherwise, by the Curve Selection Lemma, there should exist a semialgebraic continuous arc \(\gamma : (0, \xi )\longrightarrow W\), where \(\xi > 0\), such that

$$\begin{aligned}{} & {} \lim _{\varepsilon \rightarrow 0}\gamma (\varepsilon ) = a, \,\text {for some }a\in W,\text { and}\\{} & {} \quad d(\gamma (\varepsilon ), \partial W^\varepsilon )> \mu , \, \text {for some }\mu > 0\text { and each }\varepsilon \in (0, \xi ).\\ \end{aligned}$$

The last would mean that

$$\begin{aligned} B(\gamma (\varepsilon ), \mu )\subset \{x\in {\mathbb {R}}^n: \, d(x, W)\le \varepsilon \}, \, \text {for each }\varepsilon \in (0, \xi ). \end{aligned}$$

But \(B(\gamma (\varepsilon ), \mu )\rightarrow B(a, \mu )\) and \(\{x\in {\mathbb {R}}^n: \, d(x, W)\le \varepsilon \}\rightarrow W\), as \(\varepsilon \rightarrow 0\); hence, \(B(a, \mu )\subset W\), a contradiction with our assumption that W is nowhere dense.

Let \(\eta > 0\). By (5.5), there exists \(\delta > 0\) such that \(\lambda (\delta ) < \eta \). It follows that then

$$\begin{aligned} d(a, \partial W^\delta ) < \eta , \quad \hbox { for each}\ a\in W. \end{aligned}$$

Fix any \(a\in W\). There exists \(z\in \partial W^\delta \) such that \(|a - z| = d(a, \partial W^\delta )\). Observe that the line segment [az] has its endpoints respectively in W and in \(\partial W^\delta \). By (5.2),

$$\begin{aligned} f^{-1}[0, \delta /A)\subset W^\delta ; \end{aligned}$$

hence, there exists \(y\in f^{-1}(\delta /A)\cap [a, z]\). Then \(|a - y|\le |a - z| < \eta \) and \(y\in H^\eta _{\delta /A}\), which shows that \(W\subset H^\eta _{\delta /A}\). \(\square \)

Theorem 5.3 is deepened and generalized in our separate article [6].

6 Final remarks

Most of the results of our article remain true in a more general context of o-minimal structures expanding the field of real numbers \({\mathbb {R}}\) with the same proofs, where the term semialgebraic should be replaced by definable and a Nash mapping - by a definable \({\mathcal {C}}^\infty \) mapping.

As for Theorem 1.1, however, it relies heavily on the Efroymson-Shiota approximation theorem. Theorem 1.4 was generalized by A. Fischer [5, Theorem 1.1]) to o-minimal structures admitting \({\mathcal {C}}^\infty \)-cell decompositions in which the exponential function is definable (the case of non-polynomially bounded structures). For the case of general polynomially bounded o-minimal structures admitting \({\mathcal {C}}^\infty \)-cell decompositions a big progress has been made recently by the last author and Guillaume Valette, who proved that in such structures the Efroymson-Shiota approximation theorem holds true for \(p\le 1\) ( [16, Theorem 4.8]). In particular, this result allows us to prove the following generalization of Theorem 5.1.

Theorem 6.1

Let \({\mathcal {D}}\) be a polynomially bounded o-minimal structure expanding \({\mathbb {R}}\) which admits \({\mathcal {C}}^\infty \)-cell decompositions. Then, for any closed \({\mathcal {D}}\)-definable subset W of \({\mathbb {R}}^n\) and any positive integer p, there exists a \({\mathcal {D}}\)-definable \({\mathcal {C}}^p\)-function \(h:{\mathbb {R}}^n\longrightarrow [0, \infty )\) which is \({\mathcal {C}}^\infty \) on \({\mathbb {R}}^n\setminus W\) and such that \(W = h^{-1}(0)\).

Proof

By [16, Theorem 1.1], there exists a \({\mathcal {D}}\)-definable \({\mathcal {C}}^\infty \)-function \(f: {\mathbb {R}}^n{\setminus } W\longrightarrow [0, \infty )\) such that

$$\begin{aligned} \forall \, x\in {\mathbb {R}}^n\setminus W: A^{-1}f(x) \le d(x, W) \le Af(x), \end{aligned}$$

where A is a positive constant. If N is an integer greater than p, then for any \(\alpha \in {\mathbb {N}}^n\setminus \{0\}\) such that \(|\alpha |\le p\) the derivative \(D^\alpha (f^N)\) is a linear combination with integral coefficients independent of f of products

$$\begin{aligned} f^{N-k}(D^{\beta _1}f)\dots (D^{\beta _k}f), \end{aligned}$$

where \(k\in \{1,\dots , p\}\),   \(\beta _1,\dots , \beta _k\in {\mathbb {N}}^n{\setminus } \{0\}\) and \(\beta _1 + \dots + \beta _k = \alpha \). It follows from the Łojasiewicz inequality and the Hestenes lemma that for N sufficiently big the function

$$\begin{aligned} h(x):= {\left\{ \begin{array}{ll} f^N(x), &{}\text {when }x\in {\mathbb {R}}^n\setminus W\\ 0, &{}\hbox { when}\ x\in W\end{array}\right. } \end{aligned}$$

is the required function. \(\square \)