# Condition for existence of a continuous function realizing a partition

Let $$\{U_i\}_{i=1}^{I}$$ be a non-empty and finite collection of non-empty, disjoint, open, (and obviously bounded) subsets of $$[0,1]^n$$. Suppose also that $$[0,1]^n=\cup_{i =1 }^{ I} \overline{U_i}$$. Under what condition does there exist a continuous function $$f:[0,1]^n\rightarrow [0,1]^I$$ such that $$x\in U_i \Leftrightarrow \|f(x)-e_i\|< \min_{\tilde{i}\neq i}\|f(x)-e_{\tilde{i}}\| ;$$ where $$\{e_i\}_{i=1}^I$$ is the standard basis of $$\mathbb{R}^I$$.

What I have tried:

• In the case where each $$U_i$$ is convex: If $$U_i$$ is convex then there it is star-shaped so there is an $$x_i\in U_i$$ for which every $$x \in U_i$$ can be reached by a line segment emanating from $$x_i$$ and contained within $$U_i$$. Note, since $$U_i$$ is convex then such a line segment must stay within $$U_i$$. Thus, for any $$x'\in \cup_{i\in I} (0,1)^N$$, $$\|x-x_i\|<\min_{\tilde{i}\neq i} \|x-x_{\tilde{i}}\|.$$ So we set: $$f(x)= \left(\|x-x_i\| e_i \right)_{i=1}^I.$$ Is this reasoning correct?

• For the general case, I was trying to use Urysohn's Lemma but alas, to no avail..

For $$x \in U_i$$ let $$f(x) = r e_i$$ where $$r = \min_{y \notin U_i} |x - y|$$, i.e. the radius of the largest open ball centered on $$x$$ and contained in $$U_i$$. If $$x$$ is not in any $$U_i$$ let $$f(x) = 0$$. Note that $$|f(x) - f(y)| \leq |x - y|$$
• What's the $x$ on the right hand side? Jan 31, 2021 at 9:54