[proofplan]
Using the flatness hypothesis $F_A \equiv 0$, the theorem on parallel frames produces a local basis $s_1, \dots, s_n$ of $\Gamma(TM)$ with $d_A s_i = 0$. The dual basis $\omega^1, \dots, \omega^n$ of $1$-forms is then parallel for the induced connection $d_{A^*}$, hence $d_{A^*}\omega^i = 0$. The vanishing torsion hypothesis $\tau_A \equiv 0$ together with $\tau_A = \pi \circ d_{A^*} + d$ forces $d\omega^i = 0$; since $\mathbb{R}^n$ has vanishing de Rham cohomology in positive degrees, Poincaré's Lemma produces local primitives $x_i$ with $\omega^i = dx_i$. The $(x_1, \dots, x_n)$ are local coordinates because the $dx_i$ are pointwise independent. On overlaps, a second argument using $d_{A^*}(dy_i) = 0$ shows that the transition functions have constant Jacobian, hence are affine transformations. This is exactly the defining data of an affine structure on $M$.
[/proofplan]
[step:Produce a parallel local frame from the flatness hypothesis]
Since the curvature of the connection $d_A$ on $TM$ vanishes identically ($F_A \equiv 0$), the Flatness Characterises Parallel Frames theorem [Flatness Characterises Parallel Frames](/theorems/???) applies. The hypotheses of that theorem are: (a) $d_A$ is a connection on a smooth vector bundle over $M$ (satisfied, $TM$ with $d_A$), (b) the curvature vanishes (satisfied by hypothesis).
The conclusion is: for every point $p \in M$, there exists an open neighbourhood $U \ni p$ and a basis of sections $s_1, \dots, s_n \in \Gamma(TM|_U)$ such that
\begin{align*}
d_A s_i = 0 \qquad \text{for all } i = 1, \dots, n.
\end{align*}
Shrink $U$ if necessary so that $U$ is connected and diffeomorphic to an open ball in $\mathbb{R}^n$; in particular $U$ has vanishing de Rham cohomology in positive degrees by Poincaré's Lemma.
[/step]
[step:Dualize to obtain parallel coframes $\omega^i$ with $d_{A^*}\omega^i = 0$]
Let $\omega^1, \dots, \omega^n \in \Omega^1(U)$ be the pointwise dual basis, characterized by
\begin{align*}
\omega^i(s_j) = \delta_{ij} \qquad \text{on } U.
\end{align*}
By definition of the induced connection $d_{A^*}$ on $T^*M$, for every $Y \in \Gamma(TM|_U)$:
\begin{align*}
d(\omega^i(Y)) = (d_{A^*}\omega^i)(Y) + \omega^i(d_A Y).
\end{align*}
Take $Y = s_j$. The left-hand side is $d(\delta_{ij}) = 0$. The second term on the right vanishes because $d_A s_j = 0$. Hence
\begin{align*}
(d_{A^*}\omega^i)(s_j) = 0 \qquad \text{for all } i, j.
\end{align*}
The section $d_{A^*}\omega^i \in \Omega^1(U; T^*M)$ is a tensor, so it is determined by its values on a basis of $TM|_U$. Since it vanishes on the basis $\{s_j\}$, it vanishes identically:
\begin{align*}
d_{A^*}\omega^i = 0 \qquad \text{on } U, \quad i = 1, \dots, n.
\end{align*}
[/step]
[step:Use the vanishing torsion to deduce $d\omega^i = 0$]
By the equivalent formulation of torsion, $\tau_A = \pi \circ d_{A^*} + d$ as a map $\Omega^1(M) \to \Omega^2(M)$, where $\pi$ is the antisymmetrization. The hypothesis $\tau_A \equiv 0$ gives
\begin{align*}
d\omega^i = -\pi(d_{A^*}\omega^i) = 0 \qquad \text{on } U,
\end{align*}
using the previous step. Thus each $\omega^i$ is a closed $1$-form on $U$.
[/step]
[step:Integrate to produce local coordinates $x_i$ with $\omega^i = dx_i$]
Since $U$ is diffeomorphic to an open ball in $\mathbb{R}^n$, by [Poincaré's Lemma](/theorems/???), every closed $1$-form on $U$ is exact. Applied to each $\omega^i$: there exists $x_i \in C^\infty(U)$ with
\begin{align*}
dx_i = \omega^i \qquad \text{on } U.
\end{align*}
The $x_i$ are unique up to an additive constant on each connected component of $U$; since we shrank $U$ to be connected, each $x_i$ is unique up to a single additive constant.
The map
\begin{align*}
\varphi: U &\to \mathbb{R}^n \\
p &\mapsto (x_1(p), \dots, x_n(p))
\end{align*}
has differential $d\varphi_p = (dx_1|_p, \dots, dx_n|_p) = (\omega^1|_p, \dots, \omega^n|_p)$. Since $\{\omega^i|_p\}$ is a basis of $T_p^*M$ (as dual basis of the basis $\{s_i|_p\}$ of $T_pM$), $d\varphi_p$ is a pointwise isomorphism. Shrinking $U$ further if needed, the Inverse Function Theorem gives that $\varphi: U \to \varphi(U)$ is a diffeomorphism onto an open subset of $\mathbb{R}^n$. Thus $(x_1, \dots, x_n)$ is a local coordinate chart on $U$.
[guided]
The previous two steps have produced, on the neighbourhood $U$, a collection of closed $1$-forms $\omega^i \in \Omega^1(U)$ that are pointwise linearly independent. We wish to produce coordinates from them.
**Why closedness gives coordinates.** A $1$-form $\omega^i$ is closed on a simply connected domain iff it is exact: there is $x_i \in C^\infty(U)$ with $dx_i = \omega^i$. This is the content of [Poincaré's Lemma](/theorems/???) applied on a neighbourhood diffeomorphic to a ball. The hypotheses are satisfied: we chose $U$ to be diffeomorphic to an open ball, $\omega^i \in \Omega^1(U)$ is closed by the previous step, and smoothness of $\omega^i$ is inherited from the frame.
**Why the $x_i$ are coordinates.** We need $d\varphi_p$ to be an isomorphism at every $p \in U$, where $\varphi = (x_1, \dots, x_n)$. The matrix of $d\varphi_p$ in the standard basis of $T_p^*\mathbb{R}^n$ is the row vector of $(dx_1|_p, \dots, dx_n|_p) = (\omega^1|_p, \dots, \omega^n|_p)$. Since $\{\omega^i|_p\}$ is, by construction, the dual basis to $\{s_i|_p\}$, it is in particular a basis of $T_p^*M$, so $d\varphi_p$ is an isomorphism. The Inverse Function Theorem then gives a local diffeomorphism onto an open subset of $\mathbb{R}^n$; restricting $U$ to this open set gives a coordinate chart.
[/guided]
[/step]
[step:Show that transitions between two such charts are affine]
Suppose $(U, x)$ and $(U', y)$ are two local coordinate systems constructed as in the previous step, with a non-empty overlap $U \cap U'$. Each $dx_j$ and $dy_i$ is a closed $1$-form on its domain satisfying $d_{A^*}(dx_j) = 0$ and $d_{A^*}(dy_i) = 0$ (by the previous steps — they come from parallel coframes).
On $U \cap U'$, the $\{dx_1, \dots, dx_n\}$ are a pointwise basis of $T^*M$, so we may expand
\begin{align*}
dy_i = \sum_{j=1}^n B_{ij}\, dx_j, \qquad B_{ij} \in C^\infty(U \cap U').
\end{align*}
We claim the $B_{ij}$ are locally constant. To see this, apply $d_{A^*}$ to both sides. The Leibniz rule for $d_{A^*}$ on products of a scalar function and a $1$-form reads
\begin{align*}
d_{A^*}(B_{ij}\, dx_j) = dB_{ij} \otimes dx_j + B_{ij}\, d_{A^*}(dx_j) = dB_{ij} \otimes dx_j,
\end{align*}
using $d_{A^*}(dx_j) = 0$. Therefore
\begin{align*}
0 = d_{A^*}(dy_i) = \sum_j dB_{ij} \otimes dx_j.
\end{align*}
Since $\{dx_j\}_{j=1}^n$ is pointwise linearly independent in $T^*M$, the sum $\sum_j dB_{ij} \otimes dx_j$ vanishes in $T^*M \otimes T^*M$ only if each coefficient vanishes:
\begin{align*}
dB_{ij} = 0 \qquad \text{on } U \cap U', \quad \text{for all } i, j.
\end{align*}
Hence each $B_{ij}$ is locally constant. Restricting to a connected component of $U \cap U'$, each $B_{ij}$ equals a real constant $b_{ij}$.
On the connected component, the $1$-form $d(y_i - \sum_j b_{ij} x_j) = dy_i - \sum_j b_{ij}\, dx_j$ vanishes, so the function $y_i - \sum_j b_{ij} x_j$ is constant, equal to some $a_i \in \mathbb{R}$:
\begin{align*}
y_i = \sum_{j=1}^n b_{ij} x_j + a_i \qquad \text{on the connected component of } U \cap U'.
\end{align*}
This is an affine transformation. Since $\{dy_i\}$ and $\{dx_j\}$ are both bases of $T^*M$ on the overlap, the matrix $(b_{ij})$ is invertible, so the transition $y = Bx + a$ lies in the affine group $\mathrm{GL}_n(\mathbb{R}) \ltimes \mathbb{R}^n$.
[guided]
Why should transitions between charts constructed this way be affine, rather than general diffeomorphisms? The key is that **both** $dx_j$ and $dy_i$ are parallel for $d_{A^*}$. Expanding $dy_i = \sum_j B_{ij}\, dx_j$ and applying $d_{A^*}$ uses only the Leibniz rule:
\begin{align*}
0 = d_{A^*}(dy_i) = \sum_j \big(dB_{ij} \otimes dx_j + B_{ij}\, d_{A^*}(dx_j)\big).
\end{align*}
The second kind of term vanishes by parallelism of $dx_j$. The first kind lives in $T^*M \otimes T^*M$, and the tensor factors $dx_j$ are a basis, so each scalar coefficient $dB_{ij}$ must be zero.
A smooth function with zero differential on a connected open set is constant; hence $B_{ij} = b_{ij}$ locally. Now $y_i - \sum_j b_{ij} x_j$ has zero differential on the connected component and is therefore a constant $a_i$. We have shown $y_i = \sum_j b_{ij} x_j + a_i$: a genuine affine transformation. The matrix $B = (b_{ij})$ is invertible because the $\{dy_i\}$ are a basis on the overlap.
**Why affine and not merely locally constant transition?** The Jacobian of the transition map $\varphi' \circ \varphi^{-1}: \varphi(U \cap U') \to \varphi'(U \cap U')$ at the point $\varphi(p)$ is precisely the matrix $B_{ij}(p)$; its constancy as a function on the overlap is exactly what "the transition is affine" means.
[/guided]
[/step]
[step:Assemble the affine atlas and conclude]
Cover $M$ by open neighbourhoods $\{U_\alpha\}$ each carrying a coordinate chart $(U_\alpha, \varphi_\alpha)$ constructed as in Step 4. By the previous step, for every pair $\alpha, \beta$ and every connected component of $U_\alpha \cap U_\beta$, the transition $\varphi_\beta \circ \varphi_\alpha^{-1}: \varphi_\alpha(U_\alpha \cap U_\beta) \to \varphi_\beta(U_\alpha \cap U_\beta)$ is affine, of the form $x \mapsto Bx + a$ with $B \in \mathrm{GL}_n(\mathbb{R})$ and $a \in \mathbb{R}^n$.
A smooth atlas whose transition functions all lie in the affine group $\mathrm{GL}_n(\mathbb{R}) \ltimes \mathbb{R}^n$ is, by definition, an **affine structure** on $M$. Therefore $M$ admits an affine structure, as claimed. This completes the proof.
[/step]