\section{Introduction}

As a convenience to users, we provide a mechanism for declaring
nested coordinate systems.  This is particularly useful
for creating \emph{substructures} or \emph{subnets}.  Different
instances of a subnet may have the same relative placements
of nodes, but at different translations and orientations.

\section{Interface}

We support nested coordinate systems via a \emph{transformation stack}.
The entries in this stack data structures are all affine transformations that
take the current coordinate system to the global system.  New transformations
are \emph{composed} with the previous top-of-stack, so that if
$T_0$ is the current transformation to global coordinates and a
transformation $S$ is pushed onto the stack, then $T_0 S$ will
be the new transformation from current to global coordinates.

The transformation $T = Ax + b$ is given by a table of twelve entries
which represents the components of the matrix $[A; b]$ in column major
order.  A vector $x$ is given by a table with coordinate entries at
indices 1 to 3.  Note that the table can contain additional information
(e.g. a node name).  Part of the reason the transformation functions
overwrite the input vector table is so that entries besides those
at indices 1 to 3 can be retained unchanged.

The functions provided by this module are
\begin{itemize}
  \item {\tt{}xform{\char95}push(T)}: compose a transformation onto the stack
  \item {\tt{}xform{\char95}pop}: pop a level off the transformation stack
  \item {\tt{}top{\char95}xform(x)}: overwrite $x$ with $T_\mathit{top} x$,
        where $T_\mathit{top}$ is the top transform on the stack
  \item {\tt{}xform{\char95}apply(T,\ x)}: overwrite $x$ with $Tx$.
  \item {\tt{}xform{\char95}applyA(t,\ x)}: overwrite $x$ with $A_T x$,
        where $A_T$ is the linear part of the affine transform $T$.
  \item {\tt{}xform{\char95}compose(T,\ S)}: return $TS$
  \item {\tt{}xform{\char95}identity}: return the identity transform
  \item {\tt{}xform{\char95}ox(r),\ xform{\char95}oy(r),\ xform{\char95}oz(r)}:
        return right-handed rotations about the coordinate axes
  \item {\tt{}xform{\char95}translate(z)}: return a translation by the
        vector $z$
  \item {\tt{}subnet(f)}: return a function which creates a nested
        coordinate system according to any {\tt{}ox}, {\tt{}oy},
        and {\tt{}oz} parameters, calls {\tt{}f}, and then pops the
        nested coordinate system.
\end{itemize}

\section{Implementation}

\nwfilename{xformstack.nw}\nwbegincode{1}\sublabel{NWxfoD-xfoE-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-xfoE-1}}}\moddef{xformstack.lua~{\nwtagstyle{}\subpageref{NWxfoD-xfoE-1}}}\endmoddef
\LA{}data~{\nwtagstyle{}\subpageref{NWxfoD-dat4-1}}\RA{}
\LA{}functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}\RA{}
\nwnotused{xformstack.lua}\nwendcode{}\nwbegindocs{2}\nwdocspar

\subsection{The transform stack}

The size of the stack is maintained in the field $n$.

\nwenddocs{}\nwbegincode{3}\sublabel{NWxfoD-dat4-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-dat4-1}}}\moddef{data~{\nwtagstyle{}\subpageref{NWxfoD-dat4-1}}}\endmoddef
xform_stack = \{n = 0\};

\nwused{\\{NWxfoD-xfoE-1}}\nwendcode{}\nwbegindocs{4}\nwdocspar

Note that we compose new transformations onto the stack, interpreting
the transformation argument as a transformation into the current coordinates
instead of a transformation into the global coordinates.

\nwenddocs{}\nwbegincode{5}\sublabel{NWxfoD-fun9-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\endmoddef
function xform_push(T)
  local n = xform_stack.n + 1
  if n == 1 then
    xform_stack[n] = T
  else
    xform_stack[n] = xform_compose(xform_stack[n-1], T);
  end
  xform_stack.n = n;
end

\nwalsodefined{\\{NWxfoD-fun9-2}\\{NWxfoD-fun9-3}\\{NWxfoD-fun9-4}\\{NWxfoD-fun9-5}\\{NWxfoD-fun9-6}\\{NWxfoD-fun9-7}\\{NWxfoD-fun9-8}\\{NWxfoD-fun9-9}\\{NWxfoD-fun9-A}\\{NWxfoD-fun9-B}\\{NWxfoD-fun9-C}}\nwused{\\{NWxfoD-xfoE-1}}\nwendcode{}\nwbegindocs{6}\nwdocspar

\nwenddocs{}\nwbegincode{7}\sublabel{NWxfoD-fun9-2}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-2}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
function xform_pop()
  xform_stack.n = xform_stack.n - 1
end

\nwendcode{}\nwbegindocs{8}\nwdocspar

\nwenddocs{}\nwbegincode{9}\sublabel{NWxfoD-fun9-3}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-3}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
function top_xform(x)
  local n = xform_stack.n
  if n > 0 then
    return xform_apply(xform_stack[n], x)
  else
    return x
  end
end

\nwendcode{}\nwbegindocs{10}\nwdocspar

\subsection{Transformation functions}

\nwenddocs{}\nwbegincode{11}\sublabel{NWxfoD-fun9-4}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-4}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Overwrite x with Tx
function xform_apply(T, x)
  local y1 = T[1]*x[1] + T[4]*x[2] + T[7]*x[3] + T[10];
  local y2 = T[2]*x[1] + T[5]*x[2] + T[8]*x[3] + T[11];
  local y3 = T[3]*x[1] + T[6]*x[2] + T[9]*x[3] + T[12];
  x[1] = y1;
  x[2] = y2;
  x[3] = y3;
  return x;
end

\nwendcode{}\nwbegindocs{12}\nwdocspar

\nwenddocs{}\nwbegincode{13}\sublabel{NWxfoD-fun9-5}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-5}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Overwrite x with A_T * x
function xform_applyA(T, x)
  local y1 = T[1]*x[1] + T[4]*x[2] + T[7]*x[3];
  local y2 = T[2]*x[1] + T[5]*x[2] + T[8]*x[3];
  local y3 = T[3]*x[1] + T[6]*x[2] + T[9]*x[3];
  x[1] = y1;
  x[2] = y2;
  x[3] = y3;
  return x;
end

\nwendcode{}\nwbegindocs{14}\nwdocspar

Recall that
\[
  T(S(x)) = A_T (A_S x + b_S) + b_T = (A_T A_S) x + T(b_T)
\]

\nwenddocs{}\nwbegincode{15}\sublabel{NWxfoD-fun9-6}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-6}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Return TS
function xform_compose(T, S)
  local TS = \{\};
  for k = 1,4 do
    local base = 3*k-3;
    TS[base+1] = T[1]*S[base+1] + T[4]*S[base+2] + T[7]*S[base+3];
    TS[base+2] = T[2]*S[base+1] + T[5]*S[base+2] + T[8]*S[base+3];
    TS[base+3] = T[3]*S[base+1] + T[6]*S[base+2] + T[9]*S[base+3];
  end
  TS[10] = TS[10] + T[10];
  TS[11] = TS[11] + T[11];
  TS[12] = TS[12] + T[12];
  return TS;
end

\nwendcode{}\nwbegindocs{16}\nwdocspar

\nwenddocs{}\nwbegincode{17}\sublabel{NWxfoD-fun9-7}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-7}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Return the identity
function xform_identity()
  return \{ 1, 0, 0,
           0, 1, 0,
           0, 0, 1,
           0, 0, 0 \};
end

\nwendcode{}\nwbegindocs{18}\nwdocspar

Getting right hand rotations correct is always a trick.
Important note -- remember that the transformation matrix is
interpreted as column-major, but is ``typographically'' row
major.  So put on your transposing hat before reading the
following three functions.

\nwenddocs{}\nwbegincode{19}\sublabel{NWxfoD-fun9-8}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-8}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Return a rotation about the x axis
function xform_ox(r)
  local c = cos(r)
  local s = sin(r)
  return \{ 1,   0,  0,
           0,   c,  s,
           0,  -s,  c,
           0,   0,  0 \}
end

\nwendcode{}\nwbegindocs{20}\nwdocspar

\nwenddocs{}\nwbegincode{21}\sublabel{NWxfoD-fun9-9}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-9}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Return a rotation about the y axis
function xform_oy(r)
  local c = cos(r)
  local s = sin(r)
  return \{ c,   0, -s,
           0,   1,  0,
           s,   0,  c,
           0,   0,  0 \}
end

\nwendcode{}\nwbegindocs{22}\nwdocspar

\nwenddocs{}\nwbegincode{23}\sublabel{NWxfoD-fun9-A}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-A}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Return a rotation about the z axis
function xform_oz(r)
  local c = cos(r)
  local s = sin(r)
  return \{ c,   s,  0,
          -s,   c,  0,
           0,   0,  1,
           0,   0,  0 \}
end

\nwendcode{}\nwbegindocs{24}\nwdocspar

\nwenddocs{}\nwbegincode{25}\sublabel{NWxfoD-fun9-B}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-B}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
-- Return a translation
function xform_translate(z)
  return \{ 1,    0,    0,
           0,    1,    0,
           0,    0,    1,
           z[1], z[2], z[3] \}
end

\nwendcode{}\nwbegindocs{26}\nwdocspar

\subsection{{\tt{}node} and {\tt{}subnetize} functions}

We assume that node positions are expressed in the current coordinate
system (at least, that's what we assume for most purposes).
So the {\tt{}nodex} (``node transformed'') function transforms
the input coordinates from local to global, and them makes a node.

We still want to leave the option of expressing node coordinates
directly in the global coordinate system, though.  For instance,
we may want to put a node halfway between two other nodes which
have already been transformed into global coordinates.  For this
reason, we leave the {\tt{}node} function alone.

\nwenddocs{}\nwbegincode{27}\sublabel{NWxfoD-fun9-C}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-fun9-C}}}\moddef{functions~{\nwtagstyle{}\subpageref{NWxfoD-fun9-1}}}\plusendmoddef
function nodex(p)
  if p[1] then
    top_xform(p)
  end
  return node(p)
end

\nwendcode{}\nwbegindocs{28}\nwdocspar

\subsection{Test code}

\nwenddocs{}\nwbegincode{29}\sublabel{NWxfoD-xfoC-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-xfoC-1}}}\moddef{xformtst.lua~{\nwtagstyle{}\subpageref{NWxfoD-xfoC-1}}}\endmoddef
use("xformstack.lua")

