[proofplan]
We prove the theorem locally, because closedness of a differential form is local on $X$. After choosing a local frame for $E$, the connection is represented by a matrix-valued one-form $A$ and the curvature by a matrix-valued two-form $\Omega$. For each homogeneous component of $P$, we write it through its symmetric invariant polarization and use the infinitesimal invariance identity to show that the ordinary [exterior derivative](/theorems/1525) of the scalar form can be computed by applying the covariant exterior derivative to one curvature factor at a time. The Bianchi identity then makes every term vanish.
[/proofplan]
[step:Reduce to a homogeneous invariant polynomial in a local frame]
Since the assertion $d\,P(F_\nabla)=0$ is linear in $P$, write $P$ as a finite sum of homogeneous conjugation-invariant polynomials. The constant homogeneous component gives a constant differential form, hence its exterior derivative is zero. It therefore suffices to prove the result for a homogeneous invariant polynomial of degree $k \geq 1$.
Let $U \subset X$ be an [open set](/page/Open%20Set) over which $E$ is trivialized by a smooth local frame $e=(e_1,\dots,e_r)$. In this frame, the connection is represented by a matrix-valued one-form
\begin{align*}
A \in \Omega^1(U;\mathfrak{gl}_r(\mathbb{C})).
\end{align*}
The curvature is represented by the matrix-valued two-form
\begin{align*}
\Omega := dA + A \wedge A \in \Omega^2(U;\mathfrak{gl}_r(\mathbb{C})).
\end{align*}
Here $A \wedge A$ denotes wedge product of forms combined with matrix multiplication. Since the local matrix $\Omega$ represents the global curvature $F_\nabla$, the restriction of $P(F_\nabla)$ to $U$ is the scalar form obtained from $P(\Omega)$ in this frame. Because $P$ is invariant under conjugation, these local scalar forms agree on overlaps, so it is enough to prove $d\,P(\Omega)=0$ on every such $U$.
[/step]
[step:Express the invariant polynomial through its symmetric polarization]
Let
\begin{align*}
\widetilde P: \mathfrak{gl}_r(\mathbb{C})^k \to \mathbb{C}
\end{align*}
denote the symmetric $k$-linear polarization of the homogeneous polynomial $P$, normalized so that
\begin{align*}
P(B)=\widetilde P(B,\dots,B)
\end{align*}
for every $B \in \mathfrak{gl}_r(\mathbb{C})$. For $\mathfrak{gl}_r(\mathbb{C})$-valued differential forms $\alpha_1,\dots,\alpha_k$ on $U$, define the scalar differential form $\widetilde P(\alpha_1,\dots,\alpha_k)$ by applying $\widetilde P$ to the matrix coefficients and wedging the form coefficients in the displayed order. With this convention,
\begin{align*}
P(\Omega)=\widetilde P(\Omega,\dots,\Omega) \in \Omega^{2k}(U).
\end{align*}
The conjugation invariance of $P$ implies the infinitesimal invariance identity for $\widetilde P$: for all $C,B_1,\dots,B_k \in \mathfrak{gl}_r(\mathbb{C})$,
\begin{align*}
\sum_{j=1}^k \widetilde P(B_1,\dots,[C,B_j],\dots,B_k)=0.
\end{align*}
Indeed, differentiating the identity
\begin{align*}
\widetilde P(e^{tC}B_1e^{-tC},\dots,e^{tC}B_ke^{-tC})=\widetilde P(B_1,\dots,B_k)
\end{align*}
at $t=0$ gives exactly this formula.
[/step]
[step:Replace the ordinary exterior derivative by the covariant exterior derivative inside the invariant pairing]
Define the covariant exterior derivative in the chosen frame by the map
\begin{align*}
d_A: \Omega^q(U;\mathfrak{gl}_r(\mathbb{C})) \to \Omega^{q+1}(U;\mathfrak{gl}_r(\mathbb{C}))
\end{align*}
given, for $\beta \in \Omega^q(U;\mathfrak{gl}_r(\mathbb{C}))$, by
\begin{align*}
d_A\beta := d\beta + A \wedge \beta - (-1)^q \beta \wedge A.
\end{align*}
Since $\Omega$ has degree $2$, this becomes
\begin{align*}
d_A\Omega=d\Omega+A\wedge\Omega-\Omega\wedge A.
\end{align*}
We claim that
\begin{align*}
d\,\widetilde P(\Omega,\dots,\Omega)=\sum_{j=1}^k \widetilde P(\Omega,\dots,d_A\Omega,\dots,\Omega),
\end{align*}
where $d_A\Omega$ appears in the $j$-th slot. By the ordinary Leibniz rule for the exterior derivative, and because every curvature factor $\Omega$ has even degree, no sign occurs when $d$ passes the earlier factors:
\begin{align*}
d\,\widetilde P(\Omega,\dots,\Omega)=\sum_{j=1}^k \widetilde P(\Omega,\dots,d\Omega,\dots,\Omega).
\end{align*}
Substituting $d\Omega=d_A\Omega-A\wedge\Omega+\Omega\wedge A$, it remains only to show that the sum of the inserted commutator terms vanishes. At each point of $U$, the one-form $A$ contributes a matrix $C \in \mathfrak{gl}_r(\mathbb{C})$ in the exterior slot being evaluated, while $\Omega$ contributes matrices $B_1,\dots,B_k$. The total contribution is precisely
\begin{align*}
-\sum_{j=1}^k \widetilde P(B_1,\dots,[C,B_j],\dots,B_k),
\end{align*}
with the sign determined by the displayed convention for $d_A$ and the fact that all $\Omega$ factors have even degree. This vanishes by the infinitesimal invariance identity. Hence the claimed formula holds.
[guided]
The point of this step is to justify the standard Chern-Weil slogan: inside an invariant polynomial, the ordinary exterior derivative may be replaced by the covariant exterior derivative. We must prove this rather than merely state it, because the replacement introduces commutator terms.
We work in the fixed local frame on $U$. The covariant exterior derivative is the operator
\begin{align*}
d_A: \Omega^q(U;\mathfrak{gl}_r(\mathbb{C})) \to \Omega^{q+1}(U;\mathfrak{gl}_r(\mathbb{C}))
\end{align*}
defined by
\begin{align*}
d_A\beta=d\beta+A\wedge\beta-(-1)^q\beta\wedge A.
\end{align*}
For the curvature form $\Omega \in \Omega^2(U;\mathfrak{gl}_r(\mathbb{C}))$, the degree is even, so
\begin{align*}
d_A\Omega=d\Omega+A\wedge\Omega-\Omega\wedge A.
\end{align*}
Equivalently,
\begin{align*}
d\Omega=d_A\Omega-A\wedge\Omega+\Omega\wedge A.
\end{align*}
Now apply the ordinary exterior derivative to the scalar form $\widetilde P(\Omega,\dots,\Omega)$. The form $\widetilde P(\Omega,\dots,\Omega)$ is built by wedging the scalar coefficients coming from the $k$ curvature factors after applying the multilinear map $\widetilde P$ to their matrix parts. Therefore the usual graded Leibniz rule gives
\begin{align*}
d\,\widetilde P(\Omega,\dots,\Omega)=\sum_{j=1}^k \widetilde P(\Omega,\dots,d\Omega,\dots,\Omega).
\end{align*}
There are no alternating signs in this formula because each factor before the differentiated slot has degree $2$, and $(-1)^{2m}=1$ for every integer $m \geq 0$.
Substitute the expression for $d\Omega$ in terms of $d_A\Omega$:
\begin{align*}
d\,\widetilde P(\Omega,\dots,\Omega)=\sum_{j=1}^k \widetilde P(\Omega,\dots,d_A\Omega,\dots,\Omega)+\mathcal C,
\end{align*}
where $\mathcal C$ denotes the total contribution of the terms $-A\wedge\Omega+\Omega\wedge A$ inserted into the $j$-th slot. We now identify $\mathcal C$. Evaluating the resulting form on tangent vectors at a point of $U$, the one-form $A$ supplies a matrix $C \in \mathfrak{gl}_r(\mathbb{C})$, while the curvature factors supply matrices $B_1,\dots,B_k \in \mathfrak{gl}_r(\mathbb{C})$. The two products $A\wedge\Omega$ and $\Omega\wedge A$ insert the two matrix products $CB_j$ and $B_jC$ in the same slot, so their difference is the commutator $[C,B_j]=CB_j-B_jC$. With the sign from $d\Omega=d_A\Omega-A\wedge\Omega+\Omega\wedge A$, the full commutator contribution is
\begin{align*}
-\sum_{j=1}^k \widetilde P(B_1,\dots,[C,B_j],\dots,B_k).
\end{align*}
This is exactly where invariant polynomials enter. Since $P$ is conjugation-invariant, its polarization $\widetilde P$ satisfies the infinitesimal invariance identity
\begin{align*}
\sum_{j=1}^k \widetilde P(B_1,\dots,[C,B_j],\dots,B_k)=0
\end{align*}
for every $C,B_1,\dots,B_k \in \mathfrak{gl}_r(\mathbb{C})$. Hence $\mathcal C=0$, and we obtain the desired covariant Leibniz formula:
\begin{align*}
d\,\widetilde P(\Omega,\dots,\Omega)=\sum_{j=1}^k \widetilde P(\Omega,\dots,d_A\Omega,\dots,\Omega).
\end{align*}
[/guided]
[/step]
[step:Apply the Bianchi identity to the curvature factor in every slot]
The curvature form $\Omega=dA+A\wedge A$ of the connection matrix $A$ satisfies the Bianchi identity
\begin{align*}
d_A\Omega=0.
\end{align*}
Here we are using the standard Bianchi identity for connections (citing a result not yet in the wiki: Bianchi identity). Therefore each term in the formula from the previous step is zero:
\begin{align*}
\widetilde P(\Omega,\dots,d_A\Omega,\dots,\Omega)=0.
\end{align*}
Consequently,
\begin{align*}
d\,P(\Omega)=d\,\widetilde P(\Omega,\dots,\Omega)=0
\end{align*}
on the chosen trivializing open set $U$.
[/step]
[step:Patch the local closedness statement to the global Chern-Weil form]
The open set $U$ was arbitrary among trivializing open sets for $E$. On every such $U$, the restriction of the global form $P(F_\nabla)$ is represented by $P(\Omega)$ and satisfies
\begin{align*}
d\,P(\Omega)=0.
\end{align*}
Since exterior differentiation commutes with restriction to open subsets and closedness of a differential form is local, the global form satisfies
\begin{align*}
d\,P(F_\nabla)=0
\end{align*}
on all of $X$. This proves the theorem for every homogeneous component of $P$, and by linearity for the original invariant polynomial $P$.
[/step]