The theta term and triviality of principal bundles

Apologies if this question is trivial or has been answered before.

If we consider a Yang-Mills theory (with a simple, compact Lie group $$G$$) on $$\mathbb{R}^4$$, it is well-known that all the finite-action gauge connections can be classified by the second Chern number $$n$$ (see this, for example) given by $$n = \frac{1}{8\pi^2} \int_{S^4} \text{Tr} \left( F \wedge F\right).$$

The reason why we integrate over $$S^4$$ is that the boundary condition imposed by finite-action requirement makes it equivalent to consider principal $$G$$-bundles over $$S^4$$ instead, and it is possible to construct non-trivial principal bundles on $$S^4$$. However, this does not mean that we have suddenly changed our base manifold to $$S^4$$, just that the compactification to $$S^4$$ aids our classification. This brings me to my question:

Ultimately we are still living in $$\mathbb{R}^4$$, and any principal bundles we can construct over it is necessarily trivial and the second Chern number vanishes. Does this not mean that the so-called $$\theta$$ term $$\frac{\theta}{8\pi^2} \int_{\mathbb{R}^4} \text{Tr} \left( F \wedge F\right)$$ equals 0? And if that is the case, this $$\theta$$ parameter would become unphysical, in contrary to basically what every paper about the $$\theta$$ term says.

What am I missing?

• see e.g. the first section of this answer of mine Commented May 11, 2021 at 8:36
• I see! From the post you reference, it seems that the choice of using 4-sphere instead of Euclidean 4-space is one based on physics requirements (e.g. anomaly) but not mathematics alone. I'm not sure if this can be answered in a comment, but if that is the case, would it be fair to say that having the eta prime meson being so much heavier than the eta meson implies the non-trivial topology of the underlying spacetime (if we take anomaly as the explanation to the U(1)_A problem)? Commented May 14, 2021 at 1:47
• I wondered about that in this question, too. As I explain in the first answer I linked, we get to $S^4$ by considering the behaviour of the field "at infinity". Whether you consider that infinity "part of spacetime" or not is your interpretation, but I think most people would not say that us considering the compactification $S^4$ because we want well-defined behaviour at infinity means "spacetime is non-trivial" - the actual spacetime is still $\mathbb{R}^4$, the infinite point is not "physically part of it". Commented May 14, 2021 at 8:54