Limit, supremum and sets Let $f:\mathcal{X}\to\mathbb{R}$ be a continuous function. Suppose that $X_1,X_2,...,$ is a decreasing sequence of subsets of $\mathcal{X}$ that converges to a subset $X$, i.e., $X_n\downarrow X$ when $n\to\infty$.
Is it true that 
$$
\lim_{n\to\infty}\sup_{x\in X_n}f(x) = \sup_{x\in X}f(x)\quad ?
$$
I think it is, and the reason is that $\sup_{x\in X_n}f(x)$ is a monotone sequence bounded bellow by $\sup_{x\in X}f(x)$. But, is the continuity assumption relevant at all?
I'll appreciate any opinion. 
 A: This formula is not true in general. Let us discuss it a little bit. Since $X\subset X_n$, we certainly have that
$$
\sup_{x\in X} f(x) \leq \lim_{n\to \infty} \sup_{x\in X_n} f(x).
$$
The converse inequality is surely true if we have that $$\sup_{x\in X} f(x)=\sup Im f.$$
If $\sup_{x\in X} f(x)<\sup Im f$ the converse inequality does not hold in general.
Let us see three examples:
(1) If the family of sets $\{X_n:n\in\mathbb N\}$ is unbounded. Just pick $f(x)=x$ and $X_n=[0,1]\cup\{n\}$ .
(2) If $Im f$ is not upper bounded. Just pick some sequence of distinct points $x_1, x_2,..., x_n, ...$ such that $\lim_{n\to\mathbb N} f(x_n)=\infty$ and $X_n=X\cup \{x_k:k\geq n\}$.
(3) What if the function in (1) was upper bounded? The inequality still doesn't hold. Just consider the example (1) with $f(x)=\arctan x$.
Notice that there is a key technique in order to create some family $X_n$ that does not satisfy the converse inequality:

Fix, if possible, a sequence of distinct points $x_n$ on the domain of $f$ such that $$f(x_n)> \sup_{x\in X} f(x) +\varepsilon,\ \forall n\in \mathbb N,$$ for some $\varepsilon>0$, and consider the sets $X_n = X\cup \{x_k: k\geq n\}$. Then, surely, $X=\displaystyle\bigcap_{n\in\mathbb N} X_n$ and $\displaystyle\lim_{n\to \infty} \sup_{x\in X_n} f(x) \geq \sup_{x\in X} f(x) +\varepsilon$.

Therefore, in order to find a hypothesis for the equality to hold, we must prevent the construction of such sequences. One way to do that is to assume that, for any $\varepsilon>0$ the set $\{u\in \mathcal X: f(u) \geq \sup_{x\in X} f(x) +\varepsilon\}$ is finite. Then, this hypothesis is surely necessary. Notice that this hypothesis includes the trivial case $\sup_{x\in X} f(x)=\sup Im f$, for which we already knew that the equality holds. 
It turns out, surprisingly, that this hypothesis is also sufficient, then we have the following result:

A function $f:\mathcal X \to \mathbb R$ satisfies 
  $$
\sup_{x\in X} f(x) \leq \lim_{n\to \infty} \sup_{x\in X_n} f(x),
$$
  for any $\{X_n:n\in\mathbb N\}$ and $X$ satisfying $\bigcap_{n\in\mathbb N} X_n=X$, if, and only if, the sets $\{u\in \mathcal X: f(u) \geq \sup_{x\in X} f(x) +\varepsilon\}$ are finite for any $\varepsilon>0$.

Indeed, given $\varepsilon>0$, since the set $X_\varepsilon=\{u\in \mathcal X: f(u) \geq \sup_{x\in X} f(x) +\varepsilon\}$ is finite, there would exist $n_0$ such that $X_\varepsilon\cap X_n=\emptyset$ for all $n\geq n_0$, then $$\lim_{n\to\infty} \sup_{x\in X_n} f(x)\leq \sup_{x\in X_{n_0}} f(x) \leq \sup_{x\in X} f(x) +\varepsilon,$$
and since $\varepsilon>0$ was arbitrarily chosen, it follows that converse inequality.
Of course, the useless hypothesis that we obtained is needed because we have made no assumptions of any kind on the family $X_n$ and $f$ (notice that in the proof of the result above the function $f$ doesn't even need to be continuous). If we make some good assumptions on the family of sets $X_n$ and $f$, we might get some more useful results. I consider the following result to be one of these:

Suppose that $f$ is uniformly continuous and that $X_n$ is a bounded family of closed sets. Then $$
\sup_{x\in X} f(x) = \lim_{n\to \infty} \sup_{x\in X_n} f(x).
$$

Since the family $X_n$ is contained in $[-M,M]$ we restrict ourselves to this interval. Fix $\delta>0$. Consider the open set
$$
B(X,\delta) = \bigcup_{x\in X} (x-\delta, x+\delta).
$$ 
Let us see that there exists $n_0$ such that $X_{n_0} \subset B(X,\delta)$. First, define $K=[-M,M]\setminus B(X,\delta)$ and notice that $X\cap K=\emptyset$. Moreover, $K$ is a closed and bounded set, so it is compact, and since each $X_n$ is closed, the sets $X_n\cap K$ are compact. We must prove that there exists $n_0$ such that $X_{n_0}\cap K=\emptyset$. If there isn't such $n_0$, then $\{X_n \cap K: n\in\mathbb N\}$ is a family of compacts with the finite intersection property and, as such, we would have that $X\cap K = \bigcap_{n\in\mathbb N} (X_n \cap K) \neq\emptyset$, a contradiction.
Finally, given $\varepsilon>0$, by the uniform continuity of $f$, there exists $\delta>0$ such that
$$
|x-y|<\delta \Rightarrow |f(x)-f(y)|<\varepsilon.
$$
By picking $n_0$ such that $X_{n_0}\subset B(X,\delta)$, for any $u\in X_{n_0}$, there is some $v\in X$ such that $u\in(v-\delta,v+\delta)$, then $|f(u)-f(v)|<\varepsilon$, which implies that $$f(u) \leq f(v)+\varepsilon \leq \sup_{x\in X} f(x) +\varepsilon,$$
so
$$\sup_{x\in X_{n_0}} f(x)\leq \sup_{x\in X} f(x) +\varepsilon.$$
Since this can be done for any $\varepsilon>0$, it follows that
$$\lim_{n\to\infty} \sup_{x\in X_{n}} f(x)\leq \sup_{x\in X} f(x).$$
