Mathematically a vector field, $\vec{F}$, is conservative if:
$$\oint_{\gamma} (\vec{F}.d\vec{l})=0$$
Physically, the integral is the same as the work done by a force $\vec{F}$ on a body in a closed path. I intend to demonstrate mathematically that a conservative force assumes a scalar potential, i.e:
$$\oint_{\gamma} (\vec{F}.d\vec{l})=0 \Leftrightarrow \vec{F}=-\vec{\nabla} U$$
where $U$ is the scalar potential.
I know that $$\vec{F}=-\vec{\nabla} U \Rightarrow\oint_{\gamma} (\vec{F}.d\vec{l})=0 $$
(Using Stokes theorem: $\oint_{\gamma} (\vec{F}.d\vec{l})=\int_S \left([\vec{\nabla} \times\vec{F}].\vec{n}\right) dS$. Using Schwarz lemma, we have that $ [\vec{\nabla} \times\vec{\nabla}U]=0. $ So, $\oint_{\gamma} (\vec{F}.d\vec{l})=0.$)
My problem is that I can't demonstrate the inverse, i.e:
$$\oint_{\gamma} (\vec{F}.d\vec{l})=0\Rightarrow\vec{F}= -\vec{\nabla} U $$
I got a more general solution that is different of $\vec{F}= -\vec{\nabla} U. $
How could I do this?