\documentclass[main.tex]{subfiles}
\begin{document}

% \section*{Fri Oct 11 2019}
% \marginpar{Friday \\ 2019-10-11, \\ compiled \\ \today}

% On Oct 31 Marco Peloso will not give his lecture, so Sabino will do both lectures.

% Recalling last lecture:
% we consider a universe with constant density \(\rho\)\dots

We can also recover the third Friedmann equation
\begin{equation}
\dot{\rho} = -3 \frac{\dot{a}}{a} \qty(\rho + \frac{P}{c^2}) \approx -3 \frac{\dot{a}}{a} \rho
\,,
\end{equation}
%
where the approximation as before is the Newtonian one, \(P \ll \rho c^2\). In this case, however, we will be able to also recover the nonrelativistic pressure term if we account for conservation of energy and not just mass.
% without the last term, which yet again will come from the relativistic consideration.

When deriving these equations relativistically the third one comes from the conservation of the temporal component of the stress-energy tensor (\(\nabla_{\mu } T^{\mu 0} = 0\)), i.e. the ``conservation of energy'',\footnote{This is actually \emph{not} a conservation law as stated, it is not covariant: in order for it to be we would need to project it along a temporal Killing vector, which does not exist in cosmology. However, if we did have a temporal Killing vector \(\xi_{\mu }\) the projection \(\xi_{\nu } \nabla_{\mu } T^{\mu \nu } =0\) would indeed be the conservation of energy.

Indeed, it is more correct to say that this equation is not a conservation law at all, but is instead just an expression of the geometric Bianchi identities \(\nabla_{\mu } G^{\mu \nu }=0\), which are written in terms of the Einstein tensor \(G_{\mu \nu } = R_{\mu \nu } - \frac{1}{2} R g_{\mu \nu }\); if the Einstein equations hold then \(G_{\mu \nu } \) is proportional to \(T_{\mu \nu }\), therefore the two statements are equivalent.}
so to find it in our Newtonian calculation we will need to consider the nonrelativistic equivalent of that equation, which is the first law of thermodynamics.

We will consider \emph{ideal fluids}.
The first law, assuming adiabaticity --- which must be present, since net heat transfer in the universe would violate isotropy ---  states:
\begin{equation}
  \dd{E} + P\dd{V} = 0\,.
\end{equation}

We can write the total energy as the product of the energy density times the volume: \(E = \frac{4 \pi }{3} \rho c^2 a^{3}\), since the volume is \(V = \frac{4 \pi }{3} a^3\).

So, the first law reads:
%
\begin{align}
0&=\frac{4\pi }{3}\qty[\dd{\qty(\rho c^2 a^3)} + P \dd{(a^3)}]   \\
&= c^2 \rho \dd{(a^3)} + c^2 a^3 \dd{\rho } + P \dd{(a^3)}   \marginnote{Divided through by \(4 \pi / 3\)}\\
&= 3 \qty(\rho + \frac{P}{c^2}) \frac{\dd{a}}{a} + \dd{\rho } \marginnote{Divided through by \(c^2a^3\), collected terms.}
\,,
\end{align}
%
which is the third Friedmann equation, \eqref{eq:friedmann-3}: the only manipulation left to do is to apply the differentials, which are covectors, to the temporal vector \(\dv*{}{t}\) in order to turn them into time derivatives.

Why were we able to recover the relativistic term this time? The completely non-relativistic approach to this would be to write \(M = \frac{4\pi }{3} \rho a^3 \), and to write down the equation for the conservation of mass alone.
Indeed, this would yield the Friedmann equation without the \(P\) term.
What we have effectively done is to consider the first relativistic order instead, since the classical kinetic energy is recovered by the first order expansion \(E = \gamma mc^2 \approx m + mv^2 / 2\).

% \todo[inline]{Footnote number 5 at page 17 in \cite{paccianiAppuntiCorsoPhysical2018} states: ``In generale si può porre \(\ell(t) = a(t)r\) con \(r\) coordinata comovente adimensionale per la validità del principio cosmologico; \(r\) può
% essere sempre scelta piccola a piacere di modo che ad ogni istante valga la condizione di campo debole.''
% This does not seem to make sense: the weak-field condition is not dependent on our coordinate choices, and in fact is written in terms of \(\ell\) and not \(r\).}

The three Friedman equations are not all independent, we only need two of them: for example, the second one \eqref{eq:friedmann-2} can be derived from the first and third.

This means that we can derive the full relativistic equations in this Newtonian context, using the derivations we have shown for the first and third equation, and then combining these to find the second.

% \begin{subequations}
%     \begin{align}
%         \dot{a}^2 &= \frac{8 \pi G }{3} \rho a^2 - kc^2  \\
%         \ddot{a} &= - \frac{4 \pi G }{3} a  \qty(\rho  + \frac{3P}{c^2} )  \\
%         \dot{\rho} &= -\frac{3\dot{a} }{a} \qty(\rho + \frac{P}{c^2} )
%     \end{align}
% \end{subequations}

% The equations are in terms of the three parameters \(a\), \(\rho\) and \(p\), which are all functions of time.

% The third equation comes from the Bianchi identities \(\nabla_{\mu} G^{\mu \nu}=0\).

Let us do this derivation explicitly:
we differentiate the first Friedmann equation
\begin{equation}
  \dot{a}^2 = \frac{8 \pi G}{3} \rho a^2 - k c^2
\end{equation}
with respect to time to find
\begin{equation}
  2 \dot{a} \ddot{a} =
  \frac{8 \pi G}{3} \dot{\rho} a^2 + \frac{16 \pi G}{3} \rho \dot{a} a
\end{equation}

We then substitute in the expression we have for \(\dot{\rho} \) from the third equation:
%
\begin{align}
\dot{\rho} = -3 \frac{\dot{a}}{a} \qty(\rho + \frac{P}{c^2})
\,,
\end{align}
%
which gives us
%
\begin{align}
2 \dot{a} \ddot{a} &=
\frac{8 \pi G}{3} \qty[- 3 \frac{\dot{a}}{a} \qty(\rho + \frac{P}{c^2})] a^2 + \frac{16 \pi G}{3} \rho  \dot{a} a  \\
\ddot{a} &= - 4 \pi G \qty(\rho + \frac{P}{c^2}) a
+ \frac{8 \pi G}{3} \rho a
 \marginnote{Dividing through by \(2\dot{a}\)}  \\
\frac{\ddot{a}}{a} &= - \frac{8 \pi G}{3} \qty[\frac{3}{2} \qty(\rho + \frac{P}{c^2}) - \rho ]
\marginnote{Dividing through by \(a\)}
\\
\frac{\ddot{a}}{a} &= -\frac{4 \pi G}{3} \qty(\rho + 3 \frac{P}{c^2})
\,,
\end{align}
%
which is precisely equation \eqref{eq:friedmann-2}.

\section{The equation of state}

So, the equation system is underdetermined: we do not in fact have three independent Friedmann equations, but just two.
The variables we want to find, however, are three: \(P(t)\), \(\rho (t)\), \(a(t)\).

We have to make an assumption: we will assume our fluid is a \emph{barotropic} perfect fluid, that is, one for which the pressure only depends on the density: \(P \overset{!}{=} P(\rho)\).

Very often this equation of state will be linear: \(P = w \rho c^2\), with a dimensionless constant \(w\).\footnote{This is a latin \(w\), not a greek \(\omega \): students historically call it ``omega'' for some reason.}
We will assume this relation to be true.

% This is related to the adiabatic constant \(\gamma\) by \(\gamma = w+1\).

% We are going to assume homogeneity and isotropicity.

\subsection{Common equations of state}
\label{sec:common-equations-of-state}

A thing we will compute for the different equations of state is the adiabatic\footnote{The speed of sound is usually computed for adiabatic transformations, since the transmission of sound is usually close to an adiabatic process. In our case, adiabaticity is embedded in the hypotheses made in the derivation of the Friedmann equations. So, we can calculate the derivative without worrying about the adiabaticity condition being respected since for the solutions we will consider it always will be.} speed of sound:
%
\begin{align}
c^2_{s} = \pdv{P}{\rho } = \dv{P}{\rho } = w c^2
\,.
\end{align}

We also will be able to tell what the evolution of the energy density is for a varying scale factor:
this can be derived from the third Friedmann equation \eqref{eq:friedmann-3}: in this case it reads
%
\begin{align}
\frac{\dot{\rho}}{\rho } + 3\frac{P}{\rho c^2} \frac{\dot{a}}{a} + 3 \frac{\dot{a}}{a}  &= 0   \\
\frac{\dot{\rho}}{\rho } + 3 (1+w) \frac{\dot{a}}{a} &= 0 \\
\dv{}{t} \log \qty(\rho a^{3(1+w)}) &=0 \implies \rho a^{3(1+w)} = \const
\,,
\end{align}
%
so \(\rho \propto a^{-3(1+w)}\).

\begin{enumerate}
  \item \(w = 0\) is equivalent to \(P \equiv 0\): this is what we get in the nonrelativistic limit, for \(P \ll \rho c^2\), since there is no pressure this can be interpreted as a \emph{dust}. In this case \(\rho \propto a^{-3}\); also, we have \(c_s^2 \ll c^2\).
  \item \(w = 1/3\) is what we get if we seek the pressure of radiation.\footnote{This expression can be derived in different ways, one of which is to start from the fact that the stress energy tensor must be traceless since it is of the form \(T_{\mu \nu } \sim \sum _{i} \rho u^{(i)}_{\mu } u^{(i)}_{\nu }\), where \(u_{\mu }^{(i)}\) are the four-velocities of photons: their norm is zero, so we must have \(g^{\mu \nu} T_{\mu \nu } = 0\), but also for a perfect fluid \(T = T^{\mu }_{\mu } = \rho - 3 P/c^2\). Another, perhaps more illustrative derivation was given in the General Relativity course \cite[pag. 86-87]{tissinoGeneralRelativityNotes2020}.}
  In this case we have \(c_s = c/ \sqrt{3}\), while the energy density goes like \(\rho \propto a^{-4}\), since we get a factor \(a^{-3}\) from the volume expansion and another \(a^{-1}\) from the decrease of the energy of each photon due to redshift.
  Alternatively, from what was derived before we can see that the exponent in the powerlaw must be \(- 3(1+1/3) = -4\).

  So, for a radiation-dominated universe the total energy \(E \propto \rho a^{3} \propto a^{-1}\) is not conserved.
  \item \(w=1\) is called \emph{stiff matter}: it has \(P = \rho c^2\) and  \(c_s = c\).
  This is an incompressible fluid: it is so difficult to set this matter in motion that once one does it travels at the speed of light. Now, \(\rho \propto P \propto a^{-6}\).
  \item \(w=-1\) means that \(P = - \rho c^2\). We cannot compute a speed of sound (it would be imaginary).
  Now \(\rho\) and \(p\) are constants, since they are proportional to \(a^{0}=1\). This is the case of dark energy: we will show in section \ref{sec:cosmological-constant} that inserting a cosmological constant \(\Lambda\) into the Einstein equations has precisely this effect.\footnote{This is shown by interpreting the additional term in the EFE as an addition to the stress-energy tensor and interpreting it as a perfect-fluid tensor \cite[eqs. 434-438]{tissinoGeneralRelativityNotes2020}.}
\end{enumerate}

% Some possible equations of state are \(P \equiv 0\), or \(w =0\): this means \(\gamma =1 \). This is a \emph{dust pressureless fluid}.

% What is the speed of sound of our fluid? We only have the adiabatic speed of sound \(c_s^2 = \pdv*{p}{\rho}\), where the derivative is to be taken at constant entropy and is just a total derivative in the barotropic case.

% Also in the baryonic case \(p=0\) is a good approximation.

% If \(p=0\) we can simplify:
% \begin{equation}
%   \dot{\rho} = -3 \frac{\dot{a} }{a} \rho \implies
%   \rho \propto a^{-3}\,.
% \end{equation}

% Another case is a \emph{gas of photons}: in that case \(p = \rho c^2 / 3\), so \(w=\frac{1}{3} \), \(\gamma = \frac{4}{3} \), \(c_{s}^2 = c^2 / 3 \): the speed of sound is \(c / \sqrt{3} \). These photons are thermal: perturbations can propagate (even without interactions with matter\dots).

% In this case we get \(\rho \propto p \propto a^{-4}\).

