\section{Method}
\label{sec:methods}

\subsection{Split Error Detection}
\label{sec:spliterrordetection}

We build a split error classifier with output $p$ using a CNN to check whether an edge within an existing automatic segmentation is valid ($p=0$) or not ($p=1$). Rather than analyzing every input pixel, the classifier operates only on segment boundaries, which requires less pixel context and is faster. In contrast to Bogovic \etal~\cite{BogovicHJ13}, we work with 2D slices rather than 3D volumes. This enables proofreading prior or in parallel to a computationally expensive stitching and 3D alignment of individual EM images.

\paragraph{CNN Architecture.} Boundary split error detection is a binary classification task since the boundary is either correct or erroneous. However, in reality, the score $p$ is between 0 and 1. In connectomics, classification complexity arises from hundreds of different cell types, rather than from the classification decision itself. Intuitively, this yields a wider architecture with more filters rather than a deeper architecture with more layers. We explored different architectures---including residual networks~\cite{resnet}---with brute force parameter searches and precision and recall comparisons (see supplementary materials). Our final CNN configuration for split error detection has four convolutional layers, each followed by max pooling with dropout regularization to prevent overfitting due to limited training data (Fig.~\ref{fig:architecture}).

\paragraph{Classifier Inputs.} To train the CNN, we consider boundary context in the decision making process via a $75\times75$ patch over the center of an existing boundary. This size covers approximately $80\%$ of all boundaries in the 6~nm Mouse S1 AC3 Open Connectome Project dataset. If the boundary is not fully covered, we sample up to 10 non-overlapping patches along the boundary, and average the resulting scores weighted by the boundary length coverage per patch.

Similar to Bogovic~\etal~\cite{BogovicHJ13}, we use grayscale image data, corresponding boundary probabilities, and a single binary mask combining the two neighboring labels as inputs to our CNN. However, we observed that the boundary probability information generated from EM images is often misleading due to noise or artifacts in the data. This can result in merge errors within the automatic segmentation. To better direct our classifier to train on the true boundary, we extract the border between two segments. Then, we dilate this border by 5 pixels to consider slight edge ambiguities as well as cover extra-cellular space, and use this binary mask as an additional input. This creates a stacked 4-channel input patch. Fig.~\ref{fig:cnn_inputs} shows examples of correct and erroneous input patches and their corresponding automatic segmentation and ground truth.

\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{cnn_inputs.pdf}
\caption{Example inputs for learning correct splits and split errors (candidate segmentation versus the ground truth). Image, membrane probabilities, merged binary labels, and a dilated border mask provide 4-channel input patches.}
\label{fig:cnn_inputs}
\end{figure}

\subsection{Merge Error Detection}

Identification and correction of merge errors is more challenging than finding and fixing split errors, because we must look inside segmentation regions for missing or incomplete boundaries and then propose the correct boundary. However, we can reuse the same trained CNN for this task. Similar to guided volume editing by Karimov~\etal~\cite{karimov_guided_volume_editing}, we generate potential borders within a segment. For each segmentation label, we dilate the label by 20 pixel and generate 50 potential boundaries through the region by randomly placing watershed seed points at opposite sides of the label boundary. We perform watershed on the inverted grayscale EM image. This yields 50 candidate splits.

Dilation of the segment prior to watershed is motivated by our observation that the generated splits tend to attach to real membrane boundaries. These boundaries are then individually rated using our split error classifier. For this, we invert the probability score such that a correct split (previously encoded as $p=0$) is most likely a candidate for a merge error (now encoded as $p=1$). In other words, if a generated boundary is ranked as correct, it probably should be in the segmentation. Fig. \ref{fig:merge_error} illustrates this procedure. Pseudo code is available as supplemental material to promote understanding.

\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{merge_error_v6.pdf}
\caption{Merge error detection: Potential borders are generated using inverted images by randomly placing watershed seeds (green) on the boundary of a dilated segment. The best ranked seeds and border (both in red) result in the shown error correction.}

\label{fig:merge_error}
\end{figure}

\subsection{Error Correction}
\label{sec:errorcorrection}

We combine the proposed classifiers to perform corrections of split and merge errors in automatic segmentations. For this, we first perform merge error detection for all existing segments in a dataset and store the inverted rankings $1-p$ as well as potential corrections. After that, we perform split error detection and store the ranking $p$ for all neighboring segments in the segmentation. Then, we sort the merge and split error rankings separately from highest to lowest. For error correction, first we loop through the potential merge error regions and then through the potential split error regions. During this process, each error is now subject to a yes/no decision which can be provided in different ways:

\paragraph{Selection oracle.} If ground truth data is available, the selection oracle \textit{knows} whether a possible correction improves an automatic segmentation. This is realized by simply comparing the outcome of a correction using a defined measure. The oracle only accepts corrections which improve the automatic segmentation---others get
discarded. This is guided proofreading with a perfect user, and allows us to assess the upper limit of improvements.

\paragraph{Automatic selection with threshold.} The decision whether to accept or reject a potential correction is taken by comparing rankings to a threshold $p_t$. If the inverted score $1-p$ of a merge error is higher than a threshold $1-p_t$, the correction is accepted. Similarly, a correction is accepted for a split error if the ranking $p$ is higher than $p_t$. Our experiments have shown that the threshold $p_t$ is the same for merge and split errors for a balanced classifier that has been trained on equal numbers of correct and error patches.

\paragraph{Forced choice setting.} We present a user with the choice to accept or reject a correction. All potential split errors are seen. Inspecting all merge errors is not possible for users due to the sheer amount of generated borders. Therefore, we only present merge errors that have a probability threshold higher than $1-p_t$.

\noindent \newline In all cases, a decision has to be made to advance to the next possible erroneous region. If a merge error correction was accepted, the newly found boundary is added to the segmentation data. This partially updates the merge error and split error ranking with respect to the new segment. If a split error correction was accepted, two segments are merged in the segmentation data and the disappearing segment is removed from all error rankings. Then, we perform merge error detection on the now larger segment and update the ranking. We also update the split error rankings to include all new neighbors, and re-sort. The error with the next highest ranking then forces a choice.

\subsection{User Interface}

We integrate guided proofreading into an existing large data connectomics workflow. The web-based system is designed with a novice-friendly user interface (Fig.~\ref{fig:ui}). We show the current labeling of a cell boundary outline and its proposed correction overlayed on EM image data. The user cannot distinguish the current labeling from the proposed correction to avoid selection bias. We also show a solid overlay of the current and the proposed labeling. In addition, we show the image without overlays to provide an unoccluded view. User interaction is simple and involves one mouse click on either the current labeling or the correction. After interaction, the next potential error is shown.

\begin{figure}[t]
\includegraphics[width=\linewidth]{user_interface_split.pdf}
\caption{User interface. A candidate error region is shown on the left. The user must choose between the region being a split error which needs correcting (center) or not (right). Confirming the choice advances to the next potential error.}
\label{fig:ui}
\end{figure}


