Let $f : S \subseteq \mathbb{R} \to \mathbb{R}$ be nondifferentiable on $S$, and let $x \in S$. Suppose I want to show that $$ \frac{d}{dy}\bigg|_{y = x}\big[[f(y) - f(x)]^2\big] = 0. $$ The straightforward argument is $$ \frac{d}{dy}\bigg|_{y = x}\big[[f(y) - f(x)]^2\big] = 2[f(y) - f(x)]\,f'(y)\bigg|_{y = x} = 2[f(x) - f(x)]\,f'(x) = 2(0)\,f'(x) = 0, $$ but as far as I can tell, this rests on the false assumption that $f$ is differentiable at $x$. Is this type of reasoning, which symbolically carries the derivative of the function through the calculation to show that it cancels at the end, valid when the function is not differentiable? This would be useful, because then one could simply enter
D[(f[x] - f[y])^2, y] /. y -> x
into Mathematica to verify the identity. Or do I need to use a different line of reasoning to prove this?