  We present a CO and atomic fine-structure line luminosity function analysis
using the ALMA Spectroscopic Survey in the Hubble Ultra Deep Field (ASPECS).
ASPECS consists of two spatially-overlapping mosaics that cover the entire ALMA
3mm and 1.2mm bands. We combine the results of a line candidate search of the
1.2mm data cube with those previously obtained from the 3mm cube. Our analysis
shows that $\sim$80% of the line flux observed at 3mm arises from CO(2-1) or
CO(3-2) emitters at $z$=1-3 (`cosmic noon'). At 1.2mm, more than half of the
line flux arises from intermediate-J CO transitions ($J_{\rm up}$=3-6);
$\sim12$% from neutral carbon lines; and $< 1$% from singly-ionized carbon,
[CII]. This implies that future [CII] intensity mapping surveys in the epoch of
reionization will need to account for a highly significant CO foreground. The
CO luminosity functions probed at 1.2mm show a decrease in the number density
at a given line luminosity (in units of $L'$) at increasing $J_{\rm up}$ and
redshift. Comparisons between the CO luminosity functions for different CO
transitions at a fixed redshift reveal sub-thermal conditions on average in
galaxies up to $z\sim 4$. In addition, the comparison of the CO luminosity
functions for the same transition at different redshifts reveals that the
evolution is not driven by excitation. The cosmic density of molecular gas in
galaxies, $\rho_{\rm H2}$, shows a redshift evolution with an increase from
high redshift up to $z\sim1.5$ followed by a factor $\sim 6$ drop down to the
present day. This is in qualitative agreement with the evolution of the cosmic
star-formation rate density, suggesting that the molecular gas depletion time
is approximately constant with redshift, after averaging over the star-forming
galaxy population.