So, we replace the third Friedmann Equation with \(w = \const\) and
%
\begin{align}
  \rho(t) = \rho_{*} \qty(a(t) / a_{*})^{-3(1+w)}
\,,
\end{align}
%
where \(a_{*}\) and \(\rho_{*} \) are the scale factor and density at some chosen time.

If we substitute this expression into the second FE we get that gravity is attractive and the universe \emph{decelerates} (\(\ddot{a} < 0 \)) if and only if \(w > -1/3\).

Throughout this section we worked as if we had a single type of cosmic fluid in the universe: this is not really the case, we have many of them, and they will be interacting, but it is a good first approximation to consider them as separate.

\begin{figure}[ht]
\centering
\includegraphics[width=\textwidth]{figures/global_energy_contributions.pdf}
\caption{Contributions to the energy density varying with the scale factor. They are normalized to the current critical energy density, using data from the 2015 Planck mission \cite{adePlanck2015Results2016}. The increase of the radiation energy density with an increasing scale factor is sharp, but the crossover point with the matter density is at \(a = \rho_{\text{rad}}/\rho_{\text{m}} \approx \num{e-4}\), at which point we have \(\rho \approx \num{e12} \rho_{0c}\).}
\label{fig:global_energy_contributions}
\end{figure}

In figure \ref{fig:global_energy_contributions}, \(a\) can be interpreted as the time, since their relation is monotonic.
We could insert the spatial curvature \(k\) in the plot: it decreases, but slower than matter, since it appears in the first Friedmann equation with an exponent \(a^{-2}\).
We can find an effective \(\rho (a)\) law for the curvature by defining an effective \(\rho_{k}\) for curvature with \(H^2 = \frac{8 \pi G}{3} (\rho + \rho_{k})\), which implies \(\rho_{k} = - 3 k c^2 / (8 \pi G a^2)\).

We can also express this in units of the critical energy density \(\rho_{c} = 3 H^2 / (8 \pi G)\): we find
%
\begin{align} \label{eq:spatial-curvature-effective-density}
\frac{\rho_{k}}{\rho_{c}} = \Omega_{k} = - \frac{kc^2}{H^2a^2}
\,.
\end{align}

Now, the dark energy in the universe is the most important component. It it dominant over matter, radiation, and also dominant over spatial curvature.

\section{Solutions of the Friedmann Equations}
\label{sec:solutions-to-friedmann-equations}

We want to solve the equation system
%
\begin{align}
\frac{\dot{a}^2}{a^2} &= \frac{8 \pi G}{3} \rho - \frac{kc^2}{a}  \label{eq:friedmann-1-later} \\
\rho (t) &= \rho_{* } \qty(\frac{a(t)}{a_{*}})^{-3 (1+w)}
\label{eq:friedmann-3-later}
\,,
\end{align}
%
which encompasses all the physical content of the FE, since the second equation can be derived from these two.

Inserting \eqref{eq:friedmann-3-later} into \eqref{eq:friedmann-1-later} we find:
%
\begin{equation}
  \qty(\frac{\dot{a} }{a})^2 =
  \frac{8 \pi G}{3} \rho_* \qty(\frac{a}{a_*}) ^{-3 (1+w)} - \frac{kc^2}{a^2}\,.
\end{equation}

\subsection{Einstein-De Sitter models}

As we discussed before, if we had zero spatial curvature (\(k=0\)) then we would find \(\rho = \rho_{c} = 3 H^2 / (8 \pi G )\): so, we define the parameter \(\Omega = \frac{8 \pi G \rho}{3 H^2} = \rho / \rho_C\) which quantifies how close this is to being true; experimentally, this is compatible with 1.

The Einstein-de Sitter model is one where we take \(\Omega \equiv 1\): negligible spatial curvature, which is equivalent to setting \(k=0\). So, the equation becomes:
\begin{equation}
  \dot{a}^2 = \underbrace{\frac{8 \pi G}{3} \rho_* a_{*}^{3 (1+w)}}_{A^2} a^{-(1+3w)}
  \,,
  \marginnote{Set \(k=0\), multiplied by \(a^2\), defined \(A\).}
\end{equation}
%
therefore \(\dot{a} = \pm A a^{-\frac{1+3w}{2}}\), or \(a ^{\frac{1+3w}{2}}\dd{a} = \pm A \dd{t}\).
We choose the positive sign, since we observe the universe to be expanding.
This can be integrated directly: the equation is
%
\begin{align}
\int_{a_{*}}^{a} \widetilde{a}^{\frac{1+3w}{2}} \dd{\widetilde{a}} = A \int_{t_{*}}^{t} \dd{\widetilde{t}} = A\qty(t-t_{*})
\,,
\end{align}
%
but we must distinguish two cases: either \((1+3w) / 2 =-1\), which is equivalent to \(w = -1\), or not.
Let us first assume that \(w \neq -1\). Then, we get:

A solution is:
\begin{align}
  \frac{2}{3 + 3w}\eval{a^{\frac{3+3w}{2}}}_{a_{*}}^{a} &= A \qty(t - t_{*})
   \\
   a^{\frac{3 + 3w}{2}}  - a_{*}^{\frac{3+3w}{2}}
   &= \frac{3 (1+w)}{2} \underbrace{\sqrt{\frac{8\pi G}{3} \rho_{*}}}_{H_{*}} a_{*}^{\frac{3 + 3w}{2}} (t - t_{*})
   \marginnote{Since \(k=0\) we have \(H_{*}^2 = \frac{8 \pi G}{3} \rho_{*}\)}
   \\
  a^{\frac{3 +3w}{2}} &= a_{*}^{\frac{3 + 3w}{2}} \qty(1 + \frac{3}{2} (1+w) H_{*} \qty(t - t_{*}))
   \\
  a(t)&= a_{*} \qty(
    1 + \frac{3}{2} (1+w) H_{*} (t - t_{*})
  )^{\frac{2}{3(1+w)}}
\,,
\end{align}
%
which we can couple to the equation for the evolution of the density, by plugging this expression for the scale factor directly into \eqref{eq:friedmann-3-later}:
%
\begin{equation}
\rho(t) = \rho_{*} \qty(1 + \frac{3}{2}(1+w) H_* (t-t_*))^{-2}
\,,
\end{equation}
%
and also the Hubble parameter \(H \propto \sqrt{\rho }\):
%
\begin{align}
H(t) = H_{*} \qty(1 + \frac{3}{2}(1+w) H_{*}(t-t_{*}))^{-1}
\,.
\end{align}

There is a time where the bracket in \(a(t)\) is zero, which means \(a = 0 \): this moment is commonly known as the ``Big Bang', so we call it \(t_{\text{BB}}\), defined by
\begin{equation}
1 + \frac{3}{2} (1+w) H_{*} (t_{\text{BB}} - t_* ) = 0
\,.
\end{equation}

