\documentclass{article}
\usepackage{simplewick}
\usepackage{amsmath,mathtools,amssymb}
\usepackage{graphicx}
\usepackage{gensymb}
\usepackage{verbatim}
\usepackage{cancel}
\usepackage{mathrsfs}
\usepackage{bbm}
\usepackage{braket}
\usepackage{xcolor}
\definecolor{orange}{RGB}{255,127,0}
\usepackage{verbatim}
\usepackage[margin=1.0in]{geometry}
\newcommand{\ol}{\overline}
\newcommand{\ctr}{\bcontraction}
\newcommand{\ve}{\varepsilon}
\newcommand{\ap}{\ensuremath{a_p} }
\newcommand{\dg}{\ensuremath{^\dagger} }
\newcommand{\cd}{\ensuremath{\cdots} }
\newcommand{\apd}{\ensuremath{a_p^\dagger} }
\def\*#1{\mathbf{#1}}
\def\co#1{{\color{orange}#1}}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\title{Lecture 3.3: Wick's Theorem}
\date{February 17$^{\text{th}}$, 2020}
\begin{document}
\maketitle
\noindent
\section{A note on permutations}
We will use the following to denote permutations on a set of indices:
\[ x_{R_1} \cd x_{R_N} = (-1)^R x_1 \cd x_N \]
R is the permutation of the set $\{x_1, \cd, x_N\}$, and belongs to the permutation group $S_N$ ($R \in S_N$).
It can be represented as:
\begin{equation*}
R =
\begin{pmatrix}
1 & 2 & \cdots & N  \\
R_1& R_2& \cdots & R_N \\
\end{pmatrix}
\end{equation*}
The first row corresponds to the original indices while the second row corresponds to the permuted indices.
R can also be written in cyclic notation to easily determine the sign of the permutation. It is easiest to show this with an example: \\ \\
\[ x_2 x_3 x_1 x_5 x_4  = (-1)^R x_1 x_2 x_3 x_4 x_5 \]
Permutation R can be expressed as:
\begin{equation*}
R =
\begin{pmatrix}
1 & 2 &3 & 4 & 5  \\
2 & 3 & 1 & 5 & 4 \\
\end{pmatrix}
\end{equation*}
where the permuted indices $R_1$ corresponds to index 2 in the original string and so on. \\ \\
To determine the cyclic permutations, we pick one index and follow the permutations until we get back to that same index.
We can see that here, index 1 turns to 2, index 2 turns to 3, and index 3 turns to 1.
Thus, (123) represents a cyclic permutation.
In the same way, index 4 becomes index 5, and index 5 becomes index 4, and (45) represents another cyclic permutation.
\\ \\
In cyclic notation, we can write:
\begin{equation*}
R =
\begin{pmatrix}
1 & 2 &3 & 4 & 5  \\
2 & 3 & 1 & 5 & 4 \\
\end{pmatrix}
= (123)(45)
\end{equation*}
An odd number of elements in a particular cyclic permutation corresponds to a positive sign (+) for the permutation.
An even number of elements in a particular cyclic permutation corresponds to a negative sign ($-$) for the permutation.
In the above example, we have one cyclic permutation with a positive sign and one cyclic permutation with a negative sign, so the overall sign of the permutation is negative.
We thus have:
\[ x_2 x_3 x_1 x_5 x_4  = -x_1 x_2 x_3 x_4 x_5 \]
\\
Here is another example where one index does not change its place:
\[ x_1 x_3 x_2 x_5 x_4  = (-1)^R x_1 x_2 x_3 x_4 x_5 \]
\begin{equation*}
R =
\begin{pmatrix}
1 & 2 &3 & 4 & 5  \\
1 & 3 & 2 & 5 & 4 \\
\end{pmatrix}
= (1)(23)(45) = (+)(-)(-) = (+)
\end{equation*}
\[ x_1 x_3 x_2 x_5 x_4  =  x_1 x_2 x_3 x_4 x_5 \]
Cyclic permutations can also be referred to as ``cycles".
\section{Prerequisites to Wick's Theorem}

Last time, we determined that much of the math we have to solve boils down to evaluating expectation values of
strings of creation and annihilation operators in the true vacuum.
Using anti-communtation rules to do this was tedious, and we wanted to find a more efficient way.
Our answer is to use Wick's Theorem.
Before introducing Wick's Theorem, we need to introduce three prerequisite concepts: normal products, contractions, and normal products with contractions.

\subsection{Normal Products}
A normal product is a product of creation and annihilation operators where all the creation operators are to the left of the expression.
We say that a product in which all creation operators are to the left is ``normal ordered".
We denote a normal product of a string of operators $x_1 \cd x_m$ (where $x_i$ can represent a creation or annihilation operator) with the notation ``$n[x_1 \cd x_m]$'', and formally define it as:
\[n[x_1 \cd x_m]= (-1)^R a_{R_1}\dg \cd a_{R_j}\dg a_{R_{j+1}} \cd a_{R_m} \]
\[
R =
\begin{pmatrix}
1 & 2 &\cd & j & j+1 & \cd & m  \\
R_1 & R_2 &\cd & R_j & R_{j+1} & \cd & R_m  \\
\end{pmatrix}
\] \\
The normal product of an empty set is defined to be one:
\[ n[\varnothing] = 1\]

\subsubsection{Example 1}
\[n[a_p\dg a_q a_r \dg] = (-)^R a_p\dg a_r\dg a_q \]\\
\[
R =
\begin{pmatrix}
p & q & r  \\
p & r & q  \\
\end{pmatrix}
= (p)(qr) = (+)(-) = (-)
\] \\
\[n[a_p\dg a_q a_r \dg] = - a_p\dg a_r\dg a_q \]
Equivalently, we can write:
\[n[a_p\dg a_q a_r\dg ] = (-)^R a_r\dg a_p\dg a_q \]\\
\[
R =
\begin{pmatrix}
p & q & r  \\
r & p & q  \\
\end{pmatrix}
= (prq) = (+)
\] \\
\[n[a_p\dg a_q a_r\dg ] =  a_r\dg a_p\dg a_q \]
Thus we see normal products can be written in different ways, which are equivalent due to antisymmetry.
\subsubsection{Example 2}
\[ n[a_p\dg a_q\dg a_r\dg] = a_p\dg a_q\dg a_r\dg \]
Here, the string is already normal ordered, so we can just drop the normal product notation.
\subsubsection{Properties of Normal Products}
There are several properties of normal products that are useful to us:
\begin{enumerate}
\item A normal product of a normal ordered string of operators is just that string of operators:
\[n[a_{1}\dg \cd a_{j}\dg a_{j+1} \cd a_{m} ] = a_{1}\dg \cd a_{j}\dg a_{{j+1}} \cd a_{m}  \]
We note that a string of only creation operators or only annihilation operators are already in normal order.
\item A normal product of a normal product is just the normal product:
\[n[n[x_1 \cd x_m]] = n[x_1 \cd x_m] \]
This is simply a manifestation of property 1.
\item You can freely permute a string of operators, with an appropriate phase factor, as long as it is within the normal ordered form:
\[n[x_{R_1} \cd x_{R_m} ] = (-1)^R n[ x_1 \cd x_m]\]
For example,
\[n[x_2 x_1] = -n[x_1 x_2] \]
\end{enumerate}

\subsection{Contractions of Operators}

We \textit{define} a contraction between 2 operators $x_1$ and $x_2$ where $x_i$ can be either a creation or an annihilation operator, as the quantity:
$$
\ctr{}{x}{{}_1}{x}
x_1 x_2 = x_1x_2 - n[x_1x_2]
$$
We can derive the value of the contraction for various combinations of creation and annihilation operators by evaluating the expression.
We will make use of the properties listed above as well as remembering our anticommutation relations.
We have four cases to consider:
\begin{enumerate}
\item $x_1 = a_p$, $x_2 = a_q$ \\
$$
\ctr{}{a}{{}_p}{a}
a_p a_q = a_p a_q  - n[a_p a_q] = a_p a_q  - a_p a_q  = 0
$$
\item $x_1 = a_p$, $x_2 = a_q\dg$ \\
$$
\ctr{}{a}{{}_p}{a}
a_p a_q\dg = a_p a_q\dg  - n[a_p a_q\dg] = a_p a_q\dg  +  a_q\dg a_p = \delta_{pq}
$$
\item $x_1 = a_p\dg$, $x_2 = a_q$ \\
$$
\ctr{}{a}{{}_p}{a}
a_p\dg a_q = a_p\dg a_q  - n[a_p\dg a_q] = a_p\dg a_q  - a_p\dg a_q  = 0
$$
\item $x_1 = a_p\dg$, $x_2 = a_q\dg$ \\
$$
\ctr{}{a}{{}_p}{a}
a_p\dg a_q\dg = a_p\dg a_q\dg  - n[a_p\dg a_q\dg] = a_p\dg a_q\dg  - a_p\dg a_q\dg  = 0
$$

\end{enumerate}
\subsection{Normal Products with Contractions}
A normal products with contractions inside
\[
\ctr{n[x_1 \cd }{x}{{}_{i_1} \cd x_{i_\lambda} \cd }{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd}{ x}{{}_{i_\lambda} \cd x_{j_1} \cd }{x}
n[x_1 \cd x_{i_1} \cd x_{i_\lambda} \cd x_{j_1} \cd x_{j_\lambda} \cd x_m]
\]
can be rewritten as:
\[
\ctr{n[x_1 \cd }{x}{{}_{i_1} \cd x_{i_\lambda} \cd }{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd}{ x}{{}_{i_\lambda} \cd x_{j_1} \cd }{x}
n[x_1 \cd x_{i_1} \cd x_{i_\lambda} \cd x_{j_1} \cd x_{j_\lambda} \cd x_m]
=
\ctr{(-1)^R}{x}{{}_{i_1} }{x}
\ctr{(-1)^R x_{i_1}x_{j_1} \cd}{x}{{}_{i_\lambda} }{x}
(-1)^R x_{i_1}x_{j_1} \cd x_{i_\lambda} x_{j_\lambda} n[x_{k_1} \cd x_{k_\mu}]
\]
where
\[
R =
\begin{pmatrix}
1 & 2 & \cd & 2\lambda -1 & 2\lambda & 2\lambda + 1&\cd & m  \\
i_1 & j_1 & \cd& i_\lambda & j_\lambda  &k_1 & \cd & k_\mu \\
\end{pmatrix}
\] \\
and the indices $2\lambda + \mu = m$.
In words, a normal product with contractions can be written as a product of contractions outside the normal product multiplied by the uncontracted terms and a phase factor.
It is important to note that when the contractions are taken out, you cannot flip the order of the contraction.
In other words,
\[ n[\ctr{}{x}{{}_p}{x}
x_p x_q ] \neq \pm \ctr{}{x}{{}_q}{x}x_q x_p  \]
\subsubsection{Example 1}
\[\ctr{n[}{a}{{}_p a_q }{a}
\ctr{n[a_p a_q a_r\dg] = (-)^R a}{a}{_p}{a}
n[a_p a_q a_r\dg] = (-1)^R a_p a_r\dg n[a_q] \] \\
\[
R =
\begin{pmatrix}
p & q & r  \\
p & r& q\
\end{pmatrix}
= (p)(qr) = (-)
\] \\
\[\ctr{n[}{a}{{}_p a_q }{a}
\ctr{n[a_p a_q a_r\dg] = -}{a}{{}_p}{a}
n[a_p a_q a_r\dg] = - a_p a_r\dg n[a_q] = -\delta_{pr}a_q \]
\subsubsection{Two tips}
There are two tips for faster evaluation of normal products with contractions. \\ \\
The first tip is that neighboring contractions can be taken out of the normal product without considering the permutation.
By ``neighboring contraction", I mean contractions between operators that are next to each other.
This is because the permutation associated with a neighboring pair is always positive.
For example,
\[
\ctr[2ex]{n[}{a}{{}_p{\color{blue} a_q a_r\dg } a_s}{a}
\ctr{n[a_p }{a}{{}_q}{a}
n[a_p {\color{blue} a_q a_r\dg } a_s a_t\dg a_u\dg] =
\ctr{}{a}{{}_q}{a}
\ctr{{\color{blue} a_q a_r\dg }  n[}{a}{{}_p a_s}{a}
{\color{blue} a_q a_r\dg }  n[a_p a_s a_t\dg a_u\dg] \]
The second tip is that for a \textit{fully contracted} term, meaning that all operators are involved in a contraction,
the phase factor can be obtained by counting the number of intersecting contraction lines $\nu$:
\[(-1)^R = (-1)^\nu\]
For example, the term
$\ctr{n[}{a}{{}_p}{a}
\ctr{n[a_p a_q\dg  }{a}{{}_r }{a}
\ctr{n[a_p a_q\dg  a_r a_s\dg}{a}{{}_t}{a}
n[a_p a_q\dg  a_r a_s\dg a_t a_u\dg] $
has 0 intersecting contraction lines, and will have an overall phase factor of (+1).  \\ \\
The term
$\ctr{n[}{a}{{}_p a_q}{a}
\ctr[2ex]{n[a_p }{a}{{}_q a_r\dg }{a}
\ctr{n[a_p a_q a_r\dg a_s\dg  }{a}{{}_t}{a}
n[a_p a_q a_r\dg a_s\dg a_t a_u\dg] $ has 1 intersection, and will have an overall phase factor of (-1).  \\ \\
The term
$\ctr{n[}{a}{{}_p a_q}{a}
\ctr[2ex]{n[a_p }{a}{{}_q a_r\dg a_s }{a}
\ctr{n[a_p a_q a_r\dg }{a}{{}_s a_t\dg }{a}
n[a_p a_q a_r\dg a_s a_t\dg a_u\dg] $ has 2 intersections, and will have an overall phase factor of (+1). \\ \\
While we will not formally prove why this is true, the general idea is to reorder the string so there are only neighboring contractions.
In order to do that, we have to permute the indices, and see that an intersection of contraction lines is gotten rid of by a permutation of operators (one sign factor).
\\ \\
We will use the following notation to denote a normal product which is fully contracted:
\[n\ol{\ol{[x_1 \cd x_m]}} \]
The above three examples can all be expressed with this notation. \\ \\
If you have a group of fully contracted operators within your normal product, you can take the full group out and use the number of intersecting contraction lines
to determine the permutation associated with taking the group out.  \\ \\
For example, in the term
\[\ctr{n[}{a}{{}_p a_q}{a}
\ctr[2ex]{n[a_p }{a}{{}_q a_r\dg a_s }{a}
\ctr{n[a_p a_q a_r\dg }{a}{{}_s a_t\dg }{a}
\ctr{n[a_p a_q a_r\dg a_s a_t\dg a_u\dg a_v\dg}{a}{{}_w a_x}{a}
n[a_p a_q a_r\dg a_s a_t\dg a_u\dg a_v\dg a_w a_x a_y\dg] \]
the first six operators are fully contracted, and has an overall phase factor of (+) because there are 2 intersections.
As a result, we can take it out of the normal product:
\[\ctr{n[}{a}{{}_p a_q}{a}
\ctr[2ex]{n[a_p }{a}{{}_q a_r\dg a_s }{a}
\ctr{n[a_p a_q a_r\dg }{a}{{}_s a_t\dg }{a}
\ctr{n[a_p a_q a_r\dg a_s a_t\dg a_u\dg a_v\dg}{a}{{}_w a_x}{a}
n[{\color{blue} a_p a_q a_r\dg a_s a_t\dg a_u\dg} a_v\dg a_w a_x a_y\dg] =
\ctr{}{a}{{}_p}{a}
\ctr{a_p a_r\dg }{a}{{}_q }{a}
\ctr{a_p a_r\dg a_q a_t\dg  }{a}{{}_s}{a}
\ctr{a_p a_r\dg a_q a_t\dg a_s  a_u\dg n[a_v\dg}{a}{{}_w a_x}{a}
{\color{blue} a_p a_r\dg a_q a_t\dg a_s  a_u\dg }n[a_v\dg a_w a_x a_y\dg]\]
\\ \\
We will use the notation:
\[n\ol{[x_1 \cd x_m]} \]
to represent a generic normal product with some contraction.
\subsection{Matrix elements of normal products with contractions}
Remember that our ultimate goal is to know how to quickly evaluate matrix elements of strings of operators in the vacuum.
We are now ready to prove some rules for determining how a normal ordered string of operators acts in the true vacuum.

\begin{itemize}
\item Rule 1: $n[x_1 \cd x_m]\ket{0} = 0$ unless all $x_1 \cd x_m$ are creation operators \\

Proof: If all operators are creation operators,
\[n[a_{p_1}\dg \cd a_{p_m}\dg]\ket{0} = a_{p_1}\dg \cd a_{p_m}\dg\ket{0} = \ket{\Phi_{p_1 \cd p_m}} \neq 0\]

If at least one $x_i$ is an annihilation operator, it will be the rightmost term by the definition of the normal product, and will annihilate the vacuum.
The overall result is zero.
\item Rule 2: $\braket{0 | n[x_1 \cd x_m] | 0} = 0$ for  $m \geq 1$ \\

Proof: If all operators are creation operators, they will annihilate the vacuum because
\[(a_p\ket{0})\dg = \bra{0}a_p\dg = 0\]
If one or more operators are annihilation operators, they will be on the right by the definition of the normal product and annihilate the vacuum.
\item Rule 3. $\ctr{n[x_1 \cd }{x}{{}_{i_1} \cd x_{i_\lambda} \cd }{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd}{ x}{{}_{i_\lambda} \cd x_{j_1} \cd }{x}
n[x_1 \cd x_{i_1} \cd x_{i_\lambda} \cd x_{j_1} \cd x_{j_\lambda} \cd x_m] \ket{0} = 0$ if there is at least 1 uncontracted annihilator among operators $x_1 \cd x_m$.  \\

Proof:
\[
\ctr{n[x_1 \cd }{x}{{}_{i_1} \cd x_{i_\lambda} \cd }{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd}{ x}{{}_{i_\lambda} \cd x_{j_1} \cd }{x}
n[x_1 \cd x_{i_1} \cd x_{i_\lambda} \cd x_{j_1} \cd x_{j_\lambda} \cd x_m] \ket{0}
=
\ctr{(-1)^R}{x}{{}_{i_1} }{x}
\ctr{(-1)^R x_{i_1}x_{j_1} \cd}{x}{{}_{i_\lambda} }{x}
(-1)^R x_{i_1}x_{j_1} \cd x_{i_\lambda} x_{j_\lambda} n[x_{k_1} \cd x_{k_\mu}] \ket{0}
\]
By Rule 1, $n[x_{k_1} \cd x_{k_\mu}] \ket{0} = 0$ unless all operators $x_{k_1} \cd x_{k_\mu}$ are creation operators.
\item Rule 4. $\braket{0| \ctr{n[x_1 \cd }{x}{{}_{i_1} \cd x_{i_\lambda} \cd }{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd}{ x}{{}_{i_\lambda} \cd x_{j_1} \cd }{x}
n[x_1 \cd x_{i_1} \cd x_{i_\lambda} \cd x_{j_1} \cd x_{j_\lambda} \cd x_m] |0} = 0$ unless all operators are contracted.
In other words, only a fully contracted normal product ($n\ol{\ol{[x_1 \cd x_m] }}$) gives a nonzero expectation value in the true vacuum. \\

Proof: This is easily see as an application of Rule 2. Contractions of operators reduces to a number which can be pulled out of the expectation value.The only case where the expectation value is nonzero is one in which there is no operators left in the normal product, $\braket{0 | n[\varnothing] | 0} \neq 0$ \\

As a consequence of Rule 4, a vacuum expectation value of any normal product with contractions will be zero if there are a odd number of operators.
\end{itemize}
We now know how to quickly evaluate matrix elements of a normal ordered string, and a normal ordered string with contractions.
Next, we need to know how to quickly put any string in normal order so we can take advantage of these shortcuts.
This is what Wick's theorem provides us.

\section{Wick's Theorem}
We will first start by seeing what happens if we put specific strings of operators in normal order just by applying anticommutation relations.  \\
Putting a product of 2 operators in normal order is a direct application of anticommuntation relations:
\[a_p a_q\dg = \delta_{pq} - a_q\dg a_p \]
The first term, $\delta_{pq}$, can be re-expressed as $\ctr{}{a}{{}_p}{a}a_p a_q\dg$, as shown in Section 2.3.
We can equivalently write $n[\ctr{}{a}{{}_p}{a}a_p a_q\dg]$.
You will show that $\ctr{}{a}{{}_p}{a}a_p a_q\dg = n[\ctr{}{a}{{}_p}{a}a_p a_q\dg]$ in the exercises.
The second term is simply the normal product $n[a_p a_q\dg]$.
Thus, we can write (switching the order of the first and second terms):
\[a_p a_q\dg = n[a_p a_q\dg] + n[\ctr{}{a}{{}_p}{a}a_p a_q\dg] \]
\\
Let's try with a product of 3 operators, $a_p a_q\dg a_r\dg$:
\begin{align*}
a_p a_q\dg a_r\dg &= (\delta_{pq} - a_q\dg a_p)a_r\dg \\
&= \delta_{pq}a_r\dg  - a_q\dg a_p a_r\dg \\
& = \delta_{pq}a_r\dg - a_q\dg (\delta_{pr} - a_r\dg a_p)  \\
& = \delta_{pq}a_r\dg - \delta_{pr} a_q\dg +  a_q\dg a_r\dg a_p  \\
\end{align*}
Rewriting the terms in a similar way as for the product of 2 operators, we obtain:
\[a_p a_q\dg a_r\dg  = n[a_p a_q\dg a_r\dg ] + n[\ctr{}{a}{{}_p}{a} a_p a_q\dg a_r\dg ]  + n[\ctr{}{a}{{}_p a_q\dg}{a} a_p a_q\dg a_r\dg ] \]
In these two examples, we observe that the products of the creation and annihilations operators could be expressed as its normal product plus all possible contractions of its normal product form.
Wick's theorem simply generalizes this observation to any string of creation and annihilation operators.
Formally defined, Wick's theorem states:
\begin{align*}
x_1 \cd x_m &= n[x_1 \cd x_m ]  \\
&+ \sum_{i < j} \ctr{n[x_1 \cd}{x}{{}_i \cd }{x} n[x_1 \cd x_i \cd x_j\cd  x_m] \\
&+ \sum_{\substack{i_1 < j_1,  i_2 < j_2 \\ i_1 < i_2, j_1 \neq j_2}}
\ctr{n[x_1 \cd}{x}{{}_{i_1} \cd x_{i_2} \cd}{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd }{x}{{}_{i_2} \cd x_{j_1} \cd}{x}
n[x_1 \cd x_{i_1} \cd x_{i_2} \cd x_{j_1} \cd x_{j_2} \cd x_m ]  \\
&+ \cd \\
&+ \sum_{f.c.} n \ol{\ol{[x_1 \cd x_m]  }}
\end{align*}
where ``f.c." stands for fully contracted, and the last term is the sum of all fully contracted terms.
In words, a string of operators can be written as its normal product plus all contractions of the normal product.
We will adopt a shorthand notation for expressing all possible contractions of the normal product and write Wick's theorem as:
\[x_1 \cd x_m = n[x_1 \cd x_m ]  + \sum_{a.c.} n\ol{[x_1 \cd x_m ]} \]\\
where `a.c.' stands for `all possible contractions' and $n\ol{[x_1 \cd x_m ]}$ is just representative of some general normal order product with contractions.
\\ \\
Let's explicitly write out Wick's theorem for a general product of 4 operators for a more concrete example:
\begin{align*}
x_1x_2x_3x_4 &= n[x_1x_2x_3x_4 ] \\
&+n[ \ctr{}{x}{{}_1}{x} x_1x_2x_3x_4 ] + n[ \ctr{}{x}{{}_1x_2}{x} x_1x_2x_3x_4 ] + n[ \ctr{}{x}{{}_1x_2 x_3}{x} x_1x_2x_3x_4 ]
+ n[ \ctr{x_1}{x}{{}_2}{x} x_1x_2x_3x_4 ] +  n[ \ctr{x_1}{x}{{}_2 x_3}{x} x_1x_2x_3x_4 ] + n[ \ctr{x_1 x_2}{x}{{}_3}{x} x_1x_2x_3x_4 ] \\
&+ n[ \ctr{}{x}{{}_1}{x}  \ctr{x_1 x_2}{x}{{}_3}{x} x_1x_2x_3x_4 ]
+ n[ \ctr{}{x}{{}_1x_2}{x}  \ctr[2ex]{x_1}{x}{{}_2 x_3}{x} x_1x_2x_3x_4 ]
+ n[ \ctr{x_1}{x}{{}_2}{x} \ctr[2ex]{}{x}{{}_1x_2 x_3}{x}      x_1x_2x_3x_4 ]
\end{align*}
\\
Wick's theorem is proved generally in the next set of lecture notes.

\subsection{Generalized Wick's Theorem}
In some cases, substrings of operator strings are already in the normal product form.
This will allow us to simplify the terms we need to consider for Wick's theorem. \\ \\
Let's begin with an example:
\[x_1 n[x_2 x_3] \]
Wick's theorem for $x_2 x_3$ is
\[ x_2 x_3 = n[x_2 x_3] +   n[\ctr{}{x}{{}_2}{x} x_2 x_3] \]
We can rearrange this as:
\[n[x_2 x_3]  = x_2 x_3  - n[\ctr{}{x}{{}_2}{x} x_2 x_3]  \]
We can substitute this into our original expression:
\begin{align*}
x_1 n[x_2 x_3] &= x_1 (x_2 x_3  - n[\ctr{}{x}{{}_2}{x} x_2 x_3] ) \\
&=  x_1 x_2 x_3 - x_1n[\ctr{}{x}{{}_2}{x} x_2 x_3] \\
&= x_1 x_2 x_3- x_1\ctr{}{x}{{}_2}{x} x_2 x_3 \\
\end{align*}
We can now do a Wick expansion for $x_1x_2x_3$ and use properties of normal products to rearrange the fourth term:
\begin{align*}
&= {\color{blue} n[x_1x_2x_3] + n[\ctr{}{x}{{}_1}{x} x_1 x_2 x_3] +n[\ctr{}{x}{{}_1 x_2}{x} x_1 x_2 x_3] + n[\ctr{x_1}{x}{{}_2}{x} x_1 x_2 x_3] }  - x_1\ctr{}{x}{{}_2}{x} x_2 x_3 \\
&=   n[x_1x_2x_3] + n[\ctr{}{x}{{}_1}{x} x_1 x_2 x_3] +n[\ctr{}{x}{{}_1 x_2}{x} x_1 x_2 x_3] + \co{\ctr{}{x}{{}_2}{x} x_2 x_3 n[x_1]}   - x_1\ctr{}{x}{{}_2}{x} x_2 x_3 \\
&= n[x_1x_2x_3] + n[\ctr{}{x}{{}_1}{x} x_1 x_2 x_3] +n[\ctr{}{x}{{}_1 x_2}{x} x_1 x_2 x_3] + \co{x_1\ctr{}{x}{{}_2}{x} x_2 x_3  }  - x_1\ctr{}{x}{{}_2}{x} x_2 x_3 \\
&=  n[x_1x_2x_3] + n[\ctr{}{x}{{}_1}{x} x_1 x_2 x_3] +n[\ctr{}{x}{{}_1 x_2}{x} x_1 x_2 x_3]
\end{align*}
We observe that the contraction between the operators originally in normal ordered form cancel out in the final expression.
\\ \\
This is an example of the generalized Wick's theorem, which formally states:
$$x_1 \cd x_m = n[x_1 \cd x_m ]  + \sum_{a.c.} {}' n\ol{[x_1 \cd x_m ]} $$
where $\sum_{a.c.} {}' $ denotes skipping contractions of operators that originated from the same normal ordered group.
\\ \\
Thus, we see it is to our benefit to have as many operators as we can in normal ordered form because then we do not have to consider contractions between the normal ordered operators.
The generalized Wick's theorem is proved in the next set of lecture notes.

\subsection{Expectation values with Wick's theorem }
In Section 2.4 we proved some rules for quickly evaluating normal products or normal products with contractions acting in the true vacuum.
We have now introduced Wick's theorem (WT), which is a clever bookkeeping method to express any product of operators as normal products and normal products with contractions.
We will now apply WT with the rules developed in Section 2.4 to start seeing how we can take advantage of WT when evaluating matrix elements of operator strings.
\\ \\
We list the four previous rules here for easy reference:
\begin{itemize}
\item Rule 1: $n[x_1 \cd x_m]\ket{0} = 0$ unless all $x_1 \cd x_m$ are creation operators \\
\item Rule 2: $\braket{0 | n[x_1 \cd x_m] | 0} = 0$ for  $m \geq 1$ \\
\item Rule 3. $\ctr{n[x_1 \cd }{x}{{}_{i_1} \cd x_{i_\lambda} \cd }{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd}{ x}{{}_{i_\lambda} \cd x_{j_1} \cd }{x}
n[x_1 \cd x_{i_1} \cd x_{i_\lambda} \cd x_{j_1} \cd x_{j_\lambda} \cd x_m] \ket{0} = 0$ if there is at least 1 uncontracted annihilator among operators $x_1 \cd x_m$.  \\
\item Rule 4. $\braket{0| \ctr{n[x_1 \cd }{x}{{}_{i_1} \cd x_{i_\lambda} \cd }{x}
\ctr[2ex]{n[x_1 \cd x_{i_1} \cd}{ x}{{}_{i_\lambda} \cd x_{j_1} \cd }{x}
n[x_1 \cd x_{i_1} \cd x_{i_\lambda} \cd x_{j_1} \cd x_{j_\lambda} \cd x_m] |0} = 0$ unless all operators are contracted.
A vacuum expectation value of any normal product with contractions will be zero if there are a odd number of operators. \\
\end{itemize}

We can use Rules 1--4 in conjunction with Wick's theorem to develop some more rules:

\begin{itemize}
\item Rule 5 $\braket{0 | x_1 \cd x_{2m + 1} | 0} = 0 $ \\

Proof:
\[\braket{0 | x_1 \cd x_{2m + 1} | 0}   =  \braket{0 | n[x_1 \cd x_{2m + 1}] | 0}  +  \sum_{a.c.} \braket{0 | n\ol{[x_1 \cd x_{2m + 1}]} | 0}  \]
The first term is zero by Rule 2 and the second term is zero by Rule 4

 \item Rule 6 $\braket{0 | x_1 \cd x_{2m } | 0} = \sum_{f.c.} \braket{0 | n\ol{\ol{ [x_1 \cd x_{2m }]}}|0} = \sum_{f.c.} (-1)^R \ctr{}{x}{{}_{i_1}}{x}  x_{i_1} x_{j_1} \cd \ctr{}{x}{{}_{i_m}}{x} x_{i_m} x_{j_m}$\\

\begin{equation*}
R =
\begin{pmatrix}
1 & 2 &\cd  & 2m - 1 & 2m  \\
i_1 & j_1 & \cd  & i_m & j_m \\
\end{pmatrix}
\end{equation*}

Proof:
\[\braket{0 | x_1 \cd x_{2m} | 0}   =  \braket{0 | n[x_1 \cd x_{2m}] | 0}  +  \sum_{a.c.} \braket{0 | n\ol{[x_1 \cd x_{2m}]} | 0}  \]
The first term is 0 by Rule 2 and the second term is $ \sum_{f.c.} \braket{0 | n\ol{\ol{ [x_1 \cd x_{2m }]}}|0}$ by Rule 4.
\[ \sum_{f.c.} \braket{0 | \ol{\ol{ n[x_1 \cd x_{2m }]}}|0} =  \sum_{f.c.} (-1)^R  \ctr{}{x}{{}_{i_1}}{x}  x_{i_1} x_{j_1} \cd \ctr{}{x}{{}_{i_m}}{x} x_{i_m} x_{j_m} \braket{0 | n[\varnothing] | 0} = \sum_{f.c.} (-1)^R \ctr{}{x}{{}_{i_1}}{x}  x_{i_1} x_{j_1} \cd \ctr{}{x}{{}_{i_m}}{x} x_{i_m} x_{j_m} \]

\item Rule 7: $x_1 \cd x_m \ket{0} = \sum\limits_{annihilator f.c.} n\ol{[x_1 \cd x_m] }\ket{0} $
where ``annihilator f.c" denotes all contractions with the annihilation operator fully contracted.\\

Proof:
\[x_1 \cd x_m \ket{0} = n[x_1 \cd x_m] \ket{0} + \sum_{a.c.} n\ol{[x_1 \cd x_m ]} \ket{0} \]
The first term is 0 unless it is all creation operators by Rule 1, and the second is 0 unless all annihilation operators are contracted by Rule 3.
\end{itemize}
It is not important to remember which rule you are using when applying Wick's theorem to solve problems.
Rather, we are simply listing the rules to document the important consequences of Wick's theorem that allow us to take shortcuts.
As long as you understand Wick's theorem and how we obtained the rules, you should be able to naturally apply them to problems.

\section{Derivation of Slater's first rule using Wick's Theorem}

We showed in class that using anticommutation relations to derive Slater's first rule was too much work.
We could only show that Slater's rule is true for Slater determinants with a few spin orbitals, but could not prove it generally without spending a lot of tedious time.
Now, with Wick's theorem, we can prove Slater's first rule generally.
\[\braket{\Phi_{p_1 \cd p_N} | \sum_{pq} h_{pq} a_p^\dagger a_q  +  \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} a\dg_{p}a\dg_{q} a_s a_r  | \Phi_{p_1 \cd p_N}} = \sum_i h_{ii} + \frac{1}{2}\sum_{ij} \braket{ij || ij} \]

\subsection{One-body operator}
\[\braket{{\color{orange} \Phi_{p_1 \cd p_N} } | \sum_{pq}   h_{pq}{\color{blue}  a_p^\dagger a_q } | {\color{red} \Phi_{p_1 \cd p_N}}} =
\sum_{pq}   h_{pq} \braket{ 0| {\color{orange} a_{p_N} \cd a_{p_1} } {\color{blue} a_p^\dagger a_q } {\color{red} a_{p_1}\dg \cd a_{p_N}\dg }| 0} \]
We know from Wick's theorem that the only nonzero terms will be the fully contracted terms.
Furthermore, we know that we do not have to consider contractions within normal ordered groups.
Thus, we do not consider contractions within the terms in blue, orange, or red, but only contractions between the different colors.  \\ \\
$ {\color{blue} a_p^\dagger}$ will only form nonzero contractions with ${\color{orange} a_{p_N} \cd a_{p_1} } $, and
$ {\color{blue} a_q }$ will only form nonzero contractions with ${\color{red} a_{p_1}\dg \cd a_{p_N}\dg }$.
After forming those two contractions, the remaining terms in orange and red have to form contractions with each other.
However, the only nonzero contractions that they can form are between terms with the same indices ($\ctr{}{a}{{}_p}{a} a_p a_q\dg =  \delta_{pq}$)
This means that $ {\color{blue} a_p^\dagger}$ and  $ {\color{blue} a_q }$ can only form nonzero contractions if their respective orange and red contraction partners have the same indices as each other.
\\ \\
To summarize, the only terms in the expectation value that does not vanish are ones in which the operators in blue are contracted with orange and red operators with the same indices (${\color{orange} a_{p_i} } $ and
${\color{red} a_{p_i}\dg}$), and the remaining orange and red operators form contractions between operators with the same indices. There will be N contractions that can be formed, since the operators in blue can form
contractions with any operators in the red and orange set as long as the red and orange operators have the same indices.  \\ \\
We can express this in the following way:
\[\braket{\Phi | \hat{O}_1 | \Phi} = \sum_{pq}   h_{pq} \sum_i^N \braket{0|
\ctr{a_{p_N} \cd}{a}{{}_{p_i} \cd  a_{p_1} }{a}
\ctr{{\color{orange} a_{p_N} \cd a_{p_i} \cd  a_{p_1} } a_p^\dagger}{a}{{}_q a_{p_1}\dg \cd}{a}
\ctr[2ex]{ a_{p_N} \cd a_{p_i} \cd }{a}{{}_{p_1}  a_p^\dagger a_q }{a}
\ctr[3ex]{}{a}{{}_{p_N} \cd a_{p_i} \cd  a_{p_1}{\color{blue} a_p^\dagger a_q } a_{p_1}\dg \cd a_{p_i}\dg \cd}{a}
{\color{orange} a_{p_N} \cd a_{p_i} \cd  a_{p_1} } {\color{blue} a_p^\dagger a_q } {\color{red} a_{p_1}\dg \cd a_{p_i}\dg \cd a_{p_N}\dg } |0} \]
We notice 2 things:
\begin{enumerate}
\item The number of intersecting contraction lines will always be even, and so the phase factor to move all contractions out of the expectation value is positive.
\item The contractions $\ctr{}{a}{{}_p}{a} {\color{orange} a_{j}}{\color{red} a_j\dg }=  \delta_{jj}$ will collapse to products of 1 for all j.
\end{enumerate}
This means we are left with:
\begin{align*}
\braket{\Phi | \hat{O}_1 | \Phi} &= \sum_i^N  \sum_{pq}   h_{pq} \delta_{p p_i}   \delta_{q p_i}  \braket{0| 0} \\
&= \sum_i^N h_{p_i p_i}  \quad \text{or just }\\
&= \sum_i^N h_{i i}
\end{align*}

\subsection{Two-body operator }
\[\braket{{\color{orange} \Phi_{p_1 \cd p_N} } |  \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} {\color{blue}  a_p\dg a_q\dg a_s a_r } | {\color{red} \Phi_{p_1 \cd p_N}}} =
 \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} \braket{ 0| {\color{orange} a_{p_N} \cd a_{p_1} } {\color{blue} a_p\dg a_q\dg a_s a_r} {\color{red} a_{p_1}\dg \cd a_{p_N}\dg }| 0} \]
In a similar manner as before, we are limited in the nonzero contractions we can form.
Operators  ${\color{blue}  a_s}$ and ${\color{blue}  a_r}$ can form contractions with ${\color{red} a_{p_i}\dg } $ and ${\color{red} a_{p_j}\dg}$,
and operators $ {\color{blue}  a_p\dg}$ and ${\color{blue}  a_q\dg}$ can form contractions with  $ {\color{orange} a_{p_i} }$ and ${\color{orange} a_{p_j}}$.
There are four total combinations of contractions between these 8 operators.
The remaining uncontracted operators will form contractions between operators with the same indices and collapse to products of 1.
We will write the four types of contractions that can formed (contractions between red and orange operators assumed and not written explicitly):
\begin{align*}
\braket{{\color{orange} \Phi_{p_1 \cd p_N} } | \hat{O}_2  | {\color{red} \Phi_{p_1 \cd p_N}}} &=
 \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} \sum_{i < j} \braket{ 0|
 \ctr{  {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg a_s }{a}{{}_r \cd }{a}
 \ctr{ \cd a_{p_j} \cd }{a}{{}_{p_i}  \cd  }{ }
 \ctr[2ex]{ {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg}{a}{{}_s a_r \cd  a_{p_i}\dg \cd}{a}
 \ctr[2ex] {\cd}{a}{{}_{p_j} \cd a_{p_i} \cd a_p\dg}{}
 {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } {\color{blue} a_p\dg a_q\dg a_s a_r} {\color{red}\cd  a_{p_i}\dg \cd a_{p_j}\dg \cd }| 0} \\
 &+  \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} \sum_{i < j} \braket{ 0|
 \ctr{  {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg a_s }{a}{{}_r \cd }{a}
  \ctr[2ex]{ {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg}{a}{{}_s a_r \cd  a_{p_i}\dg \cd}{a}
 \ctr{ \cd a_{p_j} \cd }{a}{{}_{p_i} \cd a_p\dg  }{ }
 \ctr[2ex] {\cd}{a}{{}_{p_j} \cd a_{p_i}  \cd }{}
 {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } {\color{blue} a_p\dg a_q\dg a_s a_r} {\color{red}\cd  a_{p_i}\dg \cd a_{p_j}\dg \cd }| 0} \\
 &+  \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} \sum_{i < j} \braket{ 0|
 \ctr{  {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg a_s }{a}{{}_r \cd  a_{p_i}\dg \cd }{a}
  \ctr[2ex]{ {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg}{a}{{}_s a_r \cd }{a}
 \ctr{ \cd a_{p_j} \cd }{a}{{}_{p_i}  \cd  }{ }
 \ctr[2ex] {\cd}{a}{{}_{p_j} \cd a_{p_i} \cd a_p\dg}{}
 {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } {\color{blue} a_p\dg a_q\dg a_s a_r} {\color{red}\cd  a_{p_i}\dg \cd a_{p_j}\dg \cd }| 0} \\
 &+  \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} \sum_{i < j} \braket{ 0|
 \ctr{  {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg a_s }{a}{{}_r \cd  a_{p_i}\dg \cd }{a}
  \ctr[2ex]{ {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } a_p\dg a_q\dg}{a}{{}_s a_r \cd }{a}
 \ctr{ \cd a_{p_j} \cd }{a}{{}_{p_i} \cd a_p\dg  }{ }
 \ctr[2ex] {\cd}{a}{{}_{p_j} \cd a_{p_i}  \cd }{}
 {\color{orange} \cd a_{p_j} \cd a_{p_i} \cd } {\color{blue} a_p\dg a_q\dg a_s a_r} {\color{red}\cd  a_{p_i}\dg \cd a_{p_j}\dg \cd }| 0} \\
 &=  \frac{1}{2}  \sum_{pqrs} \braket{pq | rs} \sum_{i < j} \left[ \delta_{p p_i} \delta_{q p_j} \delta_{r p_i} \delta_{s p_j}
 - \delta_{p p_j} \delta_{q p_i} \delta_{r p_i} \delta_{s p_j}
 - \delta_{p p_i} \delta_{q p_j} \delta_{r p_j} \delta_{s p_i}
 + \delta_{p p_j} \delta_{q p_i} \delta_{r p_j} \delta_{s p_i}
 \right]  \\
 &=  \frac{1}{2}\sum_{i < j} \left[  \braket{p_i p_j | p_i p_j}  - \braket{p_j p_i | p_i p_j}  - \braket{p_i p_j | p_j p_i} + \braket{p_j p_i | p_j p_i}  \right] \\
 &= \frac{1}{2}  \sum_{i < j} 2 \left[  \braket{p_i p_j | p_i p_j}  - \braket{p_i p_j | p_j p_i} \right] \\
  &= \frac{1}{2} \sum_{i j} \frac{1}{2} (2) \left[  \braket{p_i p_j | p_i p_j}  - \braket{p_i p_j | p_j p_i} \right] \\
  &=  \frac{1}{2} \sum_{i j}  \braket{p_i p_j || p_i p_j}   \quad \text{or just }\\
&=  \frac{1}{2} \sum_{i j}  \braket{ij || ij}
\end{align*}

%We are still not quite where we want to be in terms of quickly and efficiently evaluating matrix elements of operator strings.
%The derivation of Slater's rules still took us two pages.
%Next, we will find ways to

% 3_Particle_Hole_a:
%\section{Particle-Hole Formalism}
%\subsection{Motivating the particle-hole formalism}
%\subsection{Normal Products}
%\subsection{Contractions of Operators}
%\subsection{Normal Products with Contractions}
%\subsection{Wick's Theorem and generalized Wick's Theorem}

%(at the end have a change comparing quantities in the true vs fermi vacuum
%CI stuff - relate the grid to the overlap of SD is SD of overlaps stuff?
% 3_Particle_Hole_b:
%\section{$\Phi$--Normal ordered Hamiltonian}
%\section{Derivation of Slater's first rule in the Fermi vacuum}
%\section{Derivation of Slater's second rule in the Fermi vacuum}
%\section{Derivation of Slater's third rule in the Fermi vacuum}

%(note about second and third rules - can prove those as well! - what the nonzero tells us about implications of spin orbitals differing)!
%math with expectation value inform which specific value for integral.

%Examples for class lecture: explicitly write wick's thrm for 3, 4 operators
%Keep in mind these are all for true vacuum!

\begin{comment}
Types of problems:
1. Slater's rules
Types of ways to solve:
1. First quantization
2. 2nd quantization in the true vacuum without Wick's theorem
3. 2nd quantization in the true vacuum with Wick's theorem
4. PH formalism with Wick's theorem
5. PH formalism with Wick's theorem and $\Phi$-normal ordered Hamiltonian
\end{comment}
\end{document}


% !TEX root = scombinatorics.tex
\documentclass[scombinatorics.tex]{subfiles}
\begin{document}
\chapter{Three minimax theorems}
\label{minimax}

\def\medrel#1{\parbox[t]{6ex}{$\displaystyle\hfil #1$}}
\def\ceq#1#2#3{\parbox[t]{30ex}{$\displaystyle #1$}\medrel{#2}{$\displaystyle #3$}}

\def\separatore{\hfil o \rule[0.5ex]{4ex}{0.1ex} o \rule[0.5ex]{4ex}{0.1ex} o}

Though apparently unrelated, the three theorems in this chapter can be derived one each other.
We prove them in an arbitrary order.

As evident from the statement, the last two theorems are minimax theorems.
The first theorem less so, hence the title is only approximately correct.

%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
\section{Hall's Marriage Theorem}\label{marriage}

\def\ceq#1#2#3{\parbox[t]{30ex}{$\displaystyle #1$}\medrel{#2}{$\displaystyle #3$}}

Let $\phi(x\,;z)$ be given.
Let $A\subseteq\U$ and $B\subseteq\V$ be finite sets.

We say that $A'\subseteq A$ is a \emph{set of distinct representatives\/} for $\phi(A\,;B)$ if

\ceq{\hfill|\phi(A';b)|\medrel{=}|\phi(a\,;B)|}
{=}
{1}
\quad for every $a,b\in A',B$,

or, in other words, if $\phi(A';B)$ is the graph of a bijection.

\begin{void_thm}[Hall's Marriage Theorem]\label{thm_marriage}
  For every finite $B\subseteq\V$, the following are equivalent
  \begin{itemize}
    \item[1.] $\phi(A\,;B)$ has a set of distinct representatives;

    \item[2.] $\displaystyle|B'|\ \le\ \bigg|\bigcup_{b\in B'}\phi(A\,;b)\bigg|$ for every $B'\subseteq B$.
  \end{itemize}
\end{void_thm}

\begin{proof}
  \textbf{\boldmath(\ssf{1}$\IMP$\ssf{2})}
  The following holds for any set of distinct representatives $A'$ and every set $B'\subseteq B$

  \ceq{\hfill|B'|\medrel{=}\bigg|\bigcup_{b\in B'}\phi(A';b)\bigg|}
  {\subseteq}
  {\bigg|\bigcup_{b\in B'}\phi(A\,;b)\bigg|.}

  \textbf{\boldmath(\ssf{2}$\IMP$\ssf{1})}
  Reason by induction on the cardinality of $B$.
  If $|B|=1$, the claim is clear.
  Now assume $|B|>1$ and consider two cases.

  \begin{itemize}
    \item[a.]
    This is the case when the inequality in \ssf{2} is strict for all nonempty $B'\subset B$.
    Pick any pair $a,b\in A,B$ such that $\phi(a\,;b)$.
    Then $\phi(A\sm\{a\}\,; B\sm\{b\})$ still satisfy \ssf{2}.
    By induction hypothesis, it has a set of distinct representatives $A'$.
    Then $A'\cup\{a\}$ is a set of distinct representatives for $\phi(A\,;B)$.

    \item[b.]
    Suppose instead that for some nonempty $B'\subset B$ the inequality in \ssf{2} holds with equality.
    Define

    \ceq{\hfill A'}
    {=}
    {\bigcup_{b\in B'}\phi(A\,;b)}

    It is clear that \ssf{2} holds for $\phi(A';B')$.
    Below we prove that \ssf{2} also holds for $\phi(A{\sm} A'\,;\,{B\sm} B')$.
    Once this claim is proved, we apply the induction hypothesis to obtain sets of distinct representatives for these two relations and note that their union is a set of distinct representatives for $\phi(A\,;B)$.

    To prove the claim assume that there is a set $B''\,\subseteq\ B\sm B'$ that contradicts \ssf{2}, then

    \ceq{\hfill\bigg|\bigcup_{b\in B''}\phi(A{\sm} A'\,;\,b)\bigg|}
    {<}
    {|B''|.}

    By the definition of $A',B'$

    \ceq{\hfill \bigcup_{b\in B'\cup B''}\phi(A\,;b)}
    {=}
    {\bigcup_{b\in B'}\phi(A\,;b)\ \ \cup\ \ \bigcup_{b\in B''}\phi(A\,;b)}

    \ceq{}
    {=}
    {\phantom{\bigcup_{b\in B'}\phi(A\,;b)}\llap{$A'$\kern4ex}\ \ \cup\ \ \bigcup_{b\in B''}\phi(A\,;b)}

    \ceq{}
    {=}
    {\phantom{\bigcup_{b\in B'}\phi(A\,;b)}\llap{$A'$\kern4ex}\ \ \cup\ \ \bigcup_{b\in B''}\phi(A{\sm} A'\,;b)}

    The two sets above are disjunct, hence

    \ceq{\hfill\bigg|\bigcup_{b\in B'\cup B''}\phi(A\,;b)\bigg|}
    {>}
    {|A'|+|B''|}

    As $|A'|=|B'|$, by the choice of $A',B'$, we obtain that $B'\cup B''$ contradicts the inequality in \ssf{2}.
    This prove the claim and with it the theorem.
  \end{itemize}\vspace*{-4ex}
\end{proof}

%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
\section{K\H{o}nig's Minimax Theorem}\label{Konig}

Let $\phi(x\,;z)$ be given.
Let $A\subseteq\U$ and $B\subseteq\V$ be finite sets.

A \emph{matching\/} of $\phi(A\,;B)$ is a pair of sets $A'\subseteq A$  and $B'\subseteq B$ such that $\phi(A'\,;B')$ is the graph of a bijection between $A'$ and $B'$ in other words

\ceq{\hfill|\phi(A';b)|\medrel{=}|\phi(a\,;B')|}{=}{1}\quad for every $a,b\in A',B'$.

Yet in other words, $A'$ is a set of distinctive representatives for  $\phi(A\,;B')$

We call $|A'|=|B'|$ the cardinality of the matching.
The \emph{matching number} of $\phi(A\,;B)$ is the maximal cardinality of a matching.

Note that is $A'$ is a set of distinct representatives for $\phi(A\,;B)$, then there is a $B'\subseteq B$ such that $A',B'$.
Hence the matching number is less or equal than the cardinality of any set of distinct representatives (if it exists).

A \emph{(vertex) cover\/} of $\phi(A\,;B)$ is a pair of sets $A'\subseteq A$ and $B'\subseteq B$ such that $\phi(A\,;B)$ is contained in $\big(A'\times (B\sm B')\big)\,\cup\, \big((A\sm A')\times B'\big)$. We will mainly use this property as characterized by the easy fact below.

\begin{fact}\label{fact_cover}
   The following are equivalent
   \begin{itemize}
      \item[1.] $A',B'$ is a cover;
      \item[2.] $\phi(A\,;b)\subseteq A'$ for every $b\in B\sm B'$;
      \item[3.] $\phi(a\,;B)\subseteq B'$ for every $a\in A\sm A'$.\QED
   \end{itemize}
\end{fact}

We call $|A'|+|B'|$ the cardinality of the cover.
The \emph{cover number\/} of $\phi(A\,;B)$ is the minimal cardinality of a cover.

\begin{void_thm}[K\H{o}nig's Minimax Theorem]
   For any given  $\phi(A\,;B)$, matching number $=$ cover number.
   That is, the maximal cardinality of a matching equals the minimal cardinality of a cover.
\end{void_thm}

\begin{proof}
  {\boldmath$(\le)$}
  We prove that $|A''|\le|A'|+|B'|$ for every cover $A',B'$ and every matching $A'',B''$.

  As  $\phi(A\,;b)\subseteq A'$ for every $b\in B\sm B'$, in particular we have that $\phi(A'';b)\subseteq A'$ for every $b\in B''\sm B'$.
  By the definition of matching, all these sets $\phi(A'';b)$ are distinct singletons.
  Hence $|B''|-|B'|\le|B\sm B'|\le|A'|$ is clear.

  {\boldmath$(\ge)$}
  Let $A',B'$ be a cover of minimal cardinality.
  We prove that there is a matching of cardinality at least $|A'|+|B'|$.

  We break $\phi(A\,;B)$ into two relations, find a matching of each of these and join them together to obtain a matching of cardinality $\ge|A'|+|B'|$.
  Precisely, first we show that $\phi(A{\sm} A'\,;B')$ has a set of distinct representatives $A_1\subseteq A\sm A'$.
  Hence $A_1,B'$ is a matching.
  Second, we apply the same argument shows that $\phi(A'\,;B{\sm} B')^{\rm op}$ has a  set of distinct representatives $B_2\subseteq B\sm B'$.
  Hence $A',B_1$ is a matching.
  Then $(A_1\cup A'),\ (B'\cup B_1)$ is a matching of  $\phi(A\,;B)$.
  The cardinality of this matching is $|A_1|+|A'|=|B_1|+|A'|=|B'|+|A'|$.

  We use Hall's Marriage Theorem to prove the first claim above.
  The second is proved by the symmetric argument (using \ssf{3} of the fact above in place of \ssf{2}).

  We need to check that $\phi(A{\sm} A'\,;B')$ satisfies \ssf{2} of Theorem~\ref{thm_marriage}.
  Suppose not. Then there is a set $B''\subseteq B'$ such that $|A''|<|B''|$, where

  \ceq{\hfill A''}{=}{\bigcup_{b\in B''}\phi(A{\sm} A',b)}

  Then $(A'\cup A''), (B'\sm B'')$ would be a cover of cardinality $<|A'|+|B'|$.
  This contradicts the minimality of $A',B'$.
\end{proof}

%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%\clearpage
\section{Dilworth's Theorem}\label{shadow}

Dilworth's Theorem is minimax theorem essentially equivalent to K\H{o}nig's Theorem.
To highlight the connection we choose to prove it using K\H{o}nig's Theorem.
Alternatively we could have proved Dilworth's Theorem directly and derived K\H{o}nig's and Hall's Theorem from it.

Let $<$ be a strict partial order on $\U$.
An \emph{antichain\/} is a set $A'\subseteq\U$ such that $a<a'$ for every $a,a'\in A'$. A \emph{chain\/} is a set $A'\subseteq\U$ such that $a<a'\;\vee\ a'<a$ for every distinct $a,a'\in A'$.

\begin{void_thm}[Dilworth's Theorem]
  Let $A\subseteq\U$ be finite.
  The maximal cardinality of an antichain $A'\subseteq A$ equals the minimal cardinality of a partition of $A$ into chains.
\end{void_thm}

\begin{proof}
  {\boldmath$(\le)$}
  We prove that the cardinality of an antichain cannot exceed the cardinality of a partition of $A$ into chains.

  Let $A_1,\dots,A_k$ be a partition of $A$ into chains and let $A'$ be an antichain.
  A chain can contain at most one element of $A'$, hence $|A'|\le k$.

  {\boldmath$(\ge)$}
  Let $A'\subseteq A$ be an antichain of maximal cardinality.
  We prove that there is a partition $A_1,\dots,A_k$ into chains for some $k\le|A'|$.

  %(for uniformity with the notation in K\H{o}nig's Theorem, here we denote by $A'$ the complement of the chain).

  Let $\V$ be a disjoint copy of $\U$.
  Let $f:\U\to\V$ the bijection that maps each element of $\U$ to its copy in $\V$.
  For $a,b\in\U$ such that $a<b$ let $\phi(a\,;fb)$.
  Let $A_1,B_1$ be a cover of $\phi\big(A\,;f[A]\big)$.
  We claim that $A \sm \big(A_1\cup f^{-1}[B_1]\big)$ is an antichain.
  In fact, if $a<b$ then either $a\in A_1$ or $fb\in B_1$, by the definition of cover.
  This proves the claim.

  As $A'$ has maximal cardinality, $|A| - |A'|\le |A_1\cup f^{-1}[B_1]|\le |A_1\cup B_1|$.
  If we choose a over $A_1,B_1$ of minimal cardinality, by K\H{o}nig's Theorem there is a matching $A'',B''$ of cardinality $|A''|\ge |A_1\cup B_1|$. Hence $|A''|\ge |A\sm A'|$.

  We construct a chain-partition of $A$ as follow.
  Pick an element of $a_0\in A''$ and construct the longest possible chain $a_0,b_0,a_1,b_1,\dots,a_m,b_m,a_{m+1}$ where $a_i\in A''$ for all $i\le m$, and $b_i\in B''$ is the (unique) element such that $\phi(a_i\,;b_i)$ and $a_{i+1}\in A$ is the copy of $b_i\in B''$.
  The construction halts at the first $a_{m+1}\not\in A''$.
  Then we start a new chain from some fresh element of $A''$ until the chains $a_0<a_1<\dots<a_m<a_{m+1}$ constructed in this way cover the whole of $A''$.
  Note that these chains are pairwise disjoint.
  Finally, put each element of $A$ not covered by these chains in a chain on its own.

  Notice that the elements of $A''$ belongs to a chain of length at least 2.
  Therefore the number $k$ of chains necessary to cover $A$ is $\le |A|\sm |A''| \le  |A'|$.
\end{proof}

\end{document}
\begin{comment}
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
\section{Shadows}\label{shadow}
\def\ceq#1#2#3{\parbox[t]{29ex}{$\displaystyle #1$}
\medrel{#2}
{$\displaystyle #3$}}

Define the formula

\ceq{\hfill\partial\phi(x\;;\,y,z)}
{=}
{\phi(x\;;\,z)\wedge x{\neq} y.}

It is called the shadow of $\phi(x\;;\,z$).
It defines a relation between $\U$ and $\U\times\V$.
Note that

\ceq{\hfill\partial\phi(x\;;\,y,z)_{a,b\in\U,\V}}
{=}
{\Big\{\phi(A\;;\,b)\sm\{a\}\ :\ a,b\in\U,\V\Big\}.}

The following is sometimes called the local LYM inequality.

\begin{lemma}

   For any $1\le k\le n$

   % \ceq{\hfill\bigg|{A\choose k}\cap\phi(A\;;\,b)_{b\in\V}\bigg|\cdot{n\choose k}^{\kern-.8ex-1}{\kern-1.5ex}}
   % {\le}
   % {\bigg|{A\choose k-1}\cap\partial\phi(A\;;\,a,b)_{a,b\in\U,\V}\bigg|\cdot{n\choose k-1}^{\kern-.8ex-1}{\kern-.8ex}}

   % \ceq{\hfill\bigg|{A\choose k}\cap\phi(A\;;\,b)_{b\in\V}\bigg|\cdot{n\choose k}^{\kern-.8ex-1}{\kern-.8ex}}
   % {\le}
   % {\bigg|{A\choose k-1}\cap\phi(A\sm\{a\}\;;\,b)_{a,b\in\U,\V}\bigg|\cdot{n\choose k-1}^{\kern-.8ex-1}{\kern-.8ex}}

   \ceq{\hfill\Pr{}_k\Big(\phi(A\;;\,b)_{b\in\V}\Big)}
   {\le}
   {\Pr{}_{k-1}\Big(\partial\phi(A\;;\,a,b)_{a,b\in\U,\V}\Big)}

\end{lemma}

\begin{proof}
   Consider the bipartite graph between $A^{(k)}$ and $A^{(k-1)}$ that has an edge between all sets $\phi(A\;;\,b)\in A^{(k)}$ and their respective subsets in $A^{(k-1)}$.
   That is $\phi(A\;;\,b){\sm}\{a\}$ where $a$ is any of the $k$ elements of $\phi(A\;;\,b)$.
   The number of edges of this graph is

   \ceq{\hfill\bigg|{A\choose k}\cap\phi(A\;;\,b)_{b\in\V}\bigg|\cdot k}{}{}

   Each set $\phi(A\;;\,b){\sm}\{a\}\in A^{(k-1)}$ is a node of degree at most $n-k+1$.
   Hence the number of edges of this graph is

   \ceq{}{\le}{\bigg|{A\choose k-1}\cap\partial\phi(A\;;\,a,b)_{a,b\in\U,\V}\bigg|\cdot(n-k+1)}

   To obtained the required inequality it suffice to note that

   \ceq{\hfill{n\choose k}^{\kern-.8ex-1}{\kern-.8ex}\cdot (n-k+1)}{=}{{n\choose k-1}^{\kern-.8ex-1}{\kern-.8ex}\cdot k}

   % \ceq{\hfill\bigg|{A\choose k}\cap\phi(A\;;\,b)_{b\in\V}\bigg|\cdot{n\choose k}^{\kern-.8ex-1}{\kern-.8ex}}
   % {\le}
   % {\bigg|{A\choose k-1}\cap\partial\phi(A\;;\,a,b)_{a,b\in\U,\V}\bigg|\cdot{n\choose k-1}^{\kern-.8ex-1}{\kern-.8ex}}

   % \ceq{\hfill{A\choose k-1}\cap\partial\phi(A\;;\,a,b)_{a,b\in\U,\V}}
   % {\subseteq}
   % {\bigg({A\choose k}\cup{A\choose k-1}\bigg)\cap\phi(A\;;\,b)_{b\in\V}}

   \vskip-3ex
\end{proof}

is the formula that define a relation between $\U$ and $\U\times\V$

\ceq{\hfill\partial^k\phi(x\;;\,z\,y_1\dots y_k)}{=}{\phi(x\;;\,z)\wedge \bigwedge^k_{i=1} x{\neq} y_i.}

\ceq{\hfill\partial^k\phi(A\;;\,b\,a_1\dots a_k)_{b,a_1\dots a_k\in\V\times\U^k}}{=}{\bigcup_{a_1\dots a_k\in A^k}\phi(A\sm\{a_1\dots a_k\}\;;\,b)_{b\in\V}.}

\ceq{\hfill\partial^k\phi(A\;;\,b\,a_1\dots a_k)_{b,a_1\dots a_k\in\V\times\U^k}}{=}{
\Big\{\phi(A\sm\{a_1\dots a_k\}\;;\,b)\: :\ a_1,\dots,a_k\in\U, b\in\V \Big\}.}

$\big(\partial^k\phi(x\;;\,z\,y_1\dots y_k)\big)_{b,a_1\dots a_k\in\V\times\U^k,\, n-k}$

$\phi(A\;;\,b)_{b\in\V,\, k}$

\end{comment}


\section{Conclusion and Discussion}

\subsection{Natural angular frequency}

Although by theory amplitude doesn't affect the period, as the amplitude gets
larger, the negative work done by the frictional force isn't negligible.
Thus, we need to keep the amplitude the same for every test to reduce this
influence factor.

The third measurement of ten periods is obviously smaller than the other three,
which might result from a severely different amplitude.

On the other hand, by measuring 10 times of T, the experimental value of
$\omega_0$ is quite precise (with small deviation).
Still, $u_{10T,r}=0.07\%$, that means our experiment setup works pretty well.

For recommendation, I think introducing a control system for the amplitude in
addition to bare hand can bring more precision.

\subsection{Damping coefficient}

The damping coefficient is calculated from dividing the decreasing
amplitude and log it.
When calculating the damping coefficient, successive difference method is applied
to reduce the deviation.

For more precision than successive difference method, we could use curve fitting,
thus the whole list can be used to determine the damping coefficient $\beta$
from $\theta_n=\theta_0e^{-\beta (nT)}$, instead of only using 5 groups of
isolated points.

\begin{figure}[H]
\centering
\includegraphics[width=0.7\textwidth]{matlab/p3}
\caption{Curve fitting example}
\end{figure}

And we can find the b of the curve, which is $-0.09125$
Comparing $- 5\times b =  0.4562 $ with $\beta = 0.4558$
$$ u_{\beta,r}=  0.0878 \% $$

We can reach a conclusion that although curve fitting can introduce more precise
process, the present method is quite accurate.

% NOTE:DONE

\subsection{$\varphi$ vs. $\omega$}

Both of the $\varphi$ vs. $\omega$ curve are in the shape of arc
cotangent (see Figure~\ref{phi}).
In theory we know that for the smaller damping coefficient, the left side curve
of $\omega/\omega_0=1.0$ is higher than the other and the right side curve is
lower than that.

My fit curve quit matches what a arc cotangent line looks like, one curve higher
before the intersection point and lower after the intersection point.
The time duration will be longer to reach the stable situation.
The second half of phase points number lesser than the first one because it's
hard to predict how the $\varphi$ goes.

For recommendation, it hurts for us to bear the flashlight for reading the phase
data.
Electronic devices such as a camera can be introduced to record the data,
instead of directly reading the data with human eyes.

\subsection{$\theta_{st}$ vs. $\omega$}

The shape of both curve meets our expectation (in Figure~\ref{theta}).

In the figure, the curve's shape and position meet the expectation, that is
damping 3's damping coefficient is greater than damping 2's.
And the curve is same as the theory.

From the figure, it's obvious whether the peaks occur on the left or right hand
side of the straight line $\omega/\omega_0=1.0$ for Damping Selection 2, but
hard for Damping Selection 3.
It is because that the deviation is smaller for Damping Selection 3.
In theory, the peaks should occur on the slightly left of the straight
line.


% !TEX root = main.tex
% !TEX spellcheck = en-US

\section{Polynomial Commitment Schemes}
\label{sec:pcom}
A polynomial commitment scheme $\PCOM = (\kgen, \com, \open, \verify)$ consists in four algorithms and allow to commit to a
polynomial $\p{f}$ and later open the evaluation in a point $z$ to some value $s=\p{f}(z)$. More formally:
\begin{description}
\item[$\kgen(1^\secpar, \maxdeg)$:] The key generation algorithm
   takes in a security parameter $\secpar$ and a
  parameter $\maxdeg$ which determines the maximal degree of the committed
  polynomial. It outputs a structured reference string $\srs$ (the
  commitment key). In the following we will consider $\maxdeg$ implicitly contains $\secpar$.
\item[$\com(\srs, \p{f})$:] The commitment algorithm $\com(\srs, \p{f})$ takes
  in $\srs$ and a polynomial $\p{f}$ with maximum degree $\maxdeg$, and outputs
  a commitment $c$.
\item[$\open(\srs, z, s, \p{f})$:] The opening algorithm
  takes as input $\srs$, an evaluation point $z$, a
  value $s$ and the polynomial $\p{f}$. It outputs an opening $o$.
\item[$\verify(\srs, c, z, s, o)$:] The verification algorithm takes in $\srs$,
  a commitment $c$, an evaluation point $z$, a value $s$ and an opening $o$. It
  outputs 1 if $o$ is a valid opening for $(c, z, s)$ and 0 otherwise.
\end{description}

A secure polynomial commitment $\PCOM$ should satisfy correctness, evaluation binding,  opening uniqueness, hiding and knowledge-binding.
Note that since we are in the updatable setting, $\srs$ in these security definitions is the SRS that $\advse$ finalises using the update oracle $\initU$ (See~\cref{fig:upd}).

\begin{description}
\item[Evaluation binding:] A $\ppt$ adversary $\adv$ which outputs a commitment
  $\vec{c}$ and evaluation points $\vec{z}$ has at most negligible chances to open
  the commitment to two different evaluations $\vec{s}, \vec{s'}$. That is, let
  $k \in \NN$ be the number of committed polynomials, $l \in \NN$ number of
  evaluation points, $\vec{c} \in \GRP^k$ be the commitments, $\vec{z} \in
  \FF_p^l$ be the arguments the polynomials are evaluated at, $\vec{s},\vec{s}'
  \in \FF_p^k$ the evaluations, and $\vec{o},\vec{o}' \in \FF_p^l$ be the
  commitment openings. Then for every $\ppt$ adversary $\adv$
	\[
		\condprob{
			\begin{matrix}
				  \verify(\srs, \vec{c}, \vec{z}, \vec{s}, \vec{o}) = 1,  \\
				  \verify(\srs, \vec{c}, \vec{z}, \vec{s}', \vec{o}') = 1, \\
				  \vec{s} \neq \vec{s}'
			\end{matrix}}
			{
			\begin{matrix}
%				& \srs \gets \kgen(\secparam, \maxdeg),\\
				 (\vec{c}, \vec{z}, \vec{s}, \vec{s}', \vec{o}, \vec{o}') \gets \adv^{\initU}(\maxdeg)
			\end{matrix}
		} \leq \negl\,.
	\]

\end{description}

We say that $\PCOM$ has the unique opening property if the following holds:
\begin{description}
\item[Opening uniqueness:] Intuitively, opening uniqueness assures that there is only one valid opening
for the committed polynomial and given evaluation point. This property is
crucial in showing \COMMENT{forking }simulation-extractability of $\plonk$ and $\sonic$.  Let $k \in \NN$ be the number of committed
  polynomials, $l \in \NN$ number of evaluation points, $\vec{c} \in \GRP^k$ be
  the commitments, $\vec{z} \in \FF_p^l$ be the arguments the polynomials are
  evaluated at, $\vec{s} \in \FF_p^k$ the evaluations, and $\vec{o} \in \FF_p^l$
  be the commitment openings. Then for every $\ppt$ adversary $\adv$
	\[
		\condprob{
			\begin{matrix}
				  \verify(\srs, \vec{c}, \vec{z}, \vec{s}, \vec{o}) = 1,  \\
				  \verify(\srs, \vec{c}, \vec{z}, \vec{s}, \vec{o'}) = 1, \\
				 \vec{o} \neq \vec{o'}
			\end{matrix}
		}{
			\begin{matrix}
%				& \srs \gets \kgen(\secparam, \maxdeg),\\
				  (\vec{c}, \vec{z}, \vec{s}, \vec{o}, \vec{o'}) \gets \adv^{\initU}(\maxdeg)
			\end{matrix}
		}\leq \negl\,.
	\]
\end{description}
We show
that $\plonk$'s, $\sonic$'s, and $\marlin$'s polynomial commitment schemes satisfy this
requirement in \cref{lem:pcomp_op} and \cref{lem:pcoms_unique_op}
respectively.

\begin{description}
\item[Hiding:] We also formalize notion of $k$-hiding property of a polynomial commitment scheme. Let $\HHH$ be a set of size $\maxdeg + 1$ and $\ZERO_\HHH$ its
  vanishing polynomial. We say that a polynomial scheme is \emph{hiding} with
  security $\epsh(\secpar)$ if for every $\ppt$ adversary $\adv$, $k \in \NN$,
  probability
  \begin{align*}
    \condprob
   { b' = b}{
    (f_0, f_1, c, k, b') \gets \adv^{\initU, \oraclec}(\maxdeg, c), f_0, f_1 \in \FF^{\maxdeg}
    [X]}
\leq \frac{1}{2} + \eps(\secpar).
  \end{align*}
  Where $c = f'_b (\chi)$, for a random bit $b$ and the polynomial
      $f'_b (X) = f_b + \ZERO_\HHH (X) (a_0 + a_1 X + \ldots a_{k - 1} X^{k -
        1})$,
and the oracle $\oraclec$ on adversary's evaluation query $x$ it adds $x$ to initially empty set
      $Q_x$ and if $|Q_x| \leq k$, it provides $f'_b (x)$.

  \end{description}

\begin{description}
\item[Commitment of knowledge:] Intuitively, when a commitment scheme is ``of knowledge'' then if an
adversary produces a (valid) commitment $c$, which it can open correctly in an evaluation point, then it must
know the underlying polynomial $\p{f}$ which commits to that value.  For every $\ppt$ adversary $\adv$ who produces
  commitment $c$, evaluation $s$ and opening $o$ there
  exists a $\ppt$ extractor $\ext$ such that
\[
  \condprob{
    \begin{matrix}
       \deg \p{f} \leq \maxdeg,
       c = \com(\srs, \p{f}),\\
       \verify(\srs, c, z, s, o) = 1
    \end{matrix}
        }{
    \begin{matrix}
      %
     % & \srs \gets \kgen(\secparam, \maxdeg),\\
      c \gets \adv^{\initU}(\maxdeg),
      z \sample \FF_p \\
      (s, o) \gets \adv(c, z), \\
   \p{f} = \ext_\adv(\srs, c)\\
    \end{matrix}}
  \geq 1 - \epsk(\secpar).
\]
In that case we say that $\PCOM$ is $\epsk(\secpar)$-knowledge.
\end{description}

\cref{fig:pcomp,fig:pcoms} present variants of KZG~\cite{AC:KatZavGol10} polynomial commitment schemes
used in \plonk{} and \sonic{}. The key generation algorithm $\kgen$ takes as
input a security parameter $\secparam$ and a parameter $\maxdeg$ which
determines the maximal degree of the committed polynomial. We assume that
$\maxdeg$ can be read from the output SRS. While the figures only describe trusted SRS setup, it is not hard to lift the SRS generation into the updatable setting by defining the extra algorithms $\upd$, $\verifyCRS$ as defined in~\cref{def:upd-scheme}.
\cite{CCS:MBKM19} shows, using AGM, that $\PCOMs$ is a commitment of knowledge.
The same reasoning could be used to show that property for $\PCOMp$.

\begin{figure}[h!]
  \small
\centering
\begin{pcvstack}[center,boxed]
		\begin{pchstack}
			\procedure{$\kgen(\secparam, \maxdeg)$}
			{
			\chi \sample \FF^2_p \\ [\myskip]
			\pcreturn \gone{1, \ldots, \chi^{\numberofconstrains + 2}}, \gtwo{\chi}\\ [\myskip]
				\hphantom{\hspace*{5.5cm}}
        %\hphantom{\pcind \p{o}_i(X) \gets \sum_{j = 1}^{t_i} \gamma_i^{j - 1}
        %\frac{\p{f}_{i,j}(X) - \p{f}_{i, j}(z_i)}{X - z_i}}
      }

			\pchspace

			\procedure{$\com(\srs, \vec{\p{f}}(X))$}
			{
				\pcreturn \gone{\vec{c}} = \gone{\vec{\p{f}}(\chi)}\\ [\myskip]
				\hphantom{\pcind \pcif
					\sum_{i = 1}^{\abs{\vec{z}}} r_i \cdot \gone{\sum_{j = 1}^{t_j}
					\gamma_i^{j - 1} c_{i, j} - \sum{j = 1}^{t_j} s_{i, j}} \bullet
				\gtwo{1} + }
			}
		\end{pchstack}
		% \pcvspace

		\begin{pchstack}
			\procedure{$\open(\srs, \vec{\gamma}, \vec{z}, \vec{s}, \vec{\p{f}}(X))$}
			{
			\pcfor i \in \range{1}{\abs{\vec{z}}} \pcdo\\ [\myskip]
      \pcind \p{o}_i(X) \gets \sum_{j = 1}^{t_i} \gamma_i^{j - 1}
      \frac{\p{f}_{i,j}(X) - \p{f}_{i, j}(z_i)}{X - z_i}\\ [\myskip] \pcreturn
      \vec{o} = \gone{\vec{\p{o}}(\chi)}\\ [\myskip]
				\hphantom{\hspace*{5.5cm}}
			}

			\pchspace

			\procedure{$\verify(\srs, \gone{c}, \vec{z}, \vec{s}, \gone{\p{o}(\chi)})$}
			{
				\vec{r} \gets \FF_p^{\abs{\vec{z}}}\\ [\myskip]
				\pcfor i \in \range{1}{\abs{\vec{z}}} \pcdo \\ [\myskip]
				\pcind \pcif
          \sum_{i = 1}^{\abs{\vec{z}}} r_i \cdot \gone{\sum_{j = 1}^{t_j}
          \gamma_i^{j - 1} c_{i, j} - \sum{j = 1}^{t_j} s_{i, j}} \bullet
          \gtwo{1} + \\ [\myskip] \pcind \sum_{i = 1}^{\abs{\vec{z}}} r_i z_i
          o_i
          \bullet \gtwo{1} \neq \gone{- \sum_{i = 1}^{\abs{\vec{z}}} r_i o_i }
          \bullet \gtwo{\chi} \pcthen  \\
					\pcind \pcreturn 0\\ [\myskip]
					\pcreturn 1.
			}
		\end{pchstack}
	\end{pcvstack}
	\caption{$\PCOMp$ polynomial commitment scheme.}
	\label{fig:pcomp}
  \end{figure}

% \begin{figure}[h!]
% \centering
% 	\begin{pcvstack}[center,boxed]
% 		\begin{pchstack}
% 			\procedure{$\kgen(\secparam, \maxdeg)$} {
% 				\alpha, \chi \sample \FF^2_p \\ [\myskip]
% 				\pcreturn \gone{\smallset{\chi^i}_{i = -\multconstr}^{\multconstr},
%           \smallset{\alpha \chi^i}_{i = -\multconstr, i \neq
%             0}^{\multconstr}},\\
%         \pcind \gtwo{\smallset{\chi^i, \alpha \chi^i}_{i =
%             -\multconstr}^{\multconstr}}, \gtar{\alpha}\\
% 				%\markulf{03.11.2020}{} \\
% 			%	\hphantom{\pcind \p{o}_i(X) \gets \sum_{j = 1}^{t_i} \gamma_i^{j - 1} \frac{\p{f}_{i,j}(X) - \p{f}_{i, j}(z_i)}{X - z_i}}
% 				\hphantom{\hspace*{5.5cm}}
% 		}
%
% 			\pchspace
%
% 			\procedure{$\com(\srs, \maxconst, \p{f}(X))$} {
% 				\p{c}(X) \gets \alpha \cdot X^{\dconst - \maxconst} \p{f}(X) \\ [\myskip]
% 				\pcreturn \gone{c} = \gone{\p{c}(\chi)}\\ [\myskip]
% 				\hphantom{\pcind \pcif \sum_{i = 1}^{\abs{\vec{z}}} r_i \cdot
%           \gone{\sum_{j = 1}^{t_j} \gamma_i^{j - 1} c_{i, j} - \sum_{j = 1}^{t_j}
%             s_{i, j}} \bullet \gtwo{1} + } }
% 		\end{pchstack}
% 		% \pcvspace
%
% 		\begin{pchstack}
% 			\procedure{$\open(\srs, z, s, f(X))$}
% 			{
% 				\p{o}(X) \gets \frac{\p{f}(X) - \p{f}(z)}{X - z}\\ [\myskip]
% 				\pcreturn \gone{\p{o}(\chi)}\\ [\myskip]
% 				\hphantom{\hspace*{5.5cm}}
% 			}
%
% 			\pchspace
%
% 			\procedure{$\verify(\srs, \maxconst, \gone{c}, z, s, \gone{\p{o}(\chi)})$}
%       {
%         \pcif \gone{\p{o}(\chi)} \bullet \gtwo{\alpha \chi} + \gone{s - z
%         \p{o}(\chi)} \bullet \gtwo{\alpha} = \\ [\myskip] \pcind \gone{c}
%         \bullet \gtwo{\chi^{- \dconst + \maxconst}} \pcthen  \pcreturn 1\\
%         [\myskip]
%         \rlap{\pcelse \pcreturn 0.} \hphantom{\pcind \pcif \sum_{i =
%             1}^{\abs{\vec{z}}} r_i \cdot \gone{\sum_{j = 1}^{t_j} \gamma_i^{j -
%               1} c_{i, j} - \sum{j = 1}^{t_j} s_{i, j}} \bullet \gtwo{1} + } }
% 		\end{pchstack}
% 	\end{pcvstack}
%
% 	\caption{$\PCOMs$ polynomial commitment scheme.}
% 	\label{fig:pcoms}
% \end{figure}

\subsection{Unique opening property of $\PCOMp$}
Now, we show that the version of the KZG polynomial
commitment scheme that is used in \plonk{}, $\PCOMp$, has the unique opening
property.

\begin{lemma}
\label{lem:pcomp_op}
Let $\PCOMp$ be a batched version of a KZG polynomial commitment,
cf.~\cref{fig:pcomp}, then $\PCOMp$ has the unique opening property
 in the AGM with security
$\epsop(\secpar) \leq 2 \epsdlog(\secpar) + \infrac{1}{\abs{\FF_p}}$, where
$\epsdlog(\secpar)$ is security of the $(\noofc + 2, 1)$-dlog assumption and
$\FF_p$ is the field used in $\PCOMp$.\end{lemma}
\begin{proof}
  Let $\vec{z} = (z, z') \in \FF_p^2$ be the two points the polynomials are
  evaluated at, $k \in \NN$ be the number of the committed polynomials to be
  evaluated at $z$, $k' \in \NN$ be the number of the committed polynomials
  to be evaluated at $z'$, $\vec{c} \in \GRP^k, \vec{c'} \in \GRP^{k'}$ be the
  commitments, $\vec{s} \in \FF_p^k, \vec{s'} \in \FF_p^{k'}$ the evaluations,
  and $\vec{o} = (o, o') \in \FF_p^2$ be the commitment openings.  We need to
  show that the probability a $\ppt$ $\adv$ opens the same commitment in two
  different ways is at most $\epsop(\secpar)$, even when the commitment openings
  are verified in batches.

  The idealised verifier checks whether the following equality, for $\gamma, r'$
  picked at random, holds:
  \begin{multline}
    \label{eq:ver_eq_poly}
    \left(\sum_{i = 1}^{k} \gamma^{i - 1} \cdot \p{f}_i(X) - \sum_{i = 1}^{k}
      \gamma^{i - 1} \cdot s_i\right) + r' \left(\sum_{i = 1}^{k'} \gamma'^{i -
        1} \cdot \p{f'}_i(X) -
      \sum_{i = 1}^{k'} \gamma'^{i - 1} \cdot s'_i \right)\\
    \equiv \p{o}(X)(X - z) + r' \p{o}'(X)(X- z').
  \end{multline}
  Since $r'$ has been picked at random from $\FF$, probability that
  \cref{eq:ver_eq_poly} holds while either
  \[
    \sum_{i = 1}^{k} \gamma^{i - 1} \cdot \p{f}_i(X) - \sum_{i = 1}^{k}
    \gamma^{i - 1} \cdot s_i \not\equiv \p{o}(X)(X - z) \text{, or}
  \]
  \[
    \sum_{i = 1}^{k'} \gamma'^{i - 1} \cdot \p{f'}_i(X) - \sum_{i = 1}^{k'}
    \gamma'^{i - 1} \cdot s'_i \not\equiv \p{o'}(X)(X - z')
  \]
  is $\infrac{1}{\abs{\FF_p}}$~cf.~\cite{EPRINT:GabWilCio19}.
  When \(
    \sum_{i = 1}^{k} \gamma^{i - 1} \cdot \p{f}_i(X) - \sum_{i = 1}^{k}
    \gamma^{i - 1} \cdot s_i = \p{o}(X)(X - z)
  \)
  holds, polynomial $\p{o}(X)$ is uniquely determined from the uniqueness of
  polynomial composition. Similarly, $\p{o'}(X)$ is uniquely determined as well.

  Any discrepancy
  between the idealised verifier rejection and real verifier acceptance allows
  one to break the discrete logarithm problem.

  The reduction $\rdvdlog$ proceeds as follows: $\rdvdlog$ builds a SRS $\srs$ using the input $\dlog$ instance. I.e., it answers $\adv$'s queries for SRS updates and sets the honest update of the SRS to be $\srs$. Let $\srs'$ be the finalised SRS.
  Consider a proof $\zkproof$ such
      that $\vereq_{\inp, \zkproof}(X) \neq 0$, but
      $\vereq_{\inp, \zkproof}(\chi') = 0$. Since $\adv$ is algebraic, all proof
      elements are extended by their representation as a
      combination of the input $\GRP_1$-elements. Therefore, all coefficients of the
      verification equation polynomial $\vereq_{\inp, \zkproof}(X)$ are known.
   Now, $\rdvdlog$ computes the roots of $\vereq_{\inp, \zkproof}(X)$ and finds $\chi'$ among
      them.
    Let $\chi_1, \ldots, \chi_\ell$ be the partial trapdoors of $\adv$'s SRS updates that are extracted by $\rdvdlog$ from the update proofs given by $\adv$.
  $\rdvdlog$ returns $\chi = \chi' (\chi_1 \chi_2 \ldots \chi_\ell)^{-1}$.

  Since any discrepancy
  between the idealised verifier and real verifier rejection allows
  one to break the discrete logarithm problem, the probability that the real
  verifier accepts in one of the cases above is upper-bounded by
  $2 \epsdlog + \infrac{1}{\FF_p}$.

    \qed
\end{proof}

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


\documentclass[../../main]{subfiles}
\pagestyle{fancy}

\begin{document}

\chapter{Further questions}
\thispagestyle{fancy}

Here we record many open questions related to the content of the preceeding chapters, broadly separated by topic.

\section{Relations between virtuals}

The analysis in Chapter \ref{chapter.virtual-large-cardinals} showed several implication and separation results between the virtual large cardinals. A few of these relations remain open, however.

\ques[][ques.remarkableequiv]{
  Are virtually $\theta$-strong cardinals, virtually $\theta$-supercompact cardinals and virtually $\theta$-Magidor-supercompact cardinals all equivalent, for any uncountable regular cardinal $\theta$?
}

\ques[][ques.prestrong-equivalence]{
  Let $\theta$ be an uncountable cardinal.
  \begin{enumerate}
    \item Is every virtually $\theta$-measurable cardinal also virtually $\theta$-prestrong? What if we assume $V=L[\mu]$ or $V=K$, with $K$ being the core model below a Woodin cardinal?
    \item Is every virtually $\theta$-strong cardinal virtually $\theta$-supercompact? Are they equiconsistent?
  \end{enumerate}
}

\section{Berkeleys}

Question 1.7 in \cite{RemarkableWilson} asks whether the existence of a non-$\Sigma_2$-reflecting \textit{weakly remarkable} cardinal always implies the existence of an $\omega$-Erd\H os cardinal. Here a weakly remarkable cardinal is a rewording of a virtually prestrong cardinal, and Lemmata 2.5 and 2.8 in the same paper also shows that being $\omega$-Erd\H os is equivalent to being virtually club Berkeley and that the least such is also the least virtually Berkeley.\footnote{Note that this also shows that virtually club Berkeley cardinals and virtually Berkeley cardinals are equiconsistent, which is an open question in the non-virtual context.}

\qquad Furthermore, they also showed that a non-$\Sigma_2$-reflecting virtually prestrong cardinal is equivalent to a virtually prestrong cardinal which is not virtually strong. We can therefore reformulate their question to the following equivalent question.

\ques[Wilson]{
  If there exists a virtually prestrong cardinal which is not virtually strong, is there then a virtually Berkeley cardinal?
}

\cite{RemarkableWilson} showed that their question has a positive answer in $L$, which in particular shows that they are equiconsistent. Applying our Theorem \ref{theo.virtchar} we can ask the following related question, where a positive answer to that question would imply a positive answer to Wilson's question.

\ques{
If there exists a cardinal $\kappa$ which is virtually $(\theta,\omega)$-superstrong for arbitrarily large cardinals $\theta>\kappa$, is there then a virtually Berkeley cardinal?
}

Theorem \ref{theo.berkeleyequiv} from Chapter \ref{chapter.virtual-large-cardinals} at least gives a partially positive result, noting that the assumption by definition implies that $\on$ is virtually pre-Woodin but not virtually Woodin.

\qcoro[N.]{
  If there exists a virtually $A$-prestrong cardinal for every class $A$ and there are no virtually strong cardinals, then there exists a virtually Berkeley cardinal.
}

The assumption that there is a virtually $A$-prestrong cardinal for every class $A$ in the above corollary may seem a bit strong, but Theorem \ref{theo.berkeleyequiv} shows that this is necessary, which might lead one to think that the question could have a negative answer.

\section{Indestructibility}

Our original goal concerning indestructibility was to see what indestructibility properties the faintly supercompacts have, whether any analogy with the supercompact cardinals holds. This still remains open.

\ques{
  Do faintly supercompact cardinals have indestructibility properties? For instance, if $\kappa$ is faintly supercompact, does it remain supercompact after forcing with $\add(\kappa, 1)$?
}

We proved several indestructibility properties of the ostensibly stronger notion of \textit{generically setwise supercompacts}, and several questions then arise concerning the nature of these cardinals.

\ques{
  What is the consistency strength of the generically setwise supercompact cardinals? The best upper bound is a virtually extendible, as given by Usuba's Theorem \ref{theo.usuba}, and a lower bound is the trivial faintly supercompact one. What if we require the cardinal to be inaccessible?
}

\ques{
  Is it consistent to have a faintly supercompact cardinal which is not generically setwise supercompact?
}

\ques{
  Assume there exists no inner model with a Woodin cardinal. Can there then exist generically setwise supercompact cardinals in $K$?
}

\section{Games and small embeddings}

Our results in Chapter \ref{chapter.filters-and-games} provide answers to the following questions, which were posed in \cite{HolySchlicht}.

\begin{enumerate}
	\item If $\gamma$ is an uncountable cardinal and the challenger does not have a winning strategy in the game $\G_\gamma^\theta(\kappa)$, does it follow that the judge has one?
	\item If $\omega\leq\alpha\leq\kappa$, are $\alpha$-Ramsey cardinals downwards absolute to the Dodd-Jensen core model?
	\item Does $2$-iterability imply $\omega$-Ramseyness, or conversely?
	\item Does $\kappa$ having the strategic $\kappa$-filter property have the consistency strength of a measurable cardinal?\\
\end{enumerate}

Here the ``challenger'' is player I and the ``judge'' is player II, so this is asking if every $\gamma$-Ramsey is strategic $\gamma$-Ramsey, when $\gamma$ is an uncountable cardinal. Theorem \ref{theo.stratramsey} therefore gives a negative answer to (i) for all uncountable ordinals $\gamma$. Theorem \ref{theo.downK} and Corollary \ref{coro.downK} answer (ii) positively, for $\alpha$-Ramseys with $\alpha$ having uncountable cofinality, and for ${<}\alpha$-Ramseys when $\alpha$ is a limit of limit ordinals. Note that (ii) in the $\alpha=\omega$ case was answered positively in \cite{HolySchlicht}.

\qquad As for (iii), it is mentioned in \cite{HolySchlicht} that Gitman has showed that $\omega$-Ramseys are not in general $2$-iterable by showing that $2$-iterables have strictly stronger consistency strength than the $\omega$-Ramseys, which also follows from Theorem \ref{theo.remlimram} and Theorem 4.8 in \cite{Ramsey2}. Corollary \ref{coro.ind} shows that $\omega$-Ramsey cardinals are $\Delta^2_0$-indescribable, and as $2$-iterables are (at least) $\Pi^1_3$-definable it holds that any $2$-iterable $\omega$-Ramsey cardinal is a limit of $2$-iterables, so that in general $2$-iterables cannot be $\omega$-Ramsey either, answering (iii) in the negative. Lastly, Theorem \ref{theo.omegaplusone} gives a positive answer to (iv).

\qquad We conjecture the following two questions to be true. The first is a direct analogue to Theorem \ref{theo.gengame}, and the latter is a suspected analogy between the genuine $n$-Ramsey cardinals and the weakly ineffable cardinals.

\ques{
  If $\kappa$ is faintly $\theta$-power-measurable, does player II then have a winning strategy in $\G^\theta_\omega(\kappa)$?
}

\ques{
	Are genuine $n$-Ramsey cardinals limits of $n$-Ramsey cardinals? We conjecture this to be true, in analogy with the weakly ineffables being limits of weakly compacts. Since ``weakly ineffable = $\Pi^1_1$-indescribability + subtlety'', this might involve some notion of ``$n$-iterated subtlety''. The difference here is that $n$-Ramseys cannot be \textit{equivalent} to $\Pi^1_{2n+1}$-indescribables for consistency reasons, so there is some work to be done.
}

We showed in Theorem \ref{theo.ineff}, see also Corollary \ref{coro.ineff} that completely ineffable cardinals could be characterised in terms of player II having a winning strategy in $\G_\omega^-(\kappa)$. This lends itself to the following question.

\ques{
  Are there higher analogues of ineffability which are equivalent to player II having a winning strategy in $\G_\alpha^-(\kappa)$ for $\alpha>\omega$?
}

\section{Ideal absoluteness}

One can ask of any poset property whether it is ideal-absolute, but we choose to only highlight one particular property here. We saw in Corollary \ref{coro.powerclosed} that ${<}\lambda$-closed faintly power-measurables ``corresponds to'' $(\kappa,\kappa)$-distributive ${<}\lambda$-closed forcings, and in Corollary \ref{coro.ineff} that completely ineffable cardinals ``corresponds to'' $(\kappa,\kappa)$-distributive forcings. In an attempt to find the forcing that corresponds to the faintly power-measurables, we arrive at the following question.

\ques{
	For $\kappa$ a regular cardinal, are the following equivalent?
  \begin{enumerate}
    \item $\kappa$ is faintly power-measurable;
    \item $\kappa$ is ideally power-measurable;
    \item $\kappa$ is $(\kappa,\kappa)$-distributive $\omega$-distributive faintly measurable;
    \item $\kappa$ is $(\kappa,\kappa)$-distributive $\omega$-distributive ideally measurable;
    \item Player II has a winning strategy in $\G_\omega(\kappa)$.
  \end{enumerate}
}

\end{document}


\documentclass{ecnreport}

\stud{Control \& Robotics Master}
\topic{Manipulator Modeling \& Control}

\begin{document}

\inserttitle{Manipulator Modeling \& Control}

\section{Content of this lab}

The goal of this lab is to program in C++ the three fundamentals models for robot manipulators:
\begin{itemize}
	\item Direct Geometric Model: what is the pose of the end-effector for a given joint configuration?
	\item Inverse Geometric Model: what joint values correspond to a given end-effector pose?
	\item Kinematic Model: what is the velocity screw of the end-effector when the joints move?
\end{itemize}
These models will be applied on three different robots, and used to perform basic point-to-point control.\\

As it is not a lab on C++, most of the code is already written and you only have to fill the required functions:
\begin{itemize}
	\item \texttt{Robot::init\_wMe()} to initialize the fixed transform between the wrist and end-effector
	\item \texttt{Robot::fMw(q)} for the direct geometric model wrist-to-fixed frame
	\item \texttt{Robot::inverseGeometry(M)} for...well, the inverse geometry
	\item \texttt{Robot::fJw} for the kinematic model wrist-to-fixed frame
\end{itemize}

\subsection{Installing and loading the lab in Qt Creator}

This project uses the ROS\footnote{Robot Operating System, http://www.ros.org} framework which imposes some particular steps to configure the environment. An actual ROS course will be held in the second semester, for now just configure as follows:

\begin{enumerate}
	\item Open a terminal and download the lab package: \texttt{rosdl ecn\_manip}.
	\item Run Qt Creator from the top screen icon
	\item Load the \texttt{ros/src/ecn\_manip/CMakeLists.txt} file through \texttt{File...open project}
	\item QtCreator asks for a compilation folder: give \texttt{ros/build/ecn\_manip}
	\item The files should be displayed and ready to compile and run
	\item Compilation is done by clicking the bottom-left hammer
	\item Run your program with the green triangle. It can be stopped by clicking on the red square
\end{enumerate}

\subsection{Expected work}

The {\bf only} files to be modified are:
\begin{itemize}
	\item \texttt{control.cpp}: main file where the control is done depending on the current robot mode
	\item \texttt{robot\_turret.cpp}: model of the RRP turret robot
	\item \texttt{robot\_kr16.cpp}: model of the industrial Kuka KR16 robot
	\item \texttt{robot\_ur10.cpp}: model of the Universal Robot UR-10
\end{itemize}
We will use the ViSP\footnote{Visual Servoing Platform, http://visp.inria.fr} library to manipulate mathematical vectors and matrices, including frame transforms, rotations, etc. The main classes are detailed in Appendix \ref{visp}.\\
At the end of the lab, you should upload them through the \link{http://pagesperso.ls2n.fr/~kermorgant-o/student links.php}{portal on my website}

\section{The robots}

\def\wMe{{}^w\M_e}

Three robots are proposed with increasing complexity. You should start with the Turret, then the Kuka KR16 then the UR-10.\\
For each of these robots, the table of Modified Denavit-Hartenberg parameters should be defined. As we saw during the lectures, once you have the table then the Direct Geometric and Direct Kinematic Models can be almost automatically derived. A tool is provided in this package to generate C++ code for the Geometric and Kinematic models, see Appendix \ref{dhcode} for details on this tool.

The fixed frame and the end-effector frame are imposed by the schematics.
All intermediary frames have to be placed according to MDH convention, with a final fixed transform between the wrist and end-effector frames.

\subsection{Turret RRP robot}

\begin{minipage}{.8\linewidth}
	This is a very simple robot to begin the modeling, as shown in the figure.\\
	The fixed frame $\Frame{0}$ and end-effector frame $\Frame{e}$ are imposed, as well as the joint direction.\\
	The constant values for this model are: $b = 0.5$ m and $d = 0.1$ m.\\~\\
	All computation may be done first without using the Denavit-Hartenberg parameters as the robot is quite simple.
\end{minipage}
\begin{minipage}{.2\linewidth}
	\includegraphics{fig/turret}\label{turret}
\end{minipage}

\subsection{Kuka KR16 anthropomorphic robot}

This robot is a classical 6R architecture with a spherical wrist, as shown in the next figure:

\begin{figure}[h!]\centering
	\includegraphics[width=.6\linewidth]{fig/kr16}
	\caption{Model of the Kuka KR16 with imposed fixed and end-effector frames}
\end{figure}

The wrist frame is typically at the common point between joints 4, 5 and 6.
The constant transform $\wMe$ between the wrist and the end-effector should include the $0.158$ distance and potential rotations.

\subsection{Universal Robot UR-10 anthropomorphic robot}

This robot is a less classical 6R architecture, without spherical wrist. A tool is also attached with an arbitrary end-effector offset.

\begin{figure}[h!]\centering
	\includegraphics[width=.6\linewidth]{fig/ur10}
	\caption{Model of the UR-10 with imposed fixed and end-effector frames}
\end{figure}

The Inverse Geometry is given for this robot.
The constant transform $\wMe$ between the wrist and the end-effector should include the $0.1922$ distance and potential rotations.

\newpage
\subsection{Running the simulation}

Once everything is installed and compiled, the base simulation can be run from a terminal (only 1 line depending on the robot you work on):
\cppstyle
\begin{lstlisting}
roslaunch ecn_manip turret.launch
roslaunch ecn_manip kr16.launch
roslaunch ecn_manip ur10.launch
\end{lstlisting}

This will display two windows:
\begin{itemize}
	\item RViz is the 3D simulator to show the current configuration of the robot. It will also display the base and end-effector frames, and the one that you compute. You can thus easily check if the computation is fine.
	\item The other window is composed of 4 panels:
	\begin{itemize}
		\item Buttons at the top left to change the current exercise
		\item Sliders at the bottom left to manually control the robot (exercises 1 and 2)
		\item Sliders at the top to change the switching time of the position control (exercises 3+)
		\item A plotting region with two tabs, one for the operational space and one for the joint space. The joint space is displayed in a normalized fashion, depending on the joint limits (upper and lower dotted lines)
	\end{itemize}
\end{itemize}

\section{Building the models}

\subsection*{The main code}

In the file \texttt{control.cpp}, the \texttt{if - else if} blocks correspond to the 6 exercises to be done for each robot. Note that if they work for the Turret robot, then
they should work for all robots as long as the model is correct. \\
The current exercise is changed by using the buttons in the GUI.

\subsection*{Exercise 1: Checking the Direct Geometric Model}

In this exercise, the robot follows the manually given joint positions. The task is to build and print the direct geometric model, depending on the current value of $\q$. This is to be done in two functions:
\begin{itemize}
	\item \texttt{Robot::init\_wMe()} where you have to write the constant matrix $\wMe$ from the end-effector to the wrist frame
	\item \texttt{Robot::fMw(q)}  where you have to write and return the transform $\M$ between the fixed and wrist frame
\end{itemize}
Once you have computed the \texttt{M} matrix, the code calls \texttt{robot->checkPose(M);} in order to print both your matrix and the true one. No need to tell that they should be equal.\\
What can be told is that it is useless to continue until they are.

\subsection*{Exercise 2: Checking the Direct Kinematic Model (Jacobian)}

If you select \texttt{Manual Operational Velocity} in the GUI then the sliders allow you to give a desired operational velocity (ie twist) for the end-effector.\\
This velocity is ${}^e\v_e$ and is defined in the end-effector frame.\\
The robot Jacobian has to be defined in the function \texttt{Robot::fJw(q)} that should return the Jacobian of the wrist in the fixed frame.\\

In the main code, the commanded velocity then to be mapped to the joint velocity in two steps:
\begin{enumerate}
	\item Map to the fixed frame: ${}^f\mathbf{v}_e^* = \left[\begin{array}{cc}{}^f\R_e & 0 \\ 0 & {}^f\R_e\end{array}\right]{}^e\mathbf{v}_e^*$\\
			Call \texttt{M.getRotationMatrix()} to get this rotation.\\
			The \texttt{ecn::putAt} function may be of good use.
	\item Map to the joint space: $\dot\q = \J^+.{}^f\mathbf{v}_e^*$\\
Call \texttt{robot->fJe(q).pseudoInverse()} to get the Jacobian pseudo-inverse
\end{enumerate}
You can check that the end-effector is able to follow straight 3D lines in x, y or z direction in its own frame.
Similarly, it should be able to rotate around x, y or z. This means the Jacobian computation is correct.

\newpage
\subsection*{Exercise 3: Checking the Inverse Geometric Model}

If you select \texttt{Direct point-to-point} in the GUI then the robot will receive two operational setpoints, at a given sampling time that can be changed with the \texttt{Switching time} slider in the GUI. The current setpoint is in the matrix \texttt{Md} and its corresponding joint position is in the vector \texttt{qf}.

Nothing has to be done in the main code, but of course the \texttt{Robot::inverseGeometry(M)} function has to be filled in order to compute the actual inverse geometry solution. The robot will try to have all joints reach their desired value as soon as possible, which will lead to a discontinuous motion.\\

In practice, this exercise is to check that the Inverse Geometric Model is correct: the robot should reach the desired pose.\\

When computing the inverse geometry, try to find a solution as near as possible to the passed \texttt{q0}. It should also be within the joint limits, that are available in \texttt{q\_min} and \texttt{q\_max}.\\

Many useful functions are available to solve classical trigonometric equations. They are detailed in Appendix \ref{trigsolve}.

\subsection*{Exercise 4: Interpolated point-to-point control}

In this exercise the previous pose setpoint \texttt{M0} and its corresponding joint position \texttt{q0} should be used to interpolate the joint positions.\\

Here the goal is to compute the current setpoint $\q_c = \q_0 + p(t)(\q_f-\q_0)$. The interpolation function $p(t)$ was defined during the lectures and should take into account the maximum joint velocity and acceleration that are stored in the \texttt{vMax} and \texttt{aMax} vectors. Basically this amounts to computing the minimum time \texttt{tf} needed to reach $\q_f$ from $\q_0$. This computation should be done in the \texttt{if(robot->newRef())} and then used to compute the current \texttt{qCommand}.

\subsection*{Exercise 5: Operational control through Inverse Geometric Model}

Exercises 3 and 4 lead to the correct pose but not in a straight 3D line. Indeed the robot is only controlled in the joint space with no constraints between the two extreme poses.\\
In this exercise, the goal is to perform the interpolation not in the joint space but in the Cartesian space. In practice, we will compute many poses between
\texttt{M0} and \texttt{Md} and command the robot to reach sequentially all these poses. As they will be pretty close one from each other, the resulting motion
will be close to a straight line.

The \texttt{robot->intermediaryPose(M0, Md, alpha)} function returns a pose between \texttt{M0} and \texttt{Md}, where \texttt{alpha} is between 0 and 1 and should be computed from $t$, $t_0$ and $t_f$ = 1 s.

Then, the inverse geometry of this pose should be sent to the robot as joint position setpoint.

\newpage
\subsection*{Exercise 6: Operational control through Jacobian}

In this exercise the goal is still to follow a straight line between the two points, but this time by sending a joint velocity command.\\

As seen in class, this command should make the end-effector approach its desired pose. The steps are:
\begin{enumerate}
	\item Compute the pose error in the desired frame: ${}^{e*}\M_e = {}^{f}\M_{e*}^{-1}.{}^{f}\M_e$
	\begin{itemize}
		\item in the code, ${}^{f}\M_{e*}$ corresponds to \texttt{Md} and ${}^{f}\M_e$ to \texttt{M}
		\item In practice we use the $(\mathbf{t}, \theta\u)$ representation with \texttt{p.buildFrom()}
	\end{itemize}
	\item Compute the desired linear and angular velocities: $v = -\lambda{}^{f}\M_{e*}\mathbf{t}$, \quad $\omega = -\lambda{}^{f}\M_{e} (\theta\u)$
	\item Map these velocities to the joint space: $\dot\q = \J^+ \left[\begin{array}{c}v\\\omega\end{array}\right]$
\end{enumerate}
$\lambda$ is a gain that can be changed from the GUI. Increasing it will lead to a faster convergence. It can be obtained through \texttt{robot->lambda()}.

\appendix

\newpage

\section{Using ViSP}\label{visp}

ViSP is a library for Visual Servoing (wait for the M2 Robotics to know more!) and also includes all necessary tools to play with mathematical vectors, matrices and 3D transforms.
The full documentation is here: \link{http://visp-doc.inria.fr/doxygen/visp-3.1.0/classes.html}{http://visp-doc.inria.fr/doxygen/visp-3.1.0/classes.html}.\\
The main classes to be used are:
\begin{itemize}
	\item \texttt{vpMatrix}: a classical matrix of given dimensions, can be multiplied with other matrices and vectors if the dimensions are ok. The pseudo-inverse of matrix \texttt{M}
	is available with \texttt{M.pseudoInverse()}
	\item \texttt{vpColVector}: a column vector of given dimension
	\item \texttt{vpHomogeneousMatrix}: the classical $4\times 4$ 3D transform matrix
\end{itemize}
Most of the model computation is about initializing a matrix or vector to correct dimensions (which is already done) and fill its elements with formulae.\\
To write 1 at element (i,j) of matrix M, just write \texttt{M[i][j] = 1;}\\
Similarly, to write 1 at element (i) of vector q, just write \texttt{q[i] = 1;}\\

3D transforms can be easily changed between homogeneous matrix, rotation matrix, translation vector or $\theta\u$ vector. Another type called a pose vector
consists in the full $(\mathbf{t}, \theta\u)$ vector of dimension 6:
\cppstyle
\begin{lstlisting}
vpHomogeneousMatrix M;
vpPoseVector p;
vpRotationMatrix R;
vpTranslationVector t;
vpColVector tu(3);

M.getRotationMatrix()*t;	// extract the rotation part from M and multiply with t
p.buildFrom(M);			// build (t, theta-u) from M
t = M.getTranslationVector();	// extract the translation part

// copy the theta-u part of p into tu
for(int i = 0; i < 3; ++i)
	tu[i] = p[i+3];

// compute inverse transform
M = M.inverse();
\end{lstlisting}

Two utility functions are provided to put a matrix or vector into a bigger one:
\begin{itemize}
	\item \texttt{void ecn::putAt(M, Ms, r, c)}: Writes matrix \texttt{Ms} inside matrix \texttt{M}, starting from given row and column.
	\item \texttt{void ecn::putAt(V, Vs, r)}: Writes column vector \texttt{Vs} inside vector \texttt{V}, starting from given row. These two functions do nothing but print an error
	if the submatrix or vector does not fit in the main one.
\end{itemize}

\newpage
\section{Code generation from Modified Denavit-Hartenberg parameters}\label{dhcode}

The core of robot modeling is to build the MDH table. From this, the DGM and KM can be derived automatically. The Inverse Geometry still has to be done by hand (even if some advanced tools allow code-generation for the IG resolution).

As it is quite tedious to have to compute all matrices when a solution of MDH is investigated, a tool is provided to generate the C++ code. An example can be found in the file \texttt{dh\_example.yml}:
\cppstyle
\begin{lstlisting}
notation: [alpha, a, theta, r]
joint:
1: [0, 0, q1, 0]
2: [-pi/2, 0, 0, q2]
3: [pi/2, 0, q3, r3]
4: [-pi/2, a4, q4+pi/2, 0]
\end{lstlisting}
The command to be run is: \texttt{rosrun ecn\_manip dh\_code.py <name of the file>}.\\
In the case of the above MDH table, it leads to these outputs:

\begin{minipage}{.45\linewidth}
\cppstyle \raggedright
\begin{lstlisting}
// Generated pose code
const double c1 = cos(q[0]);
const double c1p3 = cos(q[0]+q[2]);
const double c4 = cos(q[3]);
const double s1 = sin(q[0]);
const double s1p3 = sin(q[0]+q[2]);
const double s4 = sin(q[3]);
M[0][0] = -s4*c1p3;
M[0][1] = -c4*c1p3;
M[0][2] = -s1p3;
M[0][3] = a4*c1p3 - q[1]*s1;
M[1][0] = -s4*s1p3;
M[1][1] = -s1p3*c4;
M[1][2] = c1p3;
M[1][3] = a4*s1p3 + q[1]*c1;
M[2][0] = -c4;
M[2][1] = s4;
M[2][2] = 0;
M[2][3] = r3;
M[3][0] = 0;
M[3][1] = 0;
M[3][2] = 0;
M[3][3] = 1.;
// End of pose code
\end{lstlisting}
\end{minipage}
\begin{minipage}{.1\linewidth}
	\quad\quad
\end{minipage}
\begin{minipage}{.45\linewidth}
\cppstyle \raggedright
\begin{lstlisting}
// Generated Jacobian code
const double c1 = cos(q[0]);
const double c1p3 = cos(q[0]+q[2]);
const double s1 = sin(q[0]);
const double s1p3 = sin(q[0]+q[2]);
J[0][0] = -a4*s1p3 - q[1]*c1;
J[0][1] = -s1;
J[0][2] = -a4*s1p3;
//J[0][3] = 0;
J[1][0] = a4*c1p3 - q[1]*s1;
J[1][1] = c1;
J[1][2] = a4*c1p3;
//J[1][3] = 0;
//J[2][0] = 0;
//J[2][1] = 0;
//J[2][2] = 0;
//J[2][3] = 0;
//J[3][0] = 0;
//J[3][1] = 0;
//J[3][2] = 0;
J[3][3] = -s1p3;
//J[4][0] = 0;
//J[4][1] = 0;
//J[4][2] = 0;
J[4][3] = c1p3;
J[5][0] = 1.;
//J[5][1] = 0;
J[5][2] = 1.;
//J[5][3] = 0;
// End of Jacobian code
\end{lstlisting}
\end{minipage}
This is exactly what you would get by doing the manual computation from the initial table, which I hope is quite appreciated.

\newpage
\section{Trigonometric solvers}\label{trigsolve}

The code contains solvers for all types of trigonometric equations (except type 1 that is obvious).\\
They take as argument the coefficients of the equations and also the joint limits in order to prune impossible solutions. They return:
\begin{itemize}
	\item A \texttt{std::vector<double>} for equations of 1 unknown (types 2 \& 3).\\We can go through the valid solutions with:
\cppstyle
	\begin{lstlisting}
// assume q1 should ensure type 2: X.sin(q1) + Y.cos(q1) = Z

for(double q1: solveType2(X, Y, Z, q_min[0], q_max[0]))
{
	// here q1 is a valid solution, may be used to deduce other joint values
}
	\end{lstlisting}
	\item A \texttt{std::vector<JointSolution>} for equations of 2 unknowns (types 4 to 8).\\In this case, the valid solutions can be explored with:
	\cppstyle
	\begin{lstlisting}
// assume q1 and q2 should ensure type 6 equation:
//		W.sin(q2) = X.cos(q1) + Y.sin(q1) - Z1
//		W.cos(q2) = X.sin(q1) - Y.cos(q1) - Z1

for(auto qs: solveType6(X, Y, Z1, Z2, W, q_min[0], q_max[0], q_min[1], q_max[1]))
{
	// here a (q1,q2) solution is available in qs.qi and qs.qj
}
	\end{lstlisting}
\end{itemize}

Additional functions can check and even update (by $\pm 2\pi$) an angular joint value to that is fits within the joint limits:
\cppstyle
\begin{lstlisting}
// assume q1 was computed by hand, check joint limits
if(inAngleLimits(q1, q_min[0], q_max[0]))
{
	// here q1 is ok
}

// we have the sinus s1 and cosinus c1 of q1
if(inAngleLimits(q1, s1, c1, q_min[0], q_max[0]))
{
	// here q1 is ok and s1 and c1 absolute values are <= 1
}
\end{lstlisting}

\newpage
Below are listed the syntax for all trigonometric solvers:\\

%\setlength\extrarowheight{5pt}
\renewcommand{\arraystretch}{2.2}
\begin{tabular}{|c|c|C{7cm}|C{2cm}|}\hline
Type & Equation & Syntax & Returns (vector of)\\\hline
1 & $Xq_i = Y$& does not exist &$q_i$	\\\hline
2 & $Xs_i+Yc_i = Z$ & \texttt{solveType2(x, y, z, q\_min, q\_max)}&$q_i$\\\hline
3 & $\begin{array}{l}X_1s_i+Y_1c_i = Z_1 \\ X_2s_i+Y_2c_i = Z_2\end{array}$&\texttt{solveType3(x1, y1, z1,
 x2, y2, z2,
q\_min, q\_max)} &$q_i$\\\hline
4 & $\begin{array}{l}X_1q_js_i = Y_1 \\ X_2q_jc_i = Y_2\end{array}$& \texttt{solveType4(x1, y1, x2, y2,
 qi\_min, qi\_max,
 qj\_min, qj\_max)}&$(q_i,q_j)$ \\\hline
5 & $\begin{array}{l}X_1s_i = Y_1+Z_1q_j \\ X_2c_i = Y_2+Z_2q_j\end{array}$& \texttt{solveType5(x1, y1, z1,
 x2, y2, z2,
 qi\_min, qi\_max,
 qj\_min, qj\_max)}&$(q_i,q_j)$\\\hline
6 & $\begin{array}{l}Ws_j = Xc_i + Ys_i+Z_1 \\ Wc_j = Xs_i - Yc_i+Z_2\end{array}$& \texttt{solveType6(x, y,
 z1, z2, w,
 qi\_min, qi\_max,
 qj\_min, qj\_max)}&$(q_i,q_j)$\\\hline
7 & $\begin{array}{l}W_1c_j +W_2s_j = Xc_i + Ys_i+Z_1 \\ W_1s_j -W_2c_j = Xs_i - Yc_i+Z_2\end{array}$& \texttt{solveType7(x, y, z1, z2, w1, w2,
 qi\_min, qi\_max,
 qj\_min, qj\_max)}&$(q_i,q_j)$\\\hline
8 &$\begin{array}{l}Xc_i+Yc_{ij} =Z_1 \\ Xs_i+Ys_{ij} =Z_2\end{array}$ & \texttt{solveType8(x, y, z1, z2,
 qi\_min, qi\_max,
 qj\_min, qj\_max)}&$(q_i,q_j)$\\\hline
\end{tabular}

\end{document}


\documentclass[12pt]{cdblatex}
\usepackage{exercises}
\usepackage{fancyhdr}
\usepackage{footer}

\begin{document}

% --------------------------------------------------------------------------------------------
\section*{Exercise 6.3 Evaluate with undefined components}

\begin{cadabra}
   {\theta, \varphi}::Coordinate.
   {a,b,c,d,e,f,g,h#}::Indices(values={\theta, \varphi}, position=independent).

   bah := {V_{\theta} = \varphi, V_{\varphi} = \sin(\theta)}.  # cdb(ex-0603.100,bah)
   foo := U_{a} V_{b}.                                         # cdb(ex-0603.101,foo)

   evaluate (foo, bah)                                         # cdb(ex-0603.102,foo)
\end{cadabra}

\begin{align*}
   & \Cdb{ex-0603.100}\\[10pt]
   & \Cdb{ex-0603.101}\\[10pt]
   & \Cdb{ex-0603.102}
\end{align*}

\end{document}