%!TEX root = ../dissertation.tex

\chapter{Methods}

\newthought{The simulations described} in this thesis were carried out according to a new protocol for temperature-dependent calculation of vibrational spectra. This protocol consists of three phases: the sampling of molecular configurations, the simulation of molecular wavefunctions, the vibrational analysis of these wavefunctions, and the reconstruction of spectra from the analysis results. The three latter phases are well understood in the computational chemistry community\cite{RefWorks:33, RefWorks:34, RefWorks:37, RefWorks:38, RefWorks:39, RefWorks:40}, but the methods outlined here for the first phase are, to our knowledge, novel.

\section{Sampling Molecular Configurations}

Spectral simulation begins with a molecular geometry. This geometry is a set of three-dimensional coordinates that describe the type and spatial location of all the atoms in a molecule. Typically, computational chemistry assumes that the energy of the geometry is minimized\textemdash that is, that the atoms in the structure are arranged such that the potential energy stored in the molecule is as small as possible. While this simplifies calculations, it is not realistic. A molecule fixed at its minimum potential energy is at a virtual absolute zero, which is, in effect, the temperature at which most chemical calculations are carried out.

In reality, molecules are always at a nonzero temperature, and move through a large space of possible configurations. The temperature of the system to which a molecule belongs describes the size of this space; in general, the hotter a system is, the more possible configurations it can assume. Vibrations modulate a molecule through different geometries, and in turn those geometries constrain the ways in which a molecule can vibrate; it follows that molecules in a thermally excited state with access to high-energy geometries will vibrate differently and display different vibrational spectra than those which are frozen at absolute zero.

\begin{figure}
	\centering
	\includegraphics[width=0.7\linewidth]{md_cellulose}
	\caption{Snapshot of cellulose configuration from molecular dynamics simulation at 280K.}
	\label{fig:md_cellulose}
\end{figure}

To address this issue, we drew molecular geometries from the results of large-scale molecular dynamics (MD) simulations of cellulose. MD is a well-understood method for simulating large molecules and molecular systems using classical physics\cite{RefWorks:25}; it works by taking as input the locations and velocities of all the particles in the simulated system, then using a carefully selected potential function to calculate all the forces between the particles. These forces then determine how the particles move according to Newtonian mechanics, which in turn determine how the forces change, and so on. By iteratively evaluating the positions, velocities, and forces at successive discrete time steps separated by as little as a femtosecond, the behavior of molecules can be accurately simulated.

The particular MD approach employed here was designed and implemented by Vishal Agarwal expressly for the purpose of simulating cellulose \cite{RefWorks:23}. This simulation takes in temperature as a parameter, and models the behavior of more than 3,200 atoms in 32 strands of cellulose arranged in 8 parallel sheets for a period of 10 nanoseconds. This simulation is carried out by GROMACS, an open-source software package designed expressly for this type of work \cite{RefWorks:24}.

The molecules in this simulation bend, stretch, and warp according to their own thermal energy and the laws of Newtonian mechanics. By taking a snapshot of this system at any given instant, we have access to a cross-section of the configuration space available to a cellulose molecule at a specific temperature. The results of this particular simulation can be examined at intervals of one picosecond, meaning that at any selected temperature, this simulation generates 10,000 points in cellulose state space.

Unfortunately, performing quantum calculations on such large structures is intractable. As a model system, we selected cellobiose units from within the cellulose superstructure, snipping them out between glycosidic oxygens. These oxygens were then capped by manually adding hydrogen atoms at standard O-H bond lengths and angles. All carbon-linked hydrogens had to be added manually as well; the MD simulation protocol used employed a united-atom model, in which hydrogen-carbon pairs were treated as a single atom. These had to be redistinguished to generate complete cellobiose units.

Taken together, these techniques allow us to sample over the realistic configurations of cellulose at any specified temperature and extract ready-to-simulate cellobiose configurations. We conducted the molecular dynamics at 14 temperatures: 280K, 290K, 300K, 310K, 320K, 350K, 400K, 423K, 450K, 473K, 483K, 493K, 500K, and 550K. We discarded the first 5 nanoseconds of each simulation to ensure that the virtual system had reached equilibrium. Then, at each of these temperatures, we randomly selected 24 timesteps from which to extract cellobiose units, resulting in 336 unique molecular geometries, each representing a possible cellulose substructure at a specific temperature.

\section{Simulation of Wavefunctions}

Each cellobiose configuration generated from the MD was input into Gaussian 09, a widely-used computational chemistry program \cite{RefWorks:26}. Gaussian uses density functional theory (DFT) \cite{RefWorks:44} to compute an approximate wavefunction for the molecule. DFT calculations can be conducted at various levels of theory; we used the popular B3LYP hybrid functional, as is standard in carbohydrate simulation literature \cite{RefWorks:46,RefWorks:34}.

A basis set, describing the basic functions out of which the computed wavefunctions will composed, is also needed. Past carbohydrate simulation literature suggests 6-31+G(d,p) or 6-31G(2d,f,p), with the former being a relatively simple basis set and the latter being relatively complex \cite{RefWorks:34}. This complexity generally leads to more accurate results, at the cost of much more computationally intense calculations. For example, we found that 6-31+G(2d,f,p) Raman calculations took nearly eight times as long as 6-31+G(d,p) Raman calculations.

One of the first phases of this experiment was to determine which basis set was most efficient, delivering the most accuracy while using the least amount of computer time\textemdash a critical factor, given that 336 simulations needed to be performed, and each calculation could take over 90 hours. We assessed the performance of several different basis sets by using each of them to compute the wavefunction and Raman spectrum of the same 280K cellobiose configuration, and comparing the results to those of 6-31+G(2,d,f,p), the standard for carbohydrate simulation.

\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{basis_set_comparison}
\caption{Comparison of Raman spectra generated by different candidate basis sets.}
\label{fig:basis_set_comparison}
\end{figure}

\begin{table}[]
	\centering
	\caption{Times taken to calculate Raman spectrum with different basis sets for an identical cellobiose geometry at 280K.}
	\label{tbl:basis_sets}
	\begin{tabular}{@{}ll@{}}
		\toprule
		Basis Set      & Computation Time (hours) \\ \midrule
		6-31+G(2d,f,p) & 92                       \\
		6-31+G(d,f,p)  & 46                       \\
		6-31G(2d,f,p)  & 39                       \\
		6-31+G(2d,p)   & 31                       \\
		6-31+G(d,p)    & 13                       \\ \bottomrule
	\end{tabular}
\end{table}

The results of the comparison are shown in Figure \ref{fig:basis_set_comparison} and Table \ref{tbl:basis_sets}. These indicated that 6-31+G(2d,p) was the superior basis set for cellobiose simulation, delivering spectra nearly identical to those generated by 6-31+G(2d,f,p) while consuming 60\% less computer time. Therefore 6-31+G(2d,p) was used as the basis set for the bulk of the simulations.

\section{Vibrational Analysis}

Raman spectra were calculated directly from the simulation results by Gaussian. For this purpose, Gaussian employs a technique known as normal mode analysis (NMA). NMA depends on the fact that a molecule's vibrational modes are, mathematically speaking, normal to each other. In other words, they are independent, and each one has characteristics such as frequency that are independently calculable.

NMA assumes that the atoms in a molecule behave as a network of coupled three-dimensional harmonic oscillators, in which the movement of each atom (labeled with an index $i$) is affected by the position and movement of all the other atoms. To frame this mathematically, let each atom have instantaneous position coordinates $x_i, y_i, z_i$ centered about an equilibrium position denoted $x_{i,\mathrm{eq}}, y_{i,\mathrm{eq}}, z_{i,\mathrm{eq}}$. As harmonic oscillators, these atoms experience a force proportional to their displacements from their respective equilibrium positions, governed by a proportionality constant $k$. In addition, they vibrate with a characteristic frequency $\nu$ given by
\begin{equation}
\label{freq_eq}
4\pi \nu^2 mx = kx
\end{equation}
where $m$ is the atom's mass. If the atoms were considered to be simple and independent harmonic oscillators, as in the Einstein model of solids\cite{RefWorks:60}, $k$ would be simply a constant. However, in NMA, coupling dictates that $k$ is determined by the second derivative of the system's potential energy $V$ with respect to position. $V$ is a function of the overall configuration of the molecule; symbolically, $V = V(x_1, y_1, z_1 ... x_N, y_N, z_N)$. Therefore, to calculate all the force constants for all three directions of the $N$ atoms, we must take $3N$ derivatives of a function of $3N$ variables.

The result is a $3N \times 3N$ matrix of force constants describing the force each atom in the molecule feels, given an overall molecular configuration. This matrix is referred to as the Hessian, and it is of critical importance to a number of processes in computational chemistry, including energy minimization. If we denote the Hessian as $H$ and apply standard mass-weighting techniques, we can write the matrix representation of the molecular configuration as $X$ and use Equation \ref{freq_eq} to write
\begin{equation}
HX = 4\pi\nu X
\end{equation}
This is an eigenvalue equation. The eigenvalues of the Hessian are the neqative of the squared normal mode frequencies, and the eigenvectors are the mass-weighted normal coordinate displacements. In other words, solving this equation reveals how each normal mode vibrates, as well as the frequency at which it does so. With the eigenvalues and vectors in hand, Gaussian then proceeds to calculate how each vibrational mode affects the molecule's dipole moment and polarizability, producing IR and Raman intensities for each mode as well.

The reason this calculation must follow a wavefunction simulation phase is that the potential energy $V$ is determined by the wavefunction. The wavefunction determines the location and density of the electron cloud, which in turn determines how the atoms in the molecule interact. Therefore it is the combination of DFT and NMA that allows vibrational spectra to be accurately computed.

\section{Spectral Reconstruction}

It is important to note that normal mode analysis does not produce an actual visual spectrum. For each of an input molecule's vibrational modes, NMA generates a frequency, an IR intensity, a Raman activity level, and a set of vectors describing the vibration of itself in terms of atomic displacements. However, there is an accepted method for constructing a continuous spectrum based on this information. In essence, each vibrational mode is assumed to produce a peak (or trough, in the case of IR) in the spectrum with a Lorentzian profile, and the sum of these will reproduce an approximate spectrum \cite{RefWorks:55}.

A Lorentzian is a single-variable, three-parameter function similar to a Gaussian. It is described by the equation

\begin{equation}
L(x) = A\frac{\frac{1}{2}\Gamma}{(x-x_0)^2 + (\frac{1}{2}\Gamma)^2}
\end{equation}

\noindent where A is the amplitude, $\Gamma$ describes the width of the peak, and $x_0$ is the peak center. This function generates peaks with a distinctively pointed shape and long wings, illustrated in Figure \ref{fig:Lorentzian}. For a mode in the Raman spectrum, for example, peaks are recreated as Lorentzians centered at the mode frequency with an amplitude equal to the Raman activity. The only free parameter is the peak width; typically, this is chosen by investigators to best match the width of experimentally observed peaks. Typically this value is set between 8 to \SI{10}{cm^{-1}} \cite{RefWorks:33}.

A peak reconstruction proceeds in this fashion: let the vectors $F$ and $I$ represent the normal mode frequencies and their associated peak heights, and let $F_i$ and $I_i$ be the particular frequency and intensity for mode $i$. Assuming fixed peak width $\Gamma_0$, the peak $L_i$ is given as
\begin{equation}
L_i(x) = I_i\frac{\frac{1}{2}\Gamma_0}{(x-F_i)^2 + (\frac{1}{2}\Gamma_0)^2}
\end{equation}
Repeating this procedure for all $i$ (that is, all the vibrational modes), we can then derive a function $S$ that gives a continuous spectrum by summing:
\begin{equation}
S(x) = \sum_i I_i\frac{\frac{1}{2}\Gamma_0}{(x-F_i)^2 + (\frac{1}{2}\Gamma_0)^2}
\end{equation}
This function $S(x)$ represents the reconstructed spectrum. It takes a wavenumber in cm$^{-1}$ as input and returns the predicted intensity. In cases where frequencies are close together, the peak amplitudes will sum, and large super-peaks will form, as they do in real spectra.

This method has been proven effective for single sets of NMA output, but for the present work, we have hundreds of such outputs with which grapple. In the interest of isolating the effect of temperature on spectral features, we chose to handle this by averaging over the spectra computed at each temperature, yielding a set of second-order spectral functions that integrate all available information about spectral behavior at a given temperature.

Let $\Omega_T$ be the set of all computed spectral functions $S(x)$ at temperature $T$ and $\Omega_{T,i}$ be the $i$th element in the set. We can then construct the temperature's average spectrum $S_T(x)$ as:
\begin{equation}
S_T(x) = \frac{1}{|\Omega_T|}\sum_i \Omega_{T,t}(x)
\end{equation}
This procedure can be carried out for either Raman intensities or IR intensities. The resulting $S_T$ functions represent our model's prediction of the vibrational spectra of cellobiose at a temperature $T$.

In a similar fashion, the average vibrational displacement vectors can also be calculated. Let the total number of vibrational modes be $M$. At a temperature $T$, the $i$th vibrational mode of the $j$th simulation result contains a set of 3D eigenvectors $V_{j,i}$ numbered 1 through $N$, the number of atoms in the simulated molecule. The eigenvector with index $k$ describes the direction and magnitude of the motion $k$th atom during the mode's vibration. We wish to compute $\langle V_i \rangle_T$, the average set of atomic displacement vectors for mode $i$ at temperature $T$, taken over all the simulation results at $T$. Each entry in this set is given by the following formula:
\begin{equation}
\langle V_{i,k} \rangle_{T} = \frac{\sum_j^M V_{i,k}}{M}
\end{equation}
Calculating this quantity for each atom $k$ for each mode $i$, we can recompose the resulting vectors into a complete $\langle V \rangle_T$, which describes the average displacement vector for each vibrational mode at $T$.
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{Lorentzian}
\caption{Normalized Lorentzian function with center 0, width and amplitude 1.}
\label{fig:Lorentzian}
\end{figure}

\section{Summary}

To reiterate, the simulation protocol used for this work proceeds as follows:

\begin{enumerate}
	\item Molecular dynamics is used to generate cellulose configurations at a given temperature.
	\item Cellobiose structures are extracted from the cellulose structure and capped with hydrogens.
	\item Density functional theory is used to calculate approximate wavefunctions for the cellobiose configurations.
	\item Normal mode analysis is used to compute Raman spectra from the simulated wavefunctions.
	\item Averaging techniques are used to compute representative spectra and vibrational modes for each simulated temperature.