\LA{}test transform constructors~{\nwtagstyle{}\subpageref{NWxfoD-tesR-1}}\RA{}
\LA{}test composition~{\nwtagstyle{}\subpageref{NWxfoD-tesG-1}}\RA{}
\nwnotused{xformtst.lua}\nwendcode{}\nwbegindocs{30}\nwdocspar

\nwenddocs{}\nwbegincode{31}\sublabel{NWxfoD-tesR-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-tesR-1}}}\moddef{test transform constructors~{\nwtagstyle{}\subpageref{NWxfoD-tesR-1}}}\endmoddef
-- First check out the basics

rx45 = xform_ox(45)
ry45 = xform_oy(45)
rz45 = xform_oz(45)
trans = xform_translate \{1, 2, 3\}

x1 = xform_apply(rx45,  \{1, 0, 0\})
x2 = xform_apply(ry45,  \{1, 0, 0\})
x3 = xform_apply(rz45,  \{1, 0, 0\})
x4 = xform_apply(trans, \{1, 0, 0\})
x5 = xform_applyA(trans, \{1, 0, 0\})

print("Rotate e1 by rx45: ",     x1[1], x1[2], x1[3])
print("Rotate e1 by ry45: ",     x2[1], x2[2], x2[3])
print("Rotate e1 by rz45: ",     x3[1], x3[2], x3[3])
print("Translate e1 by 1,2,3: ", x4[1], x4[2], x4[3])
print("Apply A e1 by 1,2,3: ",   x5[1], x5[2], x5[3])

\nwused{\\{NWxfoD-xfoC-1}}\nwendcode{}\nwbegindocs{32}\nwdocspar

\nwenddocs{}\nwbegincode{33}\sublabel{NWxfoD-tesG-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWxfoD-tesG-1}}}\moddef{test composition~{\nwtagstyle{}\subpageref{NWxfoD-tesG-1}}}\endmoddef
-- Now check out composition

T = xform_compose(trans, rz45)
x = xform_apply(T, \{1, 0, 0\})

print("Rotate then translate: ", x[1], x[2], x[3])

undoT = xform_compose(xform_oz(-45), xform_translate\{-1,-2,-3\})
xform_apply(undoT, x)

print("After undo operation: ", x[1], x[2], x[3])

\nwused{\\{NWxfoD-xfoC-1}}\nwendcode{}

\nwixlogsorted{c}{{data}{NWxfoD-dat4-1}{\nwixu{NWxfoD-xfoE-1}\nwixd{NWxfoD-dat4-1}}}%
\nwixlogsorted{c}{{functions}{NWxfoD-fun9-1}{\nwixu{NWxfoD-xfoE-1}\nwixd{NWxfoD-fun9-1}\nwixd{NWxfoD-fun9-2}\nwixd{NWxfoD-fun9-3}\nwixd{NWxfoD-fun9-4}\nwixd{NWxfoD-fun9-5}\nwixd{NWxfoD-fun9-6}\nwixd{NWxfoD-fun9-7}\nwixd{NWxfoD-fun9-8}\nwixd{NWxfoD-fun9-9}\nwixd{NWxfoD-fun9-A}\nwixd{NWxfoD-fun9-B}\nwixd{NWxfoD-fun9-C}}}%
\nwixlogsorted{c}{{test composition}{NWxfoD-tesG-1}{\nwixu{NWxfoD-xfoC-1}\nwixd{NWxfoD-tesG-1}}}%
\nwixlogsorted{c}{{test transform constructors}{NWxfoD-tesR-1}{\nwixu{NWxfoD-xfoC-1}\nwixd{NWxfoD-tesR-1}}}%
\nwixlogsorted{c}{{xformstack.lua}{NWxfoD-xfoE-1}{\nwixd{NWxfoD-xfoE-1}}}%
\nwixlogsorted{c}{{xformtst.lua}{NWxfoD-xfoC-1}{\nwixd{NWxfoD-xfoC-1}}}%
\nwbegindocs{34}\nwdocspar

\nwenddocs{}


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

\marginpar{Wednesday\\ 2020-11-18, \\ compiled \\ \today}

Recall that
%
\begin{align}
\Sigma = \num{5.2} \alpha^{-4/5} \dot{M}_{16}^{7/10} M^{1/4} R^{-3/4} \SI{}{g / cm^2}
\,.
\end{align}

Is it true that \(M_d = M _{\text{disk}} \ll M\), as we assumed?
We can calculate it as
%
\begin{align}
M_d &= \int_{R _{\text{in}}}^{R _{\text{max}}} 2 \pi R \Sigma \dd{R}  \\
&\approx \num{e-8} \alpha^{-4/5} M_{16}^{7/10} M^{1/2} M_{\odot}
\,,
\end{align}
%
assuming that \(R _{\text{max}} \approx 10 R _{\text{in}}\).
This is indeed many orders of magnitude below the mass of the stellar source.

\subsubsection{Regions of the disk}

The \(\alpha \) parameter comes from the very rough assumption \(\nu _{\text{turb}} = \alpha c_s H\), it is a weak point of this model.
Asking that \(\alpha = \const\) is just plain wrong.

Further, we assumed that \(P = P _{\text{gas}}\), and that the Rosseland mean opacity \(\kappa _R\) is only given by free-free absorption.

We know that for Thompson scattering the cross-section is \(\kappa _R^{s} = \sigma _T / m_p = \SI{.4}{cm^2 / g}\).
When is this smaller than the free-free opacity? In dimensionless terms, the equation for \(\kappa = \tau / \Sigma \) reads
%
\begin{align}
\kappa_{R}^{\text{ff}} &> \kappa_R^{s} \\
\num{6.3} \dot{M}_{16}^{-1/2} M^{1/4} R_{10}^{-3/4} f^2 &> \num{.4}  \\
R_{10} &> \num{.5e-2} \dot{M}_{16}^{2/3} M^{1/3} f^{8/3} \\
R &> \num{.5e8} \dot{M}_{16}^{2/3} M^{1/3} f^{8/3} \SI{}{cm}
\,.
\end{align}

For a white dwarf, this is always the case; we can tell in general that for \(R \lesssim \SI{e8}{cm}\) electron scattering dominates.

The temperature decreases with radius as \(T \propto R^{-3/2}\), so for high enough radii it can drop below \SI{e4}{K}, at which point recombination can occur: at that point free-free absorption cannot occur anymore, and we must account for free-bound and bound-bound transitions.

If a NS or a BH is accreting, on the other hand, we can have a scattering-dominated internal region.

So, in terms of the \textbf{main type of matter-radiation interaction} we will have three regions: going outwards, there is domination of electron scattering, free-free absorption, bound-free/bound-bound absorption.

Does \(P _{\text{gas}}\) dominate over \(P _{\text{rad}}\)? their ratio is indeed
%
\begin{align}
\frac{P _{\text{rad}}}{P _{\text{gas}}} = \frac{ \frac{1}{3} a T^{4}}{\frac{k T_c \Sigma H}{\mu m_p}} \approx \num{3e-3} \alpha^{1/10} \dot{M}_{16}^{7/10} R_{10}^{-3/8} f^{7/5} \ll 1
\,.
\end{align}

As \(R\) decreases, \(P _{\text{rad}}\) becomes ever more relevant.
Is there an equality radius? It will definitely be smaller than \SI{3e8}{cm}.
Doing the calculation, we find
%
\begin{align}
R  _{\text{equality}} \approx \num{24} \alpha^{2/21} \dot{M}_{16}^{16/21} f^{9/21} \SI{}{km}
\,.
\end{align}

This may sometimes be attained in the innermost region of the disk, right before the ISCO.

So, in terms of the \textbf{nature of most of the pressure}, we may have a radiation-dominated region in the innermost part of the disk, but mostly there will be gas pressure domination.

\paragraph{The shape of the disk}

We calculate the shape of the disk, \(H(R)\), in the innermost radiation-dominated region.
The sound speed under radiation domination is
%
\begin{align}
c_s^2 = \frac{P}{\rho } = \frac{1}{3} \frac{a T_c^{4}}{\rho} = \frac{1}{3} \frac{4 \sigma }{c} \frac{T_c^{4}}{\rho }
\,,
\end{align}
%
and we know that
%
\begin{align}
\frac{4}{3} \frac{\sigma T_c^{4}}{\tau } = \frac{3 GM \dot{M}}{8 \pi R^3} f
\,,
\end{align}
%
which means that
%
\begin{align}
c_s^2 = \frac{3 GM \dot{M} \tau f}{8 \pi R^3 \rho c}
\,,
\end{align}
%
and using the fact that, for scattering opacity domination,
%
\begin{align}
\tau = \kappa _R^{s} \Sigma = \frac{\sigma _T}{m_p} \rho H
\,,
\end{align}
%
we find
%
\begin{align}
c_s^2 =
\frac{3 GM \dot{M} \sigma _T \rho H f}{8 \pi R^3 \rho  c m_p} =
\frac{3 GM \dot{M} \sigma _T  H f}{8 \pi R^3   c m_p}
\,,
\end{align}
%
but we also know that \(H = c_s R (R / GM)^{1/2}\); using this fact we can calculate the sound speed \(c_s = (H/R)(GM/R)^{1/2} \).
Using this (see equation \eqref{eq:speed-of-sound-disk-shape}), we get
%
\begin{align}
\frac{H^2}{R^2} \frac{GM}{R} &= \frac{3 GM \dot{M} \sigma _T  H f}{8 \pi R^3   c m_p} \\
H &= \frac{3 \sigma _T \dot{M} }{8 \pi c m_p}f
\,,
\end{align}
%
which is nearly independent of \(R\): the only dependence is inside the factor \(f\), which depends on \(R\) quite weakly.
The shape of the disk is slab-like in the inner region, and concave in the outer part but still quite flat.

\paragraph{The Eddington limit}

The Eddington luminosity for electron scattering is
%
\begin{align}
L _{\text{Edd}} = \frac{4 \pi G M m_p c}{\sigma _T}
\,,
\end{align}
%
and the corresponding accretion rate is \(\dot{M} _{\text{Edd}} = L _{\text{Edd}} / c^2\).

