\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
% \usepackage{amscd, amsfonts, amsmath, amssymb, amstext, amsthm, caption, epsfig, fancyhdr, float, graphicx, latexsym, mathtools, multicol, multirow, algorithm, chngcntr}
\usepackage[english, french]{babel}
\usepackage{booktabs}

\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subfig}
\usepackage{xspace}
\usepackage{fourier}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{tkz-graph}
\usetikzlibrary{automata,arrows,positioning,calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usetikzlibrary{mindmap}
\usetikzlibrary{decorations.text}

% \theoremstyle{definition} % insert bellow all blocks you want in normal text
% \newtheorem{definition}{Definition}

% tikzmark command, for shading over items
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
    text width=5em, text centered, rounded corners]
\tikzstyle{line} = [draw]
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]

\usepackage[most]{tcolorbox}

\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow

% \newcommand*{\warning}{\fontencoding{U}\fontfamily{futs}\selectfont\char 66\relax}

% Distributions.
\newcommand*{\UnifDist}{\mathsf{Unif}}
\newcommand*{\ExpDist}{\mathsf{Exp}}
\newcommand*{\DepExpDist}{\mathsf{DepExp}}
\newcommand*{\GammaDist}{\mathsf{Gamma}}
\newcommand*{\LognormalDist}{\mathsf{LogNorm}}
\newcommand*{\WeibullDist}{\mathsf{Weib}}
\newcommand*{\ParetoDist}{\mathsf{Par}}
\newcommand*{\NormalDist}{\mathsf{Norm}}

\newcommand*{\GeometricDist}{\mathsf{Geom}}
\newcommand*{\NegBinomialDist}{\mathsf{NegBin}}
\newcommand*{\PoissonDist}{\mathsf{Poisson}}
\newcommand*{\BivariatePoissonDist}{\mathsf{BPoisson}}
\newcommand*{\CyclicalPoissonDist}{\mathsf{CPoisson}}

\newcommand*{\iid}{\textbf{iid}\@\xspace}
\newcommand*{\pdf}{\textbf{pdf}\@\xspace}
\newcommand*{\cdf}{\textbf{cdf}\@\xspace}
\newcommand*{\pmf}{\textbf{pmf}\@\xspace}
\newcommand*{\abc}{{\textbf{abc}}\@\xspace}
\newcommand*{\smc}{\textbf{smc}\@\xspace}
\newcommand*{\mcmc}{\textbf{mcmc}\@\xspace}
\newcommand*{\ess}{\textbf{ess}\@\xspace}
\newcommand*{\mle}{\textbf{mle}\@\xspace}
\newcommand*{\bic}{\textbf{bic}\@\xspace}
\newcommand*{\kde}{\textbf{kde}\@\xspace}
\newcommand*{\glm}{\textbf{glm}\@\xspace}
\newcommand*{\xol}{\textbf{xol}\@\xspace}
\newcommand*{\cpu}{\textbf{cpu}\@\xspace}
\newcommand*{\gpu}{\textbf{gpu}\@\xspace}
\newcommand*{\arm}{\textbf{arm}\@\xspace}

\def \si {\sigma}
\def \la {\lambda}
\def \al {\alpha}
% \def\e*{\end{eqnarray*}}
\def \di{\displaystyle}

\def \E{\mathbb E}
\def \N{\mathbb N}
\def \Z{\mathbb Z}
\def \NZ{\mathbb{N}_0}
\def \I{\mathbb I}
\def \w{\widehat}
\def \P {\mathbb P}
\def \V{\mathbb V}

\newcommand{\CL}{\mathbb{C}}
\newcommand{\RL}{\mathbb{R}}
\newcommand{\nat}{{\mathbb N}}
\newcommand{\Laplace}{\mathscr{L}}
\newcommand{\e}{\mathrm{e}}
\newcommand{\ve}{\bm{\mathrm{e}}} % vector e

\renewcommand{\L}{\mathcal{L}} % e.g. L^2 loss.

\newcommand{\ih}{\mathrm{i}}
\newcommand{\oh}{{\mathrm{o}}}
\newcommand{\Oh}{{\mathcal{O}}}
\newcommand{\Exp}{\mathbb{E}}

\newcommand{\Norm}{\mathcal{N}}
\newcommand{\LN}{\mathcal{LN}}
\newcommand{\SLN}{\mathcal{SLN}}

\renewcommand{\Pr}{\mathbb{P}}
\newcommand{\Ind}{\mathbb I}
\newcommand\bfsigma{\bm{\sigma}}
\newcommand\bfSigma{\bm{\Sigma}}
\newcommand\bfLambda{\bm{\Lambda}}
\newcommand{\stimes}{{\times}}
\def \limsup{\underset{n\rightarrow+\infty}{\overline{\lim}}}
\def \liminf{\underset{n\rightarrow+\infty}{\underline{\lim}}}

% vertical separator macro
\newcommand{\vsep}{
  \column{0.0\textwidth}
    \begin{tikzpicture}
      \draw[very thick,black!10] (0,0) -- (0,7.3);
    \end{tikzpicture}
}
\newcommand\blfootnote[1]{%
  \begingroup
  \renewcommand\thefootnote{}\footnote{#1}%
  \addtocounter{footnote}{-1}%
  \endgroup
}

% More space between lines in align
% \setlength{\mathindent}{0pt}

% Beamer theme
\usetheme{ZMBZFMK}
\usefonttheme[onlysmall]{structurebold}
\mode<presentation>
\setbeamercovered{transparent=10}

% align spacing
\setlength{\jot}{0pt}

\setbeamertemplate{navigation symbols}{}%remove navigation symbols

\title[BLOCKASTICS II]{Stochastic Models for blockchain analysis}
\subtitle{Simple models for blockchain performance analysis}
\author{Pierre-O. Goffard}
\institute[ISFA]{Institut de Science Financières et d'Assurances\\
 \texttt{pierre-olivier.goffard@univ-lyon1.fr}}
\date{\today}
\titlegraphic{\includegraphics[width=2.5cm]{../../../Figures/bfs_logo.png}}

\begin{document}
\begin{frame}
  \titlepage
\end{frame}
\begin{frame}{The three dimensions of blockchain analysis}
\tableofcontents
% \begin{enumerate}
%   \item Security of PoW blockchain
%   \item Decentralization in PoS blockchain
%   \item Blockhain efficiency
% \end{enumerate}
\end{frame}
\section{Security of PoW blockchain}
\begin{frame}{Double spending attack}
\scriptsize
\begin{enumerate}
\item Mary transfers 10 BTCs to John
\item The transaction is recorded in the public branch of the blockchain and John ships the good.
\item Mary transfers to herself the exact same BTCs
\item The malicious transaction is recorded into a private branch of the blockchain
\begin{itemize}
  \scriptsize
\item Mary has friends among the miners to help her out
\item The two chains are copycat up to the one transaction
\end{itemize}
\end{enumerate}
\begin{tcolorbox}[enhanced,drop shadow, title=Fact (Bitcoin has only one rule)]
The longest chain is to be trusted
\end{tcolorbox}
\end{frame}
\begin{frame}{Double spending in practice}
\scriptsize
Vendor are advised to wait for $\alpha\in\mathbb{N}$ of confirmations so that the honest chain is ahead of the dishonest one.
\begin{center}
\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=1cm]
% \tikzstyle{block} = [rectangle, draw, fill=blue!20,
%     text width=5em, text centered, rounded corners]
\tikzstyle{block}=[rectangle, fill=black,draw=black,thick,text=black,scale=0.6]
\tikzstyle{block}=[rectangle, fill=white,draw=black,thick,text=black,scale=0.8]
\tikzstyle{confirmed block}=[rectangle, fill=white,draw=blue,thick,text=black,scale=0.8]
\tikzstyle{bad block}=[rectangle, fill=white,draw=red,thick,text=black,scale=0.8]
\node[block]    (1)                     {\tiny $\text{M}\rightarrow \text{J}$};
\node[block]    (2)[right of=1]                     {};
\node[block]    (3)[right of=2]                     {};
\node[block]    (4)[right of=3]                     {};
\node[confirmed block]    (5)[right of=4]                     {};

\node[bad block]    (6)[below of=1]         {\tiny $\text{M}\rightarrow \text{M}$};
\node[block]    (7)[right of=6]         {};
\node[block]    (8)[right of=7]         {};
\path
(1) edge[ left]     node{}     (2)
(2) edge[ left]     node{}     (3)
(3) edge[ left]     node{}     (4)
(4) edge[ left]     node{}     (5)
(6) edge[ left]     node{}     (7)
(7) edge[ left]     node{}     (8);

\end{tikzpicture}
\end{center}
In the example, vendor awaits $\alpha = 4$ confirmations, the honest chain is ahead of the dishonest one by $z = 2$ blocks.
\begin{tcolorbox}[enhanced,drop shadow, title=Fact (PoW is resistant to double spending)]
\begin{itemize}
\item Attacker does not own the majority of computing power
\item Suitable $\alpha$
\end{itemize}
Double spending is unlikely to succeed.
\end{tcolorbox}
\tiny
\begin{thebibliography}{1}
\bibitem{Na08}
S.~Nakamoto, ``Bitcoin: A peer-to-peer electronic cash system.'' Available at
  \href{https://bitcoin.org/bitcoin.pdf}{https://bitcoin.org/bitcoin.pdf},
  2008.

\end{thebibliography}

\end{frame}
\begin{frame}{Mathematical set up}
\scriptsize
Assume that
\begin{itemize}
\item $R_0=z\geq1$ (the honest chain is z blocks ahead)
\item at each time unit a block is created
\begin{itemize}
  \scriptsize
\item[$\hookrightarrow$] in the honest chain with probability $p$
\item[$\hookrightarrow$] in the dishonest chain with probability $q=1-p$
\end{itemize}
\end{itemize}
The process $(R_n)_{n\geq0}$ is a random walk on $\mathbb{Z}$ with
$$R_n=z+Y_1+\ldots+Y_n,$$
where $Y_1,\ldots,Y_n$ are the \textbf{i.i.d.} steps of the random walk.

\end{frame}
\begin{frame}{Double spending rate of success}
\scriptsize
Double spending occurs at time
$$
\tau_z=\inf\{n\in \mathbb{N}\text{ ; }R_n=0\}.
$$
\begin{tikzpicture}
  %Origin and axis
  \coordinate (O) at (0,0);
  \draw[->] (-1,0) -- (9,0) coordinate[label = {below:$n$}] (xmax);
  \draw[->] (0,-0.5) -- (0,3) coordinate[label = {left:$Z_n$}] (ymax);
  %Lower linear boundary

  %Stochastic process trajectory

  \draw (0,0) node[tublue,left] {} node{};
  \draw[very thick,tublue,-] (0,1) -- (1,1) node[pos=0.5, above] {} ;
  \draw[very thick,dashed,tublue] (1,1) -- (1,1.5) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (1,1.5) -- (2,1.5) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (2,1.5) -- (2,2) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (2,2) -- (3,2) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (3,2) -- (3,1.5) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (3,1.5) -- (4,1.5)node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (4,1.5) -- (4,1) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (4,1) -- (5,1) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (5,1) -- (5,0.5) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (5,0.5) -- (6,0.5) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue,-] (6,0.5) -- (6,1) node[pos=0.5, above] {};
   \draw[very thick,tublue,-] (6,1) -- (7,1) node[pos=0.5, above] {};
    \draw[very thick,dashed,tublue,-] (7,1) -- (7,0.5) node[pos=0.5, above] {};
     \draw[very thick,tublue,-] (7,0.5) -- (8,0.5) node[pos=0.5, above] {};
     \draw[very thick,dashed,tublue,-] (8,0.5) -- (8,0) node[pos=0.5, above] {};
  %Jump Times
  \draw (1,0) node[black,below] {$1$} node{ \color{black}$\bullet$};
  \draw (2,0) node[black,below] {$2$} node{ \color{black}$\bullet$};
  \draw (3,0) node[black,below] {$3$} node{ \color{black}$\bullet$};
  \draw (4,0) node[black,below] {$4$} node{ \color{black}$\bullet$};
  \draw (5,0) node[black,below] {$5$} node{ \color{black}$\bullet$};
  \draw (6,0) node[black,below] {$6$} node{ \color{black}$\bullet$};
  \draw (7,0) node[black,below] {$7$} node{ \color{black}$\bullet$};
  \draw (8,0) node[black,below] {$8$} node{ \color{black}$\bullet$};
  %Level of the counting process
   \draw (0,0) node[black,below left] {$0$} node{ \color{black}$\bullet$};
   \draw (0,0.5) node[black,left] {$1$} node{ \color{black}$\bullet$};
   \draw (0,1) node[black,left] {$z=2$} node{ \color{black}$\bullet$};
   \draw (0,1.5) node[black,left] {$3$} node{ \color{black}$\bullet$};
   \draw (0,2) node[black,left] {$4$} node{ \color{black}$\bullet$};
   \draw (0,2.5) node[black,left] {$5$} node{ \color{black}$\bullet$};

  % %Aggregated Capital gains
