My teacher told the following statement to me during office hours. Is it correct and if so, how could one go about proving it?
Given a material system subject to holonomic and smooth constraints whose Lagrangian is $L$ (we are assuming that it can be derived from a generalized potential rather than just a potential), then for a given function $g = g(\underline{q}, \underline{\dot q}, t)$: \begin{equation*} \frac{d}{dt} \left( \frac{\partial g}{\partial \dot q_k} \right) - \frac{\partial g}{\partial q_k} = 0 \hspace{5mm} \iff \hspace{5mm} \exists f=f(\underline{q}, t): g = \frac{d}{dt} f \tag{1}\end{equation*}
By straightforward computation one can prove the second implication ($\impliedby$) but I am having trouble with the other one. So far, by using the fact that $$ \frac{\partial}{\partial \dot q_k} \left( \frac{d}{dt}f \right) = \frac{d}{dt} \left( \frac{\partial}{\partial \dot q_k} f \right) + \frac{\partial}{\partial q_k}f $$ and integrating with respect to time I have arrived to: $$\frac{\partial}{\partial \dot q_k}f = Ct + D$$ where $C,D$ are constants of integration. However it does not seem right and it doesn't help me in showing that a primitive of $g$ with respect to time can not depend on lagrangian velocities.
Any comment or answer is much appreciated!