The critical accretion rate is the one which produces an Eddington luminosity, after accounting for efficiency:
%
\begin{align}
\eta \dot{M} _{\text{crit}} c^2 = L _{\text{Edd}}
\,,
\end{align}
%
so \(\dot{M} _{\text{crit}}\) is larger than \(\dot{M} _{\text{Edd}}\).
Using this, the height of the disk is given by
%
\begin{align}
H &= \frac{3}{2} \dot{M} f \frac{\sigma _T}{4 \pi c m_p } = \frac{3}{2} \dot{M} f \frac{GM}{L _{\text{Edd}}} \\
&= \frac{3}{2} \underbrace{\frac{GM}{R _{\text{in}}c^2}}_{\eta } R _{\text{in}} \frac{\dot{M}}{\dot{M} _{\text{Edd}}} f  \\
&= \frac{3}{2} \eta R _{\text{in}} \frac{\dot{M}}{\dot{M} _{\text{Edd}}} f
\,,
\end{align}
%
so
%
\begin{align}
\frac{H}{R _{\text{in}}} = \frac{3}{2} \frac{\dot{M}}{\dot{M} _{\text{crit}}} f
\,,
\end{align}
%
and we can see that \(H < R _{\text{in}}\) iff \(\dot{M} < M _{\text{crit}}\).
Then, we see that \textbf{the accretion rate must be subcritical as long as we want to keep the disk thin}.

\subsection{The multicolor blackbody}

A final point about disks: each layer of the disk emits roughly a blackbody, which means that the total spectrum is a superposition of several blackbodies, this is called a multicolor blackbody.

The spectrum emitted by each annulus, as usual, is described by a  Planck function:
%
\begin{align}
I_\nu = \frac{2h}{c^2} \frac{\nu^3}{\exp(\frac{h \nu }{k_B T}) - 1}
\,,
\end{align}
%
as long as there is no reprocessing of the radiation from stuff around the disk.
This is an interesting process, but for simplicity we will not discuss it.

What we measure is the flux:
%
\begin{align}
F_\nu = \int_{4 \pi } I_\nu \cos \theta \dd{\Omega }
\,,
\end{align}
%
where \(\dd{\Omega } = 2 \pi R \dd{R}/D^2\), where \(D\) is the distance from us.
The integral to compute is
%
\begin{align}
F_\nu = \frac{2 \pi }{D^2} \cos \iota \int_{R _{\text{in}}}^{R _{\text{out}}} R \dd{R} \frac{\nu^3}{\exp(\frac{h \nu }{k_B T(R)}) - 1}
\,.
\end{align}

This integral can be computed numerically, but we can already gather its main characteristics.
As we have seen earlier \eqref{eq:temperature-accretion-disk}, the temperature looks like
%
\begin{align}
T(R) = T _{\text{in}} \qty( \frac{R _{\text{in}}}{R})^{3/4}
\,.
\end{align}

Let us now estimate the integral in three limits, comparing \(h \nu     \) to \(k_B T(R _{\text{in}})\) and \(k_B T (R _{\text{out}})\) respectively.

The first interesting limit is the low-energy one: \(h \nu \ll k_B T (R _{\text{out}}) < k_B T(R)\) for any \(R\).
Then, the flux is proportional to
%
\begin{align}
F_\nu \propto \int R \dd{R} \frac{\nu^3}{h \nu / k_B T(R)}
\propto \nu^2 \int T(R) R \dd{R}
\propto \nu^2
\,.
\end{align}

The opposite, high energy limit \(h \nu \gg k_B T(R _{\text{in}})\) yields an exponential cutoff, since the contribution of the exponential \(e^{-h \nu / k_B T(R)}\) of the term in the integral with \(T = T _{\text{in}}\) is dominant
%
\begin{align}
F_\nu \propto \nu^3 \exp(- \frac{h \nu }{k_B T _{\text{in}}})
\,.
\end{align}

In the intermediate region, \(k_B T _{\text{out}} < h \nu < k_B T _{\text{in}}\).

Defining \(x = h \nu / k_B T(R)\), we find
%
\begin{align}
F_\nu \propto \int \frac{\nu^3 }{e^{x} - 1} R \dd{R}
\,,
\end{align}
%
but \(x \propto \nu / T \propto \nu R^{3/4}\), therefore \(R \propto x^{4/3} \nu^{-4/3}\), which means that (since \(\nu \) is constant in the context of the integral) \(\dd{R} \propto x^{1/3} \nu^{-4/3} \dd{x}\)
%
\begin{align}
F_\nu \propto \int \frac{\nu^3 \nu^{-8/3}}{e^{x}-1} x^{5/3} \dd{x}
\,,
\end{align}
%
which means that
%
\begin{align}
F_\nu \propto \nu^{1/3} \int \frac{x^{5/3}}{e^{x}-1} \dd{x}
\,.
\end{align}

The integral is approximately one from 0 to \(\infty \), a number.
The \(F \propto \nu^{1/3}\) signature intermediate region is a characteristic of accretion disks.

\end{document}


\subsection{Data field values}
\label{subsec:library_of_transformations:instance_level_transformations:data_field_values}

\begin{figure}
    \centering
    \begin{subfigure}{0.45\textwidth}
        \centering
        \includegraphics{images/05_library_of_transformations/03_instance_level_transformations/06_data_field_values/data_field_value.pdf}
        \caption{$Im_{DataField}$ with one object and string value ``some value''}
        \label{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:ecore}
    \end{subfigure}
    \begin{subfigure}{0.45\textwidth}
        \centering
        \input{images/05_library_of_transformations/03_instance_level_transformations/06_data_field_values/data_field_as_edge_type_value.tikz}
        \caption{$IG_{DataField}$ with one node and string value ``some value''}
        \label{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:groove}
    \end{subfigure}
    \caption{Visualisation of the transformation of field values from fields typed by data types}
    \label{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation}
\end{figure}

The previous sections have shown the instance level transformations of the introduction of all kinds of types and their instances. From this section onward, these types and their instances will be enriched by introducing fields. In this section, the instance level transformation belonging to the transformation of a data field is discussed. The type level transformation for data fields can be found in \cref{subsec:library_of_transformations:type_level_transformations:data_fields}. On the instance level, values for the data fields are introduced.

\begin{defin}[Instance model $Im_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field}
Let $Im_{DataField}$ be an instance model typed by $Tm_{DataField}$ (\cref{defin:library_of_transformations:type_level_transformations:data_fields:tmod_data_field}). Define a set $objects$, which represent the objects that will get a value for the field introduced by $Tm_{DataField}$. Furthermore, define a function $obids$ which maps each of these objects to their corresponding identifier and a function $values$, which maps each of these objects to its value for the field introduced by $Tm_{DataField}$. $Im_{DataField}$ is defined as:
\begin{align*}
Object =\ &objects \\
\mathrm{ObjectClass} =\ & \begin{cases}
    (ob, classtype) & \mathrm{if }\ ob \in objects
\end{cases}\\
\mathrm{ObjectId} =\ & \begin{cases}
    (ob, obids(ob)) & \mathrm{if }\ ob \in objects
\end{cases}\\
\mathrm{FieldValue} =\ & \begin{cases}
    ((ob, (classtype, name)), values(ob)) & \mathrm{if }\ ob \in objects
\end{cases} \\
\mathrm{DefaultValue} =\ & \{\}
\end{align*}
\isabellelref{imod_data_field}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{defin}

\begin{thm}[Correctness of $Im_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_correct}
$Im_{DataField}$ (\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field}) is a valid instance model in the sense of \cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.
\isabellelref{imod_data_field_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{thm}

A visual representation of $Im_{DataField}$ with $objects = \{ob\}$ and $obids(ob) = someId$ can be seen in \cref{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:ecore}. In this visualisation, the field value for $ob$ is defined as $values(ob) = \text{``some value''}$. Although this visualisation only shows one object, it is required to define a value for all objects that contain the field. Failing to do so would result in an invalid instance model after it is combined with another model, as the next definition will show. The correctness proof of $Im_{DataField}$ only is already quite involved, but not be included here for conciseness. It can be found as part of the validated Isabelle proofs.

In order to make composing transformation functions possible, $Im_{DataField}$ should be compatible with the instance model it is combined with.

\begin{thm}[Correctness of $\mathrm{combine}(Im, Im_{DataField})$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_combine_correct}
Assume an instance model $Im$ that is valid in the sense of \cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}. Then $Im$ is compatible with $Im_{DataField}$ (in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:compatibility}) if:
\begin{itemize}
    \item All requirements of \cref{defin:library_of_transformations:type_level_transformations:data_fields:tmod_data_field_combine_correct} are met, to ensure the combination of the corresponding type models is valid;
    \item The class type on which the field is defined by $Tm_{DataField}$ may not be extended by another class type in the type model corresponding to $Im$;
    \item All of the objects in the set $objects$ must already be objects in $Im$;
    \item All objects typed by the class type on which the field is defined must occur in the set $objects$ and thus have a value in $Im_{DataField}$;
    \item For all of the objects in the set $objects$, the identifier set by $obids$ must be the same identifier as set by $Im$ for that object;
    \item For all objects in set $objects$, the value set by the $values$ function must be valid.
\end{itemize}
\isabellelref{imod_data_field_combine_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{thm}

\begin{proof}
Use \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_merge_correct}. It is possible to show that all assumptions hold. Now we have shown that $\mathrm{combine}(Im, Im_{DataField})$ is consistent in the sense of \cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.
\end{proof}

As explained earlier, $Im_{DataField}$ needs to introduce values for all objects that are typed by the class type on which the field is defined. This is enforced by the requirements of \cref{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_combine_correct}. The proof is not included here for conciseness, but can be found as part of the validated proofs in Isabelle.

The definitions and theorems for introducing values for fields of data types within Ecore are now complete.

\subsubsection{Encoding as edges and nodes}

In the type level transformation of data fields, data fields were encoded in GROOVE as edge types to an primitive type. On the instance level, this edge type will be used and edges will be created to give a value to each node type that has the field defined. The encoding corresponding to $Im_{DataField}$ can then be represented as $IG_{DataField}$, defined in the following definition:

\begin{defin}[Instance graph $IG_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type}
Let $IG_{DataField}$ be the instance graph typed by type graph $TG_{DataField}$ (\cref{defin:library_of_transformations:type_level_transformations:data_fields:tg_data_field_as_edge_type}). Reuse the set $objects$ from $Im_{DataField}$. Moreover, reuse the functions $obids$ and $values$ from $Im_{DataField}$.
The objects in the set $objects$ are converted to nodes in $Im_{DataField}$. For each of these objects, an edge of the encoded field is created. This edge targets a node that corresponds to the value set by $values$ for the corresponding object. Finally, the identity of the objects is defined using $obids$. $IG_{DataField}$ is defined as:
\begin{align*}
N =\ & objects \cup \{values(ob) \mid ob \in objects\} \\
E =\ & \big\{\big(ob, (\mathrm{ns\_\!to\_\!list}(classtype), \langle name \rangle, fieldtype), values(ob)\big) \mid ob \in objects \big\} \\
\mathrm{ident} =\ & \begin{cases}
    (obids(ob), ob) & \mathrm{if }\ ob \in objects