\documentclass{article}
\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{cancel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{April 30, 2014}
\maketitle
counting formula $R_n=\sum\limits_{r=0}^n{\frac{1}{n-r+1}\binom{2n-r}{r,n-r,n-r}}$ where r=flat steps, and $R_n$ is number of large shroder paths.
\begin{align*}
  R_n&=2s_{n+1}\text{ s are dissections/small shrodinger paths}
\end{align*}
\section*{7.1/2}
fibanocci numbers
\begin{align*}
  f_n=f_{n-1}+f_{n-2},f_0=1,f_1=1\\
\end{align*}
partial sums
\begin{align*}
  s_n=f_0+\dots+f_n=f_{n+2}-1
\end{align*}
proof by induction

even odd odd patter

using $f_n$'s to solve covering 2xn chessboard problems.

fibonacci numbersare sum pascal triangle diagonal

generating functions
\begin{align*}
  g(x)&=\sum\limits_{n=0}^\infty{h_nx^n}
\end{align*}

derive recurrence, use recurrence
use reg generating functions for combination like things
\section*{7.3}
exponential generating functions
use for counting permutation like things.
need to be able to find a generating function and use it to find a counting formula.
\section*{7.4/5}
solving recurrence relations and ....

know if it's linear, homogeneous, constant coefficients.

method of generating functions know this.

also can find general solution to homogen, find particular solution, combine solutions and determince constants.
\section*{7.6/8.1}
catalan stuff.
catalan number is $C_n=\frac{1}{n+1}\binom{2n}{n}$

say what is counted, give bijections. say why it's a bijection.
\section*{8.2}

\section*{8.3}
self conjugate partitions, and partitions with only odd parts.

odd and distinct
\section*{8.5}
\end{document}


\chapter{Data preparation schemes for calculations}
\label{app:DataPrepScheme}

There are several ways to take the WAMIT data and prepare it for the calculations.  The first scheme (which Tiago described in one of his documents) is to parse out the relevent data, then interpolate to find the data necessary for the calcution.  Second scheme is to interpolate all the data first, then parse out the relevant parts.  These two schemes lend themselves to a matrix driven data processing such as might occur in MATLAB based code.

The third schemes, which is used in this module of \HD is to interpolate the sorted WAMIT data during the calculations themselves. This scheme presents the lowest memory usage of the three schemes as only the sorted raw data must be stored.  The interpolation step is then performed within the loops of the calculation.  The interpolated data is not kept as it is not needed afterwards.

%FIXME: add diagram from the notebook, p. 142

\section{Parse then Interpolate}
One method is to take the sorted data from the WAMIT file and parse out only the pieces of interest.  For example, a full second order QTF WAMIT file (.12d for example) might only be used in Newman's approximation.  In this case, only terms where $\omega_m = \omega_n$ and $\beta_1 = \beta_2$ are kept.  It would be possible to only keep these values and put them in a simplified matrix dependent on $\omega$ and $\beta$.  This could then be sent through two one dimensional interpolations (one interpolation on each dimension). In this manner, different interpolations would be done depending on which calculation method we were using.

The advantage with this data preparation scheme is that we can keep a small set of data and we can use simpler interpolations for some of the calculation methods.  The disadvantage is that we end up imposing that the values of the $\omega_m$ terms must be identical to the values of the $\omega_n$ terms (otherwise there would be no $\omega_m = \omega_n$ terms to keep).  This would also be true for the $\beta$ terms.

\begin{figure}[ht]
   \begin{center}
      \beginpgfgraphicnamed{MeanDrift.Flowchart}
         \input{chaps/figures/Flowcharts--parse_then_interp/MeanDrift.Flowchart.tikz.tex}
      \endpgfgraphicnamed
   \end{center}
\caption{Flow diagram for the mean drift calculation method using the parse then interpolate scheme.  $\tau$ is the period, $\omega$ is the corresponding frequency, and $\beta$ is the wave direction.  The \nth{1} and \nth{2} order {\tt WAMIT} output files are read in and arranged in ascending order within the {\tt WAMIT2\_Init} routine (\Cref{sec:WAMIT2Init}).  See text for how to solve the equation. See \Cref{chap:WamitOutput} for requirements on which WAMIT output files can be used.
   \label{fig:MeanDrift:Flowchart:ParseInterp}
}
\end{figure}

\begin{figure}[ht]
   \begin{center}
      \beginpgfgraphicnamed{Newman.Flowchart}
         \input{chaps/figures/Flowcharts--parse_then_interp/Newman.Flowchart.tikz.tex}
      \endpgfgraphicnamed
   \end{center}
\caption{Flow diagram for the Newman's approximation method using the parse then interpolate scheme.  $\tau$ is the period, $\omega$ is the corresponding frequency, and $\beta$ is the wave direction.  The \nth{1} and \nth{2} order {\tt WAMIT} output files are read in and arranged in ascending order within the {\tt WAMIT2\_Init} routine (\Cref{sec:WAMIT2Init}).
   \label{fig:Newman:Flowchart:ParseInterp}
}
\end{figure}

\begin{figure}[ht]
   \begin{center}
      \beginpgfgraphicnamed{DiffQTF.Flowchart}
         \input{chaps/figures/Flowcharts--parse_then_interp/DiffQTF.Flowchart.tikz.tex}
      \endpgfgraphicnamed
   \end{center}
\caption{Flow diagram for the full difference QTF method using the parse then interpolate scheme.  $\tau$ is the period, $\omega$ is the corresponding frequency, and $\beta$ is the wave direction.  The \nth{1} and \nth{2} order {\tt WAMIT} output files are read in and arranged in ascending order within the {\tt WAMIT2\_Init} routine (\Cref{sec:WAMIT2Init}).
   \label{fig:DiffQTF:Flowchart:ParseInterp}
}
\end{figure}

\begin{figure}[ht]
   \begin{center}
      \beginpgfgraphicnamed{DiffQTF.Flowchart}
         \input{chaps/figures/Flowcharts--parse_then_interp/SumQTF.Flowchart.tikz.tex}
      \endpgfgraphicnamed
   \end{center}
\caption{Flow diagram for the full summation QTF method using the parse then interpolate scheme.  $\tau$ is the period, $\omega$ is the corresponding frequency, and $\beta$ is the wave direction.  The \nth{1} and \nth{2} order {\tt WAMIT} output files are read in and arranged in ascending order within the {\tt WAMIT2\_Init} routine (\Cref{sec:WAMIT2Init}).
   \label{fig:SumQTF:Flowchart:ParseInterp}
}
\end{figure}

\clearpage

\section{Interpolate then parse}
Another scheme is to take the sorted WAMIT data and interpolate for all possible values of $\omega_m, \omega_n, \beta_1,$ and $\beta_2$ before selecting out the specific values wanted for the calculation.  The parsing step would then be perfomed afterwards to select only the values needed for the calculation.  This scheme has a very large memory footprint and large amount of processing time spent on the interpolation.  This scheme would be appropriate if the fully interpolated data set was used a large number of times during a \HD simulation, or if a complicated interpolation scheme was used (such as a four dimensional FFT interpolation).  However, in our implimention of \HD, only a small portion of the data would be used, and only used once during initialization.  This scheme is therefore unecessarily complicated for our purposes.

\section{Interpolate during calculation}
This scheme is used in the \modname{WAMIT2} module to perform the interplation of the sorted WAMIT data at each step of the calculation.  The calculations each require summations over a range of frequencies, or inverse discrete Fourier transforms over a range of frequencies.  The WAMIT data can be categorized as either three-dimensional, or four-dimensional depending on what WAMIT output files were used.  At each step of a summation loop, a call can be made to a subroutine that will interpolate the sorted WAMIT data for the particular $F^\pm(\omega_m,\omega_n,\beta_m,\beta_n)$ value required.  There might be a slight computational penalty for calling the interpolation scheme multiple times for sequential points.  Overall this scheme has the advantage that the returned value could be stored in a temporary variable and immediately used.  This limits the memory usage since the complete interpolated multi-dimensional matrix is not stored.


\section{Forms on infinite-dimensional vector spaces}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\title{Sequence to Sequence}

\begin{document}

\maketitle

\section{General Idea of the Paper}

Gist of what the paper is about. ( 2-3 paragraphs )

\section{Notation}
For incredibly precise notation look at the notation from http://www.seas.upenn.edu/~cis262/notes/cis262-hmm.pdf pages 95-104.

\section{Mathematical Method}

Using our notation we write the RNN as
\begin{align*}
    h^t &= W^{??}h^{(t-1)} + W^{??}y_t \\
    \hat{y}^t &= W^{??}h_t
\end{align*}

\section{Questions}

\end{document}


% !TeX root = ../main.tex
\section{HCL Built-In Functions}
\label{builtinAppend}
\textbf{Arithmetic Operations}\\
HCL includes five standard arithmetic functions for use on numerical values.
The functions are seen in table \ref{tbl:arith}.

\begin{table}[ht]
	\centering
	\caption{Arithmetic Functions}
	\label{tbl:arith}
	\begin{tabular}{|c|c|c|c|}
		\hline
		\textbf{Operation}      & \textbf{Symbol} & \textbf{Input Parameters} & \textbf{Return Type} \\ \hline
		Addition       & +      & num, num         & num         \\ \hline
		Subtraction    & -      & num, num         & num         \\ \hline
		Division       & /      & num, num         & num         \\ \hline
		Multiplication & *      & num, num         & num         \\ \hline
		Modulo         & mod    & num, num         & num         \\ \hline
	\end{tabular}
\end{table}

\textbf{Boolean Operations}\\
Functions for boolean operations are listed in table \ref{tbl:bool}.
These functions compare numeral, textual or boolean values and return a boolean value.

\begin{table}[h!]
	\centering
	\caption{Boolean Functions}
	\label{tbl:bool}
	\begin{tabular}{|c|c|c|c|}
		\hline
		\textbf{Operation}                                                       & \textbf{Symbol}         & \textbf{Input Parameters} & \textbf{Return Type} \\ \hline
		Less Than                                                    & lessThan          & num, num         & bool        \\ \hline
		\begin{tabular}[c]{@{}c@{}}Less Than \\ Equals\end{tabular}  & lessThanEqual     & num, num         & bool        \\ \hline
		Greater Than                                                    & greaterThan       & num, num         & bool        \\ \hline
		\begin{tabular}[c]{@{}c@{}}Greater Than \\ Equals\end{tabular}  & greaterThanEqual  & num, num         & bool        \\ \hline
		Numerical Equals                                                & equals            & num, num         & bool        \\ \hline
		\begin{tabular}[c]{@{}c@{}}Numerical Not \\ Equals\end{tabular} & notEquals         & num, num         & bool        \\ \hline
		And                                                             & and               & bool, bool       & bool        \\ \hline
		Or                                                              & or                & bool, bool       & bool        \\ \hline
		Boolean Equals                                                  & equals            & bool, bool       & bool        \\ \hline
		\begin{tabular}[c]{@{}c@{}}Boolean Not \\ Equals\end{tabular}   & notEquals         & bool, bool       & bool        \\ \hline
		Not                                                             & not               & bool             & bool        \\ \hline
		Textual Equals                                                  & equals            & txt, txt         & bool        \\ \hline
		\begin{tabular}[c]{@{}c@{}}Textual Not \\ Equals\end{tabular}   & notEquals         & txt, txt         & bool        \\ \hline
	\end{tabular}
\end{table}
\newpage

\textbf{Text Manipulation}\\
Functions used to manipulate text-objects or convert values to text, seen in table \ref{tbl:text}.
\begin{table}[h!]
	\centering
	\caption{Textual Functions}
	\label{tbl:text}
	\begin{tabular}{|c|c|c|c|}
		\hline
		\textbf{Operation}          & \textbf{Symbol}  & \textbf{Input Parameters} & \textbf{Return Type} \\ \hline
		Concat Text        & +       & txt, txt         & txt         \\ \hline
		Numeric To Text    & toText  & num              & txt         \\ \hline
		Boolean To Text    & toText  & bool             & txt         \\ \hline
		Textual To Text    & toText  & txt              & txt         \\ \hline
		List To Text       & toText  & list{[}T{]}      & txt         \\ \hline
		At index           & at      & txt, num         & txt         \\ \hline
		Text Concatenation & +       & txt, txt         & txt         \\ \hline
		Sub Text           & splitAt & txt, num, num    & txt         \\ \hline
		Text Length        & lenght  & txt              & num         \\ \hline
	\end{tabular}
\end{table}

\textbf{Control Structures}\\
Functions used as control structures in HCL, seen in table \ref{tbl:control}
\begin{table}[h]
	\centering
	\caption{Control Structures}
	\label{tbl:control}
	\begin{tabular}{|c|c|c|c|}
		\hline
		\textbf{Operation}                                                 & \textbf{Symbol} & \textbf{Input Parameters}            & \textbf{Return Type} \\ \hline
		\begin{tabular}[c]{@{}c@{}}Then \\ Statement\end{tabular} & then   & bool, func{[}none{]}        & bool        \\ \hline
		While Loop                                                & while  & func{[}none{]}, bool        & bool        \\ \hline
		Foreach Loop                                              & forEach   & list{[}T{]}, func{[}none{]} & none        \\ \hline
	\end{tabular}
\end{table}

\textbf{List Operations}\\
Functions used to manipulate or monitor lists, seen in table \ref{tbl:list}.
\begin{table}[h]
	\centering
	\caption{List Operations}
	\label{tbl:list}
	\begin{tabular}{|c|c|c|c|}
		\hline
		\textbf{Operation}     & \textbf{Symbol}  & \textbf{Input Parameters}            & \textbf{Return Type} \\ \hline
		Get Lenght    & lenght    & list{[}T{]}                 & num         \\ \hline
		At Index      & at        & list{[}T{]}, num            & T           \\ \hline
		Concatenation & +         & list{[}T{]}, List{[}T{]}    & list{[}T{]} \\ \hline
		Get Sublist   & splitAt   & list{[}T{]}, num, num       & list{[}T{]} \\ \hline
		Map           & map       & list{[}T{]}, func[T, T]     & list{[}T{]} \\ \hline
		Filter List   & where     & list{[}T{]}, func[T, bool]  & list{[}T{]} \\ \hline
		To List       & to        & num, num                    & list[num]   \\ \hline
		Equals        & equals    & list{[}T{]}, list{[}T{]}    & bool        \\ \hline
		Not Equals    & notEquals & list{[}T{]}, list{[}T{]}    & bool        \\ \hline
	\end{tabular}
\end{table}
\newpage

\textbf{Pin-Functions}\\
Functions used to read and write from arduino's analogue and digital pins, seen in table \ref{tbl:pins}.
\begin{table}[h]
	\centering
	\caption{Pin Operations}
	\label{tbl:pins}
	\begin{tabular}{|c|c|c|c|}
		\hline
		\textbf{Operation}                                                      & \textbf{Symbol}         & \textbf{Input Parameters} & \textbf{Return Type} \\ \hline
		Set Digital Pin                                                & setDigitalPin  & num, bool        & none        \\ \hline
		Read Digital Pin                                               & readDigitalPin & num              & num         \\ \hline
		Write Analog Pin                                               & setAnalogPin   & num, num         & none        \\ \hline
		Read Analog Pin                                                & readAnalogPin  & num              & num         \\ \hline
		Delay                                                          & delay          & num              & none        \\ \hline
	\end{tabular}
\end{table}

\textbf{Print Operations}\\
Functions used to print to output, seen in table \ref{tbl:print}.
\begin{table}[h]
	\centering
	\caption{Print Functions}
	\label{tbl:print}
	\begin{tabular}{|c|c|c|c|}
		\hline
		\textbf{Operation}  & \textbf{Symbol}    & \textbf{Input Parameters} & \textbf{Return Type} \\ \hline
		Print      & print     & num/bool/txt     & none        \\ \hline
		Print List & print     & list[T]          & none        \\ \hline
	\end{tabular}
\end{table}
\newpage


\documentclass[11pt,a4paper]{report}
\usepackage{asymptote}
\usepackage{wrapfig}
\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.75in}
\begin{document}
\begin{center}
\Large{CHAPTER 3 SUMMARY. \textbf{Vectors and Two-Dimensional Motion}}

