I'm fairly sure that this is an easy question, but I can't quite prove my suspicions.
For $f\in\mathbf{C}^\infty(\mathbf{R})$, let $g(t):=\sup_{t\leq x} f(x)$. Then $g\in\mathbf{C}^\infty(\mathbf{R})$.
I want to say that this is true, but I'm unable to fully justify it. In my mind, I'm effectively viewing $g$ as a smooth step function that always increases, moving from one hill of $f$ to the next higher hill of $f$ as $t$ increases. $g$ moves from that earlier hill to the next hill with $f$ (aka smoothly), so the only possible points where $g$ can be not smooth are the points $\{x \mid f(x)=\max_{t\leq x}{f(t)}, f'(x)=0, f''(x)<0\}$. These are the points where $g(x)$ stops following $f(x)$ and instead is the zero function until $f(x)$ "catches up" again, heading for the next higher hill.
However, when I try and construct a proof for why these points cannot be true for contradiction, I can't get anywhere. Can anyone give me a counterexample, or some hint for how to prove this?