# Is the number of intervals you get by slicing the closed region under a nice graph continuous from below?

Let $I$ be a closed interval in $\mathbb{R}$, and let $f:I \to \mathbb{R}$ be a bounded function, smooth except at finitely many points (piece-wise smooth). There are also only finitely many critical points, except that some of the pieces may be horizontal lines. [Edit: at any rate, I'm assuming $f$ has finitely many critical values in the codomain.] Let $$G = \operatorname{closure}\big(\{(x,y) \in I \times \mathbb{R} ~\big|~ y \leq f(x)\}\big)$$ denote the closed region under the graph of $f$. For each $s \in \mathbb{R}$, let $n(s)$ denote the number of connected components of the intersection of $G$ with the line $y=s$. In other words, the number of connected components of $\{(x,s) ~\big|~ s \leq f(x)\}.$

I would like a reference the following, which my intuition says is true and not difficult from the right perspective:

The function $n:\mathbb{R} \to \{0,1,2,3,\dots\}$ is continuous from below. That is, for any $s \in \mathbb{R}$, there exists $\varepsilon >0$ such that $n$ is constant on $(s-\varepsilon,s]$.

Here's a poor picture: (The vertical line segment in the boundary is at a place where $f$ had a discontinuity.)

A little context. This seems like a really elementary result (unless I'm dense and it's false as stated), but from an area that I'm not as comfortable with. I want to say it's like Morse theory for a 2-manifold with piece-wise smooth boundary in $\mathbb{R}^2$? But I'm not looking for a sledgehammer. I'm a number theorist, and this will be used in a number theory paper, and I guess that people reading (refereeing?) the paper might like a reference for this fact, even if it might be stated without proof or reference in papers in other fields. If you have a super short proof that would make sense to someone outside the area, that would be fine, too, of course.

Suppose there were some $s\in\mathbb R$ such that $n$ is not continuous from below. Then, for all $\epsilon>0$, there is some $x\in(s-\epsilon,s]$ that is a critical value of $f$, i.e., $x$ is either a local maximum, local minimum, or the height of a horizontal segment. This implies that $f$ has infinitely many such critical values, which implies that $f$ has infinitely many critical points: a contradiction of the hypothesis.
• So what it seems like is the case is that you get continuity from below at any critical value which is not a local minimum (or horizontal line segment which is basically a fat local minimum) of $G$ (I'm not talking about a local minimum of the graph of $f$), and since $G$ is the region below the graph of a function, there is no local minimum -- but I'm not sure the best way to make this statement precise. – Bobby Grizzard Apr 14 '16 at 21:12
• I'm defining a local minimum of a subset $\Omega$ of $\mathbb{R}^2$ as a point $P$ such that there is an open neighborhood of $P$ containing no points of $\Omega$ having lower $y$-coordinate. – Bobby Grizzard Apr 14 '16 at 21:39
• If you flip the argument upside down, or let $G$ be the area above the graph, then we see that $n$ will be continuous from above at all of the critical points. Of course, $n$ cannot be both continuous from above and below, or it would be constant. So, if $\Omega$ is a general compact region of the plane, then $n$ will be continuous from below when exiting $\Omega$ and continuous from above when entering $\Omega$. This is a reflection that you are choosing to think of $\Omega$ as closed and its complement as open, and not vise versa. – Jeffrey Meier Apr 15 '16 at 0:06