I asked earlier Does there exist a real everywhere differentiable function with the set of critical values of non zero measure?
I found the same question on Mathoverflow with the following proof that the set of critical values is always of measure 0:
Sergei Ivanov (https://mathoverflow.net/users/4354/sergei-ivanov), Counterexample to Sard Theorem for a not-C1 map, URL (version: 2012-11-20): https://mathoverflow.net/q/114000
citing the answer:
"
No, such functions do not exist. More precisely, let $f:\mathbb R\to\mathbb R$ be an arbitrary function, $\Sigma$ is the set of $x\in\mathbb R$ such that $f'(x)$ exists and equals 0. Then $f(\Sigma)$ has measure 0.
By countable subadditivity of measure, we may assume that the domain of $f$ is $[0,1]$ rather that $\mathbb R$. Fix an $\varepsilon>0$. For every $x\in\Sigma$ there exists a subinterval $I_x\ni x$ of $[0,1]$ such that $f(5I_x)$ is contained in an interval $J_x$ with $m(J_x)<\varepsilon m(I_x)$. Here $m$ denotes the Lebesgue measure and $5I_x$ the interval 5 times longer than $I_x$ with the same midpoint. Now by Vitali Covering Lemma there exists a countable collection $\{x_i\}$ such that the intervals $I_{x_i}$ are disjoint and the intervals $5I_{x_i}$ cover $\Sigma$. Since $I_{x_i}$ are disjoint, we have $\sum m(I_{x_i})\le 1$. Therefore $f(\Sigma)$ is covered by intervals $J_{x_i}$ whose total measure is no greater than $\varepsilon$. Since $\varepsilon$ is arbitrary, it follows that $f(\Sigma)$ has measure 0.
"
Now, I cannot see where one uses in the proof that the function is defined on the real line (as far as I saw, Vitali Covering Lemma is true not only for intervals, but also for balls in higher dimensions).
But it is known that there are functions from $\mathbb{R}^n$ to $\mathbb{R}$, $n\geq 2$, which are even continuously differentiable, but which have the set of critical values not of measure 0:
https://mathoverflow.net/a/258145 citing H. Whitney, A function not constant on a connected set of its critical points, Duke Math. J. 1 (1935), 514-517.
(cited also by Sard), and
https://mathoverflow.net/a/258147
So why does not the cited proof generalize to functions from $\mathbb{R}^n$ to $\mathbb{R}$, $n\geq 2$, and contradict the existence of such examples?