\end{enumerate}

\section{Comparing to Experiment}

The spectral data produced by the protocol described above interesting in isolation, but even more so when compared to the equivalent experimental spectra. There are two complicating factors that must be addressed when carrying out such comparisons: slight deviations in predicted mode frequencies, and the arbitrary nature of Raman activity units. The first point refers to the widely observed fact that DFT/NMA calculations of mode frequencies tend to uniformly under or  overshoot experimentally observed frequencies by one to two percent. To aid comparison, the standard technique is to multiply each predicted frequency by a constant scaling factor, chosen to align some distinctive spectral feature. In this work, an empirically determined scaling factor of 1.017 was chosen to align the main low-frequency peak at approximately \SI{1100}{cm^{-1}}.

The second point refers to the fact that the absolute value of a peak's height in a Raman spectrum has no intrinsic meaning. Different calculational and experimental techniques will yield different numbers and use different units to report the Raman activity, but all of these are arbitrary. What matters from the standpoint of chemical insight is the relative height of each peak in the spectrum. To make this feature clear, we have adopted a simple spectral normalization procedure: we set the height of the tallest peak in the spectrum to be one, and take the lowest point in the spectrum to be zero. We then report the height at every other point as a unitless fraction of the maximum peak height. This way we can accurately compare any number of different spectral datasets, regardless of their native units or scales.

A final note is that certain experimental trials produce a spectra that sits on an elevated linear baseline, due to wide-spectrum polychromatic fluorescence (an effect not believed to be relevant to the pyrolysis process). No such baseline is produced in the simulation. Therefore, for these elevated trials a baseline-corrected spectrum is produced by subtracting the baseline value from each point in the spectrum.

The methods described above do have several limitations. Perhaps the most important is that, in this paradigm, the effects of inter-chain hydrogen bonding between strands of cellulose are ignored in the vibrational analysis stage. By sampling thermal configurations, we take into account the effects of hydrogen bonding on the starting molecular geometry, but certain vibrational modes that may be suppressed by that bonding are calculated to be active with this method, and vice versa. Also, the manual addition of carbon-linked hydrogens makes analysis of modes predominantly involving motion of these atoms unviable, as their positions do not necessarily reflect actual configurations seen at any real temperature.


\subsection{Overview}
\begin{frame}
    To answer this question we considered two modeling approaches:
    \begin{enumerate}
      \item \texttt{RAVEN} (INL) - Risk Analysis and Virtual Environment \cite{baker_optimal_2018}\cite{epiney_report_2017}
      \item \texttt{TEMOA} (NCSU) - Tools for Energy Model Optimization and Analysis \cite{decarolis_modelling_2016}\cite{decarolis_temoa_2010}\cite{hunter_modeling_2013}
    \end{enumerate}
    \vspace{0.5cm}
    Both modeling tools are open source and use publicly available version control
    software, \texttt{Git}, to track changes. \\

    The analysis in \texttt{RAVEN} requires some external modules that are not currently
    available to the public.
\end{frame}

\subsection{Methods for \texttt{RAVEN}}
\begin{frame}
  \frametitle{Workflow in RAVEN}
  \begin{figure}
    \includegraphics[width=0.8\textwidth]{raven_workflow.jpg}
    \caption{A general optimization workflow in RAVEN. Only the ARMA step was used to characterize the UIUC grid.}
    \label{fig:workflow}
  \end{figure}
\end{frame}

\subsection{Methods for \texttt{Temoa}}
\begin{frame}
  \frametitle{\texttt{Temoa} Implementation}
  \texttt{Temoa} uses linear optimization to search decision space \cite{hunter_modeling_2013}.
  \begin{enumerate}
    \item Objective Function (minimizes system cost)
    \item Constraints
    \begin{enumerate}
      \item Demand must be satisfied at each time step (always).
      \item Carbon limits must be satisfied at each time step (optionally).
    \end{enumerate}
    \item Variables
    \begin{enumerate}
      \item Cost
      \item Generation
      \item Capacity
    \end{enumerate}
  \end{enumerate}
\end{frame}


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

\marginpar{Wednesday\\ 2020-12-2, \\ compiled \\ \today}

We have discussed the temperature dependence for URCA and MURCA neutrino-driven cooling of NSs, as well as radiative photon cooling.

Let us see when (slow) neutrino cooling and photon cooling have equal magnitude:
%
\begin{align}
L_\nu^{s} = L_\gamma  \implies N^{s} T^{8} = s T^{2 + 4 \alpha }
\,,
\end{align}
%
which yields (neglecting \(\alpha \)) a transition temperature of
%
\begin{align}
T_{\text{trans}}^{s} = \qty(\frac{s}{N^{s}})^{1/6} \sim \SI{e8}{K}
\,;
\end{align}
%
and we can do a similar thing for fast neutrino cooling: here
%
\begin{align}
T _{\text{trans}}^{f} = \qty(\frac{s}{N^{f}})^{1/4} \sim \SI{e6}{K}
\,,
\end{align}
%
which means that the transition time is of the order of \(\num{e4} \divisionsymbol \SI{e6}{yr}\).

This means that we can make a rough plot of \(\log T\) against \(\log t\) for the slow-cooling case; in the first phase slow cooling dominates and the temperature decreases quickly; then photon cooling takes over and the cooling accelerates.

In the fast-cooling case the cooling is faster initially, and the photon-cooling phase is reached earlier.

Real cooling curves can be computed in a much more sophisticated way.

\textbf{Fast cooling is not supported by observations, since we observe old NSs}.

\subsection{Neutron star spectra}

The most common observational manifestation of NSs are radio pulsars.
We know about around 2500 of those.
The thermal emission from the surface is not the only one.

At the beginning of the 90s the first satellite observing the soft X-rays (ROSAT) between \SI{.1}{keV} and \SI{10}{keV} discovered NS sources which emit X-rays but \emph{not} radio waves.
We know of 7 of those, the ``magnificent seven''.
Their temperature is of the order of the hundreds of eV, and their spectrum looks to be purely thermal.

New satellites like CHANDRA and XMM-Newton can give us spectra like \(\log F\) as a function of \(\log E\).

The first thing one may try to fit is a blackbody:
%
\begin{align}
F_{BB} = A \frac{E^3}{e^{E / k_B T} - 1}
\,.
\end{align}

The parameter \(A\) is proportional to \(R^2 / D^2\), where \(R\) is the radius of the NS while \(D\) is the distance from it, since
the total flux is proportional to \(L / 4 \pi D^2\), and \(L \propto R^2 T^{4}\).

There are reasons to suspect that the surface of a cooling NS is not homogeneous.
Energy is transferred to the envelope from the interior mostly through electron conduction.
We can make a good model for the crust in the plane-parallel approximation, since its depth is \(L \sim \SI{100}{m}\), while the radius of the NS is \(R \sim \SI{10}{km}\).
So, we approximate it as a slab.

The \(\hat{z}\) axis is vertical from the surface, and the magnetic field \(\vec{B}\) will generally not be aligned with it: we denote as \(\phi \) the angle between it and the \(\hat{x}\) axis --- taking \(\hat{x}\), \(\hat{z}\) and \(\vec{B}\) as coplanar.

Heat flux is usually described by Fourier's law:
%
\begin{align}
\vec{q} = - k \vec{\nabla} T
\,,
\end{align}
%
where the scalar \(k\) is called the thermal conductivity.
It being a scalar means that conduction is in principle isotropic --- the medium can conduct in any direction equally.
This is \emph{not} the case if there is a magnetic field: electrons move along field lines in a much easier way than across them.

Therefore, we expect \(k_\parallel \gg k_\perp\), where parallel and perpendicular are referred to the direction of \(\vec{B}\).
The conductivity we need is a tensorial one: the law is written as usual, however \(k\) is now a tensor.

We define a ``primed'' system of reference in which the \(\hat{x}\) axis is parallel to \(\vec{B}\): here, (in two dimensions since there is rotational symmetry around the \(\vec{B}\) axis as far as conduction is concerned)
%
\begin{align}
k' = \left[\begin{array}{cc}
k_\parallel & 0 \\
0 & k_\perp
\end{array}\right]
\,,
\end{align}
%
and the law reads
%
\begin{align}
q_i = - k_{ij} \pdv{T}{x_j}
\,.
\end{align}

The conductivity tensor will transform with the Jacobian of the rotation:
%
\begin{align}
k_{ij} = \pdv{x_i}{x'_k} \pdv{x_j}{x'_\ell} k'_{k \ell}
\,,
\end{align}
%
where, in terms of the angle \(\phi \) between \(\vec{B}\) and the surface at that point,
%
\begin{align}
\pdv{x_i}{x'_k} = \left[\begin{array}{cc}
\cos \phi  & \sin \phi  \\
- \sin \phi & \cos \phi
\end{array}\right]
\,.
\end{align}

% [Calculations]

\end{document}


%==============================================================================
\chapter{Introduction}
\label{sec:intro}
%==============================================================================

\epigraph{Our mistake is not that we take our theories too seriously, but that
we do not take them seriously enough.}{Steven Weinberg
\cite{Weinberg1993first}}

Although widely accepted, Hawking radiation remains a field of heated
discussion and active research, especially in the interpretation and
extrapolation of it. Being one of the first conclusions of the original
calculation, Hawking temperature was deduced from a \emph{pure state} of the
quantum field in the background space-time of a collapsing body, whereas a
temperature in statistical physics is usually derived from a statistical
ensemble in equilibrium, described by a \emph{thermal} and \emph{mixed state}.
This discrepancy itself has since long been largely ignored, albeit related
issues have always been in spotlight, for instance the \emph{information loss
problem} , the \emph{origin of black hole entropy} \cite{Mann2015,Harlow2016},
etc. A detailed investigation of the pure and thermal descriptions would help
understanding the aforementioned questions by laying them on a more solid
foundation.

In this work, which is motivated by \cite{Kiefer2001,Hsu2009}, the focus is to
reveal and quantify the difference between the two cases mentioned above.
\Cref{chap:hawrad} is a review of Hawking radiation in the
$\rbr{3+1}$-dimensional Einstein gravitation which is basically along
\citeauthor{Hawking1976}'s original line, as well as that in
$\rbr{1+1}$-dimensional dilaton gravity, also known as the
Callan--Giddings--Harvey--Strominger (CGHS) model, in which the quantum field
theory in curved space-time not only can be \emph{derived} from the full theory
of quantum gravity, but also be solved exactly. Then in \cref{chap:corr_field},
motivated by the coincidence of the particle-number expectations, which are the
diagonal elements of the density operators, the author computes the correlator
of field strength, so as to reveal the difference in the off-diagonal elements.
In \cref{chap:quantifing}, inspired by a new foundation of statistical physics,
which is based on exact results in quantum information theory, the author
quantifies the discrepancy between the two cases by calculating the trace
distance between them, and the results are shown to be in accordance with the
quantum-informational foundation, as well as those in \cref{chap:corr_field}.
\Cref{chap:summary} is summary and outlook.

In the appendices, \cref{sec:1+1ddlt} explains more details about the CGHS
model, \cref{chap:harosc} collects some useful results in quantised simple
harmonic oscillator, and \cref{chap:distappd} introduces trace distance and
fidelity.

Throughout the text, the \emph{natural units} will be used unless specified,
where the speed of light in vacuum $\lc$, the reduced Planck constant $\phs$ and
Boltzmann constant $\bk$ are all set to unity, while the Newton constant $\nG$
is kept.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../mythesis"
%%% End:


\section{First-order Ordinary Differential Equations}


\subsection*{Signal Processing Functions \hspace*{\fill}\hyperlink{VSIPspecHead}{(up)}\hypertarget{SignalProcessing}{}}\addcontentsline{toc}{subsection}{Signal Processing Functions}
\begin{table}[H]
\hypertarget{vsiplSignalProcessing}{}
\caption{Signal Processing Functions}
\label{tab:SignalProcessing}
\begin{center}
\begin{tabular}{|l|}\hline
\hyperlink{fftFunctions}{FFT Functions}\\
\hyperlink{convCorrFunctions}{Convolution/Correlation Functions}\\
\hyperlink{windowFunctions}{Window Functions}\\
\hyperlink{filterFunctions}{Filter Functions}\\
\hyperlink{miscSigProcFunctions}{Miscellaneous Signal Processing Functions}\\
\hline\end{tabular}
\end{center}
%\label{default}
\end{table}%
%%%
      \input{FftFunctions}
      \input{ConvCorrFunctions}
      \input{WindowFunctions}
      \input{FilterFunctions}
      \input{MiscSigProcFunctions}


\section{Introduction}\label{introduction}

This chapter describes the models, study sites, and methodologies used in this thesis to address the research questions. The first sections are related to the radiative transfer models and the parameterisation schemes of vegetation canopy heterogeneity that are used in Chapter 4. The next sections describe the photosynthesis model in JULES and briefly summarises the model setups for the experiments performed with the land surface model along the thesis; it also described the flux tower sites used in Chapter 5. The final sections of this chapter are used to describe the global experiment setups, data and methodology.

\section{Radiative transfer models}\label{section:RTMs}

\subsection{The two-stream scheme}
The Two-Stream scheme assumes that diffuse radiative fluxes are isotropic in the upward and downward directions. Supposing that the upper and lower leaf optical properties are identical, the Two-Stream scheme used to model radiative transfer in plant canopies is given in the following form \citep{Dickinson1983,Sellers1985}:
\begin{equation}
\begin{gathered}
-\overline{\mu}(dI^{\uparrow})/dL + [1 - (1 - \beta)\omega]I^{\uparrow} - \omega \beta I^{\downarrow} = \omega \overline{\mu} K \beta_0 \exp{(-KL)},\\
-\overline{\mu}(dI^{\downarrow})/dL + [1 - (1 - \beta)\omega]I^{\downarrow} - \omega \beta I^{\uparrow} = \omega \overline{\mu} K (1-\beta_0) \exp{(-KL)}
\end{gathered}
\label{equation:ts}
\end{equation}
\noindent where $I^{\uparrow}$ and $I^{\downarrow}$ are the upward and downward diffuse radiative fluxes normalized by the incident flux respectively, $\mu$ is the cosine of the zenith angle of the incident beam, $K$ is the optical depth of direct beam per unit leaf area and is equal to $G(\mu)/\mu$, $G(\mu)$ is the relative projected area of leaf elements in the direction $cos^{-1}\mu$, $\overline{\mu}$ is the average inverse diffuse optical depth per unit leaf area and is equal to $\int_{0}^{1}[\mu^{\prime}/G(\mu^{\prime})]d\mu^{\prime}$, $\mu^{\prime}$ is the direction of scattered flux, $\omega$ is the scattering coefficient and is equal to $\rho_{leaf} + \tau_{leaf}$, and $L$ is the cumulative LAI. $\beta$ and $\beta_0$ are upscattering parameters for the diffuse and direct beams respectively (see \citet{Sellers1985} for details).

