\setcounter{framenumber}{63}
\begin{frame}
  \LectureNo{3}
  \maketitle
\end{frame}

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

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

\begin{itemize}

	\item You have to learn mathemateze like a foreign language.

	\item Variables stand for arbitrary but fixed objects, constants stand for known objects.

	\item \alert{An object is defined by giving a list of properties that the object and only the object satisfies. We need to prove existence and uniqueness.}

		\item \alert{A property or relation is defined by giving the conditions for an object has the property or some objects stand in the relation. It mustn't be circular.}

		\item  \alert{A mathematical proof is a rigorous, step-by-step argument which establishes the truth of a mathematical statement.}

		\item Think of proving as problem solving.

		\item Follow the advice!

\end{itemize}

\end{frame}

\section{3.0 Elementary Set Theory}
\subsection{3.1 Sets and Set Notation}

\begin{frame}{3.1 Sets and Set Notation}

	\begin{itemize}

		\item (3.1.1) A \emph{set} is a collection of objects, called its \emph{elements} or \emph{members}.

		\begin{itemize}

			\item $x\in X$ means $x$ is an element of $X$

			\item $x\notin X$ means $x$ is \emph{not} an element of $X$.

		\end{itemize}

		\item (3.1.2) \emph{Extensional Definition}. $\{a_1, \mathellipsis, a_n\}$ is the set whose members are $a_1, \mathellipsis, a_n$.

		\begin{itemize}

			\item  $\{1,a, \{\text{Robbie},0\}\}$ contains $1,a,0$ and the set (!) $ \{\text{Robbie},0\}$

			\item $\{0\}$, singleton 0, contains only $0$
			\item $\{ \}$ contains nothing, it's the \emph{empty set} and also denoted $\emptyset$

			\item $0$ is \emph{not} a set (note that $0\neq \{0\}$!)

		\end{itemize}

		\item (3.1.3) There are also \emph{infinite} sets:

			\begin{itemize}

				\item $\mathbb{N}$ the set of natural numbers

				\item $\mathbb{Z}$ the set of integers

				\item $\mathbb{Q}$ the set of rationals

				\item $\mathbb{R}$ the set of reals

			\end{itemize}

		\item Note that  $\{0,1,2,\mathellipsis\}$ is \emph{not} an extensional definition of $\mathbb{N}$!

	\end{itemize}

\end{frame}

\begin{frame}{Set Abstraction}

	\begin{itemize}

		\item (3.1.6) If $X$ is the set of all objects satisfying condition $\Phi$, then $X$ can be written as the \emph{abstract} $\{x:\Phi(x)\}$:

		\begin{itemize}

			\item $\{x: x\in\mathbb{N}\text{ and }1\leq x\leq 10\}$ is the set of natural numbers between 1 and 10

			\item $\{x: x\text{ is prime}\}$ is the set of all prime numbers

		\end{itemize}

		\item An object $a$ is an element of $\{x:\Phi(x)\}$ iff $a$ satisfies the condition $\Phi$:

		\begin{itemize}

			\item $n\in \{x: x\in\mathbb{N}\text{ and }1\leq x\leq 10\}$ iff $n\in\mathbb{N}$ and $1\leq n\leq 10$

		\end{itemize}

		\item (3.1.7) Sometimes, we use set abstraction over an ambient set:

		\begin{itemize}

			\item $\{x\in \mathbb{N}:x\cdot x=2\}=\emptyset$

			\item $\{x\in \mathbb{R}:x\cdot x=2\}=\{\sqrt{2},-\sqrt{2}\}$

		\end{itemize}

		\item (3.1.8) Sometimes, we assume that the members of a set have a specific \emph{form}:

		\begin{itemize}

			\item $\{\frac{n}{m}:n,m\in \mathbb{Z},m\neq 0\}=\{x: \text{ there are }n,m\in \mathbb{Z}\text{ s.t. }x=\frac{n}{m},m\neq 0 \}$

		\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{The Russel Paradox}

	\begin{itemize}

		\item Not every $\{x: \Phi(x)\}$ exists!

		\item For let $\Phi(x)$ be the condition $x\notin x$ and consider \[r:=\{x:x\notin x\}.\]

		\item \emph{Russel's Paradox}. Assume that $r$ exists.  We know that $r\in r$ iff $r\notin r$.  But either (a) $r\in r$ or (b) $r\notin r$ (classical logic).  If (a) $r\in r$, then $r\notin r$.  Contradiction.  And if (b) $r\notin r$, then $r\in r$. Again, a contradiction.  So, either way, if we assume that $r$ exists (and classical logic), then we get a contradiction.  \hfill $\square$

		\item Solution: $r$ doesn't exist!

	\end{itemize}

	\begin{center}
		\begin{tabular}{c}
		\includegraphics[width=10ex]{russel}\\[-1ex]
		{\tiny $\not\hspace{-1ex}\textcopyright$ Bertrand Russell (1916). Justice in War-Time. Chicago: The Open Court Publishing Co, work in public domain}
		\end{tabular}
		\end{center}

\end{frame}

\subsection{3.2 The Subset Relation}
\begin{frame}{3.2 The Subset Relation}

	\begin{itemize}

		\item (3.2.1) A set $X$ is a subset of a set $Y$ iff every member of $X$ is also a member of $Y$.

		\begin{itemize}

			\item $X\subseteq Y$ means $X$ is a subset of $Y$

			\item $X\nsubseteq Y$ means $X$ is \emph{not} a subset of $Y$

		\end{itemize}

		\item Note that $X\nsubseteq Y$ iff there exists an $x\in X$ such that $x\notin Y$!

		\item \emph{Examples}:

		\begin{itemize}

			\item $\{0,1\}\subseteq \{1,a,0,\{b,1\}\}$

			\item $\{b,1\}\nsubseteq \{1,a,0,\{b,1\}\}$ (but $\{b,1\}\in \{1,a,0,\{b,1\}\}$!)

			\item $\mathbb{N}\subseteq \mathbb{Z}$

			\item $\mathbb{Z}\nsubseteq \mathbb{N}$

		\end{itemize}

		\item Two facts:

			\begin{itemize}

				\item (3.2.2) For all $X$, $X\subseteq X$

				\item (3.2.4) For all $X$, $\emptyset\subseteq X$.

			\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{Proof of 3.2.3}

	\begin{itemize}

		\item We show this fact indirectly.

		\item So, suppose that there exists a set $X$ such that $\emptyset\nsubseteq X$. Call this set $A$.

		\item We get that $\emptyset\nsubseteq A$, which means that there exists at least one object $x$ such that $x\in \emptyset$ but $x\notin A$. Call this object $a$.

		\item We get that $a\in \emptyset$.

		\item But we know that for each $x$, $x\notin \emptyset$, and hence $a\notin \emptyset$.

		\item We've arrived at a contradiction, $a\in \emptyset$ and $a\notin\emptyset$.

		\item Hence the assumption that there exists a set $X$ such that $\emptyset\nsubseteq X$ is false.

		\item So for each set $X$, we have that $\emptyset\subseteq X$.

		\item  $\qedsymbol$

\end{itemize}

\end{frame}

\begin{frame}{The Power Set}

	\begin{itemize}

		\item (3.2.5) For $X$ a set, we define the \emph{power set} $\wp(X)$ by \[\wp(X)=\{Y:Y\subseteq X\}\]

		\item \emph{Examples}.

			\begin{itemize}

				\item $\wp(\emptyset)=\{\alert{\emptyset}\}$

				\item $\wp(\{0\})=\{\alert{\emptyset}, \alert{\{0\}}\}$

				\item $\wp(\{a,b\})=\{\alert{\emptyset}, \{a\}, \{b\},\alert{\{a,b\}}\}$
				\item $\wp(\{a,b,c\})=\{\alert{\emptyset}, \{a\}, \{b\}, \{c\}, \{a,b\}, \{a,c\}, \{b,c\}, \alert{\{a,b,c\}}\}$

				\item \dots

			\end{itemize}

		\item Fact: If $X$ has $n$ members, then $\wp(X)$ has $2^n$ members. (This can be shown by mathematical induction, good exercise!)

	\end{itemize}

\end{frame}

\subsection{3.3 The Axiom of Extensionality}
\begin{frame}{3.3 The Axiom of Extensionality}

	\begin{itemize}

		\item (3.3.1) Sets are individuated by their members:

\begin{description}
	\item[Axiom of Extensionality.] For all sets $X$ and $Y$, $X=Y$ iff $X\subseteq Y$ and $Y\subseteq X$.
\end{description}

	\item \emph{Examples}:

		\begin{itemize}

			\item $\{1,2\}=\{2,1\}$

			\item $\{b,a,a\}=\{a,b\}$

			\item $\{n\in\mathbb{Z}:z\text{ is even}\}=\{n\in\mathbb{Z}:\text{there is a }k\in \mathbb{Z}\text{, s.t. }n=2\cdot k\}$

		\end{itemize}

	\item (3.3.3) Let's say that a set $X$ is \emph{empty} iff for all objects $x$, we have that $x\notin X$. Then we have that for all sets $X$, if $X$ is empty, then $X=\emptyset$.

	\end{itemize}

\end{frame}

\begin{frame}{Proof of 3.3.3}

	\begin{itemize}

		\item We prove this indirectly.

		\item So, suppose that there exists a set $X$ such that $X$ is empty but $X\neq\emptyset$.  Call this set $A$.

		\item It follows that $A\neq \emptyset$, hence either (a) $A\nsubseteq \emptyset$ or (b) $\emptyset\nsubseteq A$.

		\item We've already established that $\emptyset\subseteq X$ for every set $X$, so (b) directly leads to a contradiction.

		\item We focus on case (a): $A\nsubseteq \emptyset$.

		\item If $A\nsubseteq \emptyset$, this means that there exists an object $x$ such that $x\in A$ but $x\notin \emptyset$. Call this object $a$.

		\item We get that $a\in A$. But we've assumed that $A$ is an empty set, meaning that for all $x$, $x\notin A$. So, certainly, $a\notin A$. We've arrived at a contradiction, $a\in A$ and $a\notin A$.

		\item So, in both cases (a) and (b), we get a contradiction.

		\item Hence, for all sets $X$, if $X$ is empty, then $X=\emptyset$.

		\item $\qedsymbol$

		\end{itemize}

\end{frame}

\subsection{3.4 Operations on Sets: Union, Intersection, Difference}
\begin{frame}{3.4 Operations on Sets: Union, Intersection, Difference}

	\begin{itemize}

		\item (3.4.1) The \emph{union} of two sets contains all the objects that are in at least one of the two sets:
		\[X\cup Y=\{x: x\in X\text{ or }x\in Y\}.\]

		\item (3.4.2) The \emph{intersection} of two sets contains all things that are in both sets:
		 \[X\cap Y=\{x:x\in X\text{ and }x\in Y\}.\]

		\item (3.4.5) The \emph{difference} between one set and another are all the elements that are in the one but not the other: \[X\setminus Y=\{x\in X:x\notin Y\}.\]

		\item \emph{Examples}: Let $X=\{a,b\}$ and $Y=\{b,c\}$. Then:

		\begin{itemize}

			\item $X\cup Y=\{a,b,c\}$

			\item $X\cap Y=\{b\}$

			\item $X\setminus Y=\{a\}$

		\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{Draw a Picture --- Venn Diagrams}

\begin{center}
	\begin{tabular}{c c}
		\begin{venndiagram2sets}[labelA=, labelB=, radius=1cm]%
    \fillACapB
    \setpostvennhook
    {
    \draw (labelA) ++(150:4ex) node{$X$};
%      \draw (labelA) ++(-105:8ex) node{$\scriptstyle\bullet$} ++(0,0) node[above]{$n_{i j} $};
    \draw (labelB) ++(20:5ex) node{$Y$};
    \draw (venn bottom right) ++(-2.125,0.3) node{$X\cap Y$};;
        }%
    \end{venndiagram2sets}
     &
 		\begin{venndiagram2sets}[labelA=, labelB=, radius=1cm]%
    \fillA \fillB
    \setpostvennhook
    {
    \draw (labelA) ++(150:4ex) node{$X$};
%      \draw (labelA) ++(-105:8ex) node{$\scriptstyle\bullet$} ++(0,0) node[above]{$n_{i j} $};
    \draw (labelB) ++(20:5ex) node{$Y$};
    \draw (venn bottom right) ++(-2.125,0.3) node{$X\cup Y$};;
        }%
    \end{venndiagram2sets}
    \\
     \begin{venndiagram2sets}[labelA=, labelB=, radius=1cm]%
    \fillOnlyA
    \setpostvennhook
    {
    \draw (labelA) ++(150:4ex) node{$X$};
%      \draw (labelA) ++(-105:8ex) node{$\scriptstyle\bullet$} ++(0,0) node[above]{$n_{i j} $};
    \draw (labelB) ++(20:5ex) node{$Y$};
    \draw (venn bottom right) ++(-2.125,0.3) node{$X\setminus Y$};;
        }%
    \end{venndiagram2sets}
 	\end{tabular}

\textbf{A Venn Diagram is \emph{not} a proof!}

\end{center}

\end{frame}

\begin{frame}{A Proposition}

\begin{itemize}

	\item (3.4.3) For all sets $X$ and $Y$, if $X\cap Y=X$, then $X\subseteq Y$.

	\item \emph{Proof}.
		\begin{itemize}

			\item We use universal generalization and direct proof.

			\item So, let $A$ and $B$ be two sets and suppose that $A\cap B=A$.

			\item We need to show that for each $x$, if $x\in A$, then $x\in B$.

			\item So take an arbitrary object $a$ and suppose that $a\in A$.

			\item Suppose for indirect proof that $a\notin B$.

			\item It's easily seen that $A\cap B=A$.

			\item Since $a\in A$ and $A=A\cap B$, it follows that $a\in A\cap B$.

			\item But if $a\in A\cap B$, then also $a\in B$.

			\item We have arrived at a contradiction, $a\in B$ and $a\notin B$.

			\item Hence $a\in B$ by indirect proof.

			\item  So, if $a\in A$, then $a\in B$, i.e. $A\subseteq B$.

			\item  So, if $A\cap B=A$, then $A\subseteq B$.

			\item $\qedsymbol$

	\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{A Picture}

\begin{center}
 \begin{venndiagram2sets}[labelA=X, labelB=Y, radius=2.5cm, overlap=2cm, labelAB={$X\cap Y=X$}]%
    \fillOnlyA
    \setpostvennhook
    {
%    \draw (labelA) ++(150:4ex) node{$X$};
%%      \draw (labelA) ++(-105:8ex) node{$\scriptstyle\bullet$} ++(0,0) node[above]{$n_{i j} $};
%    \draw (labelB) ++(20:5ex) node{$Y$};
%    \draw (venn bottom right) ++(-2.125,0.3) node{$X\setminus Y$};;
        }%
    \end{venndiagram2sets}

    \textbf{A Venn Diagram is \emph{not} a proof!}

   \end{center}

\end{frame}

\subsection{3.5 Ordered-Pairs and Cartesian Products}
\begin{frame}{3.5 Ordered-Pairs and Cartesian Products}

	\begin{itemize}

		\item (3.5.1) An \emph{ordered pair} is a set-like collection of two objects, except that \emph{order matters}:

			\begin{itemize}

				\item $(a,b)$ is the ordered pair with $a$ in first and $b$ in second place

			\end{itemize}

		\item Note that $(2,1)\neq (1,2)$!

		\item (3.5.2) An \emph{(ordered) $n$-tuple} is a set-like collection of $n$-objects in that order:

		\begin{itemize}

			\item $(a_1, \mathellipsis, a_n)$ is the $n$-tuple with $a_i$ as the $i$-th component (for $1\leq i\leq n$).

		\end{itemize}

		\item Note that $(2,2,1)\neq (2,1)$!

		\item (3.5.4) The \emph{Cartesian product} of $X_1, \mathellipsis, X_n$ is the set of all $n$-tuples whose $i$-th component comes from $X_i$: \[X_1\times \mathellipsis\times X_n=\{(x_1, \mathellipsis, x_n):x_1\in X_1, \mathellipsis, x_n\in X_n\}.\]

		\item \emph{Examples}.

		\begin{itemize}

			\item $\{1,2\}\times \{a,b\}=\{(1,a), (1,b), (2,a), (2,b)\}$

			\item $\{a,b\}\times \{1,2\}=\{(a,1), (a,2), (b,1), (b,2)\}$

			\item $\{1,2\}^2=\{1,2\}\times\{1,2\}=\{(1,1), (1,2), (2,1), (2,2)\}$

		\end{itemize}

	\end{itemize}

\end{frame}

\subsection{3.6 Properties, Relations. and Functions}
\begin{frame}{3.6 Properties, Relations. and Functions}

	\begin{itemize}

		\item (3.6.1) A \emph{property}, $P$, over a set of objects, $X$ is a set of elements of $X$, i.e. $P$ is a property over $X$ iff $P\subseteq X$.

		\item \emph{Example}. The property of being an even natural is $\{n\in\mathbb{N}:\text{there exists a }k\in\mathbb{N}\text{, such that }k\leq n\text{ and }n=2k\}$

		\item (3.6.3) An \emph{$n$-ary relation} over $X$, $R$, is simply a set of $n$-tuples of elements from $X$, i.e. $R\subseteq X^n$.

		\item \emph{Example}. The (binary) relation of smaller than over the reals is $\{(x,y)\in\mathbb{R}^2: x\leq y\}$.

	\end{itemize}

\end{frame}

\begin{frame}{Functions}

\vspace{-2ex}

	\[f(x)=2x^3-4x^2+2x-7\]

	\begin{itemize}

		\item A \emph{function}, $f$, from one set, $X$, to another, $Y$, assigns to each element $a\in X$ a \emph{unique} element $f(a)\in Y$:

		\begin{itemize}

			\item For all $a,b\in X$, if $f(a)\neq f(b)$, then $a\neq b$.

		\end{itemize}

		\item $f(0)=-7, f(1)=-7, f(2)=-3, \mathellipsis$

		\item Terminology:

			\begin{itemize}

				\item $X$ is the \emph{domain} of $f$, $X=dom(f)$

				\item $Y$ is the \emph{range} of $f$, $Y=rg(f)$

			\end{itemize}

		\item To define a function, we need to give a unique output for every input:

\begin{center}

\begin{tabular}{c c c}
  \begin{tikzpicture}[scale=.5,
     >=stealth,
     bullet/.style={
       fill=black,
       circle,
       minimum width=1pt,
       inner sep=1pt
     },
     projection/.style={
       ->,
       thick,
       shorten <=2pt,
       shorten >=2pt
     },
     every fit/.style={
       ellipse,
       draw,
       inner sep=0pt
     }
   ]
     \foreach \y/\l in {1/d,2/c/,3/b,4/a}
       \node[bullet,label=left:$\l$] (a\y) at (0,\y) {};

     \foreach \y/\l in {1/4,2/3,3/2,4/1}
       \node[bullet,label=right:$\l$] (b\y) at (4,\y) {};

     \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=1.5cm] {} ;
     \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=1.5cm] {} ;

     \draw[projection] (a4) -- (b4);
     \draw[projection] (a4) -- (b3);
     \draw[projection] (a2) -- (b3);
     \draw[projection] (a3) -- (b1);
     \draw[projection] (a4) -- (b3);
     \draw[projection] (a1) -- (b2);
   \end{tikzpicture}
   &
   \quad
   &
    \begin{tikzpicture}[scale=.5,
     >=stealth,
     bullet/.style={
       fill=black,
       circle,
       minimum width=1pt,
       inner sep=1pt
     },
     projection/.style={
       ->,
       thick,
       shorten <=2pt,
       shorten >=2pt
     },
     every fit/.style={
       ellipse,
       draw,
       inner sep=0pt
     }
   ]
     \foreach \y/\l in {1/d,2/c/,3/b,4/a}
       \node[bullet,label=left:$\l$] (a\y) at (0,\y) {};

     \foreach \y/\l in {1/4,2/3,3/2,4/1}
       \node[bullet,label=right:$\l$] (b\y) at (4,\y) {};

     \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=1.5cm] {} ;
     \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=1.5cm] {} ;

     \draw[projection] (a4) -- (b4);
     \draw[projection] (a2) -- (b1);
     \draw[projection] (a3) -- (b1);
   \end{tikzpicture}

   \\

   More than one value for $a$ & & No value for $d$

   \end{tabular}
  \end{center}

	\end{itemize}