%  \draw (0,1.5) node[blue,below right] {$\mu_1$} node{ \color{blue}$-$};
%  \draw (0,2.25) node[blue,left] {$\mu_2$} node{ \color{blue}$-$};
%  \draw (0,3.75) node[blue,left] {$\mu_3$} node{ \color{blue}$-$};
  %Ruin time = First-crossing time time
%  \draw (5,0) node[black,above right] {$\tau_u$} node{ \color{black}$\times$};
%  \draw[dotted,black] (0,3.28) -- (5,3.28);
%  \draw[dotted,black] (5,0) -- (5,3.28);
\end{tikzpicture}
\begin{tcolorbox}[enhanced,drop shadow, title=Double spending theorem]
If $p>q$ then the double-spending probability is given by
$$
\phi(z) = \mathbb{P}(\tau_z<\infty)=\left(\frac{q}{p}\right)^{z}.
$$
\end{tcolorbox}

\end{frame}

\begin{frame}[allowframebreaks]{Proof of the double spending theorem }
\scriptsize Analogy with the gambler's ruin problem. Using a first step analysis, we have
\begin{equation}\label{eq:difference_equation}
\phi(z) = p\phi(z+1)+(1-p)\phi(z-1),\text{ }z\geq1.
\end{equation}
We also have the boundary conditions
\begin{equation}\label{eq:boundary_conditions_double_spending}
\phi(0) = 1\text{ and }\underset{z\rightarrow +\infty}{\lim}\phi(z) = 0
\end{equation}
Equation \eqref{eq:difference_equation} is a linear difference equation of order $2$ associated to the following characteristic equation
$$
px^2 - x + 1-p = 0
$$
which has two roots on the real line with
$$
r_1 = 1, \text{ and }r_2 = \frac{1-p}{p}.
$$
The solution of \eqref{eq:difference_equation} is given by
$$
\phi(z)=A+B\left(\frac{1-p}{p}\right)^z,
$$
where $A$ and $B$ are constant. Using the boudary conditions \eqref{eq:boundary_conditions_double_spending}, we deduce that
$$
\phi(z) = \left(\frac{1-p}{p}\right)^z
$$
as announced.
\end{frame}
\begin{frame}{Refinements of the double spending problem}
\scriptsize
The number of blocks $M$ found by the attacker until the honest miners find $\alpha$ blocks is a negative binomial random variable with \pmf
$$
\mathbb{P}(M = m) = \binom{\alpha+m-1}{m}p^\alpha q^m,\text{ }m\geq0.
$$
The number of block that the honest chain is ahead of the dishonest one is given by
$$
Z= (\alpha-M)_+.
$$
Applying the law of total probability yields the probability of successful double spending with
$$
\mathbb{P}(\text{Double Spending}) = \mathbb{P}(M\geq \alpha) + \sum_{m = 0}^{\alpha - 1}\binom{\alpha+m-1}{m}q^{\alpha} p^{m}.
$$
\tiny

\begin{thebibliography}{1}
  \bibitem{rosenfeld2014analysis}
M.~Rosenfeld, ``Analysis of hashrate-based double spending,'' {\em arXiv
  preprint arXiv:1402.2009}, 2014.
  \bibitem{GRUNSPAN2018}
C.~Grunspan and R.~Perez-Marco, ``Double spend race,'' {\em
  International Journal of Theoretical and Applied Finance}, vol.~21,
  p.~1850053, dec 2018.
\end{thebibliography}

\end{frame}
\begin{frame}{Refinements of the double spending problem}
\scriptsize
Let the length of honest and dishonest chain be driven by counting processes
\begin{itemize}
\item Honest chain $\Rightarrow$ $z+N_t\text{ , }t\geq0$, where $z\geq1$.
\item Malicious chain $\Rightarrow$ $M_t\text{ , }t\geq0$
\item Study the distribution of the first-\textit{rendez-vous} time
$$
\tau_z=\inf\{t\geq0\text{ , } M_t=z+N_t\}.
$$
\end{itemize}
If $N_t\sim\text{Pois}(\lambda t)$ and $M_t\sim\text{Pois}(\mu t)$ such that $\lambda>\mu$ then
$$
\phi(z) = \left(\frac{\mu}{\lambda}\right)^z,\text{ }z\geq 0.
$$
\tiny
\begin{thebibliography}{1}

\bibitem{Goffard2019}
P.-O. Goffard, ``Fraud risk assessment within blockchain transactions,'' {\em
  Advances in Applied Probability}, vol.~51, pp.~443--467, jun 2019.
\newblock \url{https://hal.archives-ouvertes.fr/hal-01716687v2}.

\bibitem{Bowden2020}
R.~Bowden, H.~P. Keeler, A.~E. Krzesinski, and P.~G. Taylor, ``Modeling and
  analysis of block arrival times in the bitcoin blockchain,'' {\em Stochastic
  Models}, vol.~36, pp.~602--637, jul 2020.
\end{thebibliography}

\end{frame}
\begin{frame}{Perspectives}
\begin{itemize}
\item Distribution of $\tau_z$? (To be discussed later)
\item Distribution of $Z$
\begin{itemize}
  \item[$\hookrightarrow$] Negative binomial when the length of the blockchain are driven by Poisson processes
  \item [$\hookrightarrow$] if not?
\end{itemize}
\end{itemize}
\end{frame}
\section{Decentralization in PoS blockchain}
\begin{frame}{Proof of Stake protocol}
\scriptsize
PoS is the most popular alternative to PoW.
\begin{itemize}
  \item A block validator is selected according to the number of native coins she owns
  \item Update the blockchain and receive a reward or do nothing
\end{itemize}
Two problems
\begin{itemize}
  \item[\warning] Nothing at stake $\Rightarrow$ Consensus postponed
  \item[\warning] Rich gets richer $\Rightarrow$ Risk of centralization
\end{itemize}

\end{frame}
\begin{frame}{Nothing-at-Stake}
\scriptsize
If given the opportunity a node will always append a new block
\begin{itemize}
  \item Everlasting fork if any
\end{itemize}
Perpetuating disagreement prevent users to exchange which lower the coin value.
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem]
To get consensus faster and almost surely
\begin{itemize}
  \item Set a minimum stake to outweight the benefit of the reward
  \item Set up a modest reward schedule $\sum_{t = 1}^\infty \text{r}_t<\infty$
\end{itemize}
\end{tcolorbox}
\tiny
\begin{thebibliography}{1}

\bibitem{Saleh2020}
F.~Saleh, ``Blockchain without waste: Proof-of-stake,'' {\em The Review of
  Financial Studies}, vol.~34, pp.~1156--1190, jul 2020.
\end{thebibliography}
\end{frame}
\begin{frame}{Risk of centralization ?}
\scriptsize
\begin{columns}
\begin{column}{0.5\textwidth}
Block appending process
\begin{itemize}
  \item Draw a coin at random
  \item The owner of the coin append a block and collect the reward
  \item The block appender is more likely to get selected during the next round
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
Similar to Polya's urn \includegraphics[scale=0.1]{../../../Figures/poly_urn.png}
\begin{itemize}
  \item Consider an urn of $N$ balls of color in $E=\{1,\ldots, p\}$
  \item Draw a ball of color $x\in E$
  \item Replace the ball together with $r$ balls of color $x$
\end{itemize}
$p$ is the number of peers and $r$ is the size of the block reward.
\end{column}
\end{columns}
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem]
The proportion of coins owned by each peer is stable on average over the long run
\end{tcolorbox}

\tiny
\begin{thebibliography}{1}

\bibitem{Rosu2021}
I.~Ro{\c{s}}u and F.~Saleh, ``Evolution of shares in a proof-of-stake
  cryptocurrency,'' {\em Management Science}, vol.~67, pp.~661--672, feb 2021.
  \end{thebibliography}
\end{frame}
\begin{frame}{Proof}
\scriptsize
Consider the balls of some color $x\in E$, and denote by
\begin{itemize}
\item $N_x$ the number of balls of color $x$ initially in the urn
\item $Y_n$ the number of balls of color $x$ in the urn after $n$ draws
\item $Z_n$ the corresponding proportion of balls of color $x$.
\end{itemize}
We show that $(Z_n)_{n\geq0}$ is a $\mathcal{F}_n-$Martingale where $\mathcal{F}_n=\sigma(Y_1,\ldots, Y_n)$. We have
\begin{eqnarray*}
\mathbb{E}(Z_{n+1}|\mathcal{F}_n) = Z_n\frac{Y_n+r}{N+r(n+1)} +(1-Z_n)\frac{Y_n}{N+r(n+1)} = Z_n
\end{eqnarray*}
It follows that
$$
\mathbb{E}(Z_n) = \mathbb{E}(Z_0) = \frac{N_x}{N}, \text{ for }n\geq0.
$$
hence the stability. Furthermore, because $|Z_n|<1$, then $\underset{n\rightarrow\infty}{\lim} Z_n = Z_\infty$ exists and it holds that $\mathbb{E}(Z_\infty) = \mathbb{E}(Z_0)$.\\
\end{frame}
\begin{frame}{What is the limiting distributions of the shares?}
\scriptsize
\begin{tcolorbox}[enhanced,drop shadow, title=Dirichlet distribution]
A random vector $(Z_1,\ldots, Z_p)$ has a Dirichlet distribution $\text{Dir}(\alpha_1,\ldots, \alpha_p)$ with \pdf
$$
f(z_1,\ldots, z_p;\alpha_1,\ldots, \alpha_p) = \frac{1}{B(\alpha)}\prod_{i=1}^p z_i^{\alpha_i-1},
$$
for $\alpha_1,\ldots, \alpha_p>0$, $0< z_1,\ldots, z_p <1$ and $\sum_{i=1}^pz_i=1$, where
$$
B(\alpha) = \frac{\prod_{i = 1}^p \Gamma(\alpha_i)}{\Gamma(\sum_{i=1}^p \alpha_i)}.
$$
\end{tcolorbox}
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (Convergence toward a Dirichlet distribution)]
Suppose that $r=1$ and let $X_n$ be the color of the ball drawn at the $n^{th}$ round then
$$
\{\mathbb{P}(X_\infty = x), x\in E\} \sim \text{Dir}(\{N_x\text{, }x\in E\}).
$$
\end{tcolorbox}
\end{frame}
\begin{frame}[allowframebreaks]{Proof}
\scriptsize
We have that
\begin{equation}\label{eq:polya_sequence_1}
\mathbb{P}(X_1=x) = \frac{N_x}{N}
\end{equation}
and
\begin{equation}\label{eq:polya_sequence_2}
\mathbb{P}(X_{n+1}=x) = \frac{N_x + \sum_{i=1}^n\delta_{X_i}(x)}{N+n} = \frac{N_x + \lambda_n(x)}{N+n} = m_n(x)
\end{equation}
where $\delta_{X_i}$ denotes the Dirac measure at $X_i$.\\
A sequence that satisfies \eqref{eq:polya_sequence_1} and \eqref{eq:polya_sequence_2} is said to be a Polya sequence with parameter $N_x\text{, }x\in E$.

\begin{lemma}
There is an equivalence between the two following statements
\begin{itemize}
\item[(i)] $X_1,X_2,\ldots,$ is a Polya sequence
\item[(ii)] $\mu^{\ast}\sim \text{Dir}(N_x,x\in E)$ and $X_1,X_2,\ldots$ given $\mu^\ast$ are \iid as $\mu^\ast$
\end{itemize}
\end{lemma}
Consider the event $A_n = \{X_1 = x_1,\ldots, X_n = x_n\}$. Induction on $n$ allows us to show that (i) is equivalent to
\begin{equation}\label{eq:P_A_polya_i}
\mathbb{P}(A_n) = \frac{\prod_{x\in E} N_x^{[\lambda_n(x)]}}{N^{[n]}},
\end{equation}
where $\lambda_n(x)$ is the number of $i$'s in $1,\ldots, n$ for which $x_i = x$ and $a^{[k]} = a(a+1)\ldots(a+k-1)$.  Now assume that $(ii)$ holds true, then
$$
\mathbb{P}(A_n|\mu^\ast) = \prod_{x\in E}\mu^\ast(x)^{\lambda_n(x)},
$$
recall that $\mu^\ast$ is a random vector, indexed on $E$, We denote by $\mu^\ast(x)$ the component associated with $x\in E$. The law of total probability then yields
\begin{equation}\label{eq:P_A_polya_ii}
\mathbb{P}(A_n) = \E\left[\prod_{x\in E}\mu^\ast(x)^{\lambda_n(x)}\right],
\end{equation}
which is the same as \eqref{eq:P_A_polya_i}. Applying the lemma together with the law of large number yields
$$
n^{-1}\sum_{i=1}^n\delta_{X_i}(x) \rightarrow \mu^{\ast}(x)\text{ as } n\rightarrow\infty.
$$
and then $m_n(x)\rightarrow\mu^{\ast}(x)$.
\tiny
\begin{thebibliography}{1}
\bibitem{Blackwell1973}
D.~Blackwell and J.~B. MacQueen, ``Ferguson distributions via polya urn
  schemes,'' {\em The Annals of Statistics}, vol.~1, mar 1973.
  \end{thebibliography}
