I know that on the punctured disc, there is no guarantee that given a vector field $F(x,y)=(P(x,y),Q(x,y))$ with $P_{y}=Q_{X}$ there is a function $G$ such that $\nabla G=F$. However, I am confused as to why that statement holds when we are given a simply connected set. When I was taking real/complex anaylsis, my professor stated that on a open rectangle we can perform "up and over" integration, meaning we can simply have $$ G = \int_{0}^{x} P(s,y_{0}) ds + \int_{0}^{y} Q(x,s) ds$$ (assuming $P,Q$ are continuously differentiable on the rectangle). I understand why it works in this case, (since differentiation under the integral sign only requires $p,q$ to be defined on the rectangle) but I fail to understand how we can then extend this to say that the potential function lemma works on all simply connected surfaces. The only explanation I have gotten is that "up an over integration" does not really work when there are "holes" since if we were to divide the set across the hole, we could have two regions in which the integrals do not necessarily match. Hence why we also need path independence as well for the lemma to work in this case. However, I find this explanation to be very informal and (for me) it does not really answer why say connecting two rectangles together without forming a hole would mean the potential function lemma holds.
I also know, in some sense, that in general, the potential function lemma can be seen as a consequence of Greene's theorem since (assuming p,q are continuously differentiable on a simply connected set), Greene's theorem will give us path independence which implies $F$ is a gradient field. However, again I am not sure why we need simple connectivity. I have read Spivak's calculus on Manifolds up to chapter 4 where general Stokes theorem was introduced, but I did not see any condition that resembled simple connectivity (except for the fact that the integration was done on n-hypercubes and I do not understand why having a "hole" in the hypercube would screw up the theorem at large).
Any help would be appreciated!