Curvature 0 and involutive horizontal distributions I am trying to check why curvature 0 implies that the horizontal distribution is involutive.
Let $\pi:P\to U$ be a principal $G:=GL_n$ bundle. Assume that $P$ is trivial and $\pi$ admits a section. Thus, $P\cong U\times G$. A connection on $P$ is a $G$ equivariant splitting of the short exact sequence of bundles $0\to P\times\mathfrak{g} \to TU\oplus TG\to \pi^*TU\to 0$. Let us denote this splitting by $s$. If $(v,u)$ is a tangent vector at the point $(x,g)$, then $s(v,u)=w_x(v)+(R_{g^{-1}})_*(u)$, where $w\in\Gamma(X,\Omega_U\otimes\mathfrak{g})$. 
Let $x_1,x_2,...x_n$ be coordinates on $U$ and consider vector fields $X_i$ corresponding to them. Use these to construct horizontal $G$ invariant vector fields on $P$ which are given by $((X_i)_x, -w_x((X_i)_x))$ at the point $(x,Id)$. This should give an involutive distribution on $P$. 
Using that $[X_1,X_2]=0$, when we compute the Lie bracket, we get 
$[(X_1,-w(X_1)),(X_2,-w(X_2))]=-[w(X_1),X_2]-[X_1,w(X_2)]+[w(X_1),w(X_2)]$.
=$X_2(w(X_1))-X_1(w(X_2))+[w(x_1),w(X_2)]$. We need to show that this is 0.
The condition that curvature is 0 is given by $dw+w\wedge w=0$, i.e. $dw_{ij}+\sum_{k=0}^{n}w_{ik}\wedge w_{kj}=0$. This means that $dw(X_1,X_2)+[w(x_1),w(X_2)]=0$, which is same as saying that $X_1(w(X_2))-X_2(w(X_1))+[w(x_1),w(X_2)]=0$
There seems to be some mismatch.
 A: I realise that you are asking for someone to find where your sign mistake is, but in my opinion that's not what MO is for.  Instead, let me sketch why flatness of the connection is equivalent to the integrability of the horizontal distribution.
Let $\pi: P \to M$ be a principal $G$-bundle and $\mathcal{H}\subset TP$ a connection, with connection 1-form $\omega$.  In other words, $\mathcal{H} = \ker \omega$.  I take it as read that these objects all satisfy the standard $G$-equivariance conditions.
Let $h: TP \to \mathcal{H}$ denote the horizontal projection along $\mathcal{V}:=\ker\pi_*$.
Then the curvature 2-form $\Omega$ is defined by
$$
\Omega(X,Y) := d\omega(hX,hY)
$$
for vector fields $X,Y$ on $P$.
Using the definition of $d\omega$
$$
\Omega(X,Y) = (hX)\omega(hY) - (hY)\omega(hX) - \omega([hX,hY]) = - \omega([hX,hY])
$$
where we have used that $\omega(hX)=0$ for all $X$.  Therefore $\Omega\equiv 0$ if and only if for all vector fields $X,Y$, $[hX,hY] \in \ker \omega$, which is equivalent to saying that the Lie bracket of any two horizontal vector fields is again horizontal.