\end{frame}
\begin{frame}{Measuring decentrality}
\scriptsize
\begin{tcolorbox}[enhanced,drop shadow, title=Fact]
The most desirable situation corresponds to all the peers being equally likely to be selected.
\end{tcolorbox}
Decentrality maybe measure by Shannon's entropy
$$
H(\mu^\ast) = -\mathbb{E}\left\{\sum_x \mu^\ast(x)\ln[\mu^\ast(x)]\right\} = -\sum_x\frac{N}{N_x}\left[\psi(N_x+1)-\psi(N+1)\right],
$$
where $\psi(x) = \frac{\text{d}}{\text{d}x}\ln[\Gamma(x)]$ is the digamma function, to be compared to $\ln(p)$
\tiny
\begin{thebibliography}{1}

\bibitem{Gochhayat2020}
S.~P. Gochhayat, S.~Shetty, R.~Mukkamala, P.~Foytik, G.~A. Kamhoua, and
  L.~Njilla, ``Measuring decentrality in blockchain based systems,'' {\em
  {IEEE} Access}, vol.~8, pp.~178372--178390, 2020.

\end{thebibliography}

\end{frame}
\begin{frame}{Extensions and perspectives}
\begin{itemize}
  \item How to include more peers along the way?
  \item What if the peers are not simply buy and hold investors?
  \item Find ways to monitor decentralization and take action if necessary
\end{itemize}
\tiny
\begin{thebibliography}{1}

\bibitem{Rosu2021}
I.~Ro{\c{s}}u and F.~Saleh, ``Evolution of shares in a proof-of-stake
  cryptocurrency,'' {\em Management Science}, vol.~67, pp.~661--672, feb 2021.
  \end{thebibliography}

\end{frame}
\section{Blockchain efficiency}
\begin{frame}{Efficiency}
Efficiency is characterized by
\begin{itemize}
  \item Throughputs: Number of transaction being processed per time unit
  \item Latency: Average transaction confirmation time
\end{itemize}
We focus on a PoW equipped blockchain and study the above quantities using a queueing model.
\end{frame}
\begin{frame}{Queue settings}
\begin{center}
\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=1cm]

\tikzstyle{phantom block}=[rectangle, fill=white,draw=white, thick,text=black,scale=2]
\tikzstyle{block}=[rectangle, fill=white,draw=black,thick,text=black,scale=4]
\tikzstyle{Intensity}=[circle, fill=white,draw=tublue,very thick, text=black,scale=1.2]
\tikzstyle{transaction pending}=[circle, fill=white,draw=tublue,very thick, text=black,scale=1]
\tikzstyle{transaction considered}=[circle, fill=tublue, text=black, scale=1]
\node[Intensity]    (1){$\lambda$};
\node[phantom block]  (2)[right of=1] {};
\node[transaction pending] (3)[right of=2] {};
\node[transaction pending] (4)[above of=3] {};
\node[transaction pending] (5)[above of=4] {};
\node[transaction pending] (6)[above of=5] {};
\node[transaction pending] (7)[below of=3] {};
\node[transaction pending] (8)[below of=7] {};
\path
(1) edge[->,bend left]     node{} (4)
    edge[->, bend right]     node{}          (7);
\pause
\node[Intensity]  (14)[above of=6]{$\mu$};
% \path
% (1) edge[->,bend left]     node{$\text{Exp}(\lambda)$}        (4)
%     edge[->, bend right]     node{}          (7);
\pause
\node[transaction considered] (3)[right of=2] {};
\node[transaction considered] (4)[above of=3] {};
\node[transaction considered] (5)[above of=4] {};
\node[transaction considered] (6)[above of=5] {};

\pause
\node[phantom block]  (10)[right of=3] {};
\node[block]  (11)[right of=10] {};
\path
(6) edge[->]   node{} (11)
(5) edge[->]   node{} (11)
(4) edge[->]   node{} (11)
(3) edge[->]   node{} (11)
;
\node[Intensity]  (12)[above of=11] {$\mu$};
\node[phantom block]  (13)[above of=12] {};

\path
(11) edge[-]     node{}        (12);
\path
(12) edge[->]     node{}        (13);

\end{tikzpicture}
\end{center}
\end{frame}
\begin{frame}{Queueing setting}
\begin{itemize}
\item Poisson arrival with rate $\lambda>0$ for the transactions
\item Poisson arrival with rate $\mu>0$ for the blocks
\item Block size $b\in\mathbb{N}^\ast$
$\Rightarrow $Batch service
\item[\warning] The server is always busy
\end{itemize}
This is somekind of $M/M^b/1$ queue.
\tiny
\begin{thebibliography}{1}
\bibitem{Kawase2017}
Y.~Kawase and S.~Kasahara, ``Transaction-confirmation time for bitcoin:
  A~queueing analytical approach to~blockchain~mechanism,'' in {\em Queueing
  Theory and Network Applications}, pp.~75--88, Springer International
  Publishing, 2017.
\bibitem{Bailey1954}
N.~T.~J. Bailey, ``On queueing processes with bulk service,'' {\em Journal of
  the Royal Statistical Society: Series B (Methodological)}, vol.~16,
  pp.~80--87, jan 1954.

\bibitem{Cox1955}
D.~R. Cox, ``The analysis of non-markovian stochastic processes by the
  inclusion of supplementary variables,'' {\em Mathematical Proceedings of the
  Cambridge Philosophical Society}, vol.~51, pp.~433--441, jul 1955.

\end{thebibliography}
\end{frame}

\begin{frame}{Queue length distribution}
\scriptsize
The queueuing process eventually reaches stationarity if
\begin{equation}\label{eq:stationarity_cond}
\mu\cdot b > \lambda.
\end{equation}
We denote by $N^q$ the length of the queue upon stationarity.
\begin{tcolorbox}[enhanced,drop shadow, title=The blockchain efficiency theorem]
Assume that \eqref{eq:stationarity_cond} holds then $N^q$ is geometrically distributed
$$
\mathbb{P}(N^q = n) = (1-p)\cdot p^n,
$$
where $p = 1/z^\ast$ and $z^\ast$ is the only root of
$$
-\frac{\lambda}{\mu}z^{b+1}+z^b\left(\frac{\lambda}{\mu}+1\right) - 1,
$$
such that $|z^\ast$|>1.
\end{tcolorbox}
\end{frame}
\begin{frame}[allowframebreaks]{Proof of the efficiency theorem}
\scriptsize
Let $N^q_t$ be the number of transactions in the queue at time $t\geq0$ and $X_t$ the time elapsed since the last block was found. Further define
\[
P_{n}(x,t)\text{d}x  =\mathbb{P}[N_t^q = n, X_t \in(x, x + \text{dx})]
\]
If $\lambda < \mu\cdot b$ holds then the process admits a limiting distribution given by
\[
\underset{t\rightarrow\infty}{\lim}P_{n}(x,t) = P_{n}(x).
\]
We aim at finding the distribution of the queue length upon stationarity
\begin{equation}\label{eq:alpha_n}
\mathbb{P}(N^q=n):=\alpha_n =\int_{0}^\infty P_{n}(x)\text{d}x.
\end{equation}
Consider the possible transitions over a small time lapse \text{h} during which no block is being generated. Over this time interval, either
\begin{itemize}
  \item no transactions arrives
  \item one transaction arrives