\end{frame}

\begin{frame}{A Function?}

	\begin{center}
	\begin{tikzpicture}[scale=1,
     >=stealth,
     bullet/.style={
       fill=black,
       circle,
       minimum width=1pt,
       inner sep=1pt
     },
     projection/.style={
       ->,
       thick,
       shorten <=2pt,
       shorten >=2pt
     },
     every fit/.style={
       ellipse,
       draw,
       inner sep=0pt
     }
   ]
     \foreach \y/\l in {1/1,2/2/,3/3,4/4}
       \node[bullet,label=left:$\l$] (a\y) at (0,\y) {};

     \foreach \y/\l in {1/4,2/3,3/2,4/1}
       \node[bullet,label=right:$\l$] (b\y) at (4,\y) {};

     \node[draw,fit=(a1) (a2) (a3) (a4),minimum width=1.5cm] {} ;
     \node[draw,fit=(b1) (b2) (b3) (b4),minimum width=1.5cm] {} ;

     \draw[projection] (a4) -- (b1);
     \draw[projection] (a3) -- (b2);
     \draw[projection] (a2) -- (b3);
     \draw[projection] (a1) -- (b4);
   \end{tikzpicture}

      \onslide<2>{$f:\{1,2,3,4\}\to\{1,2,3,4\}$, $f(x)=x$}

   \end{center}

\end{frame}

\begin{frame}{Binary Functions}

	\begin{itemize}

		\item A special case, we'll often encounter are functions where $dom(f)=X^2$ for some set $X$.

		\item \emph{Example} $f:\{a,b,c\}^2\to \{0,1\}$ defined by:

		\begin{center}
	\begin{tabular}{c c c c c c c c c c c}
	$(a,a)$ & $\overset{f}{\mapsto}$ & 0 & \quad & (b,a) & $\overset{f}{\mapsto}$ & 0  \quad & (c,a) & $\overset{f}{\mapsto}$ & 1\\

	$(a,b)$ & $\overset{f}{\mapsto}$ & 1 & \quad & (b,b) & $\overset{f}{\mapsto}$ & 0  \quad & (c,b) & $\overset{f}{\mapsto}$ & 1\\

	$(a,c)$ & $\overset{f}{\mapsto}$ & 1 & \quad & (b,c) & $\overset{f}{\mapsto}$ & 1  \quad & (c,c) & $\overset{f}{\mapsto}$ & 0\\

	\end{tabular}
\end{center}

	\item This assignment can be given in table form:

\begin{center}
	\begin{tabular}{ c | c c c}
	$f$ & $a$ & $b$ & $c$ \\ \hline

	$a$ & 0 & 1 & 1\\

	$b$ & 0 & 0 & 1\\

	$c$ & 1 & 1 & 0

	\end{tabular}

\end{center}

	\end{itemize}

\end{frame}

\subsection{3.7 Inductive Definitions and Proof by Induction}
\begin{frame}{3.7 Inductive Definitions and Proof by Induction}

	\begin{itemize}

		\item How can we ``properly'' define $\mathbb{N}$?

		\item (3.7.1) We want to say that $\mathbb{N}$ is ``the set of 0 and all its successors.''

		\item Idea:

		\begin{itemize}

			\item $0\in\mathbb{N}$

			\item For all $n$, if $n\in\mathbb{N}$, then $n+1\in\mathbb{N}$

			\item ``Nothing else is in $\mathbb{N}$.

		\end{itemize}

		\item In this way we can easily show that $3\in\mathbb{N}$, since:

		\begin{itemize}

			\item $0\in\mathbb{N}$

			\item $1=0+1$, so $1\in\mathbb{N}$
			\item $2=1+1$, so $2\in\mathbb{N}$
			\item $3=2+1$, so $3\in\mathbb{N}$

		\end{itemize}

		\item To show that $\frac{1}{2}\notin \mathbb{N}$, we'd need to show that there exists no $n\in\mathbb{N}$ such that $n+1=\frac{1}{2}$.

		\item (3.7.3) That's tricky! $\frac{1}{2}\notin \mathbb{N}\Rightarrow -\frac{1}{2}\notin\mathbb{N}\Rightarrow -\frac{3}{2}\notin\mathbb{N}\Rightarrow\mathellipsis.$

	\end{itemize}

\end{frame}

\begin{frame}{A Proper Definition of $\mathbb{N}$}

	\begin{itemize}

		\item What does it mean that ``nothing else is a member of $\mathbb{N}$''?

		\item (3.7.7) We say that one set $X$ is \emph{smaller than} a set $Y$ iff $X\subseteq Y$.

		\item $\mathbb{N}$ is the smallest set such that:

		\begin{enumerate}[(i)]

		\item $0\in X$

		\item For all numbers $x$, if $x\in X$, then $x+1\in X$.

	\end{enumerate}

		\item (3.7.8) With this official definition, we can prove that $\frac{1}{2}\notin \mathbb{N}$.

		\item \emph{Proof} (Sketch). Suppose that $X$ satisfies (i) and (ii) and $\frac{1}{2}\in X$. Then $Y=X\setminus \{\frac{k}{2}: k\in \mathbb{Z}\text{ and }k\text{ is odd}\}$ also satisfies (i) and (ii) and is smaller than $X$. So $X$ cannot be $\mathbb{N}$. Hence if $\frac{1}{2}\in\mathbb{N}$, then $\mathbb{N}\neq\mathbb{N}$. Contradiction. So $\frac{1}{2}\notin\mathbb{N}$. $\qedsymbol$

	\end{itemize}