\large{Justin Yang}

October 26, 2012
\end{center}

\section*{General Properties of Vectors}

A \textbf{vector quantity} has both a magnitude and a direction.\\A \textbf{scalar quantity} has magnitude, but no direction.

\hspace{1mm}

\noindent
\textit{Equality} $\vec{A}\ =\ \vec{B}$ if $A = B$ and their directions are the same.

\hspace{1mm}

\noindent
\textit{Addition} Vectors can be added both geometrically and algebraically.

\underline{Geometrically} \textsl{Head-to-tail} and \textsl{parallelogram} methods can be used.

Thus, the \textbf{resultant vector} $\vec{R}\ =\ \vec{A} + \vec{B}$ is the sum of two or more vectors.

\hspace{1mm}

\noindent
\textit{Negative} The negative of a vector has the same magintude but opposite direction.

\hspace{1mm}

\noindent
\textit{Subtraction} $\vec{A} + \vec{B}\ =\ \vec{A} + \left(-\vec{B}\right)$.

\hspace{1mm}

\noindent
\textit{Multiplication by a Scalar} $s \vec{A}$ has magnitude $sA$ and has the same direction as $\vec{A}$ if $s$ if positive and opposite direction if $s$ is negative.

\begin{wrapfigure}{r}{0.3\textwidth}
\begin{center}
\vspace{-20pt}
\begin{asy}
import graph;
xaxis("$x$", xmin=-0.5);
yaxis("$y$");
import olympiad;
	defaultpen(1.0);
	size(5cm);
	draw((0,0)--(2,1),EndArrow);
	markscalefactor=0.05;
	draw(anglemark((2,0),(0,0),(2,1)));
	draw((2,0)--(2,1),dashed);
	draw((0,1)--(2,1),dashed);
	label("$A_x = A \cos{\theta}$",(0,0)--(2,0),S);
	label("$A_y = A \sin{\theta}$",(0,0)--(0,1),W);
	dot((2.2,1.2),invisible);
\end{asy}
\vspace{-20pt}
\end{center}
\end{wrapfigure}

\hspace{1mm}

\noindent
\textit{Components} The component of $\vec{A}$ in the direction of a directed line $S$ is $A_S = A\cos{\theta}$, where $\theta$ is the angle between $S$ and $\vec{A}$.\\A vector can be specified by its rectangular components along the $x$- and $y$-axes $$A_x = A\cos{\theta},$$ $$A_y = A\sin{\theta}.$$\\It can also be specified by its magnitude and direction through the Pythagorean theorem and the definition of tangent $$A=\sqrt{A_x^2 + A_y^2},$$ $$\tan{\theta} = \frac{A_y}{A_x}.$$\\We can hence define \underline{algebraic} addition of vectors such that $$\vec{A}\ =\ \vec{A} + \vec{B}\ \Longleftrightarrow C_x = A_x + B_x \textrm{ and } C_y = A_y + B_y.$$

\section*{Position, Velocity, and Acceleration}

The \textbf{position vector} of a particle at a point $\left(x, y\right)$ is a vector from the origin to the point $$\vec{r} = x\hat{i} + y\hat{j}.$$

\noindent
The \textbf{displacement} is the change in position $$\Delta{\vec{r}} = \vec{r}_2 - \vec{r}_1.$$

\noindent
The \textbf{average velocity} in the time interval $\Delta{t} = t_2 - t_1$ $$\vec{v}_{av} = \frac{\Delta{\vec{r}}}{\Delta{t}}.$$

\noindent
The \textbf{instantaneous velocity} $$\vec{v} = \lim_{\Delta{t} \to 0} \frac{\Delta{\vec{r}}}{\Delta{t}}.$$

\noindent
The \textbf{average acceleration} in the time interval $\Delta{t} = t_2 - t_1$ $$\vec{a}_{av} = \frac{\Delta{\vec{v}}}{\Delta{t}}.$$

\noindent
The \textbf{instantaneous acceleration} $$\vec{a} = \lim_{\Delta{t} \to 0} \frac{\Delta{\vec{v}}}{\Delta{t}}.$$

\section*{Relative Velocity}

Measurements of velocity depend on the reference frame of the observer. A reference frame is just a coordinate system.

\noindent
Consider a particle of velocity $\vec{v}_{pA}$ relative to reference frame A, which has velocity $\vec{v}_{AB}$ relative to frame B, the velocity of the particle relative to frame B is then $$\vec{v}_{pB} = \vec{v}_{pA} + \vec{v}_{AB}.$$\\However, this relative-velocity realtion is only true when the velocities are small compared to the speed of light.
\section*{Projectile Motion}

Consider an object projected with an initial velocity $\vec{v}_0$ at angle angle $\theta_0$ with the horizontal surface. The components of the velocity are $$v_{0x} = v_0 \cos{\theta_0},$$ $$v_{0y} = v_0 \sin{\theta_0}.$$

\noindent
In the absense of air resistance, the motion of the projectile is the superposition of a constant-velocity motion in the $x$-direction and a constant-acceleration in the $y$-direction. $$a_x = 0,$$ $$a_y = -g.$$

\noindent
Thus, the kinematics of one-dimensional motion can be applied $$\Delta{x} = v_{0x} t,$$ $$v_y = v_{0y} - gt,$$ $$\Delta{y} = v_{0y} t - \frac{1}{2} gt^2,$$ $$v_y^2 - v_{0y}^2 = -2g \Delta{y}.$$

We can also show that the path of the projectile is a parabola $$y = x\tan{\theta_0} - \frac{1}{2} \frac{g}{v_0^2 \cos{2\theta_0}}.$$

\end{document}


\section{Conclusion}

In this report, have presented an compared two algorithms on how regular languages can be learned. We can represent them via both minimum deterministic finite state automata or
canonical residual finite state automata. The first type of automaton is maybe more understandable for
humans: it is easy to check if automaton accepts a word, but on the other side, it can be much more
expensive in space.
Other studies have been done to seek other way to create automata which can be even smaller
then \textit{cRFSAs}, for example, we can have automata that use logical operators on transitions such as the
\textit{Alternating Finite State Automata} or other automata using links between symbols of the alphabet.
All of these algorithms are an evolution of the \textit{L*} algorithm and work on languages which are regular.
It should be interesting to see if it is possible to conceive learning algorithms for not regular languages
such as context-free grammars. Of course, these implementations would have to output more expressive
classes of automata such as the automata working with an auxiliary stack. It is clear, however, that the
more complicated the language is, the more powerful will be the returned data-structure representing it.
This \textit{TER} has been really compelling. I like automata and the paper I studied allowed me to discover
intriguing way to build them from a regular expression. I have also been able to understand the class of
\textit{cRFSA} automata that I didn’t know before, and, even if it is inside the \textit{NFA} automata world, it is possible
to define a unique \textit{canonical} representative for any regular language. Moreover, this \textit{TER} allowed me to
see how a researcher works and how satisfying it is to be able to code and test the algorithms studied. I
hope I could continue to work in this way in my future, because I think that the theory is a fundamental
tool letting you understand how, and above all why, the practical applications of the computer science
work.

% These algorithms

\subsection{Thanks}
I would like to thank Ms. Di Giusto and M. Lozes for their support during the development of this study, they have been really helpful to suggest me different approaches to analyze and different point of view to interpret the results I obtained.


\subsection{Representation Learning}\label{sec:dl}
Representation Learning or in common words Deep learning can be considered as a subset of machine learning but has gained attention as a different field due to its success in various vision, text and speech tasks. The difference about deep learning that makes it perform better on various complex problems is that it doesn't require domain expertise to identify the features to represent a problem or case from previous experience. Instead it automatically learns the features during training process using a large set of training data on various iterations.

Initially deep learning outperformed a lot of state-of-the-art algorithms in vision tasks and established itself as the benchmark solutions \cite{simonyan2014very,he2016deep}, but during the past few years with the advancement in computing powers and the availability of large datasets the \textbf{``The Deep Learning Tsunami''} \cite{manning2015computational} has taken over NLP as well. In this section we will sequentially talk about the development of deep learning applied in NLP to solve the various tasks.