\end{itemize}
We have for $n\geq1$
\[
P_{n}(x+h) = e^{-\mu h}\left[e^{-\lambda h}P_{n}(x)+\lambda h e^{-\lambda h}P_{n-1}(x)\right]
\]
Differentiating with respect to $h$ and letting $h\rightarrow0$ leads to
\begin{equation}\label{eq:diff_eq_n_geq_1}
P_{n}'(x) = -(\lambda+\mu)P_{n}(x)+\lambda P_{n-1}(x),\text{ }n \geq1.
\end{equation}
Similarly for $n = 0$, we have
\begin{equation}\label{eq:diff_eq_n_eq_0}
P_{0}'(x) = -(\lambda+\mu)P_{0}(x).
\end{equation}
We denote by
$$
\xi(x)\text{d}x =\mathbb{P}(x\leq X< x+\text{d}x|X\geq x)= \mu\text{d}x
$$
the hazard function of the block arrival time (constant as it is exponentially distributed). The system of differential equations \eqref{eq:diff_eq_n_geq_1}, \eqref{eq:diff_eq_n_eq_0} admits boundary conditions at $x = 0$ with
\begin{equation}\label{eq:boundary_cond_1}
\begin{cases}
P_{n}(0) = \int_0^{+\infty} P_{n+b}(x)\xi(x)\text{d}x = \mu\alpha_{n+b},&n \geq1,\\
P_{0}(0) = \mu\sum_{n=0}^{b}\alpha_n,&n = 0,\ldots,b\\
\end{cases}
\end{equation}
Define the probability generating function of $N^q$ at some elapsed service time $x\geq 0$ as
$$
G(z;x) = \sum_{n=0}^\infty P_{n}(x)z^n.
$$
By differentiating with respect to $x$, we get (using \eqref{eq:diff_eq_n_geq_1} and \eqref{eq:diff_eq_n_eq_0})
$$
\frac{\partial}{\partial x}G(z;x) = -\left[\lambda(1-z)+\mu\right]G(z;x)
$$
and therefore
$$
G(z;x) = G(z;0)\exp\left\{-\left[\lambda(1-z)+\mu\right]x\right\}
$$
We get the probability generating function of $N^q$ by integrating over $x$ as
\begin{equation}\label{eq:G_z_solve_ODE}
G(z) = \frac{G(z;0)}{\lambda(1-z)+\mu}
\end{equation}
Using the boundary conditions \eqref{eq:boundary_cond_1}, we write
\begin{eqnarray}
G(z;0) &= &\sum_{n = 0}^\infty P_{n}(0)z^n \nonumber\\
&= &P_{0}(0)+\sum_{n=1}^{+\infty}P_{n}(0)z^n\nonumber\\
&=& \mu\sum_{n = 0}^{b}\alpha_n  + \mu\sum_{n=1}^{+\infty}\alpha_{n+b} z^n\nonumber\\
&=& \mu\sum_{n = 0}^{b}\alpha_n + \mu z^{-b}\left[G(z)-\sum_{n = 0}^{b}\alpha_n z^n\right]\label{eq:G_z_0}
\end{eqnarray}
Replacing the left hand side of \eqref{eq:G_z_0} by \eqref{eq:G_z_solve_ODE}, multiplying on both side by $z^b$ and rearranging yields
\begin{equation}\label{eq:G_z_as_rational_function}
\frac{G(z)}{M(z)}[z^b - M(z)] =\sum_{n=0}^{b-1}\alpha_n(z^b - z^n),
\end{equation}
where $M(z) = \mu/(\lambda(1-z)+\mu)$. Using Rouche's theorem, we find that both side of the equation shares $b$ zeros inside the circle $\mathcal{C} = \{z\in\mathbb{C}\text{ ; }|z| <1+\epsilon\}$ for some epsilon.
\begin{tcolorbox}[enhanced,drop shadow, title=Rouche's theorem]
Let $\mathcal{C}\in \mathbb{C}$ and $f$ and $g$ two holomorphic functions on $\mathcal{C}$. Let $\partial\mathcal{C}$ be the contour of $\partial\mathcal{C}$. If
$$
|f(z)-g(z)|<|g(z)|\text{, }\forall z\in\partial\mathcal{C}
$$
then $Z_f-P_f = Z_g-P_g$, where $Z_f$, $P_f$, $Z_g$, and $P_g$ are the number of zeros and poles of $f$ and $g$ respectively.

\end{tcolorbox}
We have $\partial\mathcal{C} =\{z\in\mathbb{C}\text{ ; }|z| =1+\epsilon\}$. The left hand side can be rewritten as
$$
G(z)\left[-\frac{\lambda}{\mu}z^{b+1} + \left(1 + \frac{\lambda}{\mu}\right)z^b -1\right].
$$
Define $f(z) = -\frac{\lambda}{\mu}z^{b+1} + \left(1 + \frac{\lambda}{\mu}\right)z^b -1$ and $g(z)=\left(1 + \frac{\lambda}{\mu}\right)z^b$. We have
$$
|f(z) - g(z)| = |-\frac{\lambda}{\mu}z^{b+1}-1|< \frac{\lambda}{\mu}(1+\epsilon)^{b+1}+1\rightarrow \frac{\lambda}{\mu}+1,\text{ as }\epsilon \rightarrow 0.
$$
and
$$
|g(z)| = \left(1 + \frac{\lambda}{\mu}\right)(1+\epsilon)^b\rightarrow \frac{\lambda}{\mu}+1,\text{ as }\epsilon \rightarrow 0.
$$
Regarding the right hand side, define $f(z) = \sum_{n=0}^{b-1}\alpha_n(z^b - z^n)$ and $g(z) =\sum_{n=0}^{b-1}\alpha_nz^b $. We have
$$
|f(z) - g(z)| < |\sum_{n=0}^{b-1}\alpha_n z^n| < \sum_{n=0}^{b-1}\alpha_n (1+\epsilon)^n\rightarrow  \sum_{n=0}^{b-1}\alpha_n,\text{ as }\epsilon \rightarrow 0.
$$
and
$$
|g(z)| = (1+\epsilon)^b\sum_{n=0}^{b-1}\alpha_n\rightarrow \sum_{n=0}^{b-1}\alpha_n,\text{ as }\epsilon \rightarrow 0.
$$
One of them is $1$, and we denote by $z_k$, $k = 1,\ldots, b-1$ the remaining $b-1$ zeros. Given the polynomial form of the right hand side of \eqref{eq:G_z_as_rational_function}, the fundamental theorem of algebra indicates that the number of zero is $b$. Given the left hand side
$$
G(z)\left[-\frac{\lambda}{\mu}z^{b+1} + \left(1 + \frac{\lambda}{\mu}\right)z^b -1\right].
$$
we deduce that there is one zeros outside $\mathcal{C}$, we can further show that it is a real number $z^\ast$. Multiplying both side of \eqref{eq:G_z_as_rational_function} by $(z-1)\prod_{k =1}^{b-1}(z-z_k)$, and using $G(1)=1$ yields
$$
G(z) = \frac{1-z^\ast}{z-z^{\ast}}.
$$
$N^q$ is then a geometric random variable with parameter $p = \frac{1}{z^\ast}.$
\end{frame}
\begin{frame}{Latency and throughputs}
\scriptsize
\begin{tcolorbox}[enhanced,drop shadow, title=Little's law]
Consider a stationary queueing system and denote by
\begin{itemize}
  \item $1/\lambda$ the mean of the unit inter-arrival times
  \item $L$ be the mean number of units in the system
  \item $W$ be the mean time spent by units in the system
\end{itemize}
We have
$$
L = \lambda \cdot W
$$
\end{tcolorbox}
\tiny
\begin{thebibliography}{1}

\bibitem{Little1961}
J.~D.~C. Little, ``A proof for the queuing formula:{L}= $\lambda${W},'' {\em
  Operations Research}, vol.~9, pp.~383--387, jun 1961.

\end{thebibliography}
\scriptsize
\begin{itemize}
  \item Latency is the confirmation time of a transaction
    $$
    \text{Latency} = \frac{p}{(1-p)\lambda} + \frac{1}{\mu}
    $$
  \item Throughput is the number of transaction confirmed per time unit
  $$
    \text{Throughput} = \mu\mathbb{E}(N^q\mathbb{I}_{N^q\leq b}+b\mathbb{I}_{N^q> b}) = \mu\sum_{n = 0}^bn(1-p)p^n + bp^{b+1}.
  $$
\end{itemize}
\end{frame}
\begin{frame}{Perspective}
\begin{enumerate}
  \item  Include some priority consideration to account for the transaction fees
  \tiny
  \begin{thebibliography}{1}

\bibitem{Kawase2020}
Y.~Kawase, , and S.~Kasahara, ``Priority queueing analysis of
  transaction-confirmation time for bitcoin,'' {\em Journal of Industrial {\&}
  Management Optimization}, vol.~16, no.~3, pp.~1077--1098, 2020.

\end{thebibliography}

  \item \normalsize Go beyond the Poisson process framework
  \tiny
  \begin{thebibliography}{1}

\bibitem{Li2018}
Q.-L. Li, J.-Y. Ma, and Y.-X. Chang, ``Blockchain queue theory,'' in {\em
  Computational Data and Social Networks}, pp.~25--40, Springer International
  Publishing, 2018.

\bibitem{Li2019}
Q.-L. Li, J.-Y. Ma, Y.-X. Chang, F.-Q. Ma, and H.-B. Yu, ``Markov processes in
  blockchain systems,'' {\em Computational Social Networks}, vol.~6, jul 2019.

\end{thebibliography}
\end{enumerate}

\end{frame}
\begin{frame}{A fourth dimension to analyse}
The energy consumption dimension
\begin{center}
     \includegraphics[width=\textwidth]{../../../Figures/BTC_energy_consumption.png}
     \end{center}

\url{https://cbeci.org/}

\end{frame}

% \begin{frame}
% \bibliography{../../blockastics}
% \bibliographystyle{ieeetr}
% \end{frame}

\end{document}


\section{Ensemble}
\label{sec:ensemble}
Our approach builds upon an ensemble voting strategy of different runs of multiple Recurrent Neural Networks (RNNs) and one execution of Title2Rec. The RNNs are configured differently in terms of network inputs and hyper-parameters. The RNNs are used to predict the missing tracks to be part of a playlist and thus assume to have seed(s) track(s) of the playlist to be utilized as initial elements of the network bootstrap (Section~\ref{sec:rnn}). However, when only the title of the playlist is available, our approach relies on a fall-back strategy that implements a K-means clustering of the playlists and a word embedding model of their titles (trained with fastText), called Title2Rec (Section~\ref{sec:t2r}). Figure~\ref{fig:ensemble} illustrates the overall approach.

\begin{figure}
    \centering
    \includegraphics[width=\textwidth, width=0.47\textwidth]{figures/ensemble.pdf}
    \caption{The proposed ensemble architecture for playlist completion. The inputs are a playlist and its title.}
    \label{fig:ensemble}
\end{figure}

The ensemble weighs the rankings of the different runs by giving more importance (more weights) to the top ranked tracks and less to the low ranked tracks, similarly to a Borda count election.\footnote{\url{https://en.wikipedia.org/wiki/Borda_count}} In detail, given a ranked set of predictions coming from a configuration $k$, corresponding to a particular configuration of the RNN jointly combined with Title2Rec, $R_k = \{T_1, T_2, \dots, T_{500}\}$, we assign to each track a score $s_k$ that has its maximum for the first track in the ranking and minimum for the last one, i.e. $s_k(T_i) = 500 - i + 1$. Then, we sum the scores over all the configurations that we want to ensemble, obtaining a final score for each track $s(T_i) = \sum_{k} s_k(T_i)$ which we use to create the final ranking of the tracks. Take as an example (with 3 tracks instead of 500 in the predictions) a configuration $1$ with ranking $R_1 = \{T_1, T_2, T_3\}$ and a configuration $2$ with ranking $R_2 = \{T_1, T_3, T_2\}$. We would get $s_1(T_1) =  3$, $s_1(T_2) = 2$, $s_1(T_3) = 1$, $s_2(T_1)=3$, $s_2(T_3) = 2$, $s_2(T_2)=1$ and thus $s(T_1) = 3+3= 6$, $s(T_2)= 2+1=3$, $s(T_3)=1+2=3$, obtaining as a final ranking $R = \{T_1, T_2, T_3\}$, or equivalently $R = \{T_1, T_3, T_2\}$ as $T_2$ and $T_3$ have the same score.


\chapter{Background}
\label{chapter_background}
\thispagestyle{empty}

We try to consolidate the relevant background for our thesis in this chapter by talking about prior research conducted by other researchers with respect to the topic and also parallelly provide a theoretical base on which we expand further as we progress through the thesis.

A lot of the existing research focuses on how minorities are represented in a network. Ranking of users is a common phenomenon in different circumstances, which could either be related to distribution of opportunities or in-general visibility of a particular subgroup within an ecosystem \cite{brin1998anatomy,horowitz2010anatomy,chalfin2016productivity}. Ranking systems in the real-world are driven by algorithms and agents which make decisions based on the network structure and/or node attributes \cite{adamic2003friends,gupta2013wtf,backstrom2011supervised}, and hence this has been a primary motivation to study how different groups fair in such rankings. We start by talking about networks and the simulation methods used by previous researchers (and also by us) to generate imitative representative networks with controlled parameters. We also talk about homophily as a parameter which has been observed by many researchers to play a crucial role in real-world tie formations. Finally we talk about reinforcement learning, and specifically `learning to rank' methods which we use in a novel way to perform user recommendations for networks in our thesis.

\section{Networks}
\label{back_networks}
We define a network as a \textit{graph} $G(V,E)$ which is defined by its set of vertices $V$ where a vertex $v \in V$ might possess certain vertex attributes, and \textit{edges} $E$ which connect these vertices with each other.

Vertex attributes helps to identify vertices individually and also associate them in groups. In the context of social networks, vertex attributes could be different demographics parameters like age, sex, educational qualification, nationality, ethnicity, etc. Edges in a network are links among vertices which represent connectivity amongst them. These edges could be directed or undirected which leads to the formation of directed and undirected graphs respectively. Some social network graphs are directed for example the networks for Twitter or Instagram, while others are undirected, for example LinkedIN, Facebook, Google+. In the social network perspective a directed edge signifies that the vertex from which the edge originates is subscribed to (or follows) updates and events originating from the vertex to which the edge is destined.

In our thesis, we often refer \textit{vertices} as \textit{nodes} and \textit{graphs} as \textit{networks}. These terms are used interchangeably and for the purpose of our thesis they mean exactly the same unless otherwise specified.

Also we consider vertices to possess a generic vertex attribute which designates it to either the \textit{minority} or the \textit{majority} group in the graph. Going forward, we visualize vertices belonging to the \textit{minority} group with the color \textit{red} and vertices belonging to the \textit{majority} group with the color \textit{blue}.

\subsection{Homophily}
Homophily as a concept defines the tendency of individuals to form connections with others who are similar to them. This phenomenon has been observed for many centuries as human behavior by several philosophers, like Plato, who in Phaedrus \cite{hackforth1972plato} says \textit{``Similarity begets friendship''}, acknowledging this innate propensity.

There are however varying degrees of homophily in real-world networks depending on the kind of network it is. This could lead to a network being either \textit{heterophilic} (nodes in a network tend to connect mostly with nodes belonging to other group) or \textit{homophilic} (nodes in a network tend to connect to nodes belonging to the same group).

Symmetric homophily signifies that the propensity of connecting within the same group is same for both groups, while asymmetric homophily signifies different propensities. Real-world networks usually exhibit varying degrees of asymmetric homophily.

Networks like sexual contact network or online dating network shows high degree of heterophily. Scientific collaborations networks exhibit moderate homophily while scientific citation networks have high degree of homophily in them.

How homophily changes the network structure and affects visibility of groups have been studied by several researchers \cite{stoica2018algorithmic,avin2015homophily,mcpherson2001birds,karimi2018homophily}. In our thesis we follow a similar approach of studying homophily to see its effect in our experiments.

In the context of our thesis, we define homophily between two nodes $u$ and $v$ as $h_{uv}$. Given the symmetric homophily parameter value of $h$ the value of which can range in between $[0, 1]$, $h_{uv}=h$ when $u$ and $v$ both belong to the same group, and $h_{uv}=(1-h)$ if $u$ and $v$ belongs to two different groups. Complete heterophily is signified by a value of $h=0$, where the network forms a bipartite graph. The network is in the heterophilic regime for $0 \leq h \leq 0.5$. At $h=0.5$, the group to which the node belongs does not affect the node's decision to form connections. Between $0.5 \leq h \leq 1.0$, networks belong to the homophilic regime and at $h=1$ the network is considered to be completely homophilic, resulting in a disconnected graph.

\subsection{Synthetic Network Generation - Barabási-Albert Model}
\label{ba_model}
The Barabási-Albert model \cite{barabasi1999emergence} for generation of synthetic networks was proposed by Barabási and Albert in 1999. Previous network generative models like Erdős-Rényi model \cite{erdds1959random}, Gilbert's random graph model \cite{gilbert1959random} or Watts-Strogatz model \cite{watts1998collective} failed to capture the high degree consolidation effect (or the ``rich-getting-richer'' effect) appropriately. This was the first model which factored in both `growth' and `preferential attachment' as influencers to the formation of network graphs, factors which gave these generated networks the real-world perceived scale-free effect.

The generation process starts with a network having $m_{0}$ nodes. At each iteration $i$, a new node $v_{i}$ joins the network and forms $m \leq m_{0}$ edges with the existing nodes of the network ($V_{i-1}$). The probability of an existing node $u \in V_{i-1}$ to be chosen by the incoming node $v_{i}$ to form an edge with is given by equation \ref{ba_model_eq} where $\delta(x)$ denotes the degree of node $x$.

\begin{equation}
\label{ba_model_eq}
\Pi_{u} = \delta(u) / \sum_{w \in V_{i-1}}^{}\delta(w)
\end{equation}

As we can see from equation \ref{ba_model_eq} nodes having higher degrees in the network give a higher probability value, thus imitating the \textit{rich-getting-richer} effect seen in real-world networks.

This base model was extended to include the homophily parameter by several researchers \cite{karimi2018homophily,de2013scale,avin2015homophily}, with different approaches having varying degrees of similarities in them. For the purpose of this thesis we select the model by Karimi et. al. \cite{karimi2018homophily}. We go into details of this extended model in chapter \ref{recommender_methods} where we use this extended model for generation of our own synthetic networks.

\section{Reinforcement Learning}

Reinforcement Learning is a branch of machine learning which had been there for a long time, but only over the last decade has slowly started to gain popularity in the research community.

The basic setting for a reinforcement learning task is having an \textbf{Agent} $A$ which is capable of performing a set of actions $C_{A}$ in an \textbf{Environment} $E$. The agent $A$ learns via trial-and-error to optimize its actions from $C_{A}$ to perform a certain goal task $G$. For every action it takes inside the environment $E$, it is provided with a \textit{positive} or \textit{negative} reward based on some \textit{reward function} defined for the environment. This reward acts as a feedback for the agent and with time \textit{reinforces} the belief about which actions benefits it and which actions harms its cause. Thus the agent through exploration of the space provided to it can learn on its own how to perform a given task rather than being guided by some omniscient force. This kind of psychological reinforcement can be found in almost all kinds of human learning, making \textit{Reinforcement Learning} a part of the \textit{`Bio-inspired computing'} methods which have been enjoying huge popularity over the past few years.

\textit{Learning to Rank} is a specific task type in this kind of a learning setting where an AI agent is supposed to learn how to rank various items in order of their preference for a specific need. Ranking search query results is a popular `learning to rank' problem which has been solved previously using reinforcement learning techniques by several researchers \cite{radlinski2008learning,lattimore2018toprank}. In our thesis we take such methods and apply them to a completely novel setting of ranking nodes to recommend for a user-recommendation engine. What motivated us to do this, we have already talked about, in the introduction to our thesis (chapter \ref{introduction}).

In the following chapter along with the other recommender methods we will look into more detail at the reinforcement learning methods we use for our study.


% !TEX TS-program = xelatex
% !TEX encoding = UTF-8
% !Mode:: "TeX:UTF-8"

\documentclass[onecolumn,oneside]{SUSTechHomework}

\usepackage{float}

\author{胡玉斌}
\sid{11712121}

\title{Lab 10}
\coursecode{CS315}
\coursename{Computer Security}

\begin{document}
  \maketitle

  \section*{Task 1}

  We calculate the exgcd: $e \times d + \phi(n) \times y = 1$

  The Figure \ref{fig1} show how to calculate by python with \verb|sympy| package.

  d = 0X3587A24598E5F2A21DB007D89D18CC50ABA5075BA19A33890FE7C28A9B496AEB.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task1_1.png}
    \caption{exgcd}
    \label{fig1}
  \end{figure}

  \section*{Task 2}

  Encrypting the message with RSA to calculate $C = M^e$.

  $C = \mbox{0X6FB078DA550B2650832661E14F4F8D2CFAEF475A0DF3A75CACDC5DE5CFC5FADC}$

  To verify that, calculate $M=C^d~\mbox{mod}~n$.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task2_1.png}
    \caption{Encrypt}
  \end{figure}

  \section*{Task 3}

  Calculate $C^d$, we have $M = 0X50617373776F72642069732064656573$

  Decode by \verb|utf-8|, we get message \verb|Password is dees|

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task3_1.png}
    \caption{Decrypt}
  \end{figure}

  \section*{Task 4}

  We sign the message by calculating $S=M^d$

  We get $S=0X55A4E7F17F04CCFE2766E1EB32ADDBA890BBE92A6FBE2D785ED6E73CCB35E4CB$ when $M=\mbox{I owe you \$2000.}$

  We get $S=0XBCC20FB7568E5D48E434C387C06A6025E90D29D848AF9C3EBAC0135D99305822$ when $M=\mbox{I owe you \$3000.}$

  Although we change \verb|2000| to \verb|3000|, the signature $S$ is changed a lot.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task4_1.png}
    \caption{Sign}
  \end{figure}

  \section*{Task 5}

  If the signature is correct, sigen message is the same as actual message.

  But it the signature is wrong, the message is changed.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task5_1.png}
    \caption{Verify}
  \end{figure}

  \section*{Task 6}

  \subsection*{Step 1}

  Download a certificate from a real web server.

  We use the \verb|www.baidu.com| server.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_1.png}
    \caption{Step 1}
  \end{figure}

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_2.png}
    \caption{Step 1}
  \end{figure}

  \subsection*{Step 2}

  Extract the public key (e, n) from the issuer’s certificate.

  We have $n$ and $e=0x10001$ now.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_3.png}
    \caption{Step 2}
  \end{figure}

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_4.png}
    \caption{Step 2}
  \end{figure}

  \subsection*{Step 3}

  Extract the signature from the server’s certificate.

  We have $s$ now.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_5.png}
    \caption{Step 3}
  \end{figure}

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_6.png}
    \caption{Step 3}
  \end{figure}

  \subsection*{Step 4}

  Extract the body of the server’s certificate.

  We have $sha256sum$.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_7.png}
    \caption{Step 4}
  \end{figure}

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_8.png}
    \caption{Step 4}
  \end{figure}

  \subsection*{Step 5}

  Verify the signature.

  We find that the signature $s$ is the same as the result.

  \begin{figure}[H]
    \centering
    \includegraphics[width=0.85\textwidth]{img/task6_9.png}
    \caption{Step 5}
  \end{figure}

