Demonstration of the existence of a scalar potential for a conservatice force 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?
 A: I'll first show you how to show that $\oint_\gamma F = 0$ implies $F = -\mathrm{d} U$ and then we'll discuss that mathematically the problem lies in the other direction.


*

*If we know that $\oint_\gamma F = 0$ then we can define the potential $U$ by fixing a point $x_0$ and then setting
$$ U(x) := \int_\gamma F$$
for any path between $x_0$ and $x$. This is well-defined since for any other path $\gamma'$ from $x_0$ to $x$ we have that we can form a loop $\ell$ by going first along $\gamma$ and then along $\gamma'$ in the reverse direction so that
$$ \int_\gamma F - \int_{\gamma'} F = \oint_\ell F = 0$$
so the potential is well-defined. It's not hard to check that the gradient of $U$ is $F$.

*The converse direction has a subtlety: You have assumed that there is a surface $S$ such that its boundary is $\partial S = \gamma$ for every path $\gamma$. This is only true in simply-connected spaces, but not in general. However, that being a gradient implies all loop integrals being zero is true in all spaces, we simply need to apply Stokes' theorem in its most basic form, the fundamental theorem of calculus. It says that for $\gamma$ starting at $x_1$ and ending at $x_2$, we have
$$ \int_\gamma \mathrm{d}U = \int_{\partial \gamma} U = U(x_2)-U(x_1)$$
and for loops $x_1=x_2$, so $\oint_\ell F = \oint_\ell \mathrm{d}U = 0$.
Now, it's actually important to realize that in non-simply connected spaces, there are curl-free vector fields which are not the gradient of a scalar function. For instance, on $\mathbb{R}^2 - \{(0,0)\}$ we have
$$ V(x,y) = \frac{x}{r}\partial_x + \frac{y}{r}\partial_y$$
with $r = \sqrt{x^2+y^2}$ as a curl-free vector field that is not a gradient, and also has a non-zero loop integral: Integrating it along anyloop that goes around the origin once, you get $2\pi$.
This is also of importance physically, for instance, it is the observation underlying the Aharonov-Bohm effect. While the magnetic field is zero everywhere outside the solenoid, the magnetic vector potential is not globally the gradient of a single scalar potential although its curl vanishes, and consequently its integral around a loop around the solenoid is non-zero.
