Exercise 2 Chapter 2 Rudin Real and complex analysis 
Let $f$ an arbitrary function in $\mathbb{R}$ and define
$$
\varphi(x,\delta) = \sup \left\{ |f(s) - f(t) | : s,t \in (x-\delta,x+\delta) \right\} \\
\varphi(x) = \inf\left\{ \varphi(x,\delta) :\delta > 0\right\}
$$
Prove that $\varphi$ is upper semicontinuous...

There's a remark in the chapter saying that the infimum of a family of upper semicontinuous functions is upper semicontinuous. If I define $\varphi_\delta(x) = \varphi(x,\delta)$ for $\delta > 0$ and I show that the family $\varphi_\delta(x)$ is upper semicontinuous then this will automatically imply the uppersemicontinuity of $\varphi$.
First of all I observe that w.r.t. if $0 < \delta_1 < \delta_2$ we have $\varphi_{\delta_1}(x) < \varphi_{\delta_2}(x)$, so the family is monotonic w.r.t delta. Moreover for each $\delta > 0$ we have $\varphi_\delta > 0$.
Consider now the set $\varphi_{\delta}^{-1}((-\infty,\alpha)) = \left\{ x : \varphi_\delta(x) < \alpha \right\}$ if $\alpha < 0$ then such set is $\emptyset$ which is open, assuming $\alpha > 0$ let's pick an $x \in \varphi^{-1}_{\delta}((-\infty,\alpha))$ (which is not empty as we assumed $\alpha \geq 0$), I want to show there's an $r > 0$ such that $(x-r,x+r) \subset \varphi^{-1}_{\delta}((-\infty,\alpha))$ which is true if $\varphi_\delta((x-r,x+r)) \subset (-\infty,\alpha)$. Such $r$ must exist otherwise we would have $\varphi_\delta(x) \leq \alpha$ which is a contradiction given how we chose $x$. This show the family is upper semicontinuous and the infimum is also upper semicontinuous.
 A: I doubt that $\varphi_{\delta}=\varphi(\cdot,\delta)$ is upper semi-continuous
for each $\delta>0$. Consider the following example:
Let $f:\mathbb{R}\rightarrow\mathbb{R}$ be defined by $f(x)=1_{\mathbb{R}\setminus(-1,1)}(x)\cdot D(x)$,
where $D(x)=\begin{cases}
1, & \mbox{if }x\in\mathbb{Q}\\
0, & \mbox{if }x\in\mathbb{R}\setminus\mathbb{Q}
\end{cases}.$ By direct computation, for $\delta=1$, $\varphi_{\delta}(x)=\begin{cases}
0, & \mbox{if }x=0\\
1, & \mbox{if }x\neq0
\end{cases}.$ Clearly $\varphi_{\delta}$ is not upper semi-continuous at $x=0$.
A: Let $x_{0}\in\mathbb{R}$ be arbitrary. We go to show that $\varphi$ is upper semi-continuous
at $x_{0}$. Let $y > \varphi(x_{0})$ be arbitrary. Since
$y$ is not a lower bound of $\{\varphi(x_{0},\delta)\mid\delta>0\}$, there
exists $\delta_{0}>0$ such that $\varphi(x_{0},\delta_{0})<y$. Let
$r=\frac{1}{2}\delta_{0}$. Let $x\in(x_{0}-r,x_{0}+r)$ be arbitrary.
Let $s,t\in(x-r,x+r)$ be arbitrary. Observe that $x_{0}-\delta_{0}=x_{0}-2r<x-r<x+r<x_{0}+2r=x_{0}+\delta_{0}$,
i.e., $(x-r,x+r)\subseteq(x_{0}-\delta_{0},x_{0}+\delta_0)$. Therefore,
$|f(s)-f(t)|\leq\varphi(x_{0},\delta_{0})<y$ and hence $\varphi(x,r)\leq\varphi(x_{0},\delta_{0})<y$.
It follows that $\varphi(x)=\inf_{\delta>0}\varphi(x,\delta)\leq\varphi(x,r)<y$.
That is, $\varphi(x)<y$ for all $x\in(x_{0}-r,x_{0}+r)$. This shows
that $\varphi$ is upper semi-continuous at an arbitrary point $x_{0}$
and hence is upper semi-continuous.