\end{document}


\label{GT:chapter}

We have so far assumed that the event organizer knows of or can query preferences and constraints of agents, but in some settings this may not be a realistic assumption. For instance, if agents are strategic, the organizer can no longer assume that agents will report their preferences and constraints truthful because lying may lead to a better outcome than telling the truth would.

In this chapter we investigate how strategic behavior of agents can complicate the problem of finding a stable solution.
We study the Anonymous Ordinal Invitations Problem (\AOIP) which is motivated by the Stable Invitations Problem. The term ``anonymous'' emphasizes that agents only care about size of invitations and ``ordinal'' emphasizes that agents do have ordinal preferences over sizes rather than binary preferences. Recall that agents have approval sets in the Group Activity Selection Problem and the Stable Invitations Problem, which reduces the computational complexity of these problems. In other words, we remove this assumption and assume that agents have ordinal preferences (such as total preorder) over sizes of invitations or assignments, then computational hardness results we obtained in previous chapters would still be applicable -- yet stronger hardness results may be obtainable.

The goals in previous chapters were to show that both \GASPs and \SIPs are computationally complex, even if we parameterized the problems and assumed restricted domains of preferences. In this chapter, we focus on understanding why finding a stable solution is difficult when agents act strategically; strategic behavior of agents is rooted at their preferences -- they act strategically in order to obtain the most preferred outcome possible. As such, we relax the assumption of approval sets and introduce ordinal preferences of agents over sizes of invitation or assignment, yet we begin with the simplest problem when agents have no friends or enemies. We then consider other restricted cases of \GASPs and \SIPs in turn. As we shall see, in many cases, it is impossible to incentivize agents to act truthfully while be capable of finding a stable solution at the same time.

\paragraph{Related Work.}
We refer to our discussions of related work in Chapter~\ref{GASP:chapter} and \ref{SIP:chapter}.

\section{Definitions and Notation} \label{GT:sec:prelim}

Let us formally define the Anonymous Ordinal Invitations Problem (\AOIP).
Recall that in \GASPs and \SIPs we assumed that agents are indifferent among any approved size of a solution -- which is a simplifying assumption that makes the problems computationally less complex, but most of technical results were hardness results. Yet the problems are still well-defined even though we assume that agents have ordinal preferences over sizes of a solution. In this chapter, agents are not necessarily indifferent among all sizes that are acceptable to them.

\begin{definition}
An instance of the Anonymous Ordinal Invitations Problem (\AOIP) is given by a set of agents $N = \{1, 2, \dots, n\}$ and a preference $P_i$ for each agent $i\in N$. $P_i$ is defined as a total preorder ($\succeq_i$) on the set of outcomes, $x = \{0, 1, 2, \dots, n\}$. An outcome $x\in (X\setminus\{0\})$ denotes the number of attendees and $x = 0$ is a special outcome of not attending.
For any $x_1, x_2\in (X \setminus\{0\})$, $x_1 \succeq_i x_2$ is interpreted as agent $i$ weakly preferring attending the event if $x_1$ attendees are present (including herself) to attending if $x_2$ attendees are present (including herself).
We use $\succ_i$ and $\sim_i$ to denote the induced strict preferences and indifference relations, respectively.
We drop the subscript ($i$) if it is clear from the context.
\end{definition}

We assume that for each $i$ and each $x\in (X\setminus\{0\})$, either $x \succ_i 0$ or $0 \succ_i x$. That is, no agent is indifferent between not attending and any other outcome. This assumption is made for convenience and does not change our technical results.

It is worth noting that in previous chapters we assumed that agents have ``approval sets'' rather than ordinal preferences over outcomes. For \GASPs and \SIPs, this simplifying assumption strengthens hardness results in complexity as they immediately imply the same hardness results for the general case without this assumption. On the other hand, in this chapter, we assume ordinal preferences, and it is an interesting future problem how the results shown in this chapter change if we make this simpliyfing assumption on \AOIP.

Let us define solution concepts of \AOIP.

\begin{definition} \label{GT:def:invitation}
Given an instance of \AOIP, an \emph{invitation} $I$ is a subset of $N$, and is interpreted as the organizer inviting the agents in $I$.

An invitation $I$ is said to be \emph{individually rational} (IR) if for every agent $i\in I$ it holds that $|I| \succ_i 0$.

An invitation $I$ is said to be \emph{(Nash) stable}ß if for every agent $j\not\in I$ it holds that $|S \cup \{j\}| = (|I| + 1) \prec_j 0$ and $I$ is individually rational as well.
\end{definition}
Individual rationality requires that every agent who is invited be willing to participate. In addition, stability further requires that every agent who is not invited be unwilling to participate (even without permission of others).

For each agent $i$, we can naturally induce from $P_i$ her preference over the set of all invitations.
Given $I$ and $I'$, if both contain $i$, then the preference relation between $I$ and $I'$ is induced from $P_i$ on $|I|$ and $|I'|$ (their cardinality). If neither contains $i$, then both invitations are equivalent to $0$ (the outside option). If $I$ contains $i$ and $I'$ does not, then the preference relation is induced from $P_i$ on $|I|$ and $0$.
We overload our notation ($\sim_i, \succeq_i, \succ_i$) for the induced preferences over invitations.
The preferences of agents over invitations are now well-defined.

Let us define two special classes of preferences of agents, increasing (\INC) and decreasing (\DEC). Informally, agents with \INC-preferences (\DEC, respectively) prefer the event with more attendees (fewer, respectively). In particular \INC-preference implies that $n$ is the most favorable outcome and \DEC-preference that $1$ is the most favorable outcome.
\begin{definition}\label{GT:def:preferenceTypes}
Agent $i$ has an \INC-preference if there is some threshold $l_i$ such that
$n \succeq_i (n-1) \succeq_i \cdots \succeq_i (l_i) \succ_i 0 \sim k$ for all $1 \leq k < l_i$.
Agent $i$ has a \DEC-preference if there is some threshold $h_i$ such that
$1 \succeq_i 2 \succeq_i \cdots \succeq_i (h_i) \succ_i 0 \sim k$ for all $h_i < k \leq n$.
\end{definition}
We assume that agents can have arbitrary preferences, but these two special types of preferences play an important role in the strategic case as we shall discuss in Section~\ref{GT:sec:Mechanism}.

