Let $a < b$ be real numbers, and let $f:(a,b)\rightarrow\textbf{R}$ be a function. If $x_{0}\in(a,b)$, $f$ is differentiable at $x_{0}$, and $f$ attains either a local maximum or local minimum at $x_{0}$, then $f'(x_{0}) = 0$.
MY ATTEMPT
Let us consider the local minimum first. Thus there exists $\delta > 0$ such that $f(x)\geq f(x_{0})$ for $|x - x_{0}| < \delta$.
If $x_{0} < x < x_{0} + \delta$, then we have that \begin{align*} f(x) \geq f(x_{0}) \Longrightarrow f(x) - f(x_{0}) \geq 0 \Longrightarrow \frac{f(x) - f(x_{0})}{x - x_{0}} \geq 0 \Longrightarrow f'(x^{+}_{0}) \geq 0 \end{align*}
If $x_{0} - \delta < x < x_{0}$, then we have that \begin{align*} f(x) \geq f(x_{0}) \Longrightarrow f(x) - f(x_{0}) \geq 0 \Longrightarrow \frac{f(x) - f(x_{0})}{x - x_{0}}\leq 0 \Longrightarrow f'(x^{-}_{0})\leq 0 \end{align*}
Since $f$ is differentiable at $x_{0}$, we conclude that $f'(x^{+}_{0}) = f'(x^{-}_{0})$, which is only possible if $f'(x_{0}) = 0$, and we are done.
Similar reasoning applies to the case when $x_{0}$ is a local maximum.
Could someone verify if I am reasoning correctly?
Yes, what you did is right. By the way, to treat the local maximum case, here's a cute trick if you haven't already seen it: if $f$ has a local maximum at $x_0$, then $-f$ has a local minimum at $x_0$. So, $(-f)'(x_0) = -f'(x_0) = 0$. Hence, $f'(x_0) = 0$. So, this saves you the trouble of going through the entire proof again.