\end{cases}
\end{align*}
with
\begin{align*}
\mathrm{type}_n =\ & \begin{cases}
    (ob, \mathrm{ns\_\!to\_\!list}(classtype)) & \mathrm{if }\ ob \in objects
\end{cases}
\end{align*}
\isabellelref{ig_data_field_as_edge_type}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{defin}

\begin{thm}[Correctness of $IG_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_correct}
$IG_{DataField}$ (\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type}) is a valid instance graph in the sense of \cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}.
\isabellelref{ig_data_field_as_edge_type_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{thm}

A visual representation of $IG_{DataField}$ with $objects = \{ob\}$ and $obids(ob) = someId$ can be seen in \cref{fig:library_of_transformations:instance_level_transformations:data_field_values:visualisation:groove}. Like the previous visualisation, the field value for $ob$ is defined as $values(ob) = \text{``some value''}$. Although this visualisation only shows one node, it is required to define a value for all nodes typed by the node type corresponding to the field. Failing to do so would result in an invalid instance graph after it is combined with another graph, as the next definition will show. The correctness proof of $IG_{DataField}$ only is already quite involved, but not be included here for conciseness. It can be found as part of the validated Isabelle proofs.

In order to make composing transformation functions possible, $IG_{DataField}$ should be compatible with the instance graph it is combined with.

\begin{thm}[Correctness of $\mathrm{combine}(IG, IG_{DataField})$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_combine_correct}
Assume an instance graph $IG$ that is valid in the sense of \cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}. Then $IG$ is compatible with $IG_{DataField}$ (in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:compatibility}) if:
\begin{itemize}
    \item All requirements of \cref{defin:library_of_transformations:type_level_transformations:data_fields:tg_data_field_as_edge_type_combine_correct} are met, to ensure the combination of the corresponding type graphs is valid;
    \item The node type on which the corresponding field is defined is not extended by other node types within the type graph corresponding to $IG$;
    \item All nodes in $IG$ that are typed by the node type on which the field is defined are also nodes in $IG_{DataField}$;
    \item For all nodes shared between $IG$ and $IG_{DataField}$, each node must have the same identifier in both $IG$ and $IG_{DataField}$;
    \item For all nodes for which the field is set, the $values$ function must define a valid value;
    \item If an primitive type has incoming or outgoing edge types in the type graph corresponding to $IG$, then the lower multiplicity of these edge types must be 0.
\end{itemize}
\isabellelref{ig_data_field_as_edge_type_combine_correct}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{thm}

\begin{proof}
Use \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:ig_combine_merge_correct}. It is possible to show that all assumptions hold. Now we have shown that $\mathrm{combine}(IG, IG_{DataField})$ is valid in the sense of \cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}.
\end{proof}

Like the definition for the combination of instance models, the combination of instance graphs also requires the user to set a value for all nodes that are typed by the node type that corresponds to the field type. This is to keep the graph valid.

The next definitions define the transformation function from $Im_{DataField}$ to $IG_{DataField}$:

\begin{defin}[Transformation function $f_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_to_ig_data_field_as_edge_type}
The transformation function $f_{DataField}(Im)$ is defined as:
\begin{align*}
N =\ & Object_{Im} \cup \{values(ob) \mid ob \in Object_{Im}\}  \\
E =\ & \big\{\big(ob, (\mathrm{ns\_\!to\_\!list}(classtype), \langle name \rangle, fieldtype), values(ob)\big) \mid ob \in Object_{Im} \big\} \\
\mathrm{ident} =\ & \begin{cases}
    (obids(ob), ob) & \mathrm{if }\ ob \in Object_{Im}
\end{cases}
\end{align*}
with
\begin{align*}
\mathrm{type}_n =\ & \begin{cases}
    (ob, \mathrm{ns\_\!to\_\!list}(name)) & \mathrm{if }\ ob \in Object_{Im}
\end{cases}
\end{align*}
\isabellelref{imod_data_field_to_ig_data_field_as_edge_type}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{defin}

\begin{thm}[Correctness of $f_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_to_ig_data_field_as_edge_type_func}
$f_{DataField}(Im)$ (\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:imod_data_field_to_ig_data_field_as_edge_type}) is a valid transformation function in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph} transforming $Im_{DataField}$ into $IG_{DataField}$.
\isabellelref{imod_data_field_to_ig_data_field_as_edge_type_func}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{thm}

The proof of the correctness of $f_{DataField}$ will not be included here. Instead, it can be found in the validated Isabelle theories.

Finally, to complete the transformation, the transformation function that transforms $IG_{DataField}$ into $Im_{DataField}$ is defined:

