Would a closed universe lead to violations of Heisenberg's uncertainty principle? If the universe were finite it should mean that the position of a particle can't be uncertain beyond the universe's size itself. If that is true, then what stops the momentum from being in a perfectly defined state, thereby violating the uncertainty principle?
I know that to measure the momentum with more precision we need longer wavelengths and in a finite universe we can't go beyond a certain wavelength. But I have also read that HUP is not a problem of observational limitations.
So how is HUP upheld in a closed universe?
 A: The uncertainty principle does not actually say that
$$ \sigma_x\sigma_p \geq \frac{\hbar}{2}$$
holds for all states.
This is the form it takes for most states, but this isn't a universal rule. The underlying universal rule is actually dependent on the state. If we make explicit the dependence on the quantum state $\psi$, then the general uncertainty principle for two observables $A$ and $B$ is
$$ \sigma_A(\psi)\sigma_B(\psi) \geq f(\psi)$$
where $f(\psi) = \frac{1}{2}\lvert\langle A\psi,B\psi\rangle - \langle B\psi,A\psi\rangle\rvert$. This is equal to $f(\psi) = \frac{1}{2}\langle \psi, [A,B]\psi\rangle$ if the commutator $[A,B]$ makes sense to apply to $\psi$, and since $[x,p] = \mathrm{i}\hbar$, this gives the much more famous $\sigma_x\sigma_p \geq \frac{\hbar}{2}$ for such states.
The statement "if the commutator $[A,B]$ makes sense to apply to $\psi$" might seem strange, but it is simply a fact that the mathematics of quantum mechanics lead us to cases where there is a state $\psi$ to which you might apply $A$ or $B$ but you cannot apply the commutator to it. This type of pathology occurs when at least one of the operators is unbounded (i.e. when it can, like momentum, have arbitrarily high values). I explain the details of these mathematics for the position and momentum operator on a finite "universe" in this answer of mine. A momentum eigenstate in a finite universe is exactly this type of state, but it has $f(\psi) = 0$ for the non-commutator version, so the uncertainty principle for such states reads
$$ \sigma_x\sigma_p\geq 0,$$
which is always true, so there is no contradiction.
A: There is an analogue of Heisenberg's uncertainty principle that holds if one replaces $\mathbb{R}$ by a finite abelian group; it is easy to prove. Look up for "Donoho-Stark" or just "uncertainty principle for finite abelian groups".
EDIT: If $G$ is a topological group, let us denote by $\hat{G}$ the group (for pointwise multiplication) of continuous morphisms $G \rightarrow \{z \in \mathbb{C} \ \vert \ \vert z \vert = 1\}$.
The group $\hat{G}$ is called the dual of $G$. If $f$ is a function on $G$, we denote by $\hat{f}$ the function on $\hat{G}$ defined by the formula $\xi \mapsto \int_G f(g) \xi(g)dg$ whenever an integral on $G$ is defined and this integral converges.
When $G = \mathbb{R}$, the map $x \mapsto \left(t \mapsto e^{ixt}\right)$ is an isomorphism between $\mathbb{R}$ and $\hat{\mathbb{R}}$ which allows us to identify $\mathbb{R}$ with its dual, and the usual Heisenberg inequality envolves $f$ and $\hat{f}$. Something quite similar can be done with $G = \mathbb{Z}/n\mathbb{Z}$, which also is isomorphic to its dual.
A: The magnitude of Planck's constant is very, very tiny. This causes the uncertainty principle to be significant only on extremely small length scales, of order ~ 1 atomic diameter and less. Long before we get to cosmological distance scales (~ millions of light years and more), the effects of the uncertainty principle have shrunk to insignificance and beyond that the universe is governed by newtonian dynamics and ultimately general relativity.
This means that astrophysics does not have to take into account the uncertainty principle at all except at very, very early times after the big bang when the whole universe itself was very tiny.
