Consider an outer semicontinuous set-valued mapping $S: \mathbb{R}^n \rightrightarrows \mathbb{R}^m$.

(Namely the sets $S(x) \subseteq \mathbb{R}^m$ do not "change continuously" as a function of $x$)

1) Find a continuous function $f: \mathbb{R}^n \times \mathbb{R}^m \rightarrow \mathbb{R}_{\geq 0}$ such that

$$f(x,y) = 0 \Longleftrightarrow y \in S(x)$$

2) Can we make $f$ such that $\lim_{|(x,u)| \rightarrow \infty} f(x,y) = \infty$?

For instance the Euclidean distance of $y$ to the set $S(x)$, i.e. $f(x,y) = |y|_{S(x)}$, satisfies the property but it is not continuous.

Note: definition of outer semicontinuity for a set-valued map:

A set-valued mapping $S: \mathbb{R}^n \rightrightarrows \mathbb{R}^m$ is outer semicontinuous at $\bar x$ if

$$\limsup_{x \rightarrow \bar x} S(x) \subset S(\bar x)$$

or equivalently $\limsup_{x \rightarrow \bar x} S(x) = S(\bar x)$.

-

Your idea was almost right – the Euclidean distance of $(x,y)$ from $T=\{(a,b)\mid b\in S(a)\}$ works.
Clearly, if $y\in S(x)$, then $(x,y)\in T$, and $|(x,y)|_T=0$. Conversely, if $|(x,y)|_T=0$, then there is a sequence of points $(x_n,y_n)$ with $y_n\in S(x_n)$ and $\lim_{n\to\infty}(x_n,y_n)=(x,y)$, thus $\lim_{n\to\infty}x_n=x$ and $\lim_{n\to\infty}y_n=y$, and hence $y\in\limsup_{x'\to x}S(x')=S(x)$.
Another way of saying the same thing is that $S$ is outer semicontinuous iff $T$ is closed. See also this.
Thanks. I see the property that $S$ o.s.c. iff $T$ closed ($T$ is the graph of $S$). I don't get how to relate this to the question. Maybe we can say: $S$ o.s.c. iff $T:=graph(S)$ closed; the Euclidean distance to the closed set $T$ is continuous; but then we still need your notes to say that $y \in S(x) \Leftrightarrow |(x,y)|_T = 0$. Where am I wrong? – Adam Jun 19 '12 at 15:37
Can the proof be simplified saying that $y \in S(x)$ iff $(x,y) \in T$ iff $|(x,u)_T = 0|$??? – Adam Jun 19 '12 at 18:57
@Adam: About your first two comments (the second one is slightly garbled): Yes, I was taking for granted that a point has distance $0$ from a closed set iff it's in the set, but you're right that if you want to prove that you need an argument like the one in my answer. I don't understand your question (2) -- either $T$ is bounded, then my function already has that property; or $T$ is unbounded, then that property contradicts the condition $f(x,y) = 0 \Longleftrightarrow y \in S(x)$. – joriki Jun 20 '12 at 3:26
@Adam: You've deleted question (2) in the meantime; the above comments no longer make sense for someone reading the thread now. Please keep in mind that the content of the site is for everyone, not just for those posting. To answer your question: If $T$ is unbounded, then there are points $(x,y)$ with $y\in S(x)$ with $|(x,y)|$ arbitrarily large. If $y\in S(x)$ implies $f(x,y)=0$, that contradicts the condition that $f$ tends to $\infty$ for $|(x,y)|\to\infty$. – joriki Jun 20 '12 at 23:46