The version used in this exercise was extracted from the JULES model. The JULES model is the UK community land surface model designed to be interfaced with the UK Met Office Unified Model \citep{Walters2014} by predicting fluxes of heat, water, and carbon between the land surface and the atmosphere. It originates from the Met Office Surface Exchange Scheme (MOSES) \citep{Cox1999}, and it includes the TRIFFID (Top-down Representation of Interactive Foliage and Flora Including Dynamics) dynamic vegetation model \citep{Cox2001}. The physical basis of JULES is common to most of the land surface models and are described in details in \citet{Best2011} and \citet{Clark2011}.

JULES uses a number of layers (10 in this exercise) with equally distributed LAI to calculate the radiative transfer in the canopy for direct and diffuse radiation separately. The leaves extinction properties are prescribed by leaf reflectance ($\rho_{leaf}$) and transmittance ($\tau_{leaf}$) in the PAR and NIR wavebands and canopy leaf angle distribution (spherical or horizontal). The amount of absorbed incident radiation at each layer is therefore determined by sun zenith angle, incident direct and diffuse radiation at the top of the canopy, and the leaves extinction coefficients.

\subsubsection{Canopy radiative transfer option 4}

\subsubsection{Canopy radiative transfer option 5}

\section{Handling vegetation heterogeneity in LSMs}
Full 3D radiative transfer models require a large number of parameters, and a high computational demand, thus, 1D radiative transfer approaches are still preferably used \citep{yang2003,loew2014}. However, more simplified approaches to handle sparse vegetated canopies have been implemented in LSMs, and are widely used \citep{loew2014}. The vegetation cover approach divides one grid cell in a number of tiles, where each tile has its own characteristics. The possible number of tiles and their parameters depend on each LSMs.

Suppose a model grid cell with area $A$, which is assumed to be fully covered (100\%) by a particular vegetation type. In the case of sparser canopies, e.g. savannahs, the area $A$ is covered by a dominant vegetation type, usually taller trees, but often presents a second vegetation type, for example, understory vegetation (e.g. shrubs, grass) and so on, or part of the grid with no vegetation at all is covered by bare soil. The total area $A$ is thus defined as,
\begin{equation}
A = f_{veg} + f_{under}
\label{equation:area}
\end{equation}
\noindent where $f_{veg}$ is the fractional coverage of the major vegetation type and $f_{under}$ can correspond to a different vegetation type or the soil surface.
In this case $f_{under}$ is equivalent to the between-crown gaps. The total direct transmissivity, or the gap probability with Sun above head ($\theta$ = 0$^{\circ}$) is always greater than or equals to $f_{under}$. Figure~\ref{f:loew2014} from \citet{loew2014} shows a representation of a sparse vegetation canopy with $f_{veg}$ being the percentage of the area covered by a single vegetation type, $f_{under}$ is the remaining area, and P$_{gap}$($\theta$=0$^{\circ}$) as being $f_{under}$ plus the within-crown gap probability.

\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{/home/mn811042/Thesis/chapter4/figures/Sec_4.2/figure1_pgap_fveg_funder_loew.png}
\caption{Illustration of the difference between vegetation fraction ($f_{veg}$) and gap probability (P$_{gap}$($\theta$ = 0)) for a model grid cell (extracted from \citet{loew2014}).}
\label{f:loew2014}
\end{figure}

The canopy radiative transfer scheme in most LSMs (e.g. JULES \citep{Clark2011}, CLM \citep{Bonan2002}, NOAH \citep{Niu2011}, etc)  is based on the two-stream scheme \citep{sellers1985} which calculates surface albedo and canopy absorption. In JULES, the total fAPAR of a grid cell is calculated by simply weighting the fAPAR calculated by the radiative transfer scheme by the actual area covered by vegetation as,
\begin{equation}
fAPAR = f_{veg} \cdot fAPAR_{canopy}
\label{equation:faparvegfraction}
\end{equation}
And the correspondent surface albedo ($\alpha$) can be obtained as,
\begin{equation}
\alpha = f_{veg} \cdot \alpha_{canopy}  +  f_{under} \cdot \alpha_{soil}
\label{equation:albedovegfraction}
\end{equation}
\noindent where $\alpha_{soil}$ is the soil albedo. The solar spectrum bands in JULES are determined by the spectral properties of leaves and soil.

In this section the tile fraction correction as done in JULES and other LSMs (reference) is applied to the same canopies described in the previous section. It is important to note that the tile fraction correction affects not only the radiative transfer in LSMs, but other parts of the model related to water and carbon balances as well. Here, the impacts of this correction is evaluated over the radiative components of the radiation partitioning in the model in two shortwave wavebands, PAR and NIR.

Table~\ref{tab:fveg} shows the vegetation fraction ($f_{veg}$) and the gap probability with Sun above head (P$_{gap}$($\theta$=0$^{\circ}$)) for the three evaluated canopy structures with same LAI.

\subsection{Tree-based model: MAESPA}\label{section:maespa}
The MAESTRA/MAESPA model \citep{Wang1990,Medlyn2004,Medlyn2007,Duursma2012} represents a forest canopy as an array of tree crowns, whose positions and dimensions are specified. The radiation routines are described in detail by \citet{Wang1990}. The canopy consists of individual tree crowns, which are described by a basic shape (one of several shapes, including ellipsoids, cylinders and cones), length, height to crown base, and width (in x and y directions). Radiation calculations are performed only for a set of target crowns specified by the user. The distribution of leaf area within the target crown is specified, as is the leaf angle distribution. The target crown is divided into usually 60 grid points, and the radiation penetrating to each grid point is calculated for three wavebands (PAR, NIR and thermal infra-red, TIR) based on shading within the crown, shading by neighbouring trees, the location of the sun, and whether radiation is direct or diffuse. Direct, diffuse and scattered radiation are considered separately. Scattering of radiation is approximated following \citet{Norman1979}. Leaf area within crowns is assumed to be distributed randomly \citep{Wang1990}. At each grid point, leaf area is separated into sunlit and shaded leaf area (Norman, 1993). The model has previously been applied to study canopy carbon and water fluxes of \textit{Picea sitchensis} \citep{Wang1990}, \textit{Pinus radiata} \citep{McMurtrie1993}, \textit{Betula pendula} \citep{Wang1998}, and \textit{Pinus taeda} \citep{Luo2001}.
%Using the $R$ (R Development Core Team, 2011) package, Maeswrap (Duursma, 2015), the 3D stand scenes were graphically reproduced in 3D.

\subsection{Geometric optics model: GORT}\label{section:gort}
The GORT model was developed to describe the effects of three-dimensional canopy structure on the radiation environment and to characterise the heterogeneous radiation environment in natural vegetation at the forest stand scale \citep{Li1995}. Merging theory from geometric optics and radiative transfer, the GORT model treats vegetation canopies as assemblages of randomly distributed tree crowns of ellipsoidal shape. The tree crowns are filled with leaves that absorb and scatter radiation passing through the crown. Principles of radiative transfer are used in describing the multiple scattering of leaves inside crowns and the multiple scattering among crowns and the ground surface. The GORT model was extended by \citet{Ni1997} to include the vertical canopy gap probability profile. For this exercise the PAR radiation spectrum was centred in 550 nm, and NIR in 850 nm.

\subsection{Monte-Carlo model: raytran}\label{section:raytran}

The RAMI4PILPS \citep{Widlowski2011} suite of experiments was designed to evaluate the accuracy and consistency of shortwave radiative transfer formulations as used in GCMs by evaluating different models against the extensively verified 3D reference Monte Carlo ray-tracing model, known as raytran \citep{Govaerts1995}.