Since the curvature scalar is \(R \propto H^2 \propto \rho \),\footnote{This can be shown by a simple argument: we take the trace of the EFE, to get
%
\begin{align}
g^{\mu \nu } \qty(R_{\mu \nu } - \frac{1}{2} R g_{\mu \nu })
= 8 \pi G g^{\mu \nu } T_{\mu \nu }
\implies -R = 8 \pi G T
\,,
\end{align}
%
where \(R= g^{\mu \nu } R_{\mu \nu }\) and \(T=g^{ \mu \nu } T_{\mu \nu }\) are the traces of the Ricci tensor and of the stress-energy tensor.
We've shown that \(R \propto T\): so, since \(T \propto \rho \), we have \(R \propto \rho \), but if we also assume that there is no spatial curvature then \(H^2 \propto \rho \), therefore \(R \propto H^2\).}
at \(t_{\text{BB}}\)  the curvature is diverges.

This time can be expressed by inverting the equation:
%
\begin{align}
t _{\text{BB}} = t_{*} - \frac{2}{3 (1+w)H_{*}}
\,.
\end{align}

Hakwing \& Ellis proved that if \(w>-1/3\) we unavoidably must have a Big Bang.

We can define a new time variable by
%
\begin{align}
t_{\text{new}} \equiv t-t _{\text{BB}} =  (t - t_{*})
% + 2 H_*^{-1} / (3 (1+w))
+ \frac{2}{3 H_{*} (1+w)}
\,.
\end{align}

Using this new variable the \(t_{*}\) simplifies, and we can just write:
\begin{equation}
a \propto t_{\text{new}}\,^{\frac{2}{3(1+w)}}
\,.
\end{equation}

Inserting this new time variable (which we will just call \(t\)), we get that the Hubble parameter is:
\begin{align}
H(t) &= \frac{1}{a} \dv{a}{t} = \frac{2}{3(1+w)} t^{\frac{2}{3(1+w)}-1} t^{- \frac{2}{3(1+w)}} \\
H(t) &=  \frac{2}{3(1+w) t} \label{eq:einstein-de-sitter-age}
\,,
\end{align}
so we can compute the density:
\begin{align}
\rho(t) &= \frac{3H^2}{8 \pi G} = \frac{3}{8 \pi G} \frac{4}{9 (1+w)^2 t^2} \\
&= \frac{1}{6 (1+w)^2 \pi G t^2}
\,.
\end{align}
% \todo[inline]{Show this explicitly.}
% Some cases are:
% \begin{equation}
%   \begin{cases}
%       w = 0 \implies a \propto t^{2/3}  \\
%       w=1/3 \implies a \propto t^{1/2} \\
%       w=1 \implies a \propto t^{1/3}
%   \end{cases}
% \end{equation}

Let us now revisit the cases from before:
\begin{enumerate}
  \item \(w=0\) is nonrelativistic matter: it has \(a \propto t^{2/3}\), \(\rho = 1 / (6 \pi G t^2)\) and \(H = 2/ (3t)\).

  This yields a prediction for the age of the universe of \(t \approx \SI{9.6}{Gyr}\) (using the Planck data \cite{adePlanck2015Results2016}): this is not correct, since the actual value is more like \(t \approx \SI{13.8}{Gyr}\), but it has the right order of magnitude; the discrepancy is due to the fact that the assumption of the universe being dominated by nonrelativistic matter is wrong.
  \item \(w=1/3\) is radiation: it has \(a \propto t^{1/2}\), \(\rho = 3/ (32 \pi G t^2)\) and \(H = 1/ (2t)\);
  \item \(w=-1\) is dark energy: as we mentioned before, this is the case which must be treated separately. The integral yields:
  %
  \begin{align}
  \log \qty(\frac{a}{a_{*}}) = A (t-t_{*})
  \,,
  \end{align}
  %
  which means
  %
  \begin{align}
  a (t) = a_{*} \exp(H_{*} a_{*}^{\frac{3 (1+w)}{2}} (t - t_{*}))
  \,,
  \end{align}
  %
  while, as we saw, \(\rho \) and \(P\) (and, therefore, \(H\)) are constant.
\end{enumerate}

% The \emph{De Sitter} universe is one where \(w \rightarrow 1\): \(a(t) \propto \exp(Ht) \) and \(H = \const\). (CHECK)

From the redshift we can trace back the time of emission of the photon: for a matter-dominated universe (\(w=0\)), for example, we have:
%
\begin{align}
1 + z  = \frac{a_0 }{a} =  \qty(\frac{t_0 }{t})^{2/3}
= \qty(\frac{2}{3H_0 t })^{2/3}
\,.
\end{align}

We can calculate the deceleration parameter for this case, to check that it is indeed positive: we need to differentiate the expression
%
\begin{align}
a(t) = a_0 \qty(\frac{3 H_0 t}{2})^{2/3}
\,,
\end{align}
%
and we find
%
\begin{align}
q_0 = - \frac{\ddot{a}_{0} a_0 }{\dot{a}_{0}^2}
=- \frac{t_0^{-4/3} t_0^{2/3}}{(t_0^{-1/3})^2} \times \frac{\frac{2}{3} \qty(-\frac{1}{3})}{\frac{2}{3} \frac{2}{3}} = \frac{1}{2}
\marginnote{The \(a_0 (3H_0 /2)^{2/3}\) terms all simplify.}
\,.
\end{align}

This is a special case of the fact that \cite[eq. 2.2.4b]{colespCosmology2002}
%
\begin{align}
q \equiv q_0 = \frac{1 + 3w}{2}
\,.
\end{align}

\end{document}


% ------------------------------------------------------------
\begin{frame}{Modeling and Interpreting}
\vfill
\begin{center}{%
\begin{picture}(300,120)(-140,-60)
\put(-80,+40){\makebox(0,0){\framebox(80,20){Problem}}}
\put(-80,-40){\makebox(0,0){\framebox(80,20){Logic Program}}}
\put(+80,+40){\makebox(0,0){\framebox(80,20){Solution}}}
\put(+80,-40){\makebox(0,0){\framebox(80,20){Stable Models}}}
\put(-80,+30){\vector(0,-1){60}}
\put(-40,-40){\vector(+1,0){80}}
\put(+80,-30){\vector(0,+1){60}}
\put(-110,  0){\makebox(0,0){\alert<2>{Modeling}}}
\put(+120,  0){\makebox(0,0){\alert<2>{Interpreting}}}
\put(   0,-55){\makebox(0,0){{Solving}}}
\end{picture}}
\end{center}
\end{frame}
%------------------------------------------------------------
\begin{frame}{Problems as Logic Program}

\bigskip{}
For solving a problem class \alert{P} for a problem instance \alert{I},

encode
\begin{enumerate}
\item the problem instance \alert{I} as a set \alert{C(I)} of facts
 and
\item the problem class    \alert{P} as a set \alert{C(P)} of rules
\end{enumerate}
such that the solutions to \alert{P} for \alert{I} can be (polynomially) extracted

from the stable models of \alert{C(I)}${}\cup{}$\alert{C(P)}.

\pause
\bigskip
\begin{block}{Uniform encoding}
A \alert{uniform} encoding \alert{C(P)} is a first-order logic program,

encoding the solutions to \alert{P} for any set \alert{C(I)} of facts.
\end{block}
\end{frame}
%------------------------------------------------------------
\subsection{Graph Coloring}
%------------------------------------------------------------
\begin{frame}{$N$-Colorability\\
  \normalsize Problem \alert{Instance} \onslide<3->{as \alert<3->{Facts}}}

%  \bigskip{}
  \begin{block}{\textbf{Given:} a (directed) \alert{graph $G$}}
%  \pause%
%  \begin{tabular}{l@{~}l}
\alt<1-2>{%
%\vspace*{-5mm}
  \begin{minipage}[t]{0.5\linewidth}
  \vspace*{1mm}
  \(
  G =
  \left(\begin{array}{@{}r@{}l@{}}
   V = \{&1,2,3,4,5,6\},
  {} \\[1mm]
   E = \{&(1,2),(1,3),(1,4),
  {} \\
         &(2,4),(2,5),(2,6),
  {} \\
         &(3,1),(3,4),(3,5),
  {} \\
         &(4,1),(4,2),
  {} \\
         &(5,3),(5,4),(5,6),
  {} \\
         &(6,2),(6,3),(6,5)\}
  \end{array}
  \right)
  \)
%\vspace*{10mm}
  \end{minipage}
}{%
\onslide<4->{%
%\vspace*{-22mm}
  \begin{minipage}[t]{0.5\linewidth}
  \vspace*{1mm}
  \begin{semiverbatim}
  \alert{node}(1). \ \alert{node}(2). \ \alert{node}(3).
  \alert{node}(4). \ \alert{node}(5). \ \alert{node}(6).
  \end{semiverbatim}

  \small
  \begin{semiverbatim}
  \alert{edge}(1,2). \alert{edge}(1,3). \alert{edge}(1,4).
  \alert{edge}(2,4). \alert{edge}(2,5). \alert{edge}(2,6).
  \alert{edge}(3,1). \alert{edge}(3,4). \alert{edge}(3,5).
  \alert{edge}(4,1). \alert{edge}(4,2).
  \alert{edge}(5,3). \alert{edge}(5,4). \alert{edge}(5,6).
  \alert{edge}(6,2). \alert{edge}(6,3). \alert{edge}(6,5).
  \end{semiverbatim}
%\vspace*{4mm}
  \end{minipage}
}}
%  & \pause%
  \onslide<2->{%
  \begin{minipage}[t]{0.45\linewidth}
  \input{Figures/graph}
  \end{minipage}}
%  \end{tabular}
  \end{block}

  % \begin{description}
  % \item[Problem instance] \ \\ A graph $(V,E)$.
  % \item[Problem class] \ \\ Assign each vertex in $V$ one of $n$ colors such that no
  %   two vertexes in $V$ connected by an edge in $E$ have the same color.
  % \end{description}
\end{frame}
%------------------------------------------------------------
\begin{frame}{$N$-Colorability\\
              \normalsize \onslide<7->{\alert<8>{(Extended)}} Problem \alert{Encoding}}
\begin{minipage}[t]{0.47\linewidth}
\begin{block}{Natural Language}
  \begin{enumerate}
  \item \alert<1-2,7-8>{Each node has
        a} \alert<1,3,7-8>{unique} \alert<1-2,7-8>{color}.
  \item[]
  \item[]
%  \item[]
\vspace{4mm}
  \item<4-> \alert<4>{Any two connected nodes must not have
                  the same color.}
%  \item[]
  \item<5-> \alert<5>{Let there be three colors.}
\vspace{3mm}
  \item<6-> \alert<6>{A solution is a coloring.}
  \end{enumerate}
\end{block}
\end{minipage}
\begin{minipage}[t]{0.47\linewidth}
\begin{block}{Logical Language}
  \begin{enumerate}
  \item<2->\small
\alt<1-7>{%
\begin{semiverbatim}
\alert<2,7>{color(X,C) :-} \alert<7>{iscol(C),} \alert<2,7>{node(X), not other(X,C).}
\end{semiverbatim}
\onslide<3-7>{%
\begin{semiverbatim}
\alert<3,7>{other(X,C) :-} \alert<7>{iscol(C),} \alert<3,7>{color(X,D), D != C.}
\end{semiverbatim}}}
{%
\onslide<8->{%
\begin{semiverbatim}
\alert<8>{1 \#count\{\ color(X,C) :

          \ \ \ \ \ \ \ \ \ \ \ \ iscol(C) \}\ 1

          \ \ \ \ \ \ \ \ :- node(X).}
\end{semiverbatim}}
\begin{semiverbatim}

\end{semiverbatim}}
\vspace{-1mm}
  \item<4->\small
\begin{semiverbatim}
\alert<4>{:- color(X,C), color(Y,C),}
\alert<4>{\ \ \ edge(X,Y).}
\end{semiverbatim}
\vspace{1mm}
% \item[]
  \item<5->\small
\begin{semiverbatim}
\#const \alert<5>{n=3}.

\alert<5>{iscol(1..n).}
\end{semiverbatim}
  \item<6->\small
\begin{semiverbatim}
\alert<6>{\#show color/2.}
\end{semiverbatim}
  \end{enumerate}
\end{block}
\end{minipage}
\end{frame}
%------------------------------------------------------------
\begin{frame}{$N$-Colorability\\
              \normalsize Recapitulation I\phantom{I}}
\begin{block}{Instance as Facts (in \attach{Examples/graph.lp}{\lstinline{graph.lp}})}
% \scriptsize
\lstinputlisting{Examples/graph.lp}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}{$N$-Colorability\\
              \normalsize Recapitulation II}
