For any principal $G$-bundle $P \to M$ with principal connection $\omega$, given a $G$-invariant polynomial $p: \mathfrak{g} \to \mathbb{R}$ we can construct a form $p(F\_\omega)$ on $P$ which descends to a characteristic form on the base $M$ from the curvature $F\_\omega$. This form is exact when considered as a form on $P$, and the Chern-Simons form $\text{cs}(\omega)$ on $P$ satisfies $p(F\_\omega) = d \text{cs}(\omega)$. 


I have seen it mentioned that Chern-Simons forms are related to boundary terms when computing characteristic numbers, but I have not been able to find a reference explaining this. In particular, I have heard that the Chern-Simons forms are somehow involved in the generalization of the Chern-Gauss-Bonnet theorem to manifolds with boundary.


Could anyone shed some light on this?



Chern-Simons forms, characteristic numbers, and boundary terms?
You might have heard the following. I am actually referring to the second meaning of Chern-Simons classes $\tilde p(\nabla^0,\nabla^1)\in\Omega^\bullet(M)$ satisfying $d\tilde p(\nabla^0,\nabla^1)=p((\nabla^1)^2)-p((\nabla^0)^2)$. They can of course be recovered from the classes you described.


Given a vector bundle $(V,\nabla^V)$ with connection over $M$, you get the Chern-Weil form $p(F)\in\Omega^\bullet(M)$ that you described. A lift to relative forms would be a pair $(p(F),\alpha)$ with $\alpha\in\Omega^\bullet(U)$ satisfying $d\alpha=p(F)|\_U$ on a collar neighbourhood $U$ of $\partial M$. With $\alpha$, you could easily replace $p(F)$ by a cohomologous form with compact support.


To construct $\alpha$, you need more information than just $(V,\nabla^V)$ - you need an explicit reason for $p(V)$ to vanish on $U$. In this context, a plausible reason is the existence of another connection $\nabla'$ on $V|\_U$ such that $F'=(\nabla')^2=0$. This could come from a trivialisation of $V|\_U$, but there might be other possibilities. Now you get the relative term $\alpha=\tilde p(\nabla',\nabla^V|\_U)$, and you can compute a characteristic number
$$\langle(p(F),\tilde p(\nabla',\nabla^V|\_U)),[M,\partial M]\rangle
=\int\_Mp(F)-\int\_{\partial M}\tilde p(\nabla',\nabla^V|\_U)\;.$$


For Gauss-Bonnet-Chern, you need a "reason" for the Euler class of $TM$ to be trivial in a neighbourhood of $\partial M$. This is given by the fact that $TM|\_{\partial M}\cong T\partial M\oplus\underline{\mathbb R}$. But the Levi-Civita connection does not respect this decomposition unless $M$ has totally geodesic boundary. If it does not, then you use a Chern-Simons form for the Euler form as a correction term. In fact, this is also related to Mathai-Quillen currents, which can be used to reduce Gauss-Bonnet-Chern to Poincaré-Hopf.


