# How to prove continuity of $g(y)=\max_{x\in K} f(x,y)$ when $K$ is compact?

I have a function $$f$$ that is continuous over the set of variables, $$f: \ K \times M \to \mathbb{R}$$, where $$K$$ is a compact domain of a metric space and $$M$$ is a metric space. And I want to prove that the function $$g(y)=\sup_{x\in K} f(x,y)$$ is continuous.

As $$K$$ is a compact, $$f$$ is uniformly continuous with respect to its first argument. Also, for the same reason, $$g(y)=\sup_{x\in K} f(x,y)=\max_{x\in K} f(x,y)$$.

For now, I know that for the case of $$f$$ is continuous with respect of each variable separately, this doesn't work (see an example here Is supremum over a compact domain of separately continuous function continuous?) and there is a proof for the case when $$M$$ is also a compact, or $$f$$ is just uniformly continuous on $$M$$, too (How prove this $g(x)=\sup{\{f(x,y)|0\le y\le 1\}}$ is continuous on $[0,1]$), which I personally doubt as there is no guatantee that y-s will be close there (in my notations they are x-s).

All my tries fail when I come to the point where I need to say something about argmaxes of even close y-s. For example:

I consider a sequence $$y_n \to y_0$$ with $$n\to\infty$$. For each $$y_n$$ there exists $$x_n$$ such that $$g(y_n)=\max_{x\in K} f(x,y_n)=f(x_n,y_n).$$ Then, I try to estimate the difference $$|g(y_{n+k})-g(y_n)|=|f(x_{n+k},y_{n+k})-f(x_n,y_n)|=|f(x_{n+k},y_{n+k})-f(x_{n+k},y_{n})+f(x_{n+k},y_{n})-f(x_n,y_n)|\le|f(x_{n+k},y_{n+k})-f(x_{n+k},y_{n})|+|f(x_{n+k},y_{n})-f(x_n,y_n)|.$$ One can easily see that the first component tends to zero with $$k\to\infty$$, but I have no idea what to do with the second one...

Any help would be very appreciated!

• $K$ is metric, right? Commented Feb 26 at 16:26
• Just compact (only topology, only hardcore), but if you have a proof for the case K is metric it would be very useful for me as well :)) UPD But actually yes, metric K would be enough. Thank you for the comment. I'll edit the post Commented Feb 26 at 16:36

Consider a sequence $$(y_n)_{n\in\mathbb{N}}$$ in $$M$$ that converges to some $$y \in M$$. We will show that

Claim. $$g(y_n) \to g(y)$$.

Step 1. We first show that $$\liminf_{n\to\infty} g(y_n) \geq g(y)$$.

This is an immediate consequence of the general fact that the supremum of a family of lower-semicontinuous functions is again lower-semicontinuous. (In particular, this fact does not require any structure on $$K$$.) Nevertheless, we write out the proof for self-containedness.

Let $$\alpha$$ be an arbitrary real satisfying $$\alpha < g(y)$$. Then there exists $$x \in K$$ such that $$f(x, y) > \alpha$$. So by the continuity of $$f$$, there exists $$\delta > 0$$ such that $$f(x, y') > \alpha$$ whenever $$d(y', y) < \delta$$. This then implies that

$$g(y_n) \geq f(x, y_n) > \alpha \qquad \text{whenever } d(y_n, y) < \delta,$$

and so, we have $$\liminf_{n\to\infty} g(y_n) \geq \alpha$$. Since this is true for any $$\alpha < g(y)$$, the desired assertion follows by letting $$\alpha \uparrow g(y)$$.

Step 2. Next, we show that $$\limsup_{n\to\infty} g(y_n) \leq g(y)$$.

Indeed, for each $$n$$, use the compactness of $$K$$ to choose $$x_n \in K$$ so that $$f(x_n, y_n) = g(y_n)$$. Also,

• find a subsequence $$I \subseteq \mathbb{N}$$ so that $$(g(y_n))_{n\in I} \to \limsup_{n\to\infty} g(y_n)$$, and then

• find a further subsequence $$J \subseteq I$$ such that $$(x_n)_{n\in J} \to x$$ for some $$x \in K$$. This is possible by the sequential compactness of $$K$$.

Then

$$\limsup_{n\to\infty} g(y_n) = \lim_{J \ni n \to \infty} g(y_n) = \lim_{J \ni n \to \infty} f(x_n, y_n) = f(x, y) \leq g(y).$$

Conclusion. Combining step 1 and 2, the desired claim follows. $$\square$$

Discussion. The above proof works whenever $$K$$ is both compact and sequentially compact. When $$K$$ is a compact metric space, sequential compactness comes for free. I am not sure if we can come up with a proof that does not rely on sequential compactness.

• I think compactness of $K$ only guarantees that $(x_n)_{n\in I}$ has a convergent subnet. But even if it is so, this does not seem to affect the validity of your proof. Commented Feb 26 at 17:21
• @Noiril, I guess you are right, thanks for pointing out an interesting fact! :) Commented Feb 26 at 17:26
• Great! Thank you Commented Feb 27 at 10:46

Here's a proof that's more for fun than anything else (especially since there's already a perfectly good answer here).

Let $$X$$ be a sober space (every metric space is sober) and let $$K$$ be compact and sober. Then if $$f : X \times K \to \mathbb{R}$$ is continuous, the function $$g(x) = \max_{k \in K} f(x,k)$$ is continuous too.

We use the fact that the extreme value theorem is actually constructively true in the following form:

Let $$K$$ be a compact, positive, overt locale and $$f : K \to \mathbb{R}$$ continuous. Then $$f$$ admits a maximum $$\max_K f \in \mathbb{R}$$.

This is great because it means this statement is true inside the sheaf topos $$\text{Sh}(X)$$! Externalizing this statement (and cashing out locales for sober spaces everywhere) gives

Let $$\pi : K \to X$$ be a proper, open surjection and $$f : K \to \mathbb{R}$$ continuous. Then $$x \mapsto \max_{k \in \pi^{-1} x} f(k)$$ is a continuous function.

(This is basically because compact locales in $$\text{Sh}(X)$$ are proper maps to $$X$$, positive overt locales in $$\text{Sh}(X)$$ are open surjections to $$X$$, and a "real number" in $$\text{Sh}(X)$$ is a continuous function $$X \to \mathbb{R}$$)

But now let's interpret the above theorem with

• $$\pi : X \times K \to X$$, which one easily checks to be a proper open surjection
• $$f : X \times K \to \mathbb{R}$$, which we're assuming is continuous

Then since $$\pi^{-1}(x) = \{x\} \times K$$, the theorem tells us that the function $$x \mapsto \max_{(x,k)} f(x,k)$$ is continuous, as desired.

As a brief soapbox pitch, this is one reason to care about constructive proofs! Constructively true things can be interpreted inside a sheaf topos, which gives us "continuously parameterized" versions of the theorem basically for free!

A few days ago when I saw this question, I recognized it as a version of the usual extreme value theorem where the continuous function $$f$$ and the resulting max $$g$$ are both allowed to depend on a bonus parameter from $$X$$. So I thought if I could find a constructive version of the extreme value theorem, it should give your theorem as a corollary! (Actually it gives something a bit more general than what you asked for). I'm not an expert in locale theory, and I had to wait a few days to find the theorem I cited here, but you can see how, with experience, these kinds of questions can be answered very quickly!

I hope this helps ^_^