\chapter{Results}\label{ch:results}

In this chapter, we discuss the application of the IM-SRG
to calculate the ground-state energies of two different fermionic systems.
The first is the pairing Hamiltonian,
which has been used to study pairing effects in finite and infinite systems.
We use this well-studied system as a benchmark for our numerical implementation,
as its small modelspace allows for calculations to complete relatively quickly.
The second is ${}^4\text{He}$,
the lightest closed-shell nucleus,
in a restricted modelspace in the IM-SRG(2).
The results of our implementation are then compared
against those from another open-source IM-SRG(2) library.

\section{The pairing Hamiltonian}

The pairing Hamiltonian is given by
\begin{equation}\label{eq:pairing_hamiltonian}
  H = \delta \sum_{p\sigma} (p - 1) \crea{p\sigma} \annih{p\sigma}
  - \frac{g}{2} \sum_{p q} \crea{p+}\crea{p-} \annih{q-} \annih{q+}\,,
\end{equation}
where we have equally-spaced two-fold degenerate levels indexed by the quantum number $p$
and an attractive (for $g > 0$) pairing interaction.
Cooper first considered this Hamiltonian in 1956~\cite{Coop56pairing_hamiltonian},
which led to the successful Bardeen-Cooper-Schreifer (BCS) theory of superconductivity~\cite{Bard57bcs}.
The exact eigenvalues of the pairing Hamiltonian were given by Richardson in 1963,
where the solutions are obtained via the solution of the non-linear coupled Richardson equations~\cite{Rich63pairing_hamiltonian}.

We focus on a restricted case where $p=1,\ldots,4$ and $\delta=1\mev$,
and we vary the strength of the pairing interaction $g$.
We are interested in the ground state of four fermions,
for which our reference state is the state with the two lowest levels completely filled,
\begin{equation}\label{eq:pairing_hamiltonian_reference}
  \refgnd = \crea{2-}\crea{2+}\crea{1-}\crea{1+}\ket{0}\,.
\end{equation}
This system has a couple of useful properties:
First, the number of single-particle states is only eight,
making the IM-SRG(3) calculation relatively tractable.
Additionally, one can increase the number of levels $p_{\text{max}}$ easily
to get a handle on the performance for larger single-particle basis sizes.
Second, in addition to the available exact solution,
this system is easy to construct and diagonalize in the basis
of the reference state and its particle-hole excitations,
\begin{equation}
  \{\refgnd, \refhp{ij}{ab}, \refhp{ijkl}{abcd} \}\,,
\end{equation}
where the odd number particle-hole excitations do not contribute
as Eq.~\ref{eq:pairing_hamiltonian} only couples pairs.
This makes it easy to obtain an exact solution with which to compare the IM-SRG(2)
and IM-SRG(3) solutions.
Finally, after normal ordering the Hamiltonian with respect to our reference state,
we find that $\hnoone$ is diagonal,
meaning our reference state is the canonical Hartree-Fock reference state
with the Hartree-Fock energy $\hnozero=E_{\text{HF}}=2 - g$.
This means the IM-SRG evolution must only bring in correlation corrections to the energy
without needing to overcome any reference state deficiencies.

\begin{figure}[t]
  \centering
  \includegraphics[width=0.9\textwidth]{proposal/doc/images/pairing_ham_imsrg3.pdf}
  \caption[
    The correlation energy $E_{\text{corr}}$ for the solution of the pairing Hamiltonian
    obtained via exact diagonalization,
    IM-SRG(2), and IM-SRG(3)
    for $-1 \le g \le 1$.
  ]{
    The correlation energy $E_{\text{corr}}$ for the solution of the pairing Hamiltonian
    obtained via exact diagonalization,
    IM-SRG(2), and IM-SRG(3)
    for $-1 \le g \le 1$.
    Exact diagonalization results obtained using code published with Ref.~\cite{Liet16lecnotesphysics}.
  }\label{fig:pairing_hamiltonian_fig}
\end{figure}

Thus, we are interested in the correlation energy obtained by the IM-SRG(2) and IM-SRG(3) solutions,
defined as
\begin{equation}
  E_{\text{corr}} = E(\infty) - E(0)\,.
\end{equation}
This is plotted in Fig.~\ref{fig:pairing_hamiltonian_fig} for $-1 \le g \le 1$.
We find generally good agreement between the IM-SRG correlation energy
and the exact correlation energy,
with the exception of the region for $0.5 \le g \le 1$.
Here, the IM-SRG(3) calculation improves upon the relatively large error in the IM-SRG(2)
correlation energy,
which in Ref.~\cite{Herg16imsrglecnotes}
was explained as being due to an overcounting in the fourth-order diagrams in MBPT
by a factor of 1/2 present in the IM-SRG(2) truncation.
It seems that this overcounting at fourth-order is lifted in the IM-SRG(3)
replaced by some overcounting at a higher MBPT order,
where the contributions are smaller in magnitude.
We note here that our results for IM-SRG(2) match exactly with those from Ref.~\cite{Herg16imsrglecnotes}.

\section{\texorpdfstring{${}^4\text{He}$}{Helium-4}}

The second system we consider here is ${}^4\text{He}$,
the lightest closed-shell nucleus.
Before we begin a discussion about the details of the system,
a few comments are in order.
The following calculation is restricted to a very small modelspace,
one insufficient to achieve converged results for observables.
This is because our implementation does not take advantage of the rotational invariance
of spherically symmetric systems,
that is, that the normal-ordered two- and three-body Hamiltonians
are diagonal in $J$ and $\mathcal{J}$
and independent of $M_{J}$ and $M_{\mathcal{J}}$.
The exploitation of the symmetries leads to so-called $J$-scheme IM-SRG flow equations.
The current results are a benchmark implementation for the IM-SRG(2)
that are compared against an existing IM-SRG(2) $J$-scheme implementation~\cite{Stro15imsrgcpp}.
This serves as an additional validation of our implementation
in addition to the results for the pairing Hamiltonian.
The current implementation will serve as a benchmark
against which we can compare our $J$-scheme IM-SRG(3) implementation,
which will be the focus of the next phase of this project.

As input into our calculation, we start with the intrinsic $A$-body Hamiltonian
with only an initial two-body interaction,
\begin{equation}
  H_{\text{int}} = T_{\text{int}} + \twobodyop{V}\,,
\end{equation}
with the intrinsic kinetic energy
\begin{align}
  T_{\text{int}} &= T - T_{\text{cm}} \\
                 &= \left(1 - \frac{1}{A}\right) \sum_{i} \frac{p_{i}^{2}}{2m}
                 - \frac{1}{A}\sum_{i<j}\frac{p_{i} \cdot p_{j}}{m}\,.
\end{align}
We note that the first term gives us our one-body Hamiltonian
and the second term contributes to the two-body Hamiltonian along with $\twobodyop{V}$~\cite{Herg09intrinsicham}.

We work in the single-particle harmonic-oscillator basis
at several different values of $\hbar \Omega$
(see Section~\ref{sec:sp_ho}),
with the single-particle states
\begin{equation}
  \ket{n_a (l_a s_a) j_a m_{j_a} t_a m_{t_a}} \equiv \ket{\alpha_a}\,,
\end{equation}
where $s_a=1/2$ and $t_a=1/2$.
A natural ordering of these states is according to their energy quantum number,
$e = 2  n + l$.
For the following calculation, we truncate the single-particle basis at $\emax=2$.
The resulting size of our single-particle basis is $N=40$.
As our reference state for ${}^4\text{He}$ we choose to fill the four $e=0$ HO states,
the most reasonable choice to target the ground state
without solving for and transforming to the Hartree-Fock basis.

\begin{figure}[t]
  \centering
  \includegraphics[width=0.45\textwidth]{proposal/doc/images/he4_imsrg2_energies.pdf}
  \includegraphics[width=0.45\textwidth]{proposal/doc/images/he4_imsrg2_flow.pdf}
  \caption[
    The left panel shows $E(0)$ and $E(\infty)$
    for an IM-SRG(2) calculation of ${}^4\text{He}$
    for $\hbar \Omega$ ranging from $16\mev$ to $32\mev$.
    The interaction used is the EM NN interaction
    with a regulator cutoff $\Lambda=500\mev$
    and SRG-evolved to $\lambda=1.8\invfm$.
    The right panel shows the flowing energy $E(s)$
    along with the energy with second- and third-order MBPT corrections included
    for $\hbar \Omega=32\mev$.
  ]{
    The left panel shows $E(0)$ and $E(\infty)$
    for an IM-SRG(2) calculation of ${}^4\text{He}$
    for $\hbar \Omega$ ranging from $16\mev$ to $32\mev$.
    The interaction used is the EM NN interaction
    with a regulator cutoff $\Lambda=500\mev$
    and SRG-evolved to $\lambda=1.8\invfm$~\cite{Ente03n3lonn}.
    The right panel shows the flowing energy $E(s)$
    along with the energy with second- and third-order MBPT corrections included
    for $\hbar \Omega=32\mev$.
  }\label{fig:imsrg2_he4_results}
\end{figure}

For $\twobodyop{V}$, we use the EM NN potential from Ref.~\cite{Ente03n3lonn} at N3LO
with a regulator cutoff at $\Lambda=500\mev$ and SRG-evolved to $\lambda=1.8\invfm$.
This potential has been shown to reproduce experimental binding energies
across the nuclear chart very well~\cite{Hebe20habi}.
The results from normal ordering our Hamiltonians at the different $\hbar \Omega$
with respect to our HO reference state
and evaluating the IM-SRG(2) evolution are shown
in the left panel of Fig.~\ref{fig:imsrg2_he4_results}.
We find that the unevolved energy $E(0)$,
that is, the energy expectation value of the reference state,
is already good to within 30\% of the exact result,
a consequence of the SRG-softened interaction we are using.
Still, the IM-SRG evolution absorbs up to $8\mev$ of correlation energy into the ground-state energy.
We also find that our implementation agrees with the implementation from Ref.~\cite{Stro15imsrgcpp}
to within $10^{-5}\mev$.

In the right panel of Fig.~\ref{fig:imsrg2_he4_results},
we show the flowing ground-state energy
as well as the ground-state energy with second- and third-order MBPT corrections.
We find that these corrections vanish as the correlations are absorbed into the ground-state energy,
indicating that we are achieving the desired decoupling.
We emphasize once again that these results are intended to be interpreted as validation
(for example, as a nuclear-like toy model)
and not as physically meaningful.
We consider the agreement between our implementation and that of Ref.~\cite{Stro15imsrgcpp}
to be \textit{a posteriori} evidence of the correctness of our implementation.


 \documentclass [12pt]{article}

\usepackage {amsmath}
\usepackage {amsthm}
\usepackage {amssymb}
\usepackage {graphicx}
\usepackage {float}
\usepackage {multirow}
\usepackage {xcolor}
\usepackage {algorithmic}
\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \usepackage {array}
\usepackage {booktabs}
\usepackage {url}
\usepackage {parskip}
\usepackage [margin=1in]{geometry}
\usepackage [T1]{fontenc}
\usepackage {cmbright}
\usepackage [many]{tcolorbox}
\usepackage [colorlinks = true,
            linkcolor = blue,
            urlcolor  = blue,
            citecolor = blue,
            anchorcolor = blue]{hyperref}
\usepackage {enumitem}
\usepackage {xparse}
\usepackage {verbatim}
\usepackage{listings}
\usepackage{xcolor}
\lstset { %
    language=C++,
    backgroundcolor=\color{black!5}, % set backgroundcolor
    basicstyle=\footnotesize,% basic font setting
}
\newtheorem{theorem}{Theorem}
\newtheorem{remark}{Remark}

