Solution (source code)

= Solution
{c}

For a <perfect fluid in general relativity>, let $\rho$ be rest-frame total <energy> density divided by $c^2$, $P$ its isotropic <pressure>, and $U^\mu$ its <four-velocity>, normalized by $U^\mu U_\mu=-c^2$. Then
$$
T^{\mu\nu}=\left(\rho+\frac{P}{c^2}\right)U^\mu U^\nu+Pg^{\mu\nu}.
$$
The <contracted Bianchi identity> and the <Einstein field equations> give <stress-energy conservation>, $\nabla_\mu T^{\mu\nu}=0$, for a constant <cosmological constant>. Contract with $U_\nu$ and use the normalization to obtain
$$
U^\mu\partial_\mu\rho+\left(\rho+\frac{P}{c^2}\right)\nabla_\mu U^\mu=0.
$$
In <comoving coordinates> $U^\mu=(1,0,0,0)$ and the <covariant divergence> is $\nabla_\mu U^\mu=3\dot R/R=3H$, where a dot is a <cosmic time> <derivative> and $H$ the <Hubble parameter>. Therefore
$$
\boxed{\dot\rho+3H\left(\rho+\frac{P}{c^2}\right)=0.}
$$
For a fixed region in <comoving coordinates>, let $V(t)=V_*R^3(t)$ be its physical <volume>, where $V_*$ is a fixed coordinate-volume integral, and let $E=\rho c^2V$. Since $\dot V=3HV$,
$$
\frac{dE}{dt}+P\frac{dV}{dt}
=c^2V\left[\dot\rho+3H\left(\rho+\frac{P}{c^2}\right)\right]=0.
$$
Thus the <cosmological perfect-fluid continuity equation> is exactly equivalent to the adiabatic <first law of thermodynamics>, $\boxed{dE=-P\,dV}$, for every nonzero such region. Conversely, expanding that <first law of thermodynamics> and dividing by $c^2V$ recovers the same equation. No <heat> or <particle> flux crosses the comoving boundary; interacting components separately need source terms, although the total still obeys this conservation equation.

There is a sign inconsistency in the supplied formula sheet worth isolating. Its <Riemann curvature tensor> and <Ricci tensor> conventions, together with its stated $-+++$ <metric signature>, give $G_{tt}=-3H^2$ for $R(t)=e^{Ht}$ with constant $H$. Its vacuum <Einstein field equations> with $+\Lambda g_{\mu\nu}$ then require $H^2=-\Lambda c^2/3$, whereas its printed vacuum <Friedmann equation> gives $H^2=+\Lambda c^2/3$. For example, $H>0$, $\rho=P=0$ and $\Lambda=3H^2/c^2$ satisfy the latter but leave the former's $tt$ component equal to $-6H^2$. Changing the geometric <cosmological constant> term to $-\Lambda g_{\mu\nu}$ repairs this mismatch. The conservation derivation is unaffected; below take the geometric <cosmological constant> to be zero and include any <vacuum energy> as a fluid, so no ambiguous sign enters.