\subsubsection{Word Embeddings} \label{sec:word_emb}
When using deep learning and to solve an NLP task, each word in the vocabulary is represented in a vector form so that it can be fed into the neural networks. Word embedding is the way of converting a word $w_{i}$ in vocabulary $V$ in the form of a vector of $n$ dimensions. These word vectors are generated by unsupervised training on a large corpus of words in order to gain the semantic similarities between the words. Algorithms like word2vec \cite{mikolov2013distributed} and GloVe \cite{pennington2014glove} are used to train these word embeddings. These word embeddings are generally pre-trained and made available to be downloaded from the internet and used directly in the deep learning models.

These distributed representation of words give a certain amount of semantic understanding of the words in a high dimensional vector space. For example, the distance between words $king$ and $queen$ will be similar to the distance between $boy$ and $girl$. In this contrast the \cref{eq:we1} fits perfectly.
% A visualization of these word embeddings in low dimension is shown in \cref{fig:glove_ex} \footnote{taken from \url{http://web.stanford.edu/class/cs224n/}}.

\begin{equation}\label{eq:we1}
    boy - girl + king = queen
\end{equation}

% \begin{figure}
%     \centering
%     \includegraphics[width=0.5\textwidth]{images/glove_vecs.png}
%     \caption{GloVe words visualization in 2D space}
%     \label{fig:glove_ex}
% \end{figure}

These representations have a drawback that they fail to take context of a word into account. For example, the word \textit{`Scotland'} will have a different meaning in the sentence \textit{`Scotland is one of the most best places to live on earth'} than in the sentence \textit{`Royal Bank of Scotland is one of the top banking firms in the UK'}. The glove or word2vec word embedding will fail to differentiate the two meanings of Scotland and will assign same vector in both the cases. These drawbacks are tackled by a new concept of contextual word embeddings discussed in \cref{sec:context_we}

\subsubsection{Language Models}\label{sec:lm}

\begin{figure}
    \centering
    \includegraphics[width=0.45\textwidth]{images/lang_model.png}
    \caption{Prediction of next word using a Language Model}
    \label{fig:lang_model}
\end{figure}

A language model is a type of system that predicts the probability of possible next words given a sequence of words as the input. In general terms, for a given sequence of input $(x_{1}, x_{2}, \cdots, x_{t})$, the probability distribution of next term $x_{t+1}$ is computed from a vocabulary $V$ of $k$ words ($V = (w_{1}, w_{2}, \cdots, w_{k})$).

\begin{equation}
    \label{eq:lm_dist}
        P(x_{t+1}|x_{1}, \cdots, x_{t})
\end{equation}

Earlier the language models were based on statistical approaches where they used to take a window of $n$ words as a context from the sentence to predict the next word. This approach is also known as $ngram$ Language Model. It takes an simple approach of calculating the conditional probability of next word in the sentence given the window of $n$ words as a context. These $ngram$ probabilities are calculated from counting them in some large corpus of text.

\begin{equation}
    \label{eq:lm_ngram}
        P(x_{t+1}|x_{1}, \cdots, x_{t}) =
            \frac {P(x_{t+1}, x_{t}, \cdots, x_{t-n+2})} {P(x_{t}, \cdots, x_{t-n+2})}
\end{equation}

or in simpler terms:

\begin{equation}
    \label{eq:lm_count_ngram}
        P(w_{3}|w_{1},w_{2}) = \frac{count(w_{1}, w_{2}, w_{3})}{count(w_{1}, w_{2})}
\end{equation}

This statistical approach has mainly two problems. First sparsity, consider the \cref{eq:lm_count_ngram}, what if $w_{1}$, $w_{2}$ and $w_{3}$ never occurred together. The probability of $w_{3}$ will be 0. Also, if $w_{1}$ and $w_{2}$ then there's no way to calculate the probability of $w_{3}$. Second storage, as we increase the value of $n$, the count of all $nrgams$ we see in the corpus increases as well and so does the need of memory to store them.

The neural language model using Recurrent Neural Networks (\cref{sec:rnn}) were able to model all the words in a sentence without having a need of window to predict the next word at each timestep using hidden state and output from the previous time step combining with the new input at each time step.

\subsubsection{Recurrent Neural Networks} \label{sec:rnn}
Text is a sequential form of data. To process text and extract information we need a model capable of processing the sequential data. \textit{Recurrent Neural Networks} \cite{elman1990finding} are the most elementary deep learning architectures that are able to learn from sequential data. RNN, are wide in nature as they unroll through time. These networks will have a `memory' component which can store the information about previous state. They share same set of weights throughout the layers, however, will receive a new input at every layer or time-step. The output to every time-step is dependent on the input taken at the current time-step $t_{i}$ as well as the information gained from previous time-step $t_{i-1}$. Specifically, an RN Net will maintain a hidden state $h_{t}$ at every step which is referred as the memory of network. An illustrated diagram of unrolled RNN is shown in fig \cref{fig:rnn_unrolled} \footnote{taken from \url{https://colah.github.io/posts/2015-08-Understanding-LSTMs/}}.

\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{images/RNN-unrolled.png}
    \caption{RNN Unrolled}
    \label{fig:rnn_unrolled}
\end{figure}

The operations performed in RNN at every time step is given in the \cref{eq:rnn}.

\begin{align}\label{eq:rnn}
    \begin{gathered}
        h_{t} = \sigma_{h}(W_{e}x_{t} + W_{h}h_{t-1} + b_{h}) \\
        y_{t} = \sigma_{y}(W_{y}h_{t} + b_{y})
    \end{gathered}
\end{align}

Here $\sigma_{y}$ and $\sigma_{h}$ are the activation functions. $W_{h}$ is the weight matrix to apply transformation on previous hidden state $h_{t-1}$, $W_{e}$ is the weight matrix to apply transformation on the input $x_{t}$ received over time $t$. Combining these with the bias $b_{h}$ yields hidden state $h_t$ for time $t$. Applying activation on the $h_{t}$ with $W_{y}$ gives the output $y_t$ for every time-step $t$.

\subsubsection{Long Short-Term Memory Networks}
Although, in theory the RNNs are designed to handle the sequence input but in practice they lack in storing the long term dependencies because of the problem of exploding and vanishing gradients \cite{bengio1994learning}. Long Short-Term Memory Networks \cite{hochreiter1997long} are the advanced version of RNNs with a slight modification of being capable of deciding what to `remember' and what to `forget' from the input sequence with the help of a series of gates. LSTM has a number of gates, an output gate, an input gate $i_{t}$, forget gate $f_{t}$, $o_{t}$, all of which are the functions of previous hidden state $h_{t}$ and current input $x_{t}$. These gates interact with the previous cell state $c_{t-1}$, the current input $x_{t}$, and the current cell state $c_{t}$ and enable the model to selectively retain or information from the sequence. The full version of LSTM is given in the \cref{eq:lstm}.

\begin{equation}\label{eq:lstm}
    \begin{gathered}
        f_{t} = \sigma_{g} (W_{f}x_{t} + U_{f}h_{t-1} + b_{f}) \\
        i_{t} = \sigma_{g} (W_{i}x_{t} + U_{i}h_{t-1} + b_{i}) \\
        o_{t} = \sigma_{g} (W_{o}x_{t} + U_{o}h_{t-1} + b_{o}) \\
        \Tilde{c_{t}} = \sigma_{c} (W_{c}x_{t} + U_{c}h_{t-1} + b_c)\\
        c_{t} = f_{t} \circ c_{t-1} + i_{t} \circ \Tilde{c_{t}}\\
        h_{t} = o_{t} \circ \sigma_{h}(c_{t})
    \end{gathered}
\end{equation}

where $\sigma_{g}$ is the $sigmoid$ activation function, $\sigma_{c}$ and $\sigma_{h}$ are the $tanh$ activation function, and $\circ$ is element-wise multiplication, also known as \textit{`Hadamard product'}. An illustrated diagram of unrolled RNN is shown in fig \cref{fig:lstm} \footnote{taken from \url{https://colah.github.io/posts/2015-08-Understanding-LSTMs/}}.

\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{images/lstm.png}
    \caption{LSTM}
    \label{fig:lstm}
\end{figure}

LSTM layers can be stacked on each other to form multiple layer LSTM architecture. One of the most popular LSTM architecture is Bidirectional LSTM (BiLSTM) \cite{graves2013hybrid}, where two separate LSTMs are ran forward and backward to gain the sequential information in both directions.

\subsubsection{Convolutional Neural Networks}
Convolutional Neural Networks \cite{lecun1998gradient} are the version of deep neural networks established as state-of-the-art in various computer vision tasks \cite{barbu2019objectnet,ali2019mfc}. After the release of AlexNet \cite{krizhevsky2012imagenet} in ImageNet competition 2012, CNNs have been the benchmark for almost every vision task. Inspired from the popularity of CNN in vision, researchers proposed an CNN architecture for sentence classification which outperformed many benchmarks on various text classification dataset ranging from sentiment analysis to topic classification \cite{kim2014convolutional}.

\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{images/cnn_text.png}
    \caption{CNN for sentence classification}
    \label{fig:cnn}
\end{figure}

CNNs are capable of computing vectors for all possible sub-phrases in a sentence, not just grammatically correct one as done by RNNs. A CNN takes an input sentence of word length $n$ where each word is represented distributively in $d$ dimension. So the input $X_{1:n}$ is a $2D$ matrix of shape $n \times d$  where $x_{i}$ $\epsilon$ $\mathbb{R}^d$. Input $X_{1:n}$ can be represented as \cref{eq:cnn_input}.

\begin{equation}
    \label{eq:cnn_input}
    X_{1:n} = x_{1} \oplus x_{2} \oplus \cdots \oplus x_{n}
\end{equation}

where $\oplus$ is the concatenation operator. On the input layer, convolution filter $W$  $\epsilon$ $\mathbb{R}^{hd}$ is applied over window of $h$ words to generate a new feature. So, a feature $c_{i}$ is generated from the word window $x_{i:i+h-1}$ with the following operation:

\begin{equation}
    c_{i} = \sigma (Wx_{i:i+h-1} + b)
\end{equation}

where $W$ is the weight matrix for the connections, $\sigma$ is the activation function and $b$ $\epsilon$ $\mathbb{R}$ is the bias. Now, this filter is applied to each possible window of words giving an feature map $C$ $\epsilon$ $\mathbb{R}^{n-h+1}$.

\begin{equation}
    C = [c_{1}, c_{2}, \cdots, c_{n-h+1}]
\end{equation}

The entries in feature map $C$ are sharing the parameter $W$, where each $c_{i}$ $\epsilon$ $C$ is a result of calculation on small segment of the input. Then a $max-pooling$ operation is applied on these feature maps to capture the most important part.

\begin{equation}
    \Tilde{C} = max(C)
\end{equation}

This parameter sharing helps the model to incorporate an inductive bias into the model, helping to become learn the location invariant local features. There are $k$ number of filters applied to the input with different window sizes which are then concatenated to form a vector $\textbf{K}$ $\epsilon$ $\mathbb{R}^k$. Which is then fed to next hidden layer or output layer.

An illustrated diagram of an CNN architecture for text classification is shown in fig \cref{fig:cnn} \footnote{taken from \cite{kim2014convolutional}}.

\subsubsection{Sequence  to Sequence Models}
Most of the NLP tasks require sequential output instead of a single output label unlike classification or regression \cite{sutskever2014sequence}. These tasks can be Machine Translation of natural language, Question-Answering or Summary generation systems. These systems take a sequence of input and process it to produce yet another sequence for output. The goal is to take a sequence $(x_{1}, x_{2}, \cdots, x_{n})$ as input and map it to another sequence $(y_{1}, y_{2}, \cdots, y_{n})$ as output.

The architecture used to deal with these kind of problems is known as Sequence to Sequence model or in common terms, seq2seq model. It is a combination of auto-encoders and decoders which works in a sequential manner where encoder is an neural architecture to generate a context vector from input sequence and decoder, another neural architecture taking context vector as input and generating the output sequence.

The encoder takes an input $X$ and maps it to fixed size context vector $Z$ using the formula \cref{eq:enc}

\begin{equation}
    \label{eq:enc}
        Z = \sigma(WX + b)
\end{equation}

where $\sigma$ is activation function. A decoder then maps the context vector $Z$ to a new form of input $X^{\prime}$ as shown in equation \cref{eq:dec}

\begin{equation}
    \label{eq:dec}
        X^{\prime} = \sigma^{\prime}(W^{\prime}Z + b^{\prime})
\end{equation}

where $\sigma^{\prime}$ is another activation function. The loss is calculated as the squared error between original and reconstructed input as shown in equation \cref{eq:seq2seq_loss}. An illustrated diagram of seq2seq model is shown in fig \cref{fig:enc_dec} \footnote{Taken from \url{http://web.stanford.edu/class/cs224n/}}.

\begin{equation}
    \label{eq:seq2seq_loss}
        L = ||X-X^{\prime}||^{2}
\end{equation}

\begin{figure}
     \centering
     \begin{subfigure}[b]{0.25\textwidth}
         \centering
         \includegraphics[width=\textwidth]{images/encoder.png}
         \caption{Encoder}
         \label{fig:encoder}
     \end{subfigure}
    %  \hfill
     \begin{subfigure}[b]{0.25\textwidth}
         \centering
         \includegraphics[width=\textwidth]{images/decoder.png}
         \caption{Decoder}
         \label{fig:decoder}
     \end{subfigure}
        \caption{Encoder-Decoder architecture using LSTM for seq2seq model}
        \label{fig:enc_dec}
\end{figure}

\paragraph{Attention} A problem with general encoder-decoder model is that they give equal importance to all the parts of input sequence. Also, the input sequence is compressed into a single context vector which creates the bottleneck problem, where a long information is tried to be kept into one small representation.

A solution to this problem was proposed in the work \cite{bahdanau2014neural} introducing a new mechanism called Attention. Attention aligns the output at each decoding step to the whole input sequence in order to learn the most important part of the input aligning with the current step output by providing an attentive output.

Let's say we have calculated the encoding hidden states $(h_{1},  h_{2}, \cdots, h_{n})$ for the input sequence $(x_{1}, x_{2}, \cdots, x_{n})$ during the calculation of context vector $Z$. For a decoder hidden state $s_{t}$ on timestep $t$, we get attention score $e^{t}$ as follows:

\begin{equation}
    \label{eq:att_score}
        e^{t} = [s^{T}_{t}h_{1}, \cdots, s^{T}_{t}h_{n}]
\end{equation}

We take the softmax of these scores to get the attention distribution at timestep $t$.

\begin{equation}
    \label{eq:att_dist}
        \alpha^{t} = softmax(e^{t})
\end{equation}

The attention output $a_{t}$ is then calculated as the weighted sum of encoder hidden state using $\alpha^{t}$:

\begin{equation}
    \label{eq:att_out}
        a_{t} = \sum_{i=1}^{n} \alpha_{i}^{t}h_{i}
\end{equation}

Finally, we concatenate the attention output $a_{t}$ with decoder hidden state $s_{t}$ and proceed to calculate the negative log loss same as the non-attention decoder model.

\subsubsection{Contextual Word Embeddings}\label{sec:context_we}
As discussed in \cref{sec:word_emb}, the word embeddings generated by algorithms like word2vec \cite{mikolov2013distributed} and GloVe \cite{pennington2014glove} lacks the contextual awareness and fail to differentiate a word with different sense. For example, word $get$ has thirty different senses (meaning) in wordnet \footnote{\url{https://wordnet.princeton.edu/}} based on the different contexts. But if we use pre-trained word embeddings to generate the vector representation of $get$, it will be same for all the thirty times and we will loose the semantic information.

A new trend of transfer learning came in Deep Learning based NLP with the introduction works like ELMo \cite{peters2018deep} and ULMFiT \cite{howard2018universal} where language models are used to learn the nuances of the language grammar and then the pre-trained language model is then fine-tuned on a task specific dataset to achieve better results.

\begin{figure}
    \centering
    \includegraphics[width=0.75\textwidth]{images/elmo.png}
    \caption{ELMo Vector Representation}
    \label{fig:elmo}
\end{figure}

\paragraph{ELMo} stands for Embeddings Learned from Language Models \cite{peters2018deep} uses a bidirectional language model to capture the context of a word in a sentence from both sides (left to right and vice-versa). ELMo uses an character-level CNN to convert raw text into a word vector which is then fed into a bidirectional language model. The ouput of this BiLM is then sent to the next layer of BiLM to form a set of intermediate word vectors. The final output of ELMo is the weighted sum of raw vectors and the intermediate vectors formed from two layers of the BiLMs. The two language models used here are based on LSTM architectures. An illustration of ELMo is shown is \cref{fig:elmo} \footnote{Taken from \url{https://www.analyticsvidhya.com/blog/2019/03/learn-to-use-elmo-to-extract-features-from-text/}}.

ELMo achieved 9\% error reduction on the SQuAD (question-answering) dataset compared to then state-of-the-art, 16\% on Ontonotes SRL dataset, 10\% on Ontonotes coreference dataset and 4\% on CoNLL 2003 dataset. It paved a huge path in the success of contextualized word representations for different tasks in NLP.

\paragraph{ULMFiT} stands for Universal Language Model Fine Tuning, introduced the way of applying transfer learning on text classification problem \cite{howard2018universal}. It does so in three main steps: first, train an general domain language model on large corpus of text (mainly Wikipedia); second, fine tune the language model on task specific target dataset; and third, use the again fine tune the fine-tuned language model as classifier by adding a softmax activation on top with target dataset. An illustration of the three steps of ULMFiT is shown in \cref{fig:ulmfit_steps}.

% \begin{figure}
%     \centering
%     \includegraphics[width=\textwidth]{images/ulmfit.png}
%     \caption{ULMFiT Steps}
%     \label{fig:ulmfit}
% \end{figure}

\begin{figure}
     \centering
     \begin{subfigure}[b]{0.3\textwidth}
         \centering
         \includegraphics[width=\textwidth]{images/ulm1.png}
         \caption{LM Training}
         \label{fig:lm_train}
     \end{subfigure}
    %  \hfill
     \begin{subfigure}[b]{0.3\textwidth}
         \centering
         \includegraphics[width=\textwidth]{images/ulm2.png}
         \caption{LM Fine-Tuning}
         \label{fig:lm_ft}
     \end{subfigure}
    %  \hfill
     \begin{subfigure}[b]{0.3\textwidth}
         \centering
         \includegraphics[width=\textwidth]{images/ulm3.png}
         \caption{Classifier Training}
         \label{fig:lm_classif}
     \end{subfigure}
        \caption{ULMFiT Steps \cite{howard2018universal}}
        \label{fig:ulmfit_steps}
\end{figure}

ULMFiT achieved better results for text classification on six different datasets ranging from topic classification to sentiment analysis. It did so by learning the general rules of grammar from huge corpus of text and then transferring that learning with fine tuning on a task-specific dataset providing better results than state-of-the-arts \cite{howard2018universal}.

\subsubsection{Transformers}\label{sec:transformers}
Almost all of the models we discussed have recurrent behaviour, which can not be trained parallely. This imposes a huge problem of time taken to train a model from scratch. In the work \cite{vaswani2017attention}, authors proposed a new neural architecture called Transformers which uses a combination of self attention and feed-forward network in its encoder-decoder model and doesn't require any recurrent or convolutional elements. This new seq2seq model was a huge success where it gained better performance on various sequential NLP tasks. To name one, it improved the machine translation performance by 10\% on WMT EN-FR and WMT EN-DE datasets. It also reduced the training time by large margin benefiting its non-recurrent nature \cite{vaswani2017attention}.

The success of transformer architecture paved the way for development of new models to solve the sequential tasks. It helped NLP researchers to utilize its non-recurrent nature in transfer learning where the transformer is used for general pre-training of a language model on large corpus of text which can be used for fine-tuning on domain specific dataset for downstream tasks. An encoder-decoder model of Transformer architecture is shown in the \cref{fig:trans}.

\begin{figure}
    \centering
    \includegraphics[width=0.5\textwidth]{images/transformer.png}
    \caption{Transformer architecture \cite{vaswani2017attention}.}
    \label{fig:trans}
\end{figure}

\paragraph{Generative Pre-Training}
One of the earliest works in using Transformers for pre-training of language model was presented in \cite{radford2018improving}. Following the idea from ELMo \cite{peters2018deep}, authors proposed a language model using transformer decoder trained on large corpus and then fine-tuned on task specific dataset. The main difference of GPT from ELMo is that ELMo uses two independent LSTM language models to caputre the forwards and backward context whereas in case of GPT, it uses a uni-directional multi-layer transformer language model capable of capturing context due to its attentive nature.

ELMo takes a feature based approach of feeding feature vectors for different tasks into different models, whereas GPT takes a fine-tuning based approach where same language model trained on huge corpus is fine-tuned for downstream tasks without changing the architecture. An illustration of a GPT model used for pre-training is shown in \cref{fig:gpt} \footnote{Taken from \url{https://openai.com/blog/language-unsupervised/}}.

\begin{figure}
    \centering
    \includegraphics[width=0.75\textwidth]{images/GPT.png}
    \caption{GPT architecture.}
    \label{fig:gpt}
\end{figure}

\paragraph{Bidirectional Encoder Representation from Transformers}
BERT \cite{devlin2018bert} is another example of the success of transfer learning in NLP. BERT is a bidirectional transformer language model trained on a large text corpus that can be fine-tuned on any domain specific dataset for the downstream tasks like text classification or named entity recognition. BERT mainly differs from other models like GPT and ELMo because of the pre-training tasks used during the unsupervised training of language model. It involves two tasks; first, Masked Language Model (MLM) \cite{taylor1953cloze} or prediction of the masked word in a sentence, and second, prediction of next sentence from the corpora.

For the first task of Masked Language Model, let’s say we have a sentence ‘Boris Johnson is the Prime Minister of UK’. So instead of training for prediction of next word in the sentence as a general Language Model, BERT pre-training replaces 15\% of the words with a [MASK] token and learns to predict the correct word at the position of [MASK] token. In the second task of Next Sentence Prediction, the model is trained to learn the relationship between sentences where for a given sentence pair A \& B, the model is asked to predict if the sentence B is actually the next sentence that comes after A or not?

BERT improved the fine-tuning based approach of GPT by using a bidirectional transformer for masked language modelling by learning the both left and right context which is a huge improved over GPT's unidirectional approach specially for token-level tasks like Question Answering where the answer depends on both left and right contexts. An illustrated diagram of BERT pre-training and fine-tuning is shown in \cref{fig:bert1}.
% A visual comparison between BERT, GPT and ELMo architectures presented in the work \cite{devlin2018bert} is shown in \cref{fig:bert2}.

\begin{figure}
    \centering
    \includegraphics[width=0.75\textwidth]{images/bert1.png}
    \caption{BERT \cite{devlin2018bert}}
    \label{fig:bert1}
\end{figure}

% \begin{figure}
%     \centering
%     \includegraphics[width=\textwidth]{images/bert2.png}
%     \caption{BERT, GPT and ELMo \cite{devlin2018bert}}
%     \label{fig:bert2}
% \end{figure}


\documentclass[main.tex]{subfiles}

\begin{document}
\subsection{Explain the technique of "the reduction" with the proof that $\text{HALT}_\text{TM} = \{(M, w) | M \text{ is a TM and } M \text{ halts on } w\}$ is undecidable}
\emph{cf Sipser, pp. 188 - 189}

Let's consider a related
problem, $\text{HALT}_\text{TM}$, the problem of determining whether a Turing machine halts
(by accepting or rejecting) on a given input. We use the undecidability of $\text{A}_\text{TM}$
to prove the undecidability of $\text{HALT}_\text{TM}$ by reducing $\text{A}_\text{TM}$ to $\text{HALT}_\text{TM}$.

\par\textbf{PROOF IDEA}
This proof is by contradiction. We assume that $\text{HALT}_\text{TM}$ is
decidable and use that assumption to show that $\text{A}_\text{TM}$ is decidable, contradicting Theorem 4.11 (cf section \ref{subsection:atm_undec}). The key idea is to show that $\text{A}_\text{TM}$ is reducible to $\text{HALT}_\text{TM}$.
\par Let's assume that we have a TM $R$ that decides $\text{HALT}_\text{TM}$. Then we use $R$ to
construct $S$, a TM that decides $\text{A}_\text{TM}$. To get a feel for the way to construct $S$,
pretend that you are S. Your task is to decide ATM. You are given an input of
the form $(M, w)$. You must output accept if $M$ \emph{accepts} $w$, and you must output \emph{reject} if M loops or rejects on $w$. Try simulating M on $w$. If it accepts or rejects,
do the same. But you may not be able to determine whether M is looping, and
in that case your simulation will not terminate. That's bad, because you are a
decider and thus never permitted to loop. So this idea, by itself, does not work.
\par Instead, use the assumption that you have TM $R$ that decides $\text{HALT}_\text{TM}$. With
$R$, you can test whether M halts on $w$. If $R$ indicates that M doesn't halt on $w$,
reject because $(M, w)$ isn't in $\text{A}_\text{TM}$. However, if $R$ indicates that M does halt on
$w$, you can do the simulation without any danger of looping.
\par Thus, if TM $R$ exists, we can decide $\text{A}_\text{TM}$, but we know that $\text{A}_\text{TM}$ is undecidable. By virtue of this contradiction we can conclude that $R$ does not exist.
Therefore $\text{HALT}_\text{TM}$ is undecidable.

\par\textbf{PROOF}
Let's assume for the purposes of obtaining a contradiction that TM
$R$ decides $\text{HALT}_\text{TM}$. We construct TM $S$ to decide $\text{HALT}_\text{TM}$, with $S$ operating as follows.

$S$ = "On input $(M, w)$, an encoding of a TM M and a string $w$:
\begin{enumerate}
    \item Run TM $R$ on input $(M, w)$.
    \item If $R$ rejects, $reject$.
    \item If $R$ accepts, simulate $M$ on $w$ until it halts.
    \item If $M$ has accepted, accept; if $M$ has rejected, $reject$.
\end{enumerate}{}

Clearly, if $R$ decides $\text{HALT}_\text{TM}$, then S decides ATM. Because $\text{A}_\text{TM}$ is undecidable, $\text{HALT}_\text{TM}$ also must be undecidable.

\subsection{Explain the technique of "the reduction" with the proof that $\text{REGULAR}_\text{TM} = \{(M) | M \text{ is a TM and } L(M) \text{ is a regular language } \}$ is undecidable}
\emph{cf Sipser, pp. 191}

\par\textbf{PROOF IDEA}
As usual for undecidability theorems, this proof is by reduction
from $\text{A}_\text{TM}$. We assume that $\text{REGULAR}_\text{TM}$ is decidable by a TM $R$ and use this assumption to construct a TM $S$ that decides $\text{A}_\text{TM}$. Less obvious now is how to use $R$'s ability to assist $S$ in its task. Nonetheless we can do so.
\par The idea is for $S$ to take its input $(M, w)$ and modify $M$ so that the resulting $TM$ recognizes a regular language if and only if $M$ accepts $w$. We call the modified machine $M_2$ . We design $M_2$ to recognize the nonregular language
$\{0^n1^n | n \geq 0 \}$ if $M$ does not accept $w$, and to recognize the regular language $\Sigma^*$ if $M$ accepts $w$. We must specify how $S$ can construct such an $M_2$ from $M$ and $w$. Here, $M_2$ works by automatically accepting all strings in $\{0^n1^n | n \geq 0 \}$ . In addition, if $M$ accepts $w$, $M_2$ accepts all other strings.

\par\textbf{PROOF}
We let $R$ be a TM that decides $\text{REGULAR}_\text{TM}$ decide $\text{A}_\text{TM}$. Then $S$ works in the following manner.

$S$ = "On input $(M, w)$, where $M$ is a TM and $w$ is a string:
\begin{enumerate}
    \item Construct the following TM $M_2$.
    \par $M_2$ = "On input $x$:
        \begin{enumerate}
            \item If $x$ has the form $0^n1^n$, $accept$
            \item If $x$ does not have this form, run $M$ on input $w$ and
$accept$ if $M$ accepts $w$."
        \end{enumerate}{}
    \item Run $R$ on input $(M_2)$.
    \item If $R$ accepts, $accept$; if $R$ rejects, $reject$."
\end{enumerate}{}

\subsection{Let $A_\text{LBA} = \{(B, w) | B \text{ is a linear bounded automata and } B \text{ accepts } w \}$, explain why this language is decidable}

\emph{cf Sipser, pp. 194 - }

\par\textbf{PROOF IDEA}
In order to decide whether LBA $M$ accepts input $w$, we simulate
$M$ on $w$. During the course of the simulation, if $M$ halts and accepts or rejects,
we accept or reject accordingly. The difficulty occurs if $M$ loops on $w$. We need
to be able to detect looping so that we can halt and reject.
\par The idea for detecting when $M$ is looping is that, as $M$ computes on $w$, it
goes from configuration to configuration. If $M$ ever repeats a configuration it
would go on to repeat this configuration over and over again and thus be in
a loop. Because $M$ is an LBA, the amount of tape available to it is limited. By
Lemma 5.8, $M$ can be in only a limited number of configurations on this amount
of tape. Therefore only a limited amount of time is available to $M$ before it
will enter some configuration that it has previously entered. Detecting that $M$ is
looping is possible by simulating $M$ for the number of steps given by Lemma 5.8.
If $M$ has not halted by then, it must be looping.

\par\textbf{PROOF}
The algorithm that decides $\text{A}_\text{LBA}$ is as follows.
L = "On input $(M, w)$, where $M$ is an LBA and $w$ is a string:
\begin{enumerate}
    \item Simulate $M$ on $w$ for $qng^n$ steps or until it halts.
    \item If $M$ has halted, $accept$ if it has accepted and $reject$ if it has
rejected. If it has not halted, $reject$."
\end{enumerate}{}

If $M$ on $w$ has not halted within $qng^n$ steps, it must be repeating a configuration according to Lemma 5.8 and therefore looping. That is why our algorithm
rejects in this instance.

\subsection{State Rice’s Theorem and prove it. Give two problems that can be proved
undecidable by applying Rice’s Theorem}

\emph{cf Sipser, pp. 213}
\begin{mytheo*}{}
Let $P$ be any nontrivial property of the language of a Turing
machine. Prove that the problem of determining whether a given Turing machine's
language has property $P$ is undecidable.
In more formal terms, let $P$ be a language consisting of Turing machine descriptions where $P$ fulfills two conditions. First, $P$ is nontrivial -- it contains some, but
not all, TM descriptions. Second, $P$ is a property of the TM's language-whenever
$L(M_1) = L(M_2)$, we have $(M_1) \in P \text{ iff } (M2) \in P$. Here, $M_1$ and $M_2$ are any TMs. Prove that $P$ is an undecidable language.
\end{mytheo*}

\emph{cf Sipser, pp. 215}
\par\textbf{PROOF}
Assume for the sake of contradiction that $P$ is a decidable language satisfying the
properties and let $R_p$ be a TM that decides $P$. We show how to decide $\text{A}_\text{TM}$ using $R_p$ by constructing TM $S$. First let $T_{\o}$ be a TM that always rejects, so $L(T_{\o}) = \o$.
You may assume that $(T_{\o}) \notin P$ without loss of generality, because you could proceed with $\bar{P}$ instead of $P$ if $(T_{\o}) \in P$. Because $P$ is not trivial, there exists a TM $T$ with $(T) \in P$. Design $S$ to decide $\text{A}_\text{TM}$ using $R_p$'s ability to distinguish between $T_{\o}$ and $T$.
S = "On input $(M, w)$:
\begin{enumerate}
    \item Use $M$ and $w$ to construct the following TM $M_w$.
    \par $M_w$, = "On input $x$:
        \begin{enumerate}
            \item Simulate $M$ on $w$. If it halts and rejects, $reject$.
            \par If it accepts, proceed to stage 2
            \item Simulate $T$ on $x$. If it accepts, $accept$."
        \end{enumerate}{}
    \item Use TM $R_p$ to determine whether $(M_w) \in P$. If YES, $accept$.
    \par If NO, $reject$."
\end{enumerate}{}

TM $M_w$ simulates $T$ if $M$ accepts $w$. Hence $L(M_w)$ equals $L(T)$ if $M$ $accepts$ $w$ and $\o$ otherwise. Therefore $(M, w) \in P \text{ iff } M \text{ accepts } w$.

\subsection{Define the notion of "reduction function" $f : \Sigma^{*} \rightarrow \Sigma^{*}$ from a problem $A$ to a problem $B$ and prove the following theorem: "If $A \leq B$ and $B$ is decidable then $A$ is decidable" where $A \leq B$ reads "A is reducible to B"}

\emph{cf Slides ch5}
\begin{mytheo*}{}
A function $f:\Sigma^* \rightarrow \Sigma^*$ is a reduction from problem $A \subseteq \Sigma*$ to problem $B \subseteq \Sigma*$ if the following conditions hold:
\begin{enumerate}
    \item $f$ is a computable function, i.e. there is an algorithm (termination is guaranteed) that given a finite word $w$, it computes the finite word $f(w)$.

    \item $w \in A \text{ iff } f(w) \in B$, this ensures that positive instances of the problem $A$ are translated into positive instances of the problem $B$, and negative instances of the problem $A$ are translated into negative instances of the problem $B$.
\end{enumerate}{}
Clearly, if there exists a reduction from $A$ to $B$ and $B$ is decidable then $A$ must be
decidable.
Conversely, if there exists a reduction from $A$ to $B$ and $A$ is undecidable then $B$
must be undecidable.
\end{mytheo*}

\emph{NB: When a language $A$ is mapping reducible to $B$, we note it $A \leq_m B$.}

\textbf{THEOREM} \textit{If $A \leq_m B$ and $B$ is decidable then $A$ is decidable.}
\par\textbf{PROOF}
We let $M$ be the decider for $B$ and $f$ be the reduction from $A$ to $B$.
We describe a decider N for $A$ as follows.
N="on input $w$:
\begin{enumerate}
    \item Compute $f(w)$.
    \item Run $M$ on input $f(w)$ and output whatever $M$ outputs.”
\end{enumerate}{}

Clearly, if $w \in A \text{ iff } f(w) \in B$ because $f$ is a reduction from $A$ to $B$. Then M accepts $f(w) \text{ iff } w \in A$. So N decides $A$.

\textbf{Corollary} \textit{If $A \leq_m B$ and $A$ is undecidable then $B$ is undecidable.}

Also:

\textbf{THEOREM} \textit{If $A \leq_m B$ and $B$ is Turing recognizable then $A$ is Turing recognizable.}

\textbf{Corollary} \textit{If $A \leq_m B$ and $A$ is not Turing recognizable then $B$ is not Turing recognizable.}

\end{document}


\chapter{Introduction}

The main purpose of this book is to record the current state of my
research. The book is however written in such a way that it can be
used as a textbook for studying my research.

For the latest version of this file,
related materials, articles, research questions, and erratum consult
the Web page of the author of the book:\\
\url{http://www.mathematics21.org/algebraic-general-topology.html}

\section{License and editing}

This work is licensed under the Creative Commons Attribution 4.0 International
License. To view a copy of the license, visit\\
\href{http://creativecommons.org/licenses/by/4.0/}{http://creativecommons.org/licenses/by/4.0/}.

You can create your own copy of \LaTeX{} source of the book and edit it (to correct errors, add new results, generalize existing results,
enhance readability).
The editable source of the book is presented at\\
\href{https://bitbucket.org/portonv/algebraic-general-topology}{https://bitbucket.org/portonv/algebraic-general-topology}

Please consider reviewing this book at\\
\href{http://www.euro-math-soc.eu/node/add/book-review}{http://www.euro-math-soc.eu/node/add/book-review}

If you find any error (or some improvement idea), please report in our bug tracker:\\
\url{https://bitbucket.org/portonv/algebraic-general-topology/issues}

\section{Intended audience }

This book is suitable for any math student as well as for researchers.

To make this book be understandable even for first grade students,
I made a chapter about basic concepts (posets, lattices, topological
spaces, etc.), which an already knowledgeable person may skip reading.
It is assumed that the reader knows basic set theory.

But it is also valuable for mature researchers, as it contains much
original research which you could not find in any other source except
of my work.

Knowledge of the basic set theory is expected from the reader.

Despite that this book presents new research, it is well structured
and is suitable to be used as a textbook for a college course.

Your comments about this book are welcome to the email \href{mailto:porton@narod.ru}{porton@narod.ru}.

\section{Reading Order }

If you know basic order and lattice theory (including Galois connections
and brouwerian lattices) and basics of category theory, you may skip
reading the chapter ``\nameref{chap-common}''.

You are recommended to read the rest of this book by the order.

\section{Our topic and rationale}

From \cite{mw-gen-top}: \emph{Point-set topology, also called set-theoretic
topology or general topology, is the study of the general abstract
nature of continuity or ``closeness'' on spaces. Basic point-set
topological notions are ones like continuity, dimension, compactness,
and connectedness.}

In this work we study a new approach to point-set topology (and pointfree
topology).

Traditionally general topology is studied using topological spaces
(defined below in the section ``\nameref{sec-top}''). I however
argue that the theory of topological spaces is not the best method
of studying general topology and introduce an alternative theory,
the theory of \emph{funcoids}. Despite of popularity of the theory
of topological spaces it has some drawbacks and is in my opinion not
the most appropriate formalism to study most of general topology.
Because topological spaces are tailored for study of special sets,
so called open and closed sets, studying general topology with topological
spaces is a little anti-natural and ugly. In my opinion the theory
of funcoids is more elegant than the theory of topological spaces,
and it is better to study funcoids than topological spaces. One of
the main purposes of this work is to present an alternative General
Topology based on funcoids instead of being based on topological spaces
as it is customary. In order to study funcoids the prior knowledge
of topological spaces is not necessary. Nevertheless in this work
I will consider topological spaces and the topic of interrelation
of funcoids with topological spaces.

In fact funcoids are a generalization of topological spaces, so the
well known theory of topological spaces is a special case of the below
presented theory of funcoids.

But probably the most important reason to study funcoids is that funcoids
are a generalization of proximity spaces (see section ``\nameref{sec-prox}''
for the definition of proximity spaces). Before this work it was written
that the theory of proximity spaces was an example of a stalled research,
almost nothing interesting was discovered about this theory. It was
so because the proper way to research proximity spaces is to research
their generalization, funcoids. And so it was stalled until discovery
of funcoids. That generalized theory of proximity spaces will bring
us yet many interesting results.

In addition to \emph{funcoids} I research \emph{reloids}. Using below
defined terminology it may be said that reloids are (basically) filters
on Cartesian product of sets, and this is a special case of uniform
spaces.

Afterward we study some generalizations.

Somebody might ask, why to study it? My approach relates to traditional
general topology like complex numbers to real numbers theory. Be sure
this will find applications.

This book has a deficiency: It does not properly relate my theory
with previous research in general topology and does not consider deeper
category theory properties. It is however OK for now, as I am going
to do this study in later volumes (continuation of this book).

Many proofs in this book may seem too easy and thus this theory not
sophisticated enough. But it is largely a result of a well structured
digraph of proofs, where more difficult results are made easy by reducing
them to easier lemmas and propositions.

\section{Earlier works}

Some mathematicians were researching generalizations of proximities
and uniformities before me but they have failed to reach the right
degree of generalization which is presented in this work allowing
to represent properties of spaces with algebraic (or categorical)
formulas.

Proximity structures were introduced by Smirnov in \cite{geom-prox}.

Some references to predecessors:
\begin{itemize}
\item In \cite{gen-prox-uni1,gen-prox-uni2,some-props-prox-genunif,prox-gen-unif,compl-unif-prox}
generalized uniformities and proximities are studied.
\item Proximities and uniformities are also studied in \cite{complete-prox,prox-not-compl,compl-prox-acad,compl-prox1,compl-prox2}.
\item \cite{qunif,qunif2001} contains recent progress in quasi-uniform
spaces. \cite{qunif2001} has a very long list of related literature.
\end{itemize}
Some works (\cite{on-proximity-spaces}) about proximity spaces consider
relationships of proximities and compact topological spaces. In this
work the attempt to define or research their generalization, compactness
of funcoids or reloids is not done. It seems potentially productive
to attempt to borrow the definitions and procedures from the above
mentioned works. I hope to do this study in a separate volume.

\cite{mapping-prox} studies mappings between proximity structures.
(In this volume no attempt to research mappings between funcoids is
done.) \cite{quasi-unif-top} researches relationships of quasi-uniform
spaces and topological spaces. \cite{eq-prox-totbound-unif} studies
how proximity structures can be treated as uniform structures and
compactification regarding proximity and uniform spaces.

This book is based partially on my articles \cite{filters,funcoidsreloids,pointfree}.

\section{Kinds of continuity}

A research result based on this book but not fully included in this
book (and not yet published) is that the following kinds of continuity
are described by the same algebraic (or rather categorical) formulas
for different kinds of continuity and have common properties:
\begin{itemize}
\item discrete continuity (between digraphs);
\item (pre)topological continuity;
\item proximal continuity;
\item uniform continuity;
\item Cauchy continuity;
\item (probably other kinds of continuity).
\end{itemize}
Thus my research justifies using the same word ``continuity'' for
these diverse kinds of continuity.

See \url{http://www.mathematics21.org/algebraic-general-topology.html}

\section{Responses to some accusations against style of my exposition}

\begin{quote}
The proofs are generally hard to follow and unpleasant to read as they are just a bunch of equations thrown at you, without motivation or underlying reasoning, etc.
\end{quote}

I don't think this is essential. The proofs are not the most important thing in my book. The most essential thing are definitions. The proofs are just to fill the gaps. So I deem it not important whether proofs are motivated.

Also, note ``algebraic'' in the title of my book. The proofs are meant to be just sequences of formulas for as much as possible :-) It is to be thought algebraically. The meaning are the formulas themselves.

Maybe it makes sense to read my book skipping all the proofs? Some proofs contain important ideas, but most don't. The important thing are definitions.

\section{Structure of this book}

In the chapter ``\nameref{chap-common}'' some well known definitions
and theories are considered. You may skip its reading if you already
know it. That chapter contains info about:
\begin{itemize}
\item posets;
\item lattices and complete lattices;
\item Galois connections;
\item co-brouwerian lattices;
\item a very short intro into category theory;
\item a very short introduction to group theory.
\end{itemize}
Afterward there are my little additions to poset/lattice and category
theory.

Afterward there is the theory of filters and filtrators.

Then there is ``\nameref{common-top}'', which considers briefly:
\begin{itemize}
\item metric spaces;
\item topological spaces;
\item pretopological spaces;
\item proximity spaces.
\end{itemize}
Despite of the name ``Common knowledge'' this second common knowledge
chapter is recommended to be read completely even if you know topology
well, because it contains some rare theorems not known to most mathematicians
and hard to find in literature.

Then the most interesting thing in this book, the theory of funcoids,
starts.

Afterwards there is the theory of reloids.

Then I show relationships between funcoids and reloids.

The last I research generalizations of funcoids, \emph{pointfree funcoids},
\emph{staroids}, and \emph{multifuncoids} and some different kinds
of products of morphisms.

\section{Basic notation}

I will denote a set definition like $\setcond{x\in A}{P(x)}$ instead
of customary $\{x\in A\mid P(x)\}$. I do this because otherwise formulas
don't fit horizontally into the available space.

\subsection{\index{Grothendieck universe}Grothendieck universes}

We will work in ZFC with an infinite and uncountable Grothendieck
universe.

A Grothendieck universe is just a set big enough to make all usual
set theory inside it. For example if $\mho$ is a Grothendieck universe,
and sets $X,Y\in\mho$, then also $X\cup Y\in\mho$, $X\cap Y\in\mho$,
$X\times Y\in\mho$, etc.

\index{small set}A set which is a member of a Grothendieck universe
is called a \emph{small set} (regarding this Grothendieck universe).
We can restrict our consideration to small sets in order to get rid
troubles with proper classes.
\begin{defn}
Grothendieck universe is a set $\mho$ such that:
\begin{enumerate}
\item If $x\in\mho$ and $y\in x$ then $y\in\mho$.
\item If $x,y\in\mho$ then $\{x,y\}\in\mho$.
\item If $x\in\mho$ then $\subsets x\in\mho$.
\item If $\setcond{x_{i}}{i\in I\in\mho}$ is a family of elements of $\mho$,
then $\bigcup_{i\in I}x_{i}\in\mho$.
\end{enumerate}
\end{defn}
One can deduce from this also:
\begin{enumerate}
\item If $x\in\mho$, then $\{x\}\in\mho$.
\item If $x$ is a subset of $y\in\mho$, then $x\in\mho$.
\item If $x,y\in\mho$ then the ordered pair $(x,y)=\{\{x,y\},x\}\in\mho$.
\item If $x,y\in\mho$ then $x\cup y$ and $x\times y$ are in $\mho$.
\item If $\setcond{x_{i}}{i\in I\in\mho}$ is a family of elements of $\mho$,
then the product $\prod_{i\in I}x_{i}\in\mho$.
\item If $x\in\mho$, then the cardinality of $x$ is strictly less than
the cardinality of~$\mho$.
\end{enumerate}

\subsection{Misc}

In this book quantifiers bind tightly. That is $\forall x\in A:P(x)\land Q$
and $\forall x\in A:P(x)\Rightarrow Q$ should be read $\left(\forall x\in A:P(x)\right)\land Q$
and $\left(\forall x\in A:P(x)\right)\Rightarrow Q$ not $\forall x\in A:\left(P(x)\land Q\right)$
and $\forall x\in A:\left(P(x)\Rightarrow Q\right)$.

The set of functions from a set $A$ to a set $B$ is denoted as $B^{A}$.

I will often skip parentheses and write $fx$ instead of $f(x)$ to
denote the result of a function $f$ acting on the argument $x$.

I will denote $\rsupfun fX=\setcond{\beta\in\im f}{\exists\alpha\in X:\alpha\mathrel f\beta}$
(in other words $\rsupfun fX$ is the image of a set~$X$ under a function or binary relation~$f$)
and $X\rsuprel fY\Leftrightarrow\exists x\in X,y\in Y:x\mathrel{f}y$
for sets $X$, $Y$ and a binary relation $f$. (Note that functions
are a special case of binary relations.)

By just $\rsupfun f$ and $\rsuprel f$ I will denote the corresponding
function and relation on small sets.

\begin{obvious}
For a function~$f$ we have $\rsupfun{f}X = \setcond{f(x)}{x\in X}$.
\end{obvious}

\begin{defn}
$\rsupfun{f^{-1}}X$ is called the \emph{preimage} of a set~$X$ by a function (or, more generally, a binary relation)~$f$.
\end{defn}

\begin{obvious}
$\{\alpha\}\rsuprel f\{\beta\}\Leftrightarrow\alpha\mathrel f\beta$
for every $\alpha$ and $\beta$.
\end{obvious}
$\mylambda xD{f(x)}=\setcond{(x,f(x))}{x\in D}$ for a set $D$ and
and a form $f$ depending on the variable $x$.
In other words, $\mylambda xD{f(x)}$ is the function which maps elements~$x$ of a set~$D$ into $f(x)$.

I will denote source and destination of a morphism $f$ of any category
(See chapter~\ref{chap-common} for a definition of a category.)
as $\Src f$ and $\Dst f$ correspondingly. Note that below defined
domain and image of a funcoid are not the same as its source and destination.

I will denote $\GR(A,B,f)=f$ for any morphism $(A,B,f)$ of either
$\mathbf{Set}$ or $\mathbf{Rel}$. (See definitions of $\mathbf{Set}$
and $\mathbf{Rel}$ below.)

\section{Implicit arguments}

Some notation such that $\bot^{\mathfrak{A}}$, $\top^{\mathfrak{A}}$,
$\sqcup^{\mathfrak{A}}$, $\sqcap^{\mathfrak{A}}$ have indexes (in these examples~$\mathfrak{A}$).

We will omit these indexes when they can be restored from the context. For example,
having a function $f:\mathfrak{A}\rightarrow\mathfrak{B}$ where $\mathfrak{A}$,~$\mathfrak{B}$
are posets with least elements, we will concisely denote $f\bot = \bot$ for $f\bot^{\mathfrak{A}} = \bot^{\mathfrak{B}}$.
(See below for definitions of these operations.)

\begin{note}
In the above formula $f\bot = \bot$ we have the first~$\bot$ and the second~$\bot$ denoting different objects.
\end{note}

We will assume (skipping this in actual proofs) that all omitted indexes can be restored from context.
(Note that so called dependent type theory computer proof assistants do this like we implicitly.)
\section{Unusual notation}

In the chapter ``\nameref{chap-common}'' (which you may skip reading
if you are already knowledgeable) some non-standard notation is defined.
I summarize here this notation for the case if you choose to skip
reading that chapter:

Partial order is denoted as $\sqsubseteq$.

Meets and joins are denoted as $\sqcap$, $\sqcup$, $\bigsqcap$,
$\bigsqcup$.

I call element $b$ \emph{substractive} from an element~$a$ (of a distributive
lattice $\mathfrak{A}$) when the difference $a\setminus b$ exists.
I call $b$ \emph{complementive} to $a$ when there exists $c\in\mathfrak{A}$
such that $b\sqcap c=\bot$ and $b\sqcup c=a$. We will prove that
$b$ is complementive to $a$ iff $b$ is substractive from $a$ and
$b\sqsubseteq a$.
\begin{defn}
Call $a$ and $b$ of a poset $\mathfrak{A}$ \emph{intersecting},
denoted $a\nasymp b$, when there exists a non-least element $c$
such that $c\sqsubseteq a\land c\sqsubseteq b$.
\end{defn}

\begin{defn}
$a\asymp b\eqdef\lnot(a\nasymp b)$.
\end{defn}

\begin{defn}
I call elements $a$ and $b$ of a poset $\mathfrak{A}$ \emph{joining}
and denote $a\equiv b$ when there are no non-greatest element $c$
such that $c\sqsupseteq a\land c\sqsupseteq b$.
\end{defn}

\begin{defn}
$a\nequiv b\eqdef\lnot(a\equiv b)$.\end{defn}
\begin{obvious}
$a\nasymp b$ iff $a\sqcap b$ is non-least, for every elements $a$,
$b$ of a meet-semilattice.
\end{obvious}

\begin{obvious}
$a\equiv b$ iff $a\sqcup b$ is the greatest element, for every elements
$a$, $b$ of a join-semilattice.
\end{obvious}
I extend the definitions of pseudocomplement and dual pseudocomplement
to arbitrary posets (not just lattices as it is customary):
\begin{defn}
Let $\mathfrak{A}$ be a poset. \emph{Pseudocomplement} of $a$ is
\[
\max\setcond{c\in\mathfrak{A}}{c\asymp a}.
\]

If $z$ is the pseudocomplement of $a$ we will denote $z=a^{\ast}$.
\end{defn}

\begin{defn}
Let $\mathfrak{A}$ be a poset. \emph{Dual pseudocomplement} of $a$
is
\[
\min\setcond{c\in\mathfrak{A}}{c\equiv a}.
\]

If $z$ is the dual pseudocomplement of $a$ we will denote $z=a^{+}$.\end{defn}