\documentclass[12pt]{article}
\usepackage{amsmath}
\newcommand{\bra}[1]{\langle#1|}
\newcommand{\ket}[1]{|#1\rangle}
\newcommand{\beq}{\begin{equation}}
\newcommand{\eeq}{\end{equation}}
\newcommand{\beqa}{\begin{eqnarray}}
\newcommand{\eeqa}{\end{eqnarray}}
\newcommand{\hh}{{\cal H}}
\begin{document}

\title{Calculation of the Gradient of a
Quantum Cost Function
 using
``Threading". \\Application of these ``threaded gradients"
 to a \\Quantum Neural Net\\ inspired by\\
 Quantum Bayesian Networks }

\author{Robert R. Tucci\\
        tucci@ar-tiste.com}

\date{\today}
\maketitle
\vskip2cm

\section{Introduction}

Hybrid Quantum Classical (HQC) computation
as being pursued by Rigetti Inc. involves
minimizing a ``quantum cost function", i.e.,
the mean value of a Hermitian operator,
wherein that mean value is calculated empirically from
the data yielded by a physical quantum computer.

There are many methods available for minimizing
a cost function on a classical computer.
Which minimizing method performs
best for a particular case depends on the nature of
the cost function and of the
computing resources at the user's disposal.
Some methods, like, for instance,
the  Powell method (available on
{\tt scipy.optimize.minimize}),
do not require
calculating
the gradient of the cost function.
Others, the ``gradient based methods", do.
One method that is particularly well
suited to AI problems when
distributed computing (GPU, TPU)
resources are available, is
gradient descent
used in conjunction with
a method of calculating gradients
called back-propagation (BP).
This begs the question,
can we find a good
method like BP for calculating
the gradients of a quantum cost function,
and then use gradient descent to
minimize the cost function?
The grand goal is to
give an exact analytical
formula for the gradients of a quantum cost function,
and to
express that formula as a sum of parts that
can each be readily evaluated empirically on a qc.

Several teams from the Univ. of Tokyo
Refs.\cite{japan}\cite{japan2},
Xanadu Inc. Ref.\cite{xanadu}, and QCWare Inc.
Ref.\cite{qcware}
have already
implemented their own algorithms for
accomplishing this grand goal.
Refs. \cite{japan} and \cite{xanadu}
use a formula that allows them to split
the calculation of the gradient
of a single uncontrolled rotation
along either the X, Y or Z axes into two
quantum circuits. Refs.\cite{japan2}
and \cite{qcware} use a tomographic approach.

The method proposed in this paper to tackle this grand goal
is not tomographic like the methods of Refs.\cite{japan2}
and \cite{qcware}.
Our method is more akin to the approach of
Refs. \cite{japan} and \cite{xanadu},
except that we use an ancilla qubit (they don't),
and we handle the case of gates with multiple
controls (they
only consider derivatives of gates with no controls).
Furthermore, we apply our method to a novel
quantum circuit, a quantum neural net
inspired by Quantum Bayesian Networks.
Last but not least, we point out
the huge benefits of ``qc threading" for
our method.
The benefits are particularly
high for NISQ (Noisy Intermediate Scale
Quantum) devices such as those available on the Rigetti Cloud.

This paper describing our method is being released
concurrently with a full implementation,
open source, in Python, of our method.
The implementation is part of
 the Qubiter repo at GitHub.

\section{Derivative of Uncontrolled U(2) gate}\label{sect-deriv}

In this section,
we  will show how to express
the derivative of
a 2-dim U(2) matrix with respect
to one of its 4 parameters,
as a linear combination of three U(2) matrices.
Luckily,
the parameters of most standard quantum gates
always appear inside
a 2-dim U(2) matrix with zero, one, or more controls
attached.
So, in this section, we will only concern ourselves
with calculating the derivatives
of a U(2) matrix.

Mitarai, et al. in Ref. \cite{japan}
and the authors of Xanadu's PennyLane
software Ref.\cite{xanadu}
have come up with a similar
scheme, but their method
differs from ours in some important respects.
To tackle a
general U(2)
transformation,
they first decompose
it
into an Euler
product of 3 rotations along
the standard X,Y or Z axes,
and then they take the derivatives
of each of those 3 rotations.
In this paper,
we
give a
method that can
handle an arbitrary
U(2)
transformation,
without
having to
do an Euler
decomposition first.

Let us first consider  a rotation about
a standard axis, $X, Y$ or $Z$,
instead of a general U(2) matrix.
If we let
 $\sigma_k$ for $k=1,2,3$ denote the Pauli matrices,
 then a rotation about the $Z$ axis
 is

\beq
U(\theta_3) = e^{i\sigma_3\theta_3} = C + i\sigma_3 S
\;,
\eeq
where
$\theta_3$
is some real number and
we abbreviate $S = \sin\theta_3, C = \cos \theta_3$.
Then

\beq
\frac{dU}{dt} = \dot{\theta}_3(-S + i\sigma_3 C)
\;.
\eeq
Hence
\beq
\frac{dU}{d\theta_3}=
-S + i\sigma_3 C=e^{i(\frac{\pi}{2}+\theta_3)\sigma_3}
=U(\frac{\pi}{2}+\theta_3)
\;.
\eeq
Thus, for a rotation along a standard axis,
one can evaluate the derivative of a gate
simply
by replacing that gate by that gate
with its angle advanced by $\frac{\pi}{2}$.
No need to take finite differences.

Now let us consider the most general U(2).
We will parameterize it as

\beq
U= e^{i(\theta_0 + \theta_1\sigma_X
+ \theta_2\sigma_Y
+ \theta_3\sigma_Z)}
\;,
\label{u2_pametrization}
\eeq
where $\theta_k$ for $k = 0, 1, 2, 3$ are real numbers.
Derivatives with respect to $\theta_0$
are trivial so we will set $\theta_0=0$ henceforth.
Using the Einstein summation convention,

\beq U = e^{i\sigma_k\theta_k} = C +
i\sigma_k \frac{\theta_k}{\theta} S
\;,
\eeq
where we are abbreviating

\beq
\theta = \sqrt{\theta_k\theta_k},
 S = \sin\theta, C = \cos \theta
 \;.
 \eeq
 Then, it's easy to show that

 \beq
 \frac{dU}{dt}=-S \frac{\theta_k}{\theta}
 \dot{\theta_k}+ i\sigma_k\dot{\theta_r}
 \left[\frac{\theta_k\theta_r}{\theta^2} C+
  \frac{S}{\theta}(-\frac{\theta_k\theta_r}{\theta^2}
  + \delta_{k, r})\right]
  \;.
  \label{gen_der}
  \eeq

In the rest of this section,
we will try to recast the right hand side of
 Eq.(\ref{gen_der}) into a form that
 is more convenient for empirical
 calculation from qc data.
Before embarking on this task,
let us introduce some notation.

Henceforth, we will
represent a real-valued unit vector by
a letter with a caret above it:
$\hat{a} = \frac{\vec{a}}{|\vec{a}|}$.
Also, for any real-valued 3-dim vector $\vec{a}$, let

\beq
\sigma_{\vec{a}}=\vec{a}\cdot\vec{\sigma}
\;.
\label{paulions}
\eeq
Eq.(\ref{paulions}) is a natural generalization
of the Pauli matrix notation. If $\hat{e}_A$
is the unit vector in direction $A$ for $A=X,Y,Z$,
then $\hat{e}_A\cdot\vec{\sigma} = \sigma_A$ for
$A=X,Y,Z$. Expressed in
the notation of Eq.(\ref{paulions}),
two familiar Pauli matrix identities
are

\beq
\sigma_{\vec{a}}\sigma_{\vec{b}}=\vec{a}\cdot\vec{b}
+ i\sigma_{\vec{a}\times\vec{b}}
\;,
\eeq
where $\vec{a}$ and $\vec{b}$
are any two 3-dim vectors,
and

\beq
e^{i\theta\sigma_{\hat{n}}} = \cos\theta +
i\sigma_{\hat{n}}\sin\theta
\;,
\label{cis}
\eeq
where $\theta$ is a real number and $\hat{n}$
is a 3-dim unit vector. Eq.(\ref{cis})
can be proven by Taylor expanding,
and using $\sigma_{\hat{n}}^2=1$.

We will also use the following notation for the projectors
$P_0$ and $P_1$
along the direction of $\ket{0}$
and $\ket{1}$, respectively,
in a 1-qubit space.

\beq
\begin{array}{l}n=P_1=|1\rangle\langle 1|,\\
\bar{n}=1-n=P_0=|0\rangle\langle 0|
\end{array}
\;.
\eeq
$n$ is often called the number operator.
Whenever we say $\Omega(\alpha)$
for a 1-qubit operator $\Omega$,
we mean $\Omega$ applied to qubit $\alpha$.

Eq.(\ref{gen_der}) for the general form of
$\dot{U}$ when parameterized
as Eq.({\ref{u2_pametrization}) (with $\theta_0=0$)
is fairly opaque.
To clarify
Eq.(\ref{gen_der}),
we start by specializing it to $t=\theta_1$.
The cases $t=\theta_2, \theta_3$
can be obtained from the case
$t=\theta_1$ simply by replacing
1 subscripts in our final result by 2 or 3.
So, setting $t=\theta_1$ in Eq.(\ref{gen_der}),
we immediately get:

\beq
\frac{\partial U}{\partial \theta_1} =
\left\{
\begin{array}{l}
-\frac{\theta_1 S}{\theta^2}
\left[i\sigma_{\hat{\theta}}\right]
\\
+
\frac{\theta_1}{\theta}
\left[-S + i\sigma_{\hat{\theta}}C\right]
\\
+
\frac{S}{\theta}
\left[i\sigma_1\right]
\end{array}
\right.
\;.
\eeq
If we define

\beq
p_1=\frac{\theta_1}{\theta},\;\;p_S = \frac{S}{\theta}
\;,
\eeq
then

\beq
\boxed{
\frac{\partial U}{\partial \theta_1} =
\left\{
\begin{array}{l}
-p_1p_S
\left[e^{i\frac{\pi}{2}\sigma_{\hat{\theta}}}\right]
\\
+
p_1
\left[e^{i(\frac{\pi}{2}+\theta)\sigma_{\hat{\theta}}}\right]
\\
+
p_S
\left[e^{i\frac{\pi}{2}\sigma_1}\right]
\end{array}
\right.
\;.}
\label{eq_boxed}
\eeq

Henceforth,
we will refer to
these 3 pieces as ``dparts", which stands for ``derivative
parts". Note that we can replace 1 by 2 or 3
in Eq.(\ref{eq_boxed}) to get
partials of $U$ with respect to $\theta_2$
and $\theta_3$.

\section{Derivative of Quantum Cost Function}\label{sec-q-cost}
In this section, we show how to
express the
gradient of a quantum cost function as a sum of
mean values that can be
readily evaluated empirically on a real qc.

Suppose $a, A$ are integers such that $a\leq A$,
and $\Omega_j$ are operators acting on $N_b$ qubits.
Define
\beq
\Omega_{[a,A]} = \Omega_a \Omega_{a+1}\ldots \Omega_{A}
\;
\eeq
and

\beq
\Omega_{[A,a]} = \Omega_A\ldots \Omega_{a+1} \Omega_{a}
\;.
\eeq
Note that

\beq
(\Omega_{[a, A]})^\dagger = \Omega^\dagger_{[A,a]}
\;.
\eeq

The cost function that we minimize
in Hybrid Quantum Classical computing
 can be expressed analytically as

\beq C = \bra{\psi_0}(\Omega_{[T-1,0]})^\dagger \hh
\Omega_{[T-1,0]}\ket{\psi_0}
\;,
\label{eq_q_cost_fun}
\eeq
where the $\Omega_j$ are unitary operators
and $\hh$ is a Hermitian operator
acting on $N_b$ qubits. Now let us
focus on
taking the derivative of $\Omega_\tau$, the gate for a particular time
$\tau \in \{0,1, \ldots T-1\}$. Define

\beq
\ket{\psi_\tau} = \Omega_{[\tau-1, 0]}\ket{\psi_0}
\;
\eeq
and

\beq
\hh_\tau = (\Omega_{[T-1,\tau]})^\dagger \hh \Omega_{[T-1,\tau]}
\;.
\eeq
Henceforth,
we will
use the angled brackets to
 denote an average with respect to
state $\ket{\psi_\tau}$:
\beq
\bra{\psi_\tau}\cdot\ket{\psi_\tau}
=
\langle \cdot\rangle
\;.
\eeq
Using the above notation, the
cost function and its derivative
with respect to a parameter $\theta_{\tau 1}$
that lives inside the operator $\Omega_{\tau 1}$,
can be expressed as

\beq
C = \langle \hh_\tau\rangle
\;,
\eeq
and

\beq
\frac{\partial C}{\partial\theta_{\tau 1}}
=
\langle \hh_\tau
\Omega_\tau^\dagger
\frac{\partial \Omega_\tau}{\partial\theta_{\tau 1}}
\rangle
+ h.c.
\;
\label{derv_cost1}
\eeq
h.c. denotes the hermitian conjugate
of the preceding twin expression.

Let $U_{\tau}(0)$
be an element of $SU(2)$ acting on qubit 0.
$U_{\tau}(0)$ can be parameterized as

\beq
U_{\tau}(0)=
e^{i[\theta_{\tau 1}\sigma_X(0)
+
\theta_{\tau 2}\sigma_Y(0)
+
\theta_{\tau 3}\sigma_Z(0)]}
\;,
\eeq
where the $\theta_{\tau d}$ for $d=1,2,3$
are real numbers,
and $\sigma_X(0), \sigma_Y(0), \sigma_Z(0)$
are
the Pauli matrices acting on qubit 0.
For definiteness and as a good illustration,
we will henceforth assume that the
unitary operator $\Omega_\tau$
has the special form
of an SU(2) gate with two controls:

\beq
\Omega_{\tau}=
U_{\tau}(0)^{n(1)n(2)}
\;,
\label{special_omega_tau}
\eeq
where, as usual, $n=\ket{0}\bra{0}$
is the number operator, and $n(1), n(2)$
are number operators acting on qubits 1 and 2,
respectively.
As was shown in Section \ref{sect-deriv},
one can express the partial derivative of
$U_{\tau}(0)$ with respect
 to its parameter $\theta_{\tau 1}$,
as a linear combination

\beq
\frac{\partial U_{\tau}(0)}{\partial\theta_{\tau 1}}
=
\sum_k \lambda_{\tau 1,k} V_{\tau 1,k}(0)
\;,
\label{lin_comb}
\eeq
where the
coefficients $\lambda_{\tau 1,k}$
are real numbers and the
$V_{\tau 1,k}(0)$ are elements of $SU(2)$.
Here
$k=1,2,3$.
From Eqs.(\ref{special_omega_tau})
and (\ref{lin_comb}), it follows that

\beq
\Omega^\dagger_\tau
\frac{\partial \Omega_\tau}{\partial\theta_{\tau 1}}
=
\sum_k \lambda_{\tau 1,k}\left[
n(1)n(2)U^\dagger_{\tau}(0)V_{\tau 1,k}(0)
\right]
\;,
\eeq
which, when substituted into Eq.(\ref{derv_cost1}),
yields:

\beq
\frac{\partial C}{\partial\theta_{\tau 1}}
=
\sum_k \lambda_{\tau 1,k}
\left\langle
\hh_\tau n(1)n(2)U^\dagger_{\tau}(0)V_{\tau 1,k}(0)
+h.c.\right\rangle
\;.
\eeq

Note that
$U^\dagger_{\tau}(0)V_{\tau 1,k}(0)$ is
a product of SU(2) matrices, so
it is itself an SU(2)
matrix acting on qubit 0.
Hence, it can be expressed as

\beq
U^\dagger_{\tau}(0)V_{\tau 1,k}(0)
= \exp[i\alpha_{\tau 1,k} \sigma_{\hat{\alpha}_{\tau 1,k}}(0)]=
W_{\tau 1,k}(0)
\;,
\eeq
where $\alpha_{\tau 1,k}$ is a real number
and $\hat{\alpha}_{\tau 1,k}$ is a real
valued unit vector.

Recall that if $\sigma_Z(\beta)$ is the $Z$ Pauli matrix,
and $n(\beta)=\ket{0}\bra{0}_\beta$ is the number operator,
acting on qubit $\beta$,
then

\beq
1-2n(\beta) = (-1)^{n(\beta)} = \sigma_Z(\beta)
\;.
\eeq
This result relies on the fact
that the projection operator $n$
satisfies $n^2=n$  and, therefore, it
can only have two eigenvalues, 0 and 1.
Let

\beq
\eta(1, 2) = n(1)n(2)
\;.
\eeq
Eta's square also equals itself so
$\eta\in \{0, 1\}$. Therefore

\beq
1-2\eta = (-1)^{\eta} = (-1)^{n(1)n(2)} = \sigma_Z(1)^{n(2)}=
\sigma_Z(2)^{n(1)}
\;.
\eeq

Let ``dpart" (derivative part) stand for
\beq
{\rm dpart} =\langle \hh_\tau  \eta(1,2)W(0)\rangle + h.c.
\;.
\eeq
Since

\beq
\eta= \frac{1}{2}(1- (-1)^\eta)
\;,
\eeq
it follows that
\beq
{\rm dpart}
=
\left\{\begin{array}{r}
\frac{1}{2}\langle \hh_\tau  W\rangle + h.c.
\\
-\frac{1}{2}\langle \hh_\tau  (-1)^\eta W\rangle + h.c.
\end{array}\right.
\;.
\label{top_bot_rhs}
\eeq
Next we add to the quantum circuit
an extra ancilla qubit called $\xi$.
We will refer to the top (resp., bottom)
term on the right hand side of Eq.(\ref{top_bot_rhs})
as depart$_+$ (resp., dpart$_-$). The sign
of the dpart
will be referred to as its ``polarity". We can get
dpart$_\pm$ by
starting the ancilla qubit $\xi$
at $\ket{0}$,
applying a Hadamard
matrix to it,
and measuring the mean value
of $\sigma_X$ for $\xi$.
In other words, one can verify that

\beq
{\rm dpart}_+=
\left[
\begin{array}{ccccc}
\bra{\psi_\tau}
&\mid&\hh_\tau &\mid&\ket{\psi_\tau}\\
&(W^\dag)^{n(\xi)}&&W^{n(\xi)}&\\
\bra{0}_\xi
Had(\xi)&\mid&\sigma_X(\xi)&\mid&Had(\xi)\ket{0}_\xi
\end{array}
\right]
\;,
\eeq
and

\beq
{\rm dpart}_-=
-\left[
\begin{array}{ccccc}
\bra{\psi_\tau}
&\mid&\hh_\tau &\mid&\ket{\psi_\tau}\\
&(W^\dag)^{n(\xi)}\sigma_Z(\xi)^\eta&&\sigma_Z(\xi)^\eta W^{n(\xi)}&\\
\bra{0}_\xi
Had(\xi)&\mid&\sigma_X(\xi)&\mid&Had(\xi)\ket{0}_\xi
\end{array}
\right]
\;.
\eeq

\section{Application to a type of
Quantum Neural Net inspired by
Quantum Bayesian Networks
}

So far, we have considered  the derivative
of any single gate of a quantum cost function.
We considered a multi-controlled U(2) gate,
and a derivative with respect to any of its 4 parameters.
But we left the
quantum cost function arbitrary.
In this section, we apply the results
of previous sections to a very special type of
quantum cost function.

More specifically, in
this section we will consider a quantum cost function
$\bra{\psi_T}\hh\ket{\psi_T}$
whose state $\ket{\psi_T}$
is a
quantum circuit
that could be described as a Quantum Neural Net inspired by
Quantum Bayesian Networks.
We will also assume that the Hermitian
operator $\hh$
is given to us already expressed as
 a ``QubitOperator". {\tt QubitOperator}
is a class
in the open-source software
OpenFermion. It
stores $\hh$ as a
a linear combination
 with real coefficients $c_r$
of tensor products
(aka Pauli strings) of a Pauli operator
(or the identity) acting on each qubit:

\beq
\hh = \sum_r c_r \prod_{\beta=0}^{N_b-1}
\sigma_{d_{\beta,r}}(\beta)
\;.
\label{eq_qbit_op}
\eeq
Here $d_{\beta,r} \in \{0,1,2,3\}$
so as to include the identity and the 3 Pauli matrices.

In Qubiter's
implementation of the
ideas of this paper,
we call the quantum
circuit representing $\ket{\psi_T}$
a ``Stairs
Circuit". For example, this is what the
Qubiter's Picture file of a Stairs Circuit
looks like for 3 qubits

\begin{verbatim}
U   |   |
O---U   |
@---U   |
O---O---U
O---@---U
@---O---U
@---@---U
\end{verbatim}

Here, U is a general U(2) matrix with 4 parameters,
all of which can be
made into placeholder variables
or simply kept as floats. If each U is represented by a node and
the controls of each U represent
 its parents, then this quantum circuit
can be represented by a fully connected
Quantum Bayesian Network (QB
net). (See my 10 year old blog called ``Quantum Bayesian Networks" for
more info than you would ever want to know about QB nets).

Qubiter can also be asked to
construct a QB net that is **not** fully
connected, by limiting the number
 of controls for a given U to fewer
than a control on all the qubits to
the left of U.
For example, suppose that in the
3 qubits case, we restrict the
 parents of the U in the last gate to
just one, instead of the 2 parents
 that it has in the fully connected
case. Then we get

\begin{verbatim}
U   |   |
O---U   |
@---U   |
O---+---U
@---+---U
\end{verbatim}
when qubit 0 has qubit 2 but not 1 as a parent,
or

\begin{verbatim}
U   |   |
O---U   |
@---U   |
|   O---U
|   @---U
\end{verbatim}
when qubit 0 has qubit 1 but not 2 as a parent.

Qubiter appends at the end
of  the above
quantum circuits a ``coda" (tail).
Note that

\beq
e^{-i\frac{\pi}{4}\sigma_Y}\sigma_Z
e^{i\frac{\pi}{4}\sigma_Y} =\sigma_X
\;,
\eeq

\beq
e^{i\frac{\pi}{4}\sigma_X}\sigma_Z
e^{-i\frac{\pi}{4}\sigma_X} =\sigma_Y
\;.
\eeq
A coda is a rotation
$e^{i\frac{\pi}{4}\sigma_Y}$ for every
Pauli $\sigma_X$,
and a rotation
$e^{-i\frac{\pi}{4}\sigma_X}$
for every Pauli $\sigma_Y$,
whenever
$\sigma_X$ or $\sigma_Y$
occur on the right hand side
of Eq.(\ref{eq_qbit_op}).
If such a coda is appended to
the quantum circuit,
then we only have to
measure mean values
of $\sigma_Z$ or 1 on all qubits.
Such mean values
are easy to evaluate because
they are diagonal
matrices of ones and minus ones.

The quantum circuit corresponding to
a  fully connected QB net has a
number of U(2) gates which grows
exponentially with the number of qubits,
and each U(2) gate
has as controls all the qubits
to its left.\footnote{Furthermore, current quantum computers
require exponential complexity
in number of controls to
calculate multi-controlled gates. I
characterize this as a paradox and
a serious shortcoming.} Clearly,
the complexity of
such quantum circuits blows
up exponentially. But suppose we limit
the number of parents of every U(2)
to a fixed number, say, for example, to 2 (except for
the first gate, the ``prior",
 which has no parents, and the second gate,
 which can have only one parent).
 Such parent-limited quantum circuits
 have a complexity
 which increases
 polynomially
 in the number of qubits.
 Which 2 parents are chosen for each U(2)
 can be decided heuristically
in numerous ways. For example,
one can move one parent, chosen at random,
from qubit A to qubit B,
evaluate the cost function
for each case, and choose the parent
with the lower cost.

\section{Threaded Gradients}
As an example,
suppose
that we are taking the derivative
of the third gate,
of the fully connected 3 qubit graph
with respect to $t1 =\theta_1$:

\begin{verbatim}
        U   |   |
        O---U   |
d/dt1   @---U   |
        O---O---U
        O---@---U
        @---O---U
        @---@---U
\end{verbatim}
When we do so,
we get
a quantum circuit with positive
polarity:

\begin{verbatim}
|   U   |   |
|   O---U   |
@---@---U   |
|   O---O---U
|   O---@---U
|   @---O---U
|   @---@---U
\end{verbatim}
and one with negative polarity:

\begin{verbatim}
|   U   |   |
|   O---U   |
@---@---U   |
Z---@   |   |
|   O---O---U
|   O---@---U
|   @---O---U
|   @---@---U
\end{verbatim}
We would also have to
append codas to these circuits.
Note that an ancilla qubit was added,
so the quantum circuit being
differentiated has 3 qubits,
but its derivative parts have 4 qubits.

The idea of ``threaded gradients"
is to partition
all the qubits of a qc into
groups of 4 qubits (4 is just for this example),
and to evolve
each of these 4 qubit islands
independently,
and concurrently.
Each 4 qubit island
is assigned
the task of
evaluating the mean value
of one of the dparts.

Obviously, multi-threading
the task of evaluating
a gradient
of a quantum cost function,
is ideal for a NISQ device,
because it only
requires quantum entanglement
inside small islands of 4
(4 is just for this example) qubits each, but
no correlation among islands.

\begin{thebibliography}{99}
\bibitem{japan}
	Kosuke Mitarai, Makoto Negoro,
Masahiro Kitagawa, and Keisuke Fujii.
 ``Quantum circuit learning" arXiv:1803.00745.
\bibitem{japan2}
Ken M. Nakanishi, Keisuke Fujii, Synge Todo,
``Sequential minimal optimization
for quantum-classical hybrid algorithms",
	arXiv:1903.12166 [quant-ph]
\bibitem{xanadu}
PennyLane documentation has large list of references
to arXiv papers by themselves and others.
\bibitem{qcware}
Robert M. Parrish, Joseph T. Iosue, Asier Ozaeta, Peter L. McMahon,
``A Jacobi Diagonalization and Anderson Acceleration Algorithm For
Variational Quantum Algorithm Parameter Optimization",
arXiv:1904.03206 [quant-ph]

\end{thebibliography}

\end{document}


\section{Introduction}
\label{sec:HomographyIntroduction}

Computer vision often deals with diverse image transformations to improve the outcome of the subsequent post-processing phase. The perspective transformation was deemed of particular interest to our goal of traffic analysis. Specifically, removal of perspective distortion. To this end, the so-called homography mapping is often exploited.

Broadly speaking, homography is a perspective projection of a plane from one camera view into a different camera view. The perspective projection maps points from a $3$D world onto a $2$D image plane along lines that emanate from a single point~\cite{geetha2013automatic, bousaid2020perspective}. Such a projection is contained within a $3 \times 3$ invertible transformation matrix called the homography matrix (or just homography) with $8$ \gls{dof}. A general homography matrix can be defined as follows
\begin{equation}
    \label{eq:HomographyMatrix}
    \H =
    \begin{bmatrix}
        h_{11} & h_{12} & h_{13} \\
        h_{21} & h_{22} & h_{23} \\
        h_{31} & h_{32} & h_{33}
    \end{bmatrix}
\end{equation}
This transformation may facilitate mapping between two views of the same plane. Concretely, a single vector $\vectt{u}{u_x, u_y, 1}$, which represents a warped keypoint in homogeneous coordinates, is mapped onto the rectified keypoint $\vectt{\tilde{u}}{\tilde{u}_x, \tilde{u}_y, 1}$, by the homography $\H$ using the transformation $s \vect{\tilde{u}} \approx \H \vect{u}$, where $s$ represents the scale factor. In our case, the goal was to rectify the image so that it looks as if the camera was in an orthogonal position with respect to the desired plane in the world.

Homography is frequently adopted for text document rectification to generate a fronto-parallel view~\cite{lu2005perspective, miao2006perspective}, image stitching~\cite{adel2014image, gao2011constructing}, extracting metric information from $2$D images~\cite{zhang2000flexible}, pose estimation~\cite{mariyanayagam2018poseestim}, and for various traffic-related applications, \egtext{}, ground-plane detection~\cite{arrospide2010homography}, and bird's-eye view projection~\cite{luo2010low}.

We aimed at exploring the possibility of employing homography for \gls{vot}. The primary incentive was the fact that as long as a static camera is used and a few assumptions that we will discuss later hold, the scene may be easily stripped off the effect of the perspective distortion. Consequently, the use case of tracking vehicles visually using a static camera while exploiting a fronto-parallel view over the road seemed like a plausible extension with possible advantages for traffic analysis. Furthermore, the combination of homography and object tracking is present in the literature, \egtext{}~\cite{bose2004groundplane, zhang2012homographytrack, Mei2009}. Bose~\etal{}~\cite{bose2004groundplane} presented a fully automated technique for both affine and metric rectification of a given ground plane by simply tracking moving objects. The derivation of the necessary constraints for projective transformation between the image and the ground plane was obtained by observing objects that moved at constant velocity in the world for some part of their trajectory. We conjectured that the extra information about the scene geometry that we may achieve using rectification could aid in making the tracking more accurate. Visual trackers are often supported by motion models such as Kalman filter~\cite{kalman1960linearfilter}, so the rationale was to estimate the motion model in an orthogonal projection, rather than a perspectively distorted one.

% ------------------------------------------------------------------------------
\begin{figure}[t]
    \centerline{\includegraphics[width=\linewidth]{figures/homography/homography_road.png}}
    \caption[Square marker on a road]{An example of a virtual square marker present on a road that may be used to establish a point correspondence, and thus the homography transformation, too. The obtained view allows for many applications such as speed and size measurements that would otherwise be a lot more problematic in a perspectively deformed view. \externalsrc{\cite{bose2004groundplane}}}
    \label{fig:RoadMarker}
\end{figure}
% ------------------------------------------------------------------------------

A common approach to estimate the homography is to use a set of at least four $2$D point correspondences~\cite{hartley1997defense}. The points that are used for establishing the $2$D point correspondences will be referred to as keypoints. These keypoints may belong to a marker which is an object with a known shape that is either naturally occurring or artificially positioned in the scene. A regular, easy-to-detect pattern (\egtext{}, a chessboard) is commonly utilized~\cite{zhang2016flexible}. A single marker is identified in the image by multiple independent keypoints that have a direct correspondence to its real shape, thus making a group of point correspondences. For the sake of traffic analysis, the marker may be represented by virtually any points on the image as long as certain conditions are met (\figtext{}~\ref{fig:RoadMarker}). However, the point correspondences established this way are often subjected to noise, thus errors may be introduced in the homography estimation. Although $4$ keypoints are satisfactory, often a greater number of keypoints is used, allowing to use optimization~\cite{osuna2016multiobjective, mou2013robust}. Subsequently, an outlier removal becomes an important step in the processing pipeline, for which effective and robust algorithms such as RANSAC~\cite{fischler1981ransac} are usually employed.

% ------------------------------------------------------------------------------
\begin{figure}[t]
    \centerline{\includegraphics[width=\linewidth]{figures/homography/motivation_diagram.pdf}}
    \caption[Homography ranking motivation diagram]{A fundamental difference between existing homography estimation methods and our proposed method for homography ranking. If there are multiple markers while the information about their relative positions in the world is absent, the existing approaches can only estimate isolated homographies without the ability to select the best one. To address this issue, our method easily serves as an extension to existing approaches by exploiting multiple markers to rank the isolated homographies from the ``best'' to the ``worst''.}
    \label{fig:HomographyMotivationDiagram}
\end{figure}
% ------------------------------------------------------------------------------

A real-world application of generating a bird's-eye view over a road from a video recording when we could not use a large marker to cover a sufficient portion of the road (\figtext{}~\ref{fig:MultipleMarkersOnRoad}) motivated this entire project. We observed that, under our conditions, the homography estimation based on a single small marker was inaccurate. Therefore, there was an attempt to utilize multiple small markers and measure their relative positions. However, as is often the case in practice, their position measurements were highly noisy at best. Thus, we had to bypass the position measurements altogether, which led us to adopt the proposed method, instead. It is crucial to emphasize that our method can also be adopted in a situation when the marker placed at various positions on the same planar surface can be seen at different frames using a static camera. Stacking the captured frames onto each other would effectively yield an artificially generated view of multiple markers.

Assume a presence of a sole marker in the scene (\figtext{}~\ref{fig:RoadMarker}). Moreover, assume the view of the marker is perspectively distorted. If we know its real shape, then it is possible to compute the homography. However, when multiple copies of the same marker are visible, but their positions in the world are unknown, the detailed information about the shape is not enough to incorporate all the keypoints in the estimation. In the absence of position information, existing approaches for homography estimation based on point correspondences do not work because the projection has to preserve the proportional positions. As a result, estimating the homography while not knowing the ground-truth layout of the keypoints up to an arbitrary scale does not guarantee, and often does not even lead, to the correct result.

Under the constraints discussed above, the existing methods can only generate an isolated homography for each marker based on the one-to-one point correspondence (\figtext{}~\ref{fig:HomographyMotivationDiagram}). Each homography may be affected by different sources of noise, \egtext{}, low resolution, blur, or keypoint detection. Thus, the outcome of rectification may vary up to a great extent. In addition, many practical applications often use a marker that just covers a small portion of the image, increasing susceptibility to noise as a result. The trivial solution would be to use a bigger marker that covers the majority of the estimated plane's area. But such a solution is often cumbersome. It is simply not possible to ``merge'' multiple isolated homographies together.

% ------------------------------------------------------------------------------
\begin{figure}[t]
    \centerline{\includegraphics[width=\linewidth]{figures/homography/markers_on_the_road.png}}
    \caption[Multiple markers on the road]{A motivating real-world example. We can see different frames captured during a video recording that show various positions of the same marker. The picture after the ``equality'' sign is a merge of the previous frames for better illustration. Due to the use of a static camera, we may treat the positions of the given marker on individual frames as if they were captured simultaneously. However, the question remains unanswered. Given multiple markers in the absence of their position information, which one is the best to choose for rectification?}
    \label{fig:MultipleMarkersOnRoad}
\end{figure}
% ------------------------------------------------------------------------------


\section{Lifting SSAT to NEXPTIME-completeness}
\label{sect:dssat-technique}

\subsection{Formulation}
In the following, we extend DQBF to its stochastic variant,
named \textit{dependency stochastic Boolean satisfiability} (DSSAT).

A DSSAT formula $\Qf$ over $V=\{x_1,\ldots,x_n,y_1,\ldots,y_m\}$ is of the form:
\begin{align}
    \label{eq:dssat}
    \random{p_1}x_1,\ldots,\random{p_n}x_n,\exists y_1(\dep{y_1}),\ldots,\exists y_m(\dep{y_m}).\pf(x_1,\ldots,x_n,y_1,\ldots,y_m),
\end{align}
where each $\dep{y_j}\subseteq\{x_1,\ldots,x_n\}$ denotes the set of variables that variable $y_j$ depends on,
and Boolean formula $\pf$ over $V$ is quantifier-free.
We denote the set $\{x_1,\ldots,x_n\}$ (resp. $\{y_1,\ldots,y_m\}$) of randomly (resp. existentially) quantified variables of $\Qf$ by $\rvs$ (resp. $\evs$).

Given a DSSAT formula $\Qf$ and a set $\skf=\{f_j:\av{\dep{y_j}}\mapsto\booldom\ |\ j=1,\ldots,m\}$ of Skolem functions,
the satisfying probability $\spb{\pcf{\Qf}{\skf}}$ of $\Qf$ with respect to $\skf$ is defined as follows:
\begin{align}\label{eq:dssat-probability}
    \spb{\pcf{\Qf}{\skf}}=\spb{\random{p_1}x_1,\ldots,\random{p_n}x_n.\pcf{\pf}{\skf}},
\end{align}
where $\pcf{\pf}{\skf}$ denotes the formula obtained by substituting existentially quantified variables in $\pf$ with their respective Skolem functions, as defined in~\cref{sect:dssat-dqbf}.
In other words, the satisfying probability of $\Qf$ with respect to $\skf$ equals
the satisfying probability of the SSAT formula $\random{p_1}x_1,\ldots,\random{p_n}x_n.\pcf{\pf}{\skf}$.

\begin{example}
    Given a DSSAT formula $\Qf=\random{0.5}x_1,\random{0.5}x_2,\exists y_1(\{x_1\}),\exists y_2(\{x_2\}).\pf$
    and $\pf=(x_1\lor\lnot y_1)(\lnot x_1\lor y_1)(\lnot x_1\lor\lnot x_2\lor y_2)(x_1\lor\lnot y_2)(x_2\lor\lnot y_2)$,
    the satisfying probability of $\Qf$ with respect to $\skf=\{f_1(x_1)=x_1,f_2(x_2)=x_2\}$
    equals $\spb{\random{0.5} x_1,\random{0.5} x_2.\pcf{\pf}{\skf}}=\spb{\random{0.5} x_1,\random{0.5} x_2.(x_1\lor\lnot x_2)}=0.75$.
\end{example}

The \textit{decision version} of DSSAT is stated as follows.
Given a DSSAT formula $\Qf$ and a threshold $\theta\in[0,1]$,
decide whether there exists a set $\skf$ of Skolem functions such that $\spb{\pcf{\Qf}{\skf}}\geq\theta$.
On the other hand, the \textit{optimization version} asks to find a set of Skolem functions to maximize the satisfying probability of $\Qf$.

The formulation of SSAT can be extended by incorporating universal quantifiers,
resulting in a unified framework named \textit{extended} SSAT (XSSAT)~\cite{SATHandbook-SSAT},
which subsumes both QBF and SSAT.
In the extended SSAT,
besides the four rules discussed in~\cref{sect:background-ssat} to calculate the satisfying probability of an SSAT formula $\Qf$,
the following rule is added:
$\spb{\Qf}=\min\{\spb{\ncf{\Qf}{x}},\spb{\pcf{\Qf}{x}}\}$, if the outermost variable $x$ is universally quantified.

Similarly, an \textit{extended} DSSAT (XDSSAT) formula $\Qf$ over a set of variables
$\{x_1,\ldots,x_n,y_1,\ldots,y_m,z_1,\ldots,z_l\}$ is of the form:
\begin{align}\label{eq:dssat-xdssat}
    Q_1 v_1,\ldots,Q_{n+l} v_{n+l},\exists y_1(\dep{y_1}),\ldots,\exists y_m(\dep{y_m}).\pf,
\end{align}
where $Q_i v_i$ equals either $\random{p_k} x_k$ or $\forall z_k$ for some $k$ with $v_i \neq v_j$ for $i \neq j$,
and each $\dep{y_j}\subseteq\{x_1,\ldots,x_n,z_1,\ldots,z_l\}$ denotes the set of randomly and universally quantified variables that variable $y_j$ depends on.

The satisfying probability of an XDSSAT formula $\Qf$
with respect to a set $\skf=\{f_j:\av{\dep{y_j}}\mapsto\booldom\ |\ j=1,\ldots,m\}$ of Skolem functions,
denoted by $\spb{\pcf{\Qf}{\skf}}$,
equals the satisfying probability of the XSSAT formula $Q_1 v_1,\ldots,Q_{n+l} v_{n+l}.\pcf{\pf}{\skf}$.
This satisfiability definition subsumes those for DQBF (\cref{eq:dssat-dqbf-satisfiable}) and DSSAT (\cref{eq:dssat-probability}),
where the variables preceding the existential quantifiers in the prefixes are solely universally or randomly quantified, respectively.

Note that in the above extension the Henkin-type quantifiers are only defined for the existential variables.
Although the extended formulation increases practical expressive succinctness,
the computational complexity is not changed as to be shown in the next section.

\subsection{Complexity proof}
In the following, we show that the decision version of DSSAT is NEXPTIME-complete.

\begin{theorem}
    The decision version of DSSAT is NEXPTIME-complete.
\end{theorem}
\begin{proof}
    To show that DSSAT is NEXPTIME-complete,
    we have to show that it belongs to the NEXPTIME complexity class and that it is NEXPTIME-hard.

    First, to see why DSSAT belongs to the NEXPTIME complexity class,
    observe that a Skolem function for an existentially quantified variable can be guessed and constructed in nondeterministic exponential time with respect to the number of randomly quantified variables.
    Given the guessed Skolem functions,
    the evaluation of the matrix,
    summation of weights of satisfying assignments,
    and comparison against the threshold $\theta$ can also be performed in exponential time.
    Overall, the whole procedure is done in nondeterministic exponential time with respect to the input size,
    and hence DSSAT belongs to the NEXPTIME complexity class.

    Second, to see why DSSAT is NEXPTIME-hard,
    we reduce the NEXPTIME-complete problem DQBF to DSSAT as follows.
    Given an arbitrary DQBF:
    \begin{align*}
        \Qf_Q=\forall x_1,\ldots,\forall x_n,\exists y_1(\dep{y_1}),\ldots,\exists y_m(\dep{y_m}).\pf,
    \end{align*}
    we construct a DSSAT formula:
    \begin{align*}
        \Qf_S=\random{0.5} x_1,\ldots,\random{0.5} x_n,\exists y_1(\dep{y_1}),\ldots,\exists y_m(\dep{y_m}).\pf
    \end{align*}
    by changing every universal quantifier to a randomized quantifier with probability $0.5$.
    The reduction can be done in polynomial time with respect to the size of $\Qf_Q$.
    We will show that $\Qf_Q$ is satisfiable if and only if there exists a set $\skf$ of Skolem functions such that $\spb{\pcf{\Qf_S}{\skf}}\geq 1$.

    The ``only if'' direction:
    As $\Qf_Q$ is satisfiable,
    there exists a set $\skf$ of Skolem functions such that
    substituting the existentially quantified variables with the respective Skolem functions
    makes $\pf$ a tautology over variables $\{x_1,\ldots,x_n\}$.
    Therefore, $\spb{\pcf{\Qf_S}{\skf}}=\spb{\random{0.5}x_1,\ldots,\random{0.5}x_n.\top}=1\geq 1$.

    The ``if'' direction:
    As there exists a set $\skf$ of Skolem functions such that $\spb{\pcf{\Qf_S}{\skf}}\geq 1$,
    after substituting the existentially quantified variables with the corresponding Skolem functions,
    each assignment $\as\in\av{\{x_1,\ldots,x_n\}}$ must satisfy $\pf$,
    i.e., $\pf$ becomes a tautology over variables $\{x_1,\ldots,x_n\}$.
    Otherwise, the satisfying probability $\spb{\pcf{\Qf_S}{\skf}}$ must be less than $1$
    as the weight $2^{-n}$ of some unsatisfying assignment is missing from the summation.
    Therefore, $\Qf_Q$ is satisfiable due to the existence of the set $\skf$.
\end{proof}

When DSSAT is extended with universal quantifiers,
its complexity remains in the NEXPTIME complexity class
as the fifth rule of the satisfying probability calculation does not incur any complexity overhead.
Therefore the following corollary is immediate.
\begin{corollary}
    The decision problem of XDSSAT is NEXPTIME-complete.
\end{corollary}


\section{Resonance decay simulation.}

\hspace{1.0em}Resonance decay channels are sampled according to the partial decay widths
$\Gamma(m)$,
which depend from masses $m$ of resonances.
All resonances decay isotropically in their rest
frame. For a two-particle decay the outgoing particle ($i,j$) momenta are given
by the Eq. ($\ref{SCD8}$).
 If resonance is among the outgoing particles,
its mass is first determined according to a Breit-Wigner mass
distribution:
\begin{equation}
\label{DS2} F(m) =
\frac{1}{2\pi}\frac{\Gamma(m_R)}{(m_R - m)^2 + \Gamma(m_R)^2/4}.
\end{equation}
  All pole masses $m_R$ and partial
decay widths $\Gamma_R$ are taken from the Review of Particle Properties
\cite{PDG96}.
 If the exit channel contains three or four particles, then
the respective $N$-body phase-space is taken into account for their
momenta.


\subsection{Energy transported by gravitational wave}

When sources produce gravitational waves, their energy is converted to Gravitational waves. Since generally the sources are very massive Energy of gravitational waves will be very large. Since gravitational wave travels in the speed of light, the energy is also transported at that speed. And since Energy flux is equal to the product of Energy and speed, The average energy flux `$E$' is given by \cite{1972ARA&A..10..335P}

\begin{equation}
    E = \frac{c^{3}}{16\pi G} \left \langle (h_{+})^{2} + (h_{\times})^{2} \right \rangle
\end{equation}

So we see the energy flux is very huge because of the term $\frac{c^{3}}{16 \pi G}$ which is in the order of $10^{33}$ Joules sec/ metre$^2$  and it also depends on the average of the square of the plus and cross polarized amplitudes `$h_{+}$' and `$h_{\times}$'. \\

Due to such huge energy it carries the wave can travel unimpeded forever through space and no obstacle can damp gravitational wave because the space in which the obstacle lies itself is the medium of the wave. But the Doppler effect and decrease in amplitude due to radiation of energy causes the wave to die out after the wave travels a very long distance according to the relation $Amplitude \propto \frac{1}{r}$\:.
\\

\noindent So the power or intensity of gravitational wave decreases as it moves through space according to this inverse square law i.e. as the wave moves in space through a distance `$r$' The energy of wave will be spread-out in space across a sphere of radius`$r$' through Surface area of sphere $4\pi r^2$. Since the intensity of wave is Energy over time, Intensity reduces as $r^2$ \cite{Obukhov_2009}.

\begin{equation*}
    E_{flux}= \frac{Energy}{Area} = \frac{E}{4\pi r^2}
\end{equation*}

\begin{equation*}
    E_{flux} \propto \frac{1}{r^2}
\end{equation*}

\noindent But since $E_{flux} \propto Amplitude^2$ we get the relation that $Amplitude \propto \frac{1}{r}$. i.e Amplitude decreases as distance from source increases.

\begin{figure}[h]
    \centering
    \includegraphics[scale=1.05]{images.tex/inverse_square.jpeg}
    \caption{ Here we see how the intensity of wave changes as it goes farther from the source according to the inverse square law. Source :- \href{http://www.mysearch.org.uk/website1/html/339.Laws.html}{The Mysearch Website}}
\end{figure}

\pagebreak

gw-physics-and-ligo/3 Properties.tex/3.3 Energy transported.tex


\label{chp:bgm}
%\lipsum[101-120]
\section{The Building Game as a Mathematical Framework for Self-assembly}

The Building Game was first introduced by Wales~\cite{Wales1987} as a model for the formation of closo-boranes. Zlotnick subsequently altered the Building Game and used it as a model for the assembly of polyhedral viral capsids~\cite{Zlotnick1994}. In the model, a capsid is idealized as a polyhedron with each face treated as a subunit. Assembly proceeds from a single face with a second face attached to the first along an edge. At each subsequent step of the process, an additional face is added along an edge of one of the already added faces. The process ends when all of the faces have been added resulting in a completed polyhedron.

A useful way to think about the Building Game is as a sequential coloring process. Given a polyhedron with each face painted white, choose a face and paint it black. At each subsequent step, choose a white face that is adjacent to a black face and paint it black. Repeat until all faces are black. Here the black faces represent a face being present at a given step of the assembly process.

%--Comparison with approaches in artificial life paper

\section{Formal Definition}
We formalize the Building Game in terms of the group action of the polyhedron's rotation group $G$ acting on subsets of $F$, the polyhedron's face set. Using the polyhedron's dual graph $\PolyGraph\left(F, E\right)$ whose nodes are the faces $F$ of the polyhedron and connections $E$ correspond to the pairs of faces sharing an edge we can define the mathematical structures that comprise different Building Game configurations.

%If we are interested in the Building Game of a polyhedron, we represent the its combinatorial structure by a graph $\PolyGraph = \left(F, E\right)$ whose nodes are the faces $F$ of the polyhedron and connections $E$ correspond to the pairs of faces sharing an edge. In this way, $\PolyGraph$ can be viewed as the polyhedral graph of \poly's dual polyhedron.

\begin{mydef}
  A Building Game \textbf{state} $x \subset F$ is a non-empty subset of the faces $F$ of a polyhedron such that the sub-graph of $\PolyGraph$ restricted to $x$, $\PolyGraph|_x$, is a single connected component. As a result, every state can be formed through the Building Game attachment process.
\end{mydef}

Schlegel diagrams are two dimensional projections of the three dimensional polyhedron~\cite{Sommerville1929}. By coloring different subsets of faces, it is often useful to depict Building Game states with Schlegel diagrams.  Figure~\ref{fig:TetraStates} uses Schlegel diagrams to depict all of the states of the tetrahedron. Since every face of the tetrahedron is adjacent to every other face, any non-empty subset of faces is a Building Game state. Thus, there are ${4 \choose k}$ tetrahedron states that have $k$ faces and $2^4 - 1 = 15$ states in total.
\begin{figure}[ht]
\centering
  %\includegraphics[scale=0.1, angle=0]{tetrahedron_states.eps}
  %\includegraphics[scale=0.5, angle=0]{tetrahedron_states_2.eps}
  \includegraphics[scale=0.04, angle=0]{tetrahedron_states.eps}
\caption{The Building Game states of the tetrahedron.}
\label{fig:TetraStates}
\end{figure}
As pictured in figure~\ref{fig:OctaStates}, some subsets of faces are not states. For instance, the subset of octahedron faces with only two faces that are not adjacent is not a state. Similarly, the subset of two faces meeting only at a vertex is not a state as they are not connected through edge adjacency in the graph $\PolyGraph$. However, when more faces are added to connect these faces in $\PolyGraph$ the subset is indeed a state.

\begin{figure}[ht]
        \centering
  \includegraphics[scale=0.1, angle=0]{octa_state_yes.eps}
\caption{Examples of octahedron states.}
  \includegraphics[scale=0.1, angle=0]{octa_state_no.eps}
\caption{Examples of octahedron non-states.}
\label{fig:OctaStates}
\end{figure}

%as a sequential graph labeling process. If we are interested in the BG of a polyhedron \poly, we represent \poly\spc by a graph $\PolyGraph = \left(F, E\right)$ whose nodes are the faces $F$ of \poly\spc and connections $E$ correspond to the pairs of faces sharing an edge of \poly. In this way, $\PolyGraph$ can be viewed as the polyhedral graph of \poly's dual polyhedron.

%In Zlotnick's usage of the model, the labeling of $1$ or $0$ to each face would correspond to whether the face had been attached at some point up to the current step of the process.

%--More describing fig and what is and is not an intermediate.

%The corresponding $\PolyGraph$ representation is the octahedral graph with 6 vertices and 12 edges. In this example, the state represented labels three faces with a 1 and the others with 0. The embedded geometric interpretation shows three square faces connected along their edges.

%\begin{figure}[ht]
%  \includegraphics[scale=0.1, angle=0]{fig_2_1.eps}
%\caption{The cube and its graph representation.}
%\label{fig:OctaStates}
%\end{figure}

%\begin{mydef}
%The Building Game \textbf{rotation group} $\G$ is the permutation group acting on $F$ that corresponds to \poly's rotational symmetry group.
%\end{mydef}

\subsection{Group Actions}

It is easy to see that many states are combinatorially equivalent and are just rotations of each other. As in Endres et al., we group the states into sets that are rotations of each other~\cite{Endres2005}. However, to do so, we must first build the mathematical infrastructure using group actions.

\begin{mydef}%[~\cite{Rotman1995}]
A \textbf{group action} of a group $G$ on a set $X$ is a function mapping $G \times X$ to $X$ with $(g, x) \mapsto g.x$ that satisfies: (i) $(gh).x = g.(h.x)$ for $g,h \in G$ and (ii) $e.x = x$ for $e$ the identity element of $G$~\cite{Rotman1995}.
\end{mydef}

We typically use a polyhedron's rotation group or one of its subgroups as $G$ and $2^F$, the set of subsets of $F$, as the set $X$ that $G$ acts on. In this case, the action $g.x$ permutes the faces of the polyhedron according to the element $g$ of the rotation group and results in a new subset of faces. Here, we introduce the concepts of orbits and stabilizer subgroups as they play an important role in our later analyses.
\begin{mydef}%[~\cite{Rotman1995}]
Let $G$ be a group acting on a set $X$, the \textbf{orbit} of an element $x \in X$ is the subset $G.x \doteq \left\{g.x : g \in G \right\}$ of $X$~\cite{Rotman1995}.
\end{mydef}
We also use the shorthand notation $[x]$ to refer to the orbit $G.x$ since an orbit can be thought of as an equivalence class under the relation $x \sim \hat{x}$ if there is a $g \in G$ such that $x = g.\hat{x}$.
\begin{mydef}%[~\cite{Rotman1995}]
For a  group $G$ acting on a set $X$, the \textbf{stabilizer subgroup} for an element $x\in X$ is the subgroup $G_x \doteq \left\{g \in \G :g. x = x \right\}$ of $G$ that fixes $x$~\cite{Rotman1995}.
\end{mydef}
Now, we introduce three classical results of group actions that relate orbits and stabilizer subgroups and add a corollary that we will use frequently.
\begin{mythm}[Orbit-Stabilizer~\cite{Rotman1995}]
Let $G$ be a group acting on a set $X$, then for any $x \in X, |G.x| = [G:G_x]$, the number of left-cosets of $G_x$.
\end{mythm}
\begin{mythm}[Lagrange~\cite{Rotman1995}]
If $G$ is a finite group and $S \leq G$, then $|S|$ divides $|G|$ and $[G:S] = |G|/|S|$
\end{mythm}
\begin{mylem}[Burnside~\cite{Rotman1995}]
Let $G$ be a finite group acting on a set $X$, then $$|X/G| = \frac{1}{|G|}\sum_{g \in G}|X^g|$$ where $|X/G|$ is the number of orbits and $|X^g| = \{x \in X : g.x = x\}$
\end{mylem}

\begin{mycor}
\label{cor:OST}
Let $G$ be a finite group acting on a set $X$, then for any $x \in X$ $$|G.x| = \frac{|G|}{|G_x|}.$$
\end{mycor}
\begin{proof}
This result follows trivially from the Orbit-Stabilizer and Lagrange's theorems.
\end{proof}

\subsection{Building Game Intermediates}

With this framework of group actions, we now formally define the principal unit of the Building Game.
\begin{mydef}
A Building Game \textbf{intermediate} $[x] \doteq \left\{g.x : g \in G\right\}$ is the orbit of the state $x$ under the polyhedra's rotation group.
\end{mydef}
Since the orbits of a group action form a partition on the set it acts on, each state belongs to a single intermediate and two states $x$ and $y$ are part of the same intermediate if there is a $g\in\G$ such that $y = g.x$. In the case of the tetrahedron, as pictured in figure~\ref{fig:TetraStates}, there are only four intermediates since any state with the same number of faces can be rotated to reach the others.

%\begin{mylem}
%\label{lem:GyhGxh}
%Let $x, y \in \left[x\right]$ such that $y = h.x$ for some $h \in G$. Then, $G_y = hG_xh^{-1}$.
%\end{mylem}
%\begin{proof}
%Since $G$ is normal to itself, we have $G = h^{-1}Gh = hGh^{-1}$.
%\begin{align}
%  hG_xh^{-1} &= \left\{hgh^{-1} : g \in G_x \right\} \\
%  &= \left\{hgh^{-1} : g.x = x, g \in G\right\} \\
%  \intertext{Use the transformation $\hat{g} = hgh^{-1}$.}
%  &= \left\{\hat{g} : h^{-1}\hat{g}h.x = x, \hat{g} \in hGh^{-1} \right\} \\
%  &= \left\{\hat{g} : \hat{g}.(h.x) = h.x, \hat{g} \in G \right\} \\
%  &= \left\{\hat{g} : \hat{g}.y = y, \hat{g} \in G \right\} \\
%  &= G_y
%\end{align}
%\end{proof}

Since we have defined the intermediates to be the orbits of states under the polyhedral group, we are naturally also interested in stabilizer subgroups of Building Games states.
\begin{mydef}
The \textbf{symmetry number} $r_{x^j}$ (or simply $r_j$) of a state $x^j$ is the order of its stabilizer subgroup $\left|\G_{x^j}\right|$.
\end{mydef}
In figure~\ref{fig:OctaStabs} we see three states and their orbit stabilizer subgroups. The first state, with only a single face, has a symmetry number of $3$ since any rotation by a multiple of $\frac{2\pi}{3}$ fixes the face. The second has a symmetry number of $2$ since only the identity and a rotation by $\pi$ will fix the faces. The final state, with three faces, cannot be fixed by any rotation other than the identity and thus has symmetry number $1$.
\begin{figure}[ht]
        \centering
  \includegraphics[scale=0.08, angle=0]{octa_stabilizers.eps}
\caption{The stabilizer subgroups for various octahedron states.}
\label{fig:OctaStabs}
\end{figure}

\begin{mythm}
If the states $x$ and $\hat{x}$ are members of the same intermediate $\left[x\right]$, they have the same symmetry number. Thus, we extend the notion of a symmetry number to be a property of an intermediate.
\end{mythm}
\begin{proof}
By Corollary~\ref{cor:OST} and since $G.x \doteq [x] = [\hat{x}] \doteq G.\hat{x}$, the result follows.
\begin{align}
  r_x &= |G_x| \\
  &= \frac{|G|}{|G.x|} \\
  &= \frac{|G|}{|G.\hat{x}|} \\
  &= |G_{\hat{x}}| \\
  &= r_{\hat{x}}
\end{align}
\end{proof}

%\begin{figure}[ht]
%\caption{The eight states in a particular BG intermediate.}
%\label{fig:CubeState}
%\end{figure}

%For ease of exposition, we use the notational shorthand $\left(x\right)_m$ for $x\left(f_m\right)$ and $x = g.x'$ when $x(f_m) = x'(g.f_m)$ for every $f_m \in F(\mathscr{P})$. Additionally, we denote the intermediate satisfying $\left(x\right)_m = \colorA$ for all $f_m \in \faceset$ as $x^\colorAsm$ and similarly $x^\colorBsm$ is the intermediate with $\left(x\right)_m = \colorB$ for all $f_m \in \faceset$. The function counting the number of \colorB\spc faces an intermediate has is denoted $h\left(x\right) \doteq |\left\{f_m \in \faceset : \left(x\right)_m = \colorB\right\}|$.

Since the Building Game is at its core an attachment model, we are interested in which intermediates can be formed from others by attaching a face to a particular intermediate.
\begin{mydef}
Two distinct intermediates $\left[x\right]$ and $\left[y\right]$ are \textbf{connected} if there exist states $x \in \left[x\right]$ and $y \in \left[y\right]$ such that one of the following holds:
\begin{itemize}
 \item there is a face, $f$, in the state $y$ such that $y = x \cup \left\{f\right\}$
 \item there is a face, $f$, in the state $x$ such that $x = y \cup \left\{f\right\}$
\end{itemize}
\end{mydef}

\begin{mylem}
If intermediates $\left[x\right]$ and $\left[y\right]$ are connected, then for every state $x \in \left[x\right]$ there is a state $y \in \left[y\right]$ such that $\exists f \in y: y = x \cup \left\{f\right\}$ or $\exists f \in x: x = y \cup \left\{f\right\}$.
\end{mylem}
\begin{proof}
  Without loss of generality, assume $|x| < |y|$. Since $[x]$ and $[y]$ are connected, let $\hat{x} \in [x]$, $\hat{y} \in [y]$, and $\hat{f} \in \hat{y}$, be such that $\hat{y} = \hat{x}\cup\{\hat{f}\}$. Then, for any $x \in [x]$, pick $g \in G$ such that $x = g.\hat{x}$. By choosing $y = g.\hat{y}$ and $\{f\} = g.\{\hat{f}\}$, we have
\begin{align}
  y &= g.\hat{y} \\
  &= g.(\hat{x}\cup\{\hat{f}\}) \\
  &= g.\hat{x}\cup g.\{\hat{f}\} \\
  &= x \cup \{f\} \\
\end{align}
and our result is shown.
\end{proof}

\begin{mydef}
A Building Game \textbf{pathway} is a sequence of intermediates $[x^{p_1}], [x^{p_2}], \dots, [x^{p_N}]$ such that  $[x^{p_i}]$ is connected to $[x^{p_{i+1}}]$, $|x^{p_i}| = i$, and $x^{p_N} = F$.
\end{mydef}

 Figure~\ref{fig:OctaPath} shows a Building Game pathway for the octahedron using Schlegel diagrams. The pathway has $8$ intermediates since there must be exactly one intermediate $x^{p_i}$ satisfying $h\left(x^{p_i}\right) = i$ for each $i = 1,2,\dots,8$.

\begin{figure}[ht]
\centering
\includegraphics[scale=0.065, angle=0]{octa_path.eps}
\caption{One Building Game pathway for the Octahedron.}
\label{fig:OctaPath}
\end{figure}

\begin{mydef}
The Building Game \textbf{combinatorial configuration space} for a polyhedron is a graph in which the nodes are the polyhedron's intermediates and a graph edge exists between two intermediates if and only if they are connected.
\end{mydef}

When the intermediates are partitioned by the number of faces they possess, it is natural to arrange the combinatorial configuration space into columns or tiers according to this partition. Figure~\ref{fig:CubeCCS} shows the Building Game state space for the cube. As seen, each column has intermediates with the same number of faces and connections thus exist with intermediates that are either in the tier directly above or below them. We can also see that there are three distinct pathways contained in the state space.

\begin{figure}[ht]
\centering
\includegraphics[scale=0.2, angle=0]{cube_ccs.eps}
\caption{The Building Game combinatorial configuration space of the cube.}
\label{fig:CubeCCS}
\end{figure}

Interestingly, it is not the case that the addition or removal of each face of an intermediate results in a distinct intermediate.
\begin{mydef}
For two connected intermediates $[x^j]$ and $[x^k]$, the set of different faces $$F_{jk} \doteq \left\{f \notin x^j : x^j\cup\{f\} \in [x^k]\right\}\cup\left\{f \in x^j : x^j\setminus\{f\} \in [x^k]\right\}$$ that can be added or removed from $x^j$ to get an element of $[x^k]$ is called the \textbf{degeneracy set} and the number of such faces $S_{jk} \doteq \left|F_{jk}\right|$ is called the \textbf{degeneracy number}.
\end{mydef}

The act of attaching an additional face is referred to as a forward step in the Building Game and the removal of a face is a backward step. As such, degeneracies are sometimes referred to as forward or backward degeneracies. It is important to note that in general the degeneracy number is not symmetric, i.e. \Sjk$\neq$\Skj\spc for some connections $[x^j] \leftrightarrow [x^k]$ in the state space. Figure~\ref{fig:CubeDegen} depicts the forward and backward degeneracy numbers for a particular connection. As illustrated, there are four faces that can be added to the first intermediate to form the second. However, removing any of the two faces of the second intermediate will result in the first. Thus the forward degeneracy number is four and the backward degeneracy number is two.

\begin{figure}[ht]
\centering
\includegraphics[scale=0.17, angle=0]{cube_degens.eps}
\caption{Degeneracies between two connected cube intermediates.}
\label{fig:CubeDegen}
\end{figure}

Finally, we extend the notion of a pathway to to be a sequence of intermediates of arbitrary lengths, such that the sequence begins at an intermediate with a single face and ends with the completed polyhedron and each pair of successive intermediates are connected.
\begin{mydef}
A Building Game \textbf{reversible pathway} is a sequence of intermediates $[x^{p_1}], [x^{p_2}], \dots, [x^{p_N}]$ such that  $[x^{p_i}]$ is connected to $[x^{p_{i+1}}]$, $|x^{p_0}| = 1$, and $|x^{p_N}| = |F|$.
\end{mydef}

%\begin{mythm}
%  For two connected intermediates $[x^j]$ and $[x^k]$, the degeracy numbers $S_{jk}$ and $S_{kj}$ are that same as the cardinality of $G_{x^j}.\{f\}$ and $G_{x^k}.\{f\}$ for $x^j \in [x^j], x^k \in [x^k], f \in F$ satisfying $x^k = x^j \cup \{f\}$.
%\end{mythm}
%\begin{proof}
%
%First we argue the case of $S_{jk}$ by showing that $G_x^j.\{f\} = \{\hat{f} \in F : x \cup \{\hat{f}\} \in [y]\}$.
%
%Assume $\{\hat{f}\} \in G_{x^j}.\{f\}$. Thus, there is a $g \in G$ such that $g.x = x$ and $g.\{f\} = \{\hat{f}\}$. It follows that
%\begin{align}
%x \cup \{\hat{f}\} &= (g.x)\cup (g.\{f\}) \\
%&= g.(x\cup\{f\}) \\
%&= g.y \in [y].
%\end{align}
%Thus $G_x^j.\{f\} \subset \{\hat{f} \in F : x \cup \{\hat{f}\} \in [y]\}$
%
%Now we assume $\bar{f} \in F$ with $x \cup \{\bar{f}\} \in [y]$ and argue that $\bar{f} \in G_{x^j}.\{f\}$. By lemma XXX we know there is a $h \in G_{x^j}$ such that $x^j \cup \{\bar{f}\} = h.x^k$. It follows that
%\begin{align}
%x^j \cup \{\bar{f}\} &= h.x^k \\
%&= h.(x^j \cup \{f\}) \\
%&= h.x^j \cup h.\{f\}) \\
%&= x^j \cup h.\{f\}) \\
%\end{align}
%and thus $\{\bar{f}\} = h.\{f\}$. This means that $\bar{f} \in G_{x^j}.\{f\}$ and $\{\hat{f} \in F : x \cup \{\hat{f}\} \in [y]\} \subset G_x^j.\{f\}$.
%
%We have shown that $G_x^j.\{f\} = \{\hat{f} \in F : x \cup \{\hat{f}\} \in [y]\}$ and consequently that $S_{jk} = |G_{x^j}.\{f\}|$. The proof for $S_{kj}$ follows similarly.
%\end{proof}

\subsection{Group Theoretic Results}

%Since we define Building Game intermediates as rotationally unique from each other, it is useful to think about the problem in the context of $\mathscr{P}$'s rotational symmetry group $G \doteq G\left(\mathscr{P}\right)$ and group actions. For an intermediate $x^j$, the number of symmetries $r_j$ is the order of the stabilizer subgroup $G_{x^j} \doteq \left\{g \in G : g.x^j = x^j\right\}$ of $G$ that fixes $x^j$.
%Suppose $x^j$ and $x^k$ are connected in the state space and $\varphi$ is one of the $S_{jk}$ faces that, when added to $x^j$, forms $x^k$. We say $x^j + \varphi = x^k$. The degeneracy number $S_{jk}$ can then be expressed as the order of the orbit $\left(G_{x^j}\right).\varphi$ of $\varphi$ with respect to $x^j$'s stabilizer subgroup. Analogously, we define the reverse degeneracy number as $S_{kj} \doteq \left|\left(G_{x^k}\right).\varphi\right|$

\begin{mylem}
Let $g \in G$ and $x,y \subset F$. Then $g.(x\cup y) = g.x \cup g.y$
\end{mylem}
\begin{proof}
Let $f \in g.(x\cup y)$. Then $g^{-1}.\{f\} \in x \cup y$. Without loss of generality, assume $g^{-1}.\{f\} \in x$. It follows that $f \in g.x$ and $f \in g.x \cup g.y$ as well. Therefore, $g.(x\cup y) \subset g.x \cup g.y$.

Conversely, suppose $\hat{f} \in g.x \cup g.y$ and without loss pick $\hat{f}$ to be in $g.x$. It follows that $g^{-1}.\{\hat{f}\} \in x, x \cup y$ and subsequently $\hat{f} \in g.(x \cup y)$. From this we have the reverse relation $g.x \cup g.y \subset g.(x\cup y)$ which proves our equality.
\end{proof}

%\begin{mylem}
%\label{lem:TwoIntFix}
%Let the Building Game intermediates $[x^j]$ and $[x^k]$ be connected in the combinatorial configuration space. Given $x^j \in [x^j]$, $x^k \in [x^k]$ and $f \in F$ such that $x^k = x^j \cup \left\{f\right\}$, the stabilizer subgroups $G_{x^j,\{f\}} = G_{x^k,\{f\}} = G_{x^j,x^k}$ are all equal.
%\end{mylem}
%\begin{proof}
%\begin{align}
%G_{x^k,\{f\}} &= \left\{g \in G : g.x^k = x^k, g.\{f\} = \{f\} \right\} \\
%           &= \left\{g \in G : g.(x^j \cup \{f\}) = x^j \cup \{f\}, g.\{f\} = \{f\} \right\} \\
%           &= \left\{g \in G : g.x^j \cup g.\{f\} = x^j \cup \{f\}, g.\{f\} = \{f\} \right\} \\
%           &= \left\{g \in G : g.x^j \cup \{f\} = x^j \cup \{f\}, g.\{f\} = \{f\} \right\} \\
%           &= \left\{g \in G : g.x^j  = x^j, g.\{f\} = \{f\} \right\} \\
%           &= G_{x^j,\{f\}} \\
%&= \left\{g \in G : g.x^j  = x^j, g.\{f\} = \{f\} \right\} \\
%&= \left\{g \in G : g.x^j  = x^j, g.x^j \cup g.\{f\} = x^j \cup \{f\} \right\} \\
%&= \left\{g \in G : g.x^j  = x^j, g.(x^j \cup \{f\}) = x^j \cup \{f\} \right\} \\
%&= \left\{g \in G : g.x^j  = x^j, g.x^k = x^k \right\} \\
%&= G_{x^j,x^k}
%\end{align}
%\end{proof}
%
%
%
%\begin{mylem}
%\label{lem:GG}
%For connected intermediates $[x]$ and $[y]$, with $x \cup \{f\} = y$ and $x \cup \{\hat{f}\} \doteq \hat{y}\in [y]$, the stabilizer subgroups $|G_{x,y}|$ and  $|G_{x,\hat{y}}|$ satisfy $|G_{x,y}| = |G_{x,\hat{y}}|$.
%\end{mylem}
%\begin{proof}
%If there is an $h \in G_x$ such that $\{f\} = h.\{\hat{f}\}$, the result follows similar to lemma XXX as $|G_{x,y}| = |hG_{x,\hat{y}}h^{-1}| = |G_{x,\hat{y}}|$.
%
%However, if $\{f\} \neq h.\{\hat{f}\}$ for every $h \in G_x$, the result STILL NEEDS PROOF. In the cases we consider, the lemma has been confirmed to be true through brute force computation.
%
%%--use the fact that such subgroups fix f, so they must be cycles generated by single rotation. --show that if rotation of f by that single element produces [y] then that same rotation of f-hat will too.
%\end{proof}
%
%
%
%\begin{mylem}
%\label{lem:FmodG}
%Let the Building Game intermediates $[x^j]$ and $[x^k]$ be connected in the combinatorial configuration space, the number of orbits $|F_{jk}/G_{x^j}| = |F_{kj}/G_{x^k}|$.
%\end{mylem}
%\begin{proof}
%Let $G_{x^j}.\{f\} \in F_{jk}/G_{x^j}$. Then, since $f \in F_{jk}$ we know that $x^j\cup\{f\} \in [x^k]$ and thus there is a $g \in G$ such that $g.(x^j\cup\{f\}) = x^k$. Since $g.x^j \in [x^j]$, we know that $g.\{f\} \in F_{kj}$. Then, for any $h \in G_{x^k}$ we see that $hg.(x^j\cup\{f\}) = h.x^k = x^k$. This means that $G_{x^k}.(g.\{f\}) \in F_{kj}/G_{x^k}$.
%
%Now, we similarly assume $G_{x^k}.\{\hat{f}\} \in F_{kj}/G_{x^k}$. Then, $x^k \setminus \{\hat{f}\} \in [x^j]$ and there is a $\hat{g} \in G$ such that $\hat{g}.(x^k \setminus \{\hat{f}\}) = x^j$. Therefore, $\hat{g}.\{\hat{f}\} \in F_{jk}$ as $\hat{g}.x^k \in [x^k]$. So, for every $\hat{h} \in G_{x^j}$ we get $\hat{h}\hat{g}.(x^k\setminus\{\hat{f}\}) = \hat{h}.x^j = x^j$. Thus $G_{x^j}.(\hat{g}.\{\hat{f}\}) \in F_{jk}/G_{x^j}$.
%
%Since we have shown that for every orbit in $F_{jk}/G_{x^j}$ there is a corresponding orbit in $F_{kj}/G_{x^k}|$ and vice versa, the total number of orbits in each set must be the same and our result $|F_{jk}/G_{x^j}| = |F_{kj}/G_{x^k}|$ holds.
%\end{proof}
%

\begin{mythm}
\label{thm:rSrS}
Let $[x^j]$ and $[x^k]$ be two Building Game intermediates connected in the combinatorial configuration space. If $r_j$ and $r_k$ are the intermediates' symmetry numbers and $S_{jk}$ and $S_{kj}$ are the forward and backward degeneracy numbers, then $r_kS_{jk} = r_jS_{kj}$.
\end{mythm}
\begin{proof}

%Without loss of generality, assume that $[x^j]$ has one fewer face than $[x^k]$ and pick $x^j \in [x^j]$, $x^k \in [x^k]$ and $f \in F$ such that $x^k = x^j \cup \left\{f\right\}$. Then by Burnside lemma, we have the following~\cite{Rotman1995}.
%\begin{align}
%\left|F_{jk} / G_{x^j}\right| &= \frac{1}{|G_{x^j}|}\sum_{g \in G_{x^j}}|(F_{jk})^g| \\
%&= \frac{1}{|G_{x^j}|}\sum_{\hat{f} \in F_{jk}}|G_{x^j,\{\hat{f}\}}| \\
%&= \frac{|G_{x^j,\{f\}}|}{r_j}\sum_{\hat{f} \in F_{jk}}1 \\
%&= \frac{|G_{x^j,\{f\}}|S_{jk}}{r_j}
%\end{align}
%Then, by lemmas~\ref{lem:GG} and~\ref{lem:FmodG} we have,
%\begin{align}
%\frac{r_j}{S_{jk}} &= \frac{|G_{x^j,\{f\}}|}{\left|F_{jk} / G_{x^j}\right|} \\
%&= \frac{|G_{x^k,\{f\}}|}{\left|F_{kj} / G_{x^k}\right|} \\
%&\doteq \frac{r_k}{S_{kj}}
%\end{align}
%and the result $r_kS_{jk} = r_jS_{kj}$ follows.
%

% Then, by the orbit-stabilizer theorem, Lagrange's Theorem and lemma~\ref{lem:I} we have the following~\cite{Rotman1995}.
%\begin{align}
%\frac{r_j}{S_{jk}} &\doteq \frac{\left|G_{x^j}\right|}{\left|\left(G_{x^j}\right).\{f\}\right|} \\
%                   &= \left[G_{x^j} : \left(G_{x^j}\right).\{f\} \right] \\
%                   &= \left|G_{x^j,\{f\}}\right| \\
%                   &= \left|G_{x^k,\{f\}}\right| \\
%                   &= \left[G_{x^k} : \left(G_{x^k}\right).\{f\} \right] \\
%                   &= \frac{\left|G_{x^k}\right|}{\left|\left(G_{x^k}\right).\{f\}y\right|} \\
%                   &\doteq \frac{r_k}{S_{kj}}
%\end{align}
%The result $r_kS_{jk} = r_jS_{kj}$ follows.

We prove the result by arguing the following three equalities.

\begin{align}
\label{eq:rS1}
r_kS_{jk} &= |\{(f,g) \in F \times G : x^j \cup \{f\} = g.x^k\}| &= \sum_{f \in F} |\{g \in G : x^j \cup \{f\} = g.x^k \}| \\
\label{eq:rS2}
&= |\{(f,g) \in F \times G : x^k \setminus \{f\} = g.x^j\}| &= \sum_{f \in F} |\{g \in G : x^k \setminus \{f\} = g.x^j \}| \\
\label{eq:rS3}
&= r_jS_{kj}
\end{align}

First, equality~\ref{eq:rS1} is shown as follows.
\begin{align}
|\{(f,g) \in F \times G : x^j \cup \{f\} = g.x^k\}| &= \sum_{f \in F} |\{g \in G : x^j \cup \{f\} = g.x^k \}| \\
\label{eq:rS4}
&= \sum_{f \in F^{jk}} |\{g \in G : x^j \cup \{f\} = g.x^k \}| \\
\label{eq:rS5}
&= \sum_{f \in F^{jk}} |\{g \in G : h^{(f)}.x^k = g.x^k \}| \\
&= \sum_{f \in F^{jk}} |\{g \in G : g^{-1}h^{(f)}.x^k = x^k \}| \\
\label{eq:rS6}
&= \sum_{f \in F^{jk}} |\{\tilde{g} \in G : \tilde{g}.x^k = x^k \}| \\
&= \sum_{f \in F^{jk}} |G_y| \\
&= r_kS_{jk}
\end{align}
This sum in~\ref{eq:rS4} is reduced to be only over $f \in F^{jk}$ since the inner condition means that $x^j \cup \{f\} \in [x^k]$ and thus $f \in F^{jk}$. Since  $x^j \cup \{f\} \in [x^k]$, in~\ref{eq:rS5} there is a $h^{(f)} \in G$ such that $x^j \cup \{f\} = h^{(f)}.x^k$. Here the $(f)$ superscript just denotes dependence on the particular $f$ in the sum. Equation~\ref{eq:rS6} reindexes $G$ using $\tilde{g} = g^{-1}h^{(f)}$ since this still represents all elements in $G$.

Arguing similarly, we prove equality~\ref{eq:rS3}.
\begin{align}
|\{(f,g) \in F \times G : x^k \setminus \{f\} = g.x^j\}| &= \sum_{f \in F} |\{g \in G : x^k \setminus \{f\} = g.x^j \}| \\
&= \sum_{f \in F^{kj}} |\{g \in G : x^k \setminus \{f\} = g.x^j \}| \\
&= \sum_{f \in F^{kj}} |\{g \in G : h^{(f)}.x^j = g.x^j \}| \\
&= \sum_{f \in F^{kj}} |\{g \in G : g^{-1}h^{(f)}.x^j = x^j \}| \\
&= \sum_{f \in F^{kj}} |\{\tilde{g} \in G : \tilde{g}.x^j = x^j \}| \\
&= \sum_{f \in F^{kj}} |G_{x^j}| \\
&= r_jS_{kj}
\end{align}
It only remains to prove equality~\ref{eq:rS2}.
\begin{align}
|\{(f,g) \in F \times G : x^j \cup \{f\} = g.x^k\}| &= \sum_{g \in G} |\{f \in F : x^j \cup \{f\} = g.x^k \}| \\
&= \sum_{g \in G} |\{f \in F : g^{-1}.x^j \cup g^{-1}.\{f\} = x^k \}| \\
&= \sum_{g \in G} |\{f \in F : g^{-1}.x^j  = x^k \setminus g^{-1}.\{f\} \}| \\
&= \sum_{g \in G} |\{\hat{f} \in F : g^{-1}.x^j  = x^k \setminus \{\hat{f}\} \}| \\
&= |\{(\hat{f},g) \in F \times G : x^k \setminus \{\hat{f}\} = g^{-1}.x^j\}| \\
&= \sum_{\hat{f} \in F}|\{g \in G : x^k \setminus \{\hat{f}\} = g^{-1}.x^j\}| \\
&= \sum_{\hat{f} \in F}|\{\hat{g} \in G : x^k \setminus \{\hat{f}\} = \hat{g}.x^j\}| \\
&= |\{(f,g) \in F \times G : x^k \setminus \{f\} = g.x^j\}|
\end{align}
\end{proof}

\section{Stochastic Modeling Results}
\label{sec:StochMod}

Since the Building Game is a sequential process with several choices at each step, it is natural to consider it as a stochastic process. If we define a Building Game process that allows faces to be sequentially added or removed in a reversible way, the process consists of transitions from intermediate to intermediate along connections in the combinatorial configuration space. By specifying a distribution on these transitions, it will induce a stationary distribution on the state space and provide a framework for compute relevant statistics such as expected formation times.

%By putting a distribution on all possible faces that can be added at each step of the Building Game, a distribution on the space of pathways is implicitly defined. Thus, for a choice of this transition rule, we can ask questions about the likelihood of the different pathways. Analogously, if we allow the process to be reverseable, with a transition rule at each step assigning probabilities to both

%--Math and graphical results about putting a distribution on pathways

We define the Markov process $X_t$ by the transition rate matrix $Q$ from equation~\ref{eq:Qdef}, with the heuristic that the rate of transition to an intermediate $[x^k]$ from an intermediate $[x^j]$ should be proportional to the number of faces that can be added or removed from $[x^j]$ to reach $[x^k]$. For this reason, we include the degeneracy number $S_{jk}$ as a factor in the transition rate matrix. Furthermore, we model the process using an energetic interpretation in which each intermediate has an energy and to transition between intermediates, an energy barrier $E_{jk} = E_{kj}$ must be overcome.
%\begin{align}
%\label{eq:TransitionProbability}
% P_{jk} = \frac{1}{z_j}S_{jk}\rh
%\end{align}
%\begin{align}
%\label{eq:TransitionRate}
%\begin{align}
%$$Q_{jk} =
%\[
\begin{align}
  \label{eq:Qdef}
  Q_{jk} =
  \begin{cases}
   S_{jk}e^{-\beta\left(E_{jk} - E_{j}\right)} & \text{if } [x^j] \leftrightarrow [x^k]  \\
   -z_j       & \text{if } j = k \\
   0 & \text{else}
  \end{cases}
\end{align}
%\]
Here, $z_j \doteq \sum_{\ell: \ell \neq j} S_{j\ell}e^{-\beta\left(E_{j\ell} - E_j\right)}$ is the rate at which the process leaves \xj.

Both~\cite{Keef2006} and~\cite{Endres2005} adopt a similar approach, but handle degeneracies differently and use a different energy function.

\subsection{Stationary Distribution}

\begin{mythm}
\label{thm:StatDist}
Let $D$ be a diagonal matrix with positive entries and $C$ be a symmetric matrix with $C_{jk} > 0$ for connected intermediates and $C_{jk} = 0$ for unconnected intermediates. If a transition rate matrix can be factorized as $Q = DC$, then $X_t$ has the unique stationary distribution $\pi = \diag\left(D^{-1}\right)$.
\end{mythm}
\begin{proof}
First, we show $Q$ and $\pi$ satisfy detailed balance.
\begin{align}
\pi_jQ_{jk} &= \left(\frac{1}{D_{jj}}\right)\left(D_{jj}C_{jk}\right) \\
&= C_{jk} \\
&= C_{kj} \\
&= \left(\frac{1}{D_{kk}}\right)\left(D_{kk}C_{kj}\right) \\
                    &= \pi_kQ_{kj}
\end{align}
Now, since the combinatorial state space is connected and $Q_{jk}, Q_{kj} > 0$ for all connected intermediates $[x^j]$ and $[x^k]$, the process is clearly aperiodic and positive recurrent. Thus, $\pi$ is the unique stationary distribution of the Markov process~\cite{Norris1998}.
\end{proof}

\begin{mythm}
\label{thm:E}
The Markov process $X_t$ defined by the transition rate matrix  $Q$ in equation~\ref{eq:Qdef} admits the unique stationary distribution $\frac{1}{Zr_j}e^{-\beta E_j}$ where $Z \doteq \sum_\ell \frac{1}{r_\ell}e^{-\beta E_\ell}$ is the partition function.
\end{mythm}
\begin{proof}
We take $C_{jk} \doteq \frac{S_{jk}}{Zr_j}e^{-\beta E_{jk}}$ and notice that it is symmetric by theorem~\ref{thm:rSrS}. With $D_{jj} \doteq Zr_je^{\beta E_j}$ we have our factorization
\begin{align}
Q_{jk} &= S_{jk}e^{-\beta\left(E_{jk} - E_j\right)} \\
       &= \left(Zr_je^{\beta E_j}\right) \left(\frac{S_{jk}}{Zr_j}e^{-\beta E_{jk}}\right) \\
       &= D_{jj}C_{jk}.
\end{align}
Thus, by theorem~\ref{thm:StatDist},  $\pi_j = \frac{1}{D_{jj}} = \frac{1}{Zr_j}e^{-\beta E_j}$.
\end{proof}

%In order to use theorem~\ref{thm:StatDist} to find the stationary distribution for the transition rule~\ref{eq:TransitionProbability}, we must be able to decompose the degeneracy number \Sjk\spc to fit the template of $\mathbf{C}$ and $\mathbf{D}$. In the following section we derive group theoretic identities to show that this is possible.

\subsection{Hitting Times}

While the stationary distribution is an important piece in understanding the nature of our Markov process, other statistics which describe the dynamics are also useful. For instance, we may be interested in the expected time it will take the process to travel from an intermediate $[x^j]$ to a specific subset $A$ of the combinatorial configuration space. Equation~\ref{eq:taudef} provides a mathematical definition for such a stopping time.
\begin{align}
  \label{eq:taudef}
	\tau^{A}_{j} &\doteq \inf\left\{t \geq 0 : X_t \in A, X_0 = x^j\right\}
\end{align}
Often, we choose $A$ to be the intermediate of the fully completed polyhedron. This means the the stopping time will represent the expected formation time from a given intermediate.

To assist in our calculations of hitting times, it is helpful to use $X_t$'s discrete time jump process $Y_n$. The jump process is simply a record of the sequence of intermediates that $X_t$ travels through. The discrete time Markov transition matrix associated with $Y_n$ is defined using $Q$.

\begin{align}
  \label{eq:Pdef}
  P_{jk} =
  \begin{cases}
   -Q_{jk}/Q_{jj} & \text{if } j \neq k  \\
   0  & \text{if } j = k
  \end{cases}
\end{align}
With this definition, the continuous time process $X_t$ has the alternative interpretation where the intermediate $X_t$ changes according to the jump process $Y_n$ and stays at each intermediate $[x^j]$ for an exponentially distributed amount of time with parameter $-Q_{jj}$~\cite{Norris1998}.
%
%Since we are looking at events in which the process first reaches a particular set of intermediates, it is helpful to use $X_t$'s discrete time jump process $Y_n$ which simply records the sequence of intermediates that $X_t$ passes through. Here we formally define $Y_n$ in a recursive manner, such that it is the first intermediate visited after the process $X_t$ leaves $Y_{n-1}$.
%\begin{align}
%  \label{eq:Ydef}
%	Y_n &\doteq \arg\min_{y \neq X_t}\{s : s > t, X_s = y, X_t = Y_{n-1}\} \\
%        &\sim X_{\tau_{Y_{n-1}}^{\{Y_{n-1}\}^C}}
%\end{align}
%
%\begin{align}
%	\nu^{A}_{j} &\doteq \inf\left\{n \geq 0 : Y_n \in A, Y_0 = x^j\right\}
%\end{align}

The expected hitting time $E\left[\tau_j^A\right]$ can be computed as the solution to se set of linear equations: one for each intermediate~\cite{Norris1998}. In the case of $j \not\in A$:
\begin{align}
%	E\left[\tau^{A}_{j}\right] &= E\left[E\left[\tau^{A}_{j} | Y_1 \right]\right] \\
%        &= E\left[ \frac{1}{Z_j} + \tau^{A}_{Y_1} \right] \\
%        &=  \frac{1}{Z_j} + E\left[\sum_{k}\tau^{A}_{Y_1}\mathbbm{1}_{Y_1 = k}\right] \\
%        &=  \frac{1}{Z_j} + \sum_{k: k\neq j}E\left[\tau^{A}_{k}\right] P\left(Y_1 = k\right) \\
%        &=  \frac{1}{Z_j}\left(1 + \sum_{k: k\neq j}Q_{jk}E\left[\tau^{A}_{k}\right]\right)     \\
  1 &=  -\sum_{k}Q_{jk}E\left[\tau^{A}_{k}\right],
\end{align}
and clearly for $j \in A$ we trivially have a stopping time of zero
\begin{align}
	E\left[\tau^{A}_{j}\right] &= 0.
\end{align}
Putting together the two cases, we write the solution as a linear system with $\tau^A$ the vector of stopping times with each possible initial intermediate
\begin{align}
	\left(\diag\left(\mathbbm{1}_A\right) - \diag\left(\mathbbm{1}_{A^c}\right)Q\right)E\left[\tau^{A}\right] =\mathbbm{1}_{A^c}.
\end{align}
Thus, we have
\begin{align}
	E\left[\tau^{A}\right] = \left[\left(\diag\left(\mathbbm{1}_A\right) - \diag\left(\mathbbm{1}_{A^c}\right)Q\right)\right]^{-1} \mathbbm{1}_{A^c}
\end{align}
which contains the particular value $E[\tau^A_j]$ that we are interested in.

Further, we can also compute the exact distribution of the stopping times $\tau^A$ in a similar manner~\cite{Norris1998}. First, we define the CDF as
\begin{align}
\psi_j^A\left(t\right) &\doteq P\left(\tau^A_j \leq t\right) \\
%\psi_j^A\left(0\right) &= \mathbbm{1}_{j\in A} \\
\end{align}
which gives rise to the system of differential equations and boundary conditions
%Thus, for the case of $j \not\in A$ we find
%\begin{align}
%\psi_j^A\left(t\right) &\doteq P\left(\tau^A_j \leq t\right) \\
%                       &= \sum_k P\left(\tau^A_j \leq t | Y_1 = x^k\right) P\left(Y_1 = x^k\right) \\
%                       &= \frac{1}{Z_j}\sum_{k: k \neq j} Q_{jk} P\left(Exp\left(Z_j\right) + \tau^A_k \leq t\right)  \\
%                       &= \frac{1}{Z_j}\sum_{k: k \neq j} Q_{jk} \int^t_0 P\left(\tau^A_k \leq t - s\right) Z_j e^{-Z_j s} ds  \\
%                       &= \sum_{k: k \neq j} Q_{jk} \int^t_0\psi^A_k\left(t-s\right)e^{-Z_j s} ds  \\
%                       &= \sum_{k: k \neq j} Q_{jk} \int^t_0\psi^A_k\left(r\right)e^{-Z_j\left(t-r\right)} dr  \\
%e^{Z_jt}\psi^A_j\left(t\right) &= \sum_{k: k \neq j} Q_{jk} \int^t_0 e^{Z_jr}\psi^A_k\left(r\right) dr  \\
%e^{Z_jt}\frac{d\psi^A_j}{dt} + Z_j e^{Z_j t} \psi^A_j\left(t\right) &= \sum_{k: k \neq j} q_{jk} e^{Z_jt}\psi^A_k\left(t\right)  \\
%\frac{d\psi^A_j}{dt} &= \sum_{k} q_{jk} \psi^A_k\left(t\right).
%\end{align}
\begin{align}
        \frac{d\psi^A}{dt} &= \diag\left(\mathbbm{1}_{A^c}\right)Q\psi^A \\
        \psi^A\left(0\right) &= \mathbbm{1}_{A} \\
        \psi_j^A\left(t\right) &= 0\text{  }\forall j \in A.
\end{align}
This gives rise to the solution
\begin{align}
        \psi^A\left(t\right) &= e^{\diag\left(\mathbbm{1}_{A^c}\right)Qt} \mathbbm{1}_{A}
\end{align}
for the CDF of the stopping time $\tau^A$, but we can also compute the PDF explicitly for $t > 0$.
\begin{align}
        p\left(\tau^A = t\right) &= \frac{d\psi^A}{dt} \\
        &= \diag\left(\mathbbm{1}_{A^c}\right)Q\psi^A
\end{align}

Another hitting time statistic we may be interested in is, given an initial intermediate, what is the probability we will hit a subset of intermediates $A$ before some other disjoint subset of intermediates $B$.

\begin{align}
\rho^{A,B}_j &\doteq P(\tau^A_j < \tau^B)
\end{align}

Trivially, we have
\begin{align}
\rho^{A,B}_j &= 1 \text{ if } j\in A \\
\rho^{A,B}_j &= 0 \text{ if } j\in B
\end{align}
but must compute the case of $j \in (A\cup B)^C$.

\begin{align}
\rho^{A,B}_j &= P(\tau^A_j < \tau^B_j) \\
%&= \sum_{k}P(\tau^A_j < \tau^B_j, Y_1 = k) \\
%&= \sum_{k}P(\tau^A_j < \tau^B_j|Y_1 = k)P(Y_1 = k) \\
&= \sum_{k}P(\tau^A_k < \tau^B_k)P(Y_1 = k) \\
&= \frac{1}{Z_j}\sum_{k \neq j} \rho^{A,B}_kQ_{jk} \\
0 &= Q\rho^{A,B}
\end{align}
Again, putting each of these cases together, we get the linear system
\begin{align}
\left(\diag\left(\mathbbm{1}_A\right) + \diag\left(\mathbbm{1}_B\right) + \diag\left(\mathbbm{1}_{(A\cup B)^c}\right)Q\right)\rho^{A,B} =\mathbbm{1}_{A}
\end{align}
and our solution is
\begin{align}
\rho^{A,B} = \left[\diag\left(\mathbbm{1}_A\right) + \diag\left(\mathbbm{1}_B\right) + \diag\left(\mathbbm{1}_{(A\cup B)^c}\right)Q\right]^{-1}\mathbbm{1}_{A}.
\end{align}

Using this result, an insightful choice for $A$ and $B$ would be $A = \{x_k\}$ and $B = x_{|F|}$. Then, the value of $\rho_1^{A,B}$ would correspond to the probability that a particular intermediate $x^k$ is in a reversible pathway between the intermediate with a single face and the completed polyhedron.


\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{subcaption}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage{txfonts}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\setlength\parindent{0pt}
\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\noindent\\}

\bibliographystyle{agsm}

\begin{document}

\begin{algorithm}[H]
    \DontPrintSemicolon
    \SetKwInOut{Input}{Input}
    \SetKwInOut{Output}{Output}
    \Input{a coordinate $c$, offset = $\frac{boundary}{size-1}$, $size$ of image partition}
    \Output{an image $I$ of dimensions $size \times size$ and entropy $e$}
    \BlankLine
    $cx \leftarrow c.re$\;
    \For{$x \leftarrow 0$ \KwTo $size-1$}{
        \For{$y \leftarrow 0$ \KwTo $size-1$}{
            $z \leftarrow 0$\;
            \For{$iteration \leftarrow 1$ \KwTo $\text{maxIterations}$}{
                $z \leftarrow z^2 + c$\;
                \If{$|z| > 4$}{
                    break\;
                }
            }
            \If{$iteration = \text{maxIterations}$}{
                $I[x][y] = black$\;
            }
            \Else{
                $I[x][y] = colorFunction(iteration)$\;
            }
            $c.re = c.re + \text{offset}.re$\;
        }
        $c.re = cx$\;
        $c.im = c.im - \text{offset}.im$\;
    }
    \text{Compute the entropy of $I$ and store it as $e$}\;
    \KwRet $I$, $e$\;
    \caption{calculatePartition(c, offset, size, maxIterations)}
\end{algorithm}

\begin{algorithm}[H]
    \DontPrintSemicolon
    \SetKwInOut{Input}{Input}
    \SetKwInOut{Output}{Output}
    \Input{a datatructure of settings $S$}
    \Output{a computed image $I$ and coordinate of partition with most entropy $c$}
    \BlankLine
    \text{Populate and send the partitions to the follower processes}\;
    \text{Receive each partition into the set of partitions $P$}\;
    $I \leftarrow (S.size, S.size)$\;
    $maxEntropy \leftarrow -\infty$\;
    \ForEach{$p \in P$}{
        \text{Combine partial solution $p.I$ into $I$}\;
        \If{$p.entropy > maxEntropy$}{
            $maxEntropy \leftarrow p.entropy$\;
            $successorPartition \leftarrow p$\;
        }
    }
    $c \leftarrow successorPartition.c$\;
    \KwRet $I$, $c$\;
    \caption{performIteration($S$)}
\end{algorithm}

\end{document}

%%%% End of aa.dem