\end{frame}

\begin{frame}{Function Recursion (3.7.3)}

	\begin{itemize}

		\item We can use function recursion on $\mathbb{N}$:

		\item \emph{Example}. We define $f:\mathbb{N}^2\to\mathbb{N}$ as follows
	\begin{enumerate}[(i)]

		\item For every number $n\in\mathbb{N}$, $f(n, 0)=0$.

		\item For all numbers $n,m\in\mathbb{N}$, $f(n,m+1)=f(n,m)+n$.

	\end{enumerate}

	\item Since the numbers are $0$ and all its successors, this gives us a value for each $n$.

	\item \emph{Example}: $f(3,2)=\dots$

	\begin{itemize}

		\item $f(3,1+1)=f(3, 1)+3$

		\item $f(3,1)=f(3,0+1)=f(3,0)+3$ and $f(3, 0)=0$

		\item $f(3,1)+3=f(3,0+1)+3=(f(3, 0)+3)+3=(0+3)+3=6$.

	\end{itemize}

	\end{itemize}

	\begin{center}
		\begin{tabular}{c}
		\includegraphics[width=15ex]{xkcd-recursion}\\[-1ex]
		{\tiny \textcopyright~\url{https://xkcd.com/244/}, CC BY-NC 2.5}
		\end{tabular}
		\end{center}

\end{frame}

\begin{frame}{Proof by Induction (3.7.4)}

	\begin{itemize}

		\item For every inductively defined set, we can prove things about its members via \emph{proof by induction}:

		\begin{itemize}

			\item (3.7.9) \textbf{Theorem}. Suppose that $\Phi$ is a condition on numbers such that:
		\begin{enumerate}[(i)]

			\item $\Phi(0)$ (`base case')

			\item for all natural numbers $n\in\mathbb{N}$, if $\Phi(n)$, then $\Phi(n+1)$. (`induction step')

		\end{enumerate}

		\item \emph{Proof}. Let $\Phi$ be an arbitrary condition on numbers satisfying conditions (i) and (ii), Consider the set $\{x:\Phi(x)\}$. By the conditions (i) and (ii) of our theorem, $\{x:\Phi(x)\}$ satisfies conditions (i) and (ii) from the definition of $\mathbb{N}$. Since $\mathbb{N}$ is the smallest set satisfying those conditions, we have that $\mathbb{N}\subseteq\{x:\Phi(x)\}$. But now, it easily follows that for all $n\in\mathbb{N}$, we have that $\Phi(n)$. For let $n\in\mathbb{N}$ be an arbitrary number. Since $\mathbb{N}\subseteq\{x:\Phi(x)\}$, it follows that $n\in\{x:\Phi(x)\}$. But that just means that $\Phi(n)$, as desired.

		\end{itemize}

		\item It's a kind of ``domino principle.''

	\end{itemize}

\end{frame}

\begin{frame}{Proof by Induction --- Example (3.7.5)}

Let $f:\mathbb{N}^2\to\mathbb{N}$ be defined by  follows
	\begin{enumerate}[(i)]

		\item For every number $n\in\mathbb{N}$, $f(n, 0)=0$.

		\item For all numbers $n,m\in\mathbb{N}$, $f(n,m+1)=f(n,m)+n$.

	\end{enumerate}
Then for all $n,m\in\mathbb{N}$, $f(n,m)=n\cdot m$.

\emph{Proof}:

\begin{itemize}

	\item \emph{Base case}: By (i), $f(n,0)=0$. Since $n\cdot 0=0$ for all $n\in\mathbb{N}$, the claim holds.

	\item \emph{Induction Step}: Let $n,m\in\mathbb{N}$ be arbitrary numbers and assume that $f(n,m)=n\cdot m$ (`induction hypothesis'). We know that $f(n,m+1)=f(n,m)+n$. By the induction hypothesis, we get {\small\[f(n,m+1)=f(n,m)+n=(n\cdot m)+n=n\cdot (m+1),\]} which is what we needed to show.

\end{itemize}
\end{frame}

\begin{frame}{Inductive Definitions Generalized}

	\begin{itemize}

		\item (3.7.10) In order to inductively define a set:

		\begin{enumerate}[1.]

		\item We give a set of initial elements.

		\item We provide a list of \emph{constructions} that allow us to form new elements from old elements.

		\item We define our set as the smallest set that contains all the initial elements and that is \emph{closed under} the constructions.

	\end{enumerate}

		\item \emph{Example}. $Gargle$ is now defined as the smallest set $X$ such that:

			\begin{enumerate}[(i)]

				\item $\{\clubsuit,\spadesuit\}\subseteq X$.

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

					\item For all $x$, if $x\in X$, then $\diamondsuit x\diamondsuit\in X$.

					\item For all $x$, if $x,y\in X$, then $ x\heartsuit y\in X$.

				\end{enumerate}

			\end{enumerate}

		\item We get:

		\begin{itemize}

					\item $\clubsuit,\spadesuit\in Gargle$

					\item $\diamondsuit\clubsuit\diamondsuit,\diamondsuit\spadesuit\diamondsuit\in Gargle$

					\item $\clubsuit\heartsuit\clubsuit, \clubsuit\heartsuit\spadesuit, \spadesuit\heartsuit\spadesuit\in Gargle$

					\item $\clubsuit\heartsuit\diamondsuit\clubsuit\diamondsuit, \diamondsuit\spadesuit\diamondsuit\heartsuit\spadesuit,\mathellipsis\in Gargle$

				\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{Function Recursion Generalized}

	\begin{itemize}

		\item (3.7.12) To recursively define a function on an inductively defined set:
		\begin{enumerate}[1.]

			\item We say what the value of our function is on the initial elements.

			\item We say how to calculate the value of the function for an element built by a construction, where we can reference to the values of the function for the elements the element is constructed from.

		\end{enumerate}

	\item (3.7.13) \emph{Example}: The function $\#_\spadesuit:Gargle\to\mathbb{N}$ is defined by the following recursion:

	\begin{enumerate}[(i)]

			\item $\#_\spadesuit(x)=\begin{cases} 1 & \text{if }x=\spadesuit
			\\0 &\text{if }x=\clubsuit\end{cases}$

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

					\item  $\#_\spadesuit( \diamondsuit x\diamondsuit)=\#_\spadesuit(x)$

					\item $\#_\spadesuit(x\heartsuit y)=\#_\spadesuit(x)+\#_\spadesuit(y)$
		\end{enumerate}

	\end{enumerate}

	\item We get, for example:{\small\[\#_\spadesuit(\spadesuit\heartsuit\diamondsuit\spadesuit\diamondsuit)=\#_\spadesuit(\spadesuit)+\#_\spadesuit(\diamondsuit\spadesuit\diamondsuit)=\#_\spadesuit(\spadesuit)+\#_\spadesuit(\spadesuit)=1+1=2.\]}

	\end{itemize}

\end{frame}

\begin{frame}{An Issue with Gargles}

	\begin{itemize}

		\item The gargle $\spadesuit\heartsuit\clubsuit\heartsuit\spadesuit$ can constructed in two ways:
		\begin{itemize}

			\item Since $\spadesuit,\clubsuit\in Gargle$, we know that $\clubsuit\heartsuit\spadesuit\in Gargle$. Since $\spadesuit\in Gargle$ and $\clubsuit\heartsuit\spadesuit\in Gargle$, we have $\spadesuit\heartsuit\clubsuit\heartsuit\spadesuit\in Gargle$

			\item Since $\clubsuit,\spadesuit\in Gargle$, we know that $\spadesuit\heartsuit\clubsuit\in Gargle$. Since $\spadesuit\in Gargle$ and $\spadesuit\heartsuit\clubsuit\in Gargle$, we have $\spadesuit\heartsuit\clubsuit\heartsuit\spadesuit\in Gargle$

		\end{itemize}

		\item This means that function recursion on gargles doesn't automatically work:

		\begin{enumerate}[(i)]

			\item $f(\spadesuit)=1$ and $f(\clubsuit)=0$

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

				\item $f(\diamondsuit x\diamondsuit)=f(x)$

				\item $f(x\heartsuit y)=\begin{cases}
			1 & \text{if }f(x)=1\text{ and }f(y)=0\\
			0 &\text{ otherwise}
			\end{cases}$

			\end{enumerate}

		\end{enumerate}

		\item We get:

		\begin{itemize}

			\item $f(\spadesuit\heartsuit\clubsuit\heartsuit\spadesuit)=1$

			\item $f(\spadesuit\heartsuit\clubsuit\heartsuit\spadesuit)=0$

		\end{itemize}

		\item \frownie

		\item We want \emph{unique readability}!

	\end{itemize}

\end{frame}

\begin{frame}{Inductive Proofs Generalized}

	\begin{itemize}

		\item To prove that all elements of an inductively defined set have satisfy a condition, we show:

		\begin{enumerate}[1.]

			\item All the initial elements satisfy the condition. (`base case')

			\item A newly constructed element satisfies the condition, whenever the elements that it's constructed from does. (`induction steps')

		\end{enumerate}

		\item \emph{Example}: Suppose that $\Phi$ is a condition on gargles. If we can show:
			\begin{enumerate}

				\item $\Phi(\clubsuit),$ and $\Phi(\spadesuit)$

				\item \begin{enumerate}\item For all gargles $x\in Gargle$, if $\Phi(x)$, then $\Phi(\diamondsuit x\diamondsuit)$.

					\item  For all gargles $x,y\in Gargle$, if $\Phi(x)$ and $\Phi(y)$, then $\Phi(x\heartsuit y)$

					\end{enumerate}
			\end{enumerate}
			Then for all gargles $x\in Gargle,$ $\Phi(x)$.

	\end{itemize}

\end{frame}

\begin{frame}{Example}

	\begin{itemize}

		\item \textbf{Proposition}. Each gargle contains at least one of $\spadesuit,\clubsuit$.

		\item \emph{Proof}.

			\begin{itemize}

				\item We prove this by induction over gargles.

				\item \emph{Base case}. There are two initial elements, $\spadesuit,\clubsuit$, each of which contains at least one of $\spadesuit,\clubsuit$.

				\item \emph{Induction Steps}. \begin{itemize}

					\item Suppose that $x$ contains at least one of $\spadesuit,\clubsuit$ (`induction hypothesis'). Consider $\diamondsuit x \diamondsuit$. Since by the induction hypothesis, $x$ contains one of $\spadesuit,\clubsuit$, and $\diamondsuit x \diamondsuit$ contains $x$, also $\diamondsuit x \diamondsuit$ contains at least one of $\spadesuit,\clubsuit$.

					\item Suppose that  both $x$ and $y$ contain at least one of $\spadesuit,\clubsuit$ (`induction hypothesis'). Consider $ x \heartsuit y$. Since by the induction hypothesis, $x$ contains one of $\spadesuit,\clubsuit$, and $x \heartsuit y$ contains $x$, also $x \heartsuit y$ contains at least one of $\spadesuit,\clubsuit$.

				\end{itemize}

				\item By the principle of induction over the gargles, we can conclude that all gargles contain at least one of $\spadesuit,\clubsuit$.

			\end{itemize}

	\end{itemize}

\end{frame}

\begin{frame}{How to Write (Generalized) Inductive Proofs}

	\begin{enumerate}[1.]

			\item State clearly that you're using induction to prove the claim.

			\item Prove the base case.

			\item State clearly that you're now considering the induction steps. In each sub-case, begin by stating your induction hypothesis and then use it to derive the claim about the constructed element.

			\item State clearly that you're using induction to infer that the claim in question holds for all elements of the set.

		\end{enumerate}

\end{frame}

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

\begin{itemize}

		\item A set is a collection of objects, its elements.

		\item One set is a subset of another just in case all the elements of the one set are elements of the other.

		\item Two sets are identical iff they have precisely the same elements.

		\item The union of two sets contains any element of either set, their intersection contains only the objects that are in both sets. The difference of one set and another contains all the elements of the one but not the other.

		\item An ordered tuple is a a set-like collection of objects with a specific order. In tuples, order and multiplicity count.

		\item The Cartesian product of two sets contains all the tuples formed from those sets.

		\end{itemize}

	\end{frame}

\begin{frame}{Core Ideas (Lecture Version, Cont'd)}

\begin{itemize}

		\item A property is a set of objects. An $n$-ary relation is a set of $n$-tuples.

		\item A function assigns to each input a \emph{unique} output.

		\item To inductively define a set, we give a set of initial elements and a set of constructions for new elements.

		\item To recursively define a function, we give the value of the function for the initial elements and say how to calculate the value of a newly constructed element based on the values of the elements its constructed from.

		\item To prove a claim by induction over an inductively defined set, we show that all initial element satisfy the claim and that every newly constructed element satisfies the claim whenever the elements that it's constructed from do.

	\end{itemize}

\end{frame}

\begin{frame}

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

\end{frame}


\label{ch:six}
Towards the end of the project we decided to implement a python module to do testing and analysis on some candidate probability distributions. The motivation for this was given mainly by the results showed again in \cite{RW03}.
\section{Analysis design and goals}
    To visualize and motivate the scope of this analysis we expand Eq. \ref{eq:bounds} as follow
    \begin{equation}
    	\keyrate{X}{Y}{Z} \leq \redintrinfo{X}{Y}{Z} \leq \intrinfo{X}{Y}{Z} \leq I_{form} (X;Y|Z)
    \end{equation}
    including also the information of formation.
    As mentioned before, obtaining a value for the secret-key rate and information of formation --- the fundamental quantities for key agreement --- requires a \textit{possible} protocol.
    For their bounds (i.e. the central parts of the inequality) we can obtain direct numerical values from the probability distribution alone.
    The aim of this part of the project is then to take a candidate as given in Fig. \ref{Tab:candidate2} and trace the values of the reduced and normal intrinsic information for  variation of the probability distribution.\\

    A good result we hope to obtain is a probability distribution for which the reduced measure tends to $0$, while the intrinsic information remains larger than $0$, bounding also the information of formation to be greater than $0$.
    Due to the tightness of the bounds, this will constrain the value for the secret key rate down to (possibly) $0$, while keeping a non-zero key cost ($I_{\text{form}}$).
    This will lead to a new candidate for bound information.\\

    In order to perform analysis on those measures we firstly had to implement a library of modules that dealt with the probability and information theory aspects.
    Following criteria for separability of quantum states, a quantum mechanics module was also implemented to translate and later tests the distributions from the quantum to classical regime.
    The intrinsic information (and its reduced counterpart) is defined as an \emph{infimum} over the set of tripartite probability distributions.
    To find a correct value it would require to solve an optimization problem.
    The definition given in section \ref{intrininfo} however does not allow us to formulate the problem as convex, or, at least, not a trivial one, since the mutual information is only convex for a fixed term.
    We decided then to adopt a Monte-Carlo method to estimate them.

    For each step --- i.e. for each variation --- of the candidate base probability, the values of
    \begin{itemize}
    	\item	mutual information
    	\item	intrinsic information
    	\item	reduced intrinsic information
    	\item	trace over quantum state witness given in \cite{DPS04}
    \end{itemize}
    are estimated.
\section{Different noises analysis}

	\begin{figure}[h!]
		\centering
		\includegraphics[scale=0.5]{images/analysis-path}
		\caption{From the set $S$ of tripartite distributions we create a "path"
towards distributions with zero key cost (cyan), going through the ones without extractable key (magenta). The distributions that holds bound information reside in the cyan$\setminus$magenta part.}
		\label{Fig:analysis-path}
	\end{figure}
	The variations of the distribution mentioned above are linear steps toward a noise distribution we define.
	The first and obvious noise function we tested is the uniform distribution, which acts on all values of $P_{XYZ}$.
	Following the idea of the candidate distribution showed in Fig. \ref{Tab:candidate2} we  also utilized a noise function that operates on the non-correlated part for Alice and Bob.

	This method of simulating noise added to a known distribution takes also inspiration from the quantum world.
	A method to look for bound entangled states applies a noise channel to a known entangled state and then the new state is tested on different separability criteria.
	The intuition comes from the respectively enclosed convex sets of separable states.

	\begin{figure}
		\begin{subfigure}{0.5\textwidth}
			\input{images/noise1}
			\subcaption{Noise1}
			\label{Fig:noise1}
		\end{subfigure}
		\begin{subfigure}{0.5\textwidth}
			\input{images/noise2}
			\subcaption{Noise2}
			\label{Fig:noise2}
		\end{subfigure}
		\caption{Different noises disturbs different parts of the correlation between $X$ and $Y$}
		\label{Fig:noises}
	\end{figure}

\section{The problem with the reduced intrinsic information}\label{problem}
    During the implementation of the module we were confronted with some issues on the measure of the reduced intrinsic information.
    Recalling Eq. \ref{eq:reducedintrinfo}, we first generate random channels $XYZ \rightarrow U$ to get the conditional probability $P_{U|XYZ}$.
%    In some cases, also a channel $X\rightarrow U$, or $XY \rightarrow U$ can be used.
    Then the intrinsic information is minimized over all possible channels $ZU \rightarrow \bar{ZU}$.
    Ideally, we want to show how the reduced intrinsic information goes to $0$, so that the secret key rate also falls to $0$.
    Thus, $\Ent (U)$ is a lower bound on the value of the reduced intrinsic information.
    In order to minimize this lower bound, the marginal $P_U$ should be deterministic and thus $\Ent(U) = 0$.
    However for the other term $\intrinfo{X}{Y}{ZU}$ a deterministic $U$ will result in having the intrinsic information.
    Intuitively, minimizing on $\Ent(U)$ increases the value of $\intrinfo{X}{Y}{ZU}$ and vice versa.

    Observing this, we questioned the usefulness of the reduced intrinsic information as a measure to demonstrate the existence of bound information, contrary to we thought at the beginning.

\section{Results}
Despite the difficulties encountered in implementing the code, we were able to produce some marginal results.
When the noise functions were applied to the marginal $P_{XYZ}$ of the distribution in Fig. \ref{Tab:candidate} we were able to make the following observations
\begin{itemize}
\item For the uniform noise, as expected, the behavior presents no intrinsic information nor reduced intrinsic information. The two measures remain the same until around $\alpha = 1- 1/8 = 0.875$. Around that point the reduced intrinsic information of the behavior \textit{decreases} until reaching $1$, as we already knew from \cite{RW03}.

\item For the noise in Fig. \ref{Fig:noise1}, we notice first of all that the intrinsic information is not monotonic along the path. It takes the form of a convex function with minimum for an $\alpha$ around $0.4$. At both ends of the path the two measures diverge resulting in $\intrinfo{X}{Y}{Z} \approx 1$ and $\redintrinfo{X}{Y}{Z} \approx 0.5$ for $\alpha = 0$, i.e. for just the noise function represented in the figure. On the other end we obtain again the results as before for the marginal of the candidate.

\item Finally for the noise function in fig. \ref{Fig:noise2} we observe the same general behavior as before.
The observable minimum is around values $\alpha = 0.2$ and for just the noise function the reduced intrinsic information falls to about $\redintrinfo{X}{Y}{Z} \approx 0.125$ and $\intrinfo{X}{Y}{Z} \approx 0.25$.
\end{itemize}

\begin{figure}[h!]
		\begin{subfigure}{0.5\textwidth}
			\includegraphics[scale=0.3]{images/graphs/uniform_FourPDstr_100.pdf}
			\subcaption{Uniform noise}
		\end{subfigure}
		\begin{subfigure}{0.5\textwidth}
			\includegraphics[scale=0.3]{images/graphs/noise1_FourPDstr_100.pdf}
			\subcaption{Noise$1$}
		\end{subfigure}\\[1ex]
		\begin{subfigure}{\linewidth}
			\centering
			\includegraphics[scale=0.3]{images/graphs/noise2_FourPDstr_100.pdf}
			\subcaption{Noise$2$}
		\end{subfigure}
		\caption{Results obtained from the application of the different noise functions of Fig. \ref{Fig:noises}, applied to the marginal of Fig. \ref{Tab:candidate}. Each test is conducted over 100 steps between the two behaviors}
\end{figure}


%
% API Documentation for Peach - Computational Intelligence for Python
% Package peach.fuzzy
%
% Generated by epydoc 3.0beta1
% [Mon Dec 21 08:51:35 2009]
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                          Module Description                           %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}|(}
\section{Package peach.fuzzy}

    \label{peach:fuzzy}

This package implements fuzzy logic. Consult:
\begin{quote}
\begin{description}
%[visit_definition_list_item]
\item[{fuzzy}] %[visit_definition]

Basic definitions, classes and operations in fuzzy logic;

%[depart_definition]
%[depart_definition_list_item]
%[visit_definition_list_item]
\item[{mf}] %[visit_definition]

Membership functions;

%[depart_definition]
%[depart_definition_list_item]
%[visit_definition_list_item]
\item[{defuzzy}] %[visit_definition]

Defuzzification methods;

%[depart_definition]
%[depart_definition_list_item]
%[visit_definition_list_item]
\item[{control}] %[visit_definition]

Fuzzy controllers (FIS - Fuzzy Inference Systems), for Mamdani- and
Sugeno-type controllers and others;

%[depart_definition]
%[depart_definition_list_item]
\end{description}
\end{quote}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                Modules                                %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Modules}

\begin{itemize}
\setlength{\parskip}{0ex}
\item \textbf{control}:
This package implements fuzzy controllers, of fuzzy inference systems.

  \textit{(Section \ref{peach:fuzzy:control}, p.~\pageref{peach:fuzzy:control})}

\item \textbf{defuzzy}:
This package implements defuzzification methods for use with fuzzy controllers.

  \textit{(Section \ref{peach:fuzzy:defuzzy}, p.~\pageref{peach:fuzzy:defuzzy})}

\item \textbf{fuzzy}:
This package implements basic definitions for fuzzy logic

  \textit{(Section \ref{peach:fuzzy:fuzzy}, p.~\pageref{peach:fuzzy:fuzzy})}

\item \textbf{mf}:
Membership functions

  \textit{(Section \ref{peach:fuzzy:mf}, p.~\pageref{peach:fuzzy:mf})}

\item \textbf{norms}:
This package implements operations of fuzzy logic.

  \textit{(Section \ref{peach:fuzzy:norms}, p.~\pageref{peach:fuzzy:norms})}

\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                               Variables                               %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  \subsection{Variables}

\begin{longtable}{|p{.30\textwidth}|p{.62\textwidth}|l}
\cline{1-2}
\cline{1-2} \centering \textbf{Name} & \centering \textbf{Description}& \\
\cline{1-2}
\endhead\cline{1-2}\multicolumn{3}{r}{\small\textit{continued on next page}}\\\endfoot\cline{1-2}
\endlastfoot\raggedright \_\-\_\-d\-o\-c\-\_\-\_\- & \raggedright \textbf{Value:}
{\tt \texttt{...}}&\\
\cline{1-2}
\end{longtable}

    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}|)}


\chapter{The Straight Line}

\section{Angles}
\begin{enumerate}
	\item[20.] Inkscape vector image:

	\includegraphics[scale=0.6]{chapters/ch01/images/20}

	\item[21.] If the interior of the angle is smaller than the exterior then a congruent angle can be drawn inside the exterior without any overlap.

	It can't be done for interior.

	\item[22.] Two distinct angles can have two common sides: \textit{AOB (smaller)} and \textit{AOB (bigger)}

	\includegraphics[scale=0.6]{chapters/ch01/images/22}

	\item[23.] No

	\item[24.] Yes, arcs can have different radius but same center.

	No, one arc is smaller than the other.

%25:
	\item[25.] Figure:

	\includegraphics[scale=0.8]{chapters/ch01/images/25}

	Since $CD$ is a straight line, we know from \S16.1:

	$\angle DOC = \angle DOA + \angle AOC = \ang{180}$

	$\Rightarrow \angle AOC = \ang{180} - \ang{25} = \ang{155}$

	We also know that:

	$\angle AOB = \angle AOD + \angle DOB = \ang{180}$

	$\Rightarrow \angle BOD = \ang{180} - \ang{25} = \ang{155}$

	Finally we get:

	$\angle BOC = \ang{108} - \ang{155} = \ang{25}$.

	\item[26.] \ang{25}, \ang{55}, \ang{100}, \ang{100}

	\item[27.] $19*19=361$, it's easy to show...

\end{enumerate}

\section{Perpendicular Lines}
\begin{enumerate}
	\item[28.] $\ang{14;24;44} + \ang{75;35;25} = \ang{90;0;9}$. Hence it is obtuse.

	\item[29.] $\times\times\times$ Confusing question $\times\times\times$

	\item[30.]
\end{enumerate}

books/[On going] Geometry, Book I - Planimetry (Kiselev)/solutions/chapters/ch01/ch01.tex


\subsection{Stationary points and first-order conditions}


%##########################################
\section{Broadband Power Transfer Networks}
\label{sec_wurc_pa_design}

%\rgnote{This is a brief of the content that will be presented here--I have models, simulations, and a discussion of the new design approach (and why alternative methods don't work). This is a contribution that first formulates a numerical optimization framework for wideband matching building on Yarman's real frequency techniques, and then solves it to produce a seed mathching circuit design. We show that although Yarman leaves off here, that is not sufficient to realize a practical solution and that additional parasitic models and empirical design techniques must be used to bring the design to realization. I'm cleaning up the plots and code to expand this section right now.}

	In order to operate as an opportunistic transmitter in the UHF band and adapt to various channel bandwidths, spectrum availability, and regulatory domains across the world, \ac{WURC} is designed to operate at arbitrary channel bandwidths from 1.5 - 28~MHz with center frequencies ranging from 470 - 700~MHz on its 75~$\Omega$ UHF antenna ports, and 2400 - 2500~MHz on its 50~$\Omega$ ISM antenna ports.

	We target a design goal of radio output power up to 30~dBm from 470 to 700~MHz, the maximum conducted power to the antenna currently allowed by the \ac{FCC} in the United States for unlicensed operation within a single 6~MHz UHF channel \cite{flores2013ieee80211af}.\footnote{The 30~dBm limit is measured at the input RF connector to the antenna. \ac{FCC} regulation allows up to 36~dB \ac{EIRP} when including passive antenna gain. With antenna gain greater than 6~dB, the conducted power limit is decreased by 1~dB for each 1~dB of additional antenna gain in order to maintain a 36~dBm \ac{EIRP} maximum per 6~MHz channel. When channels are bonded, the total power budget for all channels is increased according to the total number of bonded channels \cite{fcc2015ro}.}
	The 2.4~GHz ISM transmit chain provides up to 27~dBm between 2400 - 2500~MHz.
	%The wide UHF frequency range presents a challenge for a high-power RF design since power amplifiers and their associated impedance matching networks are generally optimized for a narrow frequency band.

	By targeting nominal operation between 470 - 700~MHz, the \ac{WURC} analog front end utilizes a passband that is approximately $\frac{2\cdot(700-470)}{700+470}\cdot 100\% = 39.3\%$ wide, which is a significant design challenge.
	Intuitively, the wide 160~MHz channels for 802.11ac or 2.16~GHz for 802.11ad standards seem large, but they only represent a percent bandwidth of 3.1\% and 3.6\%, respectively, making their power transfer networks more simple.\footnote{Accurate physical modeling and parasitics are more of a concern at 5.8 and 60~GHz than is achieving a wide bandwidth power transfer match.}
	The efficiency of a \emph{passive} power transfer network will fundamentally trade off with the operational bandwidth of that network, as first proved by Fano for a simple RC capacitive load \cite{fano1950theoretical}.
	Fano's fundamental limit motivates the need to optimize the efficiency of the passive transfer network that delivers power to the various amplification stages of \ac{WURC}.
	As we will show, this process is non-trivial and requires multiple iterations utilizing various design techniques.

	In this section, we will first utilize real frequency techniques to construct an optimization problem and numerically solve for an ideal solution for the passive broadband power transfer network design.
	We will then show that this solution is inadequate to actually realize in a passive lumped element circuit, which will require us to develop empirical models of our circuit elements and layout to accurately capture parasitic circuit elements.
	This will finally allow us to synthesize a physical circuit realization that meets design goals.
	The circuit is manufactured, tested, and validated with consistent results that eventually match simulated results.

%%##################################################
%\subsection{Power Transfer Network Synthesis}
%\label{sec_match_synthesis}
%
%\rgnote{content snipped from paper follows, FIXME}
%
%
%A common technique for designing high-power analog front-ends is to build multiple switched amplification and filtering chains, each optimized for a narrow band.
%However, when the system operating frequency range spans multiple octaves, space and cost constraints require that each chain support a wide range of frequencies.
%In the design of \ac{WURC}, we target two optimized transmit and receive chains for 470-698~MHz and 2400-2500~MHz, chosen because these two bands allow unlicensed operation and are invaluable for research and testing.
%
%
%
%Since the bandwidth of an RF chain is generally proportional to $\Delta f/f$, common techniques for designing and implementing discrete power transfer networks (e.g., multi-section Chebyshev transformers \cite{grebennikov2005rf}) either cannot meet design requirements for passband flatness or result in non-realizable circuits when applied to bandpass designs spanning a large frequency range like 470-698 MHz.

% ###################################
\subsection{Real Frequency Technique for Initial Circuit Synthesis}
\label{sec_dual_match}

%\rgnote{State the GEL dual matching problem here.}
%
%\begin{figure}[h]
%\centering
  %\includegraphics[width=0.67\linewidth]{figs/matching/matching_gel}
    %\caption{Block diagram of dual matching problem with Darlington source and load representations.}
%\label{fig_matching_gel}
%\end{figure}

 	Several traditional analog design techniques can be used to design a passive matching network for amplifier circuits, such as an analytical conjugate match \cite{orfanidis2002electromagnetic} \S13, the direct design approach using the Smith Chart \cite{grebennikov2005rf} \S3.3, or prototype filter design \cite{grebennikov2005rf} \S10.7.
	However, in the case that the desired passive matching network must match a complex real-world device over a large bandwidth, then these traditional design techniques become ``inaccessible'' \cite{yarman2010design, chen2015broadband}.
	Specifically, analytical and direct design techniques can yield physically feasible results for narrowband matches but produce negative-valued resistances, require the use of ideal transformers, or require very high-order circuits with a large number of components for wideband matches.
	Unfortunately, while useful for developing circuit theory, each of these outcomes is either not possible or extremely impractical to actually implement with a passive physical circuit.

	Instead, we utilize the real frequency matching technique proposed and developed by Carlin and Yarmin \cite{carlin1977new, carlin1983double, yarman1982simplified} which utilizes numerical methods to solve for a piecewise approximation to the reflection coefficient of the optimal matching network.
	The entire set of matching network S-parameters are determined from a series of identities and Belevitch factorizations of the single reflection coefficient \cite{yarman1982simplified}.
	Finally, an LC-ladder circuit can be realized with a simple lumped element passive circuit using long division(\cite{yarman2010design} \S9.7).
	We repeat this optimization for both the input and the output matching network for each amplifier component separately rather than using the cascaded gain stage approach proposed by Yarmin \cite{carlin1983double} for practical reasons: we find that physical circuit layout is improved when each amplifier component is individually matched to the system characteristic impedance rather than to each other, allowing arbitrary placement of the components.

% ######################
\subsubsection{Broadband Matching Problem Statement}
\label{sec_srft_problem_statement}

	Our objective is to maximize the \ac{TPG} of our chosen broadband amplifiers across the target band of operation utilizing only passive, lumped-element power transfer, or ``matching'' networks between the source \ac{SDR} transceiver, analog pre-amplifier and power amplifier stages, and the antenna.
	We choose to target a flat frequency response within the 470 - 700~MHz passband, thereby simplifying operation while maximizing the Bode-Fano bandwidth-efficiency tradeoff  \cite{bode1945network, fano1950theoretical}.

	The active amplifier circuits for the TQP3M9009 and RFPA3800 are represented by their de-embedded two-port S-parameter representations (Section~\ref{sec_scattering}) obtained from the component vendors and validated using evaluation boards for each component.
	In the case where the component S-parameter data are sampled at different frequency intervals, we observe that their real and imaginary components are individually smooth functions and therefore we can linearly interpolate the real and imaginary components separately with negligible loss in their S-parameter representation accuracy before recombining into a sequence of complex $\mathbf{S}[\omega_i]\in\mathbb{C}^{2\times 2}$ matrices indexed by uniform frequency intervals $\omega_i$.
	The original technique proposed by Carlin \cite{carlin1977new} also solved for the optimal ``break points,'' or arbitrary frequency points for representing the sampled reflection coefficients; however, we simplify the problem formulation by choosing uniform break points and oversampling substantially.
	Modern computational capabilities permit this luxury.

	Assuming a steady-state input stimulus and linear operating regime,\footnote{While our small-signal technique does not, in general, optimize the performance of the system when the amplifier becomes saturated, we claim first that energy efficiency was not one of our design goals, therefore operating the amplifier near saturation is not desired; and second, the design paradigm of many-antenna wireless systems is to \emph{reduce} the power budget of any single radio chain while relying on array beamforming gain to provide the link budget necessary for communication. Therefore, we always expect to operate this design in the amplifier's linear operating regime, which is where small-signal techniques excel.} the first stage amplifier system for optimization can be represented as in Figure~\ref{fig_matching_stage_1}.

\begin{figure}[h]
\centering
  \includegraphics[width=0.67\linewidth]{figs/matching/matching_stage_1}
    \caption{First stage of the dual matching problem with an active amplifier.}
\label{fig_matching_stage_1}
\end{figure}

	%In the first half of the optimization, we consider the partial system shown in Figure~\ref{fig_matching_stage_1}.
	Both the source impedance, $Z_G(\omega)$, and the amplifier itself, $\mathbf{S}(\omega)$, are parametrized with scattering parameters, allowing the complex frequency response of the amplifier to be represented with empirical data.
	For this stage, the load impedance is set to be purely resistive: $Z_L(\omega) = Z_0 = 50~\Omega$.

% ###############
\subsubsection{Real Frequency Objective Function Stage 1}
\label{sec_srft_stage_1}

	With this simplification, our goal is to find the input matching network as a function of angular frequency, $\textbf{A}(\omega)$, that maximizes the flat \ac{TPG} of the active amplifier cascaded into a 50-$\Omega$ load, or formally:
	\begin{equation} \label{eq_stage_1}
		\argmax_{[\textbf{A}(\omega)]}{[T_1(\omega) - T_{01}]},
	\end{equation}
where the first stage \ac{TPG} is
	\begin{equation} \label{eq_stage_1_tpg}
		{T_1(\omega)} = |G_{21}|^2\frac{|A_{21}|^2}{|1-A_{11}G_{22}|^2\cdot|1-\hat{A}_{22}S_{11}|^2}|S_{21}|^2,
	\end{equation}
and the target flat \ac{TPG}, $T_{01}$, is set by the engineer.
	A reasonable value for $T_{01}$ can be more systematically determined by setting $T_{01}$ to the minimum value of the amplifier's \ac{MAG} within the band of interest and decreasing $T_{01}$ until an acceptable solution to Equation~\ref{eq_stage_1} is found.
	For an active amplifier in a nominal 50~$\Omega$ circuit, the \ac{MAG} for an unconditionally stable \cite{orfanidis2002electromagnetic} amplifier is defined as
\begin{equation} \label{eq_mag}
T_{MAG} := \frac{|S_{21}|^2}{(1-|S_{11}|^2)(1-|S_{22}|^2)}.
\end{equation}

	In Equation~\ref{eq_stage_1_tpg}, we let $p:=j\omega$ and the unknown $\mathbf{A}(\omega)$ is completely determined by the polynomial
\begin{equation}
\hat{A}_{22}(p) = \frac{h(p)}{g(p)} = \frac{h_np^n+\dotsb+h_1p+h_0}{g_np^n+\dotsb+g_1p+g_0}, \label{eq_belevich_poly}
\end{equation}
where the optimization is taken over just the coefficients of $h(p)$, since all other terms can be derived uniquely from $h(p)$ as shown by Yarman \cite{yarman1982simplified}.
	First, the solution matching equalizer is assumed lossless, therefore we restrict solutions to those that obey the lossless criterion $$g(p)g(-p)=h(p)h(-p)+(-1)^k p^{2k} ~>~ 0 ~\forall p,$$
which provides the means to derive $g(p)$ from $h(p)$. %G(p^2)=
	The remaining terms are also derived as:\footnote{There is a typo in \cite{yarman2010design} with incorrect derivation of $A_{11}(p)$. The equations given here are correct and verified with working examples.}
\begin{align}
	A_{12}(p) &= A_{21}(p) = \textpm \frac{p^k}{g(p)} \\
	A_{11}(p) &= -(-1)^k\frac{h(-p)}{g(p)}.
\end{align}

	The number of reactive circuit elements is set implicitly by allocating the initial polynomial solution $h(p)$ with length $n$.
	The order of the zero of the transmission coefficients $A_{12}(p)$ at DC is also set to $k \in \mathbb{Z} \geqslant 0$ by the engineer, thus providing all the remaining unknowns and allowing the optimization to continue.
	In our case, we set $k=0$ in order to avoid additional components needed to produce zeros at DC; this produces a lowpass circuit.
	This could introduce some inefficiency in our synthesized matching circuit since the Bode-Fano limit suggests zeroing gain outside of the desired passband \cite{bode1945network, fano1950theoretical}, however we find that the tradeoff in reducing the number of components to realize the circuit to be worth it.

% ###############
\subsubsection{Real Frequency Objective Function Stage 2}
\label{sec_srft_stage_2}

\begin{figure}[h]
\centering
  \includegraphics[width=0.8\linewidth]{figs/matching/matching_stage_2}
    \caption{Second stage of the dual matching problem with an active amplifier.}
\label{fig_matching_stage_2}
\end{figure}

	Once the input matching equalizer has been synthesized, we then change the load impedance from a nominal $50~\Omega$ to $Z_L(\omega)$, which may be a constant scalar value represented by its Darlington 2-port equivalent reflection coefficients \cite{yarman2010design} or may be specified empirically by measured or modeled 2-port S-parameters $\textbf{L}(\omega)$.
	We fix $\textbf{A}(\omega)$ to the optimal value found for Equation~\ref{eq_stage_1} and define a new optimization objective function for the cascaded \ac{TPG} for the system extended in Figure~\ref{fig_matching_stage_2}:
\begin{equation} \label{eq_stage_2}
	\argmax_{[\textbf{B}(\omega)]}{[T_2(\omega) - T_{02}]},
\end{equation}
where the second stage \ac{TPG} is
\begin{equation} \label{eq_stage_2_tpg}
	{T_2(\omega)} = \overbar{T_1}(\omega)\frac{|B_{21}|^2}{|1-B_{11}\hat{S}_{22}|^2\cdot|1-\hat{B}_{22}L_{11}|^2}|L_{21}|^2,
\end{equation}
and $\overbar{T_1}(\omega)$ is the piecewise optimized \ac{TPG} for the numerical solution for Equation~\ref{eq_stage_1} and the system in Figure~\ref{fig_matching_stage_1}.

	In order to solve the two posed optimization problems, we develop a MATLAB script utilizing modified functions from Yarman \cite{yarman2010design} and write an error function taking the numerator from Equation~\ref{eq_belevich_poly} as an argument and outputting the error function from Equations~\ref{eq_stage_1} and \ref{eq_stage_2} for optimization.
	Using MATLAB's non-linear optimization toolbox utilizing the Levenberg-Marquardt least-squares optimization algorithm \cite{hansen2013least}, it is possible to converge on a satisfactory solution.
	Since the optimization is highly sensitive to the initial conditions of the polynomial in Equation~\ref{eq_belevich_poly}, we run the algorithm starting with all combinations of the coefficients of $h(p)$, \{$h_0 + \ldots + h_k\} = \{\pm 1, \ldots , \pm 1 \}$ and choose the result with the smallest error.
	While this would be prohibitive for large-sized problems, we find it works well for problems with 2-10 passive components; any more components and the set of starting conditions would be too large to exhaustively search and the physical circuit implementation would be quite large and sensitive to component tolerance.

	Finally, there do not appear to be strict guarantees that the proposed optimization will always converge for all input data sets nor that the global minimum will be found utilizing our starting conditions.
	Nevertheless, we found this optimization to be well-behaved and did not encounter any conditions that resulted in a failure to converge upon a satisfactory solution.

	\begin{figure*}[th]
\centering
   	\subfigure[TQP3M9009 Reflection Coefficients.]{
		\includegraphics[width=0.44\linewidth]{figs/matching/TQP3M9009_smith}   \label{fig_tqp_smith}
        	}
	\subfigure[RFPA3800 Reflection Coefficients.]{
		\includegraphics[width=0.45\linewidth]{figs/matching/RFPA3800_smith}   \label{fig_rfpa_smith}
        	}
\caption{Unmatched Smith Chart plots of PA components from 300 - 800 MHz.\label{fig_smith_charts}}
\end{figure*}

\subsubsection{Results for TQP3M9009}

	We display the results of the tuned optimization for the TQP3M9009 component in Figure~\ref{fig_srft_tqp}, with the \ac{MAG} (Equation~\ref{eq_mag}) displayed as an upper bound on the achievable matched gain for both the input and output matching circuits.
	In each case, we choose $T_{01} = T_{02} = 25$~dBm as the target flat gain value, represented as the flat dotted green line in Figure~\ref{fig_srft_tqp} (top left, top right).
	These values were chosen by trial and error as the maximum flat gain values that could be supported with this matching circuit.
		The number of matching elements is also chosen through trial and error in order to meet the optimization target with a minimal number of physical components.
		We can tell immediately from the relatively flat T1 and T2 \ac{MAG} that the TQP3M9009 is already well-matched and will require few components to produce a flat gain response.
		This is confirmed by viewing the Smith chart representation \cite{orfanidis2002electromagnetic} of the input and output reflection coefficients of the unmatched amplifier in Figure~\ref{fig_tqp_smith}, where we can see it is already well-matched in a 50~$\Omega$ system.

	The resulting optimized TQP3M9009 gain with only input matching, $\text{T1}_{\text{dB}}$, and both input and output matching, $\text{T2}_{\text{dB}}$, is shown as solid blue lines.
	Compared to the \ac{MAG}, which represents the optimal gain in the case where each frequency point is optimized individually without regard for a broadband match, our optimized flat passband gain performs quite well.

	The physical ideal circuits that realize this optimized gain are also shown in Figure~\ref{fig_srft_tqp} (middle left, middle right).
	Numerical solutions to Equation~\ref{eq_stage_1} result in arbitrary circuit component values, but lumped elements are only available in discrete values.
	Therefore we perform a final processing step to round the solution lumped element component values to their nearest commercially available common values.
	The raw solution and the processed solution based on common component values is given as the second and third rows in Figure~\ref{fig_srft_tqp}.

%\pagebreak

\begin{figure}[p]
\centering
  \includegraphics[width=1\linewidth]{figs/matching/14-Oct-2018_TQP3M9009_srft_results_sequential}
    \caption{50-$\Omega$ input and output broadband match and synthesized circuit for 1st stage TQP3M9009 amplifier.}
\label{fig_srft_tqp}
\end{figure}

\pagebreak

%
%
%\begin{equation}
	%\argmax_{\textbf{[E]}}{T(\omega)} = |G_{21}|^2\frac{|E_{21}|^2}{|1-E_{11}G_{22}|^2|1-\hat{E}_{22}L_{11}|^2}|L_{21}|^2
%\end{equation}

\subsubsection{Results for RFPA3800}

	We display the results of the same tuned optimization for the RFPA3800 component in Figure~\ref{fig_srft_rfpa}, with the \ac{MAG} (Equation~\ref{eq_mag}) displayed as an upper bound on the achievable matched gain for both the input and output matching circuits.

	In this case, we empirically choose $T_{03} = 7.8$ and $T_{04} = 15.3$~dBm as the target flat gain value, represented as the flat dotted green line in Figure~\ref{fig_srft_rfpa} (top left, top right).

	The RFPA3800 presents a more difficult circuit to match; from its unmatched Smith Chart representation in Figure~\ref{fig_rfpa_smith} it is not internally matched to a 50~$\Omega$ system.
	This is a common occurrence with most high-power amplifiers or transistors, which leaves flexibility to the microwave designer, but also means we will need to apply more effort to get the part matched to 50~$\Omega$.

	This means that there is a larger different between the RFPA3800 T3 and T4 \ac{MAG} and its optimized flat gain, as shown in Figure~\ref{fig_srft_rfpa} (top left, top right).
	For the same reason, a larger number of matching components are required to achieve a reasonable flat frequency response across the band from 470 - 700~MHz and a few dB of gain compared to the upper bound \ac{MAG} are sacrificed in order to achieve this relatively flat gain target.

	We extended the upper frequency range in our final optimization of this broadband matching circuit to 800~MHz based on our experience implementing the circuit and finding that high-band performance above 650~MHz suffered from parasitics.
	This extra effort extends the lowpass roll off of the power transfer circuit topology higher to ensure that performance below 700~MHz remains nominal once implemented as a physical circuit.

\begin{figure}[p]
\centering
  \includegraphics[width=1\linewidth]{figs/matching/14-Oct-2018_RFPA3800_srft_results_sequential}
    \caption{50-$\Omega$ input and output broadband match and synthesized circuit for 2nd stage RFPA3800 amplifier.}
\label{fig_srft_rfpa}
\end{figure}

\pagebreak

%\begin{figure}[h]
%\centering
  %\includegraphics[width=0.9\linewidth]{figs/matching/14-Oct-2018_RFPA3800_srft_results_sequential}
    %\caption{50-$\Omega$ input and output broadband match and synthesized circuit for RFPA3800 amplifier.}
%\label{fig_srft_rfpa}
%\end{figure}

%##################################################
\subsection{Simulation of Broadband Matching Networks}
\label{sec_broadband_ideal}
% XSPICE simulation circuit and results

%\begin{figure}[h]
%\centering
  %\includegraphics[width=4in]{figs/matching/RFPA3800_circuit}
    %\caption{SPICE simulation circuit for ideal broadband power transfer network}
%\label{fig:tx_power_plot}
%\end{figure}

	In this section, we present an early prototype of the \ac{WURC} broadband power transfer network that utilized the same real frequency numerical optimization design technique as discussed in Section~\ref{sec_srft_stage_1} and \ref{sec_srft_stage_2}, but rather than matching each amplifier to a 50~$\Omega$ input and output impedance, the multiple stages were cascaded into each other following the general procedure outlined in Yarman 1982 \cite{yarman1982simplified}.
	The intent of these simulations were to confirm the validity of the designed broadband matching circuit before producing physical prototypes; however we found that both our design technique as well as our modeling approach was insufficient to fully represent the physical realization of the broadband matching circuit.
	In this section we will discuss in detail why this occurred and the additional steps needed to implement the ideal broadband power transfer network developed in Section~\ref{sec_dual_match}.

	The initial prototype circuit design is shown in Figure~\ref{fig_spice_circuit}, where XSPICE models for the amplifier elements were extracted from the empirical S-parameter files using EMtoSPICE \cite{mandrutareduced}, a commercial tool for extracting stable time-domain simulation models from frequency-domain S-parameter data.
	We used the built-in XSPICE simulator in \ac{CAD} tool Altium Designer 13 to simulate the steady-state frequency response of the broadband amplifier chain.
	In Figure~\ref{fig_spice_results}, we show the broadband matching gain as a function of the center frequency.
	Both a match to a 65~$\Omega$ (blue) and 50~$\Omega$ (red) differential source impedance were simulated, as we had not yet decided how to compensate for the LMS6002D's 65~$\Omega$ source impedance.

	With a minimum simulated 39.2~dBm in-band gain matched against a 50~$\Omega$ source, this was sufficiently close to the designed frequency response that a prototype \ac{PCB} was fabricated to implement the circuit for testing and fine-tuning.

% SPICE Model Circuit
\begin{figure}[p]
\centering
  \includegraphics[width=1\linewidth]{figs/matching/tqp_rfpa_circuit_50_65_load}
    \caption{XSPICE simulation circuit for ideal broadband power transfer network.}
\label{fig_spice_circuit}
\end{figure}

% SPICE Simulation Results
\begin{figure}[p]
\centering
  \includegraphics[width=0.9\linewidth]{figs/matching/RF_Protoboard_XSPICE}
    \caption{XSPICE simulation results of ideal broadband power transfer network.}
\label{fig_spice_results}
\end{figure}

% #########
\subsubsection{Evaluation of Broadband Matching Networks}
\label{sec_rf_protoboard}
% RF Protoboard and results

	We designed and manufactured a controlled impedance 2-layer PCB to implement the circuit presented in Figure~\ref{fig_spice_circuit} \ref{sec_broadband_ideal}.
	With 50~$\Omega$ input and output, the circuit was designed to provide space for any additional matching components and RF probes.
	%An additional pass-through 50~$\Omega$ microstrip trace was provided to de-embed the PCB or individual components, should that become necessary.
	The assembled PCB is shown in Figure~\ref{fig_match_proto_pcb}.
	The extra grounding copper foil shown in the picture was added after initial characterization and can be ignored.

	The prototype amplification PCB was measured with a calibrated vector network analyzer and it became clear that the physical device performance was not matching simulated results.
	We show the actual $|S_{21}|$, or forward gain, of the cascaded designed gain stages in Figure~\ref{fig_match_proto_gain}, where we can immediately see that gain unexpectedly drops off to zero drastically after approximately 500~MHz whereas the designed circuit maintained a flat gain out beyond 800~MHz in simulation.

% RF Prototype Board for UHF RF PAs
\begin{figure}[p]
\centering
  \includegraphics[width=1\linewidth]{figs/matching/rf_protoboard}
    \caption{Prototype PCB of WURC broadband power transfer circuit.}
\label{fig_match_proto_pcb}
\end{figure}

% Gain Plot for RF Prototype Board
\begin{figure}[p]
\centering
  \includegraphics[width=0.8\linewidth]{figs/matching/RF_Protoboard_S21_measured}
    \caption{Measured gain of prototype WURC broadband power transfer circuit.}
\label{fig_match_proto_gain}
\end{figure}

	The root cause of this unintended result is the inability of the real-frequency matching technique to directly consider parasitic circuit elements in its formulation.
	It is a well-characterized fact that physical circuit elements are non-ideal: coupling between physical elements and construction from non-ideal materials yields parasitic resistance, capacitance, and inductance in each lumped-element component.
	A chip capacitor in particular has a \ac{SRF}, $\omega_0 = \frac{1}{\sqrt{L_p\cdot C}}$, when the desired series capacitance resonates with the parasitic series inductance of the part \cite{murata2010srf}.
	Below the resonant frequency, the capacitance term dominates; above the resonant frequency, the parasitic inductive term dominates and the physical capacitor no longer behaves like an ideal capacitor.

	\pagebreak

	For example, we present the empirical impedance functions provided by the component manufacturer of three chip capacitors considered in our matching circuit design in Figure~\ref{fig_cap_comparison}: a 16~pF 0201 (GRM0335C1H160 blue), a 5~pF 0402 (GJM1555C1H5R0 green), and a 47~pF 0402 (GJM1555C1H470 red).
	These capacitors were considered to implement the circuit in Figure~\ref{fig_spice_results}, specifically component C117 in that diagram.

	The 47~pF 0402 component has a self-resonant frequency of approximately 1600~MHz, represented by the trough in the red curve in Figure~\ref{fig_cap_comparison}.
	As a rule of thumb, the \ac{SRF} of a component should be selected to be approximately 3-times larger than the maximum operating frequency of the circuit for filters and matching application in order to ensure that its behavior approaches its expected ideal behavior.
	We confirmed that this particular capacitor was behaving in a non-ideal manner due to its low \ac{SRF} that effectively destroyed the designed conjugate match above 500~MHz in the implemented circuit.

	In general, larger value capacitances and larger physical packages result in lower \ac{SRF}, so we focused on reducing both parameters.

% Self-resonant frequencies for capacitors in WURC
\begin{figure}[hb]
\centering
  \includegraphics[width=1\linewidth]{figs/matching/capacitor_comparison}
    \caption{S-parameters for various MLCC capacitor configurations.}
\label{fig_cap_comparison}
\end{figure}

	After much iteration with small-scale simulation techniques that could accurately model the parasitics, we decided to replace the 47~pF 0402 with three different capacitors in parallel: two 16~pF 0201 and one 5~pF 0402 capacitor.
	The \ac{SRF} for these two parts was respectively 2450~MHz and 3820~MHz, well above the maximum 800~MHz operating range of the amplifiers; the combined frequency response of this parallel circuit is shown in Figure~\ref{fig_cap_comparison} as the orange plotline.

%##################################################
\subsection{Simulation of Broadband Matching Networks with Parasitics}
\label{sec_wurc_parasitics}

	While this design was confirmed at the early design stage with XSPICE simulation models, evaluation of the prototypes presented earlier demonstrated that package parasitics in the lumped-element broadband power transfer chain were missing from the XSPICE simulator models.
	These parasitics severely impaired the implemented high-frequency gain response above 500~MHz and required a more advanced model and simulation technique to correctly predict their effect.
	Re-modeling the RF chain in the Cadence Virtuoso SpectreRF circuit simulator utilizing empirical S-parameter models resulted in a more accurate simulation, allowing package parasitics to be compensated for in the lumped-element design.

	We considered the entire physical layout in SpectreRF, including transformers, microstrip, switches and filters.
	For each discrete component, empirical S-parameter files were obtained from the equipment manufacturer or directly generated from development boards using a vector network analyzer.
	The resulting physical model considering parasitics and layout is shown in Figure~\ref{fig_spectre_uhf_circuit} for the entire \ac{WURC} UHF transmit chain.

% PAGEBREAK  vvvvvvvvvvvvvv
% SpectreRF full RF chain model
\begin{figure}[p]
\centering
  \includegraphics[width=0.75\linewidth]{figs/matching/spectre_uhf_tx_complete_chain}
    \caption{Simulation model of full UHF transmit chain in Cadence Virtuoso SpectreRF.}
\label{fig_spectre_uhf_circuit}
\end{figure}
% PAGEBREAK  ^^^^^^^^^^^^^^

	The simulated results for the SpectreRF system in Figure~\ref{fig_spectre_uhf_circuit} are shown in Figure~\ref{fig_spectre_uhf_results}.
	Here, we present two results: 1) the gain performance of the system where each lumped element is replaced with an ideal capacitor or inductor while all other active components, switches, and traces are modeled by their empirical representations with parasitics (red); and 2) the gain performance when each ideal component has been replaced with an empirical S-parameter model and hand-tuned individually to bring performance as close to the ideal as possible (green).

	The hand-tuning procedure is inherently greedy but produces satisfactory results:
	\begin{itemize}
		\item \textbf{Step 1}: select an arbitrary ideal component, replace the ideal component with its S-parameter small-signal model;
		\item \textbf{Step 2}: replace this component with the small-signal model for a component with a smaller or larger common value (\emph{e.g.} a 9~pF capacitor would be compared with a 10~pF and 8~pF component in this step);
		\item \textbf{Step 3}: select the component with system frequency response that is most like the ideal system frequency response, set this component selection;
		\item \textbf{Step 4}: repeat from Step 2 until no improvement in the system frequency response is gained;
		\item \textbf{Step 5}: repeat from Step 1 until all ideal components have been replaced with small-signal models.
	\end{itemize}

	Since there are generally fewer inductor step sizes in commonly-available \ac{SMT} components than capacitor step sizes, we perform the greedy tuning algorithm first on all of the inductors in a model and \emph{then} on the capacitors.

	We can see that the final circuit frequency response in Figure~\ref{fig_spectre_uhf_results} has good, flat performance with only 4~dB ripple from 470 - 750~MHz, and that the modeled gain diverges by 2-3~dB from ideal modeled performance primarily at the high frequencies above 550~MHz.
	The overall system gain in the SpectreRF simulation in Figure~\ref{fig_spectre_uhf_results} is smaller than that predicted by XSPICE in Figure~\ref{fig_spice_results}, but it also considers losses from component parasitic resistances, switch and filter insertion loss, and microstrip losses and is closer to that of the physical circuit realization.

%##################################################
\subsubsection{Evaluation of Broadband Matching Networks with Parasitics}
\label{sec_wurc_parasitic_eval}

	Finally, having considered all physical impairments in our simulation model and after hand-tuning the simulated design, we realized this new circuit design in the first \ac{WURC} prototype shown in Figure~\ref{fig_wurc_versions} as the green PCB.
	Additional simple resistive impedance matches were made from the source LMS6002D 65~$\Omega$ differential to the system 50~$\Omega$ single-ended and from the system 50~$\Omega$ to the 75~$\Omega$ output antenna ports, but these were not difficult and the process is omitted here.

% SpectreRF simulation results
\begin{figure}[ht]
\centering
  \includegraphics[width=0.7\linewidth]{figs/matching/spectre_simulation_results}
    \caption{Simulated gain for the SpectreRF system in Figure~\ref{fig_spectre_uhf_circuit}.}
\label{fig_spectre_uhf_results}
\end{figure}

	In order to validate the final implemented design and understand how manufacturing process variation might effect the output frequency response of multiple RF chains in a \ac{MU-MIMO} system, we built a Python-based batch interface to the \ac{WURC}'s serial UART in order to sweep transmit frequencies while simultaneously controlling a bench-top vector signal analyzer to measure the output power \cite{guerra2012wurc_cal}.
	We implemented a digital frequency synthesizer within the digital baseband reference design for \ac{WURC} in order to generate a constant-power \ac{CW} complex sinusoid for ease of measurement.

% Output WURC power across multiple boards
\begin{figure}[ht!]
\centering
  \includegraphics[width=0.8\linewidth]{figs/wurc/wurc_tx_power_plot}
    \caption{Maximum linear \ac{CW} output power as a function of center frequency for multiple \ac{WURC} units.}
		\label{fig_wurc_linear_power}
\end{figure}

	The process variation plot in Figure~\ref{fig_wurc_linear_power} was generated by increasing the output transmit gain of each \ac{WURC} at each center frequency until its output power amplifier began to saturate (\emph{i.e.} the last tested value where a 1:1 input:output gain relationship still held).
This is the delivered output power of \ac{WURC} just before the 1~dB compression point of the RF chain.
Notably, the process variation across different boards is less than 1~dB, with passband ripple on the order of 2.5~dB.
This means that multiple RF chains will maintain similar output power across the entire UHF frequency range, vastly simplifying system planning and gain control processes.

\subsection{Conclusion and Discussion}

	While this is a lengthy discussion, we believe there is valuable insight in presenting the step-by-step design and optimization of the \ac{WURC} broadband power transfer network as this work took years to develop and refine through various steps of manufacture and has application beyond this single design.
	We have attempted to not only provide enough information to replicate these design steps, but also provide motivation as to why certain decisions were made.
	%In addition, the real-frequency design code is also available open-source with permission from Yarman \cite{a_github_repo}.

	The final implemented UHF-band analog RF chain for \ac{WURC} provides up to 30~dB of static transmit gain, and up to 61~dB of dynamic receive gain, which combined with its on-board static \ac{LNA} can provide up to 83~dB of receive gain for improved sensitivity, although noise figure considerations generally limit this application to 72~dBm of dynamic receive gain.

 While we present a direct comparison of different manufactured \ac{WURC} boards demonstrating their consistent performance in Figure~\ref{fig_wurc_linear_power}, today we have manufactured dozens of \ac{WURC} boards with consistent results and also hundreds of related radio modules that utilize this same broadband power transfer design techniques for a wide range of operational frequencies and components.

	In conclusion, we find that the original real frequency circuit synthesis technique doesn't capture physical implementation tradeoffs well and made several changes to the design technique in order to improve the chance for success of the physical circuit realization:

\begin{enumerate}
	\item Instead of cascading multiple amplifier blocks in a series of dependent optimizations as proposed by Yarman \cite{yarman1982simplified}, we instead match the input and output of each amplifier to 50~$\Omega$ as proposed in our Section~\ref{sec_srft_problem_statement} problem statement and cascade them into each other. This allows us to decouple the design and optimization of the broadband matching network for each component and avoid the need to accurately model the microstrip feeds between amplification stages so long as they are placed in a nominal 50~$\Omega$ system.

	\item We utilize a simulation environment that either explicitly models package, pad, and trace parasitics or utilized empirical S-parameter models for linear system analysis. These types of tools are able to model and highlight implementation issues that are not apparent from the ideal circuits synthesized by the real frequency technique. Specifically, we present an example using Cadence Virtuoso SpectreRF in this thesis and currently use Keysight Genesys for this purpose.

	\item Finally, we add an additional hand-optimization step that utilizes linear analysis tools like SpectreRF or Genesys to adjust real component values based on their packages and parasitic properties in order to tune the physical circuit so that it approaches the ideal synthesized behavior. Today this is done in a greedy method whereby each component is individually hand-optimized, however the roadmap for future work to automate this with a discrete non-linear optimization algorithm using a library of empirical parts data is clear.
\end{enumerate}


We discuss here an alternative proof method for proving
normalization. We will focus here on a \emph{semantic} proof method
using \emph{saturated sets} (see \cite{Luo:PHD90}). This proof method
goes back to \cite{Girard1972} building on some previous ideas
by \cite{Tait67}.

The key question is how to prove that given a lambda-term, its
evaluation terminates, i.e. normalizes. We concentrate here on a typed
operational semantics following \cite{Goguen:TLCA95} and define
a reduction strategy that transforms $\lambda$-terms into
$\beta$ normal form. This allows us to give a concise presentation of the important issues that arise.

 We see this benchmark as a good jumping point to investigate and mechanize the meta-theory of dependently typed systems where a typed operational semantics simplifies the study of its meta-theory. The approach of typed operational semantics is however not limited to dependently typed systems, but it has been used extensively in studying subtyping,  type-preserving compilation, and shape analysis. Hence, we believe it does describe an important approach to describing reductions.

\section{Simply Typed Lambda Calculus with Type-directed Reduction}
Recall the lambda-calculus together with its reduction rules.

\[
\begin{array}{llcl}
\mbox{Terms}  & M,N & \bnfas & x \mid \lambda x{:A}. M \mid M\;N \\
\mbox{Types} & A, B & \bnfas & \base \mid A \arrow B
\end{array}
\]

We consider as the main rule for reduction (or evaluation) applying a term to an abstraction, called \emph{$\beta$-reduction}.
% together with \emph{$\eta$-expansion}. We only $\eta$-expand a term, if we do not immediately create a redex to avoid infinite alternations between $\eta$-expansion and $\beta$-reduction.
 We use the judgment $\Gamma \vdash M \red N :A$ to mean that both $M$ and $N$ have type $A$ in the context $\Gamma$ and the term $M$ reduces to the term $N$.

% \[
% \begin{array}{lcll}
% %\multicolumn{3}{l}{\mbox{$\beta$-reduction}}  \\
% \Gamma \vdash (\lambda x{:}A.M)\;N : B & \red & \Gamma \vdash [N/x]M : B & \mbox{$\beta$-reduction} \\
% \Gamma \vdash M : A \arrow B & \red & \Gamma \vdash \lambda x{:}A.M~x : A \arrow B & \mbox{$\eta$-expansion}
% \end{array}
% \]

% The $\beta$-reduction rule only applies once we have found a redex.  However, we also need congruence rules to allow evaluation of arbitrary subterms.

\[
\begin{array}{c}
\infer[\beta]
{\Gamma \vdash (\lambda x{:}A.M)~N  \red [N/x]M : B }
%    {\Gamma \vdash \lambda x{:}A.M : A \arrow B & \Gamma \vdash  N : A}
    {\Gamma, x{:}A \vdash M :  B & \Gamma \vdash  N : A}
\qquad
%\infer[\eta]{\Gamma \vdash M \red \lambda x{:}A.M~x : A \arrow B}{
% M \not= \lambda y{:}A.M'}
\\[1em]
\infer{\Gamma \vdash M\,N \red M'\,N : B}{\Gamma \vdash M \red M' : A \arrow B & \Gamma \vdash N : A}
\qquad
\infer{\Gamma \vdash M\,N \red M\,N' : B}{\Gamma \vdash M : A \arrow B & \Gamma \vdash N \red N' : A}
\\[1em]
\infer{\Gamma \vdash \lambda x{:}A.M \red \lambda x{:}A.M' : A \arrow B}{\Gamma, x{:}A \vdash M \red M' : B}
\end{array}
\]

Our typed reduction relation is inspired by the type-directed
definition of algorithmic equality for $\lambda$-terms (see for
example \cite{Crary:ATAPL} or \cite{Harper03tocl}). Keeping track of
types in the definition of equality or reduction becomes quickly
necessary as soon as want to add $\eta$-expansion or add a unit type
where every term of type unit reduces to the unit element. We will
consider the extension with the unit type in Section~\ref{sec:unit}.

On top of the single step reduction relation, we can define multi-step
reductions as usual:

\[
\ianc{\Gamma \vdash M \red N}{\Gamma \vdash M \mred N : B}{} \qquad
\ibnc{\Gamma \vdash M \red N : B}{\Gamma \vdash N \mred M' : B}
      {\Gamma \vdash M \mred M' : B}{}
\]

Our definition of multi-step reductions guarantees that we take at least one step.
In addition, we have that typed reductions are only defined on well-typed terms, i.e. if $M$ steps then $M$ is well-typed.

\begin{lemma}[Basic Properties  of Typed Reductions and Typing]\quad
  \begin{itemize}
  \item If $\Gamma \vdash M \red N : A$ then $\Gamma \vdash M : A$ and $\Gamma \vdash N : A$.
  \item If $\Gamma \vdash M : A$ then $A$ is unique.
  \end{itemize}
\end{lemma}

The typing and typed reduction strategy satisfies weakening and
strengthening\ednote{Should maybe be already formulated using context
  extensions? -bp. Likewise, the subsitution lemma cound be formulated with well typed subst. Moreover the weaken/stren of typing follow from the same for reduction and lemma 1.1 -am}.

\begin{lemma}[Weakening and Strengthening of Typed Reductions]\label{lem:redprop}\quad
  \begin{itemize}
%   \item If $\Gamma, \Gamma' \vdash M : B$ then $\Gamma, x{:}A, \Gamma' \vdash M : B$.
%  \item If $\Gamma, x{:}A, \Gamma' \vdash M : B$ and $x \not\in\FV(M)$ then $\Gamma, \Gamma' \vdash M : B$.
  \item If $\Gamma, \Gamma' \vdash M \red N : B$ then $\Gamma, x{:}A, \Gamma' \vdash M \red N : B$.
  \item If $\Gamma, x{:}A, \Gamma' \vdash M \red N : B$ and $x \not\in \FV(M)$ then
        $x \not\in \FV(N)$ and $\Gamma, \Gamma' \vdash M \red N : B$.
  \end{itemize}
\end{lemma}
\begin{proof}
By induction on the first derivation.
\end{proof}

\begin{lemma}[Substitution Property of Typed Reductions]\label{lem:redsubst}\quad
If $\Gamma, x{:}A \vdash M \red M' : B$ and $\Gamma \vdash N : A$ then
$\Gamma \vdash [N/x]M \red [N/x]M' : B$.
\end{lemma}
\begin{proof}
By induction on the first derivation, using standard properties of composition of substitutions.
\end{proof}

We also will rely on some standard multi-step reduction properties
which are proven by induction.

\begin{lemma}[Properties of Multi-Step Reductions]\label{lm:mredprop}
\quad
\begin{enumerate}
\item\label{lm:mredtrans} If $\Gamma \vdash M_1 \mred M_2 : B$ and $\Gamma \vdash M_2 \mred M_3 : B$ then $\Gamma \vdash M_1 \mred M_3 : B$.
\item\label{lm:mredappl} If $\Gamma \vdash M \mred M' : A \arrow B$
  and $\Gamma \vdash N : A$
  then $\Gamma \vdash M~N \mred M'~N : B$.
\item\label{lm:mredappr} If $\Gamma \vdash M : A \arrow B$ and $\Gamma \vdash N \mred N' : A$ then $\Gamma \vdash M~N \mred M~N' : B$.
\item\label{lm:mredabs} If $\Gamma,x{:}A \vdash M \mred M' : B$ then $\Gamma \vdash \lambda x{:}A.M \mred \lambda x{:}A.M' : A \arrow B$.
\item\label{lm:mredsubs} If $\Gamma, x{:}A \vdash M : B$ and $\Gamma \vdash N \red N' : A$
then $ \Gamma \vdash [N/x]M \mred [N'/x]M : B$.
\end{enumerate}
\end{lemma}

\subsection*{When is a term in normal form?}

We define here briefly when a term is in $\beta$-normal form.
% The presence of $\eta$ again requires our definition to be type directed.
We define the grammar of normal terms as given below

\[
\begin{array}{llcl}
\mbox{Normal Terms}  & M,N & \bnfas & \lambda x{:A}. M \mid R \\
\mbox{Neutral Terms} & R, P & \bnfas & x \mid R\;M \\
  \end{array}
\]

This grammar does not enforce $\eta$-long.
% For example, $\lambda x{:}A \arrow A. x$ is not in $\eta$-long form.
% To ensure we only characterize $\eta$-long forms, we must ensure that we allow to switch between normal and neutral types at base type.  % On the other hand, $\lambda x{:}A \arrow A. \lambda y{:}A.x~y$ is in $\beta$-short and $\eta$-long form.

% \[
%   \begin{array}{c}
% \multicolumn{1}{l}{\fbox{$\nf {\Gamma \vdash M} A$}~~\mbox{Term $M$ is normal at type $A$}}\\[1em]
% \ianc{\nf {\Gamma, x{:}A \vdash M} B}
%      {\nf {\Gamma \vdash \lambda x{:}A.M} {A \arrow B}}{} \quad
% \ianc{\neu {\Gamma \vdash R}{\base}}
%      {\nf {\Gamma \vdash R}{\base}}{}
% \\[1em]
% \multicolumn{1}{l}{\fbox{$\neu {\Gamma \vdash M} A$}~~\mbox{Term $M$ is neutral at type $A$}}\\[1em]
% \ibnc{\neu {\Gamma \vdash R} {A \arrow B}}{\nf {\Gamma \vdash M} A}
%      {\neu {\Gamma \vdash R~M} {B}}{}
% \qquad
% \ianc{x{:}A \in \Gamma}{\neu {\Gamma \vdash x} {A}}{}
%   \end{array}
% \]

% In practice, it often suffices to enforce that we reduce a term to a weak head normal form. For weak head normal forms we simply remove the requirement that all terms applied to a neutral term must be normal.

\subsection*{Proving normalization}
The question then is, how do we know that we can normalizing a well-typed lambda-term into its $\beta$ normal form? - This is equivalent to asking whether after some reduction steps we will end up in a normal form where there are no further reductions possible. Since a normal lambda-term characterizes normal proofs, normalizing a lambda-term corresponds to normalizing proofs and demonstrates that every proof in the natural deduction system indeed has a normal proof. %

Proving that reduction must terminate is not a simple syntactic argument based on terms, since the $\beta$-reduction rule may yield a term which is bigger than the term we started with. % Further, $\eta$-expansion might make the term bigger.

As syntactic arguments are not sufficient to argue that we can always compute a $\beta$ normal form, we hence need to find a different inductive argument. For the simply-typed lambda-calculus, we could prove that while the expression itself does not get smaller,  the type of an expression does\footnote{This is the essential idea of hereditary substitutions \cite{Watkins02tr}}.  This is a syntactic argument; it however does not scale to polymorphic lambda-calculus or full dependent type theories. We will here instead discuss a \emph{semantic} proof method where we define the meaning of well-typed terms using the abstract notion of \emph{reducibility candidates}.

Throughout this tutorial, we stick to the simply typed lambda-calculus and its extension. This allows us to give a concise presentation of the important issues that arise.  However the most important benefits of typed operational semantics and our approach are demonstrated in systems with dependent types  where our development of the metatheoretic simpler than the existing techniques. We see this benchmark hence as a good jumping point to investigate and mechanize the meta-theory of dependently typed systems.

% Unlike all the previous proofs which were syntactic and direct based on the structure of the derivation or terms, semantic proofs

\section{Semantic Interpretation}
Working with well-typed terms means we need to be more careful to
consider a term within its typing context. In particular, when we
define the semantic interpretation of $\inden{\Gamma}{M}{A \arrow B}$
we must consider all extensions of $\Gamma$ (described by $\Gamma'
\ext \rho \Gamma$) in which we may use $M$.

\begin{itemize}
\item $\inden{\Gamma}{M}{\base}$ iff $\Gamma \vdash M\hastype \base$ and $M$ is strongly normalizing
% , i.e. $\Gamma \vdash M \in \SN$.
\item $\inden{\Gamma}{M}{A \arrow B}$ iff for all $\Gamma' \ext{\rho} \Gamma$ and $\Gamma' \vdash N :A$, if $\inden{\Gamma'}{N}{A}$ then $\inden{\Gamma'}{[\rho]M~N}{B}$.
\end{itemize}

% Weakening holds for the semantic interpretations.

% \begin{lemma}[Semantic Weakening]\ref{lm:sweak}
% If $\Gamma \models M : A$ then $\Gamma, x{:}C \models M : A$.
% \end{lemma}

% We sometimes write these definitions more compactly as follows

% \[
% \begin{array}{llcl}
% \mbox{Semantic base type} & \den{o} & := & \SN  \\
% \mbox{Semantic function type} & \den{A \arrow B} & := & \{ M | \forall \Gamma' \ext{\rho} \Gamma,~\forall \Gamma' \vdash N : A.~ \Gamma'\ models N : A \ \in \den{A}. M\;N \in \den{B} \}
% \end{array}
% \]

\section{General idea}

We prove that if a term is well-typed, then it is strongly normalizing in  two steps:

\begin{description}
\item[Step 1] If $\inden{\Gamma}{M}{A}$ then $\Gamma \vdash M : A$ and $M$ is strongly normalizing.
\item[Step 2] If $\Gamma \vdash M : A$ and $\inden{\Gamma'}{\sigma}{\Gamma}$ then $\inden{\Gamma'}{[\sigma]M}{A}$.
\end{description}

Therefore, we can conclude that if a term $M$ has type $A$ then $M$ is strongly normalizing and its reduction is finite, choosing $\sigma$ to be the identity substitution.
% \\[1em]
% We remark first, that all variables are in the semantic type $A$ and variables are strongly normalizing, i.e. they are already in normal form.

% % \begin{lemma}~\\
%   \begin{itemize}
%   \item If $\Gamma \vdash x : A$ then $\Gamma \models x : A$
%   \item If $\Gamma \vdash x : A$ then $(\Gamma \vdash x) \in \SN$.
%   \end{itemize}

% \end{lemma}

% These are of course statements we need to prove.


\documentclass[10pt,a4paper]{article}
\title{Bellman-Ford}
\date{}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
% For algorithms
\usepackage[linesnumbered,ruled,lined,boxed,commentsnumbered]{algorithm2e}

\usepackage{titling}

\setlength{\droptitle}{-10em}

\begin{document}
\maketitle

\begin{algorithm}[H]
	\KwData{A weighted graph $G(V,E)$ with weight function $W : E \rightarrow R$ and the source vertex $s$}
	\KwResult{Distance array $d$ which contains minimum distances from $s$ to all other vertices. If a negative cycle is
	found, then it is reported}
	\BlankLine
	\Begin {
		\tcc{ Initialize distance array}
		\For{$i \leftarrow 1$ to $\mid V \mid$} {
			$d[i] \leftarrow \infty$
		}
		$d[s] \leftarrow 0$

		\BlankLine
		\BlankLine
		\tcc{Relax all edges $\mid V \mid - 1$ times}
		\For{$i \leftarrow 1$ to $\mid V \mid - 1$} {
			\For{each edge $e(u, v) \in E$} {
				RelaxEdge($u$, $v$, $W$)
			}
		}

		\BlankLine
		\BlankLine
		\tcc{Check for negative cycle}
		\For{each edge $e(u, v) \in E$} {
			\If{RelaxEdge($u$, $v$, $W$) $= True$} {
				Report negative cycle
			}
		}
		Return $d$
	}
\caption{Bellman-Ford}
\end{algorithm}

\begin{algorithm}[H]
	\KwData{An edge $e(u, v)$ and weight function $W$}
	\KwResult{Returns true if the edge $e$ is relaxed, else false}
	\BlankLine
	\Begin {
		\If{$d[u] + W(u, v) < d[v]$}{
			$d[v] \leftarrow d[u] + W(u, v)$\\
			Return True
		}

		Return False
	}
\caption{RelaxEdge}
\end{algorithm}

\section{Proof of Correctness}
	\subsection{Invariant}

	\subsection{Initialization}

	\subsection{Maintenance}

	\subsection{Termination}
\end{document}