\DeclareTColorBox {Solution}{}{breakable, title={Solution}} \DeclareTColorBox {Solution*}{}{breakable, title={Solution (provided)}} \DeclareTColorBox {Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt} \DeclareDocumentCommand {\Expecting }{+m}{\textbf {[We are expecting:} #1\textbf {]}} \DeclareDocumentCommand {\Points }{m}{\textbf {(#1 pt.)}}

\begin {document}

\vspace {1em}
\begin {Instruction}
Adapted From Virginia Williams' lecture notes.
\end {Instruction}

{\LARGE \textbf {COMP 285 (NC A\&T, Spr `22)}\hfill \textbf {Lecture 17} }

\begin{centering}
\section*{Applications of Breadth-First Search}
\end{centering}

 \section{Breadth-First Search}
 In depth first search, we search ``deeper'' in the graph whenever possible, exploring edges out of the most recently discovered node that still has unexplored edges leaving it. Breadth first search (BFS) instead expands the frontier between discovered and undiscovered nodes uniformly across the breadth of the frontier, discovering all nodes at a distance $k$ from the source node before nodes at distance $k + 1$. BFS($s$) computes for every node $v \in G$ the distance from $s$ to $v$ in $G$. $d(u, v )$ is the length of the shortest path from $u$ to $v$ . A simple property of unweighted graphs is as follows: let $P$ be a shortest $u \to v$ path and let $x$ be the node before $v$ on $P$. Then $d(u, v) = d(u, x) + 1$.

\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{bfs_path.png}
\end{figure}

BFS(s) computes sets $L_i$, the set of nodes at distance $i$ from $s$, as seen in the diagram below.

\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{bfs_layers.png}
\end{figure}

\begin{algorithm}
\caption{\texttt{BFS}(s)}
\label{alg:BFS_s}
\begin{algorithmic}
\STATE Set vis[v] $\gets$ false for all $v$
\STATE Set $L_i \gets \emptyset$ for $i \in \{1, \cdots, n-1\}$
\STATE $L_0 \gets \{ s \}$
vis[s] $\gets$ true
\FOR{$i = 0, \cdots, n-1$}
    \IF{$L_i = \emptyset$}
        \STATE Exit
    \ENDIF
    \WHILE{$L_i \neq \emptyset$}
        \STATE $u \gets L_i$.pop()
        \STATE // In the loop below, replace $N$ with $N_{\text{out}}$ for a direct graph
        \FOR{$x \in N(u)$}
            \IF{$vis[x] = false$}
                \STATE $vis[x] \gets $ true
                \STATE $L_{i+1}$.insert(x)
                \STATE $p(x) \gets u$
            \ENDIF
        \ENDFOR
    \ENDWHILE
\ENDFOR
\end{algorithmic}
\end{algorithm}

\subsection{Runtime Analysis}
We will now look at the runtime for our BFS algorithm (Line 5) for a graph with $n$ nodes and $m$ edges. All of the initialization above the first for loop runs in $O(n)$ time. Visiting each node within the while loop takes $O(1)$ time per node visited. Everything inside the inner for loop takes $O(1)$ time per edge scanned, which we can simplify to a runtime of $O(m)$ time overall for the entire inner for loop. Overall, we see that our runtime is $O($\# nodes visited + \# edges scanned$) = O(m + n)$.

\subsection{Correctness}
We will now show that BFS correctly computes the shortest path between the source node and all other nodes in the graph. Recall that $L_i$ is the set of nodes that BFS calculates to be distance $i$ from the source node.

\textbf{Proposition 1}. For all $i, L_i = \{x \mid d(s, x) = i\}$.

\textbf{Proof.} We will prove this by (strong) induction on $i$.

\textbf{Base case}: $i = 0$, and $L_0 = \{s\}$.

\textbf{Induction hypothesis}: Suppose that $L_j = \{x \mid d(s, x) = j\}$ for every $j \leq i$ (induction hypothesis for $i$).

\textbf{Inductive step}: We will show two things: (1) if $y$ was added to $L_{i+1}$, then $d(s, y ) = i + 1$, and (2) if $d(s, y ) = i + 1$, then y is added to $L_{i+1}$. After proving (1) and (2) we can conclude that $L_{i+1} = \{y \mid d(s, y ) = i + 1\}$ and complete the induction.

Let's prove (1). First, if $y$ is added to $L_{i+1}$, it was added by traversing an edge $(x, y )$ where $x \in L_i$ , so that there is a path from $s$ to $y$ taking the shortest path from $s$ to $x$ followed by the edge $(x, y )$, and so $d(s, y ) \leq d(s, x) + 1$. Since $x \in L_i$ , by the induction hypothesis, $d(s, x) = i$, so that $d(s, y ) \leq i + 1$. However, since $y \in L_j$ for any $j \leq i$, by the induction hypothesis, $d(s, y ) > i$, and so $d(s, y ) = i + 1$.

Let's prove (2). If $d(s, y ) = i + 1$, then by the inductive hypothesis $y \in L_j$ for $j \leq i$. Let $x$ be the node before $y$ on the $s \to y$ shortest path $P$. As $d(s, y ) = i + 1$ and the portion of $P$ from $s $ to $x$ is a shortest path and has length exactly $i$. Thus, by the induction hypothesis, $x \in L_i $. Thus, when $x$ was scanned, edge $(x, y )$ was scanned as well. If $y$ had not been visited when $(x, y )$ was scanned, then $y$ will be added to $L_{i+1}$. Hence assume that $y$ was visited before $(x, y )$ was scanned. However, since $y \in L_j$ for any $j \leq i$, $y$ must have been visited by scanning another edge out of a node from $L_i$ , and hence again y is added to $L_{i+1}$.

\subsection{BFS versus DFS}

If you simplify BFS and DFS to the basics, ignoring all timestamps and levels that we would usually create, BFS and DFS have a very similar structure. Breadth first search explores the nodes closest and then moves outwards, so we can use a queue (first in first out data structure) to put new nodes at the end of the list and pull the oldest/nearest nodes from the top of the list. Depth first search goes as far down a path as it can before coming back to explore other options, so we can use a stack (last in first out data structure) which pushes new nodes on the top and also pulls the newest nodes from the top. See the pseudocode below for more detail.

\begin{algorithm}
\caption{\texttt{DFS}(s): $s$ is the source node}
\label{alg:DFS_s}
\begin{algorithmic}
\STATE T $\gets$ empty stack
Push $s$ onto $T$
\WHILE{$T$ is not empty}
    \STATE $u \gets$ pop from top of $T$
    \STATE Push all unvisited neighbors of $u$ on top of stack $T$
\ENDWHILE
\end{algorithmic}
\end{algorithm}

\begin{algorithm}
\caption{\texttt{BFS}(s): $s$ is the source node}
\label{alg:BFS_s}
\begin{algorithmic}
\STATE T $\gets$ empty queue
Push $s$ onto $T$
\WHILE{$T$ is not empty}
    \STATE $u \gets$ pop from front of $T$
    \STATE Push all unvisited neighbors of $u$ on back of queue $T$
\ENDWHILE
\end{algorithmic}
\end{algorithm}

\end{document}


\documentclass[12pt,a4]{article}

\usepackage{graphicx,subfigure,a4wide,noparindent}

\title{Designing complex Gabor filters}
\author{Bill Christmas}

\begin{document}

\maketitle

\section{Introduction}

In order to detect texture in scenes, the human visual system uses a set of bandpass filters that vary in orientation and centre frequency.  A Gabor filter bank is a set of regularly spaced filters that very approximately mimic this behaviour.  Typical filters might have point spread functions such as:

\begin{center}
  \includegraphics{psf}  \hspace{2cm} \includegraphics{psf45}
\end{center}

\section{Design principles}

Consider first a single prototype filter, for example the left-hand example above.  Such a filter has a point spread function of the form:
\[ g(x,y) = {1 \over 2 \pi  \sigma_r\sigma_\theta}\;
\exp \left\{ -{1\over2} \left[{\left(x\over\sigma_r\right)^2+\left(y \over \sigma_\theta\right)^2}\right]\right\} \;
\cos\left(2\pi U x\right) \]
The exponential term defines a Gaussian-shaped envelope of elliptical shape, and the cosine term defines the centre frequency.  The Gaussian envelope shape is used to get the best compromise of minimising the filter width in both spatial and frequency domains.  The constants are chosen so that the filter has unity gain at zero frequency, with parameters $\sigma_r, \sigma_\theta$ that express the filter width as a ``standard deviation'' in units of pixels.

The problem with such a p.s.f.\ is that the response ripples in a similar manner to the cosine term in the p.s.f.  A convenient way to deal with this is instead to use a complex p.s.f.:
\[ g(x,y) = {1 \over 2 \pi  \sigma_r\sigma_\theta}\;
\exp \left\{ -{1\over2} \left[{\left(x\over\sigma_r\right)^2+\left(y \over \sigma_\theta\right)^2}\right]\right\} \;
\exp\left(i2\pi U x\right) \]
and to deal with the resulting complex filtered image by taking its modulus.  This gives a final response whose shape is influence by the Gaussian envelope of the p.s.f.\ instead of the p.s.f.\ itself.

The Fourier transform of the p.s.f.\ is given by:
\begin{equation}
  G(u,v) = \exp \left\{ -2\pi^2\left[ \sigma_r^2 (u-U)^2 +\sigma_\theta^2 v^2 \right] \right\}\label{eq:G}
\end{equation}
--- i.e.\ an elliptical shape whose centre is offset on the $u$ axis by the centre frequency $U$.

The frequency coordinate system can then be rotated and scaled to create an array of filters of $N$ different orientations and $M$ different scales, using the substitution:

\[ {u \choose v} = s^m \left( \begin{array}{rr}\cos \pi{n\over N} & \sin
    \pi{n\over N} \\ -\sin \pi{n\over N} & \cos \pi{n\over N}
  \end{array}\right) {u' \choose v'} ,\; m = 0, 1, \ldots, M-1,\; n = 0, 1,
\ldots N-1,\; s > 1 \] where $u', v'$ are the coordinates of a general filter.
The scale ratio parameter $s$ thus defines both the ratio of the centre
frequencies of filters of adjacent scales, and also their widths.

If we are using these filters for digital image processing, we also need to determine the frequency scales, to ensure that the same proportion of the spectrum is covered in both dimensions.  In the above analysis, the frequencies $u, v$ are in the continuous domain, and have units of cycles per unit length.  We can arbitrarily choose our unit length to be a pixel width, $p$ (assuming square pixels), in which case the frequency units are $1/p$.  In the sampled domain however the frequency units are related to the image dimensions (which are generally different from each other).  If the image width and height are $L_w$ and $L_h$ pixels respectively, the units of the frequency samples are $1/(L_w p)$, $(1/L_h p)$.  Hence if the sampled frequencies are $k_u, k_v$, then
\[ {u' \choose v'} = {{k_u \over L_w} \choose {k_v \over L_h}} \]

The result is a set of filters that covers one half of the complex frequency plane, shown in Fig.~\ref{fig:spectrum}.  (We do not populate the lower half of the plane because the extra filters would have the same response as the existing ones.)  The set of filters can be made a little more compact by offsetting every other scale by $1\over 2$ of the angular separation, shown in Fig.~\ref{fig:shifted} (here the middle of the 3 scales).  Note however that this will reduce the number of filters that explicitly detect perceptually important vertical lines.
\begin{figure}[t]\centering
  \subfigure[no offset]{\includegraphics{maskfig}\label{fig:spectrum}}
  \hspace{2em}
  \subfigure[with alternate scales offset]{\includegraphics{offsetfig}\label{fig:shifted}}
  \caption{Spectral representation of filters: $M=3$, $N=6$, $s=2$\label{fig:spectra}}
\end{figure}

\section{Setting the scale parameters}

The filter scale parameters are set as follows.  Note that $\sigma_\theta$, $\sigma_r$ are the filter scales in the {\em spatial} domain.

\paragraph{$\mathbf{\sigma_\theta}$:}
This represents the filter scale in pixels in the tangential direction of the highest frequency filters.  It is more or less inversely proportional to the tangential filter separation.  Half-way between the centres of two filters adjacent in the tangential direction, the filter responses are equal ($=\delta$, say where $\delta < 1$). The distance between the two filters is given by (Fig.~\ref{fig:circles}):
\def\Sinpbnn{\sin{\left(\pi\over2N\right)}}
\[ 2r = 2U \Sinpbnn \]
Since  $\delta$ is the response of a filter at a distance $U\sin(\pi/2N)$ from its centre in what is approximately the tangential direction, and $u$ is constant in the tangential direction ($u = U$ for the highest frequency filters), then from (\ref{eq:G}):

\[ \delta = \exp \left[ -2\pi^2 \left(\sigma_\theta U \Sinpbnn\right)^2  \right] \]
\[ \rightarrow\quad \sigma_\theta =
  \sqrt{-\ln\delta \over 2\pi^2}\; {1 \over U\Sinpbnn}
\]

Using $\delta = {1\over2}$ gives a reasonably uniform overall coverage of the spectrum in the tangential direction, in which case:
\[ \sigma_\theta \approx {0.19 \over U\Sinpbnn} \]

\paragraph{$\mathbf{\sigma_r}$, no offsetting:}
$\sigma_r$ represents the filter scale in the radial direction of the highest frequency filters (the outer semi-ring in Fig.~\ref{fig:spectra}).  If we do not offset alternate scales (Fig.~\ref{fig:spectrum}), $\sigma_r$ and $\sigma_\theta$ are independent, so $\sigma_r$ depends only on the radial filter separation, which is a function of the scale ratio $s$.  The responses $\delta$ of the two outermost radially adjacent filters are equal when
\[ \exp\left[ -2\pi^2 \sigma_r^2 (u-U)^2\right]
= \exp\left[ -2\pi^2 \sigma_r^2 \left(su-U\right)^2\right] = \delta \]

Selecting appropriate roots:
\begin{eqnarray}
   \sigma_r &=& \sqrt{-\ln{\delta}\over 2\pi^2} \;{s+1\over U(s-1)} \label{eq:sigma_r}\\
   &=& {s+1\over s-1}\; \Sinpbnn\; \sigma_\theta \nonumber
\end{eqnarray}
For $\delta={1\over2}$:
\[ \sigma_r \approx 0.19 {s+1\over U(s-1)} \]

\paragraph{$\mathbf{\sigma_r}$, with offsetting:}
When alternate scales are offset by one half of the filter width (Fig.~\ref{fig:shifted}) the situation is more complicated.  Consider first the case when the filters are circular, i.e.\
\begin{equation}
  \label{eq:circ}
  \sigma_r = \sigma_\theta
\end{equation}

\begin{figure}
  \centering
  \includegraphics[width=0.6\textwidth]{circles}
  \caption{Geometry for offset circular Gabor filters; $N = 3$}
  \label{fig:circles}
\end{figure}
From basic geometrical properties (Fig.~\ref{fig:circles}), we can see that
\[ \alpha + \beta = {N+1\over 2N}\pi, \quad \sin\alpha = {s_c\over 1+s_c}, \quad \cos\beta = {1\over 1+s_c} \]
where $N$ is the number of filters at the same scale, and $s=s_c$ is the scale ratio required to generate circular filters.

Defining $\tau = \sin\left({N+1\over 2N}\right)$, we can solve for $s_c$:
\[ s_c = {1+\tau-\tau^2 \pm \sqrt{(1+2\tau)(1-\tau^2)}\over \tau^2} \]
The positive root is the required one; the negative one corresponds to $1\over s$. For $N=4$, $s \approx 2$.

In the general case, for a desired value of $s$ we can use (\ref{eq:sigma_r}), (\ref{eq:circ}) to determine an appropriate value for $\sigma_r$:
\[ \sigma_r = {s+1 \over s-1}\: {s_c-1 \over s_c+1}\: \sigma_\theta \]

\section{Speeding up the filtering}

A common complaint of Gabor filters is that the inverse FFT that has to be performed for each of the filters makes the system too slow to be useful.   The basic method performs a 2D inverse FFT over the whole filtered image spectrum.  However, most of this spectrum has almost no energy for a given filter.  If instead we shift the coordinates of the spectrum to the centre frequency of the filter, and crop this spectrum so that we only include regions where the filter has a significant response, the FFT will be correspondingly smaller and hence faster.  Because of the shift of frequency coordinates, the output image is multiplied by a phase term.  Since we take the modulus of the output image, this phase term is removed.  The output image is also smaller: it is the same size as the cropped spectrum.  However, if needed, it can be reinterpolated up to the original image size.

\end{document}


\section{Model counting}
\label{sect:related-work-model-counting}

Model-counting~\cite{SATHandbook-ModelCounting} algorithms can be classified into two categories:
exact counting and approximate counting.
The former adopts DPLL-based search with additional techniques,
such as component analysis and caching, to improve the counting efficiency~\cite{Sang2004,Sang2005ModelCounting}.
Knowledge compilation has also been applied to exact model counting.
For example, \ctwod~\cite{Darwiche2001,Darwiche2002dDNNF} compiles a CNF formula into its d-DNNF and performs counting on this data structure.
The latter takes a different strategy,
aiming at providing lower and/or upper bounds with guarantee on confidence level.
Ideas from statistics~\cite{Chakraborty2013,Chakraborty2016} have been adopted to increase the capacity limit of model counting.

\begin{table}[t]
    \centering
    \caption{Model-counting variants and their corresponding SSAT formulas}
    \label{tbl:related-work-model-counting}
    \begin{tabular}{c|c}
        Model-Counting Variant & SSAT Encoding                                                                                \\
        \hline
        Unweighted             & $\random{0.5}x_1,\ldots,\random{0.5}x_n.\pf(x_1,\ldots,x_n)$                                               \\
        Weighted               & $\random{p_1}x_1,\ldots,\random{p_n}x_n.\pf(x_1,\ldots,x_n)$                                               \\
        Projected              & $\random{0.5}x_1,\ldots,\random{0.5}x_n,\exists y_1,\ldots,\exists y_m.\pf(x_1,\ldots,x_n,y_1,\ldots,y_m)$ \\
        Maximum                & $\exists x_1,\ldots,\exists x_n,\random{0.5}y_1,\ldots,\random{0.5}y_m.\pf(x_1,\ldots,x_n,y_1,\ldots,y_m)$ \\
        Weighted projected     & $\random{p_1}x_1,\ldots,\random{p_n}x_n,\exists y_1,\ldots,\exists y_m.\pf(x_1,\ldots,x_n,y_1,\ldots,y_m)$ \\
        Maximum weighted       & $\exists x_1,\ldots,\exists x_n,\random{p_1}y_1,\ldots,\random{p_m}y_m.\pf(x_1,\ldots,x_n,y_1,\ldots,y_m)$ \\
    \end{tabular}
\end{table}

There are many variants of model counting.
For example,
weighted model counting asks to aggregate the weight of every satisfying assignment.
It has been widely adopted in probabilistic inference~\cite{Sang2005BayesianInference,Chavira2008}.
\textit{Projected model counting}~\cite{Aziz2015} computes the numbers of satisfying assignments
projected on a subset of original variables.
\textit{Maximum model counting}~\cite{Fremont2017} finds an assignment to a subset of variables in a formula
such that the number of satisfying assignments of the residual formula cofactored with the assignment is maximized.

The above variants of model counting can be expressed via SSAT,
because the randomized quantifiers of SSAT essentially aggregate the results from different branches with weights.
\Cref{tbl:related-work-model-counting} shows the variants of model-counting problems and their respective SSAT encodings.
Note that weighted projected model counting and maximum weighted model counting are equivalent to
random-exist quantified SSAT and exist-random quantified SSAT, respectively.

Model counting is under active research.
Recent advancements include \dpmc~\cite{Dudek2020},
a dynamic-programming framework for exact weighted model counting based on \textit{project-join} trees.
\dpmc applies tree decomposition to the constraint graph of a CNF formula to obtain a project-join tree
and aggregates the weight of the formula with \textit{arithmetic decision diagrams} using dynamic programming.
\dpmc is further extended to a weighted projected model counter \procount~\cite{Dudek2021}
by requiring the projected variables to be placed on top of the non-projected variables in a project-join tree.
Other latest developments of model counting can be found in the report~\cite{MC-COMP2020} of the 2020 Model Counting Competition.


\section{Conclusion}

\frame{\tableofcontents[currentsection]}

\begin{frame}
    \frametitle{Comparison}
    \begin{center}
        \begin{tabular}{lcc}
            & \textbf{Array} & \textbf{Linked List} \\
            \midrule
            Length & $O(1)$ & $O(n)$ \\
            Indexing & $O(1)$ & $O(n)$ \\
            Updating & $O(n)$ & $O(n)$ \\
            Add to front & $O(n)$ & $O(1)$ \\
            Concatenation & $O(n_1+n_2)$ & $O(n_1)$ \\
            \bottomrule
        \end{tabular}
    \end{center}
\end{frame}

\begin{frame}
    \frametitle{Usage}
    \begin{itemize}
        \item Linked lists are often used for sequential processing
              \begin{itemize}
                \item Move left to right
                \item No indexing necessary
                \item Build new list as you go
              \end{itemize}
        \item Don't treat linked lists as if they were arrays!
    \end{itemize}
\end{frame}


\section{Task Assignment Policies for Server Farms}
\label{sec:task-assignment-policies-server-farms}

The server farm architecture is ubiquitous in computer systems, because of its cost-efficiency and flexibility.
We analyze server farm in the context of high-variability workloads.

The task assignment policy is the rule implemented by the dispatcher\footnote{also known as front-end router, or load-balancer.} to assign incoming jobs to servers.
Under high-variability workloads, the task assignment policy hugely influences the mean response time.

In our discussion, we assume Poisson arrival process and Bounded-Pareto service times.

% insert here Figure 24.1 Server farm model

Task assignment policies are categorized according to (i) a priori job size knowledge (size-based/non-size-based), (ii) adaptation to the system state (dynamic/static), and (iii) job preemption (preemptive/non-preemptive).

The most common policies are:

\begin{description}

	\item [Random Order (RO)]

	\item [Round-Robin (RR)]

	\item [Join-Shortest-Queue (JSQ)]

	\item [Least-Work-Left (LWL)]

	\item [Size-Interval Task Assignment (SITA)]

	\item [Shortest-Remaining Process-Time (SRPT)]
\end{description}

\subsection{Task Assignment in FCFS Server Farms}
\label{sec:task-assignment-fcfs-server-farms}
The FCFS server farm model is common in manufacturing systems and supercomputing, where jobs are hardly preemptible.

Under high-variability workloads, we have that

\begin{equation}
\expected{T^{\mathcal{SITA}}} <
\expected{T^{\mathcal{M/G/m}}} \approx
\expected{T^{\mathcal{LWL}}} <
\expected{T^{\mathcal{JSQ}}} <
\expected{T^{\mathcal{RR}}} <
\expected{T^{\mathcal{RO}}}
\end{equation}

% insert here explanation.

\subsection{Task Assignment in PS Server Farms}
\label{sec:task-assignment-ps-server-farms}
The PS server farm model is common in web servers and data centers, where jobs are natively preemptible and resources are totally shared among jobs.

The job size distribution for website is known to be high variable and heavy-tailed \cite{crovella1997self}. It is not unrealistic to assume Poisson arrivals. It is not realistic to assume the independence of job sizes and inter-arrival times \cite{ghosh2004analysis,squillante1999internet}.

PS scheduling is invariant to job size variability, hence the benefits of SITA in reducing it are superfluous.

JSQ in surprisingly nearly insensitive to job size variability in PS server farms \cite{gupta2007analysis}.

Both under high and low variability workloads, we have that

\begin{equation}
\expected{N^{\mathit{JSQ}}} <
\expected{N^{\mathit{LWL}}} <
\expected{N^{\mathit{RR}}} <
\expected{N^{\mathit{SITA}}} \approx
\expected{T^{\mathit{RO}}}
\end{equation}

% insert here explanation.

\subsection{Optimal Server Farm Design}
\label{sec:optimal-server-farm-design}

The optimal server farm design is mainly based on the selection of the best task-assignment and scheduling policies\footnote{typically, the scheduling policy is dictated by operating systems and applications on servers.}.

In the \textit{Worst-Case Analysis}, the policy $\mathcal{P}$ is evaluated on each possible arrival sequence $\mathcal{A}$ and is compared with the optimal policy $\mathcal{OPT}$ for that arrival sequence.
The analysis evaluates policies looking for that one that minimizes the \textit{competitive ratio} $CR_{\mathcal{P}}$, defined as follow:

 \begin{equation}
 CR_{\mathcal{P}}=\max_{\mathcal{A}}r_{\mathcal{P}}(\mathcal{A})
 \end{equation}

 with

 \begin{equation}
 r_{\mathcal{P}}(\mathcal{A})=\frac{\expected{T(\mathcal{A})}^{\mathcal{P}}}{\expected{T(\mathcal{A})}^{\mathcal{OPT}}}
 \end{equation}

 The drawback of this kind of analysis is that a policy $\mathcal{P}$ can be viewed as poor, even if it performs badly only on an improbable arrival sequence.

 The \textit{Shortest-Remaining-Process-Time (SRPT)} policy preemptively assign jobs with the shortest remaining process time. This policy is effective at getting short jobs out.
 SRPT is optimal for single queue server farms with $m$ $M/G/1/1$ hosts under any \footnote{there is an arrival sequence where causing starvation. See \cite{harchol2013performance} on page 425.} arrival sequence \cite{schrage1968letter}.
 At every time, the $m$ jobs with the shortest remaining process time are those in service. Such a server farm behaves like a $M/M/1$ node with a server $m$ time faster.
 Thanks to this notable result, we refer to such an asset with the name \textit{Central-Queue-SRPT}.

 \cite{leonardi1997approximating} proved that Central-Queue-SRPT is the best possible online algorithm\footnote{from a worst-case analysis point of view, and unless of a constant multiplicative factor.}, with $CR\propto\log\Big(\frac{b}{a}\Big)$, where $b$ and $a$ are respectively the biggest and the smallest job size.

A related open problem is the optimal task assignments under immediate dispatching, meaning that jobs cannot be held in a central queue, but immediately sent to hosts.
This restriction has practical importance because of its wide applicability\footnote{e.g. web server must immediately establish connections with clients.}.

The IMD algorithm presented by \cite{avrahami2003minimizing} divides jobs in size-based classes, and then assigns each incoming job to the server with the smallest number of jobs of that class. The balanced distribution of classes maximizes the effectiveness of the SRPT scheduling policy implemented by each server. It has been proven that, from a worst-case point of view, IMD under immediate dispatching restriction is equal to SRPT without restriction.


\chapter{Built-in Prefix Operators}
In the following subsections are descriptions of the most useful prefix
\index{Prefix}
operators built into {\REDUCE} that are not defined in other sections (such
as substitution operators). Some are fully defined internally as
procedures; others are more nearly abstract operators, with only some of
their properties known to the system.

In many cases, an operator is described by a prototypical header line as
follows. Each formal parameter is given a name and followed by its allowed
type. The names of classes referred to in the definition are printed in
lower case, and parameter names in upper case. If a parameter type is not
commonly used, it may be a specific set enclosed in brackets {\tt \{} \ldots
{\tt \}}.
Operators that accept formal parameter lists of arbitrary length have the
parameter and type class enclosed in square brackets indicating that zero
or more occurrences of that argument are permitted. Optional parameters
and their type classes are enclosed in angle brackets.

\section{Numerical Operators}\index{Numerical operator}
{\REDUCE} includes a number of functions that are analogs of those found
in most numerical systems.  With numerical arguments, such functions
return the expected result.  However, they may also be called with
non-numerical arguments.  In such cases, except where noted, the system
attempts to simplify the expression as far as it can.  In such cases, a
residual expression involving the original operator usually remains.
These operators are as follows:

\subsection{ABS}
{\tt ABS}\ttindex{ABS} returns the absolute value
of its single argument, if that argument has a numerical value.
A non-numerical argument is returned as an absolute value, with an overall
numerical coefficient taken outside the absolute value operator. For example:
\begin{verbatim}
	abs(-3/4)     ->  3/4
	abs(2a)       ->  2*ABS(A)
	abs(i)        ->  1
	abs(-x)       ->  ABS(X)
\end{verbatim}

\subsection{CEILING}\ttindex{CEILING}
This operator returns the ceiling (i.e., the least integer greater than
the given argument) if its single argument has a numerical value.  A
non-numerical argument is returned as an expression in the original
operator.  For example:

\begin{verbatim}
	ceiling(-5/4) ->  -1
	ceiling(-a)   ->  CEILING(-A)
\end{verbatim}

\subsection{CONJ}\ttindex{CONJ}
This returns the complex conjugate
of an expression, if that argument has an numerical value.  A
non-numerical argument is returned as an expression in the operators
{\tt REPART}\ttindex{REPART} and {\tt IMPART}\ttindex{IMPART}. For example:
\begin{verbatim}
	conj(1+i)     -> 1-I
	conj(a+i*b)   -> REPART(A) - REPART(B)*I - IMPART(A)*I
			 - IMPART(B)
\end{verbatim}

\subsection{FACTORIAL}\ttindex{FACTORIAL}

If the single argument of {\tt FACTORIAL} evaluates to a non-negative
integer, its factorial is returned.  Otherwise an expression involving
{\tt FACTORIAL} is returned. For example:
\begin{verbatim}
	factorial(5)  ->  120
	factorial(a)  ->  FACTORIAL(A)
\end{verbatim}

\subsection{FIX}\ttindex{FIX}
This operator returns the fixed value (i.e., the integer part of
the given argument) if its single argument has a numerical value.  A
non-numerical argument is returned as an expression in the original
operator.  For example:

\begin{verbatim}
	fix(-5/4)   ->  -1
	fix(a)      ->  FIX(A)
\end{verbatim}

\subsection{FLOOR}\ttindex{FLOOR}
This operator returns the floor (i.e., the greatest integer less than
the given argument) if its single argument has a numerical value.  A
non-numerical argument is returned as an expression in the original
operator.  For example:

\begin{verbatim}
	floor(-5/4)   ->  -2
	floor(a)      ->  FLOOR(A)
\end{verbatim}

\subsection{IMPART}\ttindex{IMPART}
This operator returns the imaginary part of an expression, if that argument
has an numerical value.  A non-numerical argument is returned as an expression
in the operators {\tt REPART}\ttindex{REPART} and {\tt IMPART}.  For example:
\begin{verbatim}
	impart(1+i)   -> 1
	impart(a+i*b) -> REPART(B) + IMPART(A)
\end{verbatim}

\subsection{MAX/MIN}

{\tt MAX} and {\tt MIN}\ttindex{MAX}\ttindex{MIN} can take an arbitrary
number of expressions as their arguments.  If all arguments evaluate to
numerical values, the maximum or minimum of the argument list is returned.
If any argument is non-numeric, an appropriately reduced expression is
returned.  For example:
\begin{verbatim}
	max(2,-3,4,5) ->  5
	min(2,-2)     ->  -2.
	max(a,2,3)    ->  MAX(A,3)
	min(x)        ->  X
\end{verbatim}
{\tt MAX} or {\tt MIN} of an empty list returns 0.

\subsection{NEXTPRIME}\ttindex{NEXTPRIME}

{\tt NEXTPRIME} returns the next prime greater than its integer argument,
using a probabilistic algorithm.  A type error occurs if the value of the
argument is not an integer.  For example:
\begin{verbatim}
	nextprime(5)      ->  7
	nextprime(-2)     ->  2
	nextprime(-7)     -> -5
	nextprime 1000000 -> 1000003
\end{verbatim}
whereas {\tt nextprime(a)} gives a type error.

\subsection{RANDOM}\ttindex{RANDOM}

{\tt random(}{\em n\/}{\tt)} returns a random number $r$ in the range $0
\leq r < n$.  A type error occurs if the value of the argument is not a
positive integer in algebraic mode, or positive number in symbolic mode.
For example:
\begin{verbatim}
	random(5)         ->    3
	random(1000)      ->  191
\end{verbatim}
whereas {\tt random(a)} gives a type error.

\subsection{RANDOM\_NEW\_SEED}\ttindex{RANDOM\_NEW\_SEED}

{\tt random\_new\_seed(}{\em n\/}{\tt)} reseeds the random number generator
to a sequence determined by the integer argument $n$.  It can be used to
ensure that a repeatable pseudo-random sequence will be delivered
regardless of any previous use of {\tt RANDOM}, or can be called early in
a run with an argument derived from something variable (such as the time
of day) to arrange that different runs of a REDUCE program will use
different random sequences.  When a fresh copy of REDUCE is first created
it is as if {\tt random\_new\_seed(1)} has been obeyed.

A type error occurs if the value of the argument is not a positive integer.

\subsection{REPART}\ttindex{REPART}
This returns the real part of an expression, if that argument has an
numerical value.  A non-numerical argument is returned as an expression in
the operators {\tt REPART} and {\tt IMPART}\ttindex{IMPART}.  For example:
\begin{verbatim}
	repart(1+i)   -> 1
	repart(a+i*b) -> REPART(A) - IMPART(B)
\end{verbatim}

\subsection{ROUND}\ttindex{ROUND}
This operator returns the rounded value (i.e, the nearest integer) of its
single argument if that argument has a numerical value.  A non-numeric
argument is returned as an expression in the original operator.  For
example:
\begin{verbatim}
	round(-5/4)   ->  -1
	round(a)      ->  ROUND(A)
\end{verbatim}

\subsection{SIGN}\ttindex{SIGN}
{\tt SIGN} tries to evaluate the sign of its argument. If this
is possible {\tt SIGN} returns one of 1, 0 or -1.  Otherwise, the result
is the original form or a simplified variant. For example:
\begin{verbatim}
	sign(-5)      ->  -1
	sign(-a^2*b)  ->  -SIGN(B)
\end{verbatim}
Note that even powers of formal expressions are assumed to be
positive only as long as the switch {\tt COMPLEX} is off.

\section{Mathematical Functions}

{\REDUCE} knows that the following represent mathematical functions
\index{Mathematical function} that can
take arbitrary scalar expressions as their single argument:
\begin{verbatim}
       ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN ASINH
       ATAN ATANH ATAN2 COS COSH COT COTH CSC CSCH DILOG EI EXP
       HYPOT LN LOG LOGB LOG10 SEC SECH SIN SINH SQRT TAN TANH
\end{verbatim}
\ttindex{ACOS}\ttindex{ACOSH}\ttindex{ACOT}
\ttindex{ACOTH}\ttindex{ACSC}\ttindex{ACSCH}\ttindex{ASEC}
\ttindex{ASECH}\ttindex{ASIN}
\ttindex{ASINH}\ttindex{ATAN}\ttindex{ATANH}
\ttindex{ATAN2}\ttindex{COS}
\ttindex{COSH}\ttindex{COT}\ttindex{COTH}\ttindex{CSC}
\ttindex{CSCH}\ttindex{DILOG}\ttindex{Ei}\ttindex{EXP}
\ttindex{HYPOT}\ttindex{LN}\ttindex{LOG}\ttindex{LOGB}\ttindex{LOG10}
\ttindex{SEC}\ttindex{SECH}\ttindex{SIN}
\ttindex{SINH}\ttindex{SQRT}\ttindex{TAN}\ttindex{TANH}
where {\tt LOG} is the natural logarithm (and equivalent to {\tt LN}),
and {\tt LOGB} has two arguments of which the second is the logarithmic base.

The derivatives of all these functions are also known to the system.

{\REDUCE} knows various elementary identities and properties
of these functions. For example:
\begin{verbatim}
      cos(-x) = cos(x)              sin(-x) = - sin (x)
      cos(n*pi) = (-1)^n            sin(n*pi) = 0
      log(e)  = 1                   e^(i*pi/2) = i
      log(1)  = 0                   e^(i*pi) = -1
      log(e^x) = x                  e^(3*i*pi/2) = -i
\end{verbatim}

Beside these identities, there are a lot of simplifications
for elementary functions
defined in the {\REDUCE} system as rulelists. In order to
view these, the SHOWRULES operator can be used, e.g.

\begin{verbatim}
      SHOWRULES tan;

{tan(~n*arbint(~i)*pi + ~(~ x)) => tan(x) when fixp(n),

 tan(~x)

  => trigquot(sin(x),cos(x)) when knowledge_about(sin,x,tan)

 ,

      ~x + ~(~ k)*pi
 tan(----------------)
	    ~d

	     x                             k    1
  =>  - cot(---) when x freeof pi and abs(---)=---,
	     d                             d    2

      ~(~ w) + ~(~ k)*pi           w + remainder(k,d)*pi
 tan(--------------------) => tan(-----------------------)
	    ~(~ d)                           d

			       k
 when w freeof pi and ratnump(---) and fixp(k)
			       d

	   k
  and abs(---)>=1,
	   d

 tan(atan(~x)) => x,

			     2
 df(tan(~x),~x) => 1 + tan(x) }

\end{verbatim}

For further simplification, especially of expressions involving
trigonometric functions, see the TRIGSIMP\ttindex{TRIGSIMP} package
documentation.

Functions not listed above may be defined in the special functions
package SPECFN\ttindex{SPECFN}.

The user can add further rules for the reduction of expressions involving
these operators by using the {\tt LET}\ttindex{LET} command.

% The square root function can be input using the name {\tt SQRT}, or the
% power operation {\tt \verb|^|(1/2)}.  On output, unsimplified square roots
% are normally represented by the operator {\tt SQRT} rather than a
% fractional power.

In many cases it is desirable to expand product arguments of logarithms,
or collect a sum of logarithms into a single logarithm.  Since these are
inverse operations, it is not possible to provide rules for doing both at
the same time and preserve the {\REDUCE} concept of idempotent evaluation.
As an alternative, REDUCE provides two switches {\tt EXPANDLOGS}
\ttindex{EXPANDLOGS} and {\tt COMBINELOGS}\ttindex{COMBINELOGS} to carry
out these operations.  Both are off by default.  Thus to expand {\tt
LOG(X*Y)} into a sum of logs, one can say
\begin{verbatim}
	ON EXPANDLOGS; LOG(X*Y);
\end{verbatim}
and to combine this sum into a single log:
\begin{verbatim}
	ON COMBINELOGS; LOG(X) + LOG(Y);
\end{verbatim}

At the present time, it is possible to have both switches on at once,
which could lead to infinite recursion.  However, an expression is
switched from one form to the other in this case.  Users should not rely
on this behavior, since it may change in the next release.

The current version of {\REDUCE} does a poor job of simplifying surds.  In
particular, expressions involving the product of variables raised to
non-integer powers do not usually have their powers combined internally,
even though they are printed as if those powers were combined.  For
example, the expression
\begin{verbatim}
	x^(1/3)*x^(1/6);
\end{verbatim}
will print as
\begin{verbatim}
	SQRT(X)
\end{verbatim}
but will have an internal form containing the two exponentiated terms.
If you now subtract {\tt sqrt(x)} from this expression, you will {\em not\/}
get zero.  Instead, the confusing form
\begin{verbatim}
	SQRT(X) - SQRT(X)
\end{verbatim}
will result.  To combine such exponentiated terms, the switch
{\tt COMBINEEXPT}\ttindex{COMBINEEXPT} should be turned on.

The square root function can be input using the name {\tt SQRT}, or the
power operation {\tt \verb|^|(1/2)}.  On output, unsimplified square roots
are normally represented by the operator {\tt SQRT} rather than a
fractional power.  With the default system switch settings, the argument
of a square root is first simplified, and any divisors of the expression
that are perfect squares taken outside the square root argument.  The
remaining expression is left under the square root.
% However, if the switch {\tt REDUCED}\ttindex{REDUCED} is on,
% multiplicative factors in the argument of the square root are also
% separated, becoming individual square roots. Thus with {\tt REDUCED} off,
Thus the expression
\begin{verbatim}
	 sqrt(-8a^2*b)
 \end{verbatim}
becomes
\begin{verbatim}
	2*a*sqrt(-2*b).
\end{verbatim}
% whereas with {\tt REDUCED} on, it would become
% \begin{verbatim}
%         2*a*i*sqrt(2)*sqrt(b) .
% \end{verbatim}
% The switch {\tt REDUCED}\ttindex{REDUCED} also applies to other rational
% powers in addition to square roots.

Note that such simplifications can cause trouble if {\tt A} is eventually
given a value that is a negative number.  If it is important that the
positive property of the square root and higher even roots always be
preserved, the switch {\tt PRECISE}\ttindex{PRECISE} should be set on
(the default value).
This causes any non-numerical factors taken out of surds to be represented
by their absolute value form.
With % both {\tt REDUCED} and
{\tt PRECISE} on then, the above example would become
\begin{verbatim}
	2*abs(a)*sqrt(-2*b).
\end{verbatim}

The statement that {\REDUCE} knows very little about these functions
applies only in the mathematically exact {\tt off rounded} mode.  If
{\tt ROUNDED}\ttindex{ROUNDED} is on, any of the functions
\begin{verbatim}
	ACOS ACOSH ACOT ACOTH ACSC ACSCH ASEC ASECH ASIN ASINH
	ATAN ATANH ATAN2 COS COSH COT COTH CSC CSCH EXP HYPOT
	LN LOG LOGB LOG10 SEC SECH SIN SINH SQRT TAN TANH
\end{verbatim}
\ttindex{ACOS}\ttindex{ACOSH}\ttindex{ACOT}\ttindex{ACOTH}
\ttindex{ACSC}\ttindex{ACSCH}\ttindex{ASEC}\ttindex{ASECH}
\ttindex{ASIN}\ttindex{ASINH}\ttindex{ATAN}\ttindex{ATANH}
\ttindex{ATAN2}\ttindex{COS}\ttindex{COSH}\ttindex{COT}
\ttindex{COTH}\ttindex{CSC}\ttindex{CSCH}\ttindex{EXP}\ttindex{HYPOT}
\ttindex{LN}\ttindex{LOG}\ttindex{LOGB}\ttindex{LOG10}\ttindex{SEC}
\ttindex{SECH}\ttindex{SIN}\ttindex{SINH}\ttindex{SQRT}\ttindex{TAN}
\ttindex{TANH}
when given a numerical argument has its value calculated to the current
degree of floating point precision.  In addition, real (non-integer
valued) powers of numbers will also be evaluated.

If the {\tt COMPLEX} switch is turned on in addition to {\tt ROUNDED},
these functions will also calculate a real or complex result, again to
the current degree of floating point precision,
if given complex arguments.  For example, with {\tt on rounded,complex;}
\begin{verbatim}
	2.3^(5.6i)   ->   -0.0480793490914 - 0.998843519372*I
	cos(2+3i)    ->   -4.18962569097 - 9.10922789376*I
\end{verbatim}

\section{DF Operator}
The operator {\tt DF}\ttindex{DF} is used to represent partial
differentiation\index{Differentiation} with respect
to one or more variables. It is used with the syntax:
\begin{verbatim}
     DF(EXPRN:algebraic[,VAR:kernel<,NUM:integer>]):algebraic.
\end{verbatim}
The first argument is the expression to be differentiated. The remaining
arguments specify the differentiation variables and the number of times
they are applied.

The number {\tt NUM} may be omitted if it is 1.  For example,
\begin{quote}
\begin{tabbing}
{\tt            df(y,x1,2,x2,x3,2)} \= = $\partial^{5}y/\partial x_{1}^{2} \
 \partial x_{2}\partial x_{3}^{2}.$\kill
{\tt            df(y,x)} \> = $\partial y/\partial x$ \\
{\tt            df(y,x,2)} \> = $\partial^{2}y/\partial x^{2}$ \\
{\tt            df(y,x1,2,x2,x3,2)} \> = $\partial^{5}y/\partial x_{1}^{2} \
 \partial x_{2}\partial x_{3}^{2}.$
\end{tabbing}
\end{quote}
The evaluation of {\tt df(y,x)} proceeds as follows: first, the values of
{\tt Y} and {\tt X} are found.  Let us assume that {\tt X} has no assigned
value, so its value is {\tt X}.  Each term or other part of the value of
{\tt Y} that contains the variable {\tt X} is differentiated by the
standard rules.  If {\tt Z} is another variable, not {\tt X} itself, then
its derivative with respect to {\tt X} is taken to be 0, unless {\tt Z}
has previously been declared to {\tt DEPEND} on {\tt X}, in which
case the derivative is reported as the symbol {\tt df(z,x)}.

\subsection{Adding Differentiation Rules}

The {\tt LET}\ttindex{LET} statement can be used to introduce
rules for differentiation of user-defined operators.  Its general form is
\begin{verbatim}
	FOR ALL <var1>,...,<varn>
	     LET DF(<operator><varlist>,<vari>)=<expression>
\end{verbatim}
where {\tt <varlist>} ::= ({\tt <var1>},\dots,{\tt <varn>}), and
{\tt <var1>},...,{\tt <varn>} are the dummy variable arguments of
{\tt <operator>}.

An analogous form applies to infix operators.

{\it Examples:}
\begin{verbatim}
	for all x let df(tan x,x)= 1 + tan(x)^2;
\end{verbatim}
(This is how the tan differentiation rule appears in the {\REDUCE}
source.)
\begin{verbatim}
	for all x,y let df(f(x,y),x)=2*f(x,y),
			df(f(x,y),y)=x*f(x,y);
\end{verbatim}
Notice that all dummy arguments of the relevant operator must be declared
arbitrary by the {\tt FOR ALL} command, and that rules may be supplied for
operators with any number of arguments.  If no differentiation rule
appears for an argument in an operator, the differentiation routines will
return as result an expression in terms of {\tt DF}\ttindex{DF}.  For
example, if the rule for the differentiation with respect to the second
argument of {\tt F} is not supplied, the evaluation of {\tt df(f(x,z),z)}
would leave this expression unchanged. (No {\tt DEPEND} declaration
is needed here, since {\tt f(x,z)} obviously ``depends on'' {\tt Z}.)

Once such a rule has been defined for a given operator, any future
differentiation\index{Differentiation} rules for that operator must be
defined with the same number of arguments for that operator, otherwise we
get the error message
\begin{verbatim}
	Incompatible DF rule argument length for <operator>
\end{verbatim}

\section{INT Operator}
{\tt INT}\ttindex{INT} is an operator in {\REDUCE} for indefinite
integration\index{Integration}\index{Indefinite integration} using a
combination of the Risch-Norman algorithm and pattern matching.  It is
used with the syntax:
\begin{verbatim}
   INT(EXPRN:algebraic,VAR:kernel):algebraic.
\end{verbatim}
This will return correctly the indefinite integral for expressions comprising
polynomials, log functions, exponential functions and tan and atan. The
arbitrary constant is not represented. If the integral cannot be done in
closed terms, it returns a formal integral for the answer in one of two ways:
\begin{enumerate}
\item It returns the input, {\tt INT(\ldots,\ldots)} unchanged.

\item It returns an expression involving {\tt INT}s of some
      other functions (sometimes more complicated than
      the original one, unfortunately).
\end{enumerate}
Rational functions can be integrated when the denominator is factorizable
by the program. In addition it will attempt to integrate expressions
involving error functions, dilogarithms and other trigonometric
expressions. In these cases it might not always succeed in finding the
solution, even if one exists.

{\it Examples:}
\begin{verbatim}
	int(log(x),x) ->  X*(LOG(X) - 1),
	int(e^x,x)    ->  E**X.
\end{verbatim}
The program checks that the second argument is a variable and gives an
error if it is not.

{\it Note:} If the {\tt int} operator is called with 4 arguments,
{\REDUCE} will implicitly call the definite integration package (DEFINT)
and this package will interpret the third and fourth arguments as the lower
and upper limit of integration, respectively.  For details, consult
the documentation on the DEFINT package.

\subsection{Options}

The switch {\tt TRINT} when on will trace the operation of the algorithm. It
produces a great deal of output in a somewhat illegible form, and is not
of much interest to the general user. It is normally off.

If the switch {\tt FAILHARD} is on the algorithm will terminate with an
error if the integral cannot be done in closed terms, rather than return a
formal integration form. {\tt FAILHARD} is normally off.

The switch {\tt NOLNR} suppresses the use of the linear properties of
integration in cases when the integral cannot be found in closed terms.
It is normally off.

\subsection{Advanced Use}

If a function appears in the integrand that is not one of the functions
{\tt EXP, ERF, TAN, ATAN, LOG, DILOG}\ttindex{EXP}\ttindex{ERF}
\ttindex{TAN}\ttindex{ATAN}\ttindex{LOG}\ttindex{DILOG}
then the algorithm will make an
attempt to integrate the argument if it can, differentiate it and reach a
known function.  However the answer cannot be guaranteed in this case.  If
a function is known to be algebraically independent of this set it can be
flagged transcendental by
\begin{verbatim}
	flag('(trilog),'transcendental);
\end{verbatim}
in which case this function will be added to the permitted field
descriptors for a genuine decision procedure. If this is done the user is
responsible for the mathematical correctness of his actions.

The standard version does not deal with algebraic extensions. Thus
integration of expressions involving square roots and other like things
can lead to trouble.  A contributed package that supports integration of
functions involving square roots is available, however
(ALGINT\extendedmanual{, chapter~\ref{ALGINT}}).
In addition there is a definite integration
package, DEFINT\extendedmanual{( chapter~\ref{DEFINT})}.

\subsection{References}

	A. C. Norman \& P. M. A. Moore, ``Implementing the New Risch
		Algorithm'', Proc. 4th International Symposium on Advanced
		Comp. Methods in Theor. Phys., CNRS, Marseilles, 1977.

	S. J. Harrington, ``A New Symbolic Integration System in Reduce'',
		Comp. Journ. 22 (1979) 2.

	A. C. Norman \& J. H. Davenport, ``Symbolic Integration --- The Dust
		Settles?'', Proc. EUROSAM 79, Lecture Notes in Computer
		Science 72, Springer-Verlag, Berlin Heidelberg New York
		(1979) 398-407.

%\subsection{Definite Integration} \index{Definite integration}
%
%If {\tt INT} is used with the syntax
%
%\begin{verbatim}
%   INT(EXPRN:algebraic,VAR:kernel,LOWER:algebraic,UPPER:algebraic):algebraic.
%\end{verbatim}
%
%The definite integral of {\tt EXPRN} with respect to {\tt VAR} is
%calculated between the limits {\tt LOWER} and {\tt UPPER}.  In the present
%system, this is calculated either by pattern matching, or by first finding
%the indefinite integral, and then substituting the limits into this.

\section{LENGTH Operator}
{\tt LENGTH}\ttindex{LENGTH} is a generic operator for finding the
length of various objects in the system.  The meaning depends on the type
of the object.  In particular, the length of an algebraic expression is
the number of additive top-level terms its expanded representation.

{\it Examples:}
\begin{verbatim}
	length(a+b)    ->  2
	length(2)      ->  1.
\end{verbatim}
Other objects that support a length operator include arrays, lists and
matrices. The explicit meaning in these cases is included in the description
of these objects.

\section{MAP Operator}\ttindex{MAP}

The {\tt MAP} operator applies a uniform evaluation pattern to all members
of a composite structure: a matrix, a list, or the arguments of an
operator expression.  The evaluation pattern can be a unary procedure, an
operator, or an algebraic expression with one free variable.

It is used with the syntax:
\begin{verbatim}
   MAP(U:function,V:object)
\end{verbatim}
Here {\tt object} is a list, a matrix or an operator expression.
{\tt Function} can be one of the following:
\begin{enumerate}
\item the name of an operator for a single argument: the operator
is evaluated once with each element of {\tt object} as its single argument;
\item an algebraic expression with exactly one free variable, that is
a variable preceded by the tilde symbol. The expression
is evaluated for each element of {\tt object}, where the element is
substituted for the free variable;
\item a replacement rule of the form {\tt var => rep}
where {\tt var} is a variable (a kernel without a subscript)
and {\tt rep} is an expression that contains {\tt var}.
{\tt Rep} is evaluated for each element of {\tt object} where
the element is substituted for  {\tt var}. {\tt Var} may be
optionally preceded by a tilde.
\end{enumerate}
The rule form  for {\tt function} is needed when more than
one free variable occurs.

Examples:
\begin{verbatim}
	map(abs,{1,-2,a,-a})  ->  {1,2,ABS(A),ABS(A)}
	map(int(~w,x), mat((x^2,x^5),(x^4,x^5))) ->

		[  3     6 ]
		[ x     x  ]
		[----  ----]
		[ 3     6  ]
		[          ]
		[  5     6 ]
		[ x     x  ]
		[----  ----]
		[ 5     6  ]

	map(~w*6, x^2/3 = y^3/2 -1) -> 2*X^2=3*(Y^3-2)
\end{verbatim}

You can use {\tt MAP} in nested expressions. However, you cannot
apply {\tt MAP} to a non-composed object, e.g. an identifier or a number.

\section{MKID Operator}\ttindex{MKID}
In many applications, it is useful to create a set of identifiers for
naming objects in a consistent manner. In most cases, it is sufficient to
create such names from two components. The operator {\tt MKID} is provided
for this purpose. Its syntax is:
\begin{verbatim}
MKID(U:id,V:id|non-negative integer):id
\end{verbatim}
for example
\begin{verbatim}
	mkid(a,3)      -> A3
	mkid(apple,s)  -> APPLES
\end{verbatim}
while {\tt mkid(a+b,2)} gives an error.

The {\tt SET}\ttindex{SET} operator can be used to give a value to the
identifiers created by {\tt MKID}, for example
\begin{verbatim}
	set(mkid(a,3),3);
\end{verbatim}
will give {\tt A3} the value 2.

\section{PF Operator}\ttindex{PF}

{\tt PF(<exp>,<var>)} transforms the expression {\tt <exp>} into a list of
partial fractions with respect to the main variable, {\tt <var>}.  {\tt PF}
does a complete partial fraction decomposition, and as the algorithms used
are fairly unsophisticated (factorization and the extended Euclidean
algorithm), the code may be unacceptably slow in complicated cases.

{\it Example:}
Given {\tt 2/((x+1)\verb|^|2*(x+2))} in the workspace,
{\tt pf(ws,x);} gives the result
\begin{verbatim}
	    2      - 2         2
	{-------,-------,--------------} .
	  X + 2   X + 1    2
			  X  + 2*X + 1
\end{verbatim}

If you want the denominators in factored form, use {\tt off exp;}.
Thus, with {\tt 2/((x+1)\verb|^|2*(x+2))} in the workspace, the commands
{\tt off exp; pf(ws,x);} give the result
\begin{verbatim}
	    2      - 2       2
	{-------,-------,----------} .
	  X + 2   X + 1          2
			  (X + 1)
\end{verbatim}

To recombine the terms, {\tt FOR EACH \ldots SUM} can be used.  So with
the above list in the workspace, {\tt for each j in ws sum j;} returns the
result
\begin{verbatim}
	     2
     ------------------
		     2
      (X + 2)*(X + 1)
\end{verbatim}

Alternatively, one can use the operations on lists to extract any desired
term.

\section{SELECT Operator}\ttindex{SELECT}
\ttindex{map}\ttindex{list}

The {\tt SELECT} operator extracts from a list,
or from the arguments of an n--ary operator, elements corresponding
to a boolean predicate. It is used with the syntax:
\begin{verbatim}
  SELECT(U:function,V:list)
\end{verbatim}

{\tt Function} can be one of the following forms:
\begin{enumerate}
\item the name of an operator for a single argument: the operator
is evaluated once with each element of {\tt object} as its single argument;
\item an algebraic expression with exactly one free variable, that is
a variable preceded by the tilde symbol. The expression
is evaluated for each element of \meta{object}, where the element is
substituted for the free variable;
\item a replacement rule of the form \meta{var $=>$ rep}
where {\tt var} is a variable (a kernel without subscript)
and {\tt rep} is an expression that contains {\tt var}.
{\tt Rep} is evaluated for each element of {\tt object} where
the element is substituted for  {\tt var}. {\tt var} may be
optionally preceded by a tilde.
\end{enumerate}
The rule form  for {\tt function} is needed when more than
one free variable occurs.

The result of evaluating {\tt function} is
interpreted as a boolean value corresponding to the conventions of
{\REDUCE}. These values are composed with the leading operator of the
input expression.

{\it Examples:}
\begin{verbatim}
	select( ~w>0 , {1,-1,2,-3,3}) -> {1,2,3}
	select(evenp deg(~w,y),part((x+y)^5,0):=list)
	       -> {X^5 ,10*X^3*Y^2 ,5*X*Y^4}
	select(evenp deg(~w,x),2x^2+3x^3+4x^4) -> 4X^4 + 2X^2
\end{verbatim}


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

\begin{document}

% --------------------------------------------------------------------------------------------
\section*{Exercise 1.9 No index clashes}

\begin{cadabra}
   {a,b,c,d,e,f,u,v,w}::Indices.

   foo := A_{a c} C^{c}.                                  # cdb (ex-0109.101,foo)
   bah := B_{b c} C^{c}.                                  # cdb (ex-0109.102,bah)

   foobah := @(foo) @(bah).                               # cdb (ex-0109.103,foobah)
\end{cadabra}

\begin{align*}
   &\Cdb{ex-0109.101}\\
   &\Cdb{ex-0109.102}\\
   &\Cdb{ex-0109.103}
\end{align*}

\end{document}


\section{1D Bosonic Symmetry-Protected Topological states}
Last time,
we started talking about SPT states,
bosons in 1D.
We talked about AKLT states,
which is the ground state for spin-1 chains.
We saw the Hamiltonian was
\begin{align}
    H &= \sum_i \vec{S}\cdot\vec{S}_j
    + \frac{1}{3} \left( S_i \cdot S_j \right)^2 + \frac{2}{3}
\end{align}
and we saw this is the sum of projects where neighbouring spins are projected
onto the spin-2 chain.
\begin{align}
    H &= \sum_i P_{i,i+1}^{(2)}
\end{align}
and then we have spin-$\frac{1}{2}$s projected onto spin-1s on each site.
Before you do that though,
you put the left and right on different sites into a spin-singlet state,
and we so we said that this ground state,
AKLT proved that this is the unique gapped ground state
of this $H_{ALKT}$.

In particular, this ground state is actually annihilated by every single term
here,
and this Hamiltonian is called a frustration-free Hamiltonian.

It's useful to note that the motivation for AKLT to study this was actually how
Haldane conjectured that the spin-1 Heisenberg chain is gapped.

The motivation for AKLT was the Haldane conjecture.
The spin-one-half Heisenberg chain was known to be gapless,
but Dr Haldane predicted the spin-1 Heisenberg chain is gapped.
That was surprising,
because people assumed the spin half would have the same behaviour,
but Haldane's conjecture said that spin-1 and spin-half behave very
differently,
which is intrinsically quantum mechanical.

\begin{question}
    Does it have Goldstone bosons?
\end{question}
No, it doesn't order, no long range order in 1D.

It's non-trivial the spin-half chain is gapless,
but the  spin-1 half is gapped.

SO this AKLT,
you can think of this thing as smoothly connected,
or close,
to the Heisenberg point,
because you can slowly ramp up this parameter from 0 to 1/3.
AKLT noticed this Hamiltonian was similar to the Heisenberg model,
but you could prove it was gapped and has this interesting ground state.

So the spin-1 Heisenberg chain is in the same phase as this,
turning from 0 to 1/3,
and show the gap is still open,
so this is a model to see what the spin-1 Heisenberg chain looks like.

The key point about this state,
is that you see you have these edge modes,
which is a key non-trivial aspect of this state as opposed to trivial.

\begin{question}
    How do you see there's no phase transition from 0 to 1/3.
\end{question}
I think numerically you can see it?
This is 1D,
so there are all sorts of analytically solvable tricks,
maybe yes
but I don't know.
There is a phase transition,
but it's beyond 1/3.
I forgot exactly what.

They key point is that you have these dangling spin-1/2 things on the edge,
which are edge modes.
The global symmetry is SO(3),
but actually the chain has more symmetries,
it is time-reversal-invariant,
transitionally invariant,
reflection symmetry,
but we're interested in the OS(3) global symmetry.

The property of SO(3) is that it acts anomalously on the boundary.
Here, anomalous means microscopically each lattice site is pin-1,
so it forms a linear representation of SO(3),
but spin-1/2 is a projective representation of SO(3).
I will remind you mathematically what projective means.

Spin-$\frac{1}{2}$ is a projective representation of SO(3),
but microscopically we have spin-1 per site,
which is a linear representation of SO(3).

So let me tell you what projective representations are,
in case you don't know exactly what this means.
The short summary is that if you do a combination of rotations in SO(3),
that for example add up to identity,
whereas Spin-1/2 would give you a minus sign,
but linear representations would not give you a minus sign.

Suppose you have a group $G$ with a finite-dimensional representation.
\begin{align}
    R: G \to GL(d; \mathbb{C})
\end{align}
What that means is that for every group element,
you have the group of $d\times d$ complex matrix.

A \emph{faithful} or \emph{linear} representation has the property that when you
compose group elements,
you get the representation for the product.
\begin{align}
    R_g R_h = R_{gh}
\end{align}
However, this is not always the case,
because in general you could have
\begin{align}
    R_g R_h = \omega(g, h) R_{gh}
\end{align}
where $\omega(g,h)$ is a phase in U(1).
So in other words,
\begin{align}
    \omega \in C^2(G, U(1))
\end{align}
so $\omega$ is a function of two group elements and it gives you a U(1) phase.
If you have this rule,
you could consider associativity for 3 group elements,
which tells you you can first multiply them in any way.
\begin{align}
    R_g R_h R_k &=
    \omega(h, k) \omega(g, hk) R_{ghk}\\
    &= \omega(g, h)\omega(gh, k) R_{ghk}
\end{align}
And this takes us to an important equation.
It tells us the phases must satisfy an important equality
\begin{align}
    \omega(h, k) \omega(g, hk)
    =
    \omega(g, h) \omega(gh, k)
\end{align}
and this is called the \emph{2-cocycle condition}.

We can define this differential map $d$ that maps $n$-cochains to
$n+1$-cochains.
\begin{align}
    d: C^n(G, U(1)) \to C^{n+1}(G, U(1))
\end{align}
and we can define this differential as
\begin{align}
    d\omega_2 (g, h, k)
    =
    \frac{\omega(h, k) \omega(h, hk)}{\omega(g, h) \omega(gh, k)}
\end{align}
and so the 2-cocyle equation is really just the equation that
\begin{align}
    d\omega_2 = 1
\end{align}
and if it satisfies this equation,
we call it a 2-cocycle
so actually
$\omega_2 \in Z^2(G, U(1))$,
which is the space of 2-cocycles.
In other words,
\begin{align}
    Z^2(G, U(1)) &=
    \left\{
    X_2 \in C^2(G, U(1)) \,|\,
    dX_2 = 1
    \right\}
\end{align}
However,
there is some redundancy here,
because you could change any of these by a phase and potentially get rid of
these $\omega$s.
That is,
if $R_g R_h = \omega(g, h) R_{g,h}$,
you could just redefine
\begin{align}
    R_g \to R_g \epsilon(g) = R_g'
\end{align}
so then
\begin{align}
    R_g' R_h' &= \omega_2'(g, h) R_{gh}'\\
    R_g R_h &=
    \underbrace{\frac{\omega_2'(g, h) \epsilon(gh)}{\epsilon(g)
    \epsilon(h)}}_{\omega_2(g, h)} R_{gh}
\end{align}
and thus
\begin{align}
    \omega_2'(g,h) &=
    \omega_2(g, h) \frac{\epsilon(g) \epsilon(h)}{\epsilon(gh)}
\end{align}
So you need to consider 2-cocycles modulo this equivalence relation,
which you can think of as equivalent projective representations.
This $\epsilon(g)\in C^1(G, U(1))$ is a 1-cochain associated with a single group
elements,
with
\begin{align}
    d\epsilon &=
    \frac{\epsilon(g) \epsilon(h)}{\epsilon(gh)}
\end{align}
And now you can define the space of 2-coboundaries,
\begin{align}
    B^2(G, U(1)) := \left\{
    X_2 \in C^2(G, U(1)) \, \mid\,
    X_2 = d\epsilon_1,\,
    \epsilon_1 \in C^1(G, U(1))
    \right\}
\end{align}
that are differentials of 1-cochains
\begin{align}
    \omega_2 \sim \omega_2 \cdot d\epsilon_1
\end{align}

So projective representations should be classified by 2-cocycles modulo by
2-coboundaries.

You have these representations,
you have these extra phases,
and that phase,
you might be able to get rid of it by redefining $R_g$,
but if you can't,
then you have a non-trivial projective representation,
and two projective representations are equivalent if you can just re-phase these
$R_g$'s so distinct ones are classified by this group.

Thus distinct projective representations are classified by
the second cohomology group
\begin{align}
    \frac{Z^2(G, U(1))}{B^2(G, U(1))} =:
    H^2(G, U(1))
\end{align}
And indeed,
you could also generalize this with
\begin{align}
    H^n (G, U(1)) &=
    \frac{Z^n(G, U(1))}{B^n(G, U(1))}\\
    Z^n(G, U(1)) &=
    \left\{ X_n \in C^n(G, U(1)) \mid dX_n = 1 \right\}\\
    B^n\left( G, U(1) \right)
    &=
    \left\{
    X_n \in C^n(G, U(1)) \mid
    X_n = d\epsilon_{n-1},
    \epsilon_{n-1} \in C^{n-1}(G, U(1))
    \right\}
\end{align}
The only thing I haven't defined is how the differential map is defined,
but we only need $n=2$ for now for 1D spin-1 chains.
We will come back to higher-dimensional SPTs later.

\begin{question}
    Is $H^2$ always a group because the coefficient is $U(1)$?
\end{question}
Well $Z^2$ is always a group.
You can actually replace $U(1)$ with a module over $G$ and still define all
these things.
For $U(1)$,
we don't really need all that,
we just need $U(1)$ coefficients.

Let's just stick to the mathematics we need to do the physics.

\begin{question}
    The state is symmetric under $G$ means linear representation?
    Is there any reason why linear representation are special in that way?
\end{question}
No, not necessarily.
Linear representations are special for a wide variety of reasons,
but you could definitely have a state symmetric under $G$ but forms a projective
representation.
There are theorems which govern what the low-energy behaviour has to be.
It's important to know for the system,
but they are both equally valid as a system and its symmetry.

\begin{question}
    Is there a simple quantum example of a projective representation?
\end{question}
Yes, spin-1/2.

\begin{question}
    We can either say it forms a linear representation of spin-1
    or a spin\ldots
\end{question}
Let me rephrase your question.
A spin-1/2 chain can be thought of as a projective representation of SO(3),
or it can be thought of a linear representation of SO(3).
It's also the linear representation of the cover of some group.
Suppose I have a spin-1/2 chain,
should I think of the symmetry of the system being SU(2) or SO(3).
This is actually a pretty delicate question.

It depends on how many spin-1/2s you have.
If you have an even number of spin-1/2s, it should be SO(3),
but if you had an odd number of spin-1/2s, it should be SU(2) technically.
It depends on odd or even.

\begin{question}
    Regardless of even or odd,
    excitations are always even spin,
    is there something to interpret?
\end{question}
The local operators for a spin-1/2 are the Pauli matrices $\sigma^i$,
and they themselves form a spin-1 representation of SO(3).
The way that $\sigma^i$ transforms under an SO(3) representation,
is the same as a spin-1.
So the Pauli operators transform as Spin-1 under SO(3).
Local operators always carry integer spin,
because these $\sigma^i$ transform as a spin-1 representation.

\begin{question}
    This is true even if we have a spin-2 chain?
\end{question}
If you had a spin-2 chain,
then the local operators would not be Pauli matrices,
it would be whatever for spin-2.
Spin-2 is not the best example.
Spin-3/2 is better,
where they are $4\times 4$ matrices,
but under SO(4) rotations would transform as a local spin.
The formal statement is that local excitations carry integer spin.

Let me say that
\begin{align}
    H^2(SO(3), U(1)) = \mathbb{Z}_2
\end{align}
So it's linear in the spin-1 represetantio nand porjective in the SU(2)
represtnation.

There's a relation between $H^2$ and $\pi^1$.
I think there may be smoe theorem for Lie groups,
$H^2$ is related to $\pi^1$.
$H^1$ is related to $\pi^1$.
$H^1$ is athe abelianization of $\pi^1$.
This is group cohomology.

OK, so going back to AKLT,
the edge modes form this projective representation and we can actually see
what's going on there.
In general for SPT states in 1-dimensions,
suppsoe you have a ground state and you apply your symmetry operation,
on the represetantion on the full-many-body state,
and because in the bulk it's symmetric and you hav a finite-correlation length,
ify ou apply $R_g$ on a ring,
youget back the original state,
\begin{align}
    R_g \ket{\psi} = \ket{\psi}
\end{align}
but on an open chain,
you get the ground satte back,
but up to some boundary opeartions near the left boundary $U_g^{(L)}$
and some operations acting on the right boundary,
up to corrections exponentially small in the isze of teh system.
\begin{align}
    R_g \ket{\psi} \approx
    U_g^{(1)} U_{g}^{(R)} \ket{\psi}
\end{align}
and so
\begin{align}
    R_g R_h \ket{\psi} &\approx
    U_g^{(L)} U_h^{(L)}
    U_g^{(R)} U_h^{(R)}
    \ket{\psi}\\
    R_{gh}\ket{\psi} &= U_{gh}^{(L)} U_{gh}^{(R)} \ket{\psi}
\end{align}
Now this is a genearl statemetn that doesn't even need ALKLT.
In 1D, you hvae as ymemtric gapped state,
and you apply your symemtry transfmatoin on an open chain,
then yo hvae these local operators acting on the boundary,
and you compre aply $R_{gh}$ and $R_g R_h$,
and the only way they can be eqaul is that the $U$s are equal up to a phase.
Because some are localized onthe left and some are localized on the right
boundary,
and the only wa this could possibly hold is that
\begin{align}
    U_g^{(L)} U_{h}^{(R)} \ket{\psi} &=
    \omega_2(g, h) U_{gh}^{(L)} \ket{\psi}\\
    U_g^{(R)} U_{h}^{(R)} \ket{\psi} &=
    \omega_2^{-1}(g, h) U_{gh}^{(R)} \ket{\psi}
\end{align}
In general,
you have one projective erepsertaniotn on the left,
and the inverse one on the right.
It's just he thing about SO(3) that you find the projective rpesetnation is its
own inverse and so you have spin-$\frac{1}{2}$ in each direciton.

And so this tells us the equivalence class
\begin{align}
    [\omega_2] \in H^2(G, U(1))
\end{align}
classifies the symmetry action on the edge.

Let's do another example.
AKLT was not the simplest thing.
Even thoguh it's fustration free,
it's nontrivial to prove the ground state is simple and gapped.

There's an even simpler example.
This is called the 1D cluster state model,
sometimes called the $ZXZ$ model,
or sometimes $XZX$ model.
Here, $X$ and $Z$ are the Pauli operators.
\begin{align}
    H &=
    -\sum_{j=2}^{N-1} Z_{j-1} X_j Z_{j+1}
\end{align}
Note that every term commutes with each other.
If I have $ZXZ$ on 3 sites,
and I have another $XZX$ on 3 sites shifted by 1,
they commute with one another.
So every term in the Hamiltnoian commutes and furthermore squares to the
identity,
so the gournd state is jsut the simultaneous $+1$ eigenstate of the $XZX$.

And furthermore,
the global symmetry we're intersted here is the
$G=\mathbb{Z}_2\times \mathbb{Z}_2$,
which are generated by
\begin{align}
    \bar{X}_1 &=
    \prod_{k\mathrm{ odd}} X_k\\
    \bar{X}_2 &=
    \prod_{k\mathrm{ even}} X_k\\
\end{align}

\begin{question}
    Is this encoding $k$ logical qubits into $n$ physical qubits?
    Is it something like stabilizer groups?
\end{question}
These are just symmetries,
I wouldn't call it logical oeprators.
These are jsut symmetry operators.
They square to the identity and they commute with the whole Hamiltonian.

On each boundary,
say on the left boundary,
we actually have a set of operators that commute with the Hamiltonian exactly.
Let's call them
\begin{align}
    \bar{X}_L &= X_1 Z_2\\
    \bar{Z}_L &= Z_1
\end{align}
and these commute with the Hamiltonian.
You see $Z_1$ commutes iwth teh Hamitna,
because the only operator that hits site 1 is the first ermm,
which has a $Z$ there, so that commutes.
You can also see that with the $X_1 Z_2$.

But these have a non-trivial algebra among themselves.
They anti-commute with one another.
\begin{align}
    \bar{X}_L \bar{Z}_L = - \bar{Z}_L \bar{X}_L
\end{align}
Because they comute with te Hamiltonai,
the ground state must frm a rperestaion of this algebra,
and because they anticommute,
there must be a two-fold degeneracy on each edge.
There's a simlar one on the right one as well.
This is not an accidental degenearcy.
No local perturbation can lift this degeneracy as long as the
$\mathbb{Z}_2\times \mathbb{Z}_2$ symmetry is preserved.
Oneway to lift hte dgenracy is to add these 2 tersm to the Hamiltonian,
but these don't commute with one another,
so you cannot add these both and preservet the symmetry.

You can directly see this behaviour exactly in this model.
Suppose that you want to apply the first symmetry operator to the ground state.
Let me consider a half-infinite chain,
so we only have the left boundary,
but then it goes off to inifitey on the other end so we don't have to worry
about it.
\begin{align}
    \bar{X}_1\ket{\psi_{gs}} &=
    \bar{X}_1 \prod_{k=2}^{\infty} Z_{2k - 2} X_{2k -  1} Z_{2k}
    \ket{\psi_{gs}}
\end{align}
and then I pull some things out,
and the nice thing about pulling them out is that if I get a lot of cancelation
\begin{align}
    \bar{X}_1 Z_2 X_3 Z_4 Z_4 X_5 Z_6\cdots &=
    (X_1 X_3 X_5\cdots) Z_2 (X_3 X_5 \cdots)\\
    &= X_1 Z_2
\end{align}
so actually you have
\begin{align}
    \bar{X}_1\ket{\psi_{gs}} &=
    \bar{X}_1 \prod_{k=2}^{\infty} Z_{2k - 2} X_{2k -  1} Z_{2k}
    \ket{\psi_{gs}}\\
    &=
    X_1 Z_2 \ket{\psi_{gs}}\\
    &=
    \bar{X}_L \ket{\psi_{gs}}
\end{align}

\begin{question}
    Something about $C^*$ algebra.
\end{question}
I'll leave it as an exercise.
If you really do a more honest calfcaultion end at $N$ rather than infinity,
you should get $\bar{X}_L$ and $\bar{X}_R$.
If you simillarly did
$\bar{X}_2\ket{\psi_{gs}}$,
and instead of pulling the even rather than the odd one,
you find.
\begin{align}
    \bar{X}_2\ket{\psi_{gs}} &=
    Z_1 \ket{\psi_{gs}}
\end{align}
and this is really similar to how
$\bar{X}_1$ and $\bar{X}_2$ act as
$\bar{X}_L$ and $\bar{Z}_2$
on the left edge

And $\bar{X}_L$, $\bar{Z}_L$ form a projective represetnation of
the global symmetry
$\mathbb{Z}_2\times \mathbb{Z}_2$.

\begin{question}
    Is it clear this is a gapped state?
\end{question}
yes, every term commutes,
and each terms is +1 or -1,
and it costs an energy of 2 to raise it frmo the ground state to the next
excited state.

If you had a gapless situation on the ege,
you wouldn't have a sitaution where exactly the boundayr gets affected but the
bulk doesn't get affected at all.

You could have a sysetm fully symmetric on a chain,
but if you did have edge modes,
you owud have poewr law correaltions,
and if wasn't exaclty symmetric,
you wouldh ave some power law decay.
Also, if it wasn't gapped,
it wouldn't give an SPT phase which is by definition gapped.

This $R_g\ket{\psi} \approx U_g&L U_g^R \ket{\psi}$
really relies on the fact that it is gapped.
Are there any other questions?

\begin{question}
    How do you see there's no edge modes connected with other symmetries and
    translations?
\end{question}
In this particular model,
you can probably just count the number of degrees of freedom and see that we've
accounted for everything.

We have $Z_1 X_2 Z_3, \cdots Z_{N-2}X_{N-1}Z_N$.
The entire Hilbert space is accounted for already by counting.

\begin{question}
    Are we just partitioning the system?
\end{question}
They coexist.
Ify ou had a symmetry that is $G\times H$,
on each edge you would have a projective represenation of $G\times H$.
Spatial symmetries like translation and reflection are special.
here, the point is that even if we have a boundary,
the systeme iwth the boudnary stil rferelcets th symmetery.
Hwoever, wiht transltaiton symemtry,
the sysetme in the prescenece of the boudndary doesn't relaly resepct that,
so it desno't really makes sense to talk about hte action of tranlation symetron
when there is a boundary.

Often wiht spatial symmetries,
you couldh ave nootrivial SPTs associtated iwth te systemery,
but there may not be edge modes.
It's a more delicate task to figure out what ist he desintct property of the
SPTs given  it's hard to probe them becasue the boundary breaks the symmetry.

\section{Full classification of bosonic 1+1D topological phases}
What we saw so far is that we have this classification of how the symmetry acts
on the edge modes.
In fact,
this is the full classification of 1D SPTs.

The full classification of $(1+1)$-D topological phases is by
$H^2(G, U(1))$.
There are 2 pieces of evidence more easy to come by.

\begin{enumerate}
    \item We can use matrix product states.
    \item Try to develop a classification of TQFTs and see that deformation
        classes.
\end{enumerate}

\section{Matrix product states}
Suppose you have a chain with $N$ spins with periodic boundary conditions.
Then a \emph{matrix product} state is of the following form
\begin{align}
    \ket{\psi} &=
    \sum_{i_1,\ldots,i_N}
    \Tr\left(
    A_{i_1}^{[1]}
    A_{i_2}^{[2]}
    \cdots
    A_{i_N}^{[N]}
    \right)
    \ket{i_1,\ldots,i_N}
\end{align}
where $i_k=1,\ldots,d$ where $d$ is the local qudit dimension,
each $A_{i_k}^{[k]}$ are $D\times D$ matrices
where $D$ is the bond dimension.

The beauty of this state is that there are very few parameters.
There are only $dND^2$ parameters,
as opposed to the $d^N$ parameters for the most general $N$-qudit state.
This is an efficient parameterization of a very large class of systems.

The point of these matrix product states is that the entanglement entropy of a
matrix product state is upper-bounded by its bond dimension.
So if you had a chain,
let's say you have an open chain,
and you split it up into a left and a right piece,
then the entanglement entropy would satisfy
\begin{align}
    S = -\Tr \rho_L \ln \rho_L \le 2 \ln D
\end{align}
It is bounded by the bond dimension $D$.
In 1D,
any generic gapped ground state forms an area law.
What that means is that any gapped 1D ground state has ``area law''
entanglement,
which means that if I look at the entanglement entropy of some segment,
then $S_{1d}=\mathrm{constant}$,
meaning that it is independent of system size.

Actually, the more precise statement is that the entanglement entropy $S$ is of
order
\begin{align}
    S = O\left(
    \frac{\log^3 d}{E_{gap}}
    \right)
\end{align}
This was originally proven by Hastings in 2007,
but then it was exponentially improved 6 years later by
Arad, Kitaev, Landau, Vazirani in 2013,
and the statement above is from the latter paper.
This latter paper also improved another result of Hastings,
which is that you can approximate any gapped ground state to an accuracy that is
$1/\poly(N)$ where $N$ is system size with an MPS of sublinear bond dimension,
sublinear means the bond dimension grows slower than the size of the system.
We don't care what the polynomial is.
The more specific thing they proved is that
\begin{align}
    D &=
    O\left(
    e^{\log^{3/4} N / E_{gap}^{1/4}}
    \right)
\end{align}
The main point is that gapped ground states have area law entanglement in 1D,
and MPS is a way of parametrizing states with area law entanglement.
So if you have a gapped ground state,
you can have a fairly good approximation with MPS.

You need fewer than $dND^2$ parameters to very accurately approximate the ground
state.

\begin{question}
    is the converse true?
    Any state that satisfies area law entanglement is gapped?
\end{question}
I don't have a counter example.
Every system I know has an entropy that grows logarithmically at worst.
The converse of these statements usually have some sick counterexample.
For example,
finitely correlated Hamiltonians don't imply gapped.
I don't recall hearing any for this one though.

What we can actually do is use matrix product states to prove the
classification.
In particular, there is no topological order for 1D bosonic states.


\documentclass{article}
\usepackage{amsmath}
\usepackage{semantic}

\title{The Logic of SAW}

%\newcommand{\inference}[2]{\frac{#1}{#2}}
\newcommand{\rectyp}[1]{\#\{#1\}}
\newcommand{\recval}[1]{\{#1\}}
\newcommand{\fn}[1]{\mathtt{#1}}
\newcommand{\set}[1]{\fn{set}_{#1}}
\newcommand{\rctor}[3]{{#1} : {#2} \downarrow {#3}}
\newcommand{\Piexpr}[3]{\Pi {#1}{:}{#2}.\ {#3}}
\newcommand{\rlbl}[1]{\mathrm{\scriptstyle{}#1}}

\begin{document}

%Lambda
%Pi
%Tuple Values & Types
%Record Values & Types
%Record selectors

\section{Syntax}

We begin by defining \emph{pseudo-terms}, syntactically constructed objects that
may or may not have a valid type according to the type inference rules which we
will define later.  In defining the terms, we assume that there are disjoint infinite
sets $X$ and $C$.  We call the elements $x \in X$ \emph{variables}, and the elements
$c \in C$ \emph{constructors}.

\begin{align*}
&\begin{array}{llrll}
\text{Terms}
& T,U    &:=\:& x & \text{var term}\\
&        & |\:& (\lambda x . T) &\text{lambda}\\
&        & |\:& T U &\text{app}\\
&        & |\:& \Piexpr{x}{T}{U} &\text{Pi expression}\\
&        & |\:& \set{i}\\
&        & |\:& (T_1, \dots, T_n)\\ % Tuples
&        & |\:& \#(T_1, \dots, T_n)\\ % Tuple types
&        & |\:& \{ f_1 = T_1; \dots; f_n = T_n \} \\ % records
&        & |\:& \#\{ f_1 : T_1; \dots; f_n : T_n \} \\ % record types
&        & |\:& c(T_1,\dots,T_n)\\ % Constructors
&        & |\:& \fn{let}\ [ D_1; \dots; D_n ]\ \fn{in}\ T\\ % let
\text{Definitions}
&D_i     &:=\:&x :: T; E_{x,1}; \dots; E_{x,n}\\
\text{Equations}
&E_{c,i} &:=\:&c\ P_1\ \dots\ P_n = T\\
\text{Patterns}
&P       &:=\:&x & \text{Variable}\\
&        & |\:&(P_1, \dots, P_n) &\text{Tuple}\\ % Tuples
&        & |\:&\{ f_1 = P_1; \dots; f_n = P_n \} & \text{Record}\\ % Records
&        & |\:&c(P_1, \dots, P_n) & \text{Constructor}\\ % Constructors
&        & |\:&.T & \text{Inaccessible term}\\
\end{array}\\
\end{align*}

A term is logically defined

\section{Typing Rules}
\begin{gather*}
\begin{array}{rc}
% Variables
\rlbl{var-1}&
\inference{}{\Gamma, x{:}A |- x : A}\\[1em]
\rlbl{var-2}&
\inference{\Gamma |- x : A \quad y \not\in (\{x\} \cup \fn{fv}(A))}
          {\Gamma,y{:}B |- x : A}\\[1em]
% Lambda
\rlbl{lambda}&
\inference{\Gamma |- A{:}\set{\alpha} \quad \Gamma,x{:}A |- b{:}B}
          {\Gamma |- (\lambda x . b) : (\Piexpr{x}{A}{B})}\\[1em]
\rlbl{app}&
\inference{\Gamma |- f : (\Piexpr{x}{A}{B}) \quad \Gamma |- t : A  }
          {\Gamma |- f t : B[x/t] }\\[1em]
\rlbl{pi}&
\inference{\Gamma |- A : \set{i} \quad \Gamma,x:A |- B : \set{i}}
          {\Gamma |- (\Piexpr{x}{A}{B}) : \set{i}}\\[1em]
%Set
\rlbl{set}&
\inference{}{\Gamma |- \set{i} : \set{i+1}}\\[1em]
\rlbl{subset}&
\inference{\Gamma |- t : \set{i}}{\Gamma |- t : \set{i+1}}\\[1em]
% Tuples
\rlbl{tuple-1}&
\inference{\Gamma |- x_1 : T_1 \quad \dots \quad \Gamma |- x_n : T_n}
          {\Gamma |- (x_1, \dots, x_n) : \#(T_1, \dots, T_n)}\\[1em]
\rlbl{tuple-2}&
\inference{\Gamma |- T_1 : \set{i} \quad \dots \quad \Gamma |- T_n : \set{i}}
          {\Gamma |- \#(T_1, \dots, T_n) : \set{i}}\\[1em]
% Records
\rlbl{record-1}&
\inference{\Gamma |- t_1 : T_1\ \dots\ \Gamma |- t_n : T_n }
          {\Gamma |- \recval{ x_1 = t_1;\ \dots\ ; x_n = t_n}
                   : \rectyp{ x_1 : T_1;\ \dots\ ; x_n : T_n}}\\[1em]
\rlbl{record-2}&
\inference{\Gamma |- T_1 : \set{i} \quad \dots \quad \Gamma |- T_n : \set{i}}
          {\Gamma |- \rectyp{ x_1 : T_1;\ \dots\ ; x_n : T_n} : \set{i}}\\[1em]
\rlbl{record-3}&
\inference{\Gamma |- r : \rectyp{ x : t; \dots }}
          {\Gamma |- r.x : t }\\[1em]
% Constructors
\rlbl{ctor-1}&
\inference{c : T \in \Sigma \quad \Gamma |- \rctor{t_1,\dots,t_n}{T}{C}}
          {\Gamma |- c(t_1,\dots,t_n) : C}\\[1em]
% Constructor inference.
\rlbl{ctor-2}&
\inference{\Gamma|- t_1 : A \quad \Gamma |- \rctor{t_2,\dots,t_n}{B[x/t_1]}{C}}
          {\Gamma |- \rctor{t_1,\dots,t_n}{\Piexpr{x}{A}{B}}{C}}\\[1em]
\rlbl{ctor-3}&
\inference{}{\Gamma |- \rctor{\epsilon}{B}{B}}\\[1em]
\end{array}
\end{gather*}

\end{document}