Showing $p dx + q dy$ is locally exact I'm working on the following question from Ahlfors' Complex Analysis:

Prove without use of Theorem 16 that $p dx + q dy$ is locally exact on $\Omega$ 
   ($\Omega$ open, simply connected) iff $\int_{\partial R} p dx + q dy =0$ for every rectange $R \subset \Omega$ with sides parallel to the axes. 

Theorem 16 (the one I'm not supposed to use) states that if $p dx + q dy$ is locally exact in $\Omega$, then $\int_{\gamma} p dx + q dy =0$ for every cycle $\gamma \sim 0$ in $\Omega$.
I understand the definitions, but I don't really know how to get started, so any help would be appreciated.  
The following definition is the one I am currently working with: A differential $p dx + q dy$ is said to be locally exact in $\Omega$ is it is exact in some neighborhood of each point in $\Omega$. 
 A: The "if" part is easy. For any point $z_0 \in \Omega$, take an open ball $B(z_0,\delta) \subset \Omega$. Any point $z \in B(z_0,\delta)$ can be connected to $z_0$ through $\gamma$ made of a vertical and a horizontal line. The condition given in the problem guarantees that $U(z) \equiv \int_\gamma pdx + qdy$ is well defined. It is easy to show that $\partial U / \partial x = p$ $\partial U / \partial y = q$.
For the "only if" part, we can use the fact that $R$ is compact.
We create a set of rectangles through the following procedure.

*

*If $R$ is inside a neighborhood in which $pdx + qdy$ is exact, we are done.

*If not, divide $R$ into four smaller rectangles of equal size. If each rectangle is inside a neighborhood in which $pdx + qdy$ is exact, we are done.

*If there is a rectangle that is not contained in such a neigborhood, further divide it into four smaller rectangles.

This process gives us a (potentially infinite) set of rectangles $\{ R_1, R_2, R_3, \dots\}$. By construction, each of them is inside a neighborhood in which $pdx + qdy$ is exact, and therefore $\int_{\partial R_i} pdx + qdy = 0$.
Each closed set $R_i$ centered at $z_i$ can be turned into an open set by having an open rectangle $R_i'$ centered at $z_i$ with slightly larger sides. The set of $R_i'$s is an open covering of $R$.
Since $R$ is compact, there is a finite covering made of $R_i'$s. Take the corresponding $R_i$s.
Finally notice that $\partial R = \sum \partial R_i$, and therefore $\int_{\partial R} pdx + qdy = \sum \int_{\partial R_i} pdx + qdy = 0$.
A: Caveat: I have never gone through Ahlfors so I'm not sure that the below
is the intended answer.
It goes through a tortuous route and is nothing but a sketch.

Suppose that your 1-form $\alpha$ is locally exact on $\Omega$
and let $\partial R$ be a rectangular path in $\Omega$.
Denote as $\mathcal{R}$ the family of rectangles with sides parallel
to the axes.


*

*Since $\Omega$ is simply connected, the rectangle $R$ is contained
in $\Omega$.

*For any point $z \in R$ there is a rectangle $R_z \in \mathcal{R}$
such that $z \in R_z \subseteq R$ and $\alpha$ is exact over an open
thickening of $R_z$ (that is to say, consider a ball containing $z$
where
$\alpha$ is exact and then a rectangle in between).

*Since $R$ is compact and the interiors of the rectangles
$R_z$ cover $R$, you can find a finite subcover.

*You can consider the intersections of those rectangles and cover $R$
by a finite number of rectangles $\mathcal{R} \ni R_i \subseteq R$
intersecting at most over the boundary.

*Then $\partial R$ is given as $\sum \mathcal \partial R_i$
(modulo equivalence) and so
$$
   \int_{\partial R} \alpha
   = \sum_{i=1}^n \int_{\partial R_i} \alpha = 0.
   $$
For the converse, let $z \in \Omega$ and consider a rectangle
$R' \in \mathcal{R}$ such that $z \in U \subseteq \Omega$ where
$U = \operatorname{int}(R')$. We want to show that $\alpha$ is exact
over $U$.


*For every rectangle $\mathcal{R} \ni R \subseteq U$ the
hypotesis applies.

*For any $w \in U$ consider a polygonal path made of horizonta
and vertical segments from $z$ to $w$ and set
$$f(w) = \int_{z \leadsto w} \alpha.$$

*One uses the hypotesis to show that $f$ is well defined.
Then $\alpha = \mathrm{d} f$.


This second part should be equivalent to the fact that, over an open subset,
a 1-form is exact if and only if the integral
along (polygonal) paths do not depend on the endpoints, which is
equivalent to require that the integral along (polygonal) cycles is zero.
But instead of integrating along (polygonal) paths you integrate along
polygonal paths made of horizontal and vertical segments.
Another case is when one has a star shaped domain,
and then integrates along rays.

Rereading this answer, i see a clear mistake in (3).
This can be solved as follows:


*By local exactness, there is an cover of $R$ by balls
over which $\alpha$ is exact; we can assume this cover $U_k$
to be finite by compactness of $R$.

*Divide the edges of $R$ by $n$ and $m$ and consider the
$n \times m$ partition rectangles $R_{ij}$ covering $R$.
Then for $n$ and $m$ high enough, by Lebesgue number lemma,
you have that each $R_{ij}$ is contained in some $U_k$,
hence $\alpha$ is also exact over $R_{ij}$.


This way you don't have to intersect the subrectangles,
ie. (4) and (5) are easier.
Yet it is fundamental that $R \subseteq \Omega$.
