\documentclass[notes]{beamer}          % print frame + notes
%\documentclass[notes=only]{beamer}     % only notes
%\documentclass{beamer}                 % only frames

\usecolortheme{beaver}

% Some commonly used packages
% (copied mainly from the Utrecht University theme: https://www.overleaf.com/project/5c900fa3bd9930036341116a)
\usepackage{ragged2e}  % `\justifying` text
\usepackage{booktabs}  % Tables
\usepackage{tabularx}
\usepackage{tikz}      % Diagrams
\usetikzlibrary{calc, shapes, backgrounds}
\usepackage{amsmath, amssymb, amsfonts, amsthm}
\usepackage{url}       % `\url`s
\usepackage{listings}  % Code listings
\usepackage{comment}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{amsmath}

% Mainly math commands
\newcommand{\vect}[1]{\bm{#1}}
\usepackage{amsfonts}% to get the \mathbb alphabet
\newcommand{\field}[1]{\mathbb{#1}}
\newcommand{\C}{\field{C}}
\newcommand{\R}{\field{R}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
\providecommand{\abs}[1]{\lvert#1\rvert}
\providecommand{\norm}[1]{\lVert#1\rVert}

% A variable used to exclude slides from the lecture version
\newif\iffull
%\fullfalse
\fulltrue

% Bibliography
\usepackage[uniquename=init,giveninits=true,maxcitenames=1,style=authortitle-comp,backend=bibtex8]{biblatex}
%\bibliography{references}
\addbibresource{references.bib}

%Information to be included in the title page:
\title{Classification: Support vector machines and random forests}
\author{Federica Eduati}
\institute{Eindhoven University of Technology

Department of Biomedical Engineering}
\date{2020}

\begin{document}

\frame{\titlepage}

\section{Overview}

\begin{frame}
\frametitle{Learning goals}
At the end of this lecture you will:
\begin{itemize}
    \item Have a general understanding of support vector machines for classification.
    \item Have a general understanding of machine learning methods based on decision trees (including random forests).
\end{itemize}

\vspace{5mm}

Materials:
\begin{itemize}
    \item Chapters 9, 12 and 15 from \cite{elements}
\end{itemize}

\end{frame}

\section{General introduction}
\begin{frame}{Maximal margin classifier}

Classification problem: find a hyperplane that separates the classes in feature space.

\vspace{5mm}

In $p$ dimensions a hyperplane is a flat affine subspace of dimension $p-1$, with general equation.

\begin{equation}
    f(x) = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \dots + \beta_p X_p = x^T\beta + \beta_0 = 0
\end{equation}

Where:
\begin{itemize}
    \item $\beta_0 = 0$ only if the hyperplane goes through the origin \item the vector $\beta = (\beta_1, \beta_2, \dots, \beta_p)$ is a unit vector ($\norm{\beta} = 1$) orthogonal to the surface of the hyperplane
\end{itemize}

\end{frame}

\begin{frame}{Maximal margin classifier}
Imagine to have a training data of N pairs: $\{(x_1, y_1), (x_2, y_2), \dots, (x_N, y_N)\}$, with $x_i \in {\rm I\!R}^p$ and $y_i \in \left\{-1,1 \right\}$.

If the classes are perfectly separable, there are generally multiple hyperplanes that can separate them.

\begin{center}
\includegraphics[height=5.5cm]{../figures/week_6/svm_hyperplanes.pdf}
\end{center}

\end{frame}

\begin{frame}{Maximal margin classifier}
The \textit{maximal margin classifier} is the one with biggest margin between the two classes.

\begin{center}
\includegraphics[height=5.5cm]{../figures/week_6/svm_maximal_margin_classifier.pdf}
\end{center}

\vspace{-7mm}

\begin{equation*}
\max_{\beta, \beta_0, \norm{\beta} = 1} M \text{, subject to } y_i(x^T_i \beta + \beta_0) \geq M, i=1, \dots, N
\end{equation*}

\end{frame}

\begin{frame}{Noisy or non-separable data}
The maximal margin classifier has issues in case of:
\begin{itemize}
    \item Noisy data with outliers leading to poor solution (left panel - just added one data point to the previous example).
    \item Data non-separable by linear boundary (right panel).
\end{itemize}

\begin{center}
\includegraphics[height=5cm]{../figures/week_6/svm_outlier_or_not_separable.pdf}
\end{center}

\end{frame}

\begin{frame}{Support vector classifier}

The \textit{support vector classifier} provides a solution by maximising a \textit{soft} margin (regularization).

\vspace{5mm}

For this we can modify the optimization problem allowing some slack.

\begin{equation*}
\max_{\beta, \beta_0, \norm{\beta} = 1} M \text{, subject to } y_i(x^T_i \beta + \beta_0) \geq M (1-\xi_i), i=1, \dots, N
\end{equation*}

where $\xi_i \geq 0$ and $\sum_{i=1}^N \xi_i \leq C$. $C$ is a constant that defines the budget we allow for the total amount of slack.

\vspace{5mm}

\end{frame}

\begin{frame}{Support vector classifier}

The \textit{support vector classifier} provides a solution by maximising a \textit{soft} margin.
\begin{center}
\includegraphics[height=5.5cm]{../figures/week_6/svm_support_vector_classifier.pdf}
\end{center}

\vspace{-7mm}

\begin{equation*}
\max_{\beta, \beta_0, \norm{\beta} = 1} M \text{, subject to } y_i(x^T_i \beta + \beta_0) \geq M (1-\xi_i), i=1, \dots, N
\end{equation*}

\end{frame}

\begin{frame}{Slack variables}

The slack variables $\xi = (\xi_1, \xi_2, \dots, \xi_N)$ tell us how much each point is allowed to be on the wrong side of its margin (relative amount).

\begin{itemize}
    \item $\xi = 0$ when the $i$th observation is on the correct side of the margin
    \item $\xi > 0$ when the $i$th observation is on the wrong side of the margin
    \item $\xi > 1$ when the $i$th observation is on the wrong side of the hyperplane
\end{itemize}

\end{frame}

\begin{frame}{Mentimeter question (www.menti.com code 50 37 54 0)}
How many points are on the wrong side of the hyperplane?
\begin{center}
\includegraphics[height=5.5cm]{../figures/week_6/svm_support_vector_classifier.pdf}
\end{center}
\end{frame}

\begin{frame}{Regularization}

The constant $C$ (slack budget) is tunable and can be seen as a regularization parameter.

\begin{itemize}
    \item $C = 0$ no budget for violation of the margin (maximum margin classifier)
    \item increasing $C$ allows more slack allowed (wider margins)
\end{itemize}

Therefore $C$\ controls the bias-variance trade-off:

\begin{itemize}
    \item small $C$ $\rightarrow$ narrow margins $\rightarrow$ high fit to the data $\rightarrow$ low bias, high variance
    \item large $C$ $\rightarrow$ wide margins $\rightarrow$ more violation allowed $\rightarrow$ high bias, low variance
\end{itemize}

\end{frame}

\begin{frame}{Example}

Example of support vector classifier for increasing values of $C$.

\begin{center}
\includegraphics[height=4.2cm]{../figures/week_6/svm_support_vector_classifier_regularization_C.pdf}
\end{center}

The \textit{support points} (marked with diamonds), i.e. those with $\xi_i \neq 0$, are the only ones that determine the orientation of the margin.

\end{frame}

\begin{frame}{Noisy and non-separable data}

The support vector classifier allows to have a good classifier in both the examples of noisy and non-separable data that we have seen earlier, where the maximal margin classifier was not working properly.

\begin{center}
\includegraphics[height=5cm]{../figures/week_6/svm_outlier_or_not_separable_support_vector_classifier.pdf}
\end{center}

\end{frame}

\begin{frame}{Non-linearly separable classes}
\begin{center}
\includegraphics[height=6cm]{../figures/week_6/nonseparableclass.png}
\end{center}

\end{frame}

\begin{frame}{Classification with non-linear decision boundaries}
Extension of the Support vector classifier to handle \textbf{non-linear class boundaries}.
Idea: use of quadratic, cubic, and even higher-order polynomial functions of the predictors.
Example:
\begin{center}{
$X_1, X_2 \hspace{0.05\textwidth}\to\hspace{0.05\textwidth} X_1, X^2_1, X_2, X^2_2, X_1X_2$}
\end{center}
\begin{equation*}
	f(x)=\beta_0 + \beta_1X_1 + \beta_2X^2_1 + \beta_3X_2 + 		\beta_4Xˆ2X^2_2+ \beta_5X_1X_2
\end{equation*}

Example with one dimension:
\begin{figure}
  \includegraphics[width=0.8\textwidth]{../figures/week_6/SVM_kernel}
\end{figure}

\end{frame}

\begin{frame}{Support vector machines}

Problems:
\begin{itemize}
	\item Infeasible for high $p$
	\item Which polynomial order?
\end{itemize}
\vspace{0.5cm}
\textit{Support vector machines} (SVM): extension of the support vector classifier which enlarges the feature space by using \textbf{kernels}.\\
\vspace{0.5cm}
The kernel approach is an efficient computational methodology to enlarge the feature space.

\end{frame}

\begin{frame}{Support Vector Machines}
Inner product definition:$\langle {a,b} \rangle = \sum_{i=1}^{p} a_{i}b_{i},$ where a,b are vectors\\~\\
The solution to the support vector classifier problem involves only the inner products of the observations. The inner product of two observations $x_i, x_i'$ is given by
\begin{equation*}
\langle {x_i,x_i'} \rangle = \sum_{j=1}^{p} x_{ij} x_{i'j}
\end{equation*}
Then, the linear support vector classifier can be represented as:
\begin{equation*}
f(x) = \beta_0 + \sum_{i=1}^{N} \hat \alpha_i \langle {x,x_i} \rangle
\end{equation*}
where there are \textit{N} parameters $\hat \alpha_i$, one per training observation.
\end{frame}

%

\begin{frame}{Support Vector Machines}
$\hat{\alpha}_i$ is nonzero only for the support vectors. \\~\\
So if $\mathit{S}$ is the collection of indices of these support points, we can rewrite f(x) which involves far fewer terms than before:
\begin{equation*}
f(x) = \beta_0 + \sum_{i\in\mathit{S}} \hat{\alpha}_i \langle {x,x_i} \rangle,
\end{equation*}
Abstraction of the inner product:
\begin{equation*}
\mathit{K}(x_i,x_i'),
\end{equation*}
where we refer to $\mathit{K}$ as \textit{kernel}.
A \textit{kernel} is a function that quantifies the similarity of two observations.
\end{frame}

\begin{frame}{Mentimeter question (www.menti.com code 50 37 54 0)}
How many $\hat \alpha$ do we have to estimate in this case?
\begin{center}
\includegraphics[height=5.5cm]{../figures/week_6/svm_support_vector_classifier.pdf}
\end{center}
\end{frame}

\begin{frame}{Support Vector Machines}
Linear kernel: $\mathit{K}(x_i,x_i') = \sum_{j=1}^{p} x_{ij} x_{i'j}$ \\
Polynomial kernel of degree d: $\mathit{K}(x_i,x_i') = (1+ \sum_{j=1}^{p} x_{ij} x_{i'j})^d$\\
Radial kernel: $\mathit{K}(x_i,x_i') = exp(- \gamma \sum_{j=1}^{p} (x_{ij}-x_{i'j})^2)$ \\~\\
What is the advantage of using a kernel rather than simply enlarging the feature space using functions of the original features?
\begin{itemize}
 \item Computational advantage: we don't work in the enlarged feature space.
  \item Automatically computes inner product for high dimensional space of features.
  \item Avoid overfitting by automatically squashing down most dimensions.
\end{itemize}
\end{frame}

\begin{frame}{Extension to multi-class}
So far, binary classification, in other words, two-class setting. \\~\\
SVMs: concept of separating hyperplanes does not lend itself to more than two classes. \\~\\
Two approaches for extending SVMs to K$>$2 classes classification:
\begin{itemize}
 \item One-Versus-One Classification: $\binom{K}{2}$ SVMs comparing pair of classes. We assign the test observation to the class most frequently selected in these pairwise classification.
 \item One-Versus-All Classification: K SVMs, each time comparing one of the K classes to the remaining K-1 classes. We assign the test observation to the class (SVM in this case) with the best discrimination rule.
\end{itemize}
\end{frame}

\section{Tree-based methods}
\begin{frame}{Tree-based methods}
\begin{itemize}
 \item Can be used for \textit{regression} or \textit{classification}
 \item Partition the feature space into a set of rectangles (consecutive binary partitions)
 \item This can be summarised into a tree: decision-trees
 \end{itemize}

 \begin{figure}
\minipage{0.22\textwidth}
  \includegraphics[width=\linewidth]{../figures/week_6/tree-example-a.pdf}
\endminipage\hfill
\minipage{0.26\textwidth}
  \includegraphics[width=\linewidth]{../figures/week_6/tree-example-b.pdf}
\endminipage\hfill
\minipage{0.46\textwidth}%
  \includegraphics[width=\linewidth]{../figures/week_6/tree-example-c.pdf}
\endminipage
\end{figure}

\end{frame}

\begin{frame}{Example}
Coimbra Breast Cancer dataset

(Patricio, M., et al, BMC Cancer, 2018)
\vspace{-1cm}
\begin{center}
\includegraphics[height=8cm]{../figures/week_6/breast_cancer_2Dscatterplot.pdf}
\end{center}
\end{frame}

\begin{frame}{Example}
 \begin{figure}
\minipage{0.5\textwidth}
  \includegraphics[width=\linewidth]{../figures/week_6/breast_cancer_tree.pdf}
\endminipage\hfill
\minipage{0.5\textwidth}%
  \includegraphics[width=\linewidth]{../figures/week_6/breast_cancer_2Dscatterplot_vhlines.pdf}
\endminipage
\end{figure}
\end{frame}

\begin{frame}{Mentimeter question (www.menti.com code 50 37 54 0)}
For which ones the decision boundary was defined using a decision tree?
\begin{center}
\includegraphics[height=5cm]{../figures/week_6/Question_decision_tree}
\end{center}
\end{frame}

\begin{frame}{Mentimeter question (www.menti.com code 50 37 54 0)}
Which scenarios are suitable for decision trees?
\begin{center}
\includegraphics[height=5cm]{../figures/week_6/Question_decision_tree}
\end{center}
\end{frame}

\begin{frame}{How to build a decision-tree}
To grow a decision-tree we need a set of training data with $N$ observations consisting in $p$ inputs and a response
$(x_1,y_1) \dots (x_N,y_N)$, where each $x_i=(x_{i1}, x_{i2}, \dots, x_{ip})^T$ is a vector of feature measurements for the $i$th case.

\vspace{0.5cm}

The algorithm should build the decision tree that:

\begin{itemize}
\item divides the predictor space in $M$ non-overlapping regions $R_m$ with $m=1,...,M$ ($M$ number of leaves). For each observation that falls in the same region $R_m$ we make the same prediction.
\item this partition should minimise the $RSS$ (for regression) or the misclassification (for classification).
\end{itemize}
\end{frame}

\begin{frame}{How to build a decision-tree}
It is infeasible to evaluate every possible partition of the feature space.

\vspace{0.5cm}
We adopt an approach that is:
\begin{itemize}
	\item \textit{top-down}: starts from the top of the tree and proceeds with subsequent splits.
	\item \textit{greedy}: it looks at the optimal splitting at that specific step of the tree, without looking ahead.
\end{itemize}
\end{frame}

\begin{frame}{How to build a decision-tree}
\begin{itemize}
	\item We start from the top of the tree and we select the variable $X_j$ and the splitting point $s$ to define the pair of half-planes $R_1(j,s)=\{X|X_j \le s\}$ and $R_2(j,s)=\{X|X_j > s\}$ that leads to the greatest reduction of the cost function.
	\item This will generate two nodes, for each of the node we repeat the procedure but looking only at the data in that half-plane.
	\item This continue until we reach a termination criterion (e.g. no region with more than 5 observations).
\end{itemize}

\end{frame}

\begin{frame}{Example}
 \begin{figure}
\minipage{0.5\textwidth}
  \includegraphics[width=\linewidth]{../figures/week_6/breast_cancer_2Dscatterplot_vline.pdf}
\endminipage\hfill
\minipage{0.5\textwidth}%
  \includegraphics[width=\linewidth]{../figures/week_6/breast_cancer_2Dscatterplot_vhlines.pdf}
\endminipage
\end{figure}
\end{frame}

\begin{frame}{Mentimeter question (www.menti.com code 50 37 54 0)}
What happens for a \textbf{regression tree} if there is no termination criterion?
\begin{itemize}
\item The tree goes to infinity
\item Each leaf has one observation only
\item It is not possible to tell without seeing the data
\end{itemize}
\end{frame}

\begin{frame}{Mentimeter question (www.menti.com code 50 37 54 0)}
What happens for a \textbf{classification tree} if there is no termination criterion?
\begin{itemize}
\item The tree goes to infinity
\item Each leaf has one observation only
\item It is not possible to tell without seeing the data
\end{itemize}
\end{frame}

\begin{frame}{Cost functions}
Let $N_m$ be the number of observations falling in region $R_m$.

For \textbf{regression}:
$$\dfrac{1}{N_m}\sum_{x_i\in R_m}(y_i-\hat c_m)^2  \quad \mbox{, where} \quad \hat c_m = \dfrac{1}{N_m}\sum_{x_i\in R_m}y_i$$
For \textbf{classification}:
\begin{equation*}
	\hat{p}_{mk}=\dfrac{1}{N_m}\sum_{x_i\in R_m}I(y_i=k)
\end{equation*}

is the proportion of training observations in region $m$ that are from class $k$. Different measures of node impurity include:
\begin{itemize}
\item  \textbf{Misclassification error}: $1-\max_k \hat{p}_{mk}$
\item  \textbf{Gini index}: $\sum_{k=1}^K\hat{p}_{mk}(1-\hat{p}_{mk})$
\item  \textbf{Cross-entropy or deviance} $-\sum_{k=1}^K\hat{p}_{mk}\log\hat{p}_{mk}$
\end{itemize}
\end{frame}

\begin{frame}{Predictions using a decision-tree}
What value will each leaf predict?
\begin{itemize}
	\item For \textbf{regression}: the average of the  training observations falling in the region $R_m$ of the leaf $m$.
		\item For \textbf{classification}: the most occurring class in the region $R_m$ of the leaf $m$.
\end{itemize}

\vspace{0.5cm}

\end{frame}

\begin{frame}{Mentimeter question (www.menti.com code 50 37 54 0)}
What is the risk of a tree with a lot of leaves?
\end{frame}

\begin{frame}{Pruning a tree}
Idea: build a large tree $T_0$ and then prune it back to a subtree $T$.

This is done defining a cost complexity criterion:
$$\sum_{m=1}^{|T|}\sum_{x_i\in R_m}(y_i-\hat c_m)^2+\alpha|T|$$

where:
\begin{itemize}
\item $|T|$ is the number of leaves in a subtree $T$
\item $ \hat c_m = \dfrac{1}{N_m}\sum_{x_i\in R_m}y_i$
\item $\alpha$ is a regularisation parameter (tuned with cross-validation)
\end{itemize}
\end{frame}

\begin{frame}{Pros and cons}
\begin{itemize}
 \item Tree-based methods are simple and easily interpretable (appealing for clinical decision making process)
 \item They often suffer of low prediction accuracy
 \item Solutions: combine different trees to derive a consensus predictions (we will discuss  \textit{bagging}, \textit{random forests}, \textit{boosting})
 \item Combining a large number of trees can improve predictions at the price of loosing a bit interpretability
\end{itemize}
\end{frame}

\begin{frame}{Bagging (or bootstrap aggregation)}
General concept: the average of N observations with variance $\sigma^2$ gives an observation with variance $\sigma^2/N$

\vspace{1cm}

Idea: Instead of pruning big trees, build multiple independent big trees and average their predictions.

\vspace{1cm}

How to build independent trees with only one dataset? With \textbf{bootstrap}.
\end{frame}

\begin{frame}{How to do bagging}

\begin{itemize}
\item Generate $B$ different training datasets by bootstrapping (sampling with replacement).
\item Build a decision-tree for each bootstrapped dataset (without pruning).
\item Obtain the final predictions by averaging (regression) or majority vote (classification).
\end{itemize}

Bagging reduces the variance without increasing the bias.
\end{frame}

\begin{frame}{Out of bag error estimation}
How to estimate the test error of a bagged model?

\vspace{0.5cm}

Idea: on average, each bagged tree makes use of about 2/3 of the observations. We can use the remaining 1/3, called out-of-bag observations (OOB), to estimate prediction error.

\vspace{0.5cm}

For each observation $i$ we consider all the trees in which the observation was OOB. This yields to about B/3 predictions for that observation that can be averaged.
\end{frame}

\begin{frame}{Variable importance measure}
Problem: we reduce variance but at the price of losing interpretability.

\vspace{0.5cm}

Idea: Obtain a measure of the importance of each predictor looking at the how much they decrease the cost function (RSS for regression, Gini index for classification) in average across the B trees.

\end{frame}

\begin{frame}{Random forest}
How can we improve performance over bagging? Performing random subselections of the features.

\vspace{0.5cm}

This decorrelates the trees and reduces variance.

\vspace{0.5cm}

\textbf{Random forests}:

\begin{itemize}
 \item build a large number of decision-trees using bootstrapped training data (same as bagging)
 \item at each split select a subset of $m$ features out of the $p$ as possible split candidate. A typical choice of $m$ is $m \simeq \sqrt p$.
\end{itemize}

\end{frame}

\begin{frame}{Boosting}
With \textbf{boosting} the trees are grown sequentially.
\begin{itemize}
\item Instead of building a lot of large trees, with boosting we sequentially build small trees (with $d$ splits).
\item Each tree fits a shrunken version of the residuals of the previous tree, compensating partially the bias of the previous tree. The shrinkage factor is called $\lambda$
\item The higher $B$ (i.e. the number of trees), the smaller the bias and the higher the variance
\end{itemize}

Choice of hyper-parameters:

\begin{itemize}
\item $B$: cross-validation
\item $\lambda$: typically 0.01 or 0.001 (note: small $\lambda$ will require large $B$)
\item $d$: typically 1.
\end{itemize}

%\textbf{\begin{enumerate}
%\item Build a small tree $T_0$ with a defined number of splits $d$
%\item Compute the residuals $r_0=y-\hat y_0$
%\item For $b = 1,\ldots,B$:
%\begin{enumerate}
%	\item Build a new small tree $T_b$ using $(X,r_{b-1})$ as input and output data
%	\item Update residuals $r_b = r_{b-1} - \hat y_b$
%\end{enumerate}
%\item Get final tree as $T = \lambda \sum_{b=0}ˆB T_b $
%\end{enumerate}

\end{frame}

\begin{frame}{Summary}
\begin{itemize}
\item Decision-trees are simple and interpretable but suffer from poor predictions.
\item Combining multiple trees allows improving predictions at the price of loosing interpretability.
\item Random forests and boosting are state-of-the-art models for supervised learning.
\end{itemize}
\end{frame}

\begin{frame}{Case study: prediction of human population response}
Open DREAM challenge (http://dreamchallenges.org/) with 213 participants.
\begin{itemize}
\item Subchallenge 1: predict cytotoxicity of new cell lines based on the genotype.

\item Subchallenge 2: predict cytotoxicity of new compounds based on their chemical attributes.

\end{itemize}
\begin{center}
\includegraphics[height=3.5cm]{../figures/week_6/Challenge.pdf}
\end{center}
\vspace{-0.5cm}
For both subchallenges the best performing methods were based on random forests.

\end{frame}

%

%
%\section{Tree-based methods}
%\begin{frame}{Decision tree}
%What does a decision tree represent?
%\begin{figure}
%\minipage{0.22\textwidth}
%  \includegraphics[width=\linewidth]{../figures/week_6/tree-example-a.pdf}
%\endminipage\hfill
%\minipage{0.26\textwidth}
%  \includegraphics[width=\linewidth]{../figures/week_6/tree-example-b.pdf}
%\endminipage\hfill
%\minipage{0.46\textwidth}%
%  \includegraphics[width=\linewidth]{../figures/week_6/tree-example-c.pdf}
%\endminipage
%\end{figure}
%
%How do we know what the optimal splitting point is at each node? \newline
%
%Objective function: maximize the \textbf{Information Gain (IG)}
%\begin{equation*}
%IG(D_p,f) = I(D_p) - (\frac{N_{left}}{N_p}I(D_{left}) + \frac{N_{right}}{N_p} I(D_{right}))
%\end{equation*}
%
%The lower the impurity of the child nodes, the larger the information gain.
%
%\end{frame}
%
%\begin{frame}{Classification Trees}
%Classification problem: a class vote for each tree, and then classifies using majority vote. \newline
%
%As impurity metric or splitting criteria:
%\begin{equation*}
%\pushleft{\textbf{Entropy}}: E(t) = - \sum_{i=1}^{c} p(i|t) log_2 p(i|t)
%\end{equation*}
%\begin{equation*}
%\pushleft{\textbf{Gini impurity}}: i(t) = 1 - \sum_{i=1}^{c} p^2(i|t)
%\end{equation*}
%where $p(i|t)$ is the proportion of the samples that belong to class c for node t.
%
%\end{frame}
%\begin{frame}{Regression Trees}
%Regression problem: the predictions from each tree at a target point $x$ are simply averaged. \newline
%
%As impurity metric or splitting criteria:
%\begin{equation*}
%\pushleft{\textbf{Mean square error}}: MSE(t) = - \frac{1}{N_t} \sum_{i \epsilon D_t} (y^{(i)} - \hat{y}^t)^2
%\end{equation*}
%where $N_t$ is the number of training samples at node $t$, $D_t$ is the training subset at node $t$, $y(i)$ is the true target value, and $\hat{y}^t$ is the predicted target value
%\end{frame}
%
%\begin{frame}{Bagging or bootstrap aggregation}
%Decision trees can become much more powerful when used as ensembles. \newline
%\begin{minipage}{0.5\textwidth}
%\begin{figure}
%\includegraphics[height=3cm]{../figures/week_6/bagging.pdf}
%\end{figure}
%\end{minipage}\hfill
%\begin{minipage}{0.5\textwidth}
%\begin{itemize}
% \item The samples are drawn with replacement.
% \item High-variance, low-bias procedures, such as trees.
%\end{itemize}
%\end{minipage}
%
%\begin{minipage}{0.5\textwidth}
%\begin{figure}[H]
%\includegraphics[height=4cm]{../figures/week_6/Bias-Variance-Tradeoff.png}
%\end{figure}
%\end{minipage}\hfill
%\begin{minipage}{0.5\textwidth}
%\begin{itemize}
% \item \textit{From Understanding the Bias-Variance tradeoff, by Scott Fortmann Roe.} \newline
% \item The entire forest will have lower variance but not at the cost of increasing the bias.
%\end{itemize}
%\end{minipage}
%
%\end{frame}
%
%\begin{frame}{Random Forests: motivation}
%
%\textbf{A way of bagging decision trees}: combining the predictions of $n$ different models, each of which having profound different insights into the relationships of the data. \newline
%
%\textbf{Trees} are appropiate for bagging: high-variance, low-bias procedures. \newline
%
%\textbf{Random Forests} builds a large collection of de-correlated trees, and then averages them. It brings in the insights from each of them. So this idea is called \textbf{Ensembling}. \newline
%
%\textbf{Ensemblubg} is a machine learning technique, both for regression and classification tasks. It can also be used for feature selection. \newline
%
%\end{frame}
%
%\begin{frame}{Random Forests: algorithm}
%
%\begin{minipage}{0.5\textwidth}
%\begin{figure}[Ht]
%\includegraphics[height=4.5cm]{../figures/week_6/random-forest.pdf}
%\end{figure}
%\end{minipage} \hfill
%\begin{minipage}{0.48\textwidth}
%
%Workflow:
%\begin{itemize}
%    \item \color{blue}  \textbf{Bootstrap sampling}: \color{black}to grow the tree, a random subsample of the total dataset is used.
%    \item \color{red} \textbf{Model building}: \color{black}a random subset of all features is chosen as a "splitter variable".
%    \item \color{green}  \textbf{Bootstrap aggregating}
%\end{itemize}
%Details:
%\begin{itemize}
%    \item \textbf{Out of Bag Samples}
%    \item \textbf{Variable Importance}
%    \item \textbf{Overfitting}
%\end{itemize}
%
%\end{minipage}
%
%\end{frame}
%
%\begin{frame}{Random Forests are popular}
%Advantages:
%\begin{itemize}
%    \item \textbf{Small sample size}
%    \item \textbf{High-dimensional feature space}
%    \item \textbf{Complex data structures}  \newline
%\end{itemize}
%
%Applications:
%\begin{itemize}
% \item Predicting drug responses for cancer cell lines [\italic{Riddick et al., Bioinformatics, 2010.}] \newline
%\end{itemize} \newline
%
%Genomic characterizations $\rightarrow$ Large number of features \break $\rightarrow$ RF utilize the top features based on bootstrap aggregation \break $\rightarrow$ Good performance.
%
%\end{frame}

\end{document}


\documentclass[a4paper,11pt]{article}
\usepackage[english]{babel}
\usepackage{a4}
\usepackage[cm]{fullpage}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{amsthm}
\usepackage[T1]{fontenc}
\usepackage{lmodern} % Latin modern font family
\usepackage{enumitem}
\usepackage{fitch} % http://folk.uio.no/johanw/FitchSty.html

\newtheorem*{lemma}{Lemma}
\newtheorem*{theorem}{Theorem}

\newcommand{\dotmin}{\buildrel\textstyle.\over{\hbox{\vrule height3pt depth0pt width0pt}{\smash-}}}

% Sans-serif fonts
%\usepackage[T1experimental,lm]{sfmath} % http://dtrx.de/od/tex/sfmath.html
%\renewcommand{\familydefault}{\sfdefault}

% Some configuration for listings
\renewcommand{\labelenumi}{\arabic{enumi}.}
\renewcommand{\labelenumii}{(\alph{enumii})}

\newcounter{firstcounter}
\newcommand{\labelfirst}{(\roman{firstcounter})}
%\newcommand{\spacingfirst}{\usecounter{firstcounter}\setlength{\rightmargin}{\leftmargin}}
\newcommand{\spacingfirst}{\usecounter{firstcounter}}

\newcounter{secondcounter}
\newcommand{\labelsecond}{(\arabic{secondcounter})}
%\newcommand{\spacingsecond}{\usecounter{secondcounter}\setlength{\rightmargin}{\leftmargin}}
\newcommand{\spacingsecond}{\usecounter{secondcounter}}

\title{Recursion Theory (UvA autumn 2008)\\
\normalsize{Exercises Part 13 -- Martijn Vermaat (mvermaat@cs.vu.nl)}}

%\author{Martijn Vermaat (mvermaat@cs.vu.nl)}
%\date{Updated 5th December 2005}
\date{}

\begin{document}

\maketitle

\paragraph{Exercise 2.5.6}

Let $(X_s)_{s \in \omega}$ and $(Y_s)_{s \in \omega}$ be computable enumerations of c.e. sets $X$ and $Y$.

\begin{enumerate}[label=(\alph*)]

\item Both $X \setminus Y$ and $X \searrow Y$ are c.e sets.
\begin{proof}
  Since $z \in X_s - Y_s$ is computable, $X \setminus Y$ is $\Sigma_1$ (hence c.e.).
  The c.e. sets are closed under intersection, so $X \searrow Y$ is c.e. as well.
\end{proof}

\item $X \setminus Y = (X - Y) \cup (X \searrow Y)$.
\begin{proof}
  By definition, we have
  \begin{align*}
    & \exists s(z \in X_s - Y_s) \quad\! \Rightarrow \quad\! \exists s(z \in X_s) &&
    & \exists s(z \in X_s) \quad\! \& \quad\! \neg \exists s(z \in Y_s) \quad\! \Rightarrow \quad\! \exists s(z \in X_s - Y_s)
  \end{align*}
  which give use two useful facts:
  \begin{align}
    & X \setminus Y \subseteq X \label{fact:1}\\
    & X - Y \subseteq X \setminus Y \label{fact:2}
  \end{align}
  \begin{align*}
    X \setminus Y & = (X \setminus Y) \cap (X \cup Y)         && \text{by (\ref{fact:1})}\\
    & = (X \setminus Y) \cap ((X - Y) \cup Y)\\
    & = ((X - Y) \cup (X \setminus Y)) \cap ((X - Y) \cup Y)  && \text{by (\ref{fact:2})}\\
    & = (X - Y) \cap ((X \setminus Y) \cap Y)\\
    & = (X - Y) \cup (X \searrow Y)                           && \text{by definition.}\qedhere
  \end{align*}
\end{proof}

\item If $X - Y$ is not c.e. then $X \searrow Y$ is infinite and indeed noncomputable.
\begin{proof}
  Assume $X - Y$ is not c.e. and suppose $X \searrow Y$ is computable. We have
  \begin{align*}
    X - Y = (X \setminus Y) \cap X \cap \overline{X \searrow Y}
  \end{align*}
  where all intersection operands are c.e. and thus $X - Y$ c.e. to a contradiction.
\end{proof}

\item (Reduction Principle for c.e. sets) Given any two c.e. sets $A$ and $B$,
  there exist c.e. sets $A_1 \subseteq A$ and $B_1 \subseteq B$ such that
  $A_1 \cap B_1 = \emptyset$ and $A_1 \cup B_1 = A \cup B$.
\begin{proof}
  Let $A = W_x$ and $B = W_y$, $A_1 = W_x \setminus W_y$ and $B_1 = W_y \setminus W_x$.
  By the Padding Lemma, we can assume $x \neq y$ without loss of generalization.

  Both $A_1$ and $B_1$ are c.e. by (a).
  By (\ref{fact:1}), $A_1 \subseteq A$ and $B_1 \subseteq B$.
  Furthermore, there is no $z$ such that $\exists s(z \in W_{x,s} - W_{y,s}) \; \& \; \exists s(z \in W_{y,s} - W_{x,s})$, so $A_1 \cap B_1 = \emptyset$.
  Finally, $A_1 \cup B_1 = A \cup B$ follows from
  \begin{align*}
    & \exists s(z \in W_{x,s} - W_{y,s}) \quad\! \text{or} \quad\! \exists s(z \in W_{y,s} - W_{x,s}) \quad\! \Longleftrightarrow \quad\! \exists s(z \in W_{x,s}) \quad\! \text{or} \quad\! \exists s(z \in W_{y,s}) \text{ .}
  \end{align*}
  Note that the ($\Leftarrow$) direction relies on fact (2.24), stating that in every stage, at most one element is enumerated in at most one set $W_e$.
\end{proof}

\end{enumerate}

\end{document}


% \documentclass[10pt,t,presentation,ignorenonframetext,aspectratio=169]{beamer}
\documentclass[10pt,t,handout,ignorenonframetext,aspectratio=169]{beamer}
\usepackage[default]{lato}
\usepackage{tk_beamer1}
\input{tk_packages}
\input{tk_macros}
\input{tk_environ}
\input{tk_ximera}
\usepackage{wasysym}            % for smiley
\newcommand{\zoz}{$\mathbf{ \frac{0}{0} }$}

% some inverse trigs
\DeclareMathOperator{\arcsec}{arcsec}
\DeclareMathOperator{\arccot}{arccot}
\DeclareMathOperator{\arccsc}{arccsc}

%%%% META DATA
\newcommand{\semester}{Autumn 2021}
\newcommand{\course}{Math 1151}
\newcommand{\lecTitle}{Lecture 37: Second Fundamental Theorem \\ of Calculus (SFTOC)}
%%%% TITLE PAGE
\title[\course]{\lecTitle}
\institute[Ohio State]
{
  \medskip
}
\date[\week]{\semester}
\author{Tae Eun Kim, Ph.D.}

\begin{document}
\begin{frame}
  \titlepage
\end{frame}

\begin{frame}
  \frametitle{The Second Fundamental Theorem of Calculus}
  Here comes the second form of the Fundamental Theorem of
  \begin{thm}[Second Fundamental Theorem of Calculus, FTC2]
    Let $f$ be continuous on $[a,b]$. If $F$ is \textbf{any}
    antiderivative of $f$, then
    \[
      \int_a^b f(x)\d x = F(b)-F(a)\,. \tag{FTC2}
    \]
  \end{thm}

  \begin{itemize}
  \item An alternate interpretation of (FTC2) is to write it as
    \begin{image}[0.5\linewidth]
      \begin{tikzpicture}[scale=2,every node/.style={transform shape}]
        \node at (0,0) {
          $\ds \color{green!70!black!70!blue}\int_a^b\color{blue!70!green} \ddx f(x)\color{green!70!black!70!blue}\d x\color{black} =
          \color{purple!50!blue!90!black}f(b) - f(a).$
        };
      \end{tikzpicture}
    \end{image}
  \item The above reads as
    \vspace{0.5em}
    \begin{center}
      \begin{minipage}{0.95\linewidth}
        \begin{quote}
          \textbf{The \textcolor{green!70!black!70!blue}{accumulation}
            of a \textcolor{blue!70!green}{rate} is given by the
            \textcolor{purple!50!blue!90!black}{change in the amount}.}
        \end{quote}
      \end{minipage}
    \end{center}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Notation}
  \begin{itemize}
  \item FTC2 is useful in computing a definite integral:
    \begin{enumerate}
    \item find an antiderivative of the integrand;
    \item evaluate it at the limits of integration;
    \item take the difference.
    \end{enumerate}
  \item In the differencing process, you may find the following notation convenient:
    \[
      \eval{F(x)}_a^b = F(x) \bigg|_a^b = F(b) - F(a) \,.
    \]
  \end{itemize}
\end{frame}

\begin{frame}
  \vs
  \red{\textit{Proof.}}
  Let $a\le c\le b$ and write
  \begin{align*}
    \int_a^b f(x) \d x &= \int_a^c f(x) \d x + \int_c^b f(x) \d x \\
                       &= \int_c^b f(x) \d x - \int_c^a f(x) \d x.
  \end{align*}
  By the First Fundamental Theorem of Calculus, we have
  \[
    F(b) = \int_c^b f(x) \d x\qquad\text{and}\qquad F(a) = \int_c^a f(x) \d x
  \]
  for some antiderivative $F$ of $f$. So
  \[
    \int_a^b f(x) \d x = F(b)-F(a)
  \]
  for this antiderivative. However, \textbf{any} antiderivative
  could have be chosen, as antiderivatives of a given function
  differ only by a constant, and this constant \textit{always}
  cancels out of the expression when evaluating $F(b)-F(a)$.
  \qed{}
\end{frame}

\begin{frame}
  \vs
  \begin{question}
    Compute:
    \begin{enumerate}
    \item $\ds \int_{-2}^2 x^3\d x$
      \vfill
    \item $\ds \int_0^1 \frac{\pi}{3} \sin \frac{\pi}{3}\theta \d
      \theta$
      \vfill
    \end{enumerate}
  \end{question}
\end{frame}

\begin{frame}
  \vs
  \begin{question}
    Compute:
    \begin{enumerate}
    \item $\ds \int_0^5 e^t\d t$
      \vfill
    \item $\ds \int_1^2\left(x^9 + \frac{1}{x}\right) \d x$
      \vfill
    \end{enumerate}
  \end{question}
\end{frame}

\subsection{Net Change and Future Value}
\begin{frame}
  \frametitle{Displacement and net change}
  Let's recall that
  \begin{itemize}
  \item The derivative of a position function $s$ is a velocity function $v$.
  \item The derivative of a velocity function $v$ is an acceleration function $a$.
  \end{itemize}

  In other words,
  \begin{itemize}
  \item A velocity function $v$ is an antiderivative of an acceleration function $a$.
  \item A position function $s$ is an antiderivative of a velocity function $v$.
  \end{itemize}

  In particular, by FTC2,
  \[
    \int_a^b v(t) \d t = s(b) - s(a) \,,
  \]
  which measures a \textbf{change in position}, or \textbf{displacement} as already introduced on Monday.
\end{frame}

\begin{frame}
  \frametitle{Net change and future value}
  \begin{itemize}
  \item In general, FTC2 states that the definite integral of a rate
    of change of a certain quantity $Q$ is the \textbf{net change} in
    its amount between two limits of integration:
    \[
      \int_a^b Q'(s) \d s = Q(b) - Q(a) \,. \tag{Net change}
    \]
  \item If we replace $a = 0$ and $b = t$, we have a formula for \textbf{future value}:
    \[
      Q(t) = Q(0) + \int_0^t Q'(s) \d s \,. \tag{Future value}
    \]
  \end{itemize}
\end{frame}

\begin{frame}
  \vs
  \question{}
  A book publisher estimates that the marginal cost of a particular
  title (in dollars/book) is given by
  \[
    C'(x) = 12 - 0.0002x \,,
  \]
  where $0 \le x \le 50,000$ is the number of books printed. What is the
  cost of producing the 12,001st through 15,000th book?
\end{frame}

\begin{frame}
  \frametitle{Summary of three different integrals}
  \begingroup
  \small
  \begin{enumerate}
  \item An \textbf{indefinite integral}, a.k.a. an antiderivative computes a
    family of functions:
    \note{
      \[
        \int f(x) \d x = \text{``a class of functions whose derivative is $f$''}
      \]
    }
    \begin{center}
      \begin{tcolorbox}[width=0.5\linewidth]
        \vspace{-1em}
        \begin{image}[0.95\linewidth]
          \begin{tikzpicture}[scale=2,every node/.style={transform shape}]
            \node at (0,0) {
              $\ds \int f(x) \d x = F(x) + C$
            };
          \end{tikzpicture}
        \end{image}
        \vspace{-1em}
      \end{tcolorbox}
    \end{center}
    where $F'(x) = f(x)$.
  \item An \textbf{accumulation function} computes an accumulated area:
    \note{
      \[
        \int_a^x f(t) \d t = \text{``a function $F$ whose derivative is $f$''}
      \]
    }
    \begin{center}
      \begin{tcolorbox}[width=0.5\linewidth]
        \vspace{-1em}
        \begin{image}[0.95\linewidth]
          \begin{tikzpicture}[scale=2,every node/.style={transform shape}]
            \node at (0,0) {
              $\ds F(x)=\int_a^x f(t) \d t$
            };
          \end{tikzpicture}
        \end{image}
        \vspace{-1em}
      \end{tcolorbox}
    \end{center}
    FTC1 says that $F'(x) = f(x)$.
  \item A \textbf{definite integral} computes a signed area:
    \note{
      \[
        \int_a^b f(x) \d x = \text{``the signed area between the $x$-axis and $f$''}
      \]
    }
    \begin{center}
      \begin{tcolorbox}[width=0.5\linewidth]
        \vspace{-1em}
        \begin{image}[0.99\linewidth]
          \begin{tikzpicture}[scale=2,every node/.style={transform shape}]
            \node at (0,0) {
              $\ds \int_a^b f(x) \d x = F(b)-F(a)$
            };
          \end{tikzpicture}
        \end{image}
        \vspace{-1em}
      \end{tcolorbox}
    \end{center}
  \end{enumerate}
  \endgroup
\end{frame}

\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\chapter{Printer}

A large part of the printer can be written portably without
performance penalty.  We intend to supply standard methods for
\texttt{print-object}, and code for functions such as \texttt{princ},
\texttt{prin1}, and \texttt{print}.

Initially, we were planning to use the method created by Burger and Dybvig
\cite{Burger:1996:PFN:231379.231397} to print floating-point numbers
so that they can be read back to the exact same number.  But more
recent work \cite{Adams:2018:RFF:3296979.3192369} claims even better
techniques.  We need to compare these new techniques.


% kapitel6.tex
\chapter{Summary and Conclusions}
In this thesis a proposal for a optimization study for the boosted event selection in a search for vector-like quark pair production in the channels TT\texorpdfstring{$\longrightarrow$}~WbZt and BB\texorpdfstring{$\longrightarrow$}~WtZb is submitted.
The analysis was performed with Monte Carlo samples where a preselection and a basic selection, caused by the specific decay channel, was applied.
As a measure for the significance the value $\frac{s}{\sqrt{b}}$ was considered.
The significance was calculated concerning an interval of the chosen final discriminant $m(Zb)$ for the BBS signal process and $m(Zt)$ for the TTS signal process.
With the optimization study performed in this thesis results a significance $\frac{s}{\sqrt{b}}_{TTS}=0.32$  for the TTS and a significance $\frac{s}{\sqrt{b}}_{BBS}=0.48$ for the BBS process.
The significance is proportional to the number of signal events, therefore the absolute value of  $\frac{s}{\sqrt{b}}_{TTS}$ is lower than $\frac{s}{\sqrt{b}}_{BBS}$, because there is a fewer number of events for the TTS process.
The results for both TTS and BBS provide no significant distinction between background fluctuation and signal.
Therefore with the amount of data for a integrated luminosity  $\int L dt$ = \SI{3.2}{fb^{-1}} and this optimization study no discovery of vector-like quarks were possible.
The increase of the significance for the different limits set in the optimization study reveals that the optimization study is sensible.
Moreover it is shown, that with the boosted analysis strategy a lot of background can be rejected by requiring two large-R jets and a top-tag.
As a result of low statistic in the simulated Monte Carlo samples a requirement of one W-tag was not possible.
This requirement would have reject a lot of background, too.
Perhaps the requirement of at least one W-tag would increase the significance, but a safe statement for this is not possible.\\
Conclusive it can be said that for a higher integrated luminosity and therefore a higher amount of signal events the optimization study could provide the possibility for a discovery.


\title{Orientation on Odd-Sized Rings}
%\author{}
\date{}

\begin{document}

\tableofcontents

\section{Ring Orientation}
\label{sec:OrientRing}

\quicksec{OrientRing}
(\href{\examplespec/OrientRing.prot}{spec},
\href{\examplesett/OrientRing.args}{args},
\href{\examplesoln/OrientRing.prot}{soln})

\section{Odd-Sized Ring Orientation}
\label{sec:OrientRingOdd}

\quicksec{OrientRingOdd}
(\href{\examplespec/OrientRingOdd.prot}{spec},
\href{\examplesett/OrientRingOdd.args}{args},
\href{\examplesoln/OrientRingOdd.prot}{soln})

The \ilfile{examplespec/OddOrientRing.prot} file specifies a bidirectional ring topology where processes wish to agree with each other on a direction around the ring.
The topology is taken from the paper by Hoepman titled \textit{Uniform Deterministic Self-Stabilizing Ring-Orientation on Odd-Length Rings}.

\subsection{Problem Instance}

\codeinputlisting{../../../examplespec/OrientRingOdd.prot}

Each process \ttvbl{P[i]} reads \ttvbl{color[i-1]}, \ttvbl{color[i+1]}, \ttvbl{phase[i-1]}, and \ttvbl{phase[i+1]} and writes \ttvbl{color[i]}, \ttvbl{phase[i]}, \ttvbl{way[2*i]}, and \ttvbl{way[2*i+1]}.

Eventually we want all the \ttvbl{way[2*i]} values to equal each other and differ from the \ttvbl{way[2*i+1]} values.
That is, we want each process to agree on a direction.

The \ttvbl{color} and \ttvbl{phase} variables are labeled as \ilcode{puppet} because we allow the protocol to use them to achieve convergence.

The invariant is labeled as \ilcode{((future & shadow) % puppet)} since we only require closure within a new invariant $I'$ rather than $I$.
Also, the behavior of the protocol within the new invariant $I'$ must be the same as the underlying (i.e., shadow) protocol within $I$.

\subsection{Stabilizing Version}

\codeinputlisting{../../../examplesoln/OrientRingOdd.prot}

\section{Daisy Chain Orientation}
\label{sec:OrientDaisy}

\quicksec{OrientDaisy}
(\href{\examplespec/OrientDaisy.prot}{spec},
\href{\examplesett/OrientDaisy.args}{args},
\href{\examplesynt/OrientDaisy.prot}{synt},
\href{\examplesoln/OrientDaisy.prot}{soln})

\end{document}


\documentclass{aastex61}
%Packages
\usepackage{graphicx}
\usepackage{soul, listings, xcolor}
\usepackage{amsmath}
\usepackage{url}
%Code environment details
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\definecolor{grey}{gray}{0.95}
\lstset{frame=tb,
	escapeinside={(*@}{@*)},
	frame = single,
	aboveskip=3mm,
	belowskip=3mm,
	showstringspaces=false,
	columns=flexible,
	basicstyle={\small\ttfamily},
	numbers=none,
	numberstyle=\tiny\color{gray},
	keywordstyle=\color{blue},
	commentstyle=\color{dkgreen},
	stringstyle=\color{mauve},
	breaklines=true,
	breakatwhitespace=true,
}

%% The default is a single spaced, 10 point font, single spaced article.
%% There are 5 other style options available via an optional argument. They
%% can be envoked like this:
%%
%% \documentclass[argument]{aastex61}
%%
%% where the arguement options are:
%%
%%  twocolumn   : two text columns, 10 point font, single spaced article.
%%                This is the most compact and represent the final published
%%                derived PDF copy of the accepted manuscript from the publisher
%%  manuscript  : one text column, 12 point font, double spaced article.
%%  preprint    : one text column, 12 point font, single spaced article.
%%  preprint2   : two text columns, 12 point font, single spaced article.
%%  modern      : a stylish, single text column, 12 point font, article with
%% 		  wider left and right margins. This uses the Daniel
%% 		  Foreman-Mackey and David Hogg design.
%%
%% Note that you can submit to the AAS Journals in any of these 6 styles.
%%
%% There are other optional arguments one can envoke to allow other stylistic
%% actions. The available options are:
%%
%%  astrosymb    : Loads Astrosymb font and define \astrocommands.
%%  tighten      : Makes baselineskip slightly smaller, only works with
%%                 the twocolumn substyle.
%%  times        : uses times font instead of the default
%%  linenumbers  : turn on lineno package.
%%  trackchanges : required to see the revision mark up and print its output
%%  longauthor   : Do not use the more compressed footnote style (default) for
%%                 the author/collaboration/affiliations. Instead print all
%%                 affiliation information after each name. Creates a much
%%                 long author list but may be desirable for short author papers
%%
%% these can be used in any combination, e.g.
%%
%% \documentclass[twocolumn,linenumbers,trackchanges]{aastex61}

%% AASTeX v6.* now includes \hyperref support. While we have built in specific
%% defaults into the classfile you can manually override them with the
%% \hypersetup command. For example,
%%
%%\hypersetup{linkcolor=red,citecolor=green,filecolor=cyan,urlcolor=magenta}
%%
%% will change the color of the internal links to red, the links to the
%% bibliography to green, the file links to cyan, and the external links to
%% magenta. Additional information on \hyperref options can be found here:
%% https://www.tug.org/applications/hyperref/manual.html#x1-40003

%% This is the end of the preamble.  Indicate the beginning of the
%% manuscript itself with \begin{document}.

\begin{document}

\title{Lab 3: Radio Interferometry \\ AST 443: Observational Techniques in Astronomy}

\date{Performed October 19, 2016, and Submitted \today}

\author{Joseph Monroy}

\author{Yogesh Mehta}

\begin{abstract}
The goal of this experiment was to measure the angular profile of the Sun through two methods: using a single dish radio antenna and using a radio interferometer. From these profiles and scans of an unresolved point source (geosynchronous satellite), we can determine the angular diameter of the Sun.

We obtained our data by using the Stony Brook Radio telescope, which is able to switch between single dish and interferometry mode. This telescope was built by Professor Jin Koda, and is quite powerful for something so the cost so little. Despite some technical mishaps with the instruments and uncooperative weather, we were able to obtain our data.

For the interferometric mode, we obtained an angular diameter of 43.99' $\pm$ 0.06'. Comparing to the literature value of the angular diameter of the Sun on our observation date, 31.7', we can see that they do not agree within error. As for the single dish results, we did not have adequate enough data to deduce anything from it.
\end{abstract}

\section{Introduction} \label{sec:intro}
The field of radio astronomy has grown exponentially just in the past 80 years. Up until to this time, the radio spectrum has been out of reach due to the large telescope needed to measure the full wavelength. Through pioneers such as Karl Jansky and Grote Reber, scientists began to see the true power of the radio spectrum.

For many years astronomers kept improving the technology; however, they were always limited by the size of the telescope since you need a large diameter to resolve the huge radio wavelengths Also, it took a long time and always cost a lot to build these near football size telescope dishes. A breakthrough happened in the mid 1940's when astronomers started to apply the properties of interferometry to radio telescopes. Instead of having one huge telescope dish, you could use many, smaller telescopes over a large baseline to have the same effect. Now that the resolution simply depends on the baseline (the length of the array of telescopes), we can have radio interferometers that span many kilometers.

This is the technique we are trying to show in our experiment, and how it results in far better data then if you simply have one telescope. In our experiment we want to get the angular diameter of the Sun through interferometric techniques, while comparing the single dish angular profile of the Sun to that of a geosynchronous satellite.

\section{Observations}
We first took our data on October 19th 2016 using the Stony Brook University Radio Telescope. This telescope was specifically designed and built by Professor Jin Koda as a cheap, simple alternative for those wanting to conduct amateur radio observations. It consists of a single 1 meter diameter satellite dish attached to an azimuthal and altitude drive. Placed below this dish is a long ladder, on which we place the two flat mirrors on both sides of the dish in interferometric mode. Also directly behind the dish are receiver mirrors that reflect the incoming radio waves into the feed horn of the satellite. When we are in single dish mode, we can simply remove since they are not needed. An image of this setup is shown below:
\begin{figure}[hbt!]
	\centering
	\includegraphics[scale = .45]{tourels.jpg}
	\caption{Diagram of the Stony Brook Radio Telescope in interferometry mode \cite{2016AmJPh..84..249K}}
	\label{fig: refcurve1}
\end{figure}

We choose to put the telescope just outside the Physics building on Stony Brook University's West Campus, because it was a good place where the Sun would be visible for most of the day. The weather that day was mostly cloudy, with there being times we could not even find the Sun. Once we set up and put together the telescope, we began to calibrate the pointing of it in both single dish and interferometry mode. This was done by adjusting the azimuthal and altitude angles of the telescope such that we were just pointing next to the Sun. We then took an azimuthal scan of the Sun and noticed how many volts we were getting on the voltmeter. Depending on the mode we were in, we were supposed to see a specific pattern as a we scanned across the Sun. If we didn't get the expected result we went inside the voltmeter as switched out the attenuator for another one. We continued this until we got expected pattern, and therefore calibrated the telescope.

Now we were able to start collecting our science data. For each time we scanned across an object, we made sure to right down the current time, the azimuth and altitude of the object, and start end azimuthal angles we scanned across. Also, we made sure to keep the slew rate of the dish as constant throughout the experiment. We started by taking data in single dish mode, taking two scans of the Sun. Next we choose a reference geosynchronous satellite that was far in position from the Sun. It took a while until we found a suitable one, but we eventually found one and took a scan of it two times. Now we switched the telescope into interferometry mode by flipping the dish around and placing all the mirrors back on the ladder. We choose to scan across the Sun in this mode five separate times, once for each different, $B$, baseline. The baseline could be read off by the ruler attached to the ladder. After scanning the Sun in all the baselines, we went back to our reference satellite and took scans of it for the same baselines used for the Sun. The following is a table of our experimental log sheet:

\section{Data Reduction}
The data we recorded was taken from a laptop in the form of .CMBL files. These file types are used to view data in Logger Pro, however we are more interested in .CSV files. This file type basically separates data in columns spaced by columns. We converted all our data into this file type by using an online converter. The computer recorded our data as voltage with respect to time, so we are going to have to convert the time to azimuthal angle. This can be done by knowing the azimuthal angles in the beginning and end of the scans. And since we have a constant slew rate, we therefore can deduce the angle at each recorded time.

For the interferometric data, we first need to get the visibility $V_{0}$ at each baseline measurement. This is given by:
\begin{equation}
	V_{0}(B_{\lambda}) = \frac{P_{max}-P_{min}}{P_{max}+P_{min}}
\end{equation}
Where $P_{max}$ and $P_{min}$ represents the maximum amplitude fringe and successive minimum respectively. An example of what this should look like is shown below:
\begin{figure}[hbt!]
	\centering
	\includegraphics[scale = .45]{aaaa.jpg}
	\caption{This plot is taken from Professor Jin Koda's Journal article on this radio telescope \cite{2016AmJPh..84..249K}}
	\label{fig: refcurve1}
\end{figure}
The independent variable $B_{\lambda}$ represents the baseline expressed in multiples of the radio wavelength. In our case, the radio wavelength we used was around 2.6 cm.. We can get this variable directly from our measurements from looking directly at our fringe profile for the satellite. Based on the angular length of a fringe pattern, we can directly get the baseline in multiples of wavelength. This is shown below:
\begin{equation}
	\delta\theta = \frac{\lambda}{B} = \frac{1}{B_{\lambda}}
\end{equation}
Where $\delta\lambda$ is taken from the plot:
\begin{figure}[hbt!]
	\centering
	\includegraphics[scale = .45]{assssssssssssss.jpg}
	\caption{This is also taken from Professor Jin Koda's Journal article \cite{2016AmJPh..84..249K}.}
	\label{fig: refcurve1}
\end{figure}
Once we have the visibility for each baseline, we can plot them against each other. From this plot we can deduce the diameter of the Sun through curve fitting. Our baselines ranged from 60 inches to 120 inches

The single dish data is a lot easier to analyze. All we need to do is to convert the time to azimuthal angle by the method stated before. We can plot the Sun and satellite data on the same curve to compare the angular profiles.
The reduced plots of our single dish and interferometric data are shown in Figures 4 and 5.

\begin{figure}[hbt!]
	\centering
	\includegraphics[scale = .45]{krennic.png}
	\caption{Plot of our Sun is the blue dashed line, while the satellite is in the red dots.}
	\label{fig: refcurve1}
\end{figure}
\begin{figure}[hbt!]
	\centering
	\includegraphics[scale = .45]{jyn.png}
	\caption{Plot of our reduced interferometry mode data}
	\label{fig: refcurve1}
\end{figure}

\section{Data Analysis and Results}
Now that we have the plot of visibility vs. baseline, we can fit the plot to a sinc curve and get the diameter from the parameters. In theory, this plot should resemble a sinc function given by:
\begin{equation}
\sin\textit{c}(x) = \frac{\sin(\pi x)}{\pi x}
\end{equation}
Assuming the Sun to be a one dimensional disk, we can get the relation:
\begin{equation}
V_{0}(B_{\lambda}) = \frac{\sin(\pi B_{\lambda} \alpha)}{\pi B_{\lambda}}
\end{equation}
So if we fit the points to a sinc function, the parameter $\alpha$ should give us the angular diameter of the Sun. Looking at our plot, it clearly does not seem to resemble or adequately fit a sinc function. However, we can still get a good estimate for the angular diameter of the Sun. This can be done by noticing at which baseline $B_{\lambda}$ is the visibility closest to zero. Evidently the only point that is closest to zero is at the baseline of 80.0 inches $\pm$ 0.1 inch . Using equation (2), we can get the angular diameter of the Sun:

\begin{equation}
	\delta\theta = \frac{2.6 \; \textit{cm}}{203.2 \; \textit{cm}} = 0.12795
\end{equation}
The only error in this result is in the baseline measurement, so the error should be:
\begin{equation}
      \sigma_{\delta\theta} = \delta\theta  \frac{\sigma_{B}}{B}
\end{equation}
Plugging in the values, we get an error of $1.6 * 10^{-5}$ radians. Converting the result to arcminutes, we get an angular diameter of 43.99' $\pm$ 0.06'.

Clearly from looking at the single dish data plot, there is something wrong here. It seems that when we were taking our satellite scans, we were actually viewing two satellites at once. Therefore, it is difficult to evaluate the data at all. In theory the Sun should be resolved compared to the satellite. However in our case there is not any way to determine this.

\section{Discussion}
Now that we have the experimental angular diameter of the Sun, we can compare our result with the literature value. The angular diameter of the Sun varies depending on the time of the year since we are in an elliptical orbit. So we calculated the Earth-Sun distance on our observation date to be 1.00837 AU. Converting the Sun's diameter to AU, 0.00929826069 AU, we can now get the angular diameter of the Sun using the following equation:
\begin{equation}
	\delta = 2 \arctan\left( \frac{d}{2D}\right)
\end{equation}
Where $d$ and $D$ are the Sun diameter and the Earth-Sun distance respectively. Plugging in the numbers and converting to arcminutes, we get a value of 31.7'. Comparing this value to the experimental, they do not agree within error. They disagree by about 12', or about 0.2 degrees.

There are many explanations for this discrepancy. First off, throughout the entire experiment the voltmeter we were using was always acting strange. When we pointed the telescope at nothing it would read off maximum voltage, whereas if we pointed directly at the Sun we would get no reading. So we constantly kept switching out attenuators in the voltmeter to try to get some sort of signal from the Sun. Also it did not help that the clouds were really thick, such that we could not even find the shadow of the Sun for quite a while. Eventually we actually found our the voltmeter we were using was defective, which is a good reason why we can't fit our visibility curve to a sinc function (i.e. why our interferometric data is so off). If we had another chance at the experiment with a functioning voltmeter I believe we would be able to yield more accurate data.

Another explanation is that we did not have the telescope itself lined up correctly. This was constantly a problem we were having when taking data. We thought we had the dish lined up with the Sun by looking at the shadows, but most of the time we failed to line up properly. And when we did do it correct it would fall out of alignment quite quickly. I think that this problem could be erased if we had more practice with the instrument itself. The telescope is very finicky and particular, so you must really spend some time with it to get a good idea how it functions.

\section{Conclusion}
Over the past hundred years or so we have grown to take over the radio spectrum in all wavelengths. Whether its for AM FM radio, cellular phones, television, GPS, satellites or even your home built radio telescope, we really have grasped the power of this part of the electromagnetic spectrum.

In our experiment specifically we went out with the goal of measuring the angular diameter of the Sun using interferometric techniques. Also we wanted to use a classic single dish telescope to compare the profiles of the Sun and a geosynchronous satellite. Despite some technical and human error during the experiment, we managed to get some results. We measured the angular diameter of the Sun to be 43.99' $\pm$ 0.06'. Compared to the literature value on our observation data, 31.7', they do not agree within error. In our opinion this is mainly due to the faulty voltmeter we had during our experiment, which didn't allow us to get good interferometric data. As for the single dish results, our data is not adequate enough to get anything from it. We mistakenly took scans of two reference satellites throughout the entire experiment, which in the end made us incapable of deducing any results from our single dish data.

\begin{thebibliography}{9}
\bibitem[Koda et al.(2016)]{2016AmJPh..84..249K} Koda, J., Barrett, J., Shafto, G., et al.\ 2016, American Journal of Physics, 84, 249
\end{thebibliography}

\end{document}


% Non numerare ma aggiungere all'indice
\phantomsection
\chapter*{Glossary}
\markboth{GLOSSARY}{}
\addcontentsline{toc}{chapter}{Glossary}

\subsection*{Abbreviations and Acrnoyms}
% Acronym and abbreviations
\begin{table}[h!]
	\begin{center}
		\begin{tabularx}{\textwidth}{ll}
			\toprule
			\textsc{Term} & \textsc{Meaning} \\
			\midrule
			ASIC & Application Specific Integrated Circuit\\
			FPGA & Field Programmable Gate Array \\
			FSM & Finite State Machine \\
			PLL & Phase Locked Loop\\
			SHA & Secure Hash Algorithm \\
			LUT & Look-Up Table\\
			SSL & Secure Sockets Layer \\
			TLS & Transport Layer Security \\
			HTTP & HyperText Transfer Protocol \\
			HTTPS & HyperText Transfer Protocol Secure \\

			\bottomrule
		\end{tabularx}
	\end{center}
\end{table}

%\newpage

\subsection*{Mathematical Symbols and Notation}
\begin{table}[h!]
	\begin{center}
		\begin{tabularx}{\textwidth}{ll}
			\toprule
			\textsc{Symbol} & \textsc{Description} \\
			\midrule
			$p(x)$ & Probability mass function of a discrete random variable\\
			$E[\bullet]$ & Expectation operator \\
			$\oplus$ & Bitwise logic XOR\\
			$\wedge$ & Bitwise logic AND\\
			$\vee$ & Bitwise logic OR\\
			\bottomrule
		\end{tabularx}
	\end{center}
\end{table}


\documentclass[a4paper,11pt,oneside]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\KOMAoptions{DIV=14}
\usepackage[english]{babel}
%
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
%
\usepackage{chngcntr}
\counterwithout{figure}{section}
\counterwithout{table}{section}
%
\usepackage{xcolor}
\usepackage{url}
%
\usepackage{amsmath,amssymb}
\usepackage{trfsigns}
\usepackage{nicefrac}
\usepackage{comment}
\usepackage{cancel}
%
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\tikzset{cross/.style={cross out, draw,
         minimum size=2*(#1-\pgflinewidth),
         inner sep=0pt, outer sep=0pt}}
\usepackage{circuitikz}
%
\newcommand{\eq}[1]{Eq. (\ref{#1})}
%
\newcommand{\fscom}[2][red]{\textcolor{#1}{#2}}
\definecolor{CalcColor}{rgb}{0.0,0.0,0.5}
\newcommand{\ExCalcCol}[2][CalcColor]{\textcolor{#1}{#2}}
%\excludecomment{calc}
\includecomment{calc}

\newcommand\uc{u_\mathrm{C}}
\newcommand\duc{\dot{u}_\mathrm{C}}
\newcommand\dduc{\ddot{u}_\mathrm{C}}

\newcommand\ul{u_\mathrm{L}}
\newcommand\dul{\dot{u}_\mathrm{L}}
\newcommand\ddul{\ddot{u}_\mathrm{L}}

\newcommand\uri{u_\mathrm{R1}}
\newcommand\duri{\dot{u}_\mathrm{R1}}
\newcommand\dduri{\ddot{u}_\mathrm{R1}}

\newcommand\urii{u_\mathrm{R2}}
\newcommand\durii{\dot{u}_\mathrm{R2}}
\newcommand\ddurii{\ddot{u}_\mathrm{R2}}

\newcommand\dx{\dot{x}}
\newcommand\ddx{\ddot{x}}
\newcommand\dy{\dot{y}}
\newcommand\ddy{\ddot{y}}

%\renewcommand\c{\imath}
%\newcommand\dc{\dot{\imath}}
%\newcommand\ddc{\ddot{\imath}}
\renewcommand\c{I}
\newcommand\dc{\dot{I}}
\newcommand\ddc{\ddot{I}}

\newcommand\fsd{\mathrm{d}}

%
\title{Electric RLC circuit to 2nd order ordinary differential equation (ODE)
with constant coefficients}
\author{Frank Schultz, fs446}
%
\begin{document}
%
\noindent Uni Rostock, IEF, INT, Signal- \& Systemtheorie, \#24015, SS2019,
\today, CC BY 4.0

\noindent Prof. Sascha Spors, Frank Schultz, Till Rettberg

\noindent \textbf{Electric RLC circuit to 2nd order ordinary differential equation (ODE)
with constant coefficients}

%##############################################################################
%##############################################################################
\section{Problem Statement}

\begin{minipage}{0.5\textwidth}
Find differential equation $f(\dx,\ddx,y,\dy,\ddy)=0$ and from that
Laplace system function $H(s)=\frac{Y(s)}{X(s)}$  of the
electric RLC circuit shown right for input voltage $x(t)$ and output voltage $y(t)$.
%
$R_1$, $R_2$ denote resistors, $C$ a capacitor and $L$ an inductor.
%
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{center}
\begin{footnotesize}
\begin{circuitikz}[european, scale=0.55, /tikz/circuitikz/bipoles/length=1cm]
\draw (1,0) to [R,l=$R_1$,o-] (3,0);
\draw (3,0) to [C,l=$C$] (5,0);
\draw (5.5,0) to [L,l=$L$,*-] (5.5,-2.5);
\draw (5.5,-2.5) to [R,l=$R_2$,-*] (5.5,-5);
\draw (5,0) to [short,-o,] (7,0);
\draw (1,-5) to [short,o-o] (7,-5);
\draw[-latex] (1,-0.5)--(1,-4.5) node[midway,left]{$x(t)$};
\draw[-latex] (7,-0.5)--(7,-4.5) node[midway,right]{$y(t)$};
\end{circuitikz}
\end{footnotesize}
\end{center}
\end{minipage}

\section{Solution}
%
We use notation $\dot{u} = \frac{\fsd u}{\fsd t}$, $\ddot{u} = \frac{\fsd^2 u}{\fsd t^2}$
for temporal derivatives. We use large $I$ to indicate the current $i(t)$ for
derivative notation, since $\dot{i}$ and $\ddot{i}$ are hard to read.
%
Except the constants $R_1$, $R_2$, $C$ and $L$, all variables are functions
with respect to time.

The voltage / current relations for $R$, $L$ and $C$ are
\begin{align*}
&\uri = R_1 \c, \quad \urii = R_2 \c, \quad \ul = L \dc, \quad \uc = \frac{1}{C}\int \c \fsd t\\
&\c = \frac{\uri}{R_1}, \quad \c = \frac{\urii}{R_2}, \quad \c = \frac{1}{L} \int \ul \fsd t, \quad \c = C \duc
\end{align*}

\subsection{Method I: Complex Voltage Divider}
%
If we are not at all interested in (i) initial conditions of voltage and
current and (ii) in the ODE, we can simply apply the complex voltage
divider between $Y(\omega)$ and $X(\omega)$
%
\begin{align}
H(\omega) = \frac{Y(\omega)}{X(\omega)} =
\frac{\im \omega L + R_2}{R_1 + \frac{1}{\im \omega C} + \im \omega L + R_2}
\end{align}
%
and substitute $\im \omega \rightarrow s = \sigma + \im\omega$
%
\begin{align}
&H(s) = \frac{Y(s)}{X(s)} = \frac{s L + R_2}{R_1 + \frac{1}{s C} + s L + R_2}=
\frac{s^2 + \frac{R_2}{L} s}{s^2 + \frac{R_1 + R_2}{L} s + \frac{1}{L C}}
\end{align}
%
to obtain the Laplace system function.
%
\subsection{Method II: ODE with the Current as Intermediate Variable}
%
Here, we derive ODEs, but we are not interested in initial conditions.
With above voltage / current relations, we can state ODEs following from mesh
equations for input $x$ and output $y$ as
%
\begin{align}
x& = R_1 \c + \frac{1}{C} \int \c \fsd t + L \dc + R_2 \c,\\
y& = L \dc + R_2 \c.
\end{align}
%
The Laplace transform of $x$, $y$ and $\c$ in both equations yields
%
\begin{align}
X(s)& = R_1 \c(s) + \frac{1}{s C} \c(s) + s L \c(s) + R_2 \c(s)\\
Y(s)& = s L \c(s) + R_2 \c(s),
\end{align}
%
considering vanishing initial conditions,
%
from which the transfer function
%
\begin{align}
H(s)& = \frac{Y(s)}{X(s)} = \frac{s L \c(s) + R_2 \c(s)}{R_1 \c(s) + \frac{1}{sC} \c(s) + s L \c(s) + R_2 \c(s)},\\
%H(s)& = \frac{Y(s)}{X(s)} = \frac{s L + R_2}{R_1+R_2 + \frac{1}{s C} + s L}\\
%H(s)& = \frac{Y(s)}{X(s)} = \frac{s + \frac{R_2}{L}}{\frac{R_1+R_2}{L} + \frac{1}{s L C} + s}\\
H(s)& = \frac{Y(s)}{X(s)} = \frac{s^2 + \frac{R_2}{L} s}{s^2 + \frac{R_1+R_2}{L} s + \frac{1}{L C}}
\end{align}
%
results by canceling the current $I(s)$.

\subsection{Method III: ODE}
%
The most tedious derivation aims at finding the full ODE $f(\dx,\ddx,y,\dy,\ddy)=0$
without any intermediate variable, such as the current involved.
%
The circuit under discussion requires more careful inspection than other RLC
circuits , since there is only one current involved and the unknown voltage drop
$y$ is along two electric elements.

There is certainly a more formalised way to solve this problem, however a suitable
approach would be as follows:
%
Let us start with above stated mesh equations
%
\begin{align}
x& = R_1 \c + \frac{1}{C} \int \c \fsd t + L \dc + R_2 \c,\\
y& = L \dc + R_2 \c
\end{align}
%
and rearrange to equate them
$x - R_1 \c - \frac{1}{C} \int \c \fsd t - R_2 \c = L \dc = y - R_2 \c$
to
%
\begin{align}
%x - R_1 \c - \frac{1}{C} \int \c \fsd t - R_2 \c = y - R_2 \c\\
x - (R_1+R_2) \c - \frac{1}{C} \int \c \fsd t = y - R_2 \c.
\end{align}
%
We aim to find relations in order to substitute the current. Since we deal with a
second order ODE, we expect second order derivatives, at least for the output $y$.
%
Thus, it appears reasonable to apply a temporal derivation
%
\begin{align}
\dx - (R_1+R_2) \dc - \frac{1}{C} \c  = \dy - R_2 \dc.
\end{align}
%
Recall that $\c = \frac{1}{L} \int \ul \fsd t \rightarrow \dc = \frac{1}{L} \ul$.
%
Inserting this
%
\begin{align}
\dx - \frac{R_1+R_2}{L} \ul - \frac{1}{C} \c  = \dy - R_2 \frac{1}{L} \ul.
\end{align}
%
This simplified things, so let us perform these two steps again.
%
Second temporal derivation
%
\begin{align}
\ddx - \frac{R_1+R_2}{L} \dul - \frac{1}{C} \dc  = \ddy - \frac{R_2}{L} \dul
\end{align}
%
and again inserting $\dc = \frac{1}{L} \ul$ yields
%
\begin{align}
\ddx - \frac{R_1+R_2}{L} \dul - \frac{1}{L C} \ul  = \ddy - \frac{R_2}{L} \dul.
\end{align}
%
Now, we should rearrange this equation
%
\begin{align}
\label{eq:ODE_with_uL}
\ddx + \frac{R_2}{L} \dul = \ddy + \frac{R_1+R_2}{L} \dul + \frac{1}{L C} \ul
\end{align}
%
due to our expectation that coefficients for $x, \dx, \ddx, y, \dy, \ddy$
will appear as positive constants.
%
Next, we need to get rid of $\ul$ and $\dul$. For that we can use the mesh
equations
%
\begin{align}
\label{eq:ODE_helper_x}
&x = \uri + \uc + \ul + \urii \rightarrow& \ul = x - \uri - \uc - \urii,\\
\label{eq:ODE_helper_y}
&y = \ul + \urii \rightarrow& \ul = y - \urii.
\end{align}
%
Applying \eq{eq:ODE_helper_x} into the left, $x$-related  side of \eq{eq:ODE_with_uL}
and applaying \eq{eq:ODE_helper_y} into the right, $y$-related side of \eq{eq:ODE_with_uL}
results in
%
\begin{align}
\label{eq:ODE_tmp1}
\ddx + \frac{R_2}{L} (\dx - \duri - \duc - \durii) = \ddy + \frac{R_1+R_2}{L} (\dy - \durii) + \frac{1}{L C} (y - \urii).
\end{align}
%
It appears meaningful to sort terms
\begin{align}
\ddx + \frac{R_2}{L} \dx - \frac{R_2}{L} (\duri + \duc + \durii)
=
\ddy + \frac{R_1+R_2}{L} \dy + \frac{1}{L C} y
- \frac{R_1+R_2}{L} \durii - \frac{1}{L C} \urii.
\end{align}
Since we have no degrees of freedom left
(we have used all relations between voltage, current and Kirchhoff's laws)
we are in hope that the ODE reduces to
\begin{align}
\label{eq:ODE}
\boxed{
\ddx + \frac{R_2}{L} \dx
=
\ddy + \frac{R_1+R_2}{L} \dy + \frac{1}{L C} y}
\end{align}
under the assumption that the remaining terms
\begin{align}
- \frac{R_2}{L} (\duri + \duc + \durii)
\stackrel{?}{=}
- \frac{R_1+R_2}{L} \durii - \frac{1}{L C} \urii
\end{align}
and thus cancel out.
%
Rearranging yields
\begin{align}
&R_2 C (\duri + \duc + \durii)
\stackrel{?}{=}
(R_1+R_2) C \durii + \urii,\\
&R_2 C \duri+
R_2 C \duc+
\cancel{R_2 C \durii}
\stackrel{?}{=}
R_1 C \durii + \cancel{R_2 C \durii} + \urii,\\
&R_2 C \duri+
R_2 C \duc
\stackrel{?}{=}
R_1 C \durii+
\urii.
\end{align}
%
Inserting the current (recall that $\c = C \duc$)
\begin{align}
R_2 C R_1 \dc+
R_2 C \frac{1}{C} \c+
=
R_1 C R_2 \dc+
R_2 \c
\end{align}
proves identity as required.

Thus, the derived ODE in \eq{eq:ODE} can be transformed to Laplace domain
\begin{align}
s^2 X(s) + \frac{R_2}{L} s X(s)
=
s^2 Y(s) + \frac{R_1+R_2}{L} s Y(s) + \frac{1}{L C} Y(s)
\end{align}
%
for \underline{vanishing initial conditions} and we can confirm the already known result
%
\begin{align}
\boxed{
H(s) = \frac{Y(s)}{X(s)} =
\frac{s^2 + \frac{R_2}{L} s}
{s^2 + \frac{R_1+R_2}{L} s + \frac{1}{L C}}
}.
\end{align}
%
\bibliographystyle{IEEEtranSA.bst}
\bibliography{literature}
\end{document}


\setcounter{framenumber}{224}
\begin{frame}
  \LectureNo{8}
  \maketitle
\end{frame}

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

\section{Rehash}
\begin{frame}{Rehash}

\begin{itemize}

	\item Now we move to first-order logic.

	\item Propositional logic deals with inferences involving the sentential connectives ``not,'' ``and,'' ``or,'' \dots; \alert{first-order logic also allows for the quantifiers ``for all'' and ``there exists.''}

	\item We start with syntax:

		\begin{itemize}

			\item \alert{We model ordinary language by means of formal languages, artificial languages whose grammar is given by precise mathematical rules.}

		\end{itemize}

\end{itemize}

\end{frame}

\section{8. Syntax of First-Order Logic}
\subsection{8.1 First-Order Languages}

\begin{frame}{8.1 First-Order Languages}

	\begin{itemize}

		\item (8.1.1) Remember that in first-order (f.o.) logic we deal with the quantifiers ``for all'' and ``there is'':

		\begin{enumerate}[(1)]
		\setcounter{enumii}{2}

		\item This ball is scarlet and everything that's scarlet is red. So, this ball is red.

		\item The letter is in the left drawer. So there is something in the left drawer.

	\end{enumerate}

	\item In propositional logic, we can't accurately handle these inferences:
	\[p,q\nvDash r\]
	\[p\nvDash q\]

	\item (8.1.2) We need to take into account the \emph{internal grammatical structure} of sentences:
		\[\underbrace{\text{The ball}}_{\text{Term}}~\underbrace{\text{is scarlet}}_{\text{Predicate}}\]

	\end{itemize}

\end{frame}

\begin{frame}{Abstraction}

	\begin{itemize}

		\item The concrete terms and predicates don't matter:
				\begin{enumerate}[(1')]
		\setcounter{enumii}{2}

		\item This train is slow and everything that's slow is yellow. So, this train is yellow.

		\item The dog is in the car. So there is something in the car.

	\end{enumerate}

	\item So, we can abstract away from them:

			\begin{itemize}

				\item Terms: $t,u,v,\mathellipsis$

				\item Predicates: $P,R,Q,\mathellipsis$

			\end{itemize}

	\item We get:

		\begin{itemize}

			\item The ball is red $\leadsto$ $P(t)$

			\item The letter is in the left drawer $\leadsto$ $R(t,u)$

		\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{Kinds of Terms}

	\begin{itemize}

		\item (8.1.3) In classical f.o. logic, we distinguish \emph{three} kinds of terms:

		\begin{itemize}

			\item \emph{proper names}, like ``Johannes'' or ``Angela'' (constants)

			\item \emph{pronouns}, like ``he,'' ``she,'' and ``it'' (variables)

			\item \emph{functional terms}, like ``the birthplace of Ada Lovelace'' or ``the LCA of Ada Lovelace and Alan Turing'' (\dots functions)

		\end{itemize}

		\item We use:

			\begin{itemize}

				\item $a,b,c,\mathellipsis$ as constants

				\item $x,y,z,\mathellipsis$ as variables

				\item $f,g,h,\mathellipsis$ as function symbols

			\end{itemize}

		\item (8.1.4) Note that functions can be \emph{nested}:

			\begin{itemize}

				\item[] The LCA of Ada Lovelace and the LCA of Alan Turing and Angela Merkel

				\item[$\leadsto$]  $f(a,f(b,c))$

			\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{Quantifiers}

	\begin{itemize}

		\item (8.1.6) Enter the \emph{quantifiers} ``for all'' and ``there is'' (+ \dots):

		\begin{itemize}
		\item[] Everything that's scarlet is red.
		\item[$\leadsto$] Every $\underbrace{\text{object}}_{\text{indefinite}}$ is such that if $\underbrace{\text{it}}_{\text{pronoun}}$ is scarlet, then $\underbrace{\text{it}}_{\text{pronoun}}$ is red.
		\item[$\leadsto$] Every $x$ is such that if $x$ is scarlet, then $x$ is red.
		\end{itemize}

		\item We use the \emph{universal quantifier} $\forall$ for ``every'':

		\begin{itemize}
		\item[$\leadsto$] $\forall x(S(x)\to R(x))$
		\end{itemize}

		\item (8.1.7) Similarly, we use the universal quantifier $\exists$ for ``there is'':

		\begin{itemize}

			\item[] There is something in the left drawer
			\item[$\leadsto$] There is some $\underbrace{\text{object}}_{\text{indefinite}}$ such that $\underbrace{\text{it}}_{\text{pronoun}}$ is in the left drawer
			\item[$\leadsto$] There is some $x$ such that $x$ is in the left drawer

			\item[$\leadsto$] $\exists xR(x,b)$

		\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{Summary}

\begin{tabular}{c | l | l}
	Symbol & Name & Reading\\\hline
	$a,b,c,\mathellipsis$ & Constants & Proper names\\
	$x,y,z,\mathellipsis$ & Variables & Pronouns\\
	$f,g,h, \mathellipsis$ & Function symbols & Functional expressions\\
	$P,Q,R,\mathellipsis$ & Predicate symbols & Properties, relations\\
	$\forall $ & Universal quantifier & every, for all, each, \dots\\
	$\exists$ & Existential quantifier & there exists, for some, \dots
	\end{tabular}

\end{frame}

\subsection{8.2 Terms and Formulas}
\begin{frame}{8.2 Terms and Formulas}

	\begin{itemize}

		\item (8.2.1) A \emph{signature} is a structure $\mathcal{S}=(\mathcal{C}, \mathcal{F}, \mathcal{R}, ar)$ such that:
		\begin{enumerate}[(i)]

			\item $\mathcal{C}$ is a set of \emph{constant symbols}

			\item $\mathcal{F}$ is a set of \emph{function symbols}

			\item $\mathcal{R}$ is a set of \emph{predicate symbols}

			\item $ar:\mathcal{F}\cup\mathcal{R}\to\mathbb{N}$ is a function that assigns to each function and predicate symbol a fixed natural number, it's \emph{arity}
		\end{enumerate}

	\item (8.2.2) Notation:

		\begin{itemize}

			\item $R^n\in\mathcal{R}$ means $R\in\mathcal{R}$ with $ar(R)=n$
			\item $f^n\in\mathcal{F}$ means $f\in\mathcal{F}$ with $ar(f)=n$

		\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{(8.2.3) Examples}

	\begin{enumerate}[(i)]

				\item $\mathcal{S}_{PA}=(\{0\}, \{S^1, +^2, \cdot^2\}, \alert{\emptyset})$

				\item $\mathcal{S}_\emptyset=(\alert{\emptyset},\alert{\emptyset},\alert{\emptyset})$

				\item $\mathcal{S}_\in=(\{\emptyset\}, \emptyset, \{\in^2\})$

				\item$\mathcal{S}=(\{a,b,c\}, \{f^1, g^2\}, \{P^1, R^2\})$
			\end{enumerate}

\end{frame}

\begin{frame}{Logical Vocabulary}

	\begin{itemize}

		\item (8.2.4) The \emph{logical} vocabulary of every f.o. language is the same:
		\begin{enumerate}[(i)]

			\item the set of \emph{variables}: $\mathcal{V}=\{x,y,z,\mathellipsis\}$

			\item the \emph{sentential operators}: $\neg,\land,\lor,\to,\leftrightarrow$

			\item the \emph{identity predicate}: \alert{$=^2$}

			\item the \emph{quantifiers}: $\forall,\exists$

			\item the \emph{parentheses}: $(,)$.

		\end{enumerate}

		\item Note the distinguished, binary \emph{identity predicate} $=$.

		\item We don't abstract away from identity:

			\begin{itemize}

				\item[] The birthplace of Ada Lovelace and Alan Turing is the same.

				\item[$\leadsto$] $f(a)=f(b)$

				\item[\alert{Not}] $R(f(a),f(b))$

			\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{The Recursive Definition of Terms}

	\begin{itemize}

		\item Because of function nesting, we need to define terms recursively

		\item (8.2.5). The set $\mathcal{T}$ of \emph{terms} is recursively defined as the smallest set $X$ such that:
		\begin{enumerate}[(i)]

			\item \begin{enumerate}[(a)]
			\item $\mathcal{V}\subseteq X$
			\item $\mathcal{C}\subseteq X$
			\end{enumerate}
			\item If $t_1, \mathellipsis, t_n\in X$ and $f\in\mathcal{F}$ with $ar(f)=n$, then $f(t_1, \mathellipsis, t_n)\in X$

	\end{enumerate}

		\item So, the terms are all the variables and constants plus the functional combinations of those.

	\end{itemize}

\end{frame}

\begin{frame}{(8.2.6) Examples}

	\begin{enumerate}[(i)]

				\item In $\mathcal{S}_{PA}$: \[S(0),S(S(0)),\mathellipsis\in\mathcal{T}\]\[S(x), S(y), +(0,0), \cdot(0,0), \cdot (Sx, +(0,0)),\mathellipsis\in\mathcal{T}\]

				\item[] Notational conventions in $\mathcal{S}_{PA}$:
				\begin{enumerate}[(a)]

					\item ${n}$ means $\underbrace{S(\mathellipsis S(0)\mathellipsis)}_{n\text{ times}}$: $1=S(0),2=S(S(0)),\mathellipsis$

					\item We use ``infix notation:''  $(2\cdot 4)={\cdot}(2,4), (2+ 4)={+}(2,4),$ etc.

					\item[]

					\item[] But watch out for parentheses: $((2\cdot 4)+1)\neq (2\cdot (4+1))$
				\end{enumerate}

				\item In $\mathcal{S}_\emptyset$: only $x,y,z,\mathellipsis.$

				\item In $\mathcal{S}_\in$: only $\emptyset$ and $x,y,z,\mathellipsis.$
				\item Assuming that $f^2\in\mathcal{F}$, we have \[f(x,x), f(x,y), f(y,x), f(y,y), f(f(x,y), f(y,x)),\mathellipsis\in\mathcal{T}\]
			\end{enumerate}

\end{frame}

\begin{frame}{The Recursive Definition of Formulas}

	\begin{itemize}

		\item (8.2.8) The set $\mathcal{L}$ of \emph{formulas} is recursively defined as the smallest set $X$ such that:
		\begin{enumerate}[(i)]

			\item \begin{enumerate}[(a)]

				\item If $R^n\in\mathcal{P}$ and $t_1, \mathellipsis, t_n\in \mathcal{T},$ then $R(t_1, \mathellipsis, t_n)\in X$.

				\item If $t_1,t_2\in \mathcal{T}$, then $t_1=t_2\in X$

				\end{enumerate}

			\item \begin{enumerate}[(a)]

				\item if $\phi\in X$, then $\neg \phi\in X$

				\item if $\phi,\psi\in X$, then $(\phi\circ\psi)\in X$ for $\circ=\land,\lor,\to,\leftrightarrow$

				\item if $\phi\in X$ and $x\in \mathcal{V}$, then $Qx\phi\in X$ for $Q=\exists,\forall$

			\end{enumerate}

		\end{enumerate}

		\item $R(t_1, \mathellipsis, t_n)$ and $t_1=t_2$ are called \emph{atomic formulas}.

		\item $t_1\neq t_2$ means $\neg{t_1=t_2}$

	\end{itemize}

\end{frame}

\begin{frame}{(8.2.10.i) Examples}

Formulas in $\mathcal{L}_{PA}$:
					\[x=10\]
					\[S(x)=44\]
					\[2+2=4\]
					\[1\cdot1=0\]
					\[\forall x S(x)\neq 0\]
					\[((2\cdot 2)=5\land S(44)=7)\]
					\[\forall x\forall y(x\neq y\to S(x)\neq S(y))\]
					\[\forall x\forall y(S(x)=y+1\to S(x)=S(y))\]
					\[\forall x\exists yS(x)=y\]

\end{frame}

\begin{frame}{(8.2.10.ii) Examples}

Formulas in $\mathcal{L}_\emptyset$:

				\[x=y\]
				\[(x=y\land y\neq z)\]
				\[\forall x\exists y(x=y\land \forall z y\neq z)\]
				\[\forall x\exists y x\neq y\]
				\[\exists x\exists y(x\neq y\land \forall z(z=x\lor z=y))\]

\end{frame}

\begin{frame}{(8.2.10.iii) Examples}

Formulas in $\mathcal{L}_\in$:
				\[{\in}(x,x)\]
				\[\forall x{\in}(\emptyset,x)\]
				\[\neg\exists x{\in}(x,\emptyset)\]
				\[\forall x({\in}(x,y)\to {\in}(x,z))\]
				\[\forall x\forall(x=y\leftrightarrow\forall z({\in}(z,x)\leftrightarrow {\in}(z,y))) \]

Convention: $t\in u$ means ${\in}(t,u)$
\[x\in x\]
				\[\forall x~\emptyset\in x\]
				\[\neg\exists x~x\in \emptyset\]
				\[\forall x(x\in y\to x\in z)\]
				\[\forall x\forall y(x=y\leftrightarrow \forall z(z\in x\leftrightarrow z\in y))\]

\end{frame}

\begin{frame}{(8.2.10.iv) Examples}

Formulas in $\mathcal{L}$ over $\mathcal{S}=(\{a,b,c\}, \{f^1, g^2\}, \{P^1, R^2\})$:

				\[R(f(g(a,b)),g(f(a),f(b)))\]
				\[\forall x P(f(a))\]
				\[\forall x(P(a)\to \exists yR(x,y))\]
				\[(\forall xP(x)\land \forall xQ(x))\]
				\[\forall x(P(x)\lor \forall xQ(x))\]
				\[(P(x)\leftrightarrow \forall y\forall xR(x,y))\]

\end{frame}

\begin{frame}{Induction on $\mathcal{L}$}

	\begin{itemize}

		\item \textbf{Theorem}. Let $\Phi$ be a condition on formulas. If we can show:
		\begin{enumerate}[(i)]

			\item  \begin{enumerate}[(a)]

				\item $\Phi(R(t_1,\mathellipsis, t_n))$ for all $R^n\in \mathcal{R}$ and $t_1,\mathellipsis, t_n\in\mathcal{T}$

				\item $\Phi(t_1=t_2)$ for $t_1,t_2\in \mathcal{T}$

			\end{enumerate}

			\item \begin{enumerate}[(a)]

			\item For all $\phi\in\mathcal{L}$, if $\Phi(\phi)$, then $\Phi(\neg\phi)$.

			\item For all $\phi,\psi\in\mathcal{L}$, if $\Phi(\phi)$ and $\Phi(\psi)$, then $\Phi((\phi\circ\psi))$, for $\circ=\land,\lor,\to,\leftrightarrow$.

			\item For all $\phi\in\mathcal{L}$, if $\Phi(\phi)$, then $\Phi(Qx\phi)$ for $Q=\forall,\exists$.

		\end{enumerate}
		\end{enumerate}
		Then we can conclude that for all $\phi\in\mathcal{L}$, $\Phi(\phi)$.

	\item \textbf{Theorem}.  Let $\Phi$ be a condition on terms. If we can show:
		\begin{enumerate}[(i)]

			\item  \begin{enumerate}[(a)]

				\item $\Phi(a)$ for all $a\in\mathcal{C}$

				\item $\Phi(x)$ for all $x\in\mathcal{V}$

			\end{enumerate}

			\item If $\Phi(t_1), \mathellipsis,\Phi(t_n),$ then $\Phi(f(t_1,\mathellipsis,t_n))$.
		\end{enumerate}
		Then we can conclude that for all $t\in\mathcal{T}$, $\Phi(t)$.

	\end{itemize}

\end{frame}

\begin{frame}{(8.2.15) Recursion on $\mathcal{L}$}

We define $c:\mathcal{T}\to\mathbb{N}$ by:

	\begin{enumerate}[(i)]

		\item \begin{enumerate}[(a)]

			\item $c(a)=0$ for all $a\in\mathcal{C}$

			\item $c(x)=0$ for all $x\in \mathcal{V}$

			\end{enumerate}

		\item $c(f(t_1, \mathellipsis, t_n))=max(c(t_1), \mathellipsis, c(t_n))+1$

	\end{enumerate}

We define $c:\mathcal{L}\to\mathbb{N}$ by:
		\begin{enumerate}[(i)]

			\item  \begin{enumerate}[(a)]

				\item $c(R(t_1,\mathellipsis, t_n))=max(c(t_1), \mathellipsis, c(t_n))$

				\item $c(t_1=t_2)=max(c(t_1), c(t_2))$
			\end{enumerate}

			\item \begin{enumerate}[(a)]

			\item $c(\neg\phi)=c(\phi)+1$
			\item $c(\phi\circ\psi)=max(c(\phi),c(\psi))+1$, for $\circ=\land,\lor,\to,\leftrightarrow$.

			\item $c(Qx\phi)=c(\phi)+1$ for $Q=\forall,\exists$.

		\end{enumerate}
		\end{enumerate}

\end{frame}

\subsection{8.3 Parsing Trees and Occurrences}
\begin{frame}{8.3 Parsing Trees and Occurrences}

	\begin{itemize}

		\item (8.3.2) We recursively define $T$, which assigns to $t\in\mathcal{T}$ its parsing tree:

\begin{center}
\begin{tikzpicture}
\node at (-2,1) {(i)};

\node at (0,1) {$T(\alpha)=$};
\node at (1.5,1) {\Tree [.$\alpha$ ]};
\node at (4,1) {for all $\alpha\in\mathcal{V}\cup\mathcal{C}$};

\node at (-2,-1) {(ii)};
\node at (0,-1) {$T(f(t_1, \mathellipsis,t_n))=$};
\node at (4,-1) {\Tree [.{$f(t_1, \mathellipsis,t_n)$} [.{$T(t_1)$} ] [.$\mathellipsis$ ] [.{$T(t_n)$} ] ]};

\end{tikzpicture}
\end{center}

	\end{itemize}

\end{frame}

\begin{frame}{(8.3.3) Examples}

	\begin{center}
			\begin{tabular}{c c}
			$4$ & $(2\cdot (2+1))$\\[2ex]
			\Tree [.$S(S(S(S(0))))$ [.$S(S(S(0)))$ [.$S(S(0))$ [.$S(0)$ [.$0$ ] ] ] ] ]

				&

					\Tree [.$(S(S(0))\cdot (S(S(0))+S(0)))$ [.$S(S(0))$ [.$S(0)$ [.$0$ ] ] ] [.$(S(S(0))+S(0))$ [.$S(S(0))$ [.$S(0)$ [.$0$ ] ]  ] [.$S(0)$ [.$0$ ] ] ] ]
			\end{tabular}
		\end{center}

\end{frame}

\begin{frame}{(8.3.4) Parsing Trees for Formulas}

{\small
\begin{center}
\begin{tikzpicture}
\node at (-4,1) {(i.a)};

\node at (-2,1) {$T(R(t_1, \mathellipsis, t_n))=$};
\node at (0.5,1) {\Tree [.{$R(t_1, \mathellipsis,t_n)$} [.{$T(t_1)$} ] [.$\mathellipsis$ ] [.{$T(t_n)$} ] ]};

\node at (2.5,1) {(i.b)};
\node at (4,1) {$T(t_1=t_2)=$};
\node at (6,1) {\Tree [.$t_1=t_2$ [.$T(t_1)$ ] [.$T(t_2)$ ] ]};

\node at (-2,-1) {(ii.a)};
\node at (0,-1) {$T(\neg \phi)=$};
\node at (2,-1) {\Tree [.$\neg \phi$ [.$T(\phi)$ ] ]};

\node at (-2,-3) {(iii.b)};
\node at (0,-3) {$T((\phi\circ\psi))=$};
\node at (2,-3) {\Tree [.$(\phi\circ\psi)$ [.$T(\phi)$ ] [.$T(\psi)$ ] ]};
\node at (5,-3) {for $\circ=\land,\lor,\to,\leftrightarrow$};

\node at (-2,-5) {(ii.c)};
\node at (0,-5) {$T(Qx \phi)=$};
\node at (2,-5) {\Tree [.$Qx\phi$ [.$T(\phi)$ ] ]};
\node at (5,-5) {for $Q=\forall,\exists$};

\end{tikzpicture}
\end{center}}

\end{frame}

\begin{frame}{(8.3.5) Example}

\begin{center}

	\Tree [.{$\forall x(R(x,g(f(a),f(b)))\to \exists yR(y,y))$} [.{$R(x,g(f(a),f(b)))\to \exists yR(y,y)$} [.{$R(x,g(f(a),f(b)))$} [.$x$ ] [.{$g(f(a),f(b))$} [.$f(a)$ [.$a$ ]  ] [.$f(b)$ [.$a$ ]  ] ] ] [.$\exists yR(y,y)$ [.$R(y,y)$ [.$y$ ]  [.$y$ ] ] ] ] ]

	\end{center}

\end{frame}

\begin{frame}{(8.3.7)  Stripped Parsing Trees via Example (8.3.8)}

\begin{center}

	\begin{tabular}{c c c}

	\Tree [.{$\forall x(R(x,g(f(a),f(b)))\to \exists yR(y,y))$} [.{$R(x,g(f(a),f(b)))\to \exists yR(y,y)$} [.{$R(x,g(f(a),f(b)))$} [.$x$ ] [.{$g(f(a),f(b))$} [.$f(a)$ [.$a$ ]  ] [.$f(b)$ [.$a$ ]  ] ] ] [.$\exists yR(y,y)$ [.$R(y,y)$ [.$y$ ]  [.$y$ ] ] ] ] ]

	&

	\Tree [.{$\forall x$} [.{$\to$} [.{$R$} [.$x$ ] [.{$g$} [.$f$ [.$a$ ]  ] [.$f$ [.$a$ ]  ] ] ] [.$\exists y$ [.$R$ [.$y$ ]  [.$y$ ] ] ] ] ]

	\end{tabular}

	\end{center}

\end{frame}

\begin{frame}{(8.3.9) Naming Nodes}

Take the tree:

			\begin{center}
				\Tree [.$\bullet$ [.$\bullet$  [.$\bullet$ [.$\bullet$ ] ] [.$\bullet$ [.$\bullet$ ] [.$\bullet$ ] ] ] ]
			\end{center}

	\begin{itemize}

		\item The root is always called $r$.

		\item The first child of the root is called $( r, 1)$.

		\item The first child of $( r, 1)$ is called $( r, 1, 1)$.

		\item The \emph{second} child of $( r, 1)$ is called $( r, 1, 2)$.

		\item The node $( r, 1, 1, 2)$ doesn't exist in our tree.

		\item Nodes: {\small$\{r, ( r,1), ( r,1,1), ( r,1,2),( r,1,1, 1), ( r,1,2,1), ( r,1,2,2)\}.$}

		\item We name a node by giving the ``directions'' for someone traveling along the edges through the nodes.
	\end{itemize}

\end{frame}

\begin{frame}{Occurrences}

{\small
\begin{itemize}

		\item (8.3.10) An expression $\sigma$ \emph{occurs} in a term or formula $\tau$ iff $\sigma$ is the label of some node in the (ordinary or stripped) parsing tree of $\tau$.

	\item (8.3.11.iii) \emph{Example}. $R(x,y)$ occurs at $(r,1,2)$ and at $(r,1,2,1,1,2,1)$ in:
\begin{center}{\tiny
\begin{tabular}{c}
\begin{tikzpicture}[level distance = 3em]
{\Tree [.$\forall x(R(x,y)\to \exists x\forall y(R(y,x)\land \neg R(x,y)))$
		[.$R(x,y)\to \exists x\forall y(R(y,x)\land \neg R(x,y))$
			[.\alert{$R(x,y)$} [.$x$ ] [.$y$ ] ]
			[.$\exists x\forall y(R(y,x)\land \neg R(x,y))$
				[.$\forall y(R(y,x)\land \neg R(x,y))$
					[.$R(y,x)\land \neg R(x,y)$
						[.$R(y,x)$
							[.$y$ ]
							[.$x$ ]
						]
						[.$\neg R(x,y)$
							[.\alert{$R(x,y)$}
								[.$x$ ]
								[.$y$ ]
							]
						]
					]
				]
			]
		]
	]
}
\end{tikzpicture}
\end{tabular}}
\end{center}

	\item We define an \emph{occurrence} of $\sigma$ in $\phi$ as a pair $(n,\sigma)$ where $n$ is a node in the parsing tree labelled with $\sigma$.

	\end{itemize}
}

\end{frame}

\subsection{8.4 Free and Bound Variables}
\begin{frame}{8.4 Free and Bound Variables}

	\begin{itemize}

		\item (8.4.1) We want to understand the quantificational structure of formulas.

		\item (8.4.2) The quantifier $\forall x$ at $r$ in $\forall x(P(a)\land \neg R(x,a))$ captures $x$ at $(r,1,2,1,1)$.

		\item (8.4.4) In $\forall x({N}(x)\to {\exists x}R(x,x))$, $\forall x$ at $r$ binds $x$ at $(r,1,1,1)$, but \emph{not} at $(r,1,2,1,1)$ and  $(r,1,2,1,2)$.

		\begin{center}
		\Tree [.\alert{$\forall x$} [.$\to$ [.${N}$ [.\alert{$x$} ] ] [.${\color{green}\exists x}$ [.$R$ [.{\color{green}$x$} ] [.{\color{green}$x$} ] ] ] ] ]
		\end{center}

	\end{itemize}

\end{frame}

\begin{frame}{Variable Binding}

\begin{itemize}

	\item (8.4.5) Let $( n, x)$ be an occurrence of a variable $x$ in a formula $\phi$ and $( m, Qy)$ an occurrence of a quantifier $Q=\forall,\exists$ in $\phi$. Then, $( n, x)$ is {\it bound} by  $( m, Qy)$ iff
\begin{enumerate}[(i)]
\item $x=y,$
\item there is an downwards path from $m$ to $n,$
\item this path from $m$ to $n$ does not go through a node $k$ such that $( k, Q'x)$ is an occurrence of a quantifier $Q'=\forall,\exists$ in $\phi$.

\end{enumerate}
A variable occurrence that is not bound by any quantifier occurrence is \emph{free}.

\item \emph{Example}: $\forall x(\exists y \neg R(x,y)\lor (P(x)\to R(c,y)))$

	\begin{center}{\small
	\begin{tikzpicture}[level distance = 2em]
	 \Tree [.\alert{$\forall x$} [.$\lor$ [.{\color{green}$\exists y$} [.$\neg$ [.$R$ [.$\alert{x}$ ] [.{\color{green} $y$} ] ] ] ] [.$\to$ [.$P$ [.$\alert{x}$ ] ] [.$R$ [.$c$ ] [.{\color{blue}$y$} ] ] ] ] ]
	 \end{tikzpicture}}
	 \end{center}

\end{itemize}

\end{frame}

\begin{frame}{Example (8.4.6.iii)}

\begin{center}{\small
$\forall x(R(x,y)\to \exists x\forall y(R(y,x)\land \neg R(x,y)))$

\vspace{2ex}

\begin{tabular}{c}
\begin{tikzpicture}[level distance = 2em]
{\Tree [.{\color{red}$\forall x$}
		[.$\to$
			[.{$R$} [.{\color{red}$x$} ] [.{\color{purple}$y$} ] ]
			[.{\color{green}$\exists x$ }
				[.{\color{blue}$\forall y$}
					[.$\land$
						[.$R$
							[.{\color{blue}$y$} ]
							[.{\color{green}$x$} ]
						]
						[.$\neg$
							[.{$R$}
								[.{\color{green}$x$} ]
								[.{\color{blue}$y$} ]
							]
						]
					]
				]
			]
		]
	]
}
\end{tikzpicture}
\end{tabular}}
\end{center}

\end{frame}

\begin{frame}{Open and Closed Formulas}

	\begin{itemize}

		\item (8.4.7) A formula $\phi$ is open iff there is a free variable occurrence in it; otherwise $\phi$ is closed. Closed formulas are called \emph{sentences}.

		\item (8.4.8) \emph{Examples}:

		\begin{itemize}

				\item $\forall x(R(x,y)\to \exists x\forall y(R(y,x)\land \neg R(x,y)))$ is open, since $((r,1,1,2),y)$ is free.

				\item $\forall x(\exists y \neg R(x,y)\lor (P(x)\to R(c,y)))$ is open since $( ( r,1,2,2,2), y)$ is free

				\item $\forall x({N}(x)\to {\exists x}R(x,x))$ is closed.

			\end{itemize}

		\item (8.4.9) Open formulas don't have a definite truth-value, only sentcenes do.

	\end{itemize}

\end{frame}
\subsection{8.5 Substitution}
\begin{frame}{8.5 Substitution}

	\begin{itemize}

		\item (8.5.1) \emph{Substitution in Terms}. We define $(s)[x:=t]$ recursively by:

		\begin{enumerate}[(i)]

				\item $(s)[x:=t]=\begin{cases} s & \text{if } s\neq x\\ t & \text{ if }s=x\end{cases}$ for $s\in \mathcal{C}\cup\mathcal{V}$

				\item $(f(t_1,\mathellipsis, t_n))[x:=t]=f((t_1)[x:=t], \mathellipsis, (t_n)[x:=t])$

			\end{enumerate}

		\item (8.5.2)  \emph{Substitution in Forulas}. We define $(\phi)[x:=t]$ (the result of substituting $t$ for all \emph{free} occurrences of $x$ in $\phi$) recursively as follows:

		\begin{enumerate}[(i)]

			\item \begin{enumerate}[(a)]

				\item $(R(t_1, \mathellipsis, t_n))[x:=t]=R((t_1)[x:=t], \mathellipsis, (t_n)[x:=t])$

				\item $(t_1=t_2)[x:=t]=t_1[x:=t]=t_2[x:=t]$

			\end{enumerate}

			\item \begin{enumerate}[(a)]

			\item $(\neg\phi)[x:=t]=\neg(\phi[x:=t])$

			\item $((\phi\circ\psi))[x:=t]=((\phi)[x:=t]\circ(\psi)[x:=t])$ for $\circ=\land,\lor,\to,\leftrightarrow$

			\item $(Qy\phi)[x:=t]=\begin{cases} Qy(\phi)[x:=t] & \text{if } y\neq x\\ Qy\phi & \text{if }y=x\end{cases}$ for $Q=\forall,\exists$

			\end{enumerate}

			\end{enumerate}

	\end{itemize}

\end{frame}

\begin{frame}{Example (8.5.4)}

$(\forall x(\exists y \neg R(x,y)\lor (P(x)\to R(c,y))))[y:=c]$
	\begin{align*}
	&=\forall x((\exists y \neg R(x,y)\lor (P(x)\to R(c,y))))[y:=c]\\
	&=\forall x(((\exists y \neg R(x,y)))[y:=c]\lor (((P(x)\to R(c,y))))[y:=c])\\
	&=\forall x((\exists y \neg R(x,y))\lor ((P(x))[y:=c]\to (R(c,y))[y:=c]))\\
	&=\forall x((\exists y \neg R(x,y))\lor (P((x)[y:=c])\to (R((c)[y:=c]), (y)[y:=c])))\\
	&=\forall x(\exists y \neg R(x,y)\lor (P(x)\to R(c,c)))
	\end{align*}

\end{frame}

\subsection{8.6 Formalization}
\begin{frame}{8.6 Formalization}

\begin{itemize}

	\item (8.6.1) The \emph{translation key} interprets the signature:

	\begin{enumerate}[(i)]

			\item A so-called \emph{domain of discourse}, $D$, which is the set of things we're talking about.

			\item For each constant in the signature, a natural language term it formalizes.

			\item For each predicate in the signature, a natural language predicate it formalizes.

			\item For each function symbol in the language, a natural language expression it formalizes.

		\end{enumerate}

\end{itemize}

\end{frame}

\begin{frame}{(8.6.3) Formalization Guidelines $\exists$}

\begin{tabular}{p{6.5cm} c l}

		Somebody who's smart exists & $\leadsto$ & $\exists x S(x)$\\

		There's somebody who's not smart & $\leadsto$ & $\exists x\neg S(x)$\\

Somebody's smart and somebody's handsome & $\leadsto$ & $\exists xS(x)\land \exists xH(x)$\\

Somebody's smart and handsome & $\leadsto$ & $\exists x(S(x)\land H(x))$\\
 Nobody's both smart and handsome & $\leadsto$ &$\neg\exists x(S(x)\land H(x))$\\

 Somebody, who's smart, is handsome & $\leadsto$ & $\exists x(S(x)\land H(x))$

		\end{tabular}

		\vspace{4ex}

		 \[\alert{\exists x(S(x)\to H(x))}\]

\end{frame}

\begin{frame}{(8.6.4) Formalization Guidelines $\forall$}

\begin{tabular}{p{6cm} c l}

		Not everybody handsome is smart & $\leadsto$ & $\neg\forall x(H(x)\to S(x))$\\
Everybody who's smart is handsome & $\leadsto$ &$\forall x(S(x)\to H(x))$\\
A person who's smart is handsome & $\leadsto$ &$\forall x(S(x)\to H(x))$\\
Someone who's smart is handsome & $\leadsto$ &$\forall x(S(x)\to H(x))$\\
Everybody's smart and handsome & $\leadsto$ &$\forall x(S(x)\land H(x))$
		\end{tabular}

		\vspace{4ex}

		\[\alert{\forall x(P(x)\to S(c))\neq \forall xP(x)\to S(c)}\]

		\[\alert{\forall x(P(x)\land S(x))\neq \forall x(P(x)\to S(x))}\]

\end{frame}

\begin{frame}{(8.6.5) Formalization Guidelines $x,y,z,\mathellipsis$}

Variables ``are'' pronouns:

\vspace{4ex}

\begin{tabular}{p{6cm} c l}
		He's handsome & $\leadsto$ & $H(x)$\\
		She's handsome and smart & $\leadsto$ & $H(x)\land S(x)$\\
		He's handsome and \emph{he}'s smart & $\leadsto$ & $H(x)\land S(y)$\\
		He's handsome and she's smart & $\leadsto$ & $H(x)\land S(y)$\\
		That's a smart and handsome gal & $\leadsto$ & $H(x)\land S(x)$\\

		\end{tabular}

\end{frame}

\begin{frame}{(8.6.7) Numerical Quantifiers}

\[\exists xP(x)\tag{Exists$_1$}\]
\[\forall x\forall y(P(x)\land P(y)\to x=y)\tag{At Most$_1$}\]
\[\exists x(P(x)\land \forall y(P(y)\to x=y))\tag{Exactly$_1$}\]

\[\exists x\exists y(P(x)\land P(y)\land x\neq y)\tag{Exists$_2$}\]
\[\forall x\forall y\forall z(P(x)\land P(y)\land P(z)\to x=y\lor x=z\lor y=z)\tag{At Most$_2$}\]
\[\exists x\exists y(P(x)\land P(y)\land \forall z(P(z)\to x=z\lor y=z))\tag{Exactly$_2$}\]
\end{frame}

\begin{frame}{Core Ideas (Lecture Version)}

	\begin{itemize}

		\item In f.o. logic, we take the grammatical structure of simple sentences into account.

		\item  Singular terms stand for objects, predicates for properties/relations.

		\item Quantifiers allow us talk about things in generality.

		\item The signature consists of a set of constants, of function symbols, and of predicate symbols each.

		\item Both terms and formulas are defined inductively in f.o.r logic.

		\item We have induction for formulas and terms and function recursion.

		\item Parsing trees are defined for terms and functions.

		\item Nodes in trees have a canonical way of being named: by the directions for how to find them starting at the root.

		\item Variables are bound by quantifiers.

		\item A formula without free variables is closed, a sentence.

		\item Just like in propositional logic, there are guidelines for formalization.

	\end{itemize}

\end{frame}

\begin{frame}

	\begin{center}
	{\huge\bf Thanks!}
	\end{center}

\end{frame}