\chapter{SWR detection in the literature}

We gathered a representative sample of research papers that discuss sharp wave-ripples (and/or other hippocampal oscillations). Different studies define these oscillations with different frequency bands -- these differences are listed in \cref{tab:bands}. \Cref{apx:offline-detection-algos,apx:online-detection-algos} quote papers that use SWR detection; specifically their description of the SWR detection procedure. Emphasis is added.

\begin{table}
\begin{tabular}{@{}lllll@{}}
\toprule
Source                     & Theta (Hz) & High gamma (Hz) & Ripple (Hz)  \\
\midrule
\citefull{Nadasdy1999}     &            &                 & 150 -- 250  \\
\citefull{Csicsvari2000}   &            &                 &  80 -- 250  \\
\citefull{Behrens2005}     &            &                 &  40 -- 400  \\
\citefull{OKeefe2007}      & 6 -- 12    & 30 -- 100       & 100 -- 200  \\
\citefull{Girardeau2009}   &            &                 & 100 -- 200  \\
\citefull{Ego-Stengel2009} &            &                 & 100 -- 400  \\
\citefull{Jadhav2012}, online &         &                 & 100 -- 400  \\
\citefull{Jadhav2012}, offline &        &                 & 150 -- 250  \\
\citefull{Buzsaki2015}     & 6 -- 10    & 100+            & 110 -- 200  \\
\citefull{Colgin2016}      & 6 -- 12    & 60 -- 100       & 150 -- 200  \\
\citefull{Sadowski2016}    &            &                 & 120 -- 250  \\
\citefull{Talakoub2016}    &            &                 &  80 -- 150  \\
\citefull{Eichenbaum2017}  & 4 -- 12    & 80 -- 140       & \\
\citefull{Dutta2018}       &            &                 & 150 -- 250  \\
\citefull{Olafsdottir2018} & 6 -- 12    &                 & 140 -- 250  \\
\midrule
\texttt{fklab}             & 6 -- 12    & 60 -- 140       & 140 -- 225  \\
L2 recording               & 5 -- 10    &                 & 100 -- 200  \\
\bottomrule
\end{tabular}
\captionn[, ]{Frequency bands of hippocampal LFP events}{according to different sources (both original research papers and literature reviews). When the source does not make a distinction between high and low gamma, the full gamma range is given. Note that \citeauthor*{Behrens2005} considered artificially induced SWR's in ex-vivo hippocampus slices. \Citeauthor*{Talakoub2016} studied macaque monkeys; other primary research papers studied rats. `\texttt{fklab}' refers to the default frequency bands used in the data-analysis software used in the Kloosterman lab. The last row refers to the dataset analysed in this thesis.}
\label{tab:bands}
\end{table}

\clearpage
\section{Offline detection algorithms}
\label{apx:offline-detection-algos}

\subsection{\authoryear{Nadasdy1999}}

\begin{quotebar}
``For the extraction of sharp-wave (SPW) ripple events during sleep, the wide-band recorded data were bandpass filtered digitally (\textbf{150–250 Hz}). The power (\textbf{root mean square}) of the filtered signal was calculated, and the beginning, peak, and end of individual ripple episodes were determined. The threshold for ripple detection was set to \textbf{7 SDs above the background mean} power (Csicsvari et al., 1999 \cite{Csicsvari1999}).'' \cite{Nadasdy1999}
\end{quotebar}

\subsection{\authoryear{Csicsvari2000}}

\begin{quotebar}
``\emph{Detection of SPW-Associated Fast Ripples}: The procedures described here were identical to those described earlier (Csicsvari et al., 1999b \cite{Csicsvari1999a}). The wide-band (1–5 kHz) recorded data was digitally band-pass filtered (\textbf{80–250 Hz}), and the power (\textbf{root-mean-square}) of the filtered signal was calculated for each electrode. The mean and standard deviation (SD) of the power signal were calculated to determine the detection threshold. Oscillatory epochs with a power of \textbf{one} or more \textbf{SD above the mean} were detected. The beginning and the end of oscillatory epochs were marked at points where the power fell below \textbf{0.5 SD}. Theta periods, detected by using the theta-delta power ratio (Csicsvari et al., 1999a \cite{Csicsvari1999}), were excluded from the analysis.'' \cite{Csicsvari2000}
\end{quotebar}

\subsection{\authoryear{Behrens2005}}

\begin{quotebar}
``For ripple detection, raw data were filtered with a Spike 2 software band-pass filter of \textbf{40--400 Hz} (threshold: \textbf{4--6} times the s.d. of \textbf{eventless baseline noise}). For sharp wave detection, recordings were low-pass filtered at 20 Hz.'' \cite{Behrens2005}
\end{quotebar}

\subsection{\authoryear{Girardeau2009}}

\begin{quotebar}
``Offline ripple detection was performed by band-pass filtering (\textbf{100--200 Hz}), \textbf{squaring and normalizing}, then thresholding the field potential recorded in CA1 pyramidal layer. Ripples were defined as events peaking at \textbf{>5 standard deviations} and lasting \textbf{<100 ms}.'' \cite{Girardeau2009}
\end{quotebar}

\subsection{\authoryear{Jadhav2012}}

\begin{quotebar}
``SWRs were detected during post-hoc analysis as described previously (11, 23). Raw LFPs recorded from the tetrodes used for online SWR detection were filtered between \textbf{150 – 250 Hz} and the SWR envelope was determined using a \textbf{Hilbert transform}. The envelope was \textbf{smoothed with a Gaussian with a s.d. of 4 ms and a width of 32 ms}. SWRs were defined as contiguous periods when the smoothed SWR envelope stayed \textbf{above 3 s.d.} of the mean [sic] for \textbf{at least 15 ms} on at least one tetrode.'' \cite{Jadhav2012}
\end{quotebar}

\subsection{\authoryear{Sadowski2016}}

\begin{quotebar}
``Ripples were detected offline in the LFP recorded on one CA1 channel. Raw LFP signal was filtered between \textbf{120 and 250 Hz}, and deflections in the ripple \textbf{power envelope} greater than \textbf{5 SDs from the mean} were classified as ripple events. Ripple start times were defined locally as when ripple power exceeded \textbf{2 SDs}. Samples of raw LFP and detected ripple times were compared manually to verify detection fidelity.'' \cite{Sadowski2016}
\end{quotebar}

\subsection{\authoryear{Dutta2018}}

\begin{quotebar}
``Post-recording, ripple events were defined on tetrodes that displayed characteristics of the CA1 area of the hippocampus. Specifically, the recorded LFP in one of the channels of the selected tetrode (same one subject to online detection for our realtime analysis) first had a digital reference subtracted away. This signal was then LFP band filtered with a 400 Hz low-pass infinite impulse response (IIR) filter (from Trodes). Afterwards the signal was decimated and ripple band filtered (\textbf{150–250 Hz}) with a \textbf{25 tap} finite impulse response (\textbf{FIR}) filter. Ripple band filtering was done using a forward and a time-reversed path, resulting in a net \textbf{zero group delay} (time shift from filtering). The instantaneous power of the ripple band filtered signal was then calculated via a \textbf{Hilbert Transform} and further \textbf{smoothened with a Gaussian kernel} with a \textbf{4 ms standard deviation}. Ripple events were detected as times when z-score of the smoothened power signal signal exceeded a threshold of \textbf{3 z-units} for \textbf{at least 15 ms}. The canonical ripple epochs were defined as the time points from which the processed signal \textbf{returned down to the mean before and after threshold crossings} \cite{Cheng2008,Kemere2013}.

In cases when multiple electrodes (typically channels on different tetrodes) are available for ripple detection, a different canonical definition is required. Ripples were initially defined using as above for each electrode. A canonical multichannel ripple was defined as one which is simultaneously detected on each electrode (two in our analysis). The multichannel ripple epoch is defined as the union of the detected single-channel ripple epochs, i.e., the start of the earliest ripple detected and to end with bound of last ripple detected. As such, we obtain a conservative ripple detection latency estimate while covering the entire span of the time the LFP is in a high ripple band power state. We reanalyzed our data with the canonical ripples being defined on different channels and tetrodes with a 300 tap bandpass FIR filter allowing 1\% “ripple” in the passband with -30 dB suppression in the stopband but our results and subsequent conclusions remained consistent.'' \cite{Dutta2018}
\end{quotebar}

\clearpage
\section{Online detection algorithms}
\label{apx:online-detection-algos}

\subsection{\authoryear{Girardeau2009}}

\begin{quotebar}
``The onset of SPW-Rs was detected online by filtering the signal in the ripple-band and thresholding it. [..] Brain signals were preamplified (..), acquired and \textbf{digitized} using two synchronized Power1401 systems (CED, Cambridge, UK). [..] In both cases (test and control) the number of stimulations was \textbf{limited to 5 per second}.'' \cite{Girardeau2009}
\end{quotebar}

\subsection{\authoryear{Ego-Stengel2009}}

\begin{quotebar}
``We selected one tetrode in CA1, for which the LFP signal exhibited ripple events of large amplitude, for online ripple detection. The LFP was amplified and filtered online in the ripple band by an \textbf{8th-order Butterworth lowpass filter at 400 Hz} followed by an \textbf{8th-order Butterworth highpass filter at 100 Hz} (KrohnHite 3384 analog filters, total gain 10,000). A threshold-crossing detector (FHC Window Discriminator) was used to generate TTL pulses when the ripple amplitude exceeded a value adjusted manually by the experimenter on the first experimental day for each rat (0.1 $\pm$ 0.02 mV). These pulses triggered isolated stimulation units via a computer- controlled burst generator with a preset 1-ms delay [..] A \textbf{2-s recovery period} was forced after any stimulation burst before the next stimulation could be triggered.'' \cite{Ego-Stengel2009}
\end{quotebar}

\subsection{\authoryear{Jadhav2012}}

\begin{quotebar}
``We disrupted awake hippocampal SWRs [..] with the use of an online feedback system similar to that used in previous studies that disrupted SWRs during post-behavior sleep \cite{Girardeau2009,Ego-Stengel2009}. SWRs in CA1 were detected by monitoring power in the ripple band simultaneously across multiple tetrodes. [..] This [detection-triggered stimulation] terminated the ripple oscillation \textbf{within 25 ms of SWR onset} and transiently inhibited CA1 spiking [..].\\
We recorded continuous local field potentials (LFP, filtered 0.5-400 Hz and sampled at 1500 Hz) from all tetrodes (one channel was chosen from each tetrode for LFP recording). [..]\\
\emph{Real-time detection algorithm}. Field potential signals from the 5-6 tetrodes chosen for online detection were broadly filtered in the ripple band (\textbf{20 tap band-pass IIR filter, 100-400 Hz}). In order to establish a disruption threshold, we calculated smoothed values of the mean and s.d. of the absolute value of the filtered LFP signal on each tetrode being used for detection using an iterative procedure:\footnotemark[1]{}
\begin{align*}
\mu\est_t &= \mu\est_{t-1} \ \frac{N\smooth - 1}{N\smooth}
                + \frac{\abs{o_t}}{N\smooth} \\
\sigma\est_t &= \sigma\est_{t-1} \ \frac{N\smooth - 1}{N\smooth}
                + \frac{\abs{\abs{o_t} - \mu\est_{t-1}}}{N\smooth}
\end{align*}
Here $\mu\est$ and $\sigma\est$ are the estimated mean and s.d. of the absolute value of the filtered LFP, $o$, and $N\smooth$ is the  number of samples for smoothing (typically 10000). We allowed these estimates to stabilize before each run session. To generate a smoothened estimate of the envelope ($n\est$) of the filtered LFP, we used the following iterative estimator:\footnotemark[2]{}
\[
n\est_t = (1 - g_{t-1}) n\est_{t-1} + g_{t-1} \abs{o_t}
\]
To allow for rapid detection of increases in power, we used a larger gain $g$ for periods when the envelope was increasing: when the envelope was decreasing ($\abs{o} \le n\est$), $g = 0.2$ when the envelope was increasing, we used a moving average of the last 19 values of $g$ and $1.2$:
\[
g_t =
\begin{cases}
    0.2,    & \text{if}\quad n\est_{t-1} \geq \abs{o} \\
    \ev{g_{t-20}, g_{t-19}, \tdots, g_{t-1}, 1.2},  & \text{otherwise}
\end{cases}
\]

The threshold for disruption was set to \textbf{4-6 s.d.\ above the mean}. To prevent false-positives, vHC stimulation was triggered only when the smoothed LFP envelope exceeded threshold on at least 2 tetrodes. Stimulation rate was limited to a maximum of 4 Hz by enforcing a \textbf{lock-out period of 250 ms} after each stimulation event.'' \cite{Jadhav2012}
\end{quotebar}

\footnotetext[1]{Equations rearranged for readability, and variable names substituted to match those used in this thesis. Note that $\mu\est$ and $\sigma\est$ are exponentially weighted moving averages of respectively $\abs{o}$ and $\abs{\abs{o} - \mu\est}$.}

\footnotetext[2]{Like $\mu\est$, $n\est$ is also an exponentially weighted moving average of $\abs{o}$, but with a much larger weight for the most recent value of $\abs{o}$. Testing the estimator of \citeauthor*{Jadhav2012} on our data, we find a weight $g$ that oscilates between 0.2 and values between 0.27 and 0.30.}

\subsection{\authoryear{Talakoub2016}}

\begin{quotebar}
``Local field potentials were [..] sampled at \textbf{32 kHz}. [..] Selecting the electrode channel with the highest-amplitude ripple activity [..].  In this study, we set the threshold to \textbf{6-sd} of the band activity, a value similar to rodent interruption studies. The 6-sd threshold was estimated based on the average and variance of the ripple band from earlier recordings which were consistent over days in these experiments (9.5 $\pm$ 0.1 \uV{} mean $\pm$ SEM).\newline
[..] the signals were bandpass filtered using a custom-designed finite impulse response (\textbf{FIR}) filter with \textbf{512 taps} (\textbf{16 ms delay}, which is about one cycle of ripple activity).\footnotemark[3]{} Activities slower than \textbf{80 Hz} or faster than \textbf{150 Hz} are suppressed more than 20 dB (Fig. [..]). '' \cite{Talakoub2016}
\end{quotebar}