One of the specificities of the RAMI4PILPS suite ofexperiments is that model simulations can be compared against a reference data set of relatively well known uncertainty. The latter was provided by the 3‐ D MonteCarlo ray‐tracin g m odel kn own as raytran [Govaerts andVerstraete, 1998]. The raytran model has been comparedextensively against goniometer measurements [ Govaerts,1995], field observations [Widlowski et al., 2005a] and,more systematically, against other RT models in the contextof the RAMI activity [Pinty et al., 2001, 2004b; Widlowskiet al., 2007]. Due to its excellent performance with respectto energy conservation, and its matching of analytical solu-tions to within 10−4on average, the raytran model wasidentified as one of six credible 3‐ D canopy RT models andchosen to contribute to the development of a reference dataset against which other radiative transfer models could thenbe evaluated. This reference data set is based on the RAMIsimulations of all six credible 3‐D Monte Carlo models(having a mutual divergence of less than 1% over manythousands of model runs) and has become the cornerstoneof the RAMI On‐line Model Checker (http://romc.jrc.ec.europa.eu/) a web ‐based facility for the autonomousbenchmarking of canopy reflectance models [Widlowski et al.,2008].

The ray-tracing code used in the RAMI4PILPS experiment allows the explicit representation of radiation transfer in arbitrarily complex scenes \citep{Govaerts1998} by implementing a Monte Carlo approach where the fate of millions of individual rays are followed as they travel through the computer simulated scene. This model implements the most detailed and most faithful simulations of radiation transfer, but as other complex models is rather expensive computationally.

In this thesis, the RAMI4PILPS heterogeneous canopy scenario, referred as ``Open Forest Canopy'' was used, where tree crowns were approximated by woodless spheres in an open forest canopy scene. Details of the RAMI4PILPS experiments used in this present study are summarised in Table~\ref{tab:RAMI4PILPS} and a graphic representation of the experiment setups can be found in Fig.~\ref{fig:rami}, while further details of the RAMI4PILPS experiments can be found in \citet{Widlowski2011}.

For each scenario, simulations for different leaf area index and varying soil brightness are performed, assuming direct insulation for three different sun zenith angles, as well as isotropic illumination conditions, i.e. global incident radiation is totally diffuse.

In a first analysis, the participant parameterisations (see section~\ref{section:parameterisations}) were compared in two different ways:
\begin{enumerate}[i]
\item by evaluating the behaviour of the structural indices (clumping indices and structure factor) varying with Sun zenith angle, and
\item by comparing the direct transmissivity ($P_{gap}(\theta)$) calculated with Eq.~\ref{equation:pgap} for each one of the different `structural indices'.
\end{enumerate}

\begin{threeparttable}
\centering
\caption{Summary of variables defining structurally heterogeneous scenes (see \citet{Widlowski2011} for details). Different soil albedos are defined as BLK = black, MED = medium, SNW = snow.}
%\begin{tabular*}{\textwidth}{ l@{\extracolsep{\fill}}*{4}{c}}
\begin{tabular}{l{0.25\textwidth} l{0.75\textwidth}}
%\begin{tabular}{\textwidth}{|p{\textwidth/4}|p{\textwidth/4}|p{\textwidth/4}|p{\textwidth/4}|}
%\begin{tabular*}
     \hline
     \hline
\textbf{Variable Identification}   & \textbf{Values (Units)}\\
\noalign{\smallskip}\hline
Leaf Area Index/ canopy	                & 0.50$^S$, 1.50$^M$ and 2.50$^D$ (m$^2$.m$^{-2}$)\\
Leaf Area Index/ sphere	                & 5.0$^S$, 5.0$^M$ and 5.0$^D$  (m$^2$.m$^{-2}$)\\
1 - $P_{gap} (\theta = 0^{\circ})$      & 0.09$^S$, 0.26$^M$ and 0.434$^D$\\
Tree density                            & 12.80$^S$, 38.24$^M$ and 63.68$^D$ (trees/hectare)\\
Maximum canopy height                   & 16 m\\
Minimum sphere centre height	        & 7 m\\
Maximum sphere centre height	        & 11 m\\
$\alpha_{soil}$,PAR / $\alpha_{soil}$,NIR	& BLK: 0.00/0.00; MED: 0.12/0.21; SNW: 0.96/0.56\\
Soil scattering law	                & Lambertian\\
$\rho_{leaf}$,PAR / $\rho_{leaf}$,NIR     & 0.0735/0.3912\\
$\tau_{leaf}$,PAR / $\tau_{leaf}$,NIR     & 0.0566/0.4146\\
Leaf scattering law                     & Bi-Lambertian\\
Sun zenith angle	                & 27.5$^{\circ}$/60.0$^{\circ}$/83.5$^{\circ}$/Isotropic(ISO)\\
Scatterer Normal Distribution           & Spherical\\
Woody area index                        & 0.0 (m$^2$.m$^{-2}$)\\
\hline
\hline%\noalign{\bigskip}
%\end{tabular*}
\end{tabular}
\begin{tablenotes}
      \small
      \item $^S$Sparse vegetation. $^M$Medium vegetation. $^D$Dense vegetation.
\end{tablenotes}
\label{tab:RAMI4PILPS}
\end{threeparttable}
\bigskip

\begin{figure}
\centering
\begin{tabular}{lll}
\subfloat[Sparse Canopy]{\includegraphics[width=0.33\textwidth]{/home/mn811042/Thesis/chapter4/figures/rami_lai_050.png}}
\subfloat[Medium Canopy]{\includegraphics[width=0.33\textwidth]{/home/mn811042/Thesis/chapter4/figures/rami_lai_150.png}}
\subfloat[Dense Canopy]{\includegraphics[width=0.33\textwidth]{/home/mn811042/Thesis/chapter4/figures/rami_lai_250.png}}
\end{tabular}
\caption{Graphical representation of the open forest canopy environments used in RAMI4PILPS. The images represent three different canopy structures \citep{Widlowski2011}.}
\label{fig:rami}
\end{figure}

\section{The Two-stream scheme with clumping: parameterisation schemes}\label{section:parameterisations}

Several previous studies have suggested with observations and detailed modelling approaches that vegetation 3D structure influences radiation partitioning and other land surface related processes \citep{Nilson1971,Wang1990,Chen1996,Kucharik1999,Yang2001,yang2003,Jonckheere2004,pinty2006,Chen2008,Ni-Meister2010,Widlowski2011,Kobayashi2012,Loew2014}.

For most natural woody vegetation such as conifers and savannahs, the spatial distribution of individual tree crowns creates clear spaces where beam radiation propagates without interference of vegetation elements, and because of that the two-stream scheme results in large deviations from the actual amounts of absorbed and reflected radiation \citep{Ni-Meister2010,Kobayashi2012,Loew2014}.

For detailed computation of 3D radiation fields within complex vegetation canopies, radiative transfer schemes can use a geometrical optical approach and treat mixtures of individual trees and multiple scattering with foliage clumped within tree crowns, e.g. in the GORT model \citep{Li1995}. Another approach is to treat it heterogeneously between tree crowns, e.g. in MAESTRA/MAESPA \citep{Wang1990,Duursma2012}, among others more complex approaches. However, these models cannot be directly used in GCMs due to their extreme computational power demand \citep{Yang2001} and the high number of required vegetation structural parameters \citep{Loew2014}.

Even though efficient 1D radiative transfer schemes are still preferably used, because of their simplicity, speed and suitability to run over large areas, the use of effective radiative state variables to express the properties of 3D vegetation canopy systems makes a simpler model to analogously simulate the radiation balance of more complex 3D models \citep{Pinty2004,pinty2006}, hereafter clumping schemes.

Thus the clumping schemes  account for all phyto and woody elements composing the vegetation canopy, and when its value is greater than 1, it is an indication of specific structural canopy conditions associated with significant amounts of woody elements \citep{pinty2006}.

The first proposed `clumping index' \citep{Nilson1971,Norman1974,chen1992,Chen1996} is associated with the heterogeneous nature of the canopy volume, often used at the tree resolution, and revisited later on by other authors \citep{Pinty2004,pinty2006}, who used the same scientific proposition to account for structural heterogeneity of different radiative media at stand scale, specially in association with satellite products.

Few other authors \citep{Kucharik1999,pinty2006,Ni-Meister2010} attempted to formulate simplified modelling approaches to resolve vegetation clumping at several levels of organisation, in order to address the major differences in shortwave radiation partitioning between 1D and 3D radiative transfer schemes over non-homogeneous forest canopies all over the world.

The next sections will describe and evaluate 3 different clumping schemes to address vegetation heterogeneity in the modified two-stream scheme. Evaluations will be performed against a benchmarking exercise of radiation transfer in vegetation canopies, the RAMI4PILPS experiment \citep{Widlowski2011}.

\subsection{Adapting the two-stream scheme}

The clumping index ($\zeta(\mu)$) is introduced into the two-stream scheme by modifying three main groups of variables to account for canopy structural effects:

\begin{enumerate}
\item the optical depth of direct beam per unit leaf area, $K$;
\item the average inverse diffuse optical depth per unit leaf area, $\mu$̅; and,
\item the single scattering albedo, $a_s(\mu)$, used to obtain the upscattering parameters for the diffuse and direct beams, $\beta$ and $\beta_0$.
\end{enumerate}

The structure factor can be included on the optical depth of direct beam per unit leaf area, by modifying $K$ as:
\begin{equation}
K_{Struc}(\theta) = \frac{G(\theta)}{\mu} \cdot  \zeta(\mu)
\label{equation:opticaldepthstruct}
\end{equation}

The same analogy can be applied when calculating the average inverse diffuse optical depth per unit leaf area, $\bar{\mu}$, but obtaining the structure factor for the direction of scattered flux, $\mu^\prime$:
\begin{equation}
\overline{\mu_{Struc}} = \int_{0}^{1} \frac{\mu^\prime}{G(\mu^\prime) \cdot \zeta(\mu^\prime)} d\mu^\prime
\label{equation:muprimestruct}
\end{equation}

The parameter $\omega\beta$ can be inferred from the analysis of \citet{Norman1975} in the case of a single leaf whose normal is oriented at zenith angle $\theta_l$ from the local vertical defined in the upward hemisphere:
\begin{equation}
\omega\beta = \frac{1}{2}(\omega_l + \delta_l \cos^2 \theta_l)
\label{equation:omegabeta}
\end{equation}
\noindent where $\omega_l = \rho_{leaf} + \tau_{leaf}$ and $\delta_l = \rho_{leaf} - \tau_{leaf}$.

The equation~\ref{equation:omegabeta} however is only valid for a single leaf and to obtain the total contribution of leaves over the canopy it is necessary to integrate over the appropriate leaf orientation probability distribution, between 0 and $\pi/2$, because the leaf normal are assumed to be oriented into the upward hemisphere, as in:
\begin{equation}
\omega\beta = \frac{1}{2}\Big(\omega_l + \delta_l \int_{0}^{\pi/2} \cos^2 \theta_l g^\prime(\theta_l) \sin \theta_l d\theta_l\Big)
\label{equation:omegabeta2}
\end{equation}
\noindent where $\sin\theta_l$ is introduced for normalisation requirement of the probability distribution function. And when isolating $\beta$, it is possible to obtain the generic diffuse upscatter parameter:
\begin{equation}
\beta = \frac{1}{2\omega}\Big(\omega_l + \delta_l \int_{0}^{\pi/2} \cos^2 \theta_l g^\prime(\theta_l) \sin \theta_l d\theta_l\Big)
\label{equation:beta}
\end{equation}

If the two-stream scheme equations are solved when $\omega \rightarrow 0$, i.e., single scatter approximation and semi-infinite canopy, the upward diffuse flux at the top of the canopy may be taken as equal to the single scattering albedo ($a_s(\mu)$). The equation for the direct upscatter parameter, $\beta_0$, is
\begin{equation}
\beta_0 = \frac{1 + \overline{\mu}K}{\omega\overline{\mu}K}a_s(\mu)
\label{equation:betazero}
\end{equation}

And $a_s(\mu)$ is given by,
\begin{equation}
a_s(\mu) = \frac{\omega}{2}\int_{0}^{1} \frac{\mu^\prime G(\mu)}{\mu G(\mu^\prime) + \mu^\prime G(\mu)} d\mu^\prime
\label{equation:alphas}
\end{equation}

The equation above is only valid when assuming isotropic scattering for the leaf elements, which makes the scattering phase function independent of the angle of the incident beam (see \citet{Dickinson1983} and \citet{Sellers1985} for more details).

The addition of the structure factor into the single scattering albedo formulation results in,
\begin{equation}
a_s(\mu) = \frac{\omega}{2}\int_{0}^{1} \frac{\mu^\prime G(\mu) \zeta(\mu)}{\mu G(\mu^\prime) \zeta(\mu^\prime) + \mu^\prime G(\mu)\zeta(\mu)} d\mu^\prime
\label{equation:alphasstruct}
\end{equation}

In this case the formulation for the direct upscatter parameter considering canopy structure is:
\begin{equation}
\beta_0 = \frac{1 + \overline{\mu_{Struc}}K_{Struc}}{\omega\overline{\mu_{Struc}}K_{Struc}}
\bigg[\frac{\omega}{2}\int_{0}^{1} \frac{\mu^\prime G(\mu) \zeta(\mu)}{\mu G(\mu^\prime) \zeta(\mu^\prime) + \mu^\prime G(\mu)\zeta(\mu)} d\mu^\prime \bigg]
\label{equation:alphasstruct}
\end{equation}

\subsection{The clumping index by Kucharik et al. (1999)}
The parameterisation described in this subsection was developed by \citet{Kucharik1999}. The authors used measurements of LAI and gap fraction made with MVI (Multiband Vegetation Imager) \citep{Kucharik1997} obtained during the BOREAS (Boreal Ecosystem-Atmosphere Study) \citep{Sellers1997} field campaigns of 1994-1996 to derive a semi-empirical relationship between $\Omega(\theta)$ and solar zenith angle ($\theta$).

In this method, two key quantities are needed: (i) the fraction of ground area covered by the horizontal projection of crown envelopes ($f_c$) (from nadir view), which is a function of the typical tree crown diameter ($D$), and tree stem spacing ($\lambda$), or stem density, within a study plot; and (ii) an estimate of crown porosity ($\Phi$); this quantity is related to foliage density and defined as the gap fraction within crown envelopes divided by $f_c$.

A series of zenith gap fraction measurements were needed along a transect beneath a canopy to partition the total gap fraction ($f_{gap},t(0)$) between within-crown and between-crown gaps, and  an estimate of the total fraction of ground area covered by the horizontal projection of crown envelopes ($f_c$). To obtain $f_c$, the typical crown silhouette area ($\pi R^2$, where $R$ is the crown radius in the horizontal direction) is multiplied by the number of crowns and divided by the total ground unit area on which the stem density is based. If $f_c$ is greater than 1, crowns typically overlap in the forest, and the entire value of $f_{gap},t(0)$ can be defined as within-crown gap fraction ($f_{gap},c(0)$). The total gap fraction occurring between-crowns ($f_{gap},b(0)$) can be estimated by $1 - f_c$, and $f_{gap},c(0)$ is therefore approximated by $f_{gap},t(0) - f_{gap},b(0)$. If the value of $f_{gap},c(0) < 0$, it can be assigned a value of 0 for all practical purposes.

Crown porosity ($\Phi$) is determined by dividing $f_{gap},c(0)$ by $f_c$ ($\Phi$ = $f_{gap},c(0)/f_c$). The value of $\Phi$ may be described as a normalised within-crown gap fraction. Generally, an error of about 0.05 exists in determining $f_c$ and $\Phi$ by using an average crown radius and tree stem density rather than the actual model calculations of $f_c$. However, the authors indicated that these errors are not of concern when estimating $\Omega(0)$ using the gap-fraction partitioning strategy.

Values of $\Phi$ and $f_c$ were then used to determine a value of $\Omega$(0) that was consistent with calculations resulting from numerical simulations of the canopy gap-size distribution. A non-linear least-squares fit to approximately 250 Monte Carlo simulations (analysing values of $\Omega(0)$) was performed for values of $f_c$ $\geq$ 0.20, and for all simulated values of $\Phi$. A separate fit to the entire set of model data was performed for 0.04 $\geq f_c \geq$ 0.30. For sparse canopies where $f_c < 0.20$, a value of $\Omega(0)$ could still be determined.

Ten equations were solved simultaneously to determine 10 coefficients ($a_0$, ..., $a_9$) that describe the relationship between values of $\Omega(0)$, $f_c$, and $\Phi$. To characterise the angular dependence of $\Omega(\theta)$, a minimum value of $\Omega(\theta)$ was determined at $\theta$ = 0$^{\circ}$ and a value of $\Omega(\theta)$ was needed at $\theta$ = 90$^{\circ}$. Because it was assumed that $\Omega(\theta)$ reaches its maximum value at $\theta$ = 90$^{\circ}$, \citet{Kucharik1999} refer to this value as the maximum possible element clumping index, $\Omega_{max}$, and defines it as:
\begin{equation}
\Omega_{max} = \Big(\frac{ND}{\sqrt{A}}\Big)^{0.7}
\label{equation:clumpmax}
\end{equation}
\noindent where $N$ is number of stems within ground area $A$, and $D$ is crown diameter. If $ND/\sqrt{A} > 1$, then the value of $\Omega_{max} = 1$. The angular dependence of $\Omega(\theta)$ was defined by \citet{Kucharik1999} following the equation:
\begin{equation}
\Omega = \Omega(\theta) = \frac{\Omega_{max}}{[1 + b\exp(-k(\theta)^p)]}
\label{equation:clumptheta}
\end{equation}
\noindent where $k$ is constant (usually $k$ = 2.2), $\theta$ is zenith angle expressed in radians, and $b$ is solved from a rearrangement of Eq.~\ref{equation:clumptheta} using a known value of $\Omega(\theta)$ (e.g., $\theta$ = 0$^{\circ}$). A quantitative comparison of results produced using Eq.~\ref{equation:clumptheta} with the best-fit curves suggested that a value for $p$ can be approximated by an equation on the form:
\begin{equation}
p = -0.461\chi + 3.8
\label{equation:pchi}
\end{equation}
\noindent where $\chi$ is the ratio of crown depth to crown diameter. Generally, if $\chi$ is $\leq$ 1.0, $p$ = 3.34.

This set of semi-empirical equations was used to estimate clumping index for three different canopy sets as in RAMI4PILPS (Table~\ref{tab:RAMI4PILPS}). The results calculated by Eq.~\ref{equation:clumptheta} are presented by dotted lines in Fig.~\ref{f:ci_comparisons}.

The range of clumping index obtained by this work was from approximately 0.2, for minimum Sun zenith angle (i.e. $\theta = 0^{\circ}$), with convergence to 1, for maximum Sun zenith angle (i.e. $\theta = 90^{\circ}$), for sparse and dense canopies, while the convergence in high solar zenith angles ($\theta > 70^{\circ}$ for the medium canopy was approximately 0.7, starting with very small $\Omega(\theta) \approx$ 0.0.

\subsection{The structure factor of Pinty et al. (2006)}
Among other parameterisation schemes, the one proposed by \citet{pinty2006} presents a relatively self-sufficiency, because it does not require any previous knowledge about vegetation structure, and because of that, it can be applied to any vegetation canopy.

The values of the effective variables can be estimated by inverting a 1D radiative transfer model against the results obtained by a 3D model \citep{pinty2006}.

Previous studies have reported the dependency of `clumping index' on solar zenith angle \citep{Andrieu1993,Chen1996,Kucharik1999,Leblanc2005,Ryu2010}. This dependency remains rather smooth and limited \citep{Chen1997a,Chen1997} and it was written by \citet{pinty2006} following an approximated linear relationship:
\begin{equation}
\Omega = \zeta(\mu) \approx a + b \cdot (1 - \mu)
\label{equation:structurefactor}
\end{equation}
\noindent where $\mu$ is the cosine of $\theta$, $a = \zeta(\mu=1)$ is the parameter corresponding to an overhead Sun, and $b$ the parameter responsible for include the effects of a range of different Sun geometries.

In the particular case of an overhead Sun ($\theta$ = 0$^{\circ}$), $a$ is also equal to:
 \begin{equation}
\zeta(\mu=1) = -\ln{(1 - F_c)}\frac{2}{LAI}
\label{equation:structurefactora}
\end{equation}
\noindent where $F_c$ is the true vegetation cover (accounting for within and between crown gaps) obtained for a black canopy representation ($\rho_{leaf} = \tau_{leaf} = 0.0$) of the total incident radiation minus direct transmissivity with an overhead Sun (1 - P$_{gap}(\theta = 0^{\circ}$)).
Both parameters are used to account for vegetation canopy heterogeneity and modify the radiation path length.

\subsection{The clumping index by Ni-Meister et al. (2010)}
Following the same attempt to derive a relationship for clumping index, \citet{Ni-Meister2010} developed an analytical prognostic expression based on stem density ($\lambda$), crown radius ($R$) and LAI. In here, only the equation used for spherical crowns is shown, however, the same authors extend the analysis to more generalised ellipsoid crowns, as introduced in \citet{Li1988}. The analytical solution for the modified clumping index in Beer$^{\prime}$s law is expressed as,
\begin{equation}
\Omega = \gamma = \frac{3}{4\tau_0R}\Big(1 - \frac{1 - (2\tau_0R + 1)\exp(-2\tau_0R)}{2\tau_0^2R^2}\Big)
\label{equation:clumpNi}
\end{equation}
\noindent where $\tau_0r = 3 G LAI/ 4 \lambda \pi \cdot R^2$ for spherical crowns.

The authors validated the analytical solutions for clumping factor with the ones calculated by the full GORT model \citep{Li1995}, which was specifically developed to describe the effects of 3D canopy structure on the radiative balance and to characterise the heterogeneous radiative balance in natural vegetation at the forest stand scale.

This set of equations was used to estimate clumping index for three different canopy sets as in RAMI4PILPS (Table~\ref{tab:RAMI4PILPS}), as well. The results calculated by Eq.~\ref{equation:clumpNi} are presented by dashed-dotted lines in Fig.~\ref{f:ci_comparisons}.

The canopy sets are defined in such a particular way (LAI increasing with density), that the resulting clumping index stayed constant for all cases. That indicates the `clumping index' from \citet{Ni-Meister2010} is not capable to identify structural differences associates with canopy density as proposed in the RAMI4PILPS exercise and it does not take into account different solar geometries.

\section{Modelling photosynthesis: the Farquhar model}

\subsection{Carbon limitation}

\subsection{Electron transport limitation}

\subsection{Light limitation}

\section{FLUXNET dataset}

\subsection{Eddy covariance theory}

\subsection{Study sites}

\subsubsection{Boreal forests: the BOREAS sites}

\subsubsection{Temperate conifereous forest: Oregon sites}

\subsubsection{Woody-savannah: Tonzi ranch}

\section{Global experiment setup}

\subsection{MODIS clumping index}

\subsection{Reanalysis data}


\documentclass[12pt]{article}
\usepackage{fullpage,mathpartir,color,latexsym,theorem,amsmath}

\title{RZ Logic Intermediate Language}
\date{\today}
\author{Andrej Bauer and Chris Stone}

\newcommand{\rulesec}[2]{\subsection*{{\bf#1}\hfill\fbox{$#2$}}}

\newcommand{\M}{M}
\newcommand{\e}{e}
\newcommand{\s}{s}
\newcommand{\X}{\x} % model variable
\newcommand{\n}{x} % name
\newcommand{\p}{\psi} % propositions
\newcommand{\pt}{\sigma} % proptypes
\newcommand{\x}{\n} % term variable
\renewcommand{\k}{\kappa} % set kind
\renewcommand{\l}{{\ell}}
\newcommand{\T}{\ensuremath{\mathcal T}}
\renewcommand{\t}{T}
\newcommand{\elem}{E}
\newcommand{\tk}{\ensuremath{\mathcal K}}

\newcommand{\pFalse}{\bot}
\newcommand{\pTrue}{\top}
\newcommand{\pNot}[1]{\lnot #1}
\newcommand{\pAnd}[2]{#1_0\wedge\cdots\wedge #1_{#2}}
\newcommand{\pOr}[2]{#1_0\vee\cdots\vee #1_{#2}}
\newcommand{\pImply}[2]{#1 \Rightarrow #2}
\newcommand{\pEquiv}[2]{#1 \Leftrightarrow #2}
\newcommand{\pForall}[3]{\forall\, #1{:}#2.\,#3}
\newcommand{\pExists}[3]{\exists\, #1{:}#2.\,#3}
\newcommand{\pUnique}[3]{\exists!\, #1{:}#2\,.#3}
\newcommand{\pAssure}[2]{\mathsf{assure}\ #1\ \mathsf{in}\ #2}
\newcommand{\pEqual}[3]{#1 =_{#3} #2}
\newcommand{\pLambda}[3]{\lambda #1{:}#2.\,#3}
\newcommand{\pApp}[2]{#1\,#2}
\newcommand{\pIsEquiv}[2]{\mathsf{IsEquiv}_{#2}(#1)}
\newcommand{\pMproj}[2]{#1.#2}

\newcommand{\ptProp}{\mathsf{Prop}}
\newcommand{\ptStable}{\mathsf{Stable}}
\newcommand{\ptEquiv}[1]{\mathop{\mathsf{Equiv}} #1}
\newcommand{\ptArrow}[3]{(#1{:}#2)\to #3}

\newcommand{\kSet}{\mathsf{Set}}
\newcommand{\kArrow}[3]{(#1{:}#2)\to #3}

\newcommand{\sArrow}[3]{(#1{:}#2)\to #3}
\newcommand{\sLambda}[3]{\lambda #1{:}#2.\,#3}
\newcommand{\sApp}[2]{#1\,#2}
\newcommand{\sSubset}[3]{\{\,#1:#2\ |\ #3\,\}}
\newcommand{\sQuotient}[2]{#1 {\bigm/} #2}
\newcommand{\sEmpty}{\emptyset}
\newcommand{\sUnit}{1}
\newcommand{\sProduct}[3]{(#1_0{:}#2_0){\times}\cdots{\times}(#1_{#3}{:}#2_{#3})}
\newcommand{\sRz}[1]{\mathop{\mathsf{Rz}} #1}
\newcommand{\sSum}[3]{#1_0\langle{:}#2_0\rangle+\cdots+#1_{#3}\langle{:}#2_{#3}\rangle}
\newcommand{\sSummid}[5]{\cdots+#1_{#4}\langle{:}#2_{#4}\rangle+#1_{#5}\langle{:}#2_{#5}\rangle+\cdots}
\newcommand{\sMproj}[2]{#1.#2}

\newcommand{\eThe}[3]{\iota\, #1{:}#2.\,#3}
\newcommand{\eChoose}[5]{\mathsf{let}\ [#1{:}#2] = #3\ \mathsf{in}\ #4\,{:}\,#5}
\newcommand{\eUnit}{\mathsf{*}}
\newcommand{\eTuple}[2]{(#1_0,\ldots,#1_{#2})}
\newcommand{\eProj}[2]{\mathop{\pi_{#1}} #2 }
\newcommand{\eLambda}[3]{\lambda #1{:}#2.\,#3}
\newcommand{\eApp}[2]{#1\,#2}
\newcommand{\eInj}[2]{\mathop{#1} \langle #2 \rangle}
\newcommand{\eRz}[1]{\mathop{\mathsf{rz}} #1}
\newcommand{\eQuotient}[2]{[#1]_{#2}}
\newcommand{\eSubin}[2]{#1 :> #2}
\newcommand{\eSubout}[2]{#1 <: #2}
\newcommand{\eAssure}[2]{\mathsf{assure}\ #1\ \mathsf{in}\ #2}
\newcommand{\eRzChoose}[5]{\mathsf{let}\ \mathop{\mathsf{rz}}(#1{:}#2) = #3\ \mathsf{in}\ #4\,{:}\,#5}
\newcommand{\eLet}[5]{\mathsf{let}\ (\x{:}\s_1) = \e_1\ \mathsf{in}\ \e_2\,{:}\,\s_2}
\newcommand{\eMproj}[2]{#1.#2}

\newcommand{\mMproj}[2]{#1.#2}
\newcommand{\mApp}[2]{#1\,#2}

\newcommand{\tkModel}{\mathsf{ModelTheory}}
\newcommand{\tkArrow}[3]{(#1{:}#2)\to #3}

\newcommand{\subst}[3]{#1[#2{\mapsto}#3]}
\newcommand{\maybesubst}[3]{#1\langle[#2{\mapsto}#3]\rangle}

\newcommand{\G}{\Gamma}
\newcommand{\wf}[3]{#1 \vdash #2\ :\ #3}
\newcommand{\wfk}[2]{#1 \vdash #2 }
\newcommand{\wfpt}[2]{#1 \vdash #2 }
\newcommand{\wfelem}[2]{#1 \vdash #2}
\newcommand{\st}[3]{#1 \vdash #2 \preceq #3}
\newcommand{\eqv}[4]{#1 \vdash #2 \equiv #3 : #4}
\newcommand{\eqvk}[3]{#1 \vdash #2 \equiv #3 }
\newcommand{\pf}[2]{{\color{red} #1 \vdash #2}}
\newcommand{\eeq}[3]{#1 \vdash #2 \equiv #3}

\newcommand{\deqv}[3]{#1 \vdash #2 \equiv #3}

\newtheorem{lemma}{Lemma}

\begin{document}
\maketitle
\section{Grammar}

\subsection{Models}
\[
\begin{array}{rl@{\hspace{1cm}}l@{\hspace{1cm}}l}
 \M ::= & \X & \texttt{ModelVar($\n$)} & \mbox{variable}\\
|&\mMproj{\M}{\n}&\texttt{ModelProj($\M,\n$)}&\mbox{projection}\\
|&\mApp{\M_1}{\M_2}&\texttt{ModelApp($\M_1,\M_2$)}&\mbox{application}\\
\end{array}
\]

\subsection{Propositions}
\[
\begin{array}{rl@{\hspace{1cm}}l@{\hspace{1cm}}l}
\p ::= & \pFalse & \texttt{False} & \mbox{falsehood}\\
 |&\pTrue & \texttt{True} & \mbox{truth} \\
 |&\langle\M.\rangle\n & \texttt{Atomic(LN($\langle$Some $\M\rangle,\n$),$\pt$)} & \mbox{atomic (tagged with its type)}\\
 |&\pNot{\p}&\texttt{Not($\p$)}&\mbox{negation}\\
 |&\pAnd{\p}{n-1}&\texttt{And[$\p_0$;\ldots;$\p_{n-1}$]} & \mbox{conjunction ($n\geq 0$)}\\
 |&\pOr{\p}{n-1}& \texttt{Or[$\p_0$;\ldots;$\p_{n-1}$]} & \mbox{disjunction ($n\geq 0$)}\\
 |&\pImply{\p_1}{\p_2}& \texttt{Imply($\p_1$,$\p_2$)} & \mbox{implication}\\
 |&\pEquiv{\p_1}{\p_2}& \texttt{Iff($\p_1$,$\p_2$)} & \mbox{equivalence}\\
 |&\pForall{\x}{\s}{\p}&\texttt{Forall(($\x$,$\s$),$\p$)} & \mbox{universal quantification}\\
 |&\pExists{\x}{\s}{\p}&\texttt{Exists(($\x$,$\s$),$\p$)} & \mbox{existential quantification}\\
 |&\pUnique{\x}{\s}{\p}&\texttt{Unique(($\x$,$\s$),$\p$)} & \mbox{unique existential}\\
 |&\pEqual{\e_1}{\e_2}{\s}& \texttt{Equal($\s$,$\e_1$,$\e_2$)} & \mbox{term equality (in a set)}\\
 |&\mathsf{match}\,\e\,\mathsf{with}\,\cdots &
 \texttt{PCase($\e$,$\cdots$)} & \mbox{propositional case construct for sums}\\
 |&\pLambda{\x}{\s}{\p}&\texttt{Lambda(($\x$,$\s$),$\p$)} & \mbox{prop. abstraction}\\
 |&\pApp{\p}{\e}&\texttt{PApp($\p$,$\e$)} & \mbox{prop. application}\\
 |&\pIsEquiv{\p}{\s}& \texttt{IsEquiv($\p$,$\s$)} & \mbox{test for equivalence relation}\\
 |&\pAssure{\p_1}{\p_2}&\texttt{Assure(None,$\p_1$,$\p_2$)} & \mbox{obligation}\\
\end{array}
\]

\subsection{Proposition Types}
\[
\begin{array}{rl@{\hspace{1cm}}l@{\hspace{1cm}}l}
\pt ::= & \ptProp & \texttt{Prop} & \mbox{arbitrary proposition}\\
   |& \ptStable & \texttt{StableProp} & \mbox{$\lnot\lnot$-stable proposition}\\
  |& \ptEquiv{\s} & \texttt{Equiv($\s$)} &\mbox{(stable, curried) equivalence on $\s$}\\
 |& \ptArrow{\x}{\s}{\pt} & \texttt{PropArrow($\x$,$\s$,$\pt$)} & \mbox{(dependent) type of a predicate}\\
\end{array}
\]

\subsection{Sets}
\[
\begin{array}{rl@{\hspace{0.6cm}}l@{\hspace{0.6cm}}l}
\s ::= & \sEmpty & \texttt{Empty} & \mbox{empty set}\\
|& \sUnit & \texttt{Unit} & \mbox{empty product}\\
|&\langle\M.\rangle\n & \texttt{Basic(SLN($\langle$Some $\M\rangle$,$\n$),$\k$)} & \mbox{basic set (tagged with its kind)}\\
|& \sProduct{\x}{\s}{n} &
    \texttt{Product[($\x_0$,$\s_0$);\ldots;($\x_{n-1}$,$\s_{n-1}$)]}&\mbox{(dependent) tuple type; $n\ge 1$}\\
|& \sArrow{\x}{\s_1}{\s_2} & \texttt{Exp($\x$,$\s_1$,$\s_2$)} & \mbox{(dependent) function type}\\
|& \sSum{\l}{\s}{n} & \texttt{Sum[($\l_1$,$\langle$Some $\s_1$$\rangle$),\ldots] }& \mbox{(labeled) sum type; $n\ge 1$}\\
|&\sSubset{\x}{\s}{\p} & \texttt{Subset(($\x,\s$),$\p$)} & \mbox{subset type}\\
|&\sRz{\s} & \texttt{Rz($\s$)} & \mbox{type of realizers for the set}\\
|&\sQuotient{\s}{\p} & \texttt{Quotient($\s,\p$)} & \mbox{quotient type}\\
|&\sLambda{\x}{\s_1}{\s_2}&\texttt{SLambda(($\x,\s_1$),$\s_2$)}&\texttt{set abstraction}\\
|&\sApp{\s}{\e}&\texttt{SApp($\s,\e$)}&\mbox{set application}\\
\end{array}
\]

\subsection{Kinds}
\[
\begin{array}{rl@{\hspace{1cm}}l@{\hspace{1cm}}l}
\k ::= & \kSet & \texttt{KindSet} & \mbox{kind of (proper) sets}\\
 |& \kArrow{\x}{\s}{\k} & \texttt{KindArrow($\x$,$\s$,$\k$)} & \mbox{(dependent) kind of a family of sets}
\end{array}
\]

\subsection{Terms}

\[
\hspace{-1.5cm}
\begin{array}{rl@{\hspace{0.3cm}}l@{\hspace{0.5cm}}l}
\e ::= & \eUnit & \texttt{EmptyTuple} & \mbox{the value of type $1$}\\
|&\langle\M.\rangle\x & \texttt{Var(LN($\langle$Some $\M\rangle$,$\x$))} & \mbox{path}\\
|&\eTuple{\e}{n}&\texttt{Tuple[$\e_1$;\ldots;$\e_n$]}&\mbox{tuple}\\
|&\eProj{i}{\e}&\texttt{Proj($i$,$\e$)}&\mbox{projection; $i\geq 0$}\\
|&\eLambda{\x}{\s}{\e}&\texttt{Lambda(($\x,\s$),$\e$)}&\mbox{abstraction}\\
|&\eApp{\e_1}{\e_2}&\texttt{App($\e_1$,$\e_2$)}&\mbox{application}\\
|&\eInj{\l}{\e}&\texttt{Inj($\l$,$\langle$Some $\e$$\rangle$)}&\mbox{injection}\\
 |&{\mathsf{match}\,\e\,\mathsf{with}\,
      \overline{\l_i\,\langle{\x_i{:}\s_i}\rangle{\leadsto} \e_i}\,{:}\,\s}
     & \texttt{\small PCase($\e$,[($l_0$,($\langle$Some$(\x_0,\s_0)$$\rangle$,$\e_0$);$\cdots$],$\s$)} & \mbox{case construct for sums}\\
|&\eThe{\x}{\s}{\e}&\texttt{The(($\x,\s$),$\e$)}&\mbox{definite description}\\
|&\eRz{\e}&\texttt{RzQuot($\e$)}&\mbox{convert realizer$\to$realizee }\\
|&\eRzChoose{\x}{\s_1}{\e_1}{\e_2}{\s_2}
     &\texttt{RzChoose(($\x,\s_1$),$\e_1$,$\e_2$,$\s_2$)} &
     \mbox{realizer of a term}\\
|&\eQuotient{\e}{\p} & \texttt{Quot($\e$,$\p$)} & \mbox{equivalence class}\\
|&\eChoose{\x}{\s_1}{\e_1}{\e_2}{\s_2}
     &\texttt{RzChoose(($\x,\s_1$),$\p$,$\e_1$,$\e_2$,$\s_2$)} &
     \mbox{equivalence-class representative}\\
|&\eLet{\x}{\s_1}{\e_1}{\e_}{\s_2}
     &\texttt{Let(($\x,\s_1$),$\e_1$,$\e_2$,$\s_2$)} &
     \mbox{local definition}\\
|&\eSubin{\e}{\s}& \texttt{Subin($\e,\s$)} & \mbox{injection into a subset $\s$}\\
|&\eSubout{\e}{\s}& \texttt{Subout($\e,\s$)} & \mbox{projection from a subset into $\s$}\\
 |&\eAssure{\p}{\e}&\texttt{Assure(None,$\p$,$\e$)} & \mbox{obligation}\\
\end{array}
\]

\subsection{Theories}

\newcommand{\tTheory}[1]{\mathsf{thy}\ #1 \ \mathsf{end}}
\newcommand{\tArrow}[3]{(#1{:}#2)\to #3}
\newcommand{\tLambda}[3]{\lambda #1{:}#2.\,#3}
\newcommand{\tApp}[2]{#1\,#2}

\[
\begin{array}{rl@{\hspace{0.3cm}}l@{\hspace{0.5cm}}l}
\T ::= & \t & \texttt{TheoryName($\t$)} & \mbox{named theory}\\
 |&\tTheory{\elem_1 \cdots \elem_n} &
     \texttt{Theory[$\elem_1$;\ldots;$\elem_n$]}& \mbox{theory of a proper model}\\
|&\tArrow{\X}{\T_1}{\T_2}&\texttt{TheoryArrow(($\X,\T_1$),$\T_2$)}&\mbox{theory of a family of models}\\
|&\tLambda{\X}{\T_1}{\T_2}&\texttt{TheoryLambda(($\X,\T_1$),$\T_2$)}&\mbox{theory abstraction}\\
|&\tApp{\T}{\M}&\texttt{TheoryApp($\T,\M$)}&\mbox{theory instantiation}
\end{array}
\]

\subsection{Theory Elements}

\newcommand{\decl}{\mathit{decl}}
\[
\begin{array}{rl@{\hspace{0.3cm}}l@{\hspace{0.3cm}}l}
\elem ::= &\x : \decl& \texttt{Declaration($\x$, $\decl$)}\\[12pt]

\decl ::= &\s \langle = \e\rangle & \texttt{DeclTerm($\langle$Some $\e$$\rangle$,$\s$)} & \mbox{declare/define a term}\\
| &\k \langle = \s\rangle & \texttt{DeclSet($\langle$Some $\s$$\rangle$,$\k$)} & \mbox{declare/define a set}\\
| &\pt \langle = \p\rangle & \texttt{DeclProp($\langle$Some $\p$$\rangle$,$\pt$)} & \mbox{declare/define a proposition}\\
| &\T& \texttt{DeclModel($\T$)}&\mbox{declare a model}\\
| &\forall \X_1{:}\T_1,\ldots.\p&
    \texttt{DeclSentence([($\X_1,\T_1$);$\cdots$],$\p$)} &
    \mbox{declare an axiom}.
\end{array}
\]

\subsection{Theory Kinds}
\[
\begin{array}{rl@{\hspace{1cm}}l@{\hspace{1cm}}l}
\tk ::= & \tkModel & \texttt{ModelTheoryKind} & \mbox{kind of (proper) theory}\\
 |& \tkArrow{\X}{\T_1}{\T_2} & \texttt{TheoryKindArrow($\X$,$\T_1$,$\T_2$)} & \mbox{(dependent) kind of a family of theories}
\end{array}
\]

\subsection{Top-level elements}

\[
\begin{array}{rl@{\hspace{1cm}}l@{\hspace{1cm}}l}
\mathit{topelem} ::= & \t = \T & \texttt{Theorydef($\t$,$\T$)} & \mbox{theory definition}\\
|&\X : \T& \texttt{TopModel($\X$,$\T$)}&\mbox{model declaration}\\
\end{array}
\]

\section{Judgments}

\rulesec{Propositions}{\wf{\G}{\p}{\pt}}

\begin{mathpar}
\inferrule
  { }
  { \wf{\G}{\pFalse}{\ptStable} }

\inferrule
  { }
  { \wf{\G}{\pTrue}{\ptStable} }

\inferrule
  { \G(\x) = \pt }
  { \wf{\G}{\x}{\pt} }

\inferrule
  { \wf{\G}{\M}{\tTheory{\x_0{:}\decl_0,\ldots,\x_i{:}\pt_i\langle{{=}\p_i}\rangle,\ldots}} }
  { \wf{\G}{\pMproj{\M}{\x_i}}{\pt_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}]}}

\inferrule
  { \wf{\G}{\p}{\ptProp} }
  { \wf{\G}{\pNot{\p}}{\ptStable} }

\inferrule
  { n \geq 0\\\\
    \wf{\G}{\p_1}{\pt_1} \\ \cdots \\
    \wf{\G}{\p_n}{\pt_n} \\\\
    \st{\G}{\pt_1}{\ptProp} \\ \cdots \\
    \st{\G}{\pt_n}{\ptProp} }
  { \wf{\G}{\pAnd{\p}{n}}{(\pt_1{\cup}\cdots{\cup}\pt_n)} }

\inferrule
  { n \geq 0\\\\
    \wf{\G}{\p_1}{\ptProp} \\ \cdots \\
    \wf{\G}{\p_n}{\ptProp} }
  { \wf{\G}{\pOr{\p}{n}}{\ptProp} }

\inferrule
  { \wf{\G}{\p_1}{\ptProp} \\\\
    \wf{\G{,\color{red}\p_1}}{\p_2}{\pt_2} \\ \st{\G}{\pt_2}{\ptProp} }
  { \wf{\G}{\pImply{\p_1}{\p_2}}{\pt_2}}

\inferrule
  { \wf{\G}{\p_1}{\pt_1} \\ \st{\G}{\pt_1}{\ptProp} \\\\
    \wf{\G}{\p_2}{\pt_2} \\ \st{\G}{\pt_2}{\ptProp} }
  { \wf{\G}{\pEquiv{\p_1}{\p_2}}{\pt_1{\cup}\pt_2} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wf{\G,\x{:}\s}{\p}{\pt} \\
    \st{\G,\x{:}\s}{\pt}{\ptProp} }
  { \wf{\G}{\pForall{\x}{\s}{\p}}{\pt} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wf{\G,\x{:}\s}{\p}{\ptProp} }
  { \wf{\G}{\pExists{\x}{\s}{\p}}{\ptProp} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wf{\G,\x{:}\s}{\p}{\ptProp} }
  { \wf{\G}{\pUnique{\x}{\s}{\p}}{\ptProp} }

\inferrule
  { \wf{\G}{\e_1}{\s} \\
    \wf{\G}{\e_2}{\s} }
  { \wf{\G}{\pEqual{\e_1}{\e_2}{\s}}{\ptStable} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wf{\G,\x{:}\s}{\p}{\pt} }
  { \wf{\G}{\pLambda{\x}{\s}{\p}}{\ptArrow{\x}{\s}{\pt}} }

\inferrule
  { \wf{\G}{\p}{\ptArrow{\x}{\s}{\pt}} \\
    \wf{\G}{\e}{\s} }
  { \wf{\G}{\pApp{\p}{\e}}{\pt[\x{\mapsto}\e]} }

\end{mathpar}

\noindent{\textit{Continued\ldots}}

\clearpage

\begin{mathpar}

\newcommand{\pCase}[8] {
\mathsf{match}\,#1\,{:}#2\,\mathsf{with}\,
      #3_0\,\langle{#4_0{:}#5_0}\rangle{\leadsto} #6_0\ |\
       \cdots\ |\
      #3_{n-1}\,\langle{#4_{#7-1}{:}#5_{n-}}\rangle{\leadsto} #6_{n-1}
      \,{:}\,#8
}
\inferrule
  { n \ge 0 \\
    \l_0,\ldots,\l_{n-1} \mathrm{\ distinct} \\\\
    \wf{\G}{\e'}{\s'}\\
    \st{\G}{\e'}{\s'}{\sSum{\x}{\s'}{n-1}}\\\\
    \langle\wf{\G}{\s_0}{\kSet}\rangle \\
    \wf{\G\langle,\x_0{:}\s'_0\rangle%
          {\color{red}, \pEqual{\e}{\eInj{\l_0}{\x_0}}{\s}}}
          {\p_0}{\pt} \\
    \langle \x_0\not\in\mathop{\mathrm{FV}}\pt \rangle \\\\
    \vdots\\\\
    \langle\wf{\G}{\s_{n-1}}{\kSet}\rangle \\
    \wf{\G\langle,\x_{n-1}{:}\s'_{n-1}\rangle%
          {\color{red}, \pEqual{\e}{\eInj{\l_{n-1}}{\x_{n-1}}}{\s}}}
           {\p_{n-1}}{\pt}\\
       \langle \x_{n-1}\not\in\mathop{\mathrm{FV}}\pt \rangle }
  { \wf{\G}{\pCase{\e'}{\s'}{\l}{\x}{\s}{\p}{n}{\pt}}{\pt}
  }

\inferrule
  { \wf{\G}{\p}{\ptArrow{\cdot}{\s}{\ptArrow{\cdot}{\s}{\ptStable}}}}
  { \wf{\G}{\pIsEquiv{\p}{\s}}{\ptStable}}

\inferrule
  { \wf{\G}{\p_1}{\ptStable} \\
    \pf{\G}{\p_1} \\
    \wf{\G{,\color{red}\p_1}}{\p_2}{\pt} \\ \st{\G,\p_1}{\pt}{\ptProp} }
  { \wf{\G}{\pAssure{\p_1}{\p_2}}{\pt} }

\inferrule
  { \wf{\G}{\p}{\ptArrow{\cdot}{\s}{\ptArrow{\cdot}{\s}{\ptStable}}} \\
    \pf{\G}{\pIsEquiv{\p}{\s}} }
  { \wf{\G}{\p}{\ptEquiv{\s}} }

\inferrule
  { \wf{\G}{\p}{\pt_1} \\
    \st{\G}{\pt_1}{\pt_2} }
  { \wf{\G}{\p}{\pt_2} }

\end{mathpar}

\begin{lemma}
  If $\wf{\G}{\p}{\pt}$ then $\wfpt{\G}{\pt}$.
\end{lemma}

\rulesec{Well-Formedness of Proposition Types}{\wfpt{\G}{\pt}}

\begin{mathpar}
\inferrule
  { }
  { \wfpt{\G}{\ptProp} }

\inferrule
  { }
  { \wfpt{\G}{\ptStable} }

\inferrule
  { \wf{\G}{\s}{\kSet} }
  { \wfpt{\G}{\ptEquiv{\s}} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wfpt{\G,\x{:}\s}{\pt} }
  { \wfpt{\G}{\ptArrow{\x}{\s}{\pt}} }

\end{mathpar}

\rulesec{Subtyping for Proposition Types}{\st{\G}{\pt_1}{\pt_2}}

\begin{mathpar}
\inferrule
  { \wfpt{\G}{\pt} }
  { \st{\G}{\pt}{\pt} }

\inferrule
  { \st{\G}{\pt_1}{\pt_2} \\ \st{\G}{\pt_2}{\pt_3} }
  { \st{\G}{\pt_1}{\pt_3} }

\inferrule
  { }
  { \st{\G}{\ptStable}{\ptProp} }

\inferrule
  { \st{\G}{\s_1}{\s_2} }
  { \st{\G}{\ptEquiv{\s_2}}{\ptEquiv{\s_1}} }

\inferrule
  { \wf{\G}{\s}{\kSet} }
  { \st{\G}{\ptEquiv{\s}} {\ptArrow{\x_1}{\s}{\ptArrow{\x_2}{\s}{\ptStable}}} }

\inferrule
  { \st{\G}{\s_2}{\s_1}\\
    \st{\G,x{:}\s_2}{\pt_1}{\pt_2} }
  { \st{\G}{\ptArrow{\x}{\s_1}{\pt_1}}{\ptArrow{\x}{\s_2}{\pt_2}} }
\end{mathpar}

\begin{lemma}
  If $\st{\G}{\pt_1}{\pt_2}$ then $\wfpt{\G}{\pt_1}$ and $\wfpt{\G}{\pt_2}$.
\end{lemma}

\rulesec{Equivalence for Proposition Types}{\eeq{\G}{\pt_1}{\pt_2}}

\begin{mathpar}
\inferrule
  { \wfpt{\G}{\pt} }
  { \eeq{\G}{\pt}{\pt} }

\inferrule
  { \eeq{\G}{\pt_1}{\pt_2} \\ \cdots \\ \eeq{\G}{\pt_2}{\pt_3} }
  { \eeq{\G}{\pt_1}{\pt_3} }

\inferrule
  { \eqv{\G}{\s_1}{\s_2}{\kSet} }
  { \eeq{\G}{\ptEquiv{\s_2}}{\ptEquiv{\s_1}} }

\inferrule
  { \eqv{\G}{\s_1}{\s_2}{\kSet}\\
    \eeq{\G,x{:}\s_1}{\pt_1}{\pt_2} }
  { \eeq{\G}{\ptArrow{\x}{\s_1}{\pt_1}}{\ptArrow{\x}{\s_2}{\pt_2}} }
\end{mathpar}

\begin{lemma}
  If $\eeq{\G}{\pt_1}{\pt_2}$ then $\wfpt{\G}{\pt_1}$ and $\wfpt{\G}{\pt_2}$.
\end{lemma}

\rulesec{Set Well-Formedness}{\wf{\G}{\s}{\k}}

\begin{mathpar}
\inferrule
  { }
  { \wf{\G}{\sEmpty}{\kSet}}

\inferrule
  { }
  { \wf{\G}{\sUnit}{\kSet} }

\inferrule
  { \G(\x) = \k }
  { \wf{\G}{\x}{\k} }

\inferrule
  { \wf{\G}{\M}{\tTheory{\x_0{:}\decl_0,\ldots,\x_i{:}\k_i\langle{{=}\s_i}\rangle,\ldots}} }
  { \wf{\G}{\sMproj{\M}{\x_i}}{\k_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}]}}

\inferrule
  { \wf{\G}{\s_1}{\kSet} \\
    \wf{\G,\x{:}\s_1}{\s_2}{\kSet} }
  { \wf{\G}{\sArrow{\x}{\s_1}{\s_2}}{\kSet} }

\inferrule
  { n\ge 1\\\\
    \wf{\G}{\s_1}{\kSet}\\ \cdots \\
    \wf{\G,\x_1{:}\s_1,\ldots,\x_{n-1}{:}\s_{n-1}}{\s_n}{\kSet} }
  { \wf{\G}{\sProduct{\x}{\s}{n-1}}{\kSet} }

\inferrule
  { n \geq 1\\
    \l_0,\ldots,\l_{n-1}\ \mbox{distinct}\\\\
    \langle \wf{\G}{\s_0}{\kSet} \rangle\\ \cdots \\
    \langle \wf{\G}{\s_{n-1}}{\kSet} \rangle}
  { \wf{\G}{\sSum{\l}{\s}{n-1}}{\kSet} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wf{\G,\x{:}\s}{\p}{\ptProp} }
  { \wf{\G}{\sSubset{\x}{\s}{\p}}{\kSet} }

\inferrule
  { \wf{\G}{\s}{\kSet} }
  { \wf{\G}{\sRz{\s}}{\kSet} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wf{\G}{\p}{\ptEquiv{\s}} }
  { \wf{\G}{\sQuotient{\s}{\p}}{\kSet} }

\inferrule
  { \wf{\G}{\s_1}{\kSet} \\
    \wf{\G,\x{:}\s_1}{\s_2}{\k} }
  { \wf{\G}{\sLambda{\x}{\s}{\p}}{\kArrow{\x}{\s_1}{\k}} }

\inferrule
  { \wf{\G}{\s}{\kArrow{\x}{\s_1}{\k_2}} \\
    \wf{\G}{\e}{\s_1} }
  { \wf{\G}{\sApp{\s}{\e}}{\subst{\k_2}{\x}{\e}} }

\inferrule
  { \wf{\G}{\s}{\k_1} \\
    \st{\G}{\k_1}{\k_2} }
  { \wf{\G}{\s}{\k_2} }

\end{mathpar}

\begin{lemma}
  If $\wf{\G}{\s}{\k}$ then $\wfk{\G}{\k}$.
\end{lemma}

\rulesec{Equivalence for Sets}{\eqv{\G}{\s_1}{\s_2}{\k}}

\begin{mathpar}
\inferrule
  { \wf{\G}{\s}{\k} }
  { \eqv{\G}{\s}{\s}{\k} }

\inferrule
  { \eqv{\G}{\s_1}{\s_2}{\k} \\ \cdots \\ \st{\G}{\s_2}{\s_3}{\k} }
  { \eqv{\G}{\s_1}{\s_3}{\k} }

\inferrule
  { \eqv{\G}{\s_0}{\s'_0}{\kSet} \\\\
     \vdots\\\\
    \eqv{\G,\x_0{:}\s_0,\ldots,\x_{n-2}{:}\s_{n-2}}{\s_{n-1}}{\s'_{n-1}}{\kSet}}
  { \eqv{\G}{\sProduct{\x}{\s}{n-1}}{\sProduct{\x}{\s'}{\n-1}}{\kSet}}

\inferrule
  { \eqv{\G}{\s_1}{\s'_1}{\kSet} \\
    \eqv{\G,\x{:}\s_1}{\s_2}{\s'_2}{\kSet} }
  { \eqv{\G}{\sArrow{\x}{\s_1}{\s_2}}{\sArrow{\x}{\s'_1}{\s'_2}}{\kSet} }

\inferrule
  { \eqv{\G}{\s_0}{\s'_0}{\kSet} \\\\
     \vdots\\\\
    \eqv{\G}{\s_{n-1}}{\s'_{n-1}}{\kSet}}
  { \eqv{\G}{\sSum{\l}{\s}{n-1}}{\sSum{\l}{\s'}{n-1}}{\kSet}}

\inferrule
  { 0 \leq i,j < n \\
    \wf{\G}{\sSum{\l}{\s}{n-1}}{\kSet} }
  { \eqv{\G}{\sSummid{\l}{\s}{n-1}{i}{j}}{\sSummid{\l}{\s}{n-1}{j}{i}}{\kSet}}

\inferrule
  { \eqv{\G}{\s}{\s'}{\kSet} \\
    {\color{blue} \deqv{\G,\x{:}\s}{\p}{\p'}} }
  { \eqv{\G}{\sSubset{\x}{\s}{\p}}{\sSubset{\x}{\s'}{\p'}}{\kSet} }

\inferrule
  { \eqv{\G}{\s}{\s'}{\kSet} }
  { \eqv{\G}{\sRz{\s}}{\sRz{\s'}}{\kSet} }

\inferrule
  { \eqv{\G}{\s}{\s'}{\kSet} \\
    {\color{blue} \deqv{\G}{\p}{\p'}} }
  { \eqv{\G}{\sQuotient{\s}{\p}}{\sQuotient{\s'}{\p'}}{\kSet} }

\inferrule
  { \eqv{\G}{\s_1}{\s'_1}{\kSet} \\
    \eqv{\G,\x{:}\s_1}{\s_2}{\s'_2}{\kSet} }
  { \eqv{\G}{\sLambda{\x}{\s_1}{\s_2}}{\sLambda{\x}{\s_2}{\s'_2}}{\kSet} }

\inferrule
  { \eqv{\G}{\s}{\s'}{\kArrow{\x}{\s_1}{\k_2}} \\\\
    \wf{\G}{\e}{\s_1} \\ \wf{\G}{\e'}{\s_1} \\
    \pf{\G}{\pEqual{\e}{\e'}{\s_1}} }
  { \eqv{\G}{\sApp{\s}{\e}}{\sApp{\s'}{\e'}}{\subst{\k_2}{\x}{\e}} }

\inferrule
  { \wf{\G,\x{:}\s_2}{\s}{\k} \\
    \wf{\G}{\e_2}{\s_2} }
  { \eqv{\G}{\sApp{(\sLambda{\x}{\s_2}{\s})}{\e_2}}
        {\s[\x{\mapsto}\e_2]} {\k[\x{\mapsto}\e_2]} }

\inferrule
  { \wf{\G}{\M}{\tTheory{\x_0{:}\decl_0,\ldots,\x_i{:}\k_i{=}\s_i,\ldots}} }
  { \eqv{\G}{\sMproj{\M}{\x_i}}{\s_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}]}{\k_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}]}}

\end{mathpar}

\begin{lemma}
  If $\eqv{\G}{\s_1}{\s_2}{\k}$ then $\wf{\G}{\s_1}{\k}$ and $\wf{\G}{s_2}{\k}$ and $\wfk{\G}{\k}$.
\end{lemma}

\rulesec{Subtyping for Sets}{\st{\G}{\s_1}{\s_2}}

\begin{mathpar}
\inferrule
  { \wf{\G}{\s}{\k} }
  { \st{\G}{\s}{\s} }

\inferrule
  { \st{\G}{\s_1}{\s_2} \\ \st{\G}{\s_2}{\s_3} }
  { \st{\G}{\s_1}{\s_3} }

\inferrule
  { \eqv{\G}{\s}{\s}{\kSet} }
  { \st{\G}{\s}{\s} }

\inferrule
  { \st{\G}{\s_0}{\s'_0} \\\\
     \vdots\\\\
    \st{\G,\x_0{:}\s_0,\ldots,\x_{n-2}{:}\s_{n-2}}{\s_{n-1}}{\s'_{n-1}}}
  { \st{\G}{\sProduct{\x}{\s}{n-1}}{\sProduct{\x}{\s'}{\n-1}}}

\inferrule
  { \st{\G}{\s'_1}{\s_1} \\
    \st{\G,\x{:}\s'_1}{\s_2}{\s'_2} }
  { \st{\G}{\sArrow{\x}{\s_1}{\s_2}}{\sArrow{\x}{\s'_1}{\s'_2}} }

\inferrule
  { 0 < m \leq n \\\\
    \st{\G}{\s_0}{\s'_0} \\
     \cdots\\
    \st{\G}{\s_{m-1}}{\s'_{m-1}} \\\\
    \wf{\G}{\s_m}{\kSet} \\ \cdots \\ \wf{\G}{\s_{n-1}}{\kSet} }
  { \st{\G}{\sSum{\l}{\s}{n-1}}{\sSum{\l}{\s'}{m-1}}}

\inferrule
  { \st{\G}{\s}{\s'} \\
    {\color{blue} \deqv{\G,\x{:}\s}{\p}{\p'}} }
  { \st{\G}{\sSubset{\x}{\s}{\p}}{\sSubset{\x}{\s'}{\p'}} }

\inferrule
  { \st{\G}{\s}{\s'}{\kSet} \\
    {\color{blue} \deqv{\G}{\p}{\p'}} }
  { \st{\G}{\sQuotient{\s}{\p}}{\sQuotient{\s'}{\p'}} }

\end{mathpar}

\begin{lemma}
  If $\st{\G}{\s_1}{\s_2}$ then $\wf{\G}{\s_1}{\kSet}$ and $\wf{\G}{s_2}{\kSet}$.
\end{lemma}

\rulesec{Well-Formedness for Kinds}{\wfk{\G}{\k}}

\begin{mathpar}
\inferrule
  { }
  { \wfk{\G}{\kSet} }

\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \wfk{\G,\x{:}\s}{\k} }
  { \wfk{\G}{\kArrow{\x}{\s}{\k}} }

\end{mathpar}

\rulesec{Subtyping for Kinds}{\st{\G}{\k_1}{\k_2}}

\begin{mathpar}
\inferrule
  { }
  { \st{\G}{\kSet}{\kSet} }

\inferrule
  { \st{\G}{\s_2}{\s_1} \\
    \st{\G,\x{:}\s_2}{\k_1}{\k_2} }
  { \st{\G}{\kArrow{\x}{\s_1}{\k_1}}{\kArrow{\x}{\s_2}{\k_2}} }

\end{mathpar}

\begin{lemma}
  If $\st{G}{\k_1}{\k_2}$ then $\wfk{\G}{\k_1}$ and $\wfk{\G}{\k_2}$.
\end{lemma}

\rulesec{Equivalence for Kinds}{\eqvk{\G}{\k_1}{\k_2}}

\begin{mathpar}
\inferrule
  { }
  { \eqvk{\G}{\kSet}{\kSet} }

\inferrule
  { \eqv{\G}{\s_1}{\s_2}{\kSet} \\
    \eqvk{\G,\x{:}\s_1}{\k_1}{\k_2} }
  { \eqvk{\G}{\kArrow{\x}{\s_1}{\k_1}}{\kArrow{\x}{\s_2}{\k_2}} }

\end{mathpar}

\begin{lemma}
  If $\eqvk{G}{\k_1}{\k_2}$ then $\wfk{\G}{\k_1}$ and $\wfk{\G}{\k_2}$.
\end{lemma}
\clearpage

\rulesec{Well-Formedness for Models}{\wf{\G}{\M}{\T}}

\begin{mathpar}
\inferrule
  { \G(\x) = \T }
  { \wf{\G}{\x}{\T} }

\inferrule
  { \wf{\G}{\M}{\tTheory{\x_0{:}\decl_0,\cdots,\x_i{:}\T_i,\cdots}} }
  { \wf{\G}{\eMproj{\M}{\x_i}}{\T_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}]}}

\inferrule
  { \wf{\G}{\M_1}{\tArrow{\x}{\T_2}{\T}} \\
    \wf{\G}{\M_2}{\T_2} }
  { \wf{\G}{\sApp{\M_1}{\M_2}}{\subst{\T}{\x}{\M_2}} }

\end{mathpar}

\rulesec{Well-Formedness for Theories}{\wf{\G}{\T}{\tk}}

\begin{mathpar}

\inferrule
  { \G(\x) = \tk }
  { \wf{\G}{\x}{\tk} }

\inferrule
  { \wfelem{\G}{\elem_0} \\\\
    \vdots \\\\
    \wfelem{\G,\elem_0,\cdots,\elem_{n-2}}{\elem_{n-1}}
  }
  { \wf{\G}{\tTheory{\elem_0, \cdots, \elem_{n-1}}}{\tkModel}
  }

\inferrule
  { \wf{\G}{\T_1}{\tkModel} \\
    \wf{\G,\x{:}\T_1}{\T_2}{\tkModel} }
  { \wf{\G}{\tArrow{\x}{\T_1}{\T_2}}{\tkModel} }

\inferrule
  { \wf{\G}{\T_1}{\tkModel} \\
    \wf{\G,\x{:}\T_1}{\T_2}{\tk} }
  { \wf{\G}{\tLambda{\x}{\T_1}{\T_2}}{\tk} }

\inferrule
  { \wf{\G}{\T}{\tkArrow{\x}{\T_1}{\tk}} \\
    \wf{\G}{\M}{\T_1} }
  { \wf{\G}{\tApp{\T}{\M}}{\subst{\tk}{\x}{\M}} }

\end{mathpar}

\iffalse
\subsection{Well-Formedness for Theory Kinds}

\begin{mathpar}
\inferrule
  { }
  { \eqvk{\G}{\kSet}{\kSet} }

\inferrule
  { \eqv{\G}{\s_1}{\s_2}{\kSet} \\
    \eqvk{\G,\x{:}\s_1}{\k_1}{\k_2} }
  { \eqvk{\G}{\kArrow{\x}{\s_1}{\k_1}}{\kArrow{\x}{\s_2}{\k_2}} }

\end{mathpar}
\fi

\rulesec{Well-Formedness for Theory Elements}{\wfelem{\G}{\elem}}

\begin{mathpar}
\inferrule
  { \wf{\G}{\s}{\kSet} \\
    \langle \wf{\G}{\e}{\s} \rangle }
  { \wfelem{\G}{\x : \s \langle = \e\rangle} }

\inferrule
  { \wfk{\G}{\k} \\
    \langle \wf{\G}{\s}{\k} \rangle }
  { \wfelem{\G}{\x : \k \langle = \s\rangle} }

\inferrule
  { \wfpt{\G}{\pt} \\
    \langle \wf{\G}{\p}{\pt} \rangle }
  { \wfelem{\G}{\x : \pt \langle = \p\rangle} }

\inferrule
  { \wf{\G}{\T}{\tkModel} }
  { \wfelem{\G}{\x : \T } }

\inferrule
  { \wf{\G}{\T_1}{\tkModel}\\\\ \vdots \\\\
    \wf{\G,\X_1{:}\T_1,\ldots,\X_{n-2}{:}\T_{n-2}}{\T_{n-1}}{\tkModel}\\\\
    \wf{\G,\X_1{:}\T_1,\ldots,\X_{n-1}{:}\T_{n-1}}{\p}{\ptProp}  }
  { \wfelem{\G}{\x : \forall \X_1{:}\T_1,\ldots,\X_{n-1}{:}\T_{n-1}.\, \p} }
\end{mathpar}

\rulesec{Well-Formedness for Terms}{\wf{\G}{\e}{\s}}

\begin{mathpar}
\inferrule
  { }
  { \wf{\G}{\eUnit}{\sUnit} }

\inferrule
  { \G(\x) = \s }
  { \wf{\G}{\x}{\s} }

\inferrule
  { \wf{\G}{\M}{\tTheory{\x_0{:}\decl_0,\cdots,\x_i{:}\s_i\langle{{=}\e_i}\rangle,\cdots}} }
  { \wf{\G}{\eMproj{\M}{\x_i}}{\s_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}]}}

\inferrule
  {\wf{\G}{\e_1}{\s_1}\\ \cdots \\ \wf{\G}{\e_n}{\s_n} }
  {\wf{\G}{\eTuple{\e}{n}}{\sProduct{\cdot}{\s}{n}}}

\inferrule
  {0 \leq i < n\\\\
   \wf{\G}{\e}{\sProduct{\x}{\s}{n-1}} }
  {\wf{\G}{\eProj{i}{\e}}
      {\s_i[\x_0{\mapsto}\eProj{0}{\e}]\cdots[\x_{i-1}{\mapsto}\eProj{i-1}{\e}]}}

\inferrule
  { \wf{\G}{\s_1}{\kSet} \\
    \wf{\G,\x{:}\s_1}{\e_2}{\s_2} }
  { \wf{\G}{\eLambda{\x}{\s_1}{\e_2}}{\sArrow{\x}{\s_1}{\s_2}} }

\inferrule
  { \wf{\G}{\e_1}{\sArrow{\x}{\s_2}{\s}} \\
    \wf{\G}{\e_2}{\s_2} }
  { \wf{\G}{\eApp{\e_1}{\e_2}}{\s[\x{\mapsto}\e_2]} }

\inferrule
  { \langle \wf{\G}{\e}{\s} \rangle }
  { \wf{\G}{\eInj{\l}{\e}}{\l\langle{:}\s\rangle}}

\inferrule
  { n \ge 0 \\
    \l_0,\ldots,\l_{n-1} \mathrm{\ distinct} \\
    \wf{\G}{\s}{\kSet}\\\\
    \langle\wf{\G}{\s_0}{\kSet}\rangle \\
       \wf{\G\langle,\x_0{:}\s_0\rangle}{\e_0}{\s} \\
       \langle \x_0\not\in\mathop{\mathrm{FV}}\s \rangle \\\\
    \vdots\\\\
    \langle\wf{\G}{\s_{n-1}}{\kSet}\rangle \\
    \wf{\G\langle,\x_{n-1}{:}\s_{n-1}\rangle}{\e_{n-1}}{\s}\\
       \langle \x_{n-1}\not\in\mathop{\mathrm{FV}}\s \rangle\\\\
    \wf{\G}{\e}{\sSum{\x}{\s}{n-1}}
  }
  { \wf{\G}{\mathsf{match}\,\e\,\mathsf{with}\,
      \l_0\,\langle{\x_0{:}\s_0}\rangle{\leadsto} \e_0\ |\
       \cdots\ |\
      \l_{n-1}\,\langle{\x_{n-1}{:}\s_{n-}}\rangle{\leadsto} \e_{n-1}
      \,{:}\,\s}{\s}
  }

\inferrule
  { \pf{\G}{\pUnique{\x}{\s}{\p}} }
  { \wf{\G}{\eThe{\x}{\s}{\p}}{\sSubset{\x}{\s}{\p}} }

\inferrule
  { \wf{\G}{\e}{\sRz{\s}} }
  { \wf{\G}{\eRz{\e}}{\s} }

\inferrule
  { \wf{\G}{\e_1}{\s'_1} \\
    \eqv{\G}{\s_1}{\sRz{\s'_1}}{\kSet} \\\\
    \wf{\G,\x{:}\s_1}{\e_2}{\s_2} \\
    \x\not\in\mathop{\mathrm{FV}}\s_2\\\\
    \pf{\G}{\forall \x',\x''{:}\s_1.\ \subst{\e_2}{\x}{\x'} =_{\s_2} \subst{\e_2}{\x}{\x''}} }
  { \wf{\G}{\eRzChoose{\x}{\s_1}{\e_1}{\e_2}{\s_2}}{\s_2} }

\inferrule
  { \wf{\G}{\e}{\s} \\
    \wf{\G}{\p}{\ptEquiv{\s}} }
  { \wf{\G}{\eQuotient{\e}{\p}}{\sQuotient{\s}{\p}} }
%%%  Possibly doesn't have a principal type??
%%% No, it's ok as long as we have subtyping for quotients; just
%%%  take the type of e to be as specific as possible.

\inferrule
  { \wf{\G}{\e_1}{\sQuotient{\s_1}{\p}}\\
    \wf{\G,\x{:}\s_1}{\e_2}{\s_2}\\
    \x\not\in\mathop{\mathrm{FV}}\s_2\\\\
    \pf{\G}{\forall \x',\x''{:}\s_1.\ \pApp{\pApp{\p}{\x'}}{\x''}
               \Rightarrow
               \subst{\e_2}{\x}{\x'} =_{s_2} \subst{\e_2}{\x}{\x''} } }
  { \wf{\G}{\eChoose{\x}{\s_1}{\e_1}{\e_2}{\s_2}}{\s_2} }

\inferrule
  { \wf{\G}{\e_1}{\s_1} \\
    \wf{\G,\x{:}\s_1{\color{red}{=}\e_1}}{\e_2}{\s_2} \\
    \x\not\in\mathop{\mathrm{FV}}\s_2 }
  { \wf{\G}{\eLet{\x}{\s_1}{\e_1}{\e_2}{\s_2}}{\s_2} }

\inferrule
  { \wf{\G}{\e}{\s_1}\\
    \eqv{\G}{\s}{\sSubset{\x}{\s_1}{\p_2}}{\kSet} \\
    \pf{\G}{\subst{\p_2}{\x}{\e}} }
  { \wf{\G}{\eSubin{\e}{\s}}{\s} }

\inferrule
  { \wf{\G}{\e}{\sSubset{\x}{\s_1}{\p}} }
  { \wf{\G}{\eSubout{\e}{\s_1}}{\s_1} }

\inferrule
  { \wf{\G}{\p}{\ptStable}\\
    \pf{\G}{\p_1} \\
    \wf{\G{,\color{red}\p}}{\e}{\s} }
  { \wf{\G}{\eAssure{\p}{\e}}{\s} }

\inferrule
  { \wf{\G}{\e}{\s_1} \\
    \st{\G}{\s_1}{\s_2} }
  { \wf{\G}{\e}{\s_2} }

\end{mathpar}

\clearpage

\rulesec{Decidable Term Equivalence}{\deqv{\G}{\e_1}{\e_2}}

This section describes the \emph{decidable} term equivalence relation.
By construction, this is defined \emph{only} for well-formed terms of
the same type.

In addition to the obvious PER and congruence rules, we have:

\begin{mathpar}
\inferrule
  { }
  { \deqv{\G}{\eApp{(\eLambda{\x}{\s_2}{\e})}{\e_2}}
        {\e[\x{\mapsto}\e_2]}}

\inferrule
  { }
  { \deqv{\G}{(\eLet{\x}{\s_1}{\e_1}{\e_2}{\s_2})}
        {\e_2[\x{\mapsto}\e_1]} }

\inferrule
  { \wf{\G}{\M}{\tTheory{\x_0{:}\decl_0,\ldots,\x_i{:}\s_i{=}\e_i,\ldots}} }
  { \deqv{\G}{\eMproj{\M}{\x_i}}{(\e_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}])}  }

\inferrule
  {
  }
  { \deqv{\G}{\eProj{i}{\eTuple{\e}{n}}}{\e_i}{\s_i} }

\inferrule
  { 0 \leq i < n \\\\
    \e = {\mathsf{match}\,\eInj{\l_i}{\e'}\,\mathsf{with}\,
      \l_0\,\langle{\x_0{:}\s_0}\rangle{\leadsto} \e_0\ |\
       \cdots\ |\
      \l_{n-1}\,\langle{\x_{n-1}{:}\s_{n-}}\rangle{\leadsto} \e_{n-1}
      \,{:}\,\s}\\
  }
  { \deqv{\G}{\e}{\maybesubst{\e_i}{\x_i}{\e'}}
  }

\inferrule
  { }
  { \deqv{\G}{\eAssure{\p}{\e}}{\e} }

\end{mathpar}

{\color{blue} Question:  is it safe to substitute arbitrary expressions, or do we need a call-by-value restriction?  Same question applies to the substitutions in the typing/equivalence rules.}

\begin{lemma}
  If $\wf{\G}{\e_1}{\s}$ and $\wf{\G}{\e_2}{\s}$ and $\deqv{\G}{\e_1}{\e_2}$
then $\pf{\G}{\pEqual{\e_1}{\e_2}{\s}}$.
\end{lemma}

\rulesec{Decidable Proposition Equivalence}{\deqv{\G}{\p_1}{\p_2}}

This section describes the \emph{decidable} proposition equivalence relation.
By construction, this is defined \emph{only} for well-formed propositions of
the same proposition-type.

In addition to the obvious PER and congruence rules, we have:

\begin{mathpar}
\inferrule
  { }
  { \deqv{\G}{\pApp{(\pLambda{\x}{\s_2}{\p})}{\e_2}}
        {\p[\x{\mapsto}\e_2]}}

\inferrule
  { \wf{\G}{\M}{\tTheory{\x_0{:}\decl_0,\ldots,\x_i{:}\pt_i{=}\p_i,\ldots}} }
  { \deqv{\G}{\pMproj{\M}{\x_i}}{(\p_i[\x_0{\mapsto}\M.\x_0]\cdots[\x_{i-1}{\mapsto}\M.\x_{i-1}])}  }

\inferrule
  { 0 \leq i < n \\\\
    \p = {\mathsf{match}\,\eInj{\l_i}{\e'}\,\mathsf{with}\,
      \l_0\,\langle{\x_0{:}\s_0}\rangle{\leadsto} \p_0\ |\
       \cdots\ |\
      \l_{n-1}\,\langle{\x_{n-1}{:}\s_{n-}}\rangle{\leadsto} \p_{n-1}
      \,{:}\,\s}\\
  }
  { \deqv{\G}{\p}{\maybesubst{\p_i}{\x_i}{\e'}}
  }

\inferrule
  { }
  { \deqv{\G}{\eAssure{\p_1}{\p_2}}{\p_2} }
\end{mathpar}

\begin{lemma}
  If $\wf{\G}{\p_1}{\pt}$ and $\wf{\G}{\p_2}{\pt}$ and $\deqv{\G}{\p_1}{\p_2}$, then
\begin{enumerate}
\item $\pf{\G}{\pEquiv{\p_1}{\p_2}}$
\item $\p_1$ and $\p_2$ have equal realizers (with equal types).
\end{enumerate}
\end{lemma}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\unnumberedchapter{Abstract}
\chapter*{Abstract}

\subsection*{\thesistitle}

We introduce in this thesis two entanglement detection criteria, the \textit{Schr\"odinger-Robertson partial transpose inequality}, which can be implemented experimentally in a variety of systems and generalized \textit{$N$-qubit concurrences}, which can be used to evaluate multipartite entanglement in $N$-qubit mixed states. Then, we investigate ways to experimentally produce entanglement by giving a theoretical model which successfully describes the \textit{dipole blockade} effect. We study its possible applications in systems of two and three two-level atoms as well as its relations with the \textit{EIT} effect in systems of two three-level atoms. Finally, we show the possibility of two-photon processes in a system of two two-level atoms embedded in a cavity by using perturbation theory and a full master equation approach. We unveil interesting features of blockade and transparency in such \textit{cavity QED} systems.