To help the reader understand the setting and notation, let us present two small examples of \AOIP.

\begin{example}[Stable invitations are not unique] \label{GT:eg:multiple_stable}
	Let us consider two agents with identical preferences:
	\begin{equation*}
				P_1: 1 \succ 0 \succ 2,~~~ P_2: 1 \succ 0 \succ 2.
	\end{equation*}
	Note that both agents have \DEC-preferences (with $h_1 = h_2 = 1$).
	The two stable invitations are $I_1 = \{1\}$ and $I_2 = \{2\}$.
	The empty invitation ($\emptyset$) is not stable as both agents have $1 \succ 0$ while the full invitation ($N$) is not IR.
\end{example}

\begin{example}[A stable invitation may not exist] \label{GT:eg:noStableSet}
	Let us consider three agents with the following preferences:
	\begin{equation*}
				P_1: 3\succ 2 \succ 0 \succ 1,~~~ P_2: 1 \succ 0 \succ 2 \sim 3,~~~ P_3: 0 \succ 1 \sim 2 \sim 3.
	\end{equation*}
	Note that $1$ has an \INC-preference (with $l_1 = 2$) while $2$ has a \DEC-preference (with  $h_2 = 1$). $3$ is simply unwilling to attend the event (no outcome is acceptable to her).
	Due to $3$, any invitation including $3$ is not IR. Between $1$ and $2$ only, the empty invitation is not stable due to $2$, $S_1 = \{1\}$ is not IR due to $1$, $S_2 = \{2\}$ is not stable due to $1$, and $\{1, 2\}$ is not IR due to $2$.
\end{example}

Let us formally define a deterministic mechanism in the context of \AOIPs with strategic agents, and define what constitutes a strategy-proof mechanism. We later discuss in Section~\ref{GT:sec:randomized} why our technical results do not change when we consider randomized mechanisms.

\begin{definition} \label{GT:def:mechanism}
Given an instance of \AOIP, we define $V_i$ (the set of available actions to $i$) to be the set of all preferences over $X$ where $X = \{0, 1, 2, \dots, n\}$ is the set of outcomes.
A (deterministic) \emph{mechanism} $\mathcal{M}$ is a pair $(V, Z)$ where $V = (V_1 \times \cdots \times V_n)$ is the set of action profiles of all agents (i.e., $V_i$ is a subset of total preorder on $X$) and $Z: V \mapsto U$ is a mapping from each action profile to an invitation in $U$ where $U = 2^{N}$.
Let $V_{-i} = (V_1 \times \cdots \times V_{i-1} \times V_{i+1} \times \cdots \times V_{n})$ be the set of action profiles available to all agents but agent $i$. A mechanism $(V, Z)$ is said to be \emph{strategy-proof} if for all $i\in N$ it holds that $Z(P_i, v_{-i}) \succeq_i Z(v_i, v_{-i})$ for all $v_i \in V_i$ and $v_{-i} \in V_{-i}$.
\end{definition}

In words, mechanism $\mathcal{M}$ is strategy-proof if for every agent $i\in N$, truth-telling is a dominant strategy for any against any strategy profile of other agents given any type of agent $i$ (i.e., any preference of $i$). Thanks to the dominant-strategy revelation principle, we only need to consider direct mechanism in which agents simply report their types. For more details on this topic, Algorithmic Game Theory by Nisan et. al~\cite{nisan2007algorithmic} is a great resource (in particular, pages 224--225).

\section{Mechanisms and Strategic Agents} \label{GT:sec:Mechanism}
In this section we present several technical results on how strategic agents can affect finding stable solutions.

Our first result is an impossibility result on \AOIP.

\begin{theorem} \label{GT:thm:impossibility}
No strategy-proof mechanism can find a stable invitation (even if it exists) given arbitrary instances of \AOIPs when the number of agents is at least two.
\end{theorem}
\begin{proof}
Example~\ref{GT:eg:multiple_stable} can serve as a proof. Consider the two agents with identical preferences from the example:
	\begin{equation*}
		\begin{aligned}
				P_1: 1 \succ 0 \succ 2,~~~& P_2: 1 \succ 0 \succ 2
		\end{aligned}
	\end{equation*}
	Recall that $I_1 = \{1\}$ and $I_2 =\{2\}$ are the only two stable invitations provided that both agents are truthful.

	Let $\mathcal{M} = (V, Z)$ be any (deterministic) mechanism.
	If $Z(P_1, P_2) = I_1$, then $2$ would have an incentive to act strategically, by reporting $\hat{P}_2 (1 \succ 2 \succ 0)$ instead of $P_2$.
	Given $(P_1, \hat{P}_2)$, the only stable invitation is $I_2$.
	Notice that $2$ strictly prefers $I_2$ over $I_1$ (because $1 \succ_2 0$) and has an incentive to misreport in this example. By symmetry, $1$ may act strategically if $I_2$ were to be chosen (i.e., $Z(P_1, P_2) = I_2$).
	Therefore, no mechanism can be strategy-proof and able to find a stable invitation in this example at the same time.
\end{proof}

Intuitively, this can be explained by conflicting interests of the organizer and agents -- the organizer is trying to maximize attendance while the agents (with \DEC-preferences) to minimize.
This intuition begs the question: What if all agents have \INC-preferences instead?
When all agents have \INC-preferences, we obtain a positive result in this case as Theorem~\ref{GT:thm:mechanism} states.

\begin{theorem} \label{GT:thm:mechanism}
	There is a strategy-proof mechanism for \INC-instances of \AOIP, which can also find a stable invitation in linear time and its size is maximum among all stable invitations.
\end{theorem}
\begin{proof}
For simplicity, let us assume that each agent reports her threshold value (i.e., $l_i$ as defined in Definition (to be added)) as $L_i$ ($L_i$ may differ from $l_i$). Our mechanism then chooses the largest $k$ such that $L_k \leq k$ holds and chooses the set of $k$ agents with largest threshold values (if no such $k$ exists, mechanism chooses the empty invitation). Algorithm~\ref{alg:mechanism} describes this mechanism.
\begin{algorithm}
	\caption{Strategy-proof Mechanism}
	\label{alg:mechanism}
\begin{algorithmic}[1]
	\State \textbf{Input:} $(N, \{L_i\})$ ~ // Assume $\{L_i\}$ is sorted in non-increasing order.
	\For{$k := n, n-1, n-2, \dots, 2, 1$}
		\If{$L_k \leq k$}
			\State \textbf{return} $I = \{1, 2, \dots, {k-1}, {k}\}$
		\EndIf
	\EndFor
	\State \textbf{return} $I = \emptyset$
\end{algorithmic}
\end{algorithm}

We first show that the invitation $I$ that is returned by the mechanism in line 4 is always stable (with respect to the reported threshold values, $\{L_i\}$). If the mechanism returns $I$ in line 4, we know that it contains precisely $k$ agents (i.e. $k = |I|$). Since we sorted the threshold values of agents, for each $i \in I$ we know that $L_i \leq L_k \leq k$, which implies that $I$ is individually rational. To see why $I$ is envy-free, for any agent $j\not\in I$ we know that $j > k$ (otherwise $j\in I$) and that $L_j \geq L_k$ (because we sorted threshold values). Furthermore, since the mechanism did not return an invitation in line 5 during the iteration when $k = j$ (recall that $k$ is iterating in decreasing order), this implies that $L_j > j$ for all $j > k$ (otherwise the mechanism would have returned a different invitation and terminated). Therefore for any $j\not\in I$, we conclude that $L_j > j > k$, which implies $L_j \geq k+2$. Therefore $j$ is envy-free of $I$ because $L_j > |I| + 1$ (i.e. even if $j$ joins $I$, it is still not preferred to her outside option). Therefore if the mechanism returns any invitation in line 5, then it is stable. Now suppose the mechanism does not return any invitation in line 5, but it eventually returns the empty invitation in line 9. Then $I = \emptyset$ must be stable; it is individually rational by definition. It is also envy-free because we know that $L_k > k$ for all $k \geq 1$, which implies that $L_k > 1$ for all $k$. Therefore an empty invitation is stable in this case.

	Next we show that the mechanism indeed returns a maximum stable invitation given truthful threshold values (if it exists). Let $I^*$ be a maximum stable invitation, and let us focus on the iteration when $k = |I^*|$. We claim that the mechanism will return a stable invitation of size $k$.  Since $I^*$ is a stable invitation, we know that for all $i\in I^*$, it holds that $L_i \leq |I^*| = k$. Therefore, when the threshold values are sorted, this implies that $L_j \leq k$ for all $j\leq k$; in particular, $L_k \leq k$. Therefore the mechanism executes lines 3-4, and returns an invitation $I$ of size $k$.  In the case where the maximum stable invitation is empty, the mechanism will clearly return an empty invitation (because we have shown that the mechanism only returns a stable invitation, it would not return any invitation in line 5 but eventually execute line 9).

	Finally we show that the mechanism is strategy-proof. To show this, we will show that truth-telling is a weakly dominant strategy for any agent.
	Let us consider some fixed agent $i$ and also fix the action profile of the remaining agents to be $L_{-i}$ (which may or may not be truthful).
	Let us assume that the mechanism sorts the threshold values $(L_i, L_{-i})$ as $L_1 \leq L_2 \leq \cdots \leq L_{i-1} \leq L_i \leq L_{i+1} \leq \cdots \leq L_n$ (since we argue for an arbitrary agent $i$, this assumption can be made without loss of generality).
	Let $I_L$ denote the invitation returned by the mechanism given $(l_i, L_{-i})$ and let $k_L = |I_L|$ (i.e. when $L_i = l_i$ and thus $i$ is truth-telling).

	We first consider the case where $i$ over-reports.  That is, we consider an action profile $(v_i, L_{-i})$ where $v_i > l_i$. Given $(v_i, L_{-i})$, let $M_1 \leq M_2 \leq \cdots \leq M_{n}$ denote the sorted list of the threshold values (we use $M$ to distinguish from the case where $i$ reported truthfully). Let $I_M$ denote the invitation returned by the mechanism given $(v_i, L_{-i})$ and let $k_M = |I_M|$. Between the two action profiles $(l_i, L_{-i})$ and $(v_i, L_{-i})$, the only difference (in terms of the threshold values) is between $l_i$ and $v_i$. Since $v_i > l_i$, we know that $L_j \leq M_j$ for all $j$ and in particular that $L_{k_M} \leq M_{k_M}$. If we show that $k_M \leq k_L$, then it implies that $i$ has no incentive to over-report because $i$ has an \INC-preference (hence $i$ weakly prefers $I_L$ to $I_M$). Suppose $k_M > k_L$ instead. Since the mechanism returns an invitation of size $k_M$ given $(v_i, L_{-i})$, we know by our construction that $M_{k_M} \leq k_M$, which in turn implies $L_{k_M} \leq k_M$ (because $L_{k_M} \leq M_{k_M}$). However, since the mechanism returns an invitation of size $k_L$ given $(l_i, L_{-i})$, this implies that $L_j > j$ for all $j > k_L$ and in particular that $L_{k_M} > k_M$.  This is a contradiction, and we conclude that $k_M \leq k_L$ if agent $i$ over-reports with $v_i > l_i$.

	Next we consider the case where $i$ under-reports. Similarly to the previous case, we consider an action profile $(v_i, L_{-i})$ where $v_i < l_i$. Given $(v_i, L_{-i})$, let $M_1 \leq M_2 \leq \cdots \leq M_{n}$ denote the sorted list of the threshold values (we use $M$ to distinguish from the case where $i$ reported truthfully). Let $I_M$ denote the invitation returned by the mechanism given $(v_i, L_{-i})$ and let $k_M = |I_M|$. Between the two action profiles $(l_i, L_{-i})$ and $(v_i, L_{-i})$, the only difference (in terms of the threshold values) is between $l_i$ and $v_i$. Since $v_i < l_i$, we know that $M_j \leq L_j$ for all $j \leq i$ and that $M_j = L_j$ for all $j > i$.

	We consider two sub-cases of under-reporting and show that in both cases $i$ has no incentive to under-report.  The easier case is when $i \in I_L$. We show that in this case $|I_M| = k_M \leq k_L = |I_L|$. Suppose $k_M > k_L$ instead. Since $i \in I_L$, this implies that $k_L \geq i$ (because we assumed that $L_j < L_i = l_i$ for all $j < i$). Since the mechanism returns an invitation of size $k_M$ given $(v_i, L_{-i})$, we know by our construction that $M_{k_M} \leq k_M$. Yet we showed earlier that $M_j = L_j$ for all $j > i$, which in particular implies that $M_{k_M} = L_{k_M}$ because $k_M > k_L \geq i$. However the mechanism returns an invitation of size $k_L$ given $(l_i, L_{-i})$, which implies that $L_j > j$ for all $j > k_L$ (and in particular, $L_{k_M} > k_M$). This is a contradiction, and we conclude that $k_M \leq k_L$ if $i$ under-reports and $i\in I_L$.

	Next we consider the other sub-case where $i$ under-reports and $i\not\in I_L$. We will show that $|I_M| = k_M < l_i$, which means that the invitation returned by the mechanism when $i$ under-reports is not preferred to her outside option of not attending, and therefore $i$ has no incentive to under-report. Suppose $k_M \geq l_i$ instead. Since $i \not\in I_L$, we know that $k_L < i$ and that $l_i > i$ (otherwise the mechanism would have returned an invitation of size $i$ or larger given $(l_i, L_{-i})$). Therefore $k_M \geq l_i$ implies that $k_M > i$. Since the mechanism returns $I_M$ given $(v_i, L_{-i})$, we know that $M_{k_M} \leq k_M$. However the mechanism given $(l_i, L_{-i})$ returns an invitation of size $k_L < i$, which implies that $L_{k_M} > k_M$. We earlier showed that $L_j = M_j$ for all $j > i$ if $i$ under-reports, and in particular we have that $L_{k_M} = M_{k_M}$. Since $L_{k_M} > k_M$ and $M_{k_M} \leq k_M$, this is a contradiction, and we conclude that if $i$ under-reports and $i\not\in I_L$ then $|I_M| = k_M < l_i$.

	In all cases we have shown that truth-telling is a weakly dominant strategy for $i$ regardless of what the remaining agents report. Therefore the mechanism is strategy-proof.  Combined with our previous arguments, this shows that the mechanism is able to find a maximum stable invitation (provided that all agents play their weakly dominant strategy, truth-telling). It is worth noting that sorting the reported threshold values of agents can be done in linear time as the values are ranged in $[0, n+1]$.