\footnotetext[3]{An FIR filter has a constant group delay of $(\text{\# taps} - 1) / (2 f_s)$. A 512 tap FIR filter at $f_s = $ 32 kHz should therefore have a group delay of 8 ms (and not the reported 16 ms). Or, conversely, an FIR filter with a group delay of 16 ms should have $\approx$ 1024 taps at $f_s = $ 32 kHz (and not the reported 512 taps).}

\subsection{\authoryear{Dutta2018}}

\begin{quotebar}
``Like our canonical ripple detections, the realtime or online detection algorithm is comprised of single channel and multichannel modalities. The single channel case performs realtime reference subtraction from the LFP (filtered in the same way as the offline case) and \textbf{decimation from 30 kHz to 3 kHz} as in the canonical detection case. However, the difference between online and canonical detections begins from ripple band filtering. The decimated signal is \textbf{filtered to the ripple band with a 30 tap FIR filter}. In order to perform a realtime instantaneous power estimation and smoothing, the realtime algorithm computes the \textbf{absolute value of the ripple band filtered signal} and \textbf{further filters it by a 33 tap 50 Hz low-pass FIR} (instead of a Hilbert transform followed by Gaussian kernel smoothing). These filters cause an intrinsic sample delay from the offline case ($\approx$10.167 ms in our case). It is worth noting that the number of filter taps as well as filter types were determined by analyzing algorithmic delay and detection accuracy based on metrics described in the Data Analysis subsection. To normalize detection thresholds in the realtime case, the mean and standard deviation of the smoothed envelope are estimated over a 20 minute training period. In two $\approx$90 minute sleep box recording sessions, when we sampled 20 minute time intervals at random (N=1000), the resulting mean and standard deviation were within 5\% of the values for the entire sessions. This length of time and subsequent error in parameter estimation likely depends on the behavioral and/or sleep state of the animal — in our experimental recordings, animals were contained in a sleep box. realtime detections are then triggered when the envelope crosses a threshold defined as $\alpha$ standard deviations above the mean (threshold = $\alpha \cdot \sigma + \mu$) or $\alpha$ z-units. Following a detection, there is a \textbf{200 ms lockout period} where we ignore any further threshold crossings (i.e., to avoid stimulation artifacts). \textbf{Additionally}, we impose a hard \textbf{limit on the number of detections per second} (set to \textbf{three} during the experiments in this work).'' \cite{Dutta2018}
\end{quotebar}
% Group delay = 14.5 / 3 + 16 / 3 = 10.167  [check].


%-------------------------------------------------------------------------------
% Examples on how to make tables for ATLAS documents
% Responsible: Ian Brock (Ian.Brock@cern.ch)
%-------------------------------------------------------------------------------
% Specify where ATLAS LaTeX style files can be found.
\newcommand*{\ATLASLATEXPATH}{../../latex/}
%-------------------------------------------------------------------------------
\documentclass[UKenglish,texlive=2016]{\ATLASLATEXPATH atlasdoc}

% Standard packages that can and should be used in ATLAS papers
\usepackage{\ATLASLATEXPATH atlaspackage}
\usepackage{\ATLASLATEXPATH atlasbiblatex}
\usepackage{authblk}
\usepackage{verbatim}

\usepackage{\ATLASLATEXPATH atlasphysics}

\usepackage{../atlas_doc-defs}
\usepackage{atlas_tables-defs}

% Files with references in BibTeX format
\addbibresource{../atlas_latex.bib}

\graphicspath{{../../logos/}}

%-------------------------------------------------------------------------------
% Generic document information
%-------------------------------------------------------------------------------

% Set author and title for the PDF file
\hypersetup{pdftitle={ATLAS tables guide},pdfauthor={Ian Brock}}

\AtlasTitle{Guide to formatting tables for ATLAS documents}

\author{Ian C. Brock}
\affil{University of Bonn}

\AtlasAbstract{%
  This document illustrates the preferred style for tables in ATLAS documents.
  It illustrates what the tables should look like and also provides guidelines on how to achieve this look.

  This document was generated using version \ATPackageVersion\ of the ATLAS \LaTeX\ package.
  The \TeX\ Live version is set to \ATTeXLiveVersion.
  It uses the option \Option{atlasstyle}, which implies that the standard ATLAS preprint style is used.
}

%-------------------------------------------------------------------------------
\begin{document}

\maketitle

%-------------------------------------------------------------------------------
\section{General guidelines}
%-------------------------------------------------------------------------------

Tables should only contain as many lines as are needed for clarity.
Table~\ref{tab:yield:2dig} shows a good example that has been taken
from \enquote{Rounding --- ATLAS Recommendations}~\cite{atlas-rounding}.

\ifthenelse{\ATTeXLiveVersion < 2011}{%
  \sisetup{retainplus=true}
}{
  \sisetup{retain-explicit-plus=true}
}
\begin{table}[htbp]
  \ifthenelse{\ATTeXLiveVersion < 2012}{%
    \ifthenelse{\ATTeXLiveVersion < 2011}{%
      \sisetup{sepfour}
    }{
      \sisetup{group-digits=true, group-four-digits=true}
    }
  }{
    \sisetup{group-minimum-digits=4}
  }
  \caption{Example event yields spread over several orders of
    magnitude.}
  \label{tab:yield:2dig}
  \centering
  \begin{tabular}{%
      l
      r@{$\,\pm\,$}r
    }
    \toprule
    {Channel} & \multicolumn{2}{c}{Selected events} \\
    \midrule
    $WW, WZ, ZZ$               & \numRF{943.045}{3}  & \numRF{94.3045}{2} \\
    QCD multijets              & \numRF{2838.39}{2}  & \numRF{1419.19}{2} \\
    $Wc\bar{c}, Wb\bar{b}, Wc$ & \numRF{31178  }{2}  & \numRF{13094.8}{2} \\
    $W$ + jets                 & \numRF{10584.5}{3}  & \numRF{4445.49}{2} \\
    Single top $Wt$            & \numRF{1699.75}{3}  & \numRF{152.977}{2} \\
    $Z$ + jets                 & \numRF{2378.42}{2}  & \numRF{998.934}{2} \\
    Single top $s$             & \numRF{297.591}{3}  & \numRF{12.4988}{2} \\
    Single top $t$             & \numRF{3936.98}{3}  & \numRF{165.353}{2} \\
    $t\bar{t}$                 & \numRF{9386.28}{3}  & \numRF{901.083}{2} \\
    \midrule
    Expected                   & \numRF{63243}{2}    & \numRF{13968.5}{2} \\
    Data                       & \multicolumn{2}{l}{\num{73062}} \\
    \bottomrule
  \end{tabular}
\end{table}

An example of a wider and somewhat more complicated table is shown in \Tab{\ref{tab:intro:presentlimits}}.

\begin{table}[htbp]
  \caption[Present FCNC top quark decays experimental limits]{Present experimental limits at \SI{95}{\%} confidence level
    on the branching fractions of the FCNC top quark decay channels established by experiments of the LEP, HERA, Tevatron and LHC accelerators. }
  \label{tab:intro:presentlimits}
  \centering
  \begin{tabular}{lllll}
    \toprule
    Coupling & \multicolumn{2}{c}{LEP} & \multicolumn{2}{c}{HERA} \\
    \midrule
    $\BR(t\to q\gamma)$ & \num{2.4E-2} &                       & \num{6.4E-3} & ($tu\gamma$)\\
    $\BR(t\to qZ)$      & \num{7.8E-2} &                       & \num{49E-2} & ($tuZ$)\\
    $\BR(t\to qg)$      & \num{17E-2}  &                       & \num{13E-2} & \\
    \bottomrule
    Coupling & \multicolumn{2}{c}{Tevatron}                    & \multicolumn{2}{c}{LHC} \\
    \midrule
    $\BR(t\to q\gamma)$ & \num{3.2E-2} &                       & \multicolumn{1}{c}{---} \\
    $\BR(t\to qZ)$      & \num{3.2E-2} &                       & \num{7.0E-4}\\
    $\BR(t\to qg)$      & \num{2.0E-4} & ($tug$), $(2 \to 2)$  & \multicolumn{1}{c}{---} \\
                        & \num{3.9E-3} & ($tcg$), $(2 \to 2)$  & \multicolumn{1}{c}{---} \\
                        & \num{3.9E-4} & ($tug$), $(2 \to 1)$  & \num{5.7E-5} & ($tug$), $(2 \to 1)$\\
                        & \num{5.7E-3} & ($tcg$), $(2 \to 1)$  & \num{2.7E-4} & ($tcg$), $(2 \to 1)$\\
    \bottomrule
  \end{tabular}
\end{table}

A typical table containing Monte Carlo samples is given in \Tab{\ref{tab:mcsamples}}.

\begin{table}[htbp]
  \caption{Top quark event MC samples used for this analysis. The cross-section column includes $k$-factors and branching ratios.}
  \label{tab:mcsamples}
  \centering
  \renewcommand{\arraystretch}{1.2}
  \begin{tabular}{lSlS[table-format=9.0]SS[table-format=6.0]}
    \toprule
      & {$\sigma$ [\si{\pb}]} & Generator
      & \multicolumn{1}{c}{$N_{MC}$} & \multicolumn{1}{c}{$k$-factor} & \multicolumn{1}{c}{Dataset ID}\\
    \midrule
    $Wt$ all decays                         &  22           & \POWHEG + \PYTHIA        &   1000000  & 1.09 & 110140\\
    $t$-channel (lepton+jets) top           &  18           & \POWHEG + \PYTHIA        &   5000000  & 1.05 & 110090\\
    $s$-channel (lepton+jets) antitop       &  1.8          & \POWHEG + \PYTHIA        &   5000000  & 1.06 & 110091\\
    $t\bar{t}$ no fully hadronic            & 114           & \POWHEG + \PYTHIA        & 100000000  & 1.12 & 117050\\
    \bottomrule
  \end{tabular}
\end{table}

\Cref{tab:example1} shows the use of $\pm$ as the intercolumn
character for alignment. An alternative, as shown in
\cref{tab:example2}, is to use \verb+\phantom+ to put in extra
space equal to the width of a number if you have different numbers of
decimal places in the table.

The \texttt{booktabs} package provides the macros
\Macro{toprule}, \Macro{midrule}, \Macro{bottomrule} which are to be preferred over \Macro{hline},
as, among other things, they introduce some extra spacing around the lines, which is useful.

\begin{table}[htbp]
  \caption[Monte Carlo purities in the single lepton sample]{%
    Monte Carlo estimates of the fraction of each process in the single
    lepton data sample. This table uses ``S'' format from \texttt{siunitx} and
    ``\texttt{$\,\pm\,$}'' as the intercolumn separator.}
  \label{tab:example1}
  \centering
  \begin{tabular}{l S[table-format=2.1]@{$\;\pm\;$}S[table-format=1.1]@{\,}s
    S[table-format=3.1]@{\,}s}
    \toprule
    Category            & \multicolumn{3}{c}{$\mu$}&\multicolumn{2}{c}{$e$}\\
    \midrule
    $b \to \ell$        &     65.2 & 0.4 & \%   &  79.3 & \% \\
    $b \to c \to \ell$  &      7.8 & 0.3 & \%   &   5.4 & \% \\
    Total               &     73.0 & 0.2 & \%   &   9.1 & \% \\
    \bottomrule
  \end{tabular}
\end{table}

\begin{table}[htbp]
  \caption{Monte Carlo estimates of the fraction of each process in
    the single lepton data sample.
    This table uses \texttt{\textbackslash phantom}.}
  \label{tab:example2}
  \centering
  \begin{tabular}{lcc}
    \toprule
    Category            & \multicolumn{1}{c}{$\mu$}&\multicolumn{1}{c}{$e$}\\
    \midrule
    $b \to \ell$        & $    65.2 \pm 0.4\,\%$   &     79.3\,\% \\
    $b \to c \to \ell$  & $\pho 7.8 \pm 0.3\,\%$   & \pho 5.4\,\% \\
    Total               & $    73.0 \pm 0.2\,\%$   & \pho 9.1\,\% \\
    \bottomrule
  \end{tabular}
\end{table}

%-------------------------------------------------------------------------------
\section{\LaTeX\ packages for table}
%-------------------------------------------------------------------------------

The \LaTeX\ package \Package{booktabs} gives a number of guidelines on how tables should be formatted.
These are followed to a large extent in this document.
The following packages related to tables are included by default when you load the package \Package{atlaspackage}:
\begin{description}
\item[booktabs] useful tools for formatting tables;
\item[siunitx] tools for rounding and also for helping to format and align numbers in tables;
\end{description}
Further packages related to the formatting of tables are:
\begin{description}
\item[xtab] the most modern package for tables that spread over more than one page;
\item[longtable] an alternative package for long tables;
\item[supertabular] yet another alternative package for long tables;
\item[dcolumn] can be used as an alternative to \Package{siunitx} to align numbers in tables.
\end{description}
\Package{xtab} is included if you load \Package{atlaspackage} with the option \Option{full}.
You may also need to rotate a big table.
The \Package{rotating} package can be used for this.

In order to shorten commands when doing rounding in tables, it is useful to define a few extra macros.
Typical definitions can be found in the file \File{../atlas\_doc-defs.sty}.

If you use \Package{siunitx} to format your numbers,
you may have to adjust the option \Option{group-minimum-digits}.
As of Version 04-00-00 of \Package{atlaslatex} the default value is set to 5.
Hence \num{1234} will not have a space after the thousands digit,
whereas \num{12345} will have.
This is fine in text, but in tables, you probably want to use the option
\verb|\siseteup{group-minimum-digits=4}|, see \Tabs{\ref{tab:minimum-digits1}}{\ref{tab:minimum-digits2}}.

\begin{table}[htbp]
  \caption{Tables comparing different \Option{group-minimum-digits} values
  for the package \Package{siunitx}.}
  \label{tab:minimum-digits}
  \centering
  \subfloat[Table with \Option{group-minimum-digits=4}.]{%
  \ifthenelse{\ATTeXLiveVersion < 2012}{%
    \ifthenelse{\ATTeXLiveVersion < 2011}{%
      \sisetup{sepfour}
    }{
      \sisetup{group-digits=true, group-four-digits=true}
    }
  }{
    \sisetup{group-minimum-digits=4}
  }
  \begin{tabular}{lS[table-format=5.2]}
    Quantity & \multicolumn{1}{c}{Value}\\
    \midrule
    Value1 & 1234.56\\
    Value2 & 98765.43
  \end{tabular}
  % \caption{A table with \Option{group-minimum-digits=4}.}
  \label{tab:minimum-digits1}
  }
  \qquad
  \subfloat[Table with \Option{group-minimum-digits=5}.]{%
  \ifthenelse{\ATTeXLiveVersion < 2012}{%
    \ifthenelse{\ATTeXLiveVersion < 2011}{%
      \sisetup{group-digits=true}
    }{
      \sisetup{group-digits=true}
    }
  }{
    \sisetup{group-minimum-digits=5}
  }
  \begin{tabular}{lS[table-format=5.2]}
    Quantity & \multicolumn{1}{c}{Value}\\
    \midrule
    Value1 & 1234.56\\
    Value2 & 98765.43
  \end{tabular}
  % \caption{A table with \Option{group-minimum-digits=5}.}
  \label{tab:minimum-digits2}
  }
\end{table}

%-------------------------------------------------------------------------------
\section{Tables and rounding}
%-------------------------------------------------------------------------------

Further examples of tables can be found in the note discussing the ATLAS recommendation on rounding~\cite{atlas-rounding}.
A selection of those tables are also reproduced here.
The \LaTeX\ code for the examples given below can be found in
Appendix~\cref{sec:raw-data}.

The tables shown earlier in this document were also created with \textsf{siunitx}.
A few more examples of how to steer the formatting are given here.
Table~\ref{tab:rounding:xsect} compares two different approaches
to how this can be done  in \textsf{siunitx}, even for asymmetric errors.  Note that although these
tables look almost identical, the syntax used to create them is different (see Appendix~\ref{sec:raw-data}).
While the form may appear to be a bit clumsy at first, it is easy enough to get a
program to write out the lines. In the left-hand table
\Macro{numRP} is used in column 3, while the full syntax of \Macro{num}
in shown in column 4 for illustration purposes only.  The syntax
to change the precision of a single number is shown in the first line of
the left-hand part of the table. This is seen to be rather
trivial, but the alignment on the decimal point is now no longer
perfect. While this is probably OK for internal notes etc., papers
(should) have more stringent requirements. Another way of achieving
the same thing and avoiding the use of \textsf{round-mode} and
\textsf{round-precision} is shown in the code for the right-hand table. Note the
use of options for the \textsf{S} format and the use of \Macro{num} enclosed
in braces to format the row that requires a different precision.

\begin{table}[htbp]
  \caption{A selection of cross-section measurements. Note that
    for numbers with asymmetric errors, the option
    \texttt{\Macro{sisetup}{}\{retain-explicit-plus\}} is used to stop
    \textsf{siunitx} from dropping the plus signs on the positive
    errors. (although these tables look almost identical, the syntax used to
    create them is different --- see Appendix~\ref{sec:raw-data}).}
  \label{tab:rounding:xsect}
  \centering
  \renewcommand{\arraystretch}{1.4}
  \sisetup{retain-explicit-plus}
  \sisetup{round-mode = places}
  \begin{tabular}{%
      S@{\,:\,}S
      r@{\,}@{$\pm$}@{\,}l@{\,}l
       }
    \toprule
    \multicolumn{2}{c}{\etajet} & \multicolumn{3}{c}{\diffetab} \\
    \multicolumn{2}{c}{} & \multicolumn{3}{c}{[\si{\pico\barn}]} \\
    \midrule
    {\num{-1.6}} & -1.1 & \numRP{0.574}{3} & \num[round-precision=3]{0.094} & $^{\numRP{+0.035}{3}}_{\numRP{-0.031}{3}}$ \\
    {\num{-1.1}} & -0.8 & \numRP{1.213}{2} & \num[round-precision=2]{0.211} & $^{\numRP{+0.162}{2}}_{\numRP{-0.162}{2}}$ \\
    {\num{-0.8}} & -0.5 & \numRP{2.141}{2} & \num[round-precision=2]{0.219} & $^{\numRP{+0.223}{2}}_{\numRP{-0.123}{2}}$ \\
    {\num{-0.5}} & -0.2 & \numRP{2.326}{2} & \num[round-precision=2]{0.210} & $^{\numRP{+0.284}{2}}_{\numRP{-0.214}{2}}$ \\
    {\num{-0.2}} & +0.1 & \numRP{2.641}{2} & \num[round-precision=2]{0.220} & $^{\numRP{+0.283}{2}}_{\numRP{-0.233}{2}}$ \\
    {\num{+0.1}} & +0.5 & \numRP{3.160}{2} & \num[round-precision=2]{0.211} & $^{\numRP{+0.232}{2}}_{\numRP{-0.172}{2}}$ \\
    {\num{+0.5}} & +1.4 & \numRP{2.881}{2} & \num[round-precision=2]{0.154} & $^{\numRP{+0.201}{2}}_{\numRP{-0.301}{2}}$ \\
    \bottomrule
  \end{tabular}
  \quad
  \sisetup{round-mode = places, round-precision = 2}
  \begin{tabular}{%
      S[table-format=3.2, table-number-alignment = right]@{\,:\,}S
      S[round-mode = places, round-precision = 2,
      table-format = 1.3, table-number-alignment = right]
      @{$\,\pm\,$}
      S[round-mode = places, round-precision = 2,
      table-format = 1.3, table-number-alignment = left]
      @{\,}l
       }
    \toprule
    \multicolumn{2}{c}{\etajet} & \multicolumn{3}{c}{\diffetab} \\
    \multicolumn{2}{c}{} & \multicolumn{3}{c}{[\si{\pico\barn}]} \\
    \midrule
    -1.6 & -1.1 & {\numRP{0.574}{3}} & {\numRP{0.094}{3}} & $^{\numRP{+0.035}{3}}_{\numRP{-0.031}{3}}$ \\
    -1.1 & -0.8 & 1.213 & 0.211 & $^{\num{+0.162}}_{\num{-0.162}}$ \\
    -0.8 & -0.5 & 2.141 & 0.219 & $^{\num{+0.223}}_{\num{-0.123}}$ \\
    -0.5 & -0.2 & 2.326 & 0.210 & $^{\num{+0.284}}_{\num{-0.214}}$ \\
    -0.2 & +0.1 & 2.641 & 0.220 & $^{\num{+0.283}}_{\num{-0.233}}$ \\
    +0.1 & +0.5 & 3.160 & 0.211 & $^{\num{+0.232}}_{\num{-0.172}}$ \\
    +0.5 & +1.4 & 2.881 & 0.154 & $^{\num{+0.201}}_{\num{-0.301}}$ \\
    \bottomrule
  \end{tabular}
\end{table}

Cross-sections vs.\ $\eta$ are usually not so difficult to
format, as the magnitudes of the numbers do not change much from one
bin to the next. The situation is different for cross-sections as a
function of \ET\ or $x$. Tables~\ref{tab:xsect-ET} and
\ref{tab:xsect-x} show examples of such tables.

\begin{table}[htbp]
  \caption{Cross-section vs.\ $E_{T}$.}
  \label{tab:xsect-ET}
  \centering
  \renewcommand{\arraystretch}{1.4}
  \subfloat[No special formatting and
  \texttt{round-mode=figures}. This is the starting point for more
  refined formatting.]{%
    \input{cross_sections_charm-ET1}
    \label{tab:xsect-ET1}}
  \qquad
  \subfloat[Numbers adjusted according to the recommendations. \texttt{round-mode=places}
  is used for asymmetric errors (except the first row). Some judicious
  use of \Macro{phantom} is applied to get improved, but not yet perfect, alignment.]{%
    \input{cross_sections_charm-ET2}
    \label{tab:xsect-ET2}}
\end{table}

\texttt{round-mode=figures} is in general best for cross-sections and
their errors. A precision of 2 digits for the uncertainties is a good
starting point, but will then have to be reduced to 1 digit in some cases.
For the cross-section values, more digits (typically 3) probably have to
be specified and the precision of some values will again have to be
adjusted by hand. In Table~\ref{tab:xsect-ET2} some of the rounding
is adjusted by hand so that the numbers conform to the
rules. For the asymmetric errors, \texttt{round-mode=places} is used
and the precision of each asymmetric uncertainty is then set by hand.
This works well if the cross-sections should all be shown with decimal
points, but does not work if used to round a number such as
\num{182}. Hence the first row uses \texttt{round-mode=figures}. Even
with the tools offered by \Macro{siunitx} getting things exactly right
is non-trivial.

\begin{table}[htb]
  \caption{Cross-section vs.\ $x$.}
  \label{tab:xsect-x}
  \centering
  \renewcommand{\arraystretch}{1.4}
  \ifthenelse{\ATTeXLiveVersion < 2012}{%
    \centering\fbox{\parbox{0.8\textwidth}{%
      \textbf{This table does not appear here, as it uses features that were only
      properly implemented for \TeX\ Live 2012 and later.}
    }}
  }{%
    \subfloat[No special formatting or rounding. Option
      \textsf{scientific-notation=fixed} used.]{%
      \label{tab:xsect-x1}%
      \input{cross_sections_charm-x1}
    }
    \qquad
    \subfloat[Several fixes including rescaled cross-section. Quite a
      lot of \Macro{phantom} commands are applied to get alignment correct.]{%
      \label{tab:xsect-x2}%
      \input{cross_sections_charm-x2}
    }
  }
\end{table}

Table~\ref{tab:xsect-x} is probably the most challenging to format
correctly, as the bin boundaries also vary by several orders of
magnitude. Table~\ref{tab:xsect-x1} gives the numbers with the option
\textsf{scientific-notation=fixed} to illustrate the problem of what
the table would look like if the cross-sections are output in
\si{\pb}.  In Table~\ref{tab:xsect-x2}, the exponential format of
numbers is used to rescale the cross-section from \si{\pb} to
\si{\nb}.  \Macro{phantom} had to be used in more places than we
really like in order to get the final alignment
correct. Investigations are ongoing to see if this can be improved.

%-------------------------------------------------------------------------------
\section*{History}
%-------------------------------------------------------------------------------

\begin{description}
\item[2014-11-25: Ian Brock] First version of the document released.
\item[2018-02-15: Ian Brock] Moved table captions above tables to follow common convention.
\end{description}

%-------------------------------------------------------------------------------
% Print bibliography using biblatex
\printbibliography
%-------------------------------------------------------------------------------
% Old style bibtex bibliography
% \bibliographystyle{../../bibtex/bst/atlasBibStyleWithTitle}
% \bibliography{atlas_bibtex,atlas_biblatex}

\appendix
\section{\LaTeX\ code for tables}
\label{sec:raw-data}

This appendix gives the \LaTeX\ code including the raw data used for
Tables~\ref{tab:rounding:xsect},
\ref{tab:xsect-ET} and \ref{tab:xsect-x}.
These files for Tables~\ref{tab:xsect-ET} and \ref{tab:xsect-x} can also be
found in the \texttt{doc/atlas\_tables} directory of the \texttt{atlaslatex} package.
The options given here correspond to those that are need for \TeX\ Live 2012 and later.
See the code for the appropriate options for earlier versions.

\subsection{Table~\protect\ref{tab:rounding:xsect}}
\begin{verbatim}
\begin{table}[htbp]
  %
  \caption{A selection of cross-section measurements! Note the
  use of \Macro{sisetup} to keep the plus signs on the positive
  errors.}
  \label{tab:rounding:xsect}
  \centering
  \renewcommand{\arraystretch}{1.4}
  \sisetup{retain-explicit-plus}
  \sisetup{round-mode = places}
\begin{tabular}{%
S@{\,:\,}S
r@{\,}@{$\pm$}@{\,}l@{\,}l
}
\toprule
\multicolumn{2}{c}{\etajet} & \multicolumn{3}{c}{\diffetab} \\
\multicolumn{2}{c}{} & \multicolumn{3}{c}{[\si{\pico\barn}]} \\
\midrule
{\num{-1.6}} & -1.1 & \numRP{0.574}{3} & \num[round-precision=3]{0.094} &
$^{\numRP{+0.035}{3}}_{\numRP{-0.031}{3}}$ \\
{\num{-1.1}} & -0.8 & \numRP{1.213}{2} & \num[round-precision=2]{0.211} &
$^{\numRP{+0.162}{2}}_{\numRP{-0.162}{2}}$ \\
{\num{-0.8}} & -0.5 & \numRP{2.141}{2} & \num[round-precision=2]{0.219} &
$^{\numRP{+0.223}{2}}_{\numRP{-0.123}{2}}$ \\
{\num{-0.5}} & -0.2 & \numRP{2.326}{2} & \num[round-precision=2]{0.210} &
$^{\numRP{+0.284}{2}}_{\numRP{-0.214}{2}}$ \\
{\num{-0.2}} & +0.1 & \numRP{2.641}{2} & \num[round-precision=2]{0.220} &
$^{\numRP{+0.283}{2}}_{\numRP{-0.233}{2}}$ \\
{\num{+0.1}} & +0.5 & \numRP{3.160}{2} & \num[round-precision=2]{0.211} &
$^{\numRP{+0.232}{2}}_{\numRP{-0.172}{2}}$ \\
{\num{+0.5}} & +1.4 & \numRP{2.881}{2} & \num[round-precision=2]{0.154} &
$^{\numRP{+0.201}{2}}_{\numRP{-0.301}{2}}$ \\
\bottomrule
\end{tabular}
%
\quad
%
\sisetup{round-mode = places, round-precision = 2}
\begin{tabular}{%
S[table-format=3.2, table-number-alignment = right]@{\,:\,}S
S[round-mode = places, round-precision = 2,
table-format = 1.3, table-number-alignment = right]
@{$\,\pm\,$}
S[round-mode = places, round-precision = 2,
table-format = 1.3, table-number-alignment = left]
@{\,}l
}
\toprule
\multicolumn{2}{c}{\etajet} & \multicolumn{3}{c}{\diffetab} \\
\multicolumn{2}{c}{} & \multicolumn{3}{c}{[\si{\pico\barn}]} \\
\midrule
-1.6 & -1.1 & {\numRP{0.574}{3}} & {\numRP{0.094}{3}} &
$^{\numRP{+0.035}{3}}_{\numRP{-0.031}{3}}$ \\
-1.1 & -0.8 & 1.213 & 0.211 & $^{\num{+0.162}}_{\num{-0.162}}$ \\
-0.8 & -0.5 & 2.141 & 0.219 & $^{\num{+0.223}}_{\num{-0.123}}$ \\
-0.5 & -0.2 & 2.326 & 0.210 & $^{\num{+0.284}}_{\num{-0.214}}$ \\
-0.2 & +0.1 & 2.641 & 0.220 & $^{\num{+0.283}}_{\num{-0.233}}$ \\
+0.1 & +0.5 & 3.160 & 0.211 & $^{\num{+0.232}}_{\num{-0.172}}$ \\
+0.5 & +1.4 & 2.881 & 0.154 & $^{\num{+0.201}}_{\num{-0.301}}$ \\
\bottomrule
\end{tabular}
\end{table}
\end{verbatim}

\subsection{Table~\protect\ref{tab:xsect-ET}}
The files are: \texttt{cross\_sections\_charm-ET1.tex} and
\texttt{cross\_sections\_charm-ET2.tex}:
{\scriptsize
  \verbatiminput{cross_sections_charm-ET1.tex}
}
{\scriptsize
  \verbatiminput{cross_sections_charm-ET2.tex}
}

\subsection{Table~\protect\ref{tab:xsect-x}}

The files are: \texttt{cross\_sections\_charm-x1.tex} and
\texttt{cross\_sections\_charm-x2.tex}:
{\scriptsize
  \verbatiminput{cross_sections_charm-x1.tex}
}
{\tiny
  \verbatiminput{cross_sections_charm-x2.tex}
}

\end{document}


\documentclass[aspectratio=169]{beamer}
\input{macro.tex}

\usecolortheme{seagull}
\setbeamertemplate{sidebar right}{}
\setbeamertemplate{footline}{%
	\hfill\usebeamertemplate***{navigation symbols}
    \hspace{1cm}\insertframenumber{}/\inserttotalframenumber}
\setbeamertemplate{section in toc}[sections numbered]

\title{The Big-O Problem for Labelled Markov Chains and Weighted Automata\footfullcite{chistikov2020big}}
\date{\today}
\addbibresource{ref.bib}
\setcounter{section}{-1}
\begin{document}
\begin{frame}
    \titlepage
\end{frame}

\begin{frame}{Findings}
    \begin{enumerate}
        \item The big-O problem for non-negative Weighted Automata (WA) and  Labelled Markov Chains (LMCs) turns out to be \red{undecidable in general}.
        \item For \textbf{unambiguous} automata, i.e., where every word has at most one accepting path, the big-O problem becomes \blue{decidable} and can be solved in \blue{polynomial time}.
        \item In the \textbf{unary} case, i.e., if the input alphabet $\Sigma$ is a singleton, the big-O problem is
        also \blue{decidable} and, in fact, \textbf{coNP}-complete.
        \item In a more general \textbf{bounded} case, if the languages of all words $w$ associated with non-zero weight are included in  $w_1^*w_2^*\cdots w_m^*$ for some finite words  $w_1,w_2,\cdots, w_m \in \Sigma^*$, the big-O problem is \blue{decidable} \textit{subject to} Schanuel’s conjecture.
    \end{enumerate}
\end{frame}

\begin{frame}{Overview}
    \tableofcontents
\end{frame}

\section{Background}
\begin{frame}{Weighted Automata}
    \begin{block}{$\langle Q, \Sigma,M,F\rangle$: A Weighted Automaton $\cal W$}
        Over a semi-ring $(\mathbb{Q}, +, \times)$
        \begin{description}
            \item[$Q$] a finite set of states
            \item[$\Sigma$] a finite alphabet
            \item[$M$] $\Sigma \to \mathbb{Q}^{Q \times Q}$, a transition weighting function
            \item[$F$] $\subseteq Q$ a set of final states
        \end{description}
        Non-negative Weighted automata:  $\forall a \in \Sigma, \forall q,q^\prime \in Q \to M(a)(q,q^\prime) \ge 0 $
    \end{block}

    For an input $w \in \Sigma^*$ and a state $s \in Q$,define a function $f_s: \Sigma^\prime \to \mathbb{R}$

    $$f_s(w) = \sum_{t \in F} (M(a_1) \times M(a_2) \times \cdots \times M(a_n))_{s,t} \quad \text{for} \quad  a_1 a_2 \ldots a_n \in w$$
    stands for the weight of $w$ from state $s$
\end{frame}

\begin{frame}{Positive Weight Word Set}
    A set of all $w$ with \red{positive} weight from state $s$
    $$\begin{aligned}
            {\cal L}_s({\cal W}) & = \{w | w \in \Sigma^* \land f_s(w) > 0\}        \\
                                 & \to \text{the language of } {\cal N}_s({\cal W})
        \end{aligned}$$

    \begin{block}{}

        ${\cal N}_s({\cal W})$: the
        \textit{non-deterministic finite automaton} (NFA) formed from the \blue{same} set of states ($Q$ and $F$) as $\cal W$, start state $s$, and transitions $q \xrightarrow{a} q^\prime$ whenever $M(a)(q,q^\prime) > 0$
    \end{block}
\end{frame}

\begin{frame}{Problem Definition}
    \begin{block}{What is big-O?}
        Given $s,s^\prime \in Q$:
        $$
            \begin{aligned} \exists C>0, \forall w \in \Sigma^*, & f_s(w) \le C \cdot f_{s^\prime}(w)  \\
                                                     & \Downarrow                          \\
                s                                    & \text{ \red{is big-O of} } s^\prime
            \end{aligned}
        $$
    \end{block}

    Big-O and Big-$\Theta$ problems can be reduced to each other:
    $$
        \begin{rcases}
            s \text{ is big-O of } s^\prime \\
            s^\prime \text{ is big-O of } s
        \end{rcases}
        \Leftrightarrow s \text{ is big-}\Theta \text{ of } s^\prime
    $$
\end{frame}

\begin{frame}{Labelled Markov Chain (LMC)}
    A special class of weighted automata
    \begin{definition}
        A non-negative weighted automaton $\langle Q, \Sigma,M,F\rangle$ that: $\forall q \in Q  \backslash F$
        \begin{itemize}
            \item $\sum_{q^\prime \in Q} {\sum_{a \in \Sigma}{M(a)(q,q^\prime)}} = 1$
            \item $M(a)(q,q^\prime) = 0$
        \end{itemize}
    \end{definition}
    \begin{itemize}
        \item Final states have no outgoing transitions
        \item $f_s(E) = \sum_{w \in E} f_s(w) \le 1$ for a $E \subseteq \Sigma^*$
        \item The probability (weight) of a transition $q \to q^\prime$ is fixed \textit{independently} of the past sequence of states visited by the machine
    \end{itemize}
\end{frame}

\begin{frame}{Measurements}
    \begin{block}{}
    For two states $s$ and $s^\prime$, define the (asymmetric) ratio variation function as:
    $$r(s,s^\prime) = \sup_{E \subseteq \Sigma^*} (f_s(E) / f_{s^\prime}(E))$$
\end{block}
    The big-O problem $\implies$ whether $r(s,s^\prime) < \infty$

\begin{block}{The ratio distance (symmetric)}

    $$rd(s,s^\prime)= \max(r(s,s^\prime),r(s^\prime,s))$$
\end{block}

    A system $\cal M$ is $\epsilon$-differentially private if
    $$\forall s,s^\prime \in Q, \forall E \in \Sigma^*, \quad f_s(E) \le e^\epsilon f_{s^\prime}(e)$$
    $r$ captures the level of differential privacy between $s$ and $s^\prime$
\end{frame}

\section{Undecidability Results in General}
\begin{frame}{Big-O, Threshold and Approximation Problems are \red{Undecidable}}
    \begin{itemize}
        \item The big-O problem is \red{undecidable}, even for LMCs
        \item Each variation of the problem
        \begin{itemize}
            \item asymmetric/symmetric ($r$ vs. $rd$)
            \item non-strict/strict
            ($\le$ vs. $<$)
        \end{itemize}
        is \red{undecidable}, even under the promise of \textbf{boundedness}
        \item All variants of the \blue{approximation} tasks are \red{unsolvable}, even under the promise of boundedness.
        \begin{itemize}
            \item asymmetric/symmetric ($r$ vs. $rd$)
        \end{itemize}

        \blue{Approximation}: Find a $x$ for a given constant $\gamma$ that
        \begin{columns}
            \begin{column}{.4\textwidth}
                \begin{block}{Addictive}
                    $|r(s,s^\prime) - x|\le \gamma$
                \end{block}
            \end{column}
            \begin{column}{.1\textwidth}
                vs.
            \end{column}
            \begin{column}{.4\textwidth}
                \begin{block}{Multiplicative}
                    $1-\gamma \le \frac{x}{r(s,s^\prime)}\le 1+ \gamma$
                \end{block}
            \end{column}
        \end{columns}
    \end{itemize}
\end{frame}

\begin{frame}{The LC condition: A simple \red{necessary} (but \textcolor{gray}{insufficient}) condition of big-O}
    \framesubtitle{language containment condition}
    If $s$ is big-O of $s^\prime$, then
    \begin{block}{LC condition}
        If for all words $w$ with $f_s(w) > 0$ we also have $f_{s^\prime} (w)>0$. Equivalently,
        $${\cal L}_s{(\cal W)} \subseteq {\cal L}_{s^\prime}{(\cal W)} $$
    \end{block}
    It can be verfied by constructing NFA ${\cal N}_s{(\cal W)}$ and ${\cal N}_{s^\prime}{(\cal W)}$ that accept ${\cal L}_s{(\cal W)}$ and ${\cal L}_{s^\prime}{(\cal W)}$ respectively and verifying
    $${\cal L}({{\cal N}_s{(\cal W)}}) \subseteq {\cal L}({\cal N}_{s^\prime}{(\cal W)})$$

    \begin{block}{}
        LC condition is the first step in each of verification routines.
    \end{block}
\end{frame}

\section{Polynomial-time Deciablity for Unambiguous Cases}
\begin{frame}{Application: Unambiguous Weighted Automata}
    \begin{definition}
        A weighted automaton $\cal W$ is \red{unambiguous} from a state $s$ if every word has \red{at most} one accepting path in ${{\cal N}_s{(\cal W)}}$
    \end{definition}
    If a weighted automaton $\cal W$ is \red{unambiguous} from states $s$ and $s^\prime$, the big-O problem is decidable in polynomial time.

    \begin{proof}
        Construct a product weighted automaton $$M^\prime(a)((q_1,q_1^\prime),(q_2,q_2^\prime)) = \frac{M(a)(q_1,q_2)}{M(a)(q_1^\prime,q_2^\prime)}$$
        Is $s$ big-O of $s^\prime$? \\
        $\to$ If there is a cycle on path from $(s,s^\prime)$ to $(t,t)$? \\
        $\to$ Bellman-Ford algorithm
    \end{proof}
\end{frame}

\begin{frame}{Complexity \footnote{\url{https://www.cs.princeton.edu/courses/archive/spring13/cos423/lectures/08IntractabilityII.pdf}}}
 NFA language containment is
 \begin{table}
 \begin{tabular}{c|c|p{.5\textwidth}}
     \toprule
     & If the automata are & Note \\
     \midrule
     \textbf{NL}-complete  & in fact deterministic & \textbf{NL}: problems that can be solved in a \textbf{logarithmic} amount of memory space \\
     \hline
     in \textbf{P} & unambiguous & can be solved in a \textbf{polynomial} time \\
     \hline
     \textbf{coNP}-complete & unary &  a complement of a \textbf{NP}-complete problem \\
     \hline
     \textbf{PSPACE}-complete & in general & can be solved in a \textbf{polynomial} amount space \\
     \bottomrule
 \end{tabular}
\end{table}

 $\le$ the complexity level of repsective alogrithm for the big-O problem. (i.e. lower bound)

\end{frame}

\section{coNP Upper-bound for Unary Cases}

\begin{frame}{The big-O problem for unary weighted automata is \textbf{coNP}-complete}
    \begin{definition}
        A unary weighted automata has a singleton alphabet ($|\Sigma| = 1)$, its transition can be described as a single matrix $A=M(a)$, so it has $f_s(a^n) = A_{s,t}^n$
    \end{definition}

    There already exists an asymptotic order
    of growth of

    $$A_{s,t}^n + A_{s,t}^{n+1} + \cdots + A_{s,t}^{n+q} \approx \rho ^n n^k$$ for some $\rho$,$k$ and $q$. This paper accurately gives the correct $\rho$ and $k$ for each word and discovers that

    \begin{itemize}
        \item The big-O problem for unary weighted automata is \textbf{coNP}-complete
        \item It is
        coNP-hard even for unary labeled Markov chains (LMC)
    \end{itemize}

    \begin{block}{}
        \large{Upper bound: The unary big-O problem is in \textbf{coNP}}
    \end{block}
\end{frame}

\begin{frame}{Decidability for weighted automata with bounded languages}
    \begin{block}{Assumptions}
        \begin{enumerate}
            \item ${\cal L}_s{(\cal W)}$ and ${\cal L}_{s^\prime}{(\cal W)}$ are bounded
            \item LC condition is checked: ${\cal L}_s{(\cal W)} \subseteq {\cal L}_{s^\prime}{(\cal W)}$
        \end{enumerate}
    \end{block}
    Then, the problem is \blue{conditionally decidable}, subject to Schanuel’s conjecture \footnote{Refined definition, explanation and example available: \url{https://ncatlab.org/nlab/show/Schanuel\%27s+conjecture}}.

    \begin{theorem}
        Given a weighted automaton ${\cal W} = \langle Q, \Sigma,M,F\rangle$, $s,s^\prime \in Q$ with ${\cal L}_s{(\cal W)}$ and ${\cal L}_{s^\prime}{(\cal W)}$ are bounded, it is decidable whether $s$ is big-O of $s^\prime$, subject to Schanuel's conjecture.
    \end{theorem}

\end{frame}

\begin{frame}{Boundedness Matters: Relative order is not sufficient}
    Different from the \textit{unary} case: even if Relative orderings are the same, the boundness questions are different. For example,
    \begin{columns}
        \begin{column}{.5\textwidth}
            \begin{figure}
                \includegraphics[width=\textwidth]{example}
            \end{figure}

        \end{column}

        \begin{column}{.42\textwidth}
            $$p \le 0.62$$
            $$\begin{cases}
                f_s(a^mb^n) & = \Theta(0.6^m0.4^n) \\
                f_{s^\prime}(a^mb^n) & = \Theta(p^m0.39^n+0.59^m0.41^n)
            \end{cases}$$
        \end{column}
    \end{columns}
    \begin{block}{Big-O problem instance}
    When $n,m \to \infty$, does $f_s(a^mb^n) / f_{s^\prime}(a^mb^n) \to \infty$ always hold?
    \end{block}
\end{frame}

\section{Conditional Decidability for Bounded Language}
\begin{frame}{Language Boundedness}
    Let $L \subseteq \Sigma^\prime$:

    \begin{block}{bounded \only<4->{\redbf{Conditional Decidable!}}}
        $L$ is bounded if $L \subseteq w_1^*w_2^*\cdots w_m^*$ for some $w_1,w_2,\cdots, w_m \in \Sigma^*$
        \begin{itemize}
            \item Constructed by repeating some patterns
        \end{itemize}
    \end{block}

    \only<4->{\centering \blue{$\Downarrow$ Reduce}}

    \begin{block}{letter-bounded \only<3->{\redbf{Conditional Decidable!}}}
        $L$ is letter-bounded if $L \subseteq a_1^*a_2^*\cdots a_m^*$ for some $a_1,a_2,\cdots, a_m \in \Sigma$
        \begin{itemize}
            \item Constructed by repeating some letters
        \end{itemize}
    \end{block}

    \only<3->{\centering \blue{$\Downarrow$ Reduce}}

    \begin{block}{plus-letter-bounded \only<2->{\redbf{Conditional Decidable!}}}
        $L$ is plus-letter-bounded if $L \subseteq a_1^+a_2^+\cdots a_m^+$ for some $a_1,a_2,\cdots, a_m \in \Sigma$
        \begin{itemize}
            \item Constructed by repeating certain letters $\ge 1$
        \end{itemize}
    \end{block}
\end{frame}

\begin{frame}{Conclusions}
    This paper
    \begin{itemize}
        \item keeps undecidability results of weighted automata Big-O problem in general
        \item for bounded languages,
        \begin{itemize}
            \item the result depends on a conjecture from number theory
            \item leaves open the exact borderline between decidability and undecidability
        \end{itemize}
    \end{itemize}
    Natural directions in future work
    \begin{itemize}
        \item analogous problem for infinite words
        \item further analysis on ambiguity
        \begin{itemize}
            \item e.g., is the big-O problem decidable for k-ambiguous weighted automata?
        \end{itemize}
        \item extension to negative edge weights
    \end{itemize}
\end{frame}

\end{document}


%----------------------------------------------------------------------------------------
%	PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[paper=a4, fontsize=11pt]{scrartcl} % A4 paper and 11pt font size

\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage{fourier} % Use the Adobe Utopia font for the document - comment this line to return to the LaTeX default
\usepackage[english]{babel} % English language/hyphenation
\usepackage{amsmath,amsfonts,amsthm,amssymb} % Math packages
\usepackage{mathrsfs}

\usepackage{algorithm, algorithmic}
\renewcommand{\algorithmicrequire}{\textbf{Input:}} %Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} %UseOutput in the format of Algorithm

\usepackage{listings}
\lstset{language=Matlab}

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template

\usepackage{sectsty} % Allows customizing section commands
\allsectionsfont{\centering \normalfont\scshape} % Make all sections centered, the default font and small caps

\usepackage{fancyhdr} % Custom headers and footers
\pagestyle{fancyplain} % Makes all pages in the document conform to the custom headers and footers
\fancyhead{} % No page header - if you want one, create it in the same way as the footers below
\fancyfoot[L]{} % Empty left footer
\fancyfoot[C]{} % Empty center footer
\fancyfoot[R]{\thepage} % Page numbering for right footer
\renewcommand{\headrulewidth}{0pt} % Remove header underlines
\renewcommand{\footrulewidth}{0pt} % Remove footer underlines
\setlength{\headheight}{13.6pt} % Customize the height of the header

\numberwithin{equation}{section} % Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{figure}{section} % Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)

\setlength\parindent{0pt} % Removes all indentation from paragraphs - comment this line for an assignment with lots of text

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

\newcommand{\horrule}[1]{\rule{\linewidth}{#1}} % Create horizontal rule command with 1 argument of height

\title{
\normalfont \normalsize
\textsc{Shanghai Jiao Tong University, UM-SJTU JOINT INSTITUTE} \\ [25pt] % Your university, school and/or department name(s)
\horrule{0.5pt} \\[0.4cm] % Thin top horizontal rule
\huge Introduction to Numerical Analysis \\ HW5 \\ % The assignment title
\horrule{2pt} \\[0.5cm] % Thick bottom horizontal rule
}

\author{Yu Cang \\ 018370210001} % Your name

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

\begin{document}

\maketitle % Print the title

%----------------------------------------------------------------------------------------
%	PROBLEM 1
%----------------------------------------------------------------------------------------
\section{Lebesgue constant for Chebyshev nodes}
\begin{enumerate}
	\item
		\begin{enumerate}
			\item
				\begin{proof}
					Denote
					\begin{equation}
						\begin{aligned}
							LHS &\triangleq (x-x_i)l_i(x) \\
							RHS &\triangleq \frac{T_{n+1}(x)}{T_{n+1}'(x_i)}
						\end{aligned}
					\end{equation}
					It is left to prove $LHS = RHS$.\\
					The left part can be written as
					\begin{equation}
						LHS = c_l \omega(x)
					\end{equation}
					where
					\begin{equation}
						\omega(x) = \prod_{i=0}^{n}(x-x_i)
					\end{equation}
					and
					\begin{equation}
						c_l = \frac{1}{\prod_{k=0, k\neq i}^{n}(x_i - x_k)}
					\end{equation}

					Since both $LHS$ and $RHS$ are polynomials of order $n+1$, they are equivalent iff. they have same roots and leading coefficients.\\
					On the one hand,as for all $x_i$, where $i = 0, 1, ... , n$
					\begin{equation}
						T_{n+1}(x_i) = cos((n+1)\theta_i) = cos(\frac{2i+1}{2}\pi) = 0
					\end{equation}
					Thus, $LHS$ and $RHS$ have same roots. $RHS$ can therefore be written as
					\begin{equation}
						RHS(x) = c_r \omega(x)
					\end{equation}
					On the other hand, since
					\begin{equation}
						LHS'(x)|_{x=x_i} = (l_i(x) + (x-x_i)l_i'(x))|_{x=x_i} = 1
					\end{equation}
					and
					\begin{equation}
						RHS'(x)|_{x=x_i} = \frac{T'_{n+1}(x)}{T_{n+1}'(x_i)}\Big|_{x=x_i} = 1
					\end{equation}
					Thus, the leading coefficients of $LHS$ and $RHS$ are equal, namely $c_l = c_r$.\\
					Hence, $LHS=RHS$.
				\end{proof}
			\item
				\begin{proof}
					\begin{equation}
						\begin{aligned}
							T'_{n+1}(x) & = (cos((n+1)arccos(x)))'\\
							            & = sin((n+1)arccos(x)) (n+1) \frac{1}{\sqrt{1-x^2}}\\
							            & = \frac{n+1}{\sqrt{1-cos^2(\theta)}} sin((n+1)\theta)
						\end{aligned}
					\end{equation}
					As $\theta_k = \frac{2k+1}{2(n+1)}\pi$, thus, $sin(\theta_k) > 0$, and
					\begin{equation}
						T'_{n+1}(x_k) = \frac{n+1}{sin(\theta_k)} sin(\frac{2k+1}{2}\pi) = {(-1)}^k \frac{n+1}{sin(\theta_k)}
					\end{equation}
				\end{proof}
			\item
				\begin{proof}
					As
					\begin{equation}
						T_{n+1}(1) = cos((n+1)arccos(1)) = 1
					\end{equation}
					Thus
					\begin{equation}
						\begin{aligned}
							\sum_{i=0}^{n}|l_i(1)| & = \sum_{i=0}^{n}\Bigg|\frac{T_{n+1}(1)}{(1-x_i)T'_{n+1}(x_i)}\Bigg| \\
												   & = \sum_{i=0}^{n} \frac{1}{\Big|(1-x_i)T'_{n+1}(x_i)\Big|}\\
												   & = \frac{1}{n+1} \sum_{i=0}^{n} \bigg|\frac{sin\theta_i}{(1-cos\theta_i)} \bigg|\\
												   & = \frac{1}{n+1} \sum_{i=0}^{n} \bigg|\frac{sin\theta_i}{2sin^2(\frac{\theta_i}{2})} \bigg|\\
												   & \geq  \frac{1}{n+1} \sum_{i=0}^{n} cot(\frac{\theta_i}{2})\\
						\end{aligned}
					\end{equation}
				\end{proof}
		\end{enumerate}
	\item
		\begin{enumerate}
			\item
				\begin{proof}
					According to the mean value theorem, there exists $\theta \in [\frac{\theta_k}{2}, \frac{\theta_{k+1}}{2}]$, s.t.
					\begin{equation}
						\int_{\frac{\theta_k}{2}}^{\frac{\theta_{k+1}}{2}} cot(t) dt = \frac{\theta_{k+1} - \theta_k}{2} cot(\theta)
					\end{equation}
					As $cot'(t) = -\frac{1}{sin^2(t)} < 0$, and $\theta_k \leq \theta \leq \theta_{k+1}$, thus
					\begin{equation}
						cot(\theta) \leq cot(\theta_k)
					\end{equation}
					Therefore
					\begin{equation}
						\int_{\frac{\theta_k}{2}}^{\frac{\theta_{k+1}}{2}} cot(t) dt \leq \frac{\theta_{k+1} - \theta_k}{2} cot(\theta_k)
					\end{equation}
				\end{proof}

			\item
				\begin{proof}
					As $\theta_{k+1} - \theta_k = \frac{\pi}{n+1}$ and according to the result that have been proved above
					\begin{equation}
						\begin{aligned}
							\sum_{k=0}^{n} \int_{\frac{\theta_k}{2}}^{\frac{\theta_{k+1}}{2}} cot(t) dt
							& \leq \sum_{k=0}^{n} \frac{\theta_{k+1} - \theta_k}{2}cot(\frac{\theta_k}{2})\\
							& = \frac{\pi}{2(n+1)} \sum_{k=0}^{n} cot(\frac{\theta_k}{2})
						\end{aligned}
					\end{equation}
				\end{proof}

			\item
				\begin{proof}
					As $\theta_n = \frac{2n+1}{2n+2}\pi < \pi$, $\theta_{n+1} = \frac{2n+3}{2n+2} > \pi$, and $cot(x)$ is positive over $(0, \frac{\pi}{2})$, while negative otherwise.
					Thus
					\begin{equation}
							\int_{\frac{\theta_0}{2}}^{\frac{\pi}{2}} cot(t) dt
							\leq \int_{\frac{\theta_0}{2}}^{\frac{\theta_n}{2}} cot(t) dt
							= \sum_{k=0}^{n-1} \int_{\frac{\theta_k}{2}}^{\frac{\theta_{k+1}}{2}} cot(t) dt
					\end{equation}
					Hence
					\begin{equation}
						\int_{\frac{\theta_0}{2}}^{\frac{\pi}{2}} cot(t) dt \leq \frac{\pi}{2(n+1)} \sum_{i=0}^{n}cot(\frac{\theta_i}{2})
					\end{equation}
					(... not fine)
				\end{proof}

		\end{enumerate}

	\item
		\begin{proof}
			\begin{equation}
				\begin{aligned}
					\Lambda_n & = \max_{x \in [a, b]} \sum_{i=0}^{n} |l_i(x)|\\
							  & \geq \sum_{i=0}^{n} |l_i(1)|\\
							  & \geq \frac{1}{n+1} \sum_{i=0}^{n} cot(\frac{\theta_i}{2})\\
							  & \geq \frac{2}{\pi} \int_{\theta_0 / 2}^{\pi/2} cot(t)dt\\
							  & = \frac{2}{\pi} ln(|sin(t)|) \Bigg| _{\theta_0/2}^{\pi/2}\\
							  & = - \frac{2}{\pi} ln(sin(\frac{\theta_0}{2}))\\
							  & \geq \frac{2}{\pi} ln(\frac{2}{\theta_0}) = \frac{2}{\pi} ln(\frac{4(n+1)}{\pi})\\
							  & \ge \frac{2}{\pi} ln(n)
				\end{aligned}
			\end{equation}
		\end{proof}

\end{enumerate}

%----------------------------------------------------------------------------------------
%	PROBLEM 2
%----------------------------------------------------------------------------------------
\section{Interpolation}
\begin{enumerate}
	\item
		\begin{proof}
			Since $\Phi(f)=0$, $f(x_k) + f(y_k) = 0$ is valid for any $k$.\\
			Thus $f(x_k) = f(y_k) = 0$ or $f(x_k)$ and $f(y_k)$ have different signs.\\
			In the first case, take $\xi_k = x_k$ or $\xi_k = y_k$;\\
			In the second case, as $f$ is continous over $[a, b]$, according to the  intermediate value theorem, there exists $\xi_k \in [x_k, y_k]$ s.t. $f(\xi_k) = 0$.
		\end{proof}

	\item
		\begin{proof}
			Let $h_1(x) \in \mathbb{R}_n [x]$, $h_2(x) \in \mathbb{R}_n [x]$ and  $h_1(x) \neq h_2(x)$. They can be written as
			\begin{equation}
				h_1(x) = \sum_{i=0}^{n} a_i x^i
			\end{equation}
			\begin{equation}
				h_2(x) = \sum_{i=0}^{n} b_i x^i
			\end{equation}
			Assume $\Phi(h_1) = \Phi(h_2)$, then
			\begin{equation}
				h_1(x_k) + h_1(y_k) = h_2(x_k) + h_2(y_k) \ \ (k=0, 1, ... , n)
			\end{equation}
			Thus
			\begin{equation}
				 \begin{bmatrix}
					(1+1) & (x_0 + y_0) &  (x_0^2 + y_0^2) & ... & (x_0^n + y_0^n)\\
					(1+1) & (x_1 + y_1)  &  (x_1^2 + y_1^2) & ... & (x_1^n  + y_1^n)\\
					\vdots  & \vdots    & \vdots & \ddots & \vdots \\
					(1+1) & (x_n + y_n) & (x_n^2 + y_n^2) & ... & (x_n^n + y_n^n)\\
				\end{bmatrix}
				\begin{bmatrix}
					a_0 - b_0\\
					a_1 - b_1\\
					\vdots \\
					a_n - b_n\\
				\end{bmatrix}
				=
				\begin{bmatrix}
					0\\
					0\\
					\vdots \\
					0\\
				\end{bmatrix}
			\end{equation}
			The determinant of the coefficient matrix above is positive as it is the sum of $2^{n+1}$ determinents, each of these be positive as $x_0 < y_0 < x_1 < y_1 < ... < x_n < y_n$. Thus, solution to this linear system is $x = [0, 0, ... , 0]^T$, which means
			\begin{equation}
				a_i = b_i \ \ (i=0, 1, ... , n)
			\end{equation}
			So, the hypothsis fails as $h_1(x) = h_2(x)$. Hence, $\Phi(f) \neq \Phi(g)$, which means $\Phi$ is injective.\\
			Assume $\Phi(P1) = \Phi(f)$, $\Phi(P2) = \Phi(f)$, according to the converse-negative proposition of the injective property, there should be $P1 = P2$, thus the unicity is proved.
		\end{proof}

	\item
		\begin{proof}
			Let $P_n(x) = a_n x^n + a_{n-1} x^{n-1} + ... + a_1 x + a_0$, denote $h(x) = P_n(x) - f(x)$. As $\Phi(P_n) = \Phi(f)$, then
			\begin{equation}
			h(x_k) + h(y_k) = 0
			\end{equation}
			Thus, there exists $\xi_k \in [x_k, y_k]$ s.t. $h(\xi_k) = 0$. So
			\begin{equation}
			\sum_{i=0}^{n}a_i \xi_k ^ i = f(\xi_k) \ \ (k=0, 1, ... , n)
			\end{equation}
			which can be written as matrix form
			\begin{equation}
			\begin{bmatrix}
				1 & \xi_0 & \xi_0^2 & ... & \xi_0^n \\
				1 & \xi_1 & \xi_1^2 & ... & \xi_1^n \\
				\vdots  & \vdots & \vdots & \ddots & \vdots \\
				1 & \xi_n & \xi_n^2 & ... & \xi_n^n \\
			\end{bmatrix}
			\begin{bmatrix}
				a_0\\
				a_1\\
				\vdots \\
				a_n\\
			\end{bmatrix}
			=
			\begin{bmatrix}
				f(\xi_0)\\
				f(\xi_1)\\
				\vdots \\
				f(\xi_n)\\
			\end{bmatrix}
			\end{equation}
			The determinant of the coefficient matrix is the so called Vandermonde determinant, and $\xi_j > \xi_i$ when $j>i$. Thus, determinant of the coefficient matrix is positive, which means there exist $n+1$ points in $[a, b]$, denoted as $\xi_i$, s.t. $P(\xi_i) = f(\xi_i)$. Thus $P_n$ is the interpolation polynomial of $f$.\\

			Applying the Taylor theorem, it's clear that
			\begin{equation}
				f(x)-P_n(x) = \frac{(x-a)^{n+1}}{(n+1)!}f^{(n+1)}(\xi)
			\end{equation}
			Thus
			\begin{equation}
				\lVert f- p_n \rVert_\infty = \max_{x \in [a, b]} |f-P_n| \leq \frac{(b-a)^{n+1}}{(n+1)!}\sup_{x \in [a, b]}|f^{(n+1)}(x)|
			\end{equation}

		\end{proof}

\end{enumerate}

%----------------------------------------------------------------------------------------
%	PROBLEM 3
%----------------------------------------------------------------------------------------
\section{Trigonometric polynomials}
\begin{enumerate}
	\item
		\begin{proof}
			It's clear that the statement holds when $k=0, 1$ as $1$ and $cos \theta$ are in $T_0$ and $T_1$ respectively.\\
			Suppose the statement is still valid when $k = n-1$, thus, there exists $Q_{n-1}$ s.t.
			\begin{equation}
				(cos\theta)^{n-1} = Q_{n-1}
			\end{equation}
			When it comes to $k = n$, with the induction hypothesis,
			\begin{equation}
				\begin{aligned}
						(cos\theta)^n & =  Q_{n-1} \times cos\theta\\
						                     & = (\frac{a_0}{\sqrt{2}} + \sum_{k=1}^{n-1}a_k cosk\theta) cos\theta\\
						                     & = \frac{a_0}{\sqrt{2}}cos\theta + \sum_{k=1}^{n-1}a_k (\frac{cos(k+1)\theta + cos(k-1)\theta}{2})\\
						                     & = \frac{b_0}{\sqrt{2}} + \sum_{k=0}^{n} b_k cosk\theta \triangleq Q_n
				\end{aligned}
			\end{equation}
			Thus, $(cos\theta)^n$ is in $T_n$. Hence, for any $0 \leq k \leq n$, $(cos\theta)^k$ is in $T_n$ as $T_k \subseteq T_n$.\\

			(the bijection part haven't figured out yet ...)

		\end{proof}
	\item
		\begin{proof}
			As $Q_n(\theta_i) = F(\theta_i)$, the existence of $Q_n \in T_n$ is equivalent to the existence of solution of the linear system given as below
			\begin{equation}
				\begin{bmatrix}
					\frac{1}{\sqrt{2}} & cos(\theta_0) & cos(2\theta_0) & ... & cos(n\theta_0) \\
					\frac{1}{\sqrt{2}} & cos(\theta_1) & cos(2\theta_1) & ... & cos(n\theta_1) \\
					\vdots                 & \vdots           & \vdots             & \ddots  & \vdots     \\
					\frac{1}{\sqrt{2}} & cos(\theta_n) & cos(2\theta_n) & ... & cos(n\theta_n) \\
				\end{bmatrix}
				\begin{bmatrix}
					a_0 \\ a_1 \\ a_2 \\ \vdots \\ a_n\\
				\end{bmatrix}
				=
				\begin{bmatrix}
					F(\theta_0) \\ F(\theta_1) \\ F(\theta_2) \\ \vdots \\ F(\theta_n)\\
				\end{bmatrix}
			\end{equation}
			Thus, it's left to prove the determinant of the coefficient matrix is non-zero, which can be denoted as $\det(A)$.\\
			As $cos(k\theta)$ can be written as
			\begin{equation}
				cos(k\theta) = \sum_{n=0}^{k} b_n(cos\theta)^n
			\end{equation}
			Thus, $\det(A)$ can be simplified as below, where $C$ is an non-zero factor.
			\begin{equation}
				\det(A) = C \det
				\begin{bmatrix}
					1 & cos(\theta_0) & cos^2(\theta_0) & ... & cos^n(\theta_0) \\
					1 & cos(\theta_1) & cos^2(\theta_1) & ... & cos^n(\theta_1) \\
					\vdots                 & \vdots           & \vdots             & \ddots  & \vdots     \\
					1 & cos(\theta_n) & cos^2(\theta_n) & ... & cos^n(\theta_n) \\
				\end{bmatrix}
			\end{equation}
			With $\theta_i = \frac{2i+1}{2(n+1)}\pi$, it's clear that $\det(A)\neq0$ as its Vandermon derterminant part is non-zero. Thus the existence of $Q_n$ is valid.
		\end{proof}

	\item
		\begin{proof}
			It has been exactly proved above.
		\end{proof}

	\item
		\begin{proof}

		\end{proof}

\end{enumerate}

\end{document}


\documentclass[12pt]{article}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}

\begin{document}

% bibliography managers
% - zotero
% - onenote
% - mendeley
% - jabref -> LaTeX specific package (http://www.jabref.org/)

% make random citations
\section{Adding citations}
One of the shortest articles \cite{bib_entry1} is followed by a random citation I made \cite{whatever_name_you_want}. Sometimes most references are from the web which you can equally cite \cite{cool_paper_from_web}. Sometimes you need to cite more than one \cite{bib_entry1,whatever_name_you_want,cool_paper_from_web}

% create bibliographies manually
% go to google scholar
% step 1 - find article you want
% step 2 - click on the quotation mark icon at the bottom of the google entry
% step 3 - highlight and copy whatever bib format is shown in the pop-up
% step 4 - past beneath a \bibitem entry below
% step 5 - give the \bibitem a unique name to cite
% change the bibliography style
%------------------------%
\bibliographystyle{plain}
%------------------------%

\begin{thebibliography}{99} % <- doesn't mean 99 entires, exactly, but the maximum amount of anticipated entries
\bibitem{bib_entry1}
Lander, L. J., and T. R. Parkin.``Counterexample to Euler’s conjecture on sums of like powers'' Bull. Amer. Math. Soc 72.6 (1966): 1079.

\bibitem{whatever_name_you_want}
I just made up my own bibliography format

\bibitem{cool_paper_from_web}
\url{https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url}

\end{thebibliography}
\end{document}

test-files/4 - include bibliography/bibliographies-basic.tex


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

\chapter{User Guide} % (fold)
\label{cha:user_guide}
This user guide will provide information on how to create Q'Grady files to
describe non-local boxes and then compile them into PRISM models. This user
guide assumes familiarity with the use of PRISM.

\section{System Requirements} % (fold)
\label{sec:system_requirements}
In order to run the Q'Grady compiler and use the produced models, the following
software is required:

\begin{itemize}
    \item Java JDK 1.8+ \footnote{\url{http://www.oracle.com/technetwork/java/javase/downloads/index.html}}
    \item PRISM 4.3 \footnote{\url{http://www.prismmodelchecker.org/}} (Note, Windows binary requires 32 bit Java)
\end{itemize}
% section system_requirements (end)

\section{Writing a Q'Grady File} % (fold)
\label{sec:writing_a_q_grady_file}
Let's start with a simple box with the following properties:
\begin{itemize}
    \item Two inputs: \(x, y \in {0, 1}\).
    \item Two inputs: \(a, b \in {0, 1}\).
    \item The PR probability distribution:
    \(
        P(a, b | x, y) =
        \begin{cases}
            \frac{1}{2} & \quad a \text{ XOR } B = x \text{ AND } y \\
            0 & \quad \text{otherwise} \\
        \end{cases}
    \)
\end{itemize}

The finished file will look like this:

\begin{lstlisting}[frame = single]
    input range = 2;
    output range = 2;

    x, y -> a, b [
        0.5, 0.0, 0.0, 0.5;
        0.5, 0.0, 0.0, 0.5;
        0.5, 0.0, 0.0, 0.5;
        0.0, 0.5, 0.5, 0.0;
    ]
\end{lstlisting}

\subsection{Configuring Ranges} % (fold)
\label{sub:configuring_ranges}
Open up your preferred text editor, and let's begin.

Every Q'Grady file starts with the same way, where the range of the inputs
and outputs are specified. There is currently no ability to specify specific
ranges per variable. Note that the given range is the number of unique values
the variables can be, not the maximum value. Think of it as a number base, since
we want binary numbers, we are using base 2.

\begin{lstlisting}[frame = single]
    input range = 2;
    output range = 2;
\end{lstlisting}
% subsection configuring_ranges (end)

\subsection{Configuring Variables} % (fold)
\label{sub:configuring_variables}
Again, very straight forward no matter how many inputs or outputs you have.
The variables are made up of two lists, the input and output, separated by the
`->' arrow. Each lists' members are separated by a comma.

\begin{lstlisting}[frame = single]
    x, y -> a, b
\end{lstlisting}

With the current Q'Grady version, please ensure that the input and output are
the same length. The system is not guaranteed to work if this is not the case.
% subsection configuring_variables (end)

\subsection{Probability Distribution} % (fold)
\label{sub:probability_distribution}
This is where the meat of the Q'Grady file is. When dealing with larger boxes,
you must take great care in ensuring the accuracy of the distribution, otherwise
you will not get the results you were looking for.

In this case, we have two binary inputs and outputs. This means our distribution
is a 4x4 matrix, totalling to 16 elements.

\begin{lstlisting}[frame = single]
    [
        0.5, 0.0, 0.0, 0.5;
        0.5, 0.0, 0.0, 0.5;
        0.5, 0.0, 0.0, 0.5;
        0.0, 0.5, 0.5, 0.0;
    ]
\end{lstlisting}

Note that Q'Grady does not particularly care about white-space, meaning that so
long as the first character after the variables is the left square bracket, the
compiler will not care about any gap.

At this stage, please ensure to make any undesired outcomes of this set-up `0.0'
and \emph{not} `0'. The compiler treats these types of numbers very differently,
and only expects the former here. In addition, ensure that all rows add up to 1.
Assuming you've not accidentally created a signalling box, then the file is
ready for compilation. Save the file under any name you want with the extension
`\texttt{.qgrady}' and now we can move onto compiling.

% subsection probability_distribution (end)
% section writing_a_q_grady_file (end)
\section{Compiling the Box} % (fold)
\label{sec:compiling_the_box}
\subsection{Usage} % (fold)
\label{sub:usage}
\begin{lstlisting}[frame = single]
    usage: qgrady -f <file> [-o <file>] [-h] [-v]
     -f,--file <file>     takes input from <file>
     -o,--output <file>   places output to <file>
     -h,--help            prints this message
     -v,--version         displays compiler information version
\end{lstlisting}
% subsection usage (end)

\subsection{Running the Compiler} % (fold)
\label{sub:running_the_compiler}
Assuming the source file and compiler are in the same location, you can execute
the compilation process as follows:
\begin{lstlisting}[frame = single]
    java -jar q.grady.jar -f filename.qgrady
\end{lstlisting}

Where `filename' is whatever you saved the file as. If you want to give the
PRISM model a specific destination, you can use the `-o' or `--output' flag as
follows:

\begin{lstlisting}[frame = single]
    java -jar q.grady.jar -f filename.qgrady -o dest.prism
\end{lstlisting}

Again changing the file's name as appropriate. The help and version flags, as
their name implies, will simply display the relevant information and then cease.
These flags override the compilation process.

You will see the console printing a series of checks before starting the file
writing. These are the semantics checks imposed to ensure that only valid
boxes are being fed into the compiler. If all goes well, you should see the
following output:

\begin{lstlisting}[frame = single]
    Checking variables... OK!
    Checking values... OK!
    Checking number of rows... OK!
    Checking row lengths... OK!
    Checking row sums... OK!
    Checking for non-signalling... OK!
    Writing box to pr.prism... OK!
\end{lstlisting}
% subsection running_the_compiler (end)

The PRISM model should now be available at it's specified location. If no
specific destination was chosen, it will simply appear in the same directory as
the source file.
% section compiling_the_box (end)

\section{Using PRISM} % (fold)
\label{sec:using_prism}
Now that we have the model, we can now use it in PRISM. At this stage, the PRISM
manual\footnote{\url{http://www.prismmodelchecker.org/manual/}} would be of use
if you are unfamiliar with PRISM. This user guide will only go over using PRISM
for ensuring the result is to your expectation.

Open the file in PRISM, and enter `Model -> Compute -> Steady State
Probabilities' in the menu bar, or press \texttt{f4} instead. The `Log' tab
should display information about the computation it has just performed. The
results should look like this:

\begin{lstlisting}[frame = single]
    26:(0,0,true,0,0)=0.125
    28:(0,0,true,1,1)=0.125
    39:(0,1,true,0,0)=0.125
    41:(0,1,true,1,1)=0.125
    57:(1,0,true,0,0)=0.125
    59:(1,0,true,1,1)=0.125
    70:(1,1,true,0,1)=0.125
    72:(1,1,true,1,0)=0.125
\end{lstlisting}

The first numbers indicate the state the model is in, with the variables'
values listed in the parenthesis, with the value of \texttt{ready} separating
the inputs from the outputs. As you can see from the results, the 8 states
listed in the results match the same 8 input and output pairs that had a 0.5
probability, which is quartered to 0.125 since there are 4 possible inputs in
total.

Now you are free you make more complex models and study them further using
PRISM.
% section using_prism (end)

\section{Troubleshooting} % (fold)
\label{sec:troubleshooting}
\begin{itemize}
    \item The compiler is displaying `Signalling found.'
    \begin{itemize}
        \item Check your input file and ensure that there are no obvious areas
        in the matrix that suggest signalling. Unfortunately, the compiler
        cannot give you specific detail.
    \end{itemize}
    \item The compiler is displaying an error on row \(x\) and/or column \(y\).
    \begin{itemize}
        \item The semantic analysis has found that your probabilities don't
        match the expected size. Be careful when handling this, especially with
        larger ranges or number of inputs.
    \end{itemize}
    \item How does the compiler handle probabilities like 0.333...
    \begin{itemize}
        \item As a general rule, if you're including recurring decimals like
        0.333..., 5 decimal places is likely to be enough. PRISM seems to treat
        0.33333 as 0.333 at that point, it will sum up to 1 without issue.
    \end{itemize}
    \item The compiler isn't accepting my file.
    \begin{itemize}
        \item Please ensure that the file extension is correct, Q'Grady expects
        \texttt{.qgrady} files.
    \end{itemize}
\end{itemize}
% section troubleshooting (end)
% chapter user_guide (end)

\newpage
\end{document}


\documentclass[onehalfspacing]{article}

\usepackage{amsmath,amssymb,amsthm}
\usepackage{ wasysym }
\usepackage{ stmaryrd }
\usepackage{ mathpartir }
\usepackage{xcolor}
\usepackage{bussproofs}
\usepackage[left=3.00cm, right=3.00cm, top=3.00cm,bottom=3.0cm]{geometry}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}

\newcommand{\llb}{\llbracket}
\newcommand{\rrb}{\rrbracket}
\newcommand{\blue}[1]{{\color{blue}#1}}
\newcommand{\var}{\text{var}}

\author{Alexander Pluska}
\title{Proofs as Programs in Classical Logic\\Notes}

\begin{document}

\maketitle

\section{Plan}

Goal:
\begin{itemize}
	\item Extract program from resolution proofs of $\forall\exists$-sentences over inductive datatypes.
\end{itemize}

\noindent Steps:

\begin{itemize}
	\item Give extensions of G\"odel's System \textbf{T} and HAS + EM$_1$ + SK$_1$ to arbitrary inductive datatypes (possibly GADTs) and prove (or rather check) properties, i.e. strong normalization, cut-elimination, uniqueness of normal forms.
	\item Adapt the results of~\cite{aschieri2014interactive} to exhibit realizers in $\mathcal{F} + \Phi$ for cut-free proofs in the extended version of HAS + EM$_1$ + SK$_1$ of formulas $\forall x\exists y Pxy$ where $P$ is a predicate in the extended version of \textbf{T}.
	\item Adapt the iterative learning from~\cite{aschieri2014interactive} to extract $\lambda$-terms from realizers.
	\item Give a proof translation from resolution proofs to cut-free sequent calculus proofs (already done?).
\end{itemize}

\noindent Questions:
\begin{itemize}
	\item When does the translated proof require more than EM$_1$?
	\item Using the methods in~\cite{aschieri2014interactive} the extracted term will be in simple $\lambda$-calculus. Is is possible to obtain a term in $\mathcal{F}$? (Talk with Federico Aschieri)
	\item Can the predicates be defined in $\mathcal{F}$ instead of $\mathcal{T}$? (probably yes)
	\item What happens if we add non-inductive theories?

\end{itemize}

\pagebreak

\section{Extracting constructive content from resolution proofs}
\subsection{The superposition calculus}
First let us define the calculus from which we wish to extract programs. It will comprise a core set of rules used in the vampire theorem prover taken from~\cite{Kov_cs_2013}. Note that we pay special attention to the usually neglected (and highly non-constructive) part of CNF transformation and Skolemization. Also note that we neglect the simplification ordering which is necessary to formulate a strategy for proof search but not for our proof transformation.

\noindent\textbf{Resolution.}
\begin{center}
\AxiomC{$A\vee B$}
\AxiomC{$\neg A'\vee C$}
\BinaryInfC{$(B\vee C)\theta$}
\DisplayProof
\end{center}
where $\theta$ is an mgu of $A$ and $A'$.

\noindent\textbf{Factoring.}
\begin{center}
	\AxiomC{$A\vee A'\vee B$}
	\UnaryInfC{$(A\vee B)\theta$}
	\DisplayProof
\end{center}
where $\theta$ is an mgu of $A$ and $A'$.

\noindent\textbf{Superposition.}
\begin{center}
	\AxiomC{$l=r\vee B$}
	\AxiomC{$L[s]\vee C$}
	\BinaryInfC{$(L[r]\vee B\vee C)\theta$}
	\DisplayProof
	\AxiomC{$l=r\vee B$}
	\AxiomC{$t[s] = t'\vee C$}
	\BinaryInfC{$(t[r] = t'\vee B\vee C)\theta$}
	\DisplayProof
	\AxiomC{$l=r\vee B$}
	\AxiomC{$t[s]\neq t'\vee C$}
	\BinaryInfC{$(t[r]\neq t'\vee B\vee C)\theta$}
	\DisplayProof
\end{center}
where $\theta$ is an mgu of $l$ and $s$, $s$ is not a variable, $L[s]$ is not an equality literal.

\noindent\textbf{Equality Resolution.}
\begin{center}
	\AxiomC{$s\neq t\vee C$}
	\UnaryInfC{$C\theta$}
	\DisplayProof
\end{center}
where $\theta$ is an mgu of $s$ and $t$.

\noindent\textbf{Equality Factoring.}
\begin{center}
	\AxiomC{$s=t\vee s'=t'\vee C$}
	\UnaryInfC{$(s=t\vee t\neq t'\vee C)\theta$}
	\DisplayProof
\end{center}
where $\theta$ is an mgu of $s$ and $s'$.

First let us look at an example of the transformation we going to do. We shall look at a proof of $\forall x\exists y: f(y) = g(x)$ from $\forall x: f(x) = g(h(x))$ and $\forall x: h(h'(x)) = x$. The program we extract hopefully is $h'$.

\begin{align}
	[\text{axiom}]&&\forall x: f(x) = g(h(x))\\
	[\text{cnf 1}]&&f(x_0) = g(h(x_0))\\
	[\text{axiom}]&&\forall x: h(h'(x)) = x\\
	[\text{cnf 3}]&&h(h'(x_0)) = x_0\\
	[\text{negated conjecture}]&&\neg\forall x\exists y: f(y) = g(x)\\
	[\text{ennf 5}]&&\exists x\forall y: f(y)\neq g(x)\\
	[\text{choice axiom}]&&\exists x\forall y: f(y)\neq g(x)\rightarrow \forall x : f(x) \neq g(s_0)\\
	[\text{skolemization 6, 7}]&&\forall x: f(x)\neq g(s_0)\\
	[\text{cnf 8}]&&f(x_1)\neq g(s_0)\\
	[\text{superposition 9, 2}]&\{\}&g(s_0)\neq g(h(x_0))\\
	[\text{superposition 10, 4}]&\{x_0\mapsto h'(x_0)\}&g(x_0)\neq g(s_0)\\
	[\text{equality resolution 11}]&&\bot
\end{align}

We first use the well known trick of adding the original conjecture to the negated one from~\cite{Luckham_1971} to transform this into a classical proof of $\forall x\exists y: f(x) = g(y)$ rather than a refutation of its negation:
\setcounter{equation}{0}
\begin{align}
	[\text{axiom}]&&\forall x: f(x) = g(h(x))\\
	[\text{cnf 1}]&&f(x_0) = g(h(x_0))\\
	[\text{axiom}]&&\forall x: h(h'(x)) = x\\
	[\text{cnf 3}]&&h(h'(x_0)) = x_0\\
	[\text{\color{red}{tautology}}]&&\forall x\exists y: f(y) = g(x)\vee\neg\forall x\exists y: f(y) = g(x)\\
	[\text{ennf 5}]&&\forall x\exists y: f(y) = g(x)\vee\exists x\forall y: f(y)\neq g(x)\\
	[\text{choice axiom}]&&\exists x\forall y: f(y)\neq g(x)\rightarrow \forall x : f(x) \neq g(s_0)\\
	[\text{choice axiom}]&&\forall x(\exists y: f(y)= g(x)\rightarrow f(s_1(x)) = g(x))\\
	[\text{skolemization 6, 7}]&&\forall x\exists y: f(y) = g(x)\vee\forall x: f(x)\neq g(s_0)\\
	[\text{skolemization 9, 8}]&&\forall x: f(s_1(x)) = g(x)\vee\forall x: f(x)\neq g(s_0)\\
	[\text{cnf 8}]&&f(s_1(x_1)) = g(x_1)\vee f(x_0)\neq g(s_0)\\
	[\text{superposition 11, 2}]&\{\}&f(s_1(x_1)) = g(x_1)\vee g(s_0)\neq g(h(x_0))\\
	[\text{superposition 12, 4}]&\{x_0\mapsto h'(x_0)\}&f(s_1(x_1)) = g(x_1)\vee g(x_0)\neq g(s_0)\\
	[\text{equality resolution 13}]&\{x_0\to s_0\}&f(s_1(x_1)) = g(x_1)
\end{align}

Next we eliminate free variables by propagating substitutions:

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}]&&\forall x: f(x) = g(h(x))\\
	[\text{cnf 1}]&&f(h'(x_0)) = g(h(h'(x_0)))\\
	[\text{axiom}]&&\forall x: h(h'(x)) = x\\
	[\text{cnf 3}]&&h(h'(x_0)) = x_0\\
	[\text{tautology}]&&\forall x\exists y: f(y) = g(x)\vee\neg\forall x\exists y: f(y) = g(x)\\
	[\text{ennf 5}]&&\forall x\exists y: f(y) = g(x)\vee\exists x\forall y: f(y)\neq g(x)\\
	[\text{choice axiom}]&&\exists x\forall y: f(y)\neq g(x)\rightarrow \forall x : f(x) \neq g(s_0)\\
	[\text{choice axiom}]&&\forall x(\exists y: f(y)= g(x)\rightarrow f(s_1(x)) = g(x))\\
	[\text{skolemization 6, 7}]&&\forall x\exists y: f(y) = g(x)\vee\forall x: f(x)\neq g(s_0)\\
	[\text{skolemization 9, 8}]&&\forall x: f(s_1(x)) = g(x)\vee\forall x: f(x)\neq g(s_0)\\
	[\text{cnf 8}]&&f(s_1(x_1)) = g(x_1)\vee f(h'(x_0))\neq g(s_0)\\
	[\text{superposition 11, 2}]&\{\}&f(s_1(x_1)) = g(x_1)\vee g(s_0)\neq g(h(h'(x_0)))\\
	[\text{superposition 12, 4}]&\{\}&f(s_1(x_1)) = g(x_1)\vee g(x_0)\neq g(s_0)\\
	[\text{equality resolution 13}]&\{x_0\to s_0\}&f(s_1(x_1)) = g(x_1)
\end{align}

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}]&&\forall x: f(x) = g(h(x))\\
	[\text{cnf 1}]&&f(h'(s_0)) = g(h(h'(s_0)))\\
	[\text{axiom}]&&\forall x: h(h'(x)) = x\\
	[\text{cnf 3}]&&h(h'(s_0)) = s_0\\
	[\text{tautology}]&&\forall x\exists y: f(y) = g(x)\vee\neg\forall x\exists y: f(y) = g(x)\\
	[\text{ennf 5}]&&\forall x\exists y: f(y) = g(x)\vee\exists x\forall y: f(y)\neq g(x)\\
	[\text{choice axiom}]&&\exists x\forall y: f(y)\neq g(x)\rightarrow \forall x : f(x) \neq g(s_0)\\
	[\text{choice axiom}]&&\forall x(\exists y: f(y)= g(x)\rightarrow f(s_1(x)) = g(x))\\
	[\text{skolemization 6, 7}]&&\forall x\exists y: f(y) = g(x)\vee\forall x: f(x)\neq g(s_0)\\
	[\text{skolemization 9, 8}]&&\forall x: f(s_1(x)) = g(x)\vee\forall x: f(x)\neq g(s_0)\\
	[\text{cnf 8}]&&f(s_1(x_1)) = g(x_1)\vee f(h'(s_0))\neq g(s_0)\\
	[\text{superposition 11, 2}]&\{\}&f(s_1(x_1)) = g(x_1)\vee g(s_0)\neq g(h(h'(s_0)))\\
	[\text{superposition 12, 4}]&\{\}&f(s_1(x_1)) = g(x_1)\vee g(s_0)\neq g(s_0)\\
	[\text{equality resolution 13}]&\{\}&f(s_1(x_1)) = g(x_1)
\end{align}

Next we remove all the skolem constants in the conjecture-tautology by unification, propagate this change, and finally reinterpet superposition as composition to yield a valid intuitionistic proof:

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}]&&\forall x: f(x) = g(h(x))\\
	[\text{instantiation 1}]&&f(h'(x_1)) = g(h(h'(x_1)))\\
	[\text{axiom}]&&\forall x: h(h'(x)) = x\\
	[\text{instantiation 3}]&&h(h'(x_1)) = x_1\\
	[\text{tautology}]&&f(h'(x_1)) = g(x_1)\Rightarrow f(h'(x_1)) = g(x_1)\\
	[\text{equality 5, 2}]&\{\}&g(x_1)= g(h(h'(x_1)))\Rightarrow f(h'(x_1)) = g(x_1)\\
	[\text{equality 6, 4}]&\{\}&g(x_1)= g(x_1)\Rightarrow f(h'(x_1)) = g(x_1)\\
	[\text{equality 13}]&\{\}&f(h'(x_1)) = g(x_1)
\end{align}

Let us look at a second example: Consider the sentences $\forall x : p(x_0, f(x_0))$, $\forall x_0, x_1: (p(x_0, x_1)\Rightarrow q(x_0, g(x_1))$, $\forall x_0, x_1: (q(x_0, x_1)\Rightarrow r(x_0, h(x_1)))$. We take a look at a proof of $\forall x_0\exists x_1: r(x_0, x_1)$ which hopefully gives us $h\circ g\circ f$. First consider the output of vampire

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}] && \forall x_0: p(x_0,f(x_0))\\
	[\text{axiom}] && \forall x_0, x_1 : (p(x_0,x_1) \Rightarrow q(x_0,g(x_1)))\\
	[\text{axiom}] && \forall x_0, x_1 : (q(x_0,x_1) \Rightarrow r(x_0,h(x_1)))\\
	[\text{negated conjecture}] &&\neg\forall  x_0 : \exists x_1 : r(x_0,x_1)\\
	[\text{ennf transformation 2}] && \forall x_0, x_1 : (q(x_0,g(x_1)) \vee \neg p(x_0,x_1)) \\
	[\text{ennf transformation 3}] &&\forall x_0, x_1 : (r(x_0,h(x_1)) \vee \neg q(x_0, x_1)) \\
	[\text{ennf transformation 4}] && \exists x_0 \forall x_1 : \neg r(x_0, x_1)\\
	[\text{choice axiom}] && \exists x_0 \forall x_1 : \neg r(x_0, x_1) \Rightarrow \forall x_1 : \neg r(s_0,x_1)\\
	[\text{skolemisation 7,8}] && \forall x_1 : \neg r(s_0, x_1)\\
	[\text{cnf transformation 1}] && p(x_0,f(x_0))\\
	[\text{cnf transformation 5}] && q(x_1,g(x_2)) \vee \neg p(x_1, x_2)\\
	[\text{cnf transformation 6}] && r(x_3,h(x_4)) \vee \neg q(x_3, x_4)\\
	[\text{cnf transformation 9}] &&. \neg r(s_0,x_5)\\
	[\text{resolution 12, 13}] &\{x_3\mapsto s_0, x_5\mapsto h(x_4)\}& \neg q(s_0,x_4)\\
	[\text{resolution 14, 11}] &\{x_1\mapsto s_0, x_4\mapsto g(x_2)\}&\neg p(s_0,x_2)\\
	[\text{resolution 15, 10}] &\{x_0\mapsto s_0, x_2\mapsto f(s_0)\}& \bot
\end{align}

Again replace negated conjecture by tautology

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}] && \forall x_0: p(x_0,f(x_0))\\
	[\text{axiom}] && \forall x_0, x_1 : (p(x_0,x_1) \Rightarrow q(x_0,g(x_1)))\\
	[\text{axiom}] && \forall x_0, x_1 : (q(x_0,x_1) \Rightarrow r(x_0,h(x_1)))\\
	[\text{tautology}] &&\forall  x_0 \exists x_1 : r(x_0,x_1)\vee \neg\forall  x_0 \exists x_1 : r(x_0,x_1)\\
	[\text{ennf transformation 2}] && \forall x_0, x_1 : (q(x_0,g(x_1)) \vee \neg p(x_0,x_1)) \\
	[\text{ennf transformation 3}] &&\forall x_0, x_1 : (r(x_0,h(x_1)) \vee \neg q(x_0, x_1)) \\
	[\text{ennf transformation 4}] && \forall  x_0 : \exists x_1 : r(x_0,x_1)\vee \exists x_0 \forall x_1 : \neg r(x_0, x_1)\\
	[\text{choice axiom}] && \exists x_0 : \forall x_1 : \neg r(x_0, x_1) \Rightarrow \forall x_1 : \neg r(s_0,x_1)\\
	[\text{choice axiom}] &&\forall x_0(\exists x_1: r(x_0, x_1)\Rightarrow r(x_0, s_1(x_0)))\\
	[\text{skolemisation 7,8}] && \forall  x_0 \exists x_1 : r(x_0,x_1)\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{skolemisation 9,10}] && \forall  x_0 :  r(x_0, s_1(x_0))\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{cnf transformation 1}] && p(x_0,f(x_0))\\
	[\text{cnf transformation 5}] && q(x_1,g(x_2)) \vee \neg p(x_1, x_2)\\
	[\text{cnf transformation 6}] && r(x_3,h(x_4)) \vee \neg q(x_3, x_4)\\
	[\text{cnf transformation 11}] && r(x_6, s_1(x_6))\vee\neg r(s_0, x_5)\\
	[\text{resolution 14, 15}] &\{x_3\mapsto s_0, x_5\mapsto h(x_4)\}&r(x_6, s_1(x_6))\vee \neg q(s_0,x_4)\\
	[\text{resolution 16, 13}] &\{x_1\mapsto s_0, x_4\mapsto g(x_2)\}&r(x_6, s_1(x_6))\vee\neg p(s_0,x_2)\\
	[\text{resolution 17, 12}] &\{x_0\mapsto s_0, x_2\mapsto f(s_0)\}&r(x_6, s_1(x_6))
\end{align}

We propagate the substitutions

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}] && \forall x_0: p(x_0,f(x_0))\\
	[\text{axiom}] && \forall x_0, x_1 : (p(x_0,x_1) \Rightarrow q(x_0,g(x_1)))\\
	[\text{axiom}] && \forall x_0, x_1 : (q(x_0,x_1) \Rightarrow r(x_0,h(x_1)))\\
	[\text{tautology}] &&\forall  x_0 \exists x_1 : r(x_0,x_1)\vee \neg\forall  x_0 \exists x_1 : r(x_0,x_1)\\
	[\text{ennf transformation 2}] && \forall x_0, x_1 : (q(x_0,g(x_1)) \vee \neg p(x_0,x_1)) \\
	[\text{ennf transformation 3}] &&\forall x_0, x_1 : (r(x_0,h(x_1)) \vee \neg q(x_0, x_1)) \\
	[\text{ennf transformation 4}] && \forall  x_0 : \exists x_1 : r(x_0,x_1)\vee \exists x_0 \forall x_1 : \neg r(x_0, x_1)\\
	[\text{choice axiom}] && \exists x_0 : \forall x_1 : \neg r(x_0, x_1) \Rightarrow \forall x_1 : \neg r(s_0,x_1)\\
	[\text{choice axiom}] &&\forall x_0(\exists x_1: r(x_0, x_1)\Rightarrow r(x_0, s_1(x_0)))\\
	[\text{skolemisation 7,8}] && \forall  x_0 \exists x_1 : r(x_0,x_1)\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{skolemisation 9,10}] && \forall  x_0 :  r(x_0, s_1(x_0))\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{cnf transformation 1}] && p(x_0,f(x_0))\\
	[\text{cnf transformation 5}] && q(x_1,g(x_2)) \vee \neg p(x_1, x_2)\\
	[\text{cnf transformation 6}] && r(s_0,h(x_4)) \vee \neg q(s_0, x_4)\\
	[\text{cnf transformation 11}] && r(x_6, s_1(x_6))\vee\neg r(s_0,h(x_4))\\
	[\text{resolution 14, 15}] &\{\}&r(x_6, s_1(x_6))\vee\neg q(s_0,x_4)\\
	[\text{resolution 16, 13}] &\{x_1\mapsto s_0, x_4\mapsto g(x_2)\}&r(x_6, s_1(x_6))\vee\neg p(s_0,x_2)\\
	[\text{resolution 17, 12}] &\{x_0\mapsto s_0, x_2\mapsto f(s_0)\}&r(x_6, s_1(x_6))
\end{align}

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}] && \forall x_0: p(x_0,f(x_0))\\
	[\text{axiom}] && \forall x_0, x_1 : (p(x_0,x_1) \Rightarrow q(x_0,g(x_1)))\\
	[\text{axiom}] && \forall x_0, x_1 : (q(x_0,x_1) \Rightarrow r(x_0,h(x_1)))\\
	[\text{tautology}] &&\forall  x_0 \exists x_1 : r(x_0,x_1)\vee \neg\forall  x_0 \exists x_1 : r(x_0,x_1)\\
	[\text{ennf transformation 2}] && \forall x_0, x_1 : (q(x_0,g(x_1)) \vee \neg p(x_0,x_1)) \\
	[\text{ennf transformation 3}] &&\forall x_0, x_1 : (r(x_0,h(x_1)) \vee \neg q(x_0, x_1)) \\
	[\text{ennf transformation 4}] && \forall  x_0 : \exists x_1 : r(x_0,x_1)\vee \exists x_0 \forall x_1 : \neg r(x_0, x_1)\\
	[\text{choice axiom}] && \exists x_0 : \forall x_1 : \neg r(x_0, x_1) \Rightarrow \forall x_1 : \neg r(s_0,x_1)\\
	[\text{choice axiom}] &&\forall x_0(\exists x_1: r(x_0, x_1)\Rightarrow r(x_0, s_1(x_0)))\\
	[\text{skolemisation 7,8}] && \forall  x_0 \exists x_1 : r(x_0,x_1)\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{skolemisation 9,10}] && \forall  x_0 :  r(x_0, s_1(x_0))\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{cnf transformation 1}] && p(x_0,f(x_0))\\
	[\text{cnf transformation 5}] && q(s_0,g(x_2)) \vee \neg p(s_0, x_2)\\
	[\text{cnf transformation 6}] && r(s_0,h(g(x_2))) \vee \neg q(s_0, g(x_2))\\
	[\text{cnf transformation 11}] && r(x_6, s_1(x_6))\vee\neg r(s_0,h(g(x_2)))\\
	[\text{resolution 14, 15}] &\{\}&r(x_6, s_1(x_6))\vee\neg q(s_0,g(x_2))\\
	[\text{resolution 16, 13}] &\{\}&r(x_6, s_1(x_6))\vee\neg p(s_0,x_2)\\
	[\text{resolution 17, 12}] &\{x_0\mapsto s_0, x_2\mapsto f(s_0)\}&r(x_6, s_1(x_6))
\end{align}

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}] && \forall x_0: p(x_0,f(x_0))\\
	[\text{axiom}] && \forall x_0, x_1 : (p(x_0,x_1) \Rightarrow q(x_0,g(x_1)))\\
	[\text{axiom}] && \forall x_0, x_1 : (q(x_0,x_1) \Rightarrow r(x_0,h(x_1)))\\
	[\text{tautology}] &&\forall  x_0 \exists x_1 : r(x_0,x_1)\vee \neg\forall  x_0 \exists x_1 : r(x_0,x_1)\\
	[\text{ennf transformation 2}] && \forall x_0, x_1 : (q(x_0,g(x_1)) \vee \neg p(x_0,x_1)) \\
	[\text{ennf transformation 3}] &&\forall x_0, x_1 : (r(x_0,h(x_1)) \vee \neg q(x_0, x_1)) \\
	[\text{ennf transformation 4}] && \forall  x_0 : \exists x_1 : r(x_0,x_1)\vee \exists x_0 \forall x_1 : \neg r(x_0, x_1)\\
	[\text{choice axiom}] && \exists x_0 : \forall x_1 : \neg r(x_0, x_1) \Rightarrow \forall x_1 : \neg r(s_0,x_1)\\
	[\text{choice axiom}] &&\forall x_0(\exists x_1: r(x_0, x_1)\Rightarrow r(x_0, s_1(x_0)))\\
	[\text{skolemisation 7,8}] && \forall  x_0 \exists x_1 : r(x_0,x_1)\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{skolemisation 9,10}] && \forall  x_0 :  r(x_0, s_1(x_0))\vee \forall x_1 : \neg r(s_0, x_1)\\
	[\text{cnf transformation 1}] && p(s_0, f(s_0))\\
	[\text{cnf transformation 5}] && q(s_0,g(f(s_0))) \vee \neg p(s_0, f(s_0))\\
	[\text{cnf transformation 6}] && r(s_0,h(g(f(s_0)))) \vee \neg q(s_0, g(f(s_0)))\\
	[\text{cnf transformation 11}] && r(x_6, s_1(x_6))\vee\neg r(s_0,h(g(f(s_0))))\\
	[\text{resolution 14, 15}] &\{\}&r(x_6, s_1(x_6))\vee\neg q(s_0,g(f(s_0)))\\
	[\text{resolution 16, 13}] &\{\}&r(x_6, s_1(x_6))\vee\neg p(s_0,f(s_0))\\
	[\text{resolution 17, 12}] &\{\}&r(x_6, s_1(x_6))
\end{align}

Then unification at 15 gives $s_1 = h\circ g\circ f$ and $s_0 = x_6$ and the final transformation gives:

\setcounter{equation}{0}
\begin{align}
	[\text{axiom}] && \forall x_0: p(x_0,f(x_0))\\
	[\text{axiom}] && \forall x_0, x_1 : (p(x_0,x_1) \Rightarrow q(x_0,g(x_1)))\\
	[\text{axiom}] && \forall x_0, x_1 : (q(x_0,x_1) \Rightarrow r(x_0,h(x_1)))\\
	[\text{instantiation 1}] && p(x_6, f(x_6))\\
	[\text{instantiation 2}] && p(x_6, f(x_6))\Rightarrow q(x_6,g(f(x_6))) \\
	[\text{instantiation 3}] && q(x_6, g(f(x_6)))\Rightarrow r(x_6,h(g(f(x_6)))) \\
	[\text{tautology}] && r(x_6, h(g(f(x_6))))\Rightarrow r(x_6,h(g(f(x_6))))\\
	[\text{composition 6, 7}] &\{\}&q(x_6, g(f(x_6)))\Rightarrow r(x_6,h(g(f(x_6))))\\
	[\text{composition 5, 8}] &\{\}&p(x_6,f(x_6))\Rightarrow r(x_6, h(g(f(x_6))))\\
	[\text{composition 4, 9}] &\{\}&r(x_6, h(g(f(x_6))))
\end{align}

\pagebreak
\bibliographystyle{acm}
\bibliography{references}

\end{document}


\section{Conclusions}

Within the framework of the tests carried out, several conclusions can be drawn from the synthesis in section \ref{sec:synthesis}

\begin{itemize}
\item For the distribution models \gls{rdd} and \gls{rrdd}, the asymptotic models \gls{guw2} and \gls{w2} give density results very close to the real densities.
\item It happens that the \gls{w1} model gives better predictions but never outside \gls{rrdd} or \gls{rcdde}.
\item In \gls{rrdd}, \gls{guw2} and \gls{w2} more often give good results than \gls{w1}.
\item For \gls{rcdde} and \gls{rcddr} no model is close to the actual density. But the asymptotic models are by far the closest.
\item For \gls{rcddd}, \gls{w1} is never close to the real density. \gls{guw2} and \gls{w2} give good results for small values of \( s \) \( t \) and \( l \) but the error increases when the latter variables increase.
\end{itemize}

Finally, \gls{guw2} and \gls{w2} models are often more accurate than the \gls{w1} model.
At least among the distributions tested, \gls{w1} should not be applied beyond the \gls{rrdd} hypotheses.