On Correctness of Automatic Differentiation for Non-Differentiable Functions