\begin{block}{Uniform Encoding (in \attach{Examples/color.lp}{\lstinline{color.lp}})}
\lstinputlisting{Examples/color.lp}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{$N$-Colorability\\
              \normalsize Let's \alert{Run} it!}
\begin{block}{\alert<1>{\lstinline{gringo} \attach{Examples/graph.lp}{\lstinline{graph.lp}} \attach{Examples/color.lp}{\lstinline{color.lp}} \lstinline{| clasp 0}}}
\vspace*{-4mm}
\pause\footnotesize%
\begin{semiverbatim}
clasp version 2.0.2
Reading from stdin
Solving...
Answer: 1
color(6,2) color(5,3) color(4,2) color(3,1) color(2,1) color(1,3)
Answer: 2
color(6,1) color(5,3) color(4,1) color(3,2) color(2,2) color(1,3)
Answer: 3
color(6,3) color(5,2) color(4,3) color(3,1) color(2,1) color(1,2)
Answer: 4
color(6,1) color(5,2) color(4,1) color(3,3) color(2,3) color(1,2)
Answer: 5
color(6,3) color(5,1) color(4,3) color(3,2) color(2,2) color(1,1)
Answer: 6
color(6,2) color(5,1) color(4,2) color(3,3) color(2,3) color(1,1)
\end{semiverbatim}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{$N$-Colorability\\
              \normalsize Let's \alert{Interpret} it!}
\begin{block}{{\textbf{Found:} $3$-coloring(s)}}
\begin{minipage}[t]{0.48\linewidth}
\begin{semiverbatim}
Answer: 1

\alert<2>{color(1,3) color(5,3)}

\alert<3>{color(2,1) color(3,1)}

\alert<4>{color(4,2) color(6,2)}
\end{semiverbatim}
\end{minipage}
\begin{minipage}[t]{0.45\linewidth}
\input{figures/color}
\end{minipage}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{Interlude: Stable Model(s) Computation}
\begin{center}
\begin{picture}(300,85)(-115,-40)
%\unitlength0.85pt
\thicklines
% \put(-90,+40){\makebox(0,0){\framebox(80,20){Problem}}}
% \put(-90,-40){\makebox(0,0){\framebox(80,20){Logic Program}}}
% \put(+90,+40){\makebox(0,0){\framebox(80,20){Solution}}}
% \put(+90,-40){\makebox(0,0){\framebox(80,20){stable model(s)}}}
% \put(-90,+30){\vector(0,-1){59.5}}
\put(-80,22.5){\makebox(0,0){\framebox(80,30){\begin{tabular}{c}Problem\\Instance\end{tabular}}}}
\put(-80,-102.5){\makebox(0,0){\framebox(80,30){\begin{tabular}{c}Problem\\Encoding\end{tabular}}}}
\put(-80,-40){\oval(50,20)}\put(-102,-44){Grounder}
\put(57.5,-40){\makebox(0,0){\framebox(80,30){\begin{tabular}{c}Propositional\\Logic Program\end{tabular}}}}
\put(155,-40){\oval(50,20)}\put(141,-44){Solver}
\put(155,17.5){\makebox(0,0){\framebox(80,20){Stable Models}}}
\put(+155,-30){\vector(0,+1){37}}
\put(-54.75,-40){\vector(+1,0){72}}
\put(98,-40){\vector(+1,0){32}}
\put(-80,-87.5){\vector(0,+1){37}}
\put(-80,7){\vector(0,-1){37}}
\put(-25,-30){\makebox(0,0){\alert<2>{Grounding}}}
\put(133,-12){\makebox(0,0){\alert<2>{Solving}}}
% \put(+130,  0){\makebox(0,0){{Interpreting}}}
% \put(   0,-52){\makebox(0,0){{Solving}}}
\end{picture}
\end{center}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{$N$-Colorability\\
              \normalsize Grounding}
\begin{block}{\alert<1>{\lstinline{gringo} -t \attach{Examples/graph.lp}{\lstinline{graph.lp}} \attach{Examples/color.lp}{\lstinline{color.lp}}}}
\vspace*{-4mm}
\pause\footnotesize%
\begin{semiverbatim}
node(1). \ \ node(2). \ \ node(3). \ \ node(4). \ \ node(5). \ \ node(6).
edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). \dots

iscol(1). \ iscol(2). \ iscol(3).

1 \#count\{ color(1,1), color(1,2), color(1,3) \} 1.
1 \#count\{ color(2,1), color(2,2), color(2,3) \} 1.
1 \#count\{ color(3,1), color(3,2), color(3,3) \} 1.
1 \#count\{ color(4,1), color(4,2), color(4,3) \} 1.
1 \#count\{ color(5,1), color(5,2), color(5,3) \} 1.
1 \#count\{ color(6,1), color(6,2), color(6,3) \} 1.

:- color(1,1), color(2,1).
:- color(1,2), color(2,2).
:- color(1,3), color(2,3). \dots
\end{semiverbatim}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{$N$-Colorability\\
              \normalsize Solving}
\begin{block}{\alert<1>{\lstinline{gringo} \attach{Examples/graph.lp}{\lstinline{graph.lp}} \attach{Examples/color.lp}{\lstinline{color.lp}} \lstinline{| clasp --stats 0}}}
\vspace*{-4mm}
\pause\scriptsize%
\begin{semiverbatim}
\dots{}
\alert<3>{Models      : 6}
\alert<3>{Time        : 0.001s} (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time    : 0.000s
\alert<3>{Choices     : 5}
\alert<3>{Conflicts   : 0}
\alert<3>{Restarts    : 0}

Atoms       : 63
Rules       : 113    (1: 95 2: 12 3: 6)
Bodies      : 64
Equivalences: 106    (Atom=Atom: 31 Body=Body: 6 Other: 69)
\alert<3>{Tight       : Yes}

\alert<3>{Variables   : 63}     (Eliminated: 0 Frozen: \ \ 30)
\alert<3>{Constraints : 45}     (Binary: 73.3% Ternary:  0.0% Other: 26.7%)
Lemmas      : 0      (Binary:  0.0% Ternary:  0.0% Other:  0.0%)
\end{semiverbatim}\pause
\end{block}
\end{frame}
%------------------------------------------------------------
\subsection{Hamiltonian Cycle}
%------------------------------------------------------------
\begin{frame}{Hamiltonian Cycle\\
  \normalsize Problem Instance as Facts}

  \begin{block}{\textbf{Recall:} a directed graph $G$}
  \begin{minipage}[t]{0.5\linewidth}
  \vspace*{1mm}
  \begin{semiverbatim}
  node(1). \ node(2). \ node(3).
  node(4). \ node(5). \ node(6).
  \end{semiverbatim}

  \small
  \begin{semiverbatim}
  edge(1,2). edge(1,3). edge(1,4).
  edge(2,4). edge(2,5). edge(2,6).
  edge(3,1). edge(3,4). edge(3,5).
  edge(4,1). edge(4,2).
  edge(5,3). edge(5,4). edge(5,6).
  edge(6,2). edge(6,3). edge(6,5).
  \end{semiverbatim}
  \end{minipage}
  \small{\,}
  \begin{minipage}[t]{0.45\linewidth}
  \input{Figures/graph}
  \end{minipage}
  \end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}{Hamiltonian Cycle\\
  \normalsize Engineering an Encoding}
  \begin{block}{Problem Specification}
  A (directed) graph $G=(V,E)$ is Hamiltonian if it contains

  \alert<1>{a cycle~$C$ that visits every node of~$V$ exactly once}.
%  such that
  % \begin{enumerate}
  % \item a permutation $(v_1,\dots,v_i,v_{i+1},\dots,v_n)$ of $V$ such that
  % \item $\{(v_1,v_2),\dots,(v_i,v_{i+1}),\dots,(v_n,v_1)\}\subseteq E$.
  % \end{enumerate}
  \end{block}
\pause
  \begin{itemize}
  \item[\ithand] $C$ traverses \alert<3-4>{exactly} \alert<3>{one incoming} and \alert<4>{one outgoing} \alert<3-4>{edge per node}.
  \item[\ithand] $C$ \alert<5>{traverses} \alert<8>{every node} of~$V$ (\alert<7>{starting from an arbitrary node} in $V$).
  \end{itemize}
\pause
  \begin{block}{Problem Encoding}
  \begin{semiverbatim}
  \alt<1-4>{%
  \onslide<3-4>{\alert<3>{1 \#count\{\ cycle(X,Y) : edge(X,Y) \}\ 1 :- node(Y).}}

  \onslide<4>{\alert<4>{1 \#count\{\ cycle(X,Y) : edge(X,Y) \}\ 1 :- node(X).}}
}{%
  \only<5->{\alert<5>{reach(X) :- first(X).}}

  \only<5->{\alert<5>{\alert<6>{reach(Y)} :- \alert<6>{reach(X)}, cycle(X,Y).}}
}
  \end{semiverbatim}
\only<6>{%
\vspace{-2mm}
  \begin{itemize}
  \item[\ithand] The definition of \lstinline{reach} is \alert{recursive}!
  \end{itemize}
}
  \begin{semiverbatim}
  \alt<1-7>{\only<7>{\alert<7>{first(X) :- X = \#min[ node(Y) = Y ].}}}{%
            \onslide<8->{\alert<8>{:- node(Y), not reach(Y).}}}
  \end{semiverbatim}
  \end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}{Hamiltonian Cycle\\
              \normalsize The Complete Picture}
\begin{block}{Uniform Encoding (in \attach{Examples/cycle.lp}{\lstinline{cycle.lp}})}
\lstinputlisting[basicstyle=\ttfamily\scriptsize]{Examples/cycle.lp}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{Hamiltonian Cycle\\
              \normalsize Let's \alert{Run} it!}
\begin{block}{\alert<1>{\lstinline{gringo} \attach{Examples/graph.lp}{\lstinline{graph.lp}} \attach{Examples/cycle.lp}{\lstinline{cycle.lp}} \lstinline{| clasp --stats}}}
\vspace*{-2mm}
\pause\scriptsize%
\begin{semiverbatim}
Answer: 1
cycle(6,5) cycle(5,3) cycle(4,2) cycle(3,1) cycle(2,6) cycle(1,4)
SATISFIABLE

Models      : 1+
Time        : 0.001s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time    : 0.000s
Choices     : 3
Conflicts   : 0
Restarts    : 0

Atoms       : 84
Rules       : 117    (1: 84 2: 21 3: 12)
Bodies      : 81
Equivalences: 174    (Atom=Atom: 36 Body=Body: 12 Other: 126)
\alert{Tight       : No     (SCCs: 1 Nodes: 20)}
\end{semiverbatim}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{Hamiltonian Cycle\\
              \normalsize Let's \alert{Interpret} it!}
\begin{block}{{\textbf{Found:} Hamiltonian cycle}}
\begin{minipage}[t]{0.48\linewidth}
\begin{semiverbatim}
Answer: 1

\alert<2>{cycle(1,4)}
\alert<3>{cycle(4,2)}
\alert<4>{cycle(2,6)}
\alert<5>{cycle(6,5)}
\alert<6>{cycle(5,3)}
\alert<7>{cycle(3,1)}
\end{semiverbatim}
\end{minipage}
\begin{minipage}[t]{0.45\linewidth}
\input{figures/cycle}
\end{minipage}
\end{block}
\end{frame}
%------------------------------------------------------------
\subsection{Traveling Salesperson}
%------------------------------------------------------------
\begin{frame}{Mr Hamilton as Traveling Salesperson\\
  \normalsize Problem Instance as Facts}
  \begin{block}{\textbf{Given:} a directed graph $G$ \onslide<2->{\alert{plus edge costs}}}
  \begin{minipage}[t]{0.5\linewidth}
  \vspace*{1mm}
\alt<1>{%
  \begin{semiverbatim}
  node(1). \ node(2). \ node(3).
  node(4). \ node(5). \ node(6).
  \end{semiverbatim}

  \small
  \begin{semiverbatim}
  edge(1,2). edge(1,3). edge(1,4).
  edge(2,4). edge(2,5). edge(2,6).
  edge(3,1). edge(3,4). edge(3,5).
  edge(4,1). edge(4,2).
  edge(5,3). edge(5,4). edge(5,6).
  edge(6,2). edge(6,3). edge(6,5).
  \end{semiverbatim}
}{%
  \small
  \begin{semiverbatim}
  \alert{cost}(1,2,2).

  \alert{cost}(1,3,3). \alert{cost}(3,1,3).

  \alert{cost}(1,4,1). \alert{cost}(4,1,1).

  \alert{cost}(2,4,2). \alert{cost}(4,2,2).

  \alert{cost}(2,5,2).

  \alert{cost}(2,6,4). \alert{cost}(6,2,4).

  \alert{cost}(3,4,2).

  \alert{cost}(3,5,2). \alert{cost}(5,3,2).

  \alert{cost}(5,4,2).

  \alert{cost}(5,6,1). \alert{cost}(6,5,1).

  \alert{cost}(6,3,3).
  \end{semiverbatim}
}
  \end{minipage}
  \small{\,}
  \begin{minipage}[t]{0.45\linewidth}
  \input{Figures/costs}
  \end{minipage}
  \end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}{Mr Hamilton as Traveling Salesperson\\
  \normalsize Solution \alert{Optimization}}
  \begin{block}{Optimization Objective}
  A Hamiltonian cycle is optimal if
  its accumulated edge costs are \alert<1>{minimal}.
  \end{block}
  \begin{itemize}
  \item[\ithand] Use \alert<1>{\lstinline{\#minimize}} (and/or \alert<1>{\lstinline{\#maximize}})
                 to associate each stable model with objective value(s).
  \end{itemize}
\pause
  \begin{block}{Optimization Encoding}
  \vspace*{-2mm}
  \begin{semiverbatim}
  \% OPTIMIZE

  \alert<2>{\#minimize}[ \alert<6>{cycle(X,Y)} \alert<5>{: cost(X,Y,C)} \alert<3>{= C}\alert<4>{@1} ].
  \end{semiverbatim}
  \vspace{-2mm}
  \begin{description}
  \item[Target:] \onslide<2->{\alert<2>{minimal sum}}
                 \onslide<3->{\alert<3>{of costs \lstinline{C}}}
                 \onslide<4->{\alert<4>{(at priority level~\lstinline{1})}}
                 \onslide<5->{\alert<5>{associated with}}
                 \onslide<6->{\alert<6>{instances of \lstinline{cycle}
                 in an stable model}}
  \end{description}
  \end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{Mr Hamilton as Traveling Salesperson\\
              \normalsize Let's \alert{Run} it!}
\begin{block}{\alert<1>{\lstinline{gringo} \attach{Examples/graph.lp}{\lstinline{graph.lp}} \attach{Examples/costs.lp}{\lstinline{costs.lp}} \attach{Examples/cycle.lp}{\lstinline{cycle.lp}} \attach{Examples/price.lp}{\lstinline{price.lp}} \lstinline{| clasp --stats 0}}}
\vspace*{-4mm}
\pause\scriptsize%
\begin{semiverbatim}
Answer: 1
cycle(6,5) cycle(5,3) cycle(4,2) cycle(3,1) cycle(2,6) cycle(1,4)
\alert{Optimization: 13}
Answer: 2
cycle(6,5) cycle(5,3) cycle(4,1) cycle(3,4) cycle(2,6) cycle(1,2)
\alert{Optimization: 12}
Answer: 3
cycle(6,3) cycle(5,6) cycle(4,1) cycle(3,4) cycle(2,5) cycle(1,2)
\alert{Optimization: 11}
\alert{OPTIMUM FOUND}

\alert{Models      : 1}
\ \ \alert{Enumerated: 3}
\ \ \alert{Optimum   : yes}
\alert{Optimization: 11}
Time        : 0.004s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time    : 0.000s
\end{semiverbatim}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}[fragile]{Mr Hamilton as Traveling Salesperson\\
              \normalsize Let's \alert{Interpret} it!}
\begin{block}{\textbf{Found:} \onslide<3->{\alert{optimal}} Hamiltonian cycle}
\begin{minipage}[t]{0.48\linewidth}
\begin{semiverbatim}
Answer: \alt<1>{1

cycle(1,4)
cycle(4,2)
cycle(2,6)
cycle(6,5)
cycle(5,3)
cycle(3,1)}{\alt<2>{2

cycle(1,2)
cycle(2,6)
cycle(6,5)
cycle(5,3)
cycle(3,4)
cycle(4,1)}{3

cycle(1,2)
cycle(2,5)
cycle(5,6)
cycle(6,3)
cycle(3,4)
cycle(4,1)}}
\end{semiverbatim}
\end{minipage}
\begin{minipage}[t]{0.45\linewidth}
\input{figures/price}
\end{minipage}
\end{block}
\end{frame}
%------------------------------------------------------------
\begin{frame}{Take-Home Messages}

\bigskip{}
For solving a problem (class) in ASP, provide
\begin{enumerate}
\item<1-9,14> \alert{facts} describing an instance and
\item<1-8,14> a (uniform) \alert{encoding} of solutions.
\end{enumerate}

\bigskip{}
Encodings are often structured by the following logical parts:
\begin{enumerate}
\item<2-9,14> \alert{Domain} information \hfill (by deduction from facts)
\item<3-8,10,14> \alert{Generator} providing solution candidates \hfill (choice rules)
\item<4-8,10,14> \alert{Define} rules analyzing properties of candidates \hfill (normal rules)
\item<5-8,11,14> \alert{Tester} eliminating invalid candidates \hfill (integrity constraints)
\item<6-8,12,14> \alert{Display} statements projecting stable models \hfill (onto characteristic atoms)
\item<7-8,13,14> \alert{Optimizer} evaluating stable models \hfill (\lstinline{\#minimize}/\lstinline{\#maximize})
\end{enumerate}
\onslide<8->{
\begin{block}{In a Nutshell}
\begin{tabular}{rcl}
  Logic Program&$\subseteq$&\alert<9>{(Data + Deduction)} + \alert<10>{(Generation + Analysis)} + \\
               & &\alert<11>{Selection} + \alert<12>{Projection} [+ \alert<13>{Optimization}]
\end{tabular}
\end{block}}
\end{frame}
%%% Local Variables:
%%% mode: latex
%%% TeX-PDF-mode: t
%%% TeX-master: "asp"
%%% End:


\documentclass[12pt]{article}
\usepackage[margin=1.0in]{geometry}

\usepackage{indentfirst}
\usepackage{graphicx}
\usepackage{ amssymb }
\usepackage{listings}
\usepackage[toc,page]{appendix}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{subcaption}
\usepackage{mwe}
\renewcommand{\thesubsection}{\thesection.\alph{subsection}}

\usepackage{wasysym}
\usepackage{ marvosym }
\usepackage{amsmath}

\title{CTA200: Tidal Evolution of the Earth-Moon System}
\author{Jessica Patel}
\date{Friday, May 14th, 2021}

\begin{document}

\maketitle

\section{Introduction}
Ocean tides on Earth are caused by the gravitational attraction of the Moon and the Sun. The gravitational forces act on the tidal bulge in Earth's oceans and the solid body of the Earth, producing tidal torque. The lunar tidal torque decreases the spin angular momentum of the Earth, $S_{\oplus}$, and increases the orbital angular momentum of the Moon, $L_{\leftmoon}$. This increases the length of day, and decreases the length of the lunar month. Due to the conservation of angular momentum, this gives the relationship for the total angular momentum of the Earth-Moon system given by Equation 1. The solar tidal torque decreases $S_{\oplus}$ as well, but to a lower extent. Considering conservation of angular momentum in the Earth-Moon-Sun system, this new relationship would be given by Equation 2. Since the solar tidal torque decreases $S_\oplus$, then orbital angular momentum of Earth, $L_{\oplus}$, must increase since it slightly decreases $L_{EM}$.
\begin{eqnarray}
L_{EM} = S_{\oplus} + L_{\leftmoon} \\
L_{total} = L_{EM} + L_{\oplus} =  S_{\oplus} + L_{\leftmoon} + L_{\oplus}
\end{eqnarray}
These relationships between the various angular momenta and the tidal torques give rise to the following first-order ordinary differential equations.
\begin{eqnarray}
\frac{dL_{\oplus}}{dt} = T_{\odot} \\
\frac{dS_{\oplus}}{dt} = - T_{\odot} - T_{\leftmoon} \\
\frac{dL_{\leftmoon}}{dt} = T_{\leftmoon}
\end{eqnarray}
The goal of this project is to evaluate how the angular momenta of the Earth and the Moon changed over time, to ultimately solve the problem of determining the Moon's age. This is done by integrating the evolution of the Earth-Moon system from the present-day configuration to the past to determine when the Earth-Moon separation went to zero, and hence, when the Earth and Moon formed.

\section{Procedure and Results}
\subsection{Calculating Parameters}
The python script accomplishes this goal by first calculating the initial, or present day, values for the various angular momenta parameters and the tidal torque parameters. This was done using the following set of equations.

\begin{eqnarray}
L_{\oplus} = M_{\oplus} \sqrt{G(M_{\odot}+M_{\oplus})a_{\oplus}} \\
S_{\oplus} = I\Omega_{\oplus} \\
L_{\leftmoon} = m_{\leftmoon} \sqrt{G(M_{\oplus}+m_{\leftmoon})a_{\leftmoon}} \\
T_{\leftmoon} = \frac{3}{2} \frac{Gm_{\leftmoon}^2}{a_{\leftmoon}} \left(\frac{R_{\oplus}}{a_{\leftmoon}}\right)^5 \frac{k_2}{Q_{\leftmoon}} \\
T_\odot = T_{\leftmoon} \beta = T_{\leftmoon} \frac{1}{4.7} \left(\frac{a_{\leftmoon}}{a_{\leftmoon}(0)} \right)^6
\end{eqnarray}
Next, the timescales associated with equations (3), (4) and (5) were calculated by considering a timescale $\tau$ instead of the infinitesimal time step $dt$. These calculated values are given in Table 1.

\begin{table}[h]
\centering
\begin{tabular}{l|lcr}
\textbf{Parameter} & \textbf{Calculated Value}\\
\hline
L_{\oplus}(0)& 2.6483 \times 10^{47} \ \text{g cm2/s} \\
\hline
S_{\oplus}(0)& 5.8294 \times 10^{40} \ \text{g cm2/s}\\
\hline
L_{\leftmoon}(0) & 2.9082 \times 10^{41} \ \text{g cm2/s} \\
\hline
T_{\leftmoon} & 4.2745 \times 10^{23} \ \text{dynes}\\
\hline
T_{\oplus} & 9.0946 \times 10^{22} \ \text{dynes}\\
\hline
\tau_{L_{\oplus}}}& 9.2336 \times 10^{16} \ \text{years}\\
\hline
\tau_{S_{\oplus}}} & 3.5658 \times 10^{9} \ \text{years}\\
\hline
\tau_{L_{\leftmoon}}}& 2.1574 \times 10^{10} \ \text{years} \\
\hline
\end{tabular}

\caption{Calculated values rounded to 4 decimal places. Exact values are given in the code.}
\end{table}

\subsection{Integrating differential equations}
To integrate equations (3), (4) and (5), a function was first created to return the right hand sides of each equation. This was done by writing the tidal torques in terms of $a_\leftmoon$, and by solving for $a_\leftmoon$ using equation (8).

Then, the $\texttt{scipy.integrate.solve\_ivp()}$ function was used to solve the differential equations. The initial values for the angular momenta were inputted, and $1 \times 10^{7}$ samples of time were used since this amount allowed for the maximum amount of information to be collected within the capabilities of the computer processor.

The solutions for the angular momenta parameters were then plotted, as shown in Figures 1 (a) and (b). It can be seen that Earth's orbital angular momentum stays mostly constant since it only shows variation on a very small scale. From Figure 2 (b), it can be observed that curves have the same rates of change, but opposite signs. They also start off with rapid rates of change and then start to flatten over time. This is expected since the Earth and Moon exchange angular momentum, which is mostly conserved.

\begin{figure*}[h]
        \centering
        \begin{subfigure}[b]{0.47\textwidth}
            \centering
            \includegraphics[width=\textwidth]{LE.pdf}
            \caption[]%
            {{\small }}
            \label{fig:mean and std of net14}
        \end{subfigure}
        \begin{subfigure}[b]{0.48\textwidth}
            \centering
            \includegraphics[width=\textwidth]{SE_LM.pdf}
            \caption[]%
            {{\small }}
        \end{subfigure}
        \caption[]%
        {\small (a) Earth's orbital angular momentum plotted within small vertical limits to show limited change. (b) Earth's spin angular momentum with Moon's orbital angular momentum plotted over each other to show the dependent behaviour and conservation (mostly).}
    \end{figure*}

After, it was investigated whether these solutions follow the conservation of angular momentum. The error within the total angular momentum of the Earth-Moon-Sun system was first calculated by adding all three angular momenta, and subtracting this total for a given time by the total in the present day, and dividing that by the total for a given time. This returned an array of the form $\texttt{[0.0000e+00 ...  7.8119e-15]}$, showing that the error is quite minimal and close to the size of the relative and absolute error tolerances.

Furthermore, for the Earth-Moon system, it is not expected for the total angular momentum to be conserved due to the interference of the Sun's gravitational attraction, and thus the fractional change was calculated in the same manner as before, but only taking the sum of $S_{\oplus}$ and $L_{\leftmoon}$. This returned an array of the form $\texttt{[0.0000e+00 ... 1.3450e-02]}$, showing that the fractional change is minimal but cannot be neglected.

$\ $

$\ $

\subsection{Using solutions to evaluate other parameters}
Using the solutions of the angular momenta, the lunar semi-major axis was solved for using equation (8) again and was plotted over time, as shown in Figure 2 (a). The length of an Earth day over time was also found using equation (7) to solve for $\Omega_{\oplus}$ and using the relation $\Omega_\oplus = 2 \pi / lod $ to solve for the length of day, $lod$. This was also plotted, as shown in Figure 2 (b). It can be seen that both graphs display asymptotic behaviour near $\sim -1.6 \ \text{My}$ and the rate of change decreases as both curves reach higher age values. The lunar semi-major axis starts to flatten while the length of Earth days appears to approach linear growth.

\begin{figure*}[h]
        \centering
        \begin{subfigure}[b]{0.47\textwidth}
            \centering
            \includegraphics[width=\textwidth]{a_m.pdf}
            \caption[]%
            {{\small }}
            \label{fig:mean and std of net14}
        \end{subfigure}
        \begin{subfigure}[b]{0.48\textwidth}
            \centering
            \includegraphics[width=\textwidth]{lod.pdf}
            \caption[]%
            {{\small }}
        \end{subfigure}
        \caption[]%
        {\small (a) Lunar semi-major axis in kilometers with a marker for the Roche radius aligned with the asymptotic behaviour of the curve. (b) Length of Earth day going back in time.}
    \end{figure*}

Figure 2 (a) also shows a marker for the Earth-Moon Roche radius of $6378.1370 \ \text{km}$, since it is believed that the Moon formed at this distance. The curve stops before the Roche radius since a larger amount of samples could not be taken. Furthermore, since the Roche radius is relative to the center of the Earth while the semi-major axis is relative to the barycenter of the system, the Roche radius is quite small since the distance between the barycenter and center of the Earth of $4670 \ \text{km}$ must be subtracted. Considering that the curve follows asymptotic behaviour, it can be assumed that the Moon was at the Roche radius at a time slightly earlier than this model provides. This suggests that, even though Figure 2 (b) suggests that the length of an Earth day was about $5 \ \text{hours}$, it must have been even shorter.

Since this tidal model results in curves that stop or become asymptotic at an age of $-1.6615 \ \text{gigayears}$, this suggests that the Moon is $1.6615 \ \text{gigayears}$ old. This value is of a similar degree as the timescales calculated earlier.

\section{Analysis}
The goal of determining when the Moon formed was accomplished. The main results are that the Earth's orbital angular momentum stays mostly constant, that the Earth's spin angular momentum and the Moon's orbital angular momentum show the same behaviour but with opposite signs since they are mostly conserved, and that the semi-major axis and the length of Earth days are both increasing.

Considering that the theoretical values of the ages of the Earth and Moon are $4.543 \ \text{Gigayears}$ and $4.425 \ \text{Gigayears}$ respectively, it is clear that the this model significantly underestimates the ages and does not account for the difference in ages between the two astronomical bodies.

This underestimation is likely caused by the fact that this model does not account for tidally induced energy dissipation that occurs due to the friction created in the interior of Earth and in the oceans from the orbital and rotational energy. This reduces the spin orbital angular momentum of Earth, and thus increases the orbital angular momentum of the Moon. This leads to a larger semi-major axis, and thus an older age of the Moon since it takes the Moon a longer time to reach the Roche radius.
\end{document}


%!TEX root = ../main.tex
\documentclass[../main.tex]{subfiles}
\begin{document}

\section{A Model of Continuous Task Choice} \label{sec:tractable-model-of-cont-task-choice}
This section presents a model of continuous task choice which can be employed to analyze changes in task specific skill prices. In this framework, workers maximize utility by allocating  their working time between tasks. In doing so, workers are facing a trade-off between realized wages that are determined through their choice and associated amenities which depend on the workers preferences regarding their choice of tasks. This trade-off is reflected in a utility function defined as a composition of two parts: a pecuniary part, particularly realized wages, and a non-pecuniary part, i.e. the amenities associated with the executed tasks. The model I develop is related to the one presented in Böhm (\citeyear{bohm2019price}), where workers maximize their utility by choosing the task that offers the highest sum of pecuniary and non-pecuniary rewards. However, I deviate from this approach with discrete task choice in that I allow a continuous combination of tasks.
\\
As a starting point, I first introduce the utility maximization problem each worker faces in section \ref{sec:utility-max-problem}. In general, workers experience positive utility from wages which is accompanied by a dislike towards strong specialization in executed tasks as well as deviations from their preferred choice of tasks. In section \ref{sec:implications-with-j=2}, I present the solution of this choice problem by means of a two task version of this model. Subsequently, I derive the identification of changes in relative skill prices, based on the two task version of the model in section \ref{sec:identifying-changes-in-skill-prices}. Section \ref{sec:model_estimation} discusses how in an empirical application this identification strategy can be employed to estimate such changes in skill prices.

\subsection{The Utility Maximization Problem} \label{sec:utility-max-problem}
A worker's realized wage is modeled as a function of the task-specific wages that would be obtained if a worker spent her entire work-time on one particular task (\textit{potential wages}), and the fraction of work-time that she spends on each task, i.e. her \textit{task choice}.
\\
The amenity valuation associated with each task choice is determined by, first, an exogenous preference for a certain allocation of working time to tasks. In particular, agents experience negative utility from deviations from their preferred allocation. Second, amenities are modeled to capture a general dislike towards strong task-specialization. Notice that both these properties translate into non positive utility. With this conceptualization of the amenities at hand, it appears to be more intuitive to think of this non-pecuniary part of the utility function in terms of a penalty. Therefore, I will use the notion \textit{penalty term} in the further course of this thesis.
\\
Since the objective of this analysis is an investigation of relative quantities, I use a notation in logarithmic values when describing my model. Above described properties are translated into a task choice model as follows. In each period $t \in \{0, ..., T\}$, all agents $i \in \{1, ..., N\}$ individually maximize their utility $u_{i,t}$ by choosing the fractions of their working time spent on each of $J$ tasks. These task choices are captured in $\lambda_{i,j,t}, \; \text{with} \; 0 \leq \lambda_{i,j,t} \leq 1, \; \text{and} \;j \in \{1, ..., J\}, \; \text{s.t.} \; \sum^J_{j=1} \lambda_{i,j,t} = 1$. This approach allows to represent occupations as continuous compositions of tasks.
\\
Realized wages of a worker result as the sum of potential task specific wages weighted by task choices. This definition of realized wage is captured in equation (\ref{eq:real_wage}), where $\boldsymbol{\lambda}_{i,t}$ and $\boldsymbol{w}_{i,t}$ denote vectors of length $J$ that contain the chosen work time fraction and the potential wage for each task, respectively. Alternatively, realized wages can be thought of as a linear combination of potential wages.
\begin{equation}\label{eq:real_wage}
	w(\boldsymbol{\lambda}_{i,t}, \boldsymbol{w}_{i,t}) = \sum^J_{j=1} \lambda_{i,j,t} w_{i,j,t}
\end{equation}
Following above description of negative amenities associated with task choices, the penalty term is defined as a function of task choices and preferred time allocations. Furthermore, this penalty incorporates the assumed dislike towards specialization. These properties are captured by the function presented in equation (\ref{eq:penalty}).
\begin{equation}\label{eq:penalty}
	\rho(\boldsymbol{b}_i, \boldsymbol{\lambda}_{i,t}, \phi, \theta) = \theta \sum^J_{j=1} |b_{i,j} - \lambda_{i,j,t}|^\phi
\end{equation}
In this functional form of the penalty term, $\boldsymbol{b}_{i,j}$ denotes a vector of length $J$ that captures the individually preferred time allocation on tasks, with $0 \leq b_{i,j} \leq 1 \;  \forall \; j \in \{1, ..., J\}$. This preference is assumed to be time invariant. From equation (\ref{eq:penalty}) one can see that the penalty is minimized at a value of zero by setting task choices exactly equal to the preferred allocation, i.e., $\lambda_{i,j,t} = b_{i,j} \; \forall \; j \in \{1, ..., J\}$. Ceteris paribus, increasing the difference between a worker's preferred time allocation and her respective task choice is associated with an increase of the penalty, hence decreasing utility.
\\
Parameter $\theta \in \mathbb{R}_+$ works as a scaling factor, allowing to adjust relative relevance of the amenity and wage terms for the utility function. This weighting parameter is limited to positive values since switching signs of this function results in a loss of its previously described desired properties. All else equal, an increase in penalty weight $\theta$ entails higher penalties from a deviation from the preferred time allocation. As seen from the absence of subscripts, $\theta$ is modeled to be constant across individuals and time.
\\
Finally, the penalty term's exponent $\phi$ determines the dislike towards strong task specializations. Since the base of this exponent by construction is between zero and one (i.e., $|b_{i,j} - \lambda_{i,j,t}| \in [0,1]$), a larger exponent $\phi$, ceteris paribus, decreases penalties from deviations. $\phi$ is required to be weakly positive in order to ensure continuity of the first order condition of the resulting maximization problem (see section \ref{sec:implications-with-j=2} below). Similar to the penalty weight parameter, $\phi$ is assumed to be time invariant and identical across individuals as well as tasks.
\\
Equation (\ref{eq:utility}) below presents both components, realized wage and penalty term, combined to the utility function. Overall, the functional form of the penalty term is modeled to be time invariant, which will be important for the estimation strategy of changes in task prices in section \ref{sec:model_estimation}.
\begin{align}\label{eq:utility}
	u_{i,t} &= w(\boldsymbol{\lambda}_{i,t}, \boldsymbol{w}_{i,t}) - \rho(\boldsymbol{b}_i, \boldsymbol{\lambda}_{i,t}, \phi, \theta)  \\
	{}		&= \sum^J_{j=1} \lambda_{i,j,t} w_{i,j,t} - \theta \sum^J_{j=1} |b_{i,j} - \lambda_{i,j,t}|^\phi \nonumber
\end{align}
Each worker is assumed to act utility maximizing by setting task choices. Solving this optimization problem provides optimal task choices $\boldsymbol{\lambda}^*_{i, t}$, which are defined as follows.
\begin{equation} \label{eq:optimization_problem}
	\boldsymbol{\lambda}^*_{i, t} \equiv \argmax_{\boldsymbol{\lambda}_{i, t}} u_{i,t}(\boldsymbol{b}_i, \boldsymbol{\lambda}_{i, t}, \phi, \theta) = \argmax_{\boldsymbol{\lambda}_{i, t}} w(\boldsymbol{\lambda}_{i,t}, \boldsymbol{w}_{i,t}) - \rho(\boldsymbol{b}_i, \boldsymbol{\lambda}_{i,t}, \phi, \theta).
\end{equation}

\subsection{Implications in a Model with J=2 Tasks} \label{sec:implications-with-j=2}
Up to this point the model introduced in this thesis captures the general setting of a continuous choice between $J$ tasks. With the complexity of occupations in the real world in mind, a subdivision of each occupation into a multitude of tasks would be conceivable. The desired number of dimensions of this decomposition depends on the specific context of the model and can be specified accordingly. In this subsection, I consider a very tractable version of this model with $J=2$ tasks. This facilitates solving the model and results in accessible interpretations. The insights gained from this specification, however, are transferable to a higher dimensional task differentiation.
\\
A distinction between $J=2$ tasks could, for instance, be used to analyze a setting similar to the one presented in Yamaguchi (\citeyear{yamaguchi2018changes}) who distinguishes between "cognitive" and manual (specifically, "motor") tasks. Similarly, Beaudry et al. (\citeyear{beaudry2016great}) build their arguments on a model that considers two distinct tasks: "cognitive" and "routine".
\\
A specification of the model with $J=2$ tasks allows to restate the utility function in equation (\ref{eq:utility}) in a more concise way, using that both, $\lambda_{i,j,t}$ and $b_{i,j}$ sum to one over all tasks. Furthermore, I normalize potential task specific wages, so that $w_{i,j=1,t} = 0$  in every period $t \in \{1, ..., T\}$. In this setting, potential wages in task two yield a quantity that is relative to the potential wage in task one. This does not impact the model's informative value regarding the relative task specific wages and will facilitate the identification thereof. Consequently, the utility function of a case with $J=2$ tasks results as following expression, the derivation of which can be found in appendix \ref{app:derive_two_task_utility}.
\begin{align}\label{eq:two_task_utility}
	u_{i,t} 		& = \lambda_{i,t} \tilde{w}_{i,t} - 2 \theta |b_i - \lambda_{i,t}|^\phi,  \\
	\text{where} 	& {} \nonumber \\
	\lambda_{i,t} 	& \equiv \lambda_{i,j=2,t}  \nonumber \\
	b_i 			& \equiv b_{i,j=2} \nonumber \\
	\tilde{w}_{i,t} & \equiv w_{i,j=2,t} - w_{i,j=1,t}. \nonumber
\end{align}
Drawing on the utility maximization problem, which is presented in a general version in equation (\ref{eq:optimization_problem}), workers maximize utility by optimally setting choice parameter $\lambda_{i,t}$. Thus, the first order condition presented in equation (\ref{eq:foc}) must be satisfied. This results in the piecewise defined optimal task choice presented in equation (\ref{eq:lmb_opt})\footnote{Note that $\tilde{w}_{i,t} < 0$, if and only if the potential wage in task $2$ is smaller then the potential wage in task $1$. This case is accompanied by a shift in task choices towards task $1$, which will result in $b_i > \lambda_{i,t}$ (this corresponds to the second case in equation (\ref{eq:lmb_opt})).  Analogously, it can be seen that $\tilde{w}_{i,t} > 0 \iff b_i < \lambda_{i,t}$. The exponent in equation (\ref{eq:lmb_opt}), therefore, is by construction always over a weakly positive base and thereby defined for any real number of $\tilde{w}_{i,t}$.}. For a derivation of the first and second order conditions of this optimization problem, see appendix \ref{app:foc_soc_utility}. A detailed derivation of optimal task choices $\lambda_{i,t}^*$ can be found in appendix \ref{app:derive_lmb_opt}.
\begin{equation} \label{eq:foc}
	\frac{\partial u_{i,t}(b_i, \lambda_{i,t}, \phi, \theta)}{\partial \lambda_{i,t}} \overset{!}{=} 0
\end{equation}
\begin{equation} \label{eq:lmb_opt}
	\lambda^*_{i,t} = \left\{
	\begin{array}{ll}
		b_i - (\frac{- \tilde{w}_{i,t}}{2 \phi \theta})^{\frac{1}{\phi -1}}, \: & \: \text{if $b_i \geq \lambda_{i,t}$}\\
		b_i + (\frac{\tilde{w}_{i,t}}{2 \phi \theta})^{\frac{1}{\phi - 1}}, \: & \: \text{if $b_i < \lambda_{i,t}$}
	\end{array}
\right.
\end{equation}
From this representation of optimal task choices one can see that the penalty exponent $\phi$ is required to be weakly positive in order to provide continuity of optimal choices.\footnote{Considering equation (\ref{eq:penalty}), one can easily see that $\lim_{|b_i - \lambda_{i,t}|\to 0} \rho (\theta, \lambda_{i,t}, b_i, \phi) = \infty, \: \forall \phi < 0 \: \text{and} \: \theta > 0$} Apart from this, constraining $\phi > 1$ ensures strict concavity of the utility function which is the sufficient condition for a global maximum of $u_{i,t}$ at $\lambda_{i,t}^*$, given its domain of definition, $\lambda_{i,t}^* \in [0,1]$ (see appendix \ref{app:foc_soc_utility} for a derivation of this result).
\\
Another way to understand the implications of choices of the penalty exponent $\phi$ on the solution to this maximization problem is in terms of the optimal task choice. Allowing for $0 \leq \phi \leq 1$ results in a weakly convex utility function with a kink point at $\lambda_{i,t} = b_i$. In this case, it can be seen from the first derivative of the utility function (appendix \ref{app:foc_soc_utility}) that workers will either stick with their preferred time allocation $b_i$ regardless of relative wages or changes thereof, or alternatively they will fully focus on one single task as soon as its relative wage is high enough, resulting in corner solutions. In such a model specification at most three optimal task choices are feasible: $\lambda_{i,t}^* \in \{0, b_i, 1\}$. While the first case results in a trivial version of the model without inter temporal task adjustments, the second case results in a model where each worker either sticks with her preferred task split $b_i$ or fully focuses on the higher paid task. Both cases are not desirable for the analyses in this thesis, so that it is throughout this work assumed that $\phi > 1$.
\\
Furthermore, notice that the solution presented above accommodates the special case of $\phi = 2$ in which, first, the penalty term no longer needs to be defined piecewise, and second, optimal task choices are linear in changes in relative potential wages. I will fall back to this case in the context of the simulation study that is presented in section \ref{sec:simulation_study} of this thesis.

\subsection{Identifying Changes in Skill Prices} \label{sec:identifying-changes-in-skill-prices}
Previous subsection presents the solution to the maximization problem workers are facing. Following this, I now show how the changes in skill prices over discrete time changes can be identified in this framework. Detailed derivations of the results presented throughout this section can be found in appendix \ref{app:ident_changes_in_skill_prices}. Starting from the utility function in the case of $J=2$ different tasks, presented in equation (\ref{eq:two_task_utility}), changes in time are captured in the total derivative thereof with respect to time. Using the product and chain rules, this yields the expression in equation (\ref{eq:util_total_derivative}).
\\
For the total derivative with respect to time, I make use of a more detailed notation where, instead of using subscripts to denote time dependence, such variables are written as explicit functions of time. Relative potential wages ($\tilde{w}_{i,t}$), thus are expressed as $\tilde{w}_{i}(t)$. Consequently, optimal task choices result as an indirect function of time, i.e. $\lambda_{i,t}^* \equiv \lambda_i^*(\tilde{w}_i (t))$, as seen from equation (\ref{eq:lmb_opt}). The utility function follows analogously.
\begin{align} \label{eq:util_total_derivative}
	\frac{d }{dt} u_{i}(\lambda_i^*(\tilde{w}_i(t)), \tilde{w}_i(t)) &=	\frac{\partial u_i(\lambda_i^*(\tilde{w}_i(t)), \tilde{w}_i(t))}{\partial \lambda_i^*(\tilde{w}_i(t))} \frac{\partial \lambda_i^*(\tilde{w}_i(t))}{\partial \tilde{w}_i(t)}  \frac{d \tilde{w}_i(t)}{dt} \nonumber \\
	{} &+ \frac{\partial u_i(\lambda_i^*(\tilde{w}_i(t)), \tilde{w}_i(t))} {\partial \tilde{w}_i(t)} \frac{d \tilde{w}_i}{dt}
\end{align}
By application of the envelope theorem, the indirect effect of changes in relative potential wages via a change in optimal task choices $\lambda_i^*$ equates to zero so that only the direct effect of changes in relative wages needs to be considered.\footnote{As seen from equation (\ref{eq:foc}), the partial derivative of the utility function with respect to the task choice parameter must be zero by the first order condition of the utility maximization problem.} The total derivative of utility with respect to time, therefore, can be restated as follows.
\begin{equation} \label{eq:util_derivative_env_th}
	\frac{d }{dt} u_{i}(\lambda_i^*(\tilde{w}_i(t)), \tilde{w}_i(t)) = \lambda^*(\tilde{w}_i(t)) \frac{d \tilde{w}_i (t)}{d t}
\end{equation}
For the problem addressed in this thesis, however, changes in discrete time need to be identified. Therefore, equation (\ref{eq:util_derivative_env_th}) is integrated from $t-1$ to $t$. Throughout the remainder of this thesis, I use $\Delta$ as notation for discrete changes of time-dependent variables. Hence, I formulate the integral over marginal changes in equation (\ref{eq:util_derivative_env_th}) from $t-1$ to $t$ as follows.
\begin{equation} \label{eq:util_integration}
	\Delta u_{i,t} = \int^t_{t-1} \left( \frac{d}{d \tau} u_i\big(\lambda_i^*(\tilde{w}_i(\tau))\big) \right) d\tau = \int^{\tilde{w}_{i,t}}_{\tilde{w}_{i,t-1}} \lambda_i^*(\tilde{w}_{i, \tau}) d\tilde{w}_{i, \tau},
\end{equation}
where in the last part of expression (\ref{eq:util_integration}) integration by substitution is used to restate the integral in the second term. By substituting $\tilde{w}_t(\tau)$ with $\tilde{w}_{i,\tau}$, I again rely on the abbreviated notation of time dependence, which I will stick with for the remainder of this work.
\\
Applying a linear interpolation of task choices, presented in equation (\ref{eq:lambda_approximation}), leads to the intermediate result which is shown in equation (\ref{eq:utility_change}). For the identification of the model, this approximation of $\lambda_{i,\tau}^*$ allows to arrive at discrete changes in utility as a function of discrete changes in potential wages. However, against the background of an empirical application of this result, a different interpretation is conceivable: For an unknown functional form of optimal task choices, a linear interpolation between two observable points in time offers a approximation of the interim task choices.
\begin{equation} \label{eq:lambda_approximation}
	\lambda^*_i(\tilde{w}_{i,\tau}) \approx \lambda^* + \frac{\lambda^*(\tilde{w}_{i,t}) - \lambda^*(\tilde{w}_{i,t-1})}{\tilde{w}_{i,t} - \tilde{w}_{i,t-1}} (\tilde{w}_{i,\tau} - \tilde{w}_{i,t-1})
\end{equation}
\begin{equation} \label{eq:utility_change}
	\Delta u_{i,t} = \bar{\lambda}_{i,t}^* \Delta \tilde{w}_{i,t}
\end{equation}
Where $\bar{\lambda}_{i,t}^* \equiv \frac{\lambda_{i,t-1}^* + \lambda_{i,t}^*}{2}$ denotes the mean task choice of periods $t-1$ and $t$. Notice that the linear interpolation of optimal task choices is not an approximation in case the penalty function is quadratic (i.e., penalty exponent $\phi = 2$). It can be seen from equation (\ref{eq:lmb_opt}) that a quadratic penalty term will result in optimal task choices $\lambda_{i,t}^*$ that are linear in relative potential wages. The functional form of optimal task choices is not an approximation but exactly correct in this case.
\\
Similar to the model presented in Böhm et al. (\citeyear{bohm2019occupation}), the key identifying assumption is the divisibility of potential wages into wage paid per constant unit of skill, i.e. skill prices ($\pi_{j,t}$), and skill endowments ($s_{i,j,t}$) In log notation, this assumption allows for a decomposition as shown in equation (\ref{eq:potential_wages}) for each task $j \in \{1, ...,J\}$.
\begin{equation} \label{eq:potential_wages}
	w_{i,j,t} = \pi_{j,t} + s_{i,j,t}
\end{equation}
This implies that changes in relative potential wages can be decomposed into changes in relative skill endowments and changes in relative skill prices, i.e. $\Delta \tilde{w}_{i,t} = \Delta \tilde{\pi}_i + \Delta \tilde{s}_{i,t}$. Similarly, changes in utility can be split into wage changes and changes in the penalty term, as shown in the general version of the utility function presented in equation (\ref{eq:utility}), i.e. $\Delta u_{i,t} = \Delta w_{i,t} - \Delta \rho_{i,t}$. Making use of both decompositions, equation (\ref{eq:utility_change}) can be restated to an expression of wage changes:
\begin{equation} \label{eq:wage_change}
 	\Delta w_{i,t} = \bar{\lambda}^*_{i,t} \Delta \tilde{\pi}_{t} + \bar{\lambda}^*_{i,t} \Delta \tilde{s}_{i,t} + \left[ \rho_{i}(\lambda_{i,t}^*) - \rho_{i}(\lambda_{i,t-1}^*) \right]
\end{equation}
Considering equation (\ref{eq:wage_change}), changes in observable realized wages can be partitioned into three subcomponents: First, changes in skill prices ($\bar{\lambda}^*_{i,t} \Delta \tilde{\pi}_{t}$), which is what this section aims to identify. Second, changes in skill endowments ($\bar{\lambda}^*_{i,t} \Delta \tilde{s}_{i,t}$) that result from some skill accumulation process, and third, changes in the penalty term ($\rho_{i}(\lambda_{i,t}^*) - \rho_{i}(\lambda_{i,t-1}^*)$). Identifying the relation between changes in realized wages and changes in skill prices, therefore, requires the determining both, the second and third summands of equation (\ref{eq:wage_change}) in a first step. In the following section I hence discuss the strategy used to distinguish price changes from these other influences on realized wages.

\subsection{Estimation of the Model} \label{sec:model_estimation}
Equation (\ref{eq:wage_change}) shows that determining changes in relative skill prices requires to distinguish them from changes in both, skill endowments as well as in the penalty term. In an estimation with optimal task choices as explanatory variables price changes would not be distinguishable from changes in skill endowments. Moreover, it would require controlling for changes in the penalty term. A method to isolate changes in skill prices is presented in Böhm et al. (\citeyear{bohm2019occupation}). In a setup that is simiar to the framework presented in this thesis, the authors distinguish between effects of skill accumulation and changes in skill prices relying on a base period $t=0, ...., T_{base}$ in which they set $\Delta \pi_t = 0$. In the article, the authors argue that this can either be seen as an assumption or as a normalization. In the context of this thesis, it is straight forward to think of it as a normalization for two reasons. First, the model introduced in this work by construction cannot provide insights on absolute levels of prices, but relative prices instead. It is, therefore, intuitive to interpret changes in skill prices relative to a base period. Second, in order to answer the research question of this thesis on changes in the relative importance of different task specific skills, one inherently has to consider changes in task prices in comparison to some earlier period.
\\
In addition to skill accumulation, the base period can also be used to estimate changes in the penalty term. In this model, the penalty term is a direct function of optimal task choices, only. In the absence of changes in skill prices, it is therefore possible to estimate $\Delta \rho_{i,t} = \rho_i(\lambda_{i,t}^*) - \rho_i(\lambda_{i,t-1}^*)$ and treat it as a confounding variable in subsequent periods.\footnote{See Böhm et al. \citeyear{bohm2019occupation} who present similar, yet more general results on a model with "non-pecuniary benefits" with unknown functional form.} Exploiting the base period to estimate both, skill accumulation and changes in the penalty term, comes with the downside that these estimated effects cannot be distinguished. However, this is not of relevance to the specific question of this thesis, which is focused on the identification of skill prices. Furthermore, there are other, more sophisticated approaches to work out the skill accumulation process in panel data. These I will discuss in greater detail in section \ref{sec:conclusions}.
\\
The estimation results for the contributions of skill accumulation and changes in the penalty term can be used to adjust wage changes in subsequent periods for these effects. Particularly, the assumption that both, the skill accumulation process as well the functional form of the penalty term are time invariant allows to transfer the estimated results from the base period to the subsequent period. Finally, an estimation of changes in skill prices can be obtained by regressing the residual wage change, i.e. observed change in realized wages adjusted for changes in skill endowments and penalty term, on average task choices.
\end{document}


\documentclass[thesis.tex]{subfiles}

\section{Center-of-Mass Factorization}
For atomic systems, the single-particle orbitals are built from the essentially fixed Coulomb potential of the nucleus.  Conversely, self-bound nuclear systems are translationally invariant, but the single-particle orbits from which they are built are not.  Therefore, there is an added complication with nuclear systems where the intrinsic state and the center-of-mass state are not neccessarily seperate.  A fully seperated ground-state wavefunction can be written as,
\begin{equation}
  \corrket = \corrket_{\text{cm}}\corrket_{\text{in}},
\end{equation}
where $\corrket_{\text{cm}}$ is the center-of-mass wavefunction and $\corrket_{\text{in}}$ is the intrinsic wavefunction.

\begin{equation}
  \Ham_{\text{in}} = \Top - \Top_{\text{cm}} + \Vop = \sum_{i<j}^{A} \left[ \frac{\left( \hat{\mathbf{p}}_{i} - \hat{\mathbf{p}}_{j} \right)^{2}}{2mA} + \Vop\left( \mathbf{r}_{i} - \mathbf{r}_{j} \right) \right]
\end{equation}
By defining the center-of-mass momentum as $\vec{P}=\sum_{i=1}^{A}\vec{p}_{i}$, this separation of the kinetic term gives,
Next, defining the center-of-mass coordinate as $\vec{R}=\frac{1}{A}\sum_{i=1}^{A}\vec{r}_{i}$ allows for the separation of the potential term,
\begin{equation}
  \Ham_{cm}\left( \tilde{\omega} \right) = \Top_{\text{cm}} + \frac{1}{2}mA\tilde{\omega}^{2}\Rop_{\text{cm}}^{2} - \frac{3}{2}\hbar\tilde{\omega} = \frac{1}{2mA}\sum_{ij}^{A}\mathbf{p}}_{i}\cdot\mathbf{p}}_{j} + \frac{m\tilde{\omega}^{2}}{2A}\sum_{ij}^{A}\mathbf{r}_{i}\cdot\mathbf{r}_{j} - \frac{3}{2}\hbar\tilde{\omega}
\end{equation}

Use of Jacobi coordinates \cite{BISHOP19901341,NOGGA2002054003}

\begin{equation}
  E_{\text{cm}}\left( \omega \right) \equiv \left\langle \Ham_{cm}\left( \tilde{\omega} \right) \right\rangle \simeq \frac{1}{2\lambda}\left( \left\langle \Ham_{\text{in}} + \lambda\Ham_{cm}\left( \tilde{\omega} \right) \right\rangle - \left\langle \Ham_{\text{in}} - \lambda\Ham_{cm}\left( \tilde{\omega} \right) \right\rangle \right)
\end{equation}

\cite{HAGEN2009062503}
require that $E_{\text{cm}}\left( \tilde{\omega} \right) = 0$ and use $\left\langle \Top_{\text{cm}} \right\rangle = \frac{3}{4}\hbar\tilde{\omega}$
\begin{gather}
  \Ham_{cm}\left( \omega \right) + \frac{3}{2}\hbar\omega - \Top_{\text{cm}} = \frac{\omega^{2}}{\tilde{\omega}^{2}}\left( \Ham_{cm}\left( \tilde{\omega} \right)  + \frac{3}{2}\hbar\tilde{\omega} - \Top_{\text{cm}} \right) \notag \\
  \hbar\tilde{\omega} = \hbar\omega + \frac{2}{3}E_{\text{cm}}\left( \omega \right) \pm \sqrt{\frac{4}{9}\left( E_{\text{cm}}\left( \omega \right) \right)^{2} + \frac{4}{3}\hbar\omegaE_{\text{cm}}\left( \omega \right)}
\end{gather}

Lawson-Gloeckner method, \cite{GLOECKNER1974313}.
\begin{equation} \label{eq:lawsongloeckner}
  \Ham^{\hspace{1pt}}_{\text{in}} = \Ham_{\text{in}} + \beta\Ham_{\text{cm}}\left( \tilde{\omega} \right)
\end{equation}

\end{document}


\vssub
\subsubsection{~First-order scheme}
\opthead{PR1}{\ws}{H. L. Tolman}

\noindent
In the first order scheme the fluxes in $\theta$- and $k$-space are calculated
using Eqs. (\ref{eq:1up_xy_1}) through (\ref{eq:1up_xy_3}) (replacing $\cN$ with
$N$ and rotating the appropriate counters). The complete first order scheme
becomes

% eq:1up_intra_tot

\begin{equation}
N_{i,j,l,m}^{n+1} = N_{i,j,l,m}^n
 + \frac{\Delta t}{\Delta \theta} \left [ \cF_{l,-} - \cF_{l,+} \right ]
 + \frac{\Delta t}{\Delta k_m} \left [ \cF_{m,-} - \cF_{m,+} \right ]
\: , \label{eq:1up_intra_tot} \end{equation}

\noindent
where $\Delta \phi$ is the directional increment, and $\Delta k_m$ is the
(local) wavenumber increment. The low-wavenumber boundary conditions is
applied by taking $\cF_{m,-}=0$ for $m=1$, and the high wavenumber boundary
condition is calculated using the parametric approximation (\ref{eq:tail_N_k})
for $N$, extending the discrete grid by one grid point to high wavenumbers.


\chapter{Lecture 18 Jun 13th 2018}%
\label{chp:lecture_18_jun_13th_2018}
% chapter lecture_18_jun_13th_2018

\section{Finite Abelian Groups}%
\label{sec:finite_abelian_groups}
% section finite_abelian_groups

\subsection{Primary Decomposition}%
\label{sub:primary_decomposition}
% subsection primary_decomposition

\begin{note}[Notation]
  Let $G$ be an abelian group and $m \in \mathbb{Z}.$ We define
  \begin{equation*}
    G^{(m)} := \{g \in G : g^m = 1\}
  \end{equation*}
\end{note}

\begin{propo}[Group of Elements of the Same Order is a Subgroup]
\label{propo:group_of_elements_of_the_same_order_is_a_subgroup}
  Let $G$ be an abelian group. Then $G^{(m)} \leq G$.
\end{propo}

\begin{proof}
  Note that $1^m = 1 \in G^{(m)}$. $\forall g, h \in G^{(m)}$, since $G$ is abelian, we have that\sidenote{Pay attention that this is only true if $G$ is abelian.}
  \begin{equation*}
    \left( gh \right)^m = g^m h^m = 1 \cdot 1 = 1.
  \end{equation*}
  Therefore $gh \in G^{(m)}$. Also, for $g \in G^{(m)}$, we have
  \begin{equation*}
    \left( g^{-1} \right)^m = \left( g^m \right)^{-1} = 1.
  \end{equation*}
  Thus $g^{-1} \in G^{(m)}$. By the \hlnotea{Subgroup Test}, we have that $G^{(m)} \leq G$. \qed
\end{proof}

\begin{propo}[Decomposition of a Finite Abelian Group]
\label{propo:decomposition_of_a_finite_abelian_group}
  Let $G$ be a finite abelian group with $\abs{G} = mk$ such that $\gcd(m, k) = 1$. Then
  \begin{enumerate}
    \item $G \cong G^{(m)} \times G^{(k)}$; and
    \item $\abs{G^{(m)}} = m$ and $\abs{G^{(k)}} = k$.
  \end{enumerate}
\end{propo}

\begin{proof}
  \begin{enumerate}
    \item Since $G$ is abelian, $G^{(m)} \triangleleft G$ and $G^{(k)} \triangleleft G$.

      \underline{Claim 1}: $G^{(m)} \cap G^{(k)} = \{1\}$ \\
      \textbf{Proof of Claim 1:} $\forall g \in G^{(m)} \cap G^{(k)}$, $g^m = 1 = g^k$ \\
      $\because \gcd(m, k) = 1$, by \hlnotea{Bezout's Lemma}, $\exists x, y \in \mathbb{Z} \quad 1 = mx + ky$ \\
      $\implies g = g^1 = g^{mx + ky} = ( g^m )^x ( g^k )^y = 1 \cdot 1 = 1$ \\
      $\implies G^{(m)} \cap G^{(k)} = \{1\}$ as claimed.

      \underline{Claim 2}: $G = G^{(m)}G^{(k)}$ \sidenote{Recall that this is the \hyperref[defn:product_of_groups]{Product}}\\
      $\forall g \in G \enspace \because o(g) = mk \quad 1 = g^{mk} = ( g^k )^m = ( g^m )^k$ \\
      It follows that $g^k \in G^{(m)}$ and $g^m \in G^{(k)}$. From \textbf{Claim 1} and by abelianness, we have that
      \begin{equation*}
        g = g^{mx + ky} = (g^k)^y (g^m)^x \in G^{(m)}G^{(k)}
      \end{equation*}
      Thus $G \subseteq G^{(m)}G^{(k)}$. On the other hand, since $G^{(m)} \triangleleft G$ and $G^{(k)} \triangleleft G$, by \cref{lemma:product_of_groups_as_a_subgroup}, we have that $G^{(m)}G^{(k)} \leq G$ and hence $G^{(m)} G^{(k)} \subseteq G$. Thus $G = G^{(m)}G^{(k)}$ as claimed.

      From \textbf{Claims 1 and 2}, we can conclude by \cref{crly:group_iso_with_cross_prod_of_its_subgroups}\sidenote{Should this not be \cref{thm:product_and_cross_product_of_normal_subgroups_are_isomorphic}?}, that $G \cong G^{(m)} \times G^{(k)}$ as required.

    \item Write $\abs{G^(m)} = m'$ and $\abs{G^{(k)}} = k'$. By part $(1)$, we have that $mk = \abs{G} = m'k'$.

      \underline{Claim 3}: $\gcd(m, k') = 1$ \\
      Suppose not\\
      $\implies \exists p$ prime $ \quad p \, | \, m$ and $p \, | \, k'$\\
      $\implies \exists g \in G^{(k)} \quad o(g) = p \qquad \because \hyperref[thm:cauchy]{\text{Cauchy's Theorem}}$\\
      Now $p \, | \, m \implies \exists q \in \mathbb{Z} \quad m = pq$\\
      $\implies g^m = g^{pq} = 1 \enspace \because o(g) = p$\\
      $\implies g \in G^{(m)}$.\\
      By part $(1)$, we have that $g \in G^{(m)} \cap G^{(k)} = \{1\} \implies g = 1$, which contradicts the fact that $o(g) = p$. Thus $\gcd(m, k') = 1$ as claimed. Similarly, we can get that $\gcd(m', k) = 1$.

      Notice that $mk = m'k' \implies m \, | \, m'k'$ \\
      $\implies m \, | \, m' \quad \because \gcd(m, k') = 1$
      and similarly $k \, | \, k'$. But then $mk = m'k'$ would imply that $m' = m$ and $k' = k$.
  \end{enumerate}\qed
\end{proof}

As a direct consequence of \cref{propo:decomposition_of_a_finite_abelian_group}, we have the following:

\begin{thm}[Primary Decomposition]
\index{Primary Decomposition}
\label{thm:primary_decomposition}
  Let $G$ be a finite abelian group with $\abs{G} = p_1^{n_1} \hdots p_k^{n_k}$, where $p_1, ..., p_k$ are distinct primes, and $n_1, ..., n_k \in \mathbb{N}$. Then
  \begin{enumerate}
    \item $G \cong G^{\left(p_1^{n_1}\right)} \times \hdots \times G^{\left(p_k^{n_k}\right)}$; and
    \item $\forall i \enspace 1 \leq i \leq k \quad \abs{G^{\left(p_i^{n_i}\right)}} = p_i^{n_i}$.
  \end{enumerate}
\end{thm}

% subsection primary_decomposition (end)

\subsection{p-Groups}%
\label{sub:p_groups}
% subsection p_groups

On a related note of the groups $G^{\left(p_i^{n_i}\right)}$, we define the following:

\begin{defn}[p-Group]\index{p-Group}
\label{defn:p_group}
  Let $p$ be a prime. A \hlnoteb{p-group} is a group in which every element has an order that is a non-negative power of $p$.
\end{defn}

\begin{propo}[p-Groups are Finite]
\index{p-Groups are Finite}
\label{propo:p_groups_are_finite}
  A finite group $G$ is a p-group $\iff$ $\abs{G}$ is a power of $p$ (including $p^0$).
\end{propo}

\begin{proof}
  $(\impliedby)$ If $\abs{G} = p^\alpha$ for some $\alpha \in \mathbb{N} \cup \{0\}$ and $g \in G$, by \cref{crly:lagrange_s_theorem_crly1}, $o(g) \, | \, p^\alpha$ \\
  $\implies G$ is a p-group.

  \noindent $(\implies)$ Consider the contrapositive and let $\abs{G} = p^n p_2^{n_2} \hdots p_k^{n_k}$ where $p, p_2, ..., p_k$ are distinct primes, $n \in \mathbb{N} \cup \{0\}$, and $n_2, ..., n_k \in \mathbb{N}$. For $k \geq 2$, by \hyperref[thm:cauchy]{Cauchy's Theorem}, $p_2 \, | \, \abs{G}$\\
  $\implies \exists g_1 \in G \quad o(g_1) = p_2$\\
  $\implies G$ is not a p-group.\\
  Therefore, our desired result follows.\qed
\end{proof}

\newthought{Our end goal} here is to prove to ourselves that all finite abelian groups can be written as cross products of cyclic groups, i.e. if $G$ is an abelian group, then
\begin{equation*}
  G \cong C_1 \times C_2 \times \hdots \times C_n.
\end{equation*}
With \cref{thm:primary_decomposition}, we have that
\begin{equation*}
  G \cong G_1 \times G_2 \times \hdots \times G_n.
\end{equation*}
The following proposition will enable us to get to our goal from our current position:

\begin{propononum}[Finite Abelian p-Groups of order $p$ are Cyclic]
If $G$ is a finite abelian p-group that contains only one subgroup of order $p$, where $p$ is prime, then $G$ is cyclic. In other words, if a finite abelian p-group is not cyclic, then it must have at least $2$ subgroups of order $p$.
\end{propononum}

% subsection p_groups (end)

% section finite_abelian_groups (end)

% chapter lecture_18_jun_13th_2018 (end)