Let $f : \mathbb{R}^n \to \mathbb{R}$ be a function such that partial derivatives \begin{equation} (\partial_i f)(x) := \lim\limits_{h \to 0} \frac{f(x + h e_i)-f(x)}{h} \end{equation} exists for all $i=1,\cdots,n$ and almost every $x \in \mathbb{R}^n$.
Then I wonder if $f$ itself is Lebesgue-measurable on $\mathbb{R}^n$. Here, $n \geq 2$ is arbitrary.
Could anyone please help me? I think it is true at least for $n=2$ but cannot generalize further.
Even more general result is true:
Theorem. A function $f:\mathbb R^n\to \mathbb R$ is Lebesgue measurable if $f$ is separately continuous almost everwhere.
Proof. This theorem can be proved by induction on $n$. For $n=1$, $f$ is continuous almost everywhere, which means that there exists a Lebesgue null set $N\subseteq \mathbb R$ such that $f{\restriction}_{\mathbb R\setminus N}$ is continuous and hence $f$ is Lebesue measurable.
Assume that the theorem is proved for some $n$. Take any function $f:\mathbb R^{n+1}\to\mathbb R$ which is separately continuous almost everywhere. Then there exists a Lebesgue null set $N\subseteq\mathbb R^{n+1}$ such that for every $x\in \mathbb R^{n+1}\setminus N$ and every $i\in\{1,\dots,n+1\}$ we have $f(x)=\lim_{\delta\to 0}f(x+\delta e_i)$. Identify the Euclidean space $\mathbb R^{n+1}$ with the product $\mathbb R^n\times \mathbb R$. By the Fubini Theorem, there exists a null set $M\subseteq\mathbb R$ such that for every $q\in\mathbb R\setminus M$ the set $N_q=\{x\in\mathbb R^n:(x,q)\in N\}$ is Lebesgue-null in $\mathbb R^n$. Choose any countable dense set $Q\subseteq\mathbb R\setminus M$ and consider the Lebesgue null set $N_Q=\bigcup_{q\in Q}N_q$ in $\mathbb R^n$. Then the set $\tilde N=N\cup(N_Q\times\mathbb R)$ is Lebesgue-null in $\mathbb R^{n+1}=\mathbb R^n\times\mathbb R$. By the inductive assumption, for every $q\in Q$, the function $f_q:\mathbb R^n\to\mathbb R$, $f_q:x\mapsto f(x,q)$, is Lebesgue measurable.
To prove that the function $f$ is Lebesgue-measurable, we have to show that for every real numbers $a<b$, the set $f^{-1}(a,b)=\{x\in\mathbb R^{n+1}:a<f(x)<b\}$ is Lebesgue measurable. Since the set $\tilde N=N\cup(N_Q\times \mathbb R)$ is Lebesgue null, it suffices to check that the set $f^{-1}(a,b)\setminus \tilde N$ is Lebesgue measurable in $\mathbb R^{n+1}$. For every $x\in f^{-1}(a,b)\setminus \tilde N$, the separate continuity of $f$ at $x$ ensures that $f(x)=\lim_{\varepsilon\to 0}f(x+\varepsilon e_{n+1})$. Then the set $$\begin{aligned} f^{-1}(a,b)\setminus \tilde N&=\{(x,y)\in (\mathbb R^n\times\mathbb R)\setminus \tilde N:\\ &\quad\quad\exists k\in\mathbb N\;\forall m\in\mathbb N\;\exists q\in Q\;\; |y-q|<\tfrac1m\;\wedge\; a+\tfrac1k\le f(x,q)\le b-\tfrac1k\}\\ &=\bigcup_{k\in\mathbb N}\bigcap_{m\in\mathbb N}\bigcup_{q\in Q}\{(x,y)\in(\mathbb R^n\times\mathbb R)\setminus\tilde N:|y-q|<\tfrac1m\;\wedge\; a+\tfrac1k\le f_q(x)\le b-\tfrac1k\} \end{aligned} $$ is Lebesgues measurable by the Lebesgue measurability of the functions $f_q$.$\quad\square$