\end{proof}

Ahe assumption that all agents have \INC-preferences may seem restrictive to be realistic at a first glance. However, when the B.E. Journal of Theoretical Economis was first incepted in year 2000, the founders encouraged a small group of prominent economists to contribute to the journal while being exempted from usual refereeing obligation.\footnote{We thank Professor Matthew O. Jackson from the Department of Economics at Stanford University for sharing this story.} However, as the participants may be unsure about the quality of the journal, they asked each economist to report a number $x$ such that their participation is contioning on the event that at least $x$ other economists agreeing to participate. Clearly, given the list of fellow economists, all economists have \INC-preferences. Given responses from 72 economists on the list, the founders would find a largest stable set of economists who agree to participate (using the same method as the mechanism we described in proof of Theroem~\ref{GT:thm:mechanism}). This anecdote demonstrates that such restrictions on prefence domain of agents are still applicable in real world settings, and ecaping from impossibility results by considering special cases can be practical.

Recall that \AOIPs is a special case of \GASPs and \SIPs as there is only one activity and no friends or enemies in \AOIPs instances. As such, our impossibility results are applicable to \GASPs and \SIPs if ordinal preferences of agents are assumed. In addition, let us consider two other special cases of these two problems for which similar impossibility results hold.

We learned that when all agents have \INC-preferences, there exists a strategy-proof mechanism that can find a maximum stable invitation in linear time. However, this mechanism cannot be generalized to the cases where there are two or more activities even if all agents have \INC-preferences for each of the activities. Although we did not formally define a mechanism in the context of \GASP, one can easily generalize Definition~\ref{GT:def:mechanism} such that a (deterministic) mechanism takes preferences of agents (over all activities), and produces an assignment of agents to activities.
\begin{theorem} \label{GT:thm:impossibility_inc_gasp}
No strategy-proof mechanism can find a stable assignment (even if it exists) given arbitrary instances of \GASPs even if all agents have \INC-preferences for all activities.
\end{theorem}
\begin{proof}
Consider two agents $N = \{1, 2\}$ and two activities $A^* = \{a_1, a_2\}$.
	\begin{equation*}
		P_1: (a_1, 2) \succ (a_2, 2) \succ (a_1, 1) \succ \void, ~~~
		P_2: (a_2, 2) \succ (a_1, 2) \succ (a_2, 1).
	\end{equation*}
In this setting, out of nine possible assignments (each agent being assigned to one of $\{\void, a_1, a_2\}$), there are three stable assignments: $\pi_1$ which assigns both agents to $a_1$, $\pi_2$ which assigns both agents to $a_2$,and $\pi_3$ which assigns $1$ to $a_1$ and $2$ to $a_2$.
The induced preference over these three assignments can be determined from each agent's preference:
	\begin{equation*}
		\pi_1 \succ_1 \pi_2 \succ_1 \pi_3, ~~~
		\pi_2 \succ_2 \pi_1 \succ_2 \pi_3.
	\end{equation*}
Although there are three stable assignments, a mechanism cannot choose any one of them while incentivizing the agents to act truthfully.

If a mechanism chooses $\pi_1$ given $(P_1, P_2)$, then agent $2$ has an incentive to lie about her preferences by reporting $\hat{P}_2: (a_2, 2) \succ_2 (a_2, 1) \succ_2 \void$ instead (by not approving $(a_1, 2)$ anymore). Given $(P_1, \hat{P}_2)$, the mechanism must now choose $\pi_2$ which is the only stable assignment.
By symmetry, the mechanism cannot choose $\pi_2$ because of agent $1$.
Lastly, if the mechanism chooses $\pi_3$, then now both agents have incentives to lie. For instance, agent $1$ can report $\hat{P}_1 = (a_1, 2) \succ_1 (a_2, 2) \succ_1 \void$ instead, and $\pi_1$ and $\pi_2$ become the only stable assignments given $(\hat{P}_1, P_2)$ -- notice that agent $1$ prefers both $\pi_1, \pi_2$ to $\pi_3$.

This shows that, even if all agents have \INC-preferences for all activities, it is impossible to achieve strategy-proofness and stability of a solution at the same time.
\end{proof}

We also learned that agents having non-\INC-preferences (such as \DEC-preferences) lead to impossibility of designing strategy-proof mechanisms. An interesting special case of \SIPs is when all agents approve all sizes of invitations and prefer all sizes equally and have no friends at all. In other words, agents only have enemy relationships in this special case, and sizes of an invitation or friends do not matter at all. This is a very restrictive domain of preferences, yet we obtain a similar impossibility result for this special case. Although we did not formally define a mechanism in the context of \SIP, one can easily generalize Definition~\ref{GT:def:mechanism} such that a (deterministic) mechanism takes an enemy set of each agent, and produces an invitation.

\begin{theorem} \label{GT:thm:impossibility_only_enemies}
No strategy-proof mechanism can find a stable invitation (even if it exists) given arbitrary instances of \SIPs even when all agents approve all sizes of invitations and all agents have empty friend sets.
\end{theorem}
\begin{proof}
Consider two agents who do not like each other (while $F_1=F_2=\emptyset$ and both agents approve any size of an invitation):
	\begin{equation*}
			R_1 = \{2\}, ~~~ R_2 = \{1\}.
	\end{equation*}
	Clearly, the only stable invitations are $I_1 = \{1\}$ and $I_2 = \{2\}$.
	Let $\mathcal{M} = (V, Z)$ be any (deterministic) mechanism.
	If $Z(R_1, R_2) = I_1$, then $2$ would have an incentive to act strategically, by reporting $\hat{R}_2 = \emptyset$ instead of $R_2$. Given $(R_1, \hat{R}_2)$, $I_1$ is no longer stable, and therefore the mechanism must choose $I_2$. By symmetry, an analogous argument applies if $Z(R_1, R_2) = I_2$. This concludes the proof.
\end{proof}

Lastly, one may wonder whether finding an individually rational invitation in \AOIPs is possible while incentivizing agents. Unfortunately, the following theorem gives another impossibility result.

\begin{theorem} \label{GT:thm:impossibility_IR}
	No strategy-proof mechanism can find a non-empty individually rational (IR) invitation, even if it exists, for arbitrary instances of \AOIP.
\end{theorem}
\begin{proof}
Consider three agents with preferences as follows:
\begin{equation*}
			P_1: 3\succ 0 \succ 2 \sim 1,~~~ P_2: 2 \succ 3 \succ 2 \succ 1,~~~ P_3: 3 \succ 2 \succ 0 \succ 1
\end{equation*}
There are two non-empty IR invitations: $I_1 = \{1, 2, 3\}$ and $I_2 = \{2, 3\}$.
If a mechanism chooses $I_1$ given $(P_1, P_2, P_3)$, $2$ can report $(2 \succ 0 \succ 3 \sim 1)$ and make $I_2$ the only non-empty IR invitation. Similarly, if a mechanism chooses $I_2$ given $(P_1, P_2, P_3)$, $3$ can report $(3 \succ 0 \succ 2 \sim 1)$ so as to make $I_3$ the only non-empty IR invitation. Therefore no mechanism can be strategy-proof and capable of finding IR invitations at the same time.
\end{proof}

\subsection{Randomized Mechanisms} \label{GT:sec:randomized}
Although we have so far only discussed deterministic mechanisms, our impossibility results can be extended to randomized mechanisms. First we define $Z$ to be a mapping from $V$ to $\Pi(U)$ where $\Pi(U)$ denotes the set of all probability distributions over $U$. The definition of a strategy-proof mechanism must change accordingly -- we do this by adopting the axioms in the von Neumann-Morgenstern utility theorem~\cite{von1947theory}. We introduce lotteries over invitations and define preferences of agents over lotteries. Given a probability distribution over invitations, one can compute the expected cardinal utility of lotteries. We then define a strategy-proof mechanism analogously to Definition~\ref{GT:def:mechanism}: for each $i$, it must hold that the expected utility of $Z(P_i, v_{-i})$ is no less than the expected utility of $Z(v_i, v_{-i})$ for all $v_i\in V_i$ and for all $v_{-i} \in V_{-i}$. The impossibility result given by Theorem~\ref{GT:thm:impossibility} still holds: If $(V, Z)$ is a strategy-proof mechanism, then $Z(P_1, P_2)$ must assign zero probability to both $\{1\}$ and $\{2\}$, yet these are the only two stable invitations.  All other impossibility results we mention in this work can be extended in this manner.

\section{Discussion}

While we focused on designing algorithms or proving computational hardness results in previous chapters, the focus of this chapter is on mechanism design and impossibility results (much like computational hardness results). In mechanism design theory, the objective is to design a mechanism which is given an action profile of all agents and chooses an outcome (which can be probabilistic) such that the mechanism satisfies certain properties. One of the most important properties is incentive compatibility -- agents must be incentivized to act in a certain way (such as truth-telling) because no agent can be better off by acting in a different way. In many settings, utilities of agents may be transferable (such as money), which provides ways to compensate for agents who end up with less desirable outcomes. However, in social settings like the group scheduling and assignment problems, it is more reasonable to assume that utilities of agents are assumed to be non-transferable, and therefore it is not possible to compensate agents for any outcome.

Our impossibility results reveal interesting aspects of preferences of agents which prevent us from obtaining strategy-proof mechanisms.  Theorem~\ref{GT:thm:impossibility} shows that agents not having \INC-preferences play an important role in \AOIP. This motivated us to consider the case where all agents have \INC-preferences, and we were able to obtain an optimal, strategy-proof mechanism that is described in blah.
However, as Theorem~\ref{GT:thm:impossibility_inc_gasp} shows, this mechanism does not extend to the cases where two or more activities are present. Despite all agents having \INC-preferences, agents' preferences over different activities play a crucial role in this case. Lastly, we learned from Theorem~\ref{GT:thm:impossibility_only_enemies} that agents having enemies also lead to impossibility results even if agents are indifferent among sizes of solutions and friends and there is only one activity. Enemy relationship introduces combinatoric complexity in the solution space, which was observed in previous chapters as well when we investigated complexity of these problems. It is worth noting that our impossibility results are not directly implied by Arrow's impossibility theorem~\cite{arrow2012social} or the Gibbard–Satterthwaite theorem~\cite{gibbard1973manipulation,satterthwaite1975strategy} because the domains of preferences of agents we consider in this work are restricted.

Although our findings answer many questions about how strategic behavior of agents affect our ability to find desirable solutions, we are left with several interesting open questions. We presented several impossibility results yet only one positive result on strategy-proof mechanisms. It will be interesting to see if there is a different, natural restriction on preferences of agents which leads to a strategy-proof mechanism. Also, we only considered dominant-strategy incentive-compatibility in this work, but it's a natural follow-up problem to see whether our impossibility results are still applicable in the context of Bayesian-Nash incentive-compatibility (see pages 233--234 of Algorithmic Game Theory by Nisan et. al~\cite{nisan2007algorithmic}, for instance).

