Some basic subdifferential computations I'm trying to understand a bit of nonsmooth analysis, but I'm struggling even to compute a simple example. Any help would be awesome!
Could you please confirm how do the subdifferentials of these functions look like at $x=0$?

*

*$f_1(x)\doteq\left\{\begin{array}{ll} 0, & \text{if } x= 0 \\ 1, & \text{otherwise.} \end{array}\right.$


*$f_2(x)\doteq x+f_1(x)$.


*$f_3(x)\doteq\left\{\begin{array}{ll} 0, & \text{if } x= 0 \\ \infty, & \text{otherwise.} \end{array}\right.$


*$f_4(x)\doteq x+f_3(x)$.
By the definition $\partial f(x)\doteq \{s\in \mathbb{R}\colon f(y)\geq f(x) + s(y-x), \ \forall y\in \mathbb{R}\}$, it seems to me that $\partial f_1(0)=\{0\}$, $\partial f_2(0)=\{1\}$ and $\partial f_3(0)=\partial f_4(0)=\mathbb{R}$. Am I correct?
Probably not, because of these two apparent contradictions:

*

*The point $x=0$ is a local minimizer of $f_2$, which would imply that $0\in \partial f_2(0)$, right? But this seems not to be the case.

*It seems to me, intuitively, that $\partial f_1(0)$ and $\partial f_3(0)$ should coincide, which does not seem to be the case, either.

What am I missing?
Thanks!
 A: Your answers are correct. Your concerns are not.

The point $x=0$ is a local minimizer of $f_2$, which would imply that $0\in \partial f_2(0)$, right? But this seems not to be the case.

The subgradient you are considering is the global subgradient, not one of the local generalisations. Consequently, $x = 0$ would have to be a global minimiser in order for $0 \in \partial f_2(0)$. This, of course, is not the case, e.g. $f_2(-2) = -1 < 0 = f_2(0)$.

It seems to me, intuitively, that $\partial f_1(0)$ and $\partial f_3(0)$ should coincide, which does not seem to be the case, either.

You may need to adjust your intuition. Remember, you're looking for slopes of (sub)tangent lines through $(0, f_i(0))$ that lie below the graph of $f_i$. In the case of $f_1$, the subtangent is very restricted by the line $y = 1$ which forms most of the graph of $f_1$, to the point where the subtangent is forced to be parallel.
This is not the case in $f_3$. Instead, we have removed that part of the graph, so the subtangent can take any slope.
