[proofplan]
We approximate the homotopy $H: [0,1]^2 \to U$ by a grid of small rectangles, each mapped into $U$. On each rectangle, the image lies in a disc contained in $U$, and [Cauchy's theorem for star-shaped domains](/theorems/342) kills the integral around each small rectangle. Interior edges cancel in a telescoping sum, leaving only the boundary paths $\gamma_0$ and $\gamma_1$. The closed-curve version follows by the same argument adapted to free homotopies.
[/proofplan]
[step:Partition the homotopy square into a fine grid with images in discs inside $U$]
Let $H: [0,1]^2 \to U$ be a homotopy with $H(\cdot, 0) = \gamma_0$, $H(\cdot, 1) = \gamma_1$, $H(0, s) = a$, $H(1, s) = b$. Since $H$ is continuous and $[0,1]^2$ is compact, $H$ is uniformly continuous. The image $H([0,1]^2)$ is a compact subset of the open set $U$, so
\begin{align*}
\delta = \operatorname{dist}(H([0,1]^2), \, \mathbb{C} \setminus U) > 0.
\end{align*}
Choose $N$ large enough that the uniform continuity modulus satisfies: whenever $|(t,s) - (t',s')| < \sqrt{2}/N$, we have $|H(t,s) - H(t',s')| < \delta$. Partition $[0,1]^2$ into $N^2$ sub-squares $R_{ij} = [t_{i-1}, t_i] \times [s_{j-1}, s_j]$ where $t_i = i/N$, $s_j = j/N$.
For each sub-square $R_{ij}$, the image $H(R_{ij})$ has diameter less than $\delta$, so $H(R_{ij}) \subseteq B(H(t_i, s_j), \delta) \subseteq U$.
[guided]
The strategy is classical: we cannot directly compare $\gamma_0$ and $\gamma_1$, but we can compare adjacent horizontal slices of the homotopy. The uniform continuity of $H$ on the compact square $[0,1]^2$ guarantees that a sufficiently fine grid makes each image $H(R_{ij})$ small enough to fit inside a disc in $U$.
Why does $\operatorname{dist}(H([0,1]^2), \mathbb{C} \setminus U) > 0$? Because $H([0,1]^2)$ is compact (continuous image of a compact set) and $\mathbb{C} \setminus U$ is closed, and they are disjoint (since $H$ maps into $U$). The distance between a compact set and a disjoint closed set in a metric space is strictly positive.
The condition $|H(t,s) - H(t',s')| < \delta$ for nearby grid points ensures $H(R_{ij})$ fits in a ball of radius $\delta$ centred at any vertex of the image, and that ball lies in $U$ by the definition of $\delta$.
[/guided]
[/step]
[step:Define piecewise-linear paths along grid lines and apply Cauchy's theorem to each cell]
For each grid point $(t_i, s_j)$, let $w_{ij} = H(t_i, s_j)$. Define piecewise-linear paths:
- Horizontal segments: $\eta_{ij}^h$ is the straight-line segment from $w_{i-1,j}$ to $w_{i,j}$.
- Vertical segments: $\eta_{ij}^v$ is the straight-line segment from $w_{i,j-1}$ to $w_{i,j}$.
The boundary of the cell corresponding to $R_{ij}$ is the closed rectangular path
\begin{align*}
\partial C_{ij} = \eta_{i,j-1}^h + \eta_{i,j}^v - \eta_{i,j}^h - \eta_{i-1,j}^v,
\end{align*}
traversed counter-clockwise. Since $H(R_{ij})$ lies in the disc $B(w_{ij}, \delta) \subseteq U$, and this disc is convex (hence star-shaped), the four vertices $w_{i-1,j-1}, w_{i,j-1}, w_{i,j}, w_{i-1,j}$ all lie in this disc, so $\partial C_{ij}$ lies in this disc. By [Cauchy's theorem for star-shaped domains](/theorems/342):
\begin{align*}
\int_{\partial C_{ij}} f(z) \, dz = 0 \quad \text{for all } 1 \leq i, j \leq N.
\end{align*}
[/step]
[step:Sum over all cells and cancel interior edges to relate $\gamma_0$ and $\gamma_1$]
Sum the integrals over all $N^2$ cells:
\begin{align*}
0 = \sum_{i=1}^N \sum_{j=1}^N \int_{\partial C_{ij}} f(z) \, dz.
\end{align*}
Each interior vertical segment $\eta_{i,j}^v$ (with $1 \leq i \leq N-1$) appears once with positive orientation in $\partial C_{ij}$ and once with negative orientation in $\partial C_{i+1,j}$, so these cancel. Similarly, each interior horizontal segment $\eta_{i,j}^h$ (with $1 \leq j \leq N-1$) cancels between $\partial C_{i,j}$ and $\partial C_{i,j+1}$. The surviving edges are:
- Bottom ($j = 0$): the path $\eta_{1,0}^h + \eta_{2,0}^h + \cdots + \eta_{N,0}^h$ from $w_{0,0} = a$ to $w_{N,0} = b$, which is the piecewise-linear approximation to $\gamma_0$.
- Top ($j = N$): the path $\eta_{1,N}^h + \cdots + \eta_{N,N}^h$ from $a$ to $b$, traversed in the reverse direction, approximating $-\gamma_1$.
- Left ($i = 0$): segments from $w_{0,0} = a$ to $w_{0,N} = a$, all degenerate since $H(0, s) = a$.
- Right ($i = N$): segments from $w_{N,0} = b$ to $w_{N,N} = b$, all degenerate since $H(1, s) = b$.
The telescoping therefore gives
\begin{align*}
\int_{\text{bottom}} f(z) \, dz - \int_{\text{top}} f(z) \, dz = 0.
\end{align*}
[guided]
The cancellation mechanism is purely combinatorial: in the sum $\sum_{i,j} \int_{\partial C_{ij}} f \, dz$, each internal edge is shared by exactly two cells with opposite orientations. This is the discrete analogue of Stokes' theorem on the grid.
The left and right boundary contributions vanish because $H(0, s) = a$ for all $s$ (so $w_{0,j} = a$ for all $j$, making left-boundary segments degenerate points) and $H(1, s) = b$ for all $s$ (similarly for the right boundary). The fixed-endpoint condition is essential here: it collapses the vertical boundary segments to points.
After cancellation, only the bottom path (approximating $\gamma_0$) and the top path (approximating $\gamma_1$, reversed) survive.
[/guided]
[/step]
[step:Pass from piecewise-linear approximations to the original paths]
It remains to show that the piecewise-linear bottom path has the same integral as $\gamma_0$ (and similarly for the top path and $\gamma_1$). On the $i$-th sub-interval $[t_{i-1}, t_i]$, both $\gamma_0|_{[t_{i-1}, t_i]}$ and the segment $\eta_{i,0}^h$ connect $w_{i-1,0} = \gamma_0(t_{i-1})$ to $w_{i,0} = \gamma_0(t_i)$, and both paths lie in $B(w_{i,0}, \delta) \subseteq U$.
Since $B(w_{i,0}, \delta)$ is convex (hence star-shaped), the concatenation $\gamma_0|_{[t_{i-1}, t_i]} - \eta_{i,0}^h$ is a closed path in a star-shaped subset of $U$. By [Cauchy's theorem for star-shaped domains](/theorems/342):
\begin{align*}
\int_{\gamma_0|_{[t_{i-1}, t_i]}} f(z) \, dz = \int_{\eta_{i,0}^h} f(z) \, dz.
\end{align*}
Summing over $i = 1, \ldots, N$:
\begin{align*}
\int_{\gamma_0} f(z) \, dz = \sum_{i=1}^N \int_{\eta_{i,0}^h} f(z) \, dz = \int_{\text{bottom}} f(z) \, dz.
\end{align*}
The identical argument applies to $\gamma_1$ and the top path. Combining with the telescoping identity from the previous step:
\begin{align*}
\int_{\gamma_0} f(z) \, dz = \int_{\gamma_1} f(z) \, dz.
\end{align*}
[guided]
Why does $\gamma_0|_{[t_{i-1}, t_i]}$ lie in $B(w_{i,0}, \delta)$? For any $t \in [t_{i-1}, t_i]$, we have $|(t, 0) - (t_i, 0)| \leq 1/N < \sqrt{2}/N$, so the uniform continuity condition gives $|H(t, 0) - H(t_i, 0)| = |\gamma_0(t) - w_{i,0}| < \delta$. Hence $\gamma_0(t) \in B(w_{i,0}, \delta)$.
The same reasoning shows the straight segment $\eta_{i,0}^h$ lies in the same disc (its endpoints are $w_{i-1,0}$ and $w_{i,0}$, both in $B(w_{i,0}, \delta)$, and the disc is convex). With both paths in a star-shaped set, [Cauchy's theorem for star-shaped domains](/theorems/342) equates their integrals.
This replacement step is what bridges the combinatorial grid argument (which operates on piecewise-linear paths) with the original smooth paths $\gamma_0$ and $\gamma_1$.
[/guided]
[/step]
[step:Derive the closed-curve version from the fixed-endpoint version]
For the closed-curve version, let $\gamma_0, \gamma_1$ be freely homotopic closed paths via $H: [0,1]^2 \to U$ with $H(0, s) = H(1, s)$ for all $s$. The same grid argument applies, except now the left and right vertical boundary paths coincide (since $w_{0,j} = H(0, s_j) = H(1, s_j) = w_{N,j}$). These vertical edges cancel against each other in the telescoping sum, again leaving only the bottom and top contributions. The replacement argument then gives $\int_{\gamma_0} f \, dz = \int_{\gamma_1} f \, dz$.
In particular, if $\gamma$ is null-homotopic (freely homotopic to a constant loop $\gamma_1(t) \equiv p$), then $\int_\gamma f \, dz = \int_{\gamma_1} f \, dz = 0$ since the constant loop has zero length.
[/step]