\section*{Publications}
Some of the contents of this chapter were published and included in the proceedings of the Twenty-ninth AAAI Conference on Artificial Intelligence  (AAAI)~\cite{LEE15AAAI}.


\documentclass{article}
\usepackage{amsmath,amssymb,enumerate,algorithm,algorithmic}
\title{ThreadGo: A multithreaded hybrid acceleration of the matrix multiplication}
\author{
by Shrohan Mohapatra \\
Email ID: shrohanapple@gmail.com
}
\begin{document}
\maketitle

\section{Introduction}

There have been several formal algorithmic attempts towards the optimisation of the matrix multiplication, some focussing on exploration of bilinear and trilinear algorithms \cite{strassen, schonhage, coppersmith, kleinberg, williams}, and others being averse to calculate the matrix multiplication \cite{raz}. The fastest known algorithm for matrix multiplication is the one given by Le Gall \cite{legall} which is of complexity $O(n^{2.3728639})$. But what lies in the hindsight of such theoretical algorithm designs is that

\begin{enumerate}
	\item Post-Strassen sub-cubic matrix multiplication algorithms are \textit{mere approximations}. These show an asymptotic possibility of the tensor power of a certain algebraic identity to work out that way.
	\item Also, the complexity of these algorithms often do not imply their pragmatic applicability because the associated constant of proportionality is \textit{estimably large}, which may render these slower than the existing \textit{asymptotically slower} algorithms.
\end{enumerate}

The current fastest \textit{serial algorithm} for matrix multiplication popular in the commercial domain is the Strassen's algorithm, which is known to run fairly faster than the standard school-book algorithm. Many cache-aware and cache-oblivious algorithm designs have been proposed \cite{skeina, harald, lam} in order to accelerate the process of matrix multiplication in a single core. To improve further upon the computational aspect of the same, many parallel and distributed versions \cite{randall,irony, kak} of the school book algorithm have been suggested.

In this Python 3.7 package "ThreadGo", I have tried the implementation of a hybrid matrix multiplication algorithm that switches between the multithreaded versions of the Strassen's algorithm and the naive definition as per the availability of the virtual memory to the program. The package assumes significant number of cores for the platform and innocently launches scalable number of threads into the environment in an attempt to parallelise the \textit{sequential independent} sections of the individual algorithms. One could easily explain the design formally using the \textit{cellular automata based approach} \cite{shrohan} but that would unnecessarily complicate the overall mathematical foundations. So in the subsequent sections of this documentation, I would sketch the pen portrait of the strategy of parallelization of the respective sections of the algorithm.

\section{Parallelization of the school book algorithm}

The mathematical definition of the multiplication of two $n \times n$ matrices $A_{i,j}$ and $B_{i,j}$ is as follows

\begin{equation}
(AB)_{(i,j),1 \leq i \leq n,1 \leq j \leq n} = \sum_{k=1}^{n} A_{i,k} B_{k,j}
\end{equation}

\begin{algorithm}
\caption{Naive matrix multiplication}
\label{schoolbook}
\begin{algorithmic}
\REQUIRE Input $n \times n$ matrices $A$ and $B$
\ENSURE Output matrix $C = A \times B$
\STATE $C$ \leftarrow $[[0,0,0,0, \cdots (n \text{ times}) \cdots 0],\cdots (n \text{ times}) \cdots,[0, \cdots (n \text{ times}) \cdots 0]]$
\FOR{$i=1;i \leq n;i++$}
\FOR{$j=1;j \leq n;j++$}
\FOR{$k=1;k \leq n;k++$}
$C[i][j] \leftarrow C[i][j] + A[i][k] * B[k][j]$ \label{line1}
\ENDFOR
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}

A simple pseudocode of the direct definition-based implementation has been shown in algorithm \ref{schoolbook}. But one can notice that line \ref{line1} in algorithm \ref{schoolbook}, i.e. the operation $C[i][j] \leftarrow C[i][j] + A[i][k] * B[k][j]$ is trivially the only \textit{sequential independent} part of the code. What the ThreadGo package does is very simple; it launches $n^3$ threads that perform the updation $C[i][j] \leftarrow C[i][j] + A[i][k] * B[k][j]$ for all 3-tuples $(i,j,k), 1 \leq i \leq n, 1 \leq j \leq n, 1 \leq k \leq n$. So even though the number of threads grows in $O(n^3)$, the time complexity of the parallel algorithm is $O(1)$.

\section{Parallelization of the Strassen's algorithm}

In the Strassen's algorithm, the input $n \times n$ matrices $A$ and $B$ and the output $n \times n$ matrix $C$, is broken into 12 $\frac{n}{2} \times \frac{n}{2}$ sub-matrices as follows.

\begin{equation}
A = \begin{pmatrix}
A_{11} & A_{12} \\
A_{21} & A_{22} \\
\end{pmatrix}
\end{equation}

\begin{equation}
B = \begin{pmatrix}
B_{11} & B_{12} \\
B_{21} & B_{22} \\
\end{pmatrix}
\end{equation}

\begin{equation}
C = \begin{pmatrix}
C_{11} & C_{12} \\
C_{21} & C_{22} \\
\end{pmatrix}
\end{equation}

Then the algorithm calls itself seven times recursively with the following multiplicands.

\begin{aligned}
M_1 = (A_{11}+A_{22})(B_{11}+B_{22}) \\
M_2 = (A_{21}+A_{22})B_{11} \\
M_3 = A_{11}(B_{12}-B_{22}) \\
M_4 = A_{22}(B_{21}-B_{11}) \\
M_5 = (A_{11}+A_{12})B_{22} \\
M_6 = (A_{21}-A_{11})(B_{11}+B_{12}) \\
M_7 = (A_{12}-A_{22})(B_{21}+B_{22}) \\
\end{aligned}

\vspace{3mm}

From the products $M_1, M_2, \cdots M_7$, the components of the matrix product are calculated.

\begin{aligned}
C_{11} = M_1 + M_4 - M_5 + M_7 \\
C_{12} = M_3 + M_5 \\
C_{21} = M_2 + M_4 \\
C_{22} = M_1 - M_2 + M_3 + M_6 \\
\end{aligned}

\vspace{3mm}

If one were to follow the Strassen's algorithm in its serial mode, the time complexity $T_{serial}(n)$ follows the recurrence relation

\begin{equation} \label{equation1}
T_{serial}(n) = 7 \cdot T_{serial}\bigg(\frac{n}{2}\bigg) + k_1 n^2
\end{equation}

$k_1$ being a constant. From Master's theorem, $T_{serial}(n) = O(n^{log_2 7})$. In ThreadGo, two aspects of the code are scalably multi-threaded.

\begin{enumerate}
	\item The seven recursive matrix multiplication procedure calls to calculate the product $M_1, M_2, \cdots M_7$.
	\item Basic completely parallelizable matrix operations such as initialisation, addition, subtraction etc.
\end{enumerate}

Hence the time complexity of the scalably parallel version of Strassen's algorithm $T_{parallel}(n)$ follows the recurrence relation

\begin{equation}
T_{parallel}(n) = T_{parallel}\bigg(\frac{n}{2}\bigg) + k_2
\end{equation}

$k_2$ being another constant. From Master's theorem, $T_{parallel}(n) = O(log(n))$. Also the number of threads $F(n)$ follows a recurrence relation similar to that in equation \ref{equation1},

\begin{equation}
F(n) = 7 \cdot F\bigg(\frac{n}{2}\bigg) + k_3 n^2
\end{equation}

$k_3$ being yet another constant. So the complexity of ThreadGo based implementation of the Strassen's algorithm in terms of the number of threads is $O(n^{log_2 7})$. Even though the number of threads are asymptotically less, in a pragmatic setup, the number of recursive calls and subsequent thread joins take more time than the parallel version of the naive implementation, which actually accosts to a lot of thread switching time, thus having an adverse effect of the total time. Thus, ThreadGo makes a "switch" of the algorithms at certain input size from the parallel version of the Strassen's algorithm to that of the naive implementation.

\section{A deeper insight to ThreadGo}

\subsection{How to install}

Installation is completely hassle-free; just download the ThreadGo package, root it to your favourite folder, and import it in your program from the path properly whenever you want to use it. Since it's a Python 3.7.3 in which this package has been written, it's preferable to import it in a program written in Python 3.7.3 or higher.

\subsection{What else it contains}

For beginners, hobbyists, end-use programmers and other enthusiasts, the root ThreadGo folder contains a script 'example.py' that serves as a simple demonstration as to how one can use ThreadGo package. For those who want to know what and how the script has been written, there is a 'project' sub-directory that consists of several files.

\begin{enumerate}
	\item For contributors, analysts and others, the source code is there in the program 'threadGo.py'. Since it is very simply written and designed, it will be very easy for the ones well-versed with Python, multithreading and object-oriented design to understand the model.
	\item For accessors and analysts who are curious to know whether the algorithm discussed is practically correct or not, there is a program 'correctnessTest.py'. This program performs randomised testing by means of partitioning the input space into four of my wishful categories: Non-negative integers, integers, non-negative floating point numbers and the negative ones; and picking random test cases from each of the categories. The tests are performed quickly so the program can rerun for as many as times as the accessor wants.
	\item Also, to exhibit the robustness of algorithm, there is a program 'performanceTest.py' that essentially pops up a plot of the time and space complexities, one by one (the first plot reveals the time complexity, so if you close that figure the other plot pops up), against the growing size of the matrix. The 'spike' noticeable in the plots show the 'switch' of the algorithm.
	\item For enthusiasts questioning how and when to use matrix multiplication algorithm, the program 'transitiveClosure.py' serves as an inspiration for them. This program takes a random directed unweighted graph in the form of an adjacency matrix and computes its transitive closure using a reduction to the matrix multiplication  algorithm presented in \cite{skeina}.
\end{enumerate}

\begin{thebibliography}{99}

\bibitem{strassen}
V. Strassen, "Gaussian Elimination is not optimal", \textit{Numer. Math.}, 13:354-356, 1969
\bibitem{williams}
V. Williams, "Multiplying matrices in $O(n^{2.373})$ time", \textit{ACM Press}, pp. 887-8988, 2014
\bibitem{kleinberg}
H. Cohn, R. Kleinberg, B. Szegedy, C. Umans, "Group-theoretic Algorithms for Matrix Multiplication", \textit{$46^{th}$ Annual IEEE Symposium in Foundations of Computer Sciences}, 2005
\bibitem{raz}
R. Raz, "On the complexity of matrix multiplication product", \textit{ACM Press}, 2002
\bibitem{coppersmith}
D. Coppersmith, S. Winograd, "Matrix multiplication via arithmetic progression", \textit{Journal of Symbolic Computation}, pp. 251-280, 1990
\bibitem{legall}
F. Le Gall, "Powers of tensors and fast matrix multiplication", \textit{Proceedings of the $39^{th}$ International Symposium on Symbolic and Algebraic Computation (ISSAC)}, 2014
\bibitem{schonhage}
A. Sch\"onhange, "Partial and Total Matrix Multiplication", \textit{SIAM Journal of Computation}, Volume 10, pp.434-455, 1981
\bibitem{skeina}
Skiena, Steven, "Sorting and Searching", \textit{The Algorithm Design Manual, Springer}, pp. 45–46, 401–403, 2008
\bibitem{harald}
Prokop, Harald, "Cache-Oblivious Algorithms", 1999, \textit{Master's Thesis (Massachusetts Institute of Technology)}
\bibitem{lam}
Lam, Monica S., Rothberg, Edward E., Wolf, Michael E., "The Cache Performance and Optimizations of Blocked Algorithms", \textit{Int'l Conf. on Architectural Support for Programming Languages and Operating Systems (ASPLOS)}, 1991
\bibitem{randall}
Randall, Keith H., "Cilk: Efficient Multithreaded Computing", \textit{Ph.D. Thesis (Massachusetts Institute of Technology)}, pp. 54-57, 1998
\bibitem{irony}
Irony, D., Toledo, S., Tiskin, A., "Communication lower bounds for distributed-memory matrix multiplication", \textit{J. Parallel Distrib. Comput. 64}, 9:1017-1026, 2004
\bibitem{kak}
Kak, S., "Efficiency of matrix multiplication on the cross-wired mesh array", \texttt{arXiv:1411.3273}, 2014
\bibitem{shrohan}
Mohapatra, S., "Novel applications of cellular automata in computing and computational astrophysics", \textit{B.Tech. Thesis(Indian Institute of Technology Bhubaneswar)}, 2019

\end{thebibliography}
\end{document}