I think the following should be a well-known corollary to Sard's theorem (basically, the crudest statement to the effect that 'two functions $f$ and $g$ whose gradients are linearly dependent everywhere, must be functions of each-other') but I do not know what to cite or where or what to refer to:
Let $f\in C^d(\mathbb{R}^d,\mathbb{R})$ and $g\in C^1(\mathbb{R}^d,\mathbb{R})$ be so that, $\forall x \in \mathbb{R}^d$, $dg(x)$ and $df(x)$ are linearly dependent and $df(x)=0 \Rightarrow dg(x)=0$. Then, for every connected set $S\subseteq \mathbb{R}^d$ for which $f|_{S}$ is constant, $g|_S$ is constant as well.
(EDIT: I notice now that this statement might be wrong as it stands. However, the tentative proof might still work if we assume $f$ to be superharmonic)
The proof would presumably go somewhere along the following lines:
- Firstly, $f(S)(=\{f^*\})$ could be one of $f$'s "regular values" (standard terminology in context of Sard's theorem) meaning that $df|_{S}$ doesn't vanish. The implicit function theorem then implies that $f^{-1}(f^*)$ is a $C^d$ sub-manifold of $\mathbb{R}^n$. $S$ is necessarily a subset of one of the connected components $C\subseteq f^{-1}(f^*)$. Since $C$ is a connected $C^d$ sub-manifold of $\mathbb{R}^n$, there is for every pair $(x,y)\in C^2$ a $C^1$ path $\gamma:[0,1] \to \mathbb{R}^d$ s.t. $\gamma(0)=x,\,\gamma(1)=y$ and $\gamma([0,1])\subseteq C$. The 2nd fundamental theorem of calculus then implies that $$g(y)-g(x)=g(\gamma(1))-g(\gamma(0))=\int_0^1dt\,[d(g\circ \gamma)](t) = \int_0^1dt\,\underbrace{[dg(\gamma(t)](\gamma'(t))}_{=0,\,\forall t \in (0,1)}=0$$ where $[dg(\gamma(t)](\gamma'(t))=0$ because $dg(\gamma(t)$ is a scalar multiple of $df(\gamma(t))$ and $[df(\gamma(t))](\gamma'(t))=[d(f\circ \gamma)](t)=0$ (because $f\circ \gamma$ is a constant function). Hence $g|_{C}$ is constant and therefore $g|_{S}$ is constant.
- If $f(S)(=\{f^*\})$ is one of the rare irregular values of $f$, we can proceed as follows: Let $Q$ be the connected component of $f^{-1}(f^*)$ that contains $S$. Some thought shows that $Q$ is a countable union of the interior of $Q$ and the boundary of each of the connected components of the open set $Q^c$. Some thought shows that $g$ must be constant on each of the members of that aforementioned countable union. So $g(Q)$ is a countable set that must be connected since $Q$ is connected and $g$ is continuous, meaning that $g(Q)(=G(S))$ is a singleton.
Anyone a suggestion for a reference (or a related result which uses weaker assumptions than mine)?