\begin{defin}[Transformation function $f'_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_to_imod_data_field}
The transformation function $f'_{DataField}(IG)$ is defined as:
\begin{align*}
Object =\ &\{\mathrm{src}(e) \mid e \in E_{IG}\} \\
\mathrm{ObjectClass} =\ & \begin{cases}
    (ob, classtype) & \mathrm{if }\ ob \in \{\mathrm{src}(e) \mid e \in E_{IG}\}
\end{cases}\\
\mathrm{ObjectId} =\ & \begin{cases}
    (ob, obids(ob)) & \mathrm{if }\ ob \in \{\mathrm{src}(e) \mid e \in E_{IG}\}
\end{cases}\\
\mathrm{FieldValue} =\ & \begin{cases}
    ((ob, (classtype, name)), values(ob)) & \mathrm{if }\ ob \in \{\mathrm{src}(e) \mid e \in E_{IG}\}
\end{cases} \\
\mathrm{DefaultValue} =\ & \{\}
\end{align*}
\isabellelref{ig_data_field_as_edge_type_to_imod_data_field}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{defin}

\begin{thm}[Correctness of $f'_{DataField}$]
\label{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_to_tmod_class_func}
$f'_{DataField}(IG)$ (\cref{defin:library_of_transformations:instance_level_transformations:data_field_values:ig_data_field_as_edge_type_to_imod_data_field}) is a valid transformation function in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model} transforming $IG_{DataField}$ into $Im_{DataField}$.
\isabellelref{ig_data_field_as_edge_type_to_imod_data_field_func}{Ecore-GROOVE-Mapping-Library.DataFieldValue}
\end{thm}

Once more, the correctness proof is not included here but can be found in the validated Isabelle proofs of this thesis.


\section{Dimension reduction}

\begin{figure}[H]
\includegraphics[width=1.0\textwidth,height=0.9\textheight,keepaspectratio]{{{\runDir/pcaElbow}}}
\caption{Scree plot showing proportion of variance explained by each PCA component}
\end{figure}

\begin{figure}[H]
\includegraphics[width=1.0\textwidth,height=0.9\textheight,keepaspectratio]{{{\runDir/pcaJackStraw}}}
\caption{Seurat Jack Straw analysis of PCA components}
\end{figure}

\begin{figure}[H]
\includegraphics[width=1.0\textwidth,height=0.9\textheight,keepaspectratio]{{{\runDir/pcaComponents}}}
\caption{Heatmaps of the top genes for each PCA component}
\end{figure}


\chapter{Graphs}

\textbf{Erdos-Gallai:} $d_1\geq\cdots\geq d_n$ can be degree sequence of simple graph on $n$ vertices iff their sum is even and $\sum_{i=1}^{k}d_{i}\leq k(k-1)+\sum _{i=k+1}^{n}\min(d_{i},k), \forall 1\le k\le n.$

\section{Cycles}
	\kactlimport{Basics/DirectedCycle.h}
	\kactlimport{Basics/NegativeCycle (7.3).h}

\section{DSU}
	\kactlimport{DSU/DSU (7.6).h}

\section{Trees}
	\kactlimport{Trees (10)/LCAjump (10.2).h}
	\kactlimport{Trees (10)/LCArmq (10.2).h}
	\kactlimport{Trees (10)/HLD (10.3).h}
	\kactlimport{Trees (10)/Centroid (10.3).h}

	\subsection{SqrtDecompton}

		HLD generally suffices. If not, here are some common strategies:

		\begin{itemize}
			\item Rebuild the tree after every $\sqrt N$ queries. % https://codeforces.com/contest/1254/submission/65439802
			\item Consider vertices with $>$ or $<\sqrt N$ degree separately. % https://codeforces.com/contest/1254/submission/65437007
			\item For subtree updates, note that there are $O(\sqrt N)$ distinct sizes among child subtrees of any node.
		\end{itemize}

		\textbf{Block Tree:} Use a DFS to split edges into contiguous groups of size $\sqrt N$ to $2\sqrt N.$

		\textbf{Mo's Algorithm for Tree Paths:} Maintain an array of vertices where each one appears twice, once when a DFS enters the vertex (\texttt{st}) and one when the DFS exists (\texttt{en}). For a tree path $u\leftrightarrow v$ such that \texttt{st[u]<st[v]},

		\begin{itemize}
		\item If $u$ is an ancestor of $v,$ query \texttt{[st[u],st[v]]}.
		\item Otherwise, query $\texttt{[en[u],st[v]]}$ and consider $LCA(u,v)$ separately.
		\end{itemize}

		Solutions with worse complexities can be faster if you optimize the operations that are performed most frequently. Use arrays instead of vectors whenever possible. Iterating over an array in order is faster than iterating through the same array in some other order (ex. one given by a random permutation) or DFSing on a tree of the same size. Also, the difference between $\sqrt N$ and the optimal block (or buffer) size can be quite large. Try up to 5x smaller or larger (at least).

		% ex. GP of Nanjing 2020 K

\section{DFS Algorithms}

	% \kactlimport{DFS/SCC (12.1).h}
	\kactlimport{DFS/EulerPath (12.2).h}
	\kactlimport{DFS/SCCT.h}
	\kactlimport{DFS/TwoSAT (12.1).h}
	\kactlimport{DFS/BCC (12.4).h}
	\kactlimport{DFS/MaximalCliques.h}

\section{Flows}

	\textbf{Konig's Theorem:} In a bipartite graph, max matching = min vertex cover.

	\textbf{Dilworth's Theorem:} For any partially ordered set, the sizes of the max antichain and of the min chain decomposition are equal. Equivalent to Konig's theorem on the bipartite graph $(U,V,E)$ where $U=V=S$ and $(u,v)$ is an edge when $u<v$. Those vertices outside the min vertex cover in both $U$ and $V$ form a max antichain.

	% Wikipedia, https://codeforces.com/gym/102428/problem/A, https://maps20.kattis.com/problems/maps20.thewrathofkahn

	\kactlimport{Flows (12.3)/Dinic.h}
	\kactlimport{Flows (12.3)/GomoryHu.h}
	\kactlimport{Flows (12.3)/MCMF.h}

	% \kactlimport{Flows (12.3)/GlobalMinCut.h}

\section{Matching}

	% \kactlimport{Matching/DFSmatch.h}
	\kactlimport{Matching/Hungarian.h}
	\kactlimport{Matching/UnweightedMatch.h}
	\kactlimport{Matching/WeightedMatch.h}
	\kactlimport{Matching/MaxMatchLexMin.h}
	\kactlimport{Matching/MaxMatchFast.h}
	% \kactlimport{Matching/MaxMatchHeuristic.h}
	% \kactlimport{Matching/UnweightedMatch2.h}

\section{Advanced}

	% \kactlimport{Advanced/MaxClique.h}
	\kactlimport{Advanced/ChordalGraphRecognition.h}
	\kactlimport{Advanced/DominatorTree.h}
	\kactlimport{Advanced/EdgeColor.h}
	\kactlimport{Advanced/DirectedMST.h}
	\kactlimport{Advanced/LCT.h}
	\kactlimport{Advanced/TopTree.h}


\documentclass[11pt]{scrartcl} % Font size
\input{../structure.tex} % Include the file specifying the document structure and custom commands

%----------------------------------------------------------------------------------------
%	TITLE SECTION
%----------------------------------------------------------------------------------------

\title{
	\normalfont\normalsize
	\textsc{Harvard Privacy Tools Project}\\ % Your university, school and/or department name(s)
	\vspace{25pt} % Whitespace
	\rule{\linewidth}{0.5pt}\\ % Thin top horizontal rule
	\vspace{20pt} % Whitespace
	{\huge Mean Sensitivity Proofs}\\ % The assignment title
	\vspace{12pt} % Whitespace
	\rule{\linewidth}{2pt}\\ % Thick bottom horizontal rule
	\vspace{12pt} % Whitespace
}

% \author{\LARGE} % Your name

\date{\normalsize\today} % Today's date (\today) or a custom date

\begin{document}

\maketitle

\begin{definition}
The sample mean of database $X$ of size $n$ is defined as
$$f(X) = \frac{1}{n} \sum_{i=1}^n x_i.$$
\end{definition}
These are restricted-sensitivity proofs that only apply when N is known.
The library makes use of the Resize component to guarantee this static property.
If N is unknown, there is an argument on the DPMean component to estimate the mean by postprocessing plug-in estimates for the count and sum.

\section{Neighboring Definition: Change One}

% l1 sensitivity
\subsection{$\ell_1$-sensitivity}
\begin{theorem}
Say the space of datapoints $\mathcal{X}$ is bounded above by $M$ and bounded below by $m$. Then $f(\cdot)$ has $\ell_1$-sensitivity in the change-one model bounded above by
$$ \frac{M-m}{n}.$$
\end{theorem}

\begin{proof}
Say $X$ and $X'$ are neighboring databases which differ at data-point $x_j$, and let $\Delta{f}$ indicate the $\ell_1$-sensitivity of $f(\cdot)$. Then
\begin{align*}
\Delta{f} &= \max_{X,X'} \left\vert f(X) - f(X)' \right\vert \\
	&=  \max_{X,X'} \frac{1}{n} \left\vert \left(\sum_{\{ i \in [n] \vert i \ne j\}} x_i\right) + x_j  - \left(\sum_{\{ i \in [n] \vert i \ne j\}} x_i'\right) + x_j'  \right\vert \\
	&= \max_{X,X'} \frac{1}{n} \left\vert x_j - x_j' \right\vert \\
	&\le \frac{M-m}{n}.
\end{align*}
\end{proof}

% l2 sensitivity
\subsection{$\ell_2$-sensitivity}
\begin{theorem}
	Say the space of datapoints $\mathcal{X}$ is bounded above by $M$ and bounded below by $m$.
	Then $f(\cdot)$ has $\ell_2$-sensitivity in the change-one model bounded above by
	 $$ \frac{M-m}{n}. $$
\end{theorem}

\begin{proof}
This follows the same logic as the above proof.
\end{proof}

\section{Neighboring Definition: Add/Drop One}
\subsection{$\ell_1$-sensitivity}

\begin{theorem}
Say the space of datapoints $\mathcal{X}$ is bounded above by $M$ and bounded below by $m$.
Then $f(\cdot)$ has $\ell_1$-sensitivity in the add/drop-one model bounded above by
$$ \frac{M-m}{n}. $$
\end{theorem}

\begin{proof}
For notational ease, let $n$ always refer to the size of database $x$. We must consider both adding and removing an element from $x$. First, consider adding a point:\\

Let $X' = X \cup \{x\}$. Without loss of generality, assume the point added is the $(n+1)^{\text{th}}$ element of database $X'$. Note that
\begin{align*}
\left \vert f(X) - f(X)' \right\vert &= \left\vert \frac{1}{n} \sum_{i=1}^n x_i - \frac{1}{n+1} \sum_{i=1}^{n+1} x_i \right\vert \\
	&= \left\vert \left(\frac{1}{n} - \frac{1}{n+1}\right) \sum_{i=1}^n x_i - \frac{x}{n+1}\right\vert \\
	&= \frac{1}{n+1} \left\vert \frac{1}{n} \sum_{i=1}^n x_i - x \right\vert \\
	&\le \frac{ \left\vert M - m \right\vert}{n+1}.
\end{align*}

Second, consider removing a point: \\
Let $X' = X\textbackslash\{x\}$. Without loss of generality assume that the point subtracted is the $n^{\text{th}}$ element of database $X$.
\begin{align*}
\left \vert f(X) - f(X') \right\vert &= \left\vert \frac{1}{n-1} \sum_{i=1}^{n-1} x_i - \frac{1}{n} \sum_{i=1}^n x_i \right\vert \\
	&= \left\vert \left(\frac{1}{n-1} - \frac{1}{n}\right) \sum_{i=1}^{n-1} x_i - \frac{x}{n}\right\vert \\
	&= \frac{1}{n} \left\vert \frac{1}{n-1} \sum_{i=1}^{n-1} x_i  - x \right\vert \\
	&\le \frac{\left\vert M-m\right\vert}{n}.
\end{align*}

Then, since $\forall n > 0,$

$$ \frac{1}{n+1} < \frac{1}{n},$$

the sensitivity of the mean in general is bound from above by

$$ \frac{M-m}{n}.$$
\end{proof}

% l2 sensitivity
\subsection{$\ell_2$-sensitivity}

\begin{theorem}
Say the space of datapoints $\mathcal{X}$ is bounded above by $M$ and bounded below by $m$. Then $f$ has $\ell_2$-sensitivity in the add/drop-one model bounded above by
	$$ \frac{M-m}{n}. $$
\end{theorem}

\begin{proof}
This follows the same logic as the above proof.
%	For notational ease, let $n$ always refer to the size of database $X$. We must consider both adding and removing an element from $X$. First, consider adding a point:
%
%	Let $X' = X \cup x$. Without loss of generality assume the point added is the $(n+1)^\text{th}$ element of database X'. Then,
%	\begin{align*}
%		\Delta f &= \max_{X,X'} \sqrt{(f(X)- f(X)')^2} \\
%					   &= \max_{X,X'} \left( \frac{1}{n}\sum_{i=1}^{n}x_i - \frac{1}{n+1}\sum_{i=1}^{n+1}x'_i \right)\\
%					   &= \max_{X,X'} \left( \left(\frac{1}{n}\sum_{i=1}^{n}x_i\right) - \left(\frac{1}{n+1}\sum_{i=1}^{n}x'_i\right) - \frac{x}{n+1} \right)\\
%					   &= \max_{X,X'} \left( \frac{ \left(\sum_{i=1}^{n}x_i\right) - nx }{n(n+1)} \right)\\
%					   &= \frac{nM - nm}{n(n+1)}\\
%					   &= \frac{M - m}{n+1}.
%	\end{align*}
%
%Second, consider removing an element:\\
%Let $X' = X \setminus \{ x \}$. Without loss of generality assume that the point subtracted is the $n^\text{th}$ element of database $X$. Then,
%	\begin{align*}
%		\Delta f &= \max_{X,X'} (f(X)- f(X)')^2 \\
%					   &= \max_{X,X'} \left( \frac{1}{n}\sum_{i=1}^{n}x_i - \frac{1}{n-1}\sum_{i=1}^{n-1}x'_i \right)\\
%					   &= \max_{X,X'} \left( \left( \frac{1}{n}\sum_{i=1}^{n-1}x_i \right) + \frac{x}{n} - \left( \frac{1}{n-1}\sum_{i=1}^{n-1}x'_i \right) \right) \\
%					   &= \max_{X,X'} \left( \frac{(n-1)x - \sum_{i=1}^{n-1}x_i }{n(n-1)} \right) \\
%					   &= \frac{(n-1)M - (n-1)m}{n(n-1)} \\
%					   &= \frac{M-m}{n}
%	\end{align*}
%
%Then, since $\forall n > 0,$
%
%$$ \frac{1}{n+1} < \frac{1}{n},$$
%
%the sensitivity of the mean in general is bound from above by
%
%$$ \frac{M-m}{n}.$$
\end{proof}

% \bibliographystyle{alpha}
% \bibliography{mean}

\end{document}


\section{Conclusion}
\label{sec:conclusion}

The main goal of this project was to implement a feasible semantic indoor localization system that can be used to locate a user's position on a map who is carrying a smartphone so that the person does not need any additional device. Producing information of the semantic spaces was realized by using an ultrasound signal generator that generates sinusoids with specific frequencies and the sinusoids conveyed IDs of rooms in the environment. An Android application was implemented in order to collect audio samples to be decoded into room information using Fast Fourier Transform (FFT) and a couple of filtering algorithms. Calculated location information could be either sent to a server that can aggregate multiple targets' location or kept secret for the user's privacy. This main goal of the project was mostly achieved throughout this semester and we illustrated how accurate and efficient this localization system is by various kinds of experiments. Power consumption caused by this Android application imposed mild overhead on the smartphone, this system showed clear and accurate results even though when there was noise and interference. Through additional evaluation such as tests for room coverage and obstacle blocking, we also proved this system is proper for indoor characteristics.

%% Master
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "ee149"
%%% End:


%
%

\chapter{Examples of {\smart} Applications} \label{SEC:Examples}
\markboth{EXAMPLES OF SMART APPLICATIONS}{}

This chapter contains a variety of examples to illustrate the various
capabilities available in {\smart}, and how to use them.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{A fixpoint iteration with repeated submodels}

Fixpoint iteration schemes can become quite complex.
In the following code, two copies of the same Petri net \Code{b} are used,
with different parameters, together with a second Petri net, \Code{d}.
This situation might arise when a particular Petri net models part of a system
which is replicated multiple times with different characteristics.
%
\lstinputlisting[firstline=3]{examples/conv_pns.sm}
%
Although multiple use of the same Petri net is convenient from the
user's point of view, it might actually cause {\smart} to perform extra work.
This is because {\smart} remembers important, and large, data structures
that it must build to compute a measure for a given high-level model,
so that the data structures can be reused for successive measures.
For example, the statement
\begin{lstlisting}
real x3 := d(i1:=x1, i2:=x2).o1;
\end{lstlisting}
causes the state space and stationary solution of Petri net \Code{d}
to be computed, while statement
\begin{lstlisting}
real x4 := d(i1:=x1, i2:=x2).o2;
\end{lstlisting}
simply reuses the previous computation and just computes a different measure.
However, when a model is parameterized, only the data structures
corresponding to parameters used in the latest call are kept,
to avoid excessive memory consumption.
Thus, if an iteration of the \Code{converge} statement
calls \Code{b(i1:=x3).o1} and \Code{b(i1:=x4).o1} with \Code{x3} and
\Code{x4} set to different values, the next iteration will
not be able to reuse work even if the value of \Code{x3}, \Code{x4},
or both, are the same as in the previous iteration.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Finding the optimal value of a function}

The \Code{converge} statement in {\smart} can be used to obtain the optimal
value of a convex or concave function (or a local optimum for any function
with continuous first derivatives).
The idea is that, given the values $f_1$, $f_2$, $f_3$, and $f_4$
of a convex function at four distinct points $x_1 < x_2 < x_3 < x_4$,
we can discard the leftmost or the rightmost point (or the two leftmost
or righmost points if the values are in monotonic order), based on these values;
we can then iterate the search within the remaining interval,
and stop when the four points and the four values are sufficiently close.
The following code illustrates how to do this in {\smart}:
%
\lstinputlisting[firstline=3]{examples/maxima.sm}
%
Note that option \Code{UseCurrent} must be set to \Code{false} for this
scheme to work properly, otherwise the values of $x_2$, $x_3$, and $x_4$
would be updated using the new values computed for $x_1$, $x_2$, and $x_3$,
which is incorrect.

Of course, instead of using this scheme to discover that the maximum value
of $x-x^2$ over the interval $[0,1]$ is $0.25$ and is achieved at $x=0.5$
(or a close approximation of that, since this a numerical iterative method),
we can use it, for example, to find the time at which a given measure is
maximized in a Petri net model or the value of a rate for which the probability
of absorption is minimized in a continuous-time model.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Dining philosophers}

The dining philosopher model \cite{Pastor1994} is composed of $N$ subnets equal
to the one shown in Fig.~\ref{FIG:dining}.
The net represents a philosopher and the philosopher's right fork.
The philosopher's left fork, represented by
the dotted place $\mathit{Fork}_{(i+1) \bmod N}$, is part of the
subnet for the next philosopher; it
is depicted to illustrate how the subnets interact.
The corresponding {\smart} code is as follows:
%
\lstinputlisting[firstline=3]{examples/phils_ex1.sm}
%

\begin{figure}
  \centering
  \includegraphics[scale=1]{figures/phils.pdf}
  \caption{Model for a single dining philosopher.}
  \label{FIG:dining}
\end{figure}

\begin{comment}

If we wanted to use an advanced symbolic method, we could request this with an
option statement, which must appear before the two \Code{print} statements.
However, this also requires to partition the model.
We could do so by assigning \Code{M} philosophers per level:
\begin{code}
\begin{verbatim}
spn phils(int N, int M) := {
  for (int i in {1..N}) {
    ...
    partition(1+div(i,M):Idle[i]:WaitL[i]:WaitR[i]:HasL[i]:HasR[i]:Fork[i]);
  }
  for (int i in {1..N}) {
    ...
  }
  ...
};
# StateStorage MDD_SATURATION
int N := read_int("number of philosophers");
int M := read_int("number of philosophers per level");
print("Number of reachable states: ", phils(N,M).ns, ".\n");
print("Number of state-to-state transitions: ", phils(N,M).na, ".\n");
\end{verbatim}
\end{code}
Of course, if \Code{N} is not a multiple of \Code{M}, the last
level will have fewer than \Code{M} philosophers.
Also, a partition must define at least two levels, thus
\Code{N} must be strictly greater than \Code{M}.
Having more philosophers per level decreases the number of levels in the
MDD, but increases the size of the local state spaces, hence of the
MDD nodes.

If we had used a method requiring pregeneration of the local state
spaces, we would have to add the statement
\begin{code}
\begin{verbatim}
    inhibit(Fork[1+mod(i,N)]:Rel[i], HasR[1+mod(i,N)]:Rel[i]);
\end{verbatim}
\end{code}
in the second \Code{for} loop, to ensure that these local state spaces
are finite.

\end{comment}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{A flexible manufacturing system}

The Petri net \cite{1991PNPM-Decomposition} in Fig.~\ref{FIG:fms}
models a flexible manufacturing system (FMS).
This model is parameterized by the initial number $N$ of tokens in
$P_1$, $P_2$, and $P_3$.
The {\smart} description for this net is:
%
\lstinputlisting[firstline=3]{examples/fms_ex1.sm}
%

\begin{figure}
  \centering
  \includegraphics[scale=0.5]{figures/FMS-smartman.pdf}
  \caption{A flexible manufacturing system.}
  \label{FIG:fms}
\end{figure}

\begin{comment}

Had we wanted to use a structural solution approach, we could have
partitioned the model with the statement
\begin{code}
\begin{verbatim}
partition(P1:P1wM1:P1M1:M1:P1d:P1s, P12s:P12M3:M3:P12wM3:P12:P1wP2:P2wP1,
  P2:P2wM2:P2M2:M2:P2d:P2s, P3:P3M2:P3s);
\end{verbatim}
\end{code}
(which defines four submodels) and used the options
\begin{code}
\begin{verbatim}
# StateStorage MULTI_LEVEL_AVL
# MarkovStorage MATRIX_DIAGRAM_GENERAL
\end{verbatim}
\end{code}
Note, however, that the usually more efficient methods
\begin{code}
\begin{verbatim}
# StateStorage MDD_SATURATION
# MarkovStorage MATRIX_DIAGRAM_KRONECKER
\end{verbatim}
\end{code}
cannot be used with the given partition, because some immediate transitions,
such as \Code{tP1j}, are synchronizing (i.e., they affect multiple submodels).

%We partition the model into 19 levels obtained by assigning
%each place to a different level, with the exception of
%the complementary places $M_1$, $M_2$, and $M_3$, placed in the same level
%as the places $P_1M_1$, $P_2M_2$, and $P_{12}M_3$, respectively.

\end{comment}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Slotted ring}

Fig.~\ref{FIG:slotted} shows the Petri net for a single node of a slotted
ring network protocol \cite{Pastor1994}.
The overall model is composed of $N$
such subnets connected by merging transitions
(i.e., $\mathit{Free}_{(i+1) \bmod N}$ and $\mathit{Used}_{(i+1) \bmod N}$
really belong to the ``next'' subnet).
The following {\smart} code shows a decomposition where each
node of the ring is in a different level, and the requested
measure is simply the number of states.
%
\lstinputlisting[firstline=3]{examples/slot.sm}
%

\begin{figure}
  \centering
  \includegraphics[scale=0.5]{figures/slot.pdf}
  \caption{Model of a slotted ring.}
  \label{FIG:slotted}
\end{figure}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{A Kanban system}

This model \cite{1996WMPN-SNSkanban}, shown in Fig.~\ref{FIG:kanban},
is parameterized by the number $N$ of tokens initially
in $p_{1}$, $p_{2}$, $p_{3}$, and $p_{4}$.
The following code shows a partition into four levels, one per kanban station.
The output measure is the number of arcs in the state-to-state transition
matrix for $N$ varying from $1$ to a maximum specified at runtime.
\begin{figure}
  \centering
  \includegraphics[scale=1]{figures/kanban.pdf}
  \caption{A kanban system.}
  \label{FIG:kanban}
\end{figure}
%
\lstinputlisting[firstline=3]{examples/kanban.sm}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Randomized leader election protocol}

The randomized asynchronous leader election protocol in \cite{DolevKR82}
solves the following problem: given a ring of $N$ processors, the
participants are required to designate a unique processor as leader by
sending messages around the ring. The ring is unidirectional, meaning that
the processes send messages to their unique successor (e.g. the one to the
right), and receive messages from their unique predecessor. It is known that
if the processors are indistinguishable (no unique identifiers are
assigned), then there is no deterministic algorithm to solve the problem.

The randomized algorithm works in phases. At the beginning of every round,
each process flips a coin to decide whether it will continue running for
election or not. Initially all processes are valid candidates. After
choosing a value ($0 = $ don't run this round, $1 = $ run), this is
communicated to the neighbour to the right. A process is eliminated from the
race only if it chose not to run and it's predecessor chose to run. After
being eliminated from the race, a process never becomes eligible again (it
enters the inactive state), and it is used only to relay messages between
active nodes around the ring. They do no initiate any communication.
Termination is detected by the active processes (at least one active node
exists at all times) by sending a token around the ring to count the
inactive nodes. The process that receives its own token with count $N-1$ is
the elected leader.

In our model, each processes has $5$ state variables:
\begin{lstlisting}
status[i]       : {start, wait, active, inactive, leader};      // init start
preference[i]   : {0, 1};                                       // init 0
counter[i]      : {0..N-1};                                     // init 0
sent[i]         : {none, pref, counter};                        // init none
recv[i]         : {none, pref, counter};                        // init none
\end{lstlisting}

\begin{figure}
  \centering
  \includegraphics[scale=0.5]{figures/leaderchart.pdf}
  \caption{State transition chart for the \Code{status} variable.}
  \label{FIG:leaderchart}
\end{figure}

\noindent The state-transition diagram for the \Code{status} of a process is
shown in Figure \ref{FIG:leaderchart}.

\IGNORE{
The Petri Net model is shown is Figure \ref{FIG:leaderfig}
\begin{figure}
  \CENTERPSSCALE{leaderfig}{0.5}
  \caption{Petri net model: the subnet of process $i$.}
  \label{FIG:leaderfig}
\end{figure}
}

\noindent The SMART code for this model is listed below:
%
\lstinputlisting[firstline=3]{examples/leader.sm}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{A round--robin mutual exclusion protocol}

\begin{comment}
The protocol regulates the access to a shared resource (e.g. a communication
channel) for a ring of $N$ processors. The resource manager gives permission
to use the channel to each process in order, by moving a token around the
ring. When a process has the token, it reads in a message from the channel and
stores it in its own buffer. It can then release the token to the next processor
before reading the contents of the buffer, or read the buffer first and then
send the token to the neighbour.

Figure \ref{FIG:robinfig} shows the subnet for process $i$.
Each subnet is initially marked with one token in place $\id{wait}_i$,
except for process $0$ which starts with one token in $\id{req}_i$, meaning
that it is the first process to have access when the protocol starts.

\begin{figure}
  \CENTERPSSCALE{robinfig}{0.5}
  \caption{The round--robin mutual exclusion.}
  \label{FIG:robinfig}
\end{figure}

\begin{code}
\begin{verbatim}
spn robin(int N) := {
  place Res;
  partition(1:Res);
  for (int i in {0..N-1}) {
    place
        R[i], bufidle[i], buffull[i],
        pwait[i], pask[i], pok[i], pload[i], psend[i];
    trans
        task[i], tbuf[i], t1load[i], t2load[i], t1send[i], t2send[i];
    partition(
        i+2:bufidle[i]:buffull[i]:pwait[i]:pask[i]:pok[i]:pload[i]:psend[i],
        1:R[i]);
    firing(task[i]:expo(1.0), tbuf[i]:expo(1.0), t1load[i]:expo(1.0),
        t1send[i]:expo(1.0), t2load[i]:expo(1.0), t2send[i]:expo(1.0));
  }
  for (int i in {0..N-1}) {
    arcs(Res:task[i], pask[i]:task[i], task[i]:R[i], task[i]:pok[i],
        R[i]:tbuf[i], bufidle[i]:tbuf[i], tbuf[i]:buffull[i], tbuf[i]:Res,
        buffull[i]:t1load[i], pok[i]:t1load[i], t1load[i]:bufidle[i], t1load[i]:psend[i],
        buffull[i]:t2load[i], pload[i]:t2load[i], t2load[i]:bufidle[i], t2load[i]:pwait[i],
        pok[i]:t1send[i], pwait[mod(i+1,N)]:t1send[i],
        t1send[i]:pload[i], t1send[i]:pask[mod(i+1,N)],
        psend[i]:t2send[i], pwait[mod(i+1,N)]:t2send[i],
        t2send[i]:pwait[i], t2send[i]:pask[mod(i+1,N)]);
  }
  init(Res:1, pask[0]:1);
  for (int i in {1..N-1}) {init (pwait[i]:1);}
  for (int i in {0..N-1}) {init(bufidle[i]:1);}
}
\end{verbatim}
\end{code}

\end{comment}


\chapter{QCD primer}
\label{chap:qcd}

Quantum chromodynamics is the theory of strong interactions\footnote{A brief historical review about the development of {\sffamily QCD} may be found at \cite{historyqcd}.}. It aims to describe the interactions between elementary constituents, namely the quarks\footnote{The quarks were firstly predicted in Gell-Mann's Eightfold Way \cite{gellmann}.}, mediated by the carriers of the color force, the gluons.

The existence of color charge was proposed as an additional quantum number which would solve the violation of Pauli's exclusion principle for some particular baryons\footnote{For example, $\Delta^{++}$, which consists of three up quarks.}. Since the quarks were never experimentally evidenced, it was proposed that the strong interaction constrains the free particles to only exist in color neutral states. This particularity of {\sffamily QCD} is known as color confinement. Nevertheless, in the partonic picture\footnote{Feynman proposed that high energy nuclei are made of elementary constituents, generically called partons \cite{partons}.}, deep inelastic scattering\footnote{{\sffamily DIS} is a process during which the structure of a hadron may be probed via interaction with, in general, a lepton.} experiments between an electron and a proton confirmed the already predicted Bjorken scaling\footnote{Bjorken deduced an expression for the cross-section of the electron by imagining that it interacts electromagnetically with each parton from the proton \cite{bjorkenimf}.} of the electrons' differential cross-section.

In essence, {\sffamily QCD} is an extension of the original $\textsf{SU}(2)$ gauge theory of Yang and Mills \cite{yangmills} to local non-Abelian $\textsf{SU}(3)$ gauge transformations.

\section{Field content}
Following textbook expositions \cite{maggiore, peskin, greiner}, the {\sffamily QCD} Lagrangian $\mathcal{L}$ is constructed from symmetry principles, namely $\textsf{SO}(1,3)$ Lorentz invariance and local gauge invariance under $\textsf{SU}(3)$. The fields should transform according to irreducible representations of these groups. The quark content of the Lagrangian is described by the quark and anti-quark fields $\psi_{\alpha,i,f}(x)$ and $\overline{\psi}_{\alpha,i,f}(x)$. They are Dirac spinors (spinorial index $\alpha$), transform according to the fundamental representation of $\textsf{SU}(3)$ (color index $i=1,2,3$ or red, green, blue) and come in different flavours (flavour index $f=\overline{1,N_f}$ or up, down, strange, charm, bottom, up). The gluon fields $A_a^\mu(x)$ are Lorentz vectors and each correspond to a generator $t^a$ ($a=\overline{1,8}$) which, in the fundamental representation, is given by the Gell-Mann matrices $t^a=\lambda^a/2$.

\section{Gauge transformations}
The quark and anti-quark fields must be invariant under local $\textsf{SU}(3)$ gauge transformations\footnote{For simplicity, all the field indices will be dropped in the following computations.}
\shadedeq{
    \psi(x)\mapsto\textsf{U}(x)\psi(x), \quad \overline{\psi}\mapsto\overline{\psi}(x)\textsf{U}^\dagger(x)
}
with the group transformation expressible, via exponentiation, from the Lie algebra generators, with space-time dependent group parameters $\varepsilon^a(x)$, as
\boxedeqlabel{gaugetransf}{
    \textsf{U}(x)=\exp{i\sum_a\varepsilon^a(x)t^a}
}
The gauge fields\footnote{For each algebra element $t^a$, one may introduce a gauge field $A_a^\mu$. These may be then used to construct a Lie-algebra valued gauge potential $A^\mu$. This potential depends on the chosen representation.} $A_\mu(x)=\sum\limits_a A^a_\mu(x)t^a$ must transform according to
\boxedeqlabel{gaugefields}{
    A_\mu(x)\mapsto\textsf{U}(x)A_\mu(x)\textsf{U}^\dagger(x)+\frac{i}{g}\textsf{U}(x)\big[\partial_\mu\textsf{U}^\dagger(x)\big]
}
where $g$ denotes the coupling constant. It is important to notice that one may generate gluon fields out of a null one, that is $A_\mu=0$ by applying a local gauge transformation. Such field configurations take the form
\begin{equation*}
    A_\mu^{\text{pure}}=\frac{i}{g}\textsf{U}\big(\partial_\mu\textsf{U}^\dagger\big)
\end{equation*}
and are called pure gauge fields \cite{gelisqft,eichmann}. The corresponding field strength tensor is null $F_{\mu\nu}^{\text{pure}}=0$.

One may introduce the covariant derivative\footnote{The covariant derivative has an elegant geometrical interpretation \cite{torre}: it represents the rate of change when fields from different space-time points are parallel transported along a given path. During this procedure, they are being aligned such that they may be properly compared. The corresponding connection is actually the gauge field.}
\begin{equation*}
    \textsf{D}_\mu=\partial_\mu-igA_\mu.
\end{equation*}
Further, one may define the field strength tensor as the commutator between covariant derivatives\footnote{Since it arises as a commutator between covariant derivatives, which describe the parallel transport, the field strength tensor may be interpreted as a measure of the path dependence of parallel transport. For this reason, it is also referred to as the curvature \cite{torre}.}
\begin{equation*}
    F_{\mu\nu}=\frac{i}{g}\big[\textsf{D}_\mu,\textsf{D}_\nu\big],
\end{equation*}
which yields an expression in terms of gauge fields
\shadedeq{
    F_{\mu\nu}=\partial_\mu A_\nu-\partial_\nu A_\mu-ig\big[A_\mu,A_\nu\big]
}
or equivalently, by color components $F_{\mu\nu}=F_{\mu\nu}^at^a$, as
\begin{equation*}
    F_{\mu\nu}^a=\partial_\mu A_\nu^a-\partial_\nu A_\nu^a+gf^{abc}A_\mu^bA_\nu^c,
\end{equation*}
where $f^{abc}$ are the structure constants of the Lie algebra $\mathfrak{su}(3)$. The last term from the above equation, when plugged in the Lagrangian, will give rise to gluonic self-interactions, a particular feature of QCD. The field strength tensor gauge transforms in the usual manner as
\shadedeq{
    F_{\mu\nu}(x)\mapsto \textsf{U}(x)F_{\mu\nu}(x)\textsf{U}^\dagger(x)
}

\section{QCD Lagrangian}
One may now proceed to constructing the Lagrangian. The quark content is that of a free fermionic Lagrangian\footnote{After replacing the partial derivative with the covariant derivative, the Lagrangian will also contain an interaction term
\begin{equation*}
    \mathcal{L}_{\textsf{int}}=g \overline{\psi} \gamma^\mu A_\mu^a t^a \psi.
\end{equation*}}, but built with covariant derivatives, in order to satisfy gauge invariance
\begin{equation*}
    \mathcal{L}_{\textsf{quarks}}=\overline{\psi}(x)\big(i\slashed{\textsf{D}}-\textsf{M}\big)\psi(x),
\end{equation*}
where $\textsf{M}=\textsf{Diag}\left\{m_1,\ldots,m_{N_f}\right\}$ is the diagonal quark mass matrix in flavour space\footnote{In the Standard Model, the quark mass matrix is no longer diagonal. After spontaneous symmetry breaking, the mixing between different flavoured quark masses is given by the {\sffamily CKM} matrix \cite{pdg}.}.

The dynamics of the gluon fields is described by the following construction\footnote{It is important to notice that such a construction contains not only standard kinetic terms but also interaction vertices with three gluons, which are proportional to $g$ and four gluons, proportional to $g^2$.}
\begin{equation*}
    \mathcal{L}_{\textsf{gluons}}=-\frac{1}{2}\textsf{Tr}\left\{F_{\mu\nu}F^{\mu\nu}\right\},
\end{equation*}
where the color tracing over the contraction of field strength tensors assured gauge invariance. Equivalently, one may rewrite the above expression in terms of color components as
\begin{equation*}
    \mathcal{L}_{\textsf{gluons}}=-\frac{1}{4}F_{\mu\nu}^aF^{a,\mu\nu},
\end{equation*}
valid in the fundamental representation, where $\textsf{Tr}\left\{t^at^b\right\}=\delta^{ab}/2$. Therefore, the {\sffamily QCD} Lagrangian takes the form
\boxedeqlabel{qcd6}{
    \mathcal{L}_{\textsf{QCD}}=\overline{\psi}(x)\big(i\slashed{\textsf{D}}-\textsf{M}\big)\psi(x)-\frac{1}{4}F_{\mu\nu}^aF^{a,\mu\nu}
}

The corresponding Yang-Mills action expressed in flat coordinates is given by
\begin{align}\label{yangmills}
    \textsf{S}=\int\mathrm{d}^4x\left(-\frac{1}{2}\textsf{Tr}\left\{F_{\mu\nu}F^{\mu\nu}\right\}\right),
\end{align}

\section{Field equations}
The variational derivatives with respect to the color spinor fields give the colored Dirac equations
\begin{equation*}
    (i\slashed{\textsf{D}}-\textsf{M})\psi=0,
\end{equation*}
and similarly for the anti-quark fields
\begin{equation*}
    \overline{\psi}(i\overleftarrow{\slashed{\textsf{D}}}-\textsf{M})=0.
\end{equation*}
The Euler-Lagrange equations corresponding to the gluon fields yield the Yang-Mills equations, or equivalently, colored Maxwell equations\footnote{There is an additional equation, called the Bianchi identity, which follows from the definition and properties of $F_{\mu\nu}$. It may be expressed as \cite{tong}
\begin{equation*}
    \textsf{D}_\mu^{\phantom{*}*}F^{\mu\nu}=0,
\end{equation*}
where we introduced the dual field strength tensor as
\begin{equation*}
    ^*F^{\mu\nu}=\frac{1}{2}\epsilon^{\mu\nu\rho\sigma}F_{\rho\sigma}.
\end{equation*}}
\shadedeq{
    \textsf{D}_\nu F^{\nu\mu}=gJ^\mu
}
in which $J^\mu=\sum\limits_a J^{a,\mu} t^a$ with $J^{a,\mu}=\overline{\psi}\gamma^\nu t^a\psi$ being the color current. The color current is covariantly conserved $\textsf{D}_\mu J^\mu=0$.


\section{Hints on Using the Prover Effectively}

\begin{frame}
  \frametitle{Control the Size of Formulas}

  \begin{itemize}
  \item \tc{dkblue}{Proof obligations are often large}

    \begin{itemize}
    \o long definitions of actions and invariants
    \o \kw{let} constructions add to complexity when expanded
    \end{itemize}

  \oo \tc{dkblue}{The backend provers are easily overwhelmed by large formulas}

    \begin{itemize}
    \o may work on top-level operators or deeply inside a long formula
    \o even simple proof steps may take an extraordinate amount of time
    \end{itemize}

  \oo \alert{Use local definitions and \HIDE\ them when unnecessary}

    \begin{itemize}
    \o prove facts about a \kw{let}-bound operator, then \HIDE\ it
    \end{itemize}
  \end{itemize}

  \vfill\vfill
\end{frame}

\begin{frame}
  \frametitle{Example: Controlling the Size of Expressions}

  \qquad\begin{tlablock}
    \LEMMA\
    \begin{noj2}
      & \begin{conj}
          x \in SomeVeryBigExpression\\
          y \in AnotherBigExpression
        \end{conj}\\
      \biimplies &
        \begin{conj}
            y \in AnotherBigExpression\\
            x \in SomeVeryBigExpression
        \end{conj}
\pause
        \hspace{1cm}\raisebox{0cm}[0pt][0pt]{\begin{minipage}{3cm}
          \begin{beamercolorbox}[rounded=true,shadow=true]{postit}\footnotesize
            \OBVIOUS\ may take\\forever here
          \end{beamercolorbox}
        \end{minipage}}
    \end{noj2}\\
\pause
    \ps{1}{.}\ \ \ \DEFINE\ S\ \deq\ SomeVeryBigExpression\\
    \ps{1}{.}\ \ \ \DEFINE\ T\ \deq\ AnotherBigExpression\\
    \ps{1}{1.}\ S = SomeVeryBigExpression\\
    \quad\OBVIOUS\\
    \ps{1}{2.}\ T = AnotherBigExpression\\
    \quad\OBVIOUS\\
    \ps{1}{.}\ \ \ \HIDE\ \DEF\ S,\ T\\
    \ps{1}{3.}\
      \begin{noj2}
        & x \in S \land y \in T\\
        \biimplies & y \in T \land x \in S
      \end{noj2}\\
    \quad\OBVIOUS\\
    \ps{1}{4.}\ \QED\qquad\BY\ \ps{1}{1},\ \ps{1}{2},\ \ps{1}{3}
  \end{tlablock}
\end{frame}

\begin{frame}
  \frametitle{Avoid Circular Rewrites}

  \begin{itemize}
  \item \tc{dkblue}{Rewriting is often effective for reasoning about equalities}

    \begin{itemize}
    \o idea: replace left-hand side of equality by right-hand side
    \o Isabelle's automatic tactic are based on rewriting
    \o for example, use\ \ \tc{dkgreen}{$x' = x-y \land y'=y$}\ \ to eliminate $x'$ and $y'$    \end{itemize}

\pause

  \oo \tc{dkblue}{Must make sure that rewriting terminates}

    \begin{itemize}
    \o consider\ \ \tc{dkgreen}{$s = f(t) \land t = g(s)$}
    \o Isabelle attempts to reject circular sets of equations
    \o if rejected, proof may get stuck
    \o if not rejected, proof may never terminate
    \end{itemize}

  \oo \alert{Use local definitions, and \HIDE\ them to break loops}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Circular Rewrites: Example}

  \qquad\begin{tlablock}
    \ps{4}{5.}\ r.name = \str{xyz}\\
    \quad\ps{5}{1.}\ r = [name \mapsto "xyz",\ value \mapsto \alt<1>{r}{\alert{r}}.value]\\
    \quad\quad\BY\ \ps{2}{2}\\
    \quad\ps{5}{2.}\ \QED\\
    \quad\quad\BY\ \ps{5}{1}
  \end{tlablock}

\pause

  \vfill\vfill

  \qquad\alert{The equation in step $\ps{5}{1}$ is circular!}

  \vfill\vfill

\pause

  \qquad\begin{tlablock}
    \ps{4}{5.}\ r.name = \str{xyz}\\
    \quad\ps{5}{}\ \ \ \DEFINE\ rval\ \deq\ r.value\\
    \quad\ps{5}{1.}\ r = [name \mapsto "xyz",\ value \mapsto rval]\\
    \quad\quad\BY\ \ps{2}{2}\\
    \quad\ps{5}{}\ \ \ \HIDE\ \DEF\ rval\\
    \quad\ps{5}{2.}\ \QED\\
    \quad\quad\BY\ \ps{5}{1}
  \end{tlablock}
\end{frame}

\begin{frame}
  \frametitle{Establishing Facts About \CHOOSE}

  \qquad\begin{tlablock}
    \DEFINE\ m\ \deq\ \CHOOSE x \in S : P(x)\\
    \DEFINE\ NoValue\ \deq\ \CHOOSE x : x \notin Value
  \end{tlablock}

  \begin{itemize}
  \oo \tc{dkblue}{How to prove a property $Q(m)$ ?}

    \begin{itemize}
    \o \CHOOSE\ always denotes some value, even if $P(x)$ holds for no $x \in S$
    \end{itemize}

\pause

  \oo \tc{dkblue}{In practice, must establish the two following facts}

    \begin{itemize}
    \o $\E x \in S : P(x)$
    \o $\A x \in S : P(x) \implies Q(x)$
    \o \tlaps\ will then deduce $Q(m)$
    \end{itemize}

\pause

  \oo \tc{dkblue}{Important special case: ``null'' values}

    \begin{itemize}
    \o existence of such a value follows from the library theorem

      \medskip

      \begin{tlablock}
        NoSetContainsEverything\ \deq\ \A S : \E x : x \notin S
      \end{tlablock}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{It's Easier To Prove Something If It's True}

  \begin{itemize}
  \item \tc{dkblue}{All specifications initially contain mistakes}

    \begin{itemize}
    \o errors range from typos to misunderstandings to genuine bugs
    \o formal mathematical definitions are hard to get right
    \end{itemize}

  \oo \tc{dkblue}{\tlaps\ is not good at catching specification errors}

    \begin{itemize}
    \o if you are stuck on a proof, is it you, the prover or the specification?
    \o even with structured proofs, complexity quickly gets out of hand
    \end{itemize}

  \oo \tc{dkblue}{Extensively debug your specifications using \tlc}

    \begin{itemize}
    \o almost all bugs manifest themselves on small instances
    \o run \tlc\ on many properties and inspect the counter-examples
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Focus On The Theorems You Are Interested In}

  \begin{itemize}
  \item \tc{dkblue}{\tlaps\ currently has limited support for theories}

    \begin{itemize}
    \o set theory and functions are fully supported
    \o decision procedure for elementary integer arithmetic
    \o very rudimentary support for sequences
    \end{itemize}

\pause

  \oo \tc{dkblue}{State facts about ``data'' as assumptions}

    \begin{itemize}
    \o do you want to verify an algorithm or basic mathematics?
    \o but --- isn't that dangerous?
    \o it is, but you can validate many assumptions using \tlc
    \o override infinite sets with finite ones in the model, e.g.\ \ \tc{dkgreen}{$Nat\ \deq\ 0..50$}
    \end{itemize}

\pause

  \oo \alert{Theory support will improve slowly and your help is welcome}
  \end{itemize}
\end{frame}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "tutorial"
%%% End: