\section{Fuzzy Inference}

A simplified Sugeno-style fuzzy inference system is developed with functionalities for fuzzy rule / set parsing, input fuzzification, fuzzy inferencing and output defuzzification.

\subsection{Determining Fuzzy sets}

As mentioned in the previous section, the noises in the image inevitably introduces uncertainties to our system. Therefore \textbf{the feature values referenced in our rules have to be represented in fuzzy sets}.

To determine the \textbf{best fuzzy sets capturing the appropriate degree of uncertainties}, we use the statistics from the training set to find the optimal threshold.

For $Thinness$, we use 3 fuzzy sets for ellipse-like, rectangle-like and triangle-like $Extent$ ratio. For $Extent$, we use 2 fuzzy sets for circle-like and square-like $Thinness$ ratio. The shapes and boundries of these fuzzy sets are determined based on the \textbf{distribution and percentiles of feature values} in the training set. We consider the area between 25th percentile and 75th percentile as the \textbf{high confidence range}, while the remaining area plus a small portion of area adjacent to the extreme values (to tolerate some outliners) are considered as the \textbf{low confidence range}. The corresponding polygons are then constructed based on these two ranges to represent the fuzzy sets. The final fuzzy sets are illustrated in Figure 3 (Figures not drawn to scale).

\begin{figure}

\begin{subfigure}[b]{\columnwidth}
\includegraphics[width=\columnwidth]{Figure_3_Fuzzy_Sets_1.png}
\caption{Fuzzy Set of Extent}\end{subfigure}

\begin{subfigure}[b]{\columnwidth}
\includegraphics[width=\columnwidth]{Figure_4_Fuzzy_Sets_2.png}
\caption{Fuzzy Set of Thinness}
\end{subfigure}

\caption{Fuzzy Sets}

\end{figure}

\subsection{Implementing Inference Engine}

Now that the fuzzy sets are determined, we have to implement the inference engine. But the specific nature of our task requires us to make some adaptations to the the usual fuzzy inference engine.

Firstly, unlike the example from the textbook, the set of possible outputs in our task is \textbf{NOT} a set of linguistic values which can be represented by a series of contiguous intervals. We can't compute a COG-like output and decide which category it falls in, because it's not possible to assign a reasonable order to the shapes.

Secondly, rules derived in the previous section are all of the format:

\textit{IF X IS LIKE A AND Y IS NOT LIKE B THEN Shape IS C}

Note that the consequent of each rule is an assertion about the shape of the input figure and that \textbf{each rule corresponds to the recognition process for one specific shape}. In fact a fuzzy inference system of this kind is essentially \textbf{a flattened decision tree}, with \textbf{each rule acting as a filter to calculate the possibility of one specific shape}. The only difference is that in our expert system rules are separated from inference, making it easily maintainable.

Thus, in order to gain the advantages brought by fuzzy inference without over-complicating our task, we choose to implement \textbf{a simplified Sugeno-style inference engine}. In the final defuzzification stage, we don't compute a weighted average of the rule outputs. Instead we examine all the possible values for the target variable $Shape$ and \textbf{choose the one with the highest possibility as the output}.


\section{The classifying type of a group}

\subsection{The classifying type of a group}

\begin{thm}
  For every group $G$ there is a pointed connected $1$-type $BG$ equipped with group isomorphism
  \begin{equation*}
    \loopspace{BG} \simeq G
  \end{equation*}
\end{thm}


\input{../preamble}
\DeclareMathOperator{\Ce}{Re}

\begin{document}
\title{Crash Course on Representation Theory - Day 1}
\author{Apurva Nakade}
\thispagestyle{fancy}
\maketitle

All the vector spaces will be finite dimensional vector spaces over $\C$. $G$ will denote a finite group. $V$ will denote a vector space of dimension $d$ over $\C$. All representations will be finite dimensional.

\section{Introduction}
Representation theory is based on the philosophy: When life gives you groups, linearize. Groups in general have very little structure on them (only 1 product) and hence are notoriously difficult to analyze. On the other hand there are a lot ways to exploit matrices: addition, multiplication, diagonalization, eigenvalues and eigenvectors, the various canonical forms, etc. As such it is usually quite fruitful to reduce a problem in group theory to one in linear algebra.

Theorems in basic representation theory can be very broadly broken into two kinds: i) structural theorems about existence and classification of representations coming from linear algebra, ii) constructive theorems which actually construct these representations using other techniques like combinatorics. In this class we'll only look at theorems of the first kind.

\subsection{Frobenius determinant}
Historically, a generalization of the following question prompted Frobenius to develop representation theory.
For variables $x_0, x_1, \ldots, x_{n-1}$ define the Frobenius matrix to be a matrix whose $i,j^{th}$ entry is $x_{(i-j \mod n)}$ i.e. in the $j^{th}$ column $x_i$ is in the row $i+j \mod n$.
\begin{align}
	F_n & = \begin{bmatrix} x_0 & x_{n-1} & \cdots & x_{1} \\ x_{1} & x_0 & \cdots & x_{2} \\ \vdots&& \ddots &\vdots \\ x_{n-1} & x_{n-2} & \cdots & x_0 \end{bmatrix}
\end{align}
\begin{ques}
	What are the irreducible factors of the determinant of $F_n$?
\end{ques}
We'll use representation theory to answer this question. For small dimensions it is a fun exercise to work out the factors by hand.
\begin{align}
	\det \begin{bmatrix} x_0 & x_1 \\ x_1 & x_0 \end{bmatrix} &= x_0^2 - x_1^2 = (x_0 - x_1)(x_0 + x_1) \\
	\det \begin{bmatrix} x_0 & x_1 & x_2 \\ x_1 & x_0 & x_2 \\ x_2 & x_1 & x_0 \end{bmatrix} &= x_0^3 + x_1^3 + x_2^3 - 3 x_0 x_1 x_2
	= \: ??
\end{align}

\section{Definitions}
A $d$ dimensional \textbf{representation} of $G$ is a group homomorphism $$\rho: G \rightarrow GL(V)$$ where $V$ is a $d$ dimensional vector space over $\C$ and $GL(V)$ denotes the group of invertible linear transformations $V \rightarrow V$. We say that $G$ acts on $V$ or that $V$ has an action of $G$ on it, denoted $G \circlearrowright V$. It is common to abuse notation and say that $V$ is a representation of $G$. More explicitly, we assign to each element $g \in G$ a linear transformation $\rho(g)$ satisfying
\begin{enumerate}
	\item $\rho(e) = I_{V}$ where $e$ is the identity in $G$ and $I_V$ is the trivial linear transformation on $V$
	\item $\rho(gh) = \rho(g)\rho(h)$
	\item $\rho(g^{-1}) = \rho(g)^{-1}$
\end{enumerate}
An \textbf{equivariant} map between two representations $\rho$ and $\tau$ of $G$ is a linear map $f: V \rightarrow W$ such that the induced map $GL(f)$ fits in the following commutative diagram
\begin{align}
	\xymatrix{
	                 & GL(V) \ar^{GL(f)}[d] \\
	G \ar[ur] \ar[r] & GL(W)                \\
	}
\end{align}
To be more explicit a linear map $f:V \rightarrow W$ is equivariant if for any $v \in V$ we have $f(\rho(g)(v)) = \tau(g)(f(v))$. An \textbf{isomorphism} of representations is an invertible equivariant map $f: V \rightarrow W$.

A \textbf{sub-representation} of $V$ is a subspace $W \subsetneq V$ such that $W$ is itself a representation of $G$ i.e. for every $g \in G$, $w \in W$ we have $\rho(g)w \in W$. We say that $W$ is closed under the action of $G$. A representation of $G$ which has no sub-representation is called an \textbf{irreducible} representation. We say that a representation $V$ is \textbf{decomposable} if it there are sub-representations $V_1, V_2$ such that $V_1 \oplus V_2 \cong V$.

Irreducible representations are the analogues of prime numbers in representation theory. One of the central goals of representation theory is to classify all the possible irreducible representations and to decompose arbitrary representations into irreducible ones.

\section{Examples}

\subsection{Trivial Representation}
For any finite group $G$ and any vector space $V$ there is a \textbf{trivial} representation $\rho : G \rightarrow GL(V)$ which sends every element in $G$ to the identity transformation $I_V$.

\subsection{Cyclic Groups}
For the abelian group $\Z/n$ with generator $a$ every representation is completely determined by where $a$ is mapped. Any $n \times n$ matrix $A$ satisfying $A^n = 1$ gives a representation $\Z/n \rightarrow GL(V), a \mapsto A$. In particular for each $0 \le k < n$ the $n^{th}$ root of unity $e^{2 \pi i k/n}$ gives us a 1 dimensional representation of $\Z/n$. It is easy to see that no two of these representations are isomorphic.

\subsection{Symmetric Group}
Every symmetric group $S_n$ has an $n$ dimensional representation called the \textbf{standard representation}. $S_n$ acts on $\C^n$ as follows: If $e_1, \cdots, e_n$ is the standard basis for $\C^n$ then the permutation $g \in S_n$ acts on $\C^n$ via
\begin{align}
	\rho(g){e _ i} & = e_ {\sigma(i)}
\end{align}
The matrices of $\rho(g)$ in the standard basis are called the \textbf{permutation matrices}.

The standard representation of $S_n$ is not irreducible. Consider the 1-dimensional subspace $ W$ generated by the element $e_1 + e_2 + \cdots + e_n$. This subspace is invariant under the action of $S_n$ and hence is a sub-representation of $\C^n$. Let $W^{\perp}$ be the vector space of $\C^n$ consisting of vectors which are perpendicular to $W$ i.e. $W^{\perp} = \{ c_1.e_1 + \cdots + c_n.e_n  : c_1 + \cdots + c_n = 0\}$. It is easy to see that $W^{\perp}$ is also a sub-representation of $\C^n$ and hence $V \cong W \oplus W^{\perp}$ as representations.

\subsection{Sign Representation}
Every symmetric group $S_n$ has a 1 dimensional representation $\mathrm{sign}: S_n \rightarrow GL_1(\C)$ called \textbf{sign representation} defined as follows: Every transposition $(i,j)$ maps to $-1$. Every permutation can be written (non-uniquely) as a product of transpositions and hence we can extend this map to the entire $S_n$. We can then show that this extension is well defined.

\subsection{Dihedral group}
Let $D_{2n}$ denote the \textbf{dihedral group} which is the group of symmetries of a regular $n$ sided polygon in $\R^2$. $D_{2n}$ has a presentation
\begin{align}
	D_{2n} = \langle x,y \mid x^2 = 1, y^n = 1, xyxy=1\rangle
\end{align}
$x$ denotes reflection about a line that passes through the center of the polygon and $y$ denotes a reflection about the center of the polygon by an angle of $2 \pi / n$. We can show that $D_{2n}$ contains exactly $2n$ elements and every element is of the form $y^d$ or $xy^d$ for some $0 \le d \le n - 1$, hence the subscript $2n$. $D_{2n}$ has a natural 2 dimensional representation
\begin{align}
	\rho : D_{2n} &\rightarrow GL_2(\C) \\
	x & \mapsto \begin{bmatrix} 0               & 1                \\ -1 & 0 \end{bmatrix} \\
	y & \mapsto \begin{bmatrix} \cos(2 \pi / n) & -\sin(2 \pi / n) \\ sin(2 \pi / n) & \cos(2 \pi / n) \end{bmatrix}
\end{align}
One can show that the standard 2 dimensional representation of $D_{2n}$ is irreducible.

\subsection{Quaternions}
The \textbf{quaternion group} $Q_8$ defined by the presentation
\begin{align}
	Q_8 = \langle i,j,k, -1 \mid i^2 = j^2 = k^2 = -1 = ijk, (-1)^2 = 1  \rangle
\end{align}
has a 1 dimensional \textbf{sign representation} given by mapping $i$ to 1 and $j$, $k$ to $-1$, and similarly two other sign representations. $Q_8$ also has a 2-dimensional representation $Q_8 \rightarrow GL(\C^2)$ given by
\begin{align}
	i \mapsto \begin{bmatrix} i & 0 \\ 0 & -i \end{bmatrix}
	\qquad
	j \mapsto \begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}
	\qquad
	k \mapsto \begin{bmatrix} 0 & i \\ i & 0 \end{bmatrix}
\end{align}

\subsection{Regular Representation}
Every group $G$ has a $|G|$ dimensional representation called a \textbf{regular representation}. Consider the free vector space $V$ over $G$ i.e. $V$ is a $|G|$ dimensional vector space with a basis given by $\{ e_g : g \in G\}$. $G$ acts on $V$ via
\begin{align}
	\rho(g)(e_h) = e_{gh}
\end{align}
The regular representation is not irreducible as it contains a 1 dimensional vector space spanned by $\sum _ {g \in G} e_g$ which is invariant under the action of $G$.

\section{`Prime' representations}
Representation theory of finite groups over $\C$ asserts the existence of finitely many irreducible representations up to isomorphism. Further these representations can be detected by their characters.

Recall that two elements $g_1, g_2 \in G$ are called \textbf{conjugates} of each other if there exists an $h \in G$ such that $h^{-1} g_1 h = g_2$. Being a conjugate is an equivalence relation and the equivalence classes are called \textbf{conjugacy classes}.

\begin{thm} Up to isomorphism there are finitely many irreducible representations of $G$. Suppose $\rho_1, \rho_2, \ldots, \rho_r$ are the distinct irreducible representations of $G$ with dimensions $d_1$, $d_2$, \ldots, $d_r$ respectively then,
	$\quad$
	\begin{enumerate}
		\item $r$ equals the number of conjugacy classes in $G$.
		\item $d_i \mid |G|$ where $|G|$ denotes the size of $G$.
		\item $|G| = d_1^2 + d_2^2 + \cdots + d_r^2$
	\end{enumerate}
\end{thm}

\begin{thm}[Maschke's theorem]
	Every reducible representation is decomposable.
\end{thm}

\begin{thm}[Schur's lemma]
	Using the same notation as in the previous theorem, every finite dimensional representation $\tau$ of $G$ has a unique decomposition
	\begin{align}
		\tau \cong \rho_1^{\oplus k_1} \oplus \rho_2^{\oplus k_2} \oplus \cdots \oplus \rho_r^{\oplus k_r}
	\end{align}
	for some positive integers $k_1, k_2, \cdots, k_r$ where by $\rho_i \oplus \rho_j$ we mean the representation $G \xrightarrow{\rho_i \oplus \rho_j} GL(V_i \oplus V_j)$.
\end{thm}
In terms of matrices $(\rho_i \oplus \rho_j)(g)$ is the block matrix with two blocks given by $\rho_i(g)$ and $\rho_j(g)$ respectively. This theorem can be interpreted as saying that for every representation $\tau: G \rightarrow GL(V)$ it is possible to choose a basis for $V$ such that all the matrices $\tau(g)$ become block diagonal in this basis, further each of the blocks are obtained from the irreducible representations.

These two theorems should be thought of as saying that in the world of $G$ representations there are finitely many `primes'. Every other representation can be uniquely written as a `product'(=direct sum) of these primes.

\subsection{Examples}
\begin{description}
	\item[Dihedral group $D_6$:]
	$D_6$ which is the same as the symmetric group $S_3$ has 3 conjugacy classes $\{ \{1 \}$, $\{ (1,2)$; $(1,3)$; $(2,3) \}$, $\{(1,2,3)$; $(1,3,2)\} \}$ and hence has 3 irreducible representations of dimensions say $d_1, d_2, d_3$ which satisfy i) $d_i | 6$ and ii) $d_1^2 + d_2^2 + d_3^2 = 6$. The only such numbers are $1,1,2$. Further we know what they are: the trivial representation, the sign representation and the standard representation of the dihedral group $D_6$.

	\item[Quaternion group $Q_8$:]
	The quaternion group $Q_8$ has 5 conjugacy classes $\{ 1\}$, $\{ -1\}$, $\{i, -i\}$, $\{ j, -j\}$, and $\{ k, -k\}$ and hence has 5 distinct irreducible representations. But we know 5 irreducible representations of $Q_8$: the trivial representation, the 3 sign representations, and the two dimensional representation.

	\item[Cyclic group:]
	Let $G$ be the cyclic group $\Z/n$. As $G$ is abelian $ghg^{-1} = h$ for all $h$ i.e. each conjugacy class contains exactly 1 element and hence the number of conjugacy classes of $G$ is $n$. So $G$ has exactly $n$ distinct irreducible representations. Suppose their dimensions are $d_1, \cdots, d_n$ then we must have $n = d_1^2 + \cdots + d_n^2$. The only possibility is $d_i = 1$ for all $i$ i.e. all the irreducible representations of $\Z/n$ are 1 dimensional. But we already know $n$ one dimensional representations of $\Z/n$ (given by the roots of unity). More generally we get

	\begin{proposition}
		Every irreducible representation of an a abelian group is 1 dimensional.
	\end{proposition}

	\item[$p^2$ groups:]
	Let $G$ be a group of size $p^2$ where $p$ is a prime. Suppose $G$ has $r$ irreducible representations of dimensions $d_1, d_2, \cdots, d_r$ then we must have $d_i | p^2$ so each $d_i$ is in the set $\{ 1, p , p^2 \}$. We also have $p^2 = d_1 ^2 + d_2 ^2 + \cdots + d_r^2$. Every group has a trivial representation so that one of the $d_i's$ is 1. The only possibility is $d_i = 1$ for all $i$ and hence $r = p^2$. But this forces $G$ to have $p^2$ conjugacy classes and hence every conjugacy class contains exactly 1 element i.e. $G$ is abelian.

	\begin{proposition}
		Every group of size $p^2$ is abelian.
	\end{proposition}

	\item[Symmetric groups]
	The symmetric groups $S_n$ have size $n!$. The conjugacy classes of $S_n$ are given by cycle types. One can show that the number of cycle types is equal to the number of ways of partitioning $n$ and hence for every partition of the number $n$ we get an irreducible representation of $S_n$.
\end{description}

\end{document}

05 Representation theory/01 Representation Theory.tex


\section*{Exercises}

\begin{ex}
  Graphically, find the point $(x,y)$ which
  lies on both of the lines $x+3y=1$ and $4x-y=3$. That is, graph each line
  and see where they intersect.

  \begin{sol}
    $
    \begin{array}{c}
      x+3y=1 \\
      4x-y=3
    \end{array}$, Solution is: $\mat{x=\frac{10}{13},y=\frac{1}{13}}$.
  \end{sol}
\end{ex}

\begin{ex}
  Graphically, find the point of intersection of the two lines $
  3x+y=3$ and $x+2y=1$. That is, graph each line
  and see where they intersect.

  \begin{sol}
    $
    \begin{array}{c}
      3x+y=3 \\
      x+2y=1
    \end{array}
    $, Solution is: $\mat{x=1,y=0}$
  \end{sol}
\end{ex}

\begin{ex} You have a system of $k$ equations in two variables, $k\geq 2$.
  Explain the geometric significance of

  \begin{enumerate}
  \item No solution.

  \item A unique solution.

  \item An infinite number of solutions.
  \end{enumerate}

  % \begin{sol}
  % \end{sol}
\end{ex}

\begin{ex}
  Draw a picture of three planes such that no two of the planes are
  parallel, but the three planes have no common intersection.

  \begin{sol}~\par\vspace{-2ex}\quad
    \begin{tikzpicture}[xscale=0.2,yscale=0.15]
      \draw[fill=gray!30] (-6,0) -- ++(7,7) -- ++(4,0) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!90] (-2,-8) -- ++(7,7) -- ++(2,4) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!60] (2,-8) -- ++(7,7) -- ++(-2,4) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!60] (0,-4) -- ++(7,7) -- ++(-2,4) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!60] (-2,0) -- ++(7,7) -- ++(-2,4) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!30] (-2,0) -- ++(7,7) -- ++(4,0) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!90] (0,-4) -- ++(7,7) -- ++(2,4) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!30] (2,0) -- ++(7,7) -- ++(4,0) -- ++(-7,-7) -- cycle;
      \draw[fill=gray!90] (2,0) -- ++(7,7) -- ++(2,4) -- ++(-7,-7) -- cycle;
    \end{tikzpicture}
  \end{sol}
\end{ex}


\section{Kruskal's and Prim's Algorithms}	\label{section:mst-algs}

%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{Kruskal's Algorithm}
  \begin{lstlisting}[style = code]
  sort (non-descreasingly) the edges $E$

  $X = \emptyset$
  for $e \in E$ in non-descreasing order
    if $X \cup \set{e}$ does not produce cycle
       $X \gets X \cup \set{e}$
  \end{lstlisting}

  \importikznocaption{0.45\textwidth}{0.70\textwidth}{tikz-in-beamer/mst-kruskal-example-overlay.tex}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{Kruskal's Algorithm}
  \begin{description}
	\item[State:] forest $\triangleq$ a collection of connected components
	\item[Ops:] on connected components
	  \begin{itemize}
		\item cycle detection
		\item union two CCs
	  \end{itemize}
  \end{description}

  \pause

  \begin{center}
	Using the \textcolor{red}{\bf disjoint-set} data structure.
  \end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{Prim's Algorithm}
  \begin{lstlisting}[style = code]
  $X = \emptyset$
  $S = \set{s}$    // pick any $s \in V$
  $R = V \setminus S$
  while $R \neq \emptyset$
    $e = (u,v) \gets$ a lightest edge across $(S, R)$
    $X \gets X \cup \set{e}$
    $S \gets S \cup \set{u} \quad R \gets R \setminus \set{v}$
  \end{lstlisting}

  \importikznocaption{0.45\textwidth}{0.70\textwidth}{tikz-in-beamer/mst-prime-example-overlay.tex}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{Prim's Algorithm}
  \begin{description}
	\item[State:] a growing tree (CC)
	\item[Op:] identifying a lightest edge
  \end{description}

  \pause

  \begin{center}
	Using the \textcolor{red}{\bf priority-queue (min-heap)} data structure.
  \end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%


\chapter{Test Problems for Optimization}
\label{chap:a20testProblems}

In the following, we give formal definitions of the test problems
mentioned in \cref{sec:53testProblems}.
For each problem, we state the objective function
$\objfunscaled\colon \clint{\*a, \*b} \to \real$,
$\xscaled \mapsto \objfunscaled(\xscaled)$,
its domain $\clint{\*a, \*b}$
(where $\xscaled \in \clint{\*a, \*b}$),
the location $\xoptscaled \in \clint{\*a, \*b}$ of its global minimum, and
its minimal value $\objfunscaled(\xoptscaled)$
(and the constraint function
$\ineqconfunscaled\colon \clint{\*a, \*b} \to \real^{m_{\ineqconfunscaled}}$,
if any).
Plots of the test problems are given in
\cref{%
  fig:unconstrainedOptimizationProblem,%
  fig:constrainedOptimizationProblem%
}.

{
  \newcommand*{\centertestfunline}[1]{%
    \mathclap{\hphantom{\mathrm{(B.99a)}}#1}%
  }
  \let\xse\xscaledentry

  \input{tex/document/a21unconstrained}
  \input{tex/document/a22constrained}
}

\cleardoublepage


\documentclass[10pt]{article}
\author{Alex Peyrard}
\title{Information and coding theory assignment 3}

\begin{document}
\maketitle

\section{Inequalities}
Given $U\rightarrow X\rightarrow Y\rightarrow V$ a Markov chain, we can find :
\[I(U,V)\leq I(U,Y)\]
\[I(U,V)\leq I(X,V)\]

\[I(U,V)\leq I(U,X)\]
\[I(U,V)\leq I(X,Y)\]
\[I(U,V)\leq I(Y,V)\]

\[I(U,Y)\leq I(U,X)\]
\[I(U,Y)\leq I(X,Y)\]

\[I(X,V)\leq I(X,Y)\]
\[I(X,V)\leq I(Y,V)\]

\section{Fano's inequality}

\section{Kraft's inequality}
We want to prove that for a uniquely decodable code, then $\sum\limits_{k=1}^{m}D^{-l_{k}}\leq 1$
With $D$ the size of the size of the alphabet, $m$ the number of words, and $l_{k}$ the length of the $k^{th}$ word.

For the code to be uniquely decodable, it can't have a code that is the beginning of a following code. For a D-ary code, this means that if there are $D$ words of code length $l$, there can't be words of length superior to $l$.

Thus, for the D-ary code to be uniquely decodable, we can at most have $D-1$ words of code length $l < l_{max}$, and $D$ words of code length $l_{max}$.

This means that we have :
\[\sum\limits_{k=1}^{m}D^{-l_{k}}=(D-1)\sum\limits_{i=1}^{l_{max-1}}D^{-i}+D*D^{-l_{max}}\]
\[\sum\limits_{k=1}^{m}D^{-l_{k}}=(D-1)\sum\limits_{i=1}^{l_{max}}D^{-i}+D^{-l_{max}}\]
\[\sum\limits_{k=1}^{m}D^{-l_{k}}=(D-1)\frac{D^{-l_{max}}(D^{l_{max}-1})}{D-1}+D^{-l_{max}}\]
\[\sum\limits_{k=1}^{m}D^{-l_{k}}=1\]
Since this is at the most, a code is uniquely decodable if
\[\sum\limits_{k=1}^{m}D^{-l_{k}}\leq1\]
QED

\end{document}


\problemname{Vaccine Efficacy}

To determine the efficacy of a vaccine against a disease, a clinical
trial is needed.  Some participants are given the real vaccine, while
others are given a placebo as the control group.  The participants are
tracked to determine if they are infected by three different strains
(A, B, and C) of a virus.  The efficacy of the vaccine against
infection by a particular strain is simply the percentage reduction of
the infection rate of the vaccinated group compared to the control group.

For example, suppose that there are $40$ people in the vaccinated
group, $8$ of which are infected by strain B.  Then the infection rate
is $20$\%.  Further suppose that $50$ people are in the control group,
and $30$ people are infected by strain B.  Then the infection rate for
the control group is $60$\%.  Thus the vaccine efficacy against
infection is approximately $66.67$\% (since $20$\% is a $66.67$\%
percentage reduction of $60$\%).  If the infection rate for a
particular strain in the vaccinated group is not lower than that of
the control group, the vaccine is not effective against infection by
that strain.

What is the vaccine efficacy against infection by the three strains?

\section*{Input}

The first line of input contains an integer $N$
($2 \leq N \leq 10\,000$) containing the number of participants in the
clinical trial.

The next $N$ lines describe the participants. Each of these lines contains
a string of length four. Each letter is either `Y' or `N'.  The first letter
indicates whether the participant is vaccinated with the real vaccine,
and the remaining three letters indicate whether the participant is
infected by strain A, B, and C, respectively.

There is at least one participant in the vaccinated group and the
control group.  There is at least one participant in the control group
infected by each strain (but they may be different participants).

\section*{Output}

Display the vaccine efficacy against infection by strain A, B, and C
in that order.  If the vaccine is not effective against infection by a
particular strain, display \texttt{Not Effective} for that strain
instead.  Answers with an absolute error or relative error of at most
$10^{-2}$ will be accepted.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


% jam 2004-09-10

\section{Classifying projected simplexes}
\label{sec:classifying}

%-----------------------------------------------------------------

The convex hull of a $(m-1)$ dimensional projection of a $m$-simplex
is either a $(m-1)$-simplex or a $(m-1)$ dimensional cross polytope.

\begin{Lemma}
\label{rambau-lemma}
Any set $Z$ of $(m+2)$ points whose convex hull is of dimension $m$
has exactly two triangulations denoted $T_{Z^+}$ and $T_{Z^-}$.
\end{Lemma}

See Rambau~\cite[Lemma~1.1.2]{rambau-jorg-1996}.

Let $S=(\p_0, \p_1 \ldots  \p_m)$ be an $m$-simplex in $\Reals^{n}$.
Let $\pi$ be a projection from $\Reals^{n}$ to $Q$, an $(m-1)$-dimensional
affine subspace of $\Reals^{n}$.
Assume $\pi$ is chosen so that the points
$\{\pi \p_0, \pi \p_1 \ldots  \pi \p_m\}$ are in {\it general position},
that is, any $l+1$ of the projected points spans an $l$-dimensional
affine subspace of $Q$.

By Lemma \ref{rambau-lemma},
there are two exactly triangulations of the convex hull of the projected points.
The $(m-1)$-simplexes of the triangulations are images of the $(m-1)$-simplexes of $S$,
and two triangulations correspond to a partition of $(m-1)$-simplexes of $S$
into two subsets, the "top" and "bottom" of $S$ with respect to $\pi$.

To see why this is true, and to further classify the triangulations,
consider the fact that the boundary of the convex hull of $\pi S$
must contain either $m$ or $m+1$ of the $\pi \p_i$.
(Any fewer and the points cannot be in general position.)

\begin{Theorem}
\label{one-simplex-case}
If the boundary of the convex hull of $\pi S$
contains $m$ of the $\pi \p_i$,
then it is a $(m-1)$-simplex
and the image of one of the $(m-1)$-simplexes, $F$, in $S$.
The first triangulation is just $\pi F$.
The second triangulation consists of the images of
all the remaining $(m-1)$-simplexes of $S$.
The second triangulation is itself the mutual refinement of both.
\end{Theorem}

The first 2 statements are obvious.
If we label the vertices so that $\{\pi \p_1 \ldots  \pi \p_m\}$
are on the boundary, and $\pi \p_0$ is in the interior,
then the second triangulation results from refining the first
triangulation {\it pulling}
\cite{lee-hdcg-17-2004} the vertex $\pi \p_0$.
The faces of the triangulation formed by pulling
are the images of the $m$ $(m-1)$-simplexes
of $S$ that contain $\p_0$, that is, all the $(m-1)$-simplexes in $S$,
other than $(\p_1 \ldots  \pi \p_m)$.

\begin{Theorem}
\label{two-simplex-case}
If the boundary of the convex hull of $\pi S$
contains all $m+1$ of the $\pi \p_i$,
then it is the image of 2 of the $(m-1)$-simplexes in $S$,
which share a common $(m-2)$-simplex.
These 2 simplexes are the first triangulation.
The second triangulation consists of the images
of the remaining $m-1$ $(m-1)$-simplexes of $S$,
which share a common $1$-simplex.
The mutual refinement is formed by splitting either
the shared $(m-2)$-simplex in the first triangulation
or the shared $1$-simplex in the second.
\end{Theorem}

\subsection{Implementation}

Let $\Vspace$ be a $d$-dimensional real inner product space.
Let $\p() : \Integers^{+} \mapsto \Vspace,$
so that $\p(\Ssimplex)$ is a geometric realization of the $d$-simplex $\Ssimplex$.
Let $\Projection_{\Aspace}$ be the orthogonal projection onto
$\Aspace$, a $(d-1)$-dimensional affine subspace of $\Vspace$.
Assume that the $\affine_span \left( \p(\Ssimplex) \right)$
is $(d-1)$-dimensional.

Let $\Kcomplex_{d-1}$ be an oriented version of the $(d-1)$-skeleton of $\Ssimplex$.

By the results above, the oriented $(d-1)$-simplices,
$\{ \Ffacet_0 \ldots \Ffacet_d \}$ in $\Kcomplex_{d-1}$
can be partitioned into two subsets, $\Kcomplex_{d-1}^{+}$
and $\Kcomplex_{d-1}^{-}$, such that
$\Projection_{\Aspace} \left( \p ( \Kcomplex_{d-1}^{+} ) \right)$
and
$\Projection_{\Aspace} \left( \p ( \Kcomplex_{d-1}^{-} ) \right)$
are each triangulations of
$\convex_span \left( \Projection_{\Aspace} \left( \p ( \Ssimplex ) \right) \right)$.
The two subsets can be determined by computng the signed
volumes of the realizations of the oriented facets,
with the positive volumes forming one triangulation and the negative the other.

What I want to do is to create a mutual refinement of the two subsets,
$\Kcomplex_{d-1}^{1}$,
which triangulates
$\convex_span \left( \Projection_{\Aspace} \left( \p ( \Ssimplex ) \right) \right)$.
I then want to split and collapse simplices in any complex containing $\Ssimplex$
so that the $d$-simplex $\Ssimplex$ is replaced by the $(d-1)$-dimensional
complex $\Kcomplex_{d-1}^{1}$.

There are two cases:
\begin{enumerate}

\item $\convex_span \left( \Projection_{\Aspace} \left( \p ( \Ssimplex ) \right) \right)$
has $d$-corners, which are the projected realizations of $d$
of the vertices of $\Ssimplex$.
The remaining vertex, $\Vvertex_0$,
is such that
$\Projection_{\Aspace} \left( \p ( \Vvertex_0 ) \right)$,
can be expressed
as a convex combination of the projected realizations of the corner vertices.

In this case, one of $\Kcomplex_{d-1}^{\pm}$ is a single facet $\Ffacet_d$
and the other contains the remaining $d$ facets $\{\Ffacet_0 \ldots \Ffacet_{d-1} \}$,
which share $\Vvertex_0$.
To get the mutual refinement, we split $\Ffacet_d$ around a new vertex $\Vvertex_1$.
To reduce the split children of $\Ssimplex$ to $\Kcomplex_{d-1}^{1}$,
we collapse the edge $\{ \Vvertex_0 , \Vvertex_1 \}$.

Note that the number of vertices in any complex containing $\Ssimplex$
is unchanged.

\item All the $\Projection_{\Aspace} \left( \p ( \Vvertex_i ) \right) $
are corners of
$\convex_span \left( \Projection_{\Aspace} \left( \p ( \Ssimplex ) \right) \right)$.

In this case, one of $\Kcomplex_{d-1}^{\pm}$
contains two facets, $\Ffacet_{d-1}$ and $\Ffacet_{d}$,
and the other contains the remaining $(d-1)$ facets, $\{\Ffacet_0 \ldots \Ffacet_{d-2} \}$.
$\Ffacet_{d-1}$ and $\Ffacet_{d}$ share a common $(d-2)$-simplex, $\Tsimplex$.
$\{\Ffacet_0 \ldots \Ffacet_{d-2} \}$ share a common edge.
The common edge connects the vertex $\Vvertex_{d-1}$,
which is opposite $\Tsimplex$ in $\Ffacet_{d-1}$,
and the vertex $\Vvertex_{d}$
which is opposite $\Tsimplex$ in $\Ffacet_{d}$.
To get the mutual refinement, we split $\Eedge$ around a new vertex $\Vvertex_0$
and split $\Tsimplex$ around a new vertex $\Vvertex_1$.
To reduce the split children of $\Ssimplex$ to $\Kcomplex_{d-1}^{1}$,
we collapse the edge $\{ \Vvertex_0 , \Vvertex_1 \}$.

Note that the number of vertices in any complex containing $\Ssimplex$
is increased by 1.

\end{enumerate}


\providecommand{\main}{..}
\documentclass[\main/thesis.tex]{subfiles}
\begin{document}
\chapter{Generalizations}\label{generalizations}

\section{Base}

Recall the evaluation function.

$$
    [\![d_0d_1d_2...d_n]\!]_{base}
    =
    \bar{d_0}\times base^0 + \bar{d_1}\times base^1 + \bar{d_2}\times base^2 + ... + \bar{d_n}\times base^n
$$
%
where $ \bar{d_n} $ ranges from $ 0 $ to $ base - 1 $ for all $ n $.

As we can see the base of numeral systems has already been generalized.
But nonetheless, it is a good start and we will continue to abstract more things
away.

\section{Offset}

To cooperate unary numerals, we relax the constraint on the range of digit
assignment by introducing a new variable, \textit{offset}:

$$
    [\![d_0d_1d_2...d_n]\!]_{base}
    =
    \bar{d_0}\times base^0 + \bar{d_1}\times base^1 + \bar{d_2}\times base^2 + ... + \bar{d_n}\times base^n
$$

The evaluation of numerals remains the same but the assignment of digits has changed from

$$
    { 0, 1, ..., \mathit{base} - 1 }
$$

to

$$
    { \mathit{offset}, \mathit{offset} + 1, ..., \mathit{offset} + \mathit{base} - 1 }
$$

The codomain of the digit assignment function is \textit{shifted} by \textit{offset}.
Now that unary numerals would have an offset of $ 1 $
and systems of other bases would have offsets of $ 0 $.

\paragraph{1-2 binary system}
Recall \textit{1-2 random access lists} from the previous chapter,
which is the numerical representation of a binary numeral system with an offset
of $ 1 $.
Let us see how to count to ten in the 1-2 binary system.
\footnote{As a reminder, the order of non-decimal numerals are reversed.}

\begin{table}[H]
    \centering
    \begin{adjustbox}{max width=\textwidth}
    \begin{tabular}{ | l | l |}
    \textbf{Number} & \textbf{Numeral} \\
    \hline
    1 & 1  \\
    2 & 2  \\
    3 & 11 \\
    4 & 21 \\
    5 & 12 \\
    \end{tabular}
    \quad
    \begin{tabular}{ | l | l | }
    \textbf{Number} & \textbf{Numeral} \\
    \hline
    6  & 22 \\
    7  & 111 \\
    8  & 211 \\
    9  & 121 \\
    10 & 221 \\
    \end{tabular}
    \end{adjustbox}
\caption{1-2 binary numeral system}
\label{table:8}
\end{table}

There are no restrictions on the symbols of digits.
But nonetheless, it is reasonable to choose symbols that match their assigned
values, as we choose the symbol ``1'' and ``2'' as digits for the 1-2 binary system.

% \begin{center}
%     \begin{adjustbox}{max width=\textwidth}
%     \begin{tabular}{ | l | r | r | }
%     \textbf{Numeral system} & \textbf{Base} & \textbf{Offset} \\
%     \hline
%     decimal         & 10 & 0 \\
%     binary          & 2  & 0 \\
%     hexadecimal     & 16 & 0 \\
%     unary           & 1  & 1 \\
%     1-2 binary      & 2  & 1 \\
%     \end{tabular}
%     \end{adjustbox}
% \end{center}

\paragraph{bijective numerations}
Systems with an offset of $ 1 $ are also known as \textit{bijective numerations}
because every number can be represented by exactly one numeral. In other words,
the evaluation function is bijective. The 1-2 binary system is one such numeration.

\paragraph{zeroless representations}
A numeral system is said to be \textit{zeroless} if no digits are assigned $ 0 $,
i.e., $ \mathit{offset} \textgreater 0 $.
Data structures modeled after zeroless systems are called \textit{zeroless representations}.
These containers are preferable to their ``zeroful'' counterparts.
The reason is that a digit of value $ 0 $ corresponds to a building block with
$ 0 $ elements, and a building block that contains no element is not only useless,
but also hinders traversal as it takes time to skip over these empty nodes,
as we have seen in random access lists from the previous chapter.

\section{Number of Digits}

The binary numeral system running in circuits looks different from what we have
in hand.
Surprisingly, these binary numbers can fit into our representation with just a tweak.
If we allow a system to have more digits,
then a fixed-precision binary number can be regarded as a single digit!
To illustrate this,
a 32-bit binary number (\textit{Int32}) would become a single digit that ranges
from $ 0 $ to $ 2^{32} $, while everything else including the base remains the same.

Formerly in our representation,
there are exactly \textit{base} number of digits and their assignments range from:

$$
    \mathit{offset}  ...  \mathit{offset} + \mathit{base} - 1
$$

By introducing a new index \textit{\#digit} to generalize the number of digits,
their assignments range from:

$$
    \mathit{offset}  ...  \mathit{offset} + \mathit{\#digit} - 1
$$

\paragraph{Redundancy}

Numeral systems like \textit{Int32} are said to be \textbf{redundant}
because there is more than one way to represent a number.
In fact, systems that admit $ 0 $ as one of the digits must be redundant,
since we can always take a numeral and add leading zeros without changing it's value.

Incrementing a decimal numeral such as $ 999999 $ takes much more time than
$ 999998 $ because carries or borrows can propagate.
Redundancy provides ``buffer'' against these carries and borrows.
In this case, incrementing $ 999999 $ and $ 999998 $ of \textit{Int32} both
results in a cost of constant time.

Numerical representations modeled after redundant numeral systems also enjoy
similar properties. When designed properly, redundancy can improve the performance
of operations of data structures.

\section{Relations with Natural Numbers}

The following table contains all of the numeral systems we have addressed so far,
with \textit{base}, \textit{offset}, and \textit{\#digit} taken into account.
\footnote{
\textit{Int32} and \textit{Int64} are respectively 32-bit and 64-bit machine
integers.
}

\begin{table}[H]
    \centering
    \begin{adjustbox}{max width=\textwidth}
    \begin{tabular}{ | l | r | r | r | }
    \textbf{Numeral system} & \textbf{Base} & \textbf{\#Digit} & \textbf{Offset} \\
    \hline
    decimal         & 10 & 10 & 0 \\
    binary          & 2  & 2  & 0 \\
    hexadecimal     & 16 & 16 & 0 \\
    unary           & 1  & 1  & 1 \\
    1-2 binary      & 2  & 2  & 1 \\
    Int32           & 2  & $ 2^{32} $ & 0 \\
    Int64           & 2  & $ 2^{64} $ & 0 \\
    \end{tabular}
    \end{adjustbox}
\caption{Summary of indices of common numeral systems}
\label{table:9}
\end{table}

Although we are now capable of expressing those numeral systems with just a few
indices, there are also some unexpected inhabitants included in this representation.
There is always a trade-off between expressiveness and properties.

We will explore the various types of numeral systems and define operations on
them in the chapter~\ref{constructions}.

\end{document}


\documentclass[letterpaper]{article}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{tikz}

\begin{document}

\title{Approximately Euclidean Grids}
\author{Moshe Looks}

\maketitle

The distance $d_G(u, v)$ between vertices in an undirected graph $G = (V, E)$ is the number
of edges in a shortest path between $u$ and $v$. The distance $d_2(p, q)$ between points
Euclidean space is the $2$-norm of the line segment between $u$ and $v$. A non-trivial
mapping $f : V \to \mathbb{N}^2$ cannot satisfy $d_G(u, v) = d_2(f(u), f(v))$ because of the
incommensurability of the side and diagonal of the square. Nonetheless, $d_G(u, v)$ can be
used to approximate $d_2(f(u), f(v))$; the approximation will be better or worse depending on
our choices of $G$ and $f$. How well can $d_G$ approximate $d_2$, assuming $|V| = N$?

This is an interesting question that is difficult to answer in full generality. Let's
consider the special case of a graph with $N = n^2$ vertices mapped onto the square grid
$\{1, \ldots, n\} \times \{1, \ldots, n\}$. If we add edges between horizontal and vertical
neighbors, we get Manhattan distances ($d_1$, based on the $1$-norm). If we additionally add
edges between diagonal neighbors, then we get chessboard distances ($d_\infty$, based on the
$\infty$-norm).

\setlength{\tabcolsep}{15pt}
\begin{tabular}{ l r}
  \input{manhattan.tex} & \input{chessboard.tex}
\end{tabular}

We have the nice property that $d_1(p, q) \leq d_2(p, q) \leq d_\infty(p, q)$, although
neither one of these constructs gives us a very good approximation of $d_2$. It is easy to
see that in both cases, the divergences from $d_2$ grow unboundedly with $n$.  In fact,
Tobias Fritz has \href{https://arxiv.org/abs/1109.1963}{proven} that this divergence happens
for \emph{every} distance function based on a periodic graph. But nothing prevents us from
considering aperiodic graphs. What happens if we start with a graph corresponding to $d_1$
and we add edges between only \emph{some} diagonal neighbors? Let's call this sort of graph
with $|V| = n^2$, where $d_G$ is meant to approximate $d_2$, an order-$n$ Eugrid (Euclidean
grid). Here is an interesting order-5 Eugrid:

\begin{center}
  \input{eugrid5.tex}
\end{center}

What makes it interesting is that for every Pythagorean triple\footnote{Triples of natural
numbers $(a, b, c)$ s.t. $a^2 + b^2 = c^2$; eg. $(3, 4, 5)$, $(12, 5, 13)$, \&c.}  $(a, b,
c)$ and every pair of vertices $(p, q)$ corresponding respectively to $(x, y)$ and $(x \pm a,
y \pm b)$, the distance relation $d(p, q) = c$ is satisfied. Let's call a Eugrid that
satisfies this property \emph{Pythagorean}. Pythagorean triples are dense in the rational
numbers. Consequently, a Pythagorean Eugrid of sufficiently high order would, in a certain
sense, perfectly reflect the structure of Euclidean space, insofar as it is \emph{can} be
reflected by a finite square grid. But do high-order Pythagorean Eugrids exist? As it turns
out, they do not; order-12 is as high as they go. Unlucky 13! The space of order-13 Eugrids
is rather large, and so the proof that none of them are Pythagorean is based on a rather
tricky branch-and-bound search; refer to \hyperref[sec:appendix]{the appendix} for details.
Elegance eluding us, we henceforth resort to heuristics and approximations. Such is the lot
of the computer ``scientist''.

\section{An approximate approach}

Let us consider for the moment only distances from $\mathbf{1} = (1, 1)$ to other points, and
thus only concern ourselves with diagonals corresponding to line segments $\{p + (\Delta,
\Delta) \, | \, 0 \leq \Delta \leq 1\}$. The distance $d_G(\mathbf{1}, (x+1, y+1))$ may be
calculated via a simple recurrence relation as
\begin{equation*}
  D_1(x, y) := 1 + d_G(\mathbf{1}, (x, y))
\end{equation*}
in the presence of a diagonal edge originating at $(x, y)$ and
\begin{equation*}
  D_2(x, y) := 1 + \min(d_G(\mathbf{1}, (x + 1, y)), d_G(\mathbf{1}, (x, y + 1)))
\end{equation*}
in the absence of a diagonal. This immediately suggests a simple greedy approach where we
visit each potential diagonal exactly once\footnote{Taking care to visit $(x+1, y+1)$ after
we have visited $(x+1,y)$ and $(x,y+1)$.} and decide whether or not to add it to the graph by
comparing the quantities
\begin{equation*}
  L_1(x, y) := |\sqrt{x^2 + y^2} - D_1(x, y)|
\end{equation*}
and
\begin{equation*}
  L_2(x, y) := |\sqrt{x^2 + y^2} - D_2(x, y)|
\end{equation*}
that characterize the ``loss'' for adding vs. omitting a given edge. This gives us
\begin{center}
  \includegraphics[scale=1.95]{simple.png}
\end{center}
which is black where $L_1 < L_2$, white where $L_1 < L_2$, and gray where $L_1 = L_2$. The
underlying graph structure is aperiodic so Fritz's no-go theorem does not apply; arcs around
$\mathbf{1}$ become increasingly circular as the radius increases.
\begin{center}
  \includegraphics[scale=1.95]{simple_arcs.png}
\end{center}

The moment we shift our perspective however, things begin to seem rather worse. If we center
ourselves at $(16, 8)$ for example we see instead
\begin{center}
  \includegraphics[scale=1.95]{simple_ugly_arcs.png}
\end{center}
where black arcs are for graph structure based on $L_1 < L_2$ and gray arcs are for graph
structure based on $L_1 \leq L_2$; neither one is very good.

How can we make better Eugrids? We can generalize this simple greedy approach and consider
distances to more points than just $\mathbf{1}$. What is left is to specify \emph{which}
points, and how to weight their relative contributions, since adding a particular diagonal
edge may make some distance more Euclidean, and other less so.

For the vertex $u$ at $(x_u, y_u)$ we can potentially calculate distances to all vertices $v$
at $(x_v, y_v)$ such that $x_v < x_u$ and $y_v < y_u$. But since this both highly redundant
and scales badly with $n$, we restrict ourselves to points on the edges of the Eugrid, i.e.
of the forms $(x_v, 1)$ and $(1, y_v)$. This gives us nice coverage and is computationally
tractable, but requires careful normalization to balance relative contributions.

If we ima

There is one more

\begin{equation*}
\sum_{i=1}^{x+y-1} \frac{\theta_i \cdot |\sqrt{x_i^2 + y_i^2} - D_i|}{\min(x_i, y_i)}
\end{equation*}

and distances between pairs of vertices
mapping to pairs of points placed at pairs of points of the form $(p, p + \Delta) \, | \, p,
\Delta _\in \mathbb{N}^2$.

In the spirit of trying simple things first, lets see what happens if we take a greedy
approach and only consider distance to  It can be easily seen that
if there is an edge between the vertices corresponding to points $(i, j)$ and $(i + 1, j+1)$
then
\begin{equation}
  d_G(\mathbf{1}, (i+1, j+1)) =
\end{equation}
and that otherwise
\begin{equation}
  d_G(\mathbf{1}, (i+1, j+1)) =
\end{equation}

This suggests simply

This approach gives us very nice circular arcs around $\mathbf{1}$

\includegraphics[scale=0.2]{cs.png}

But very ugly circular arcs around other vertices.

\includegraphics[scale=0.2]{cs2.png}

\section*{Appendix: Searching for Pythagorean Eugrids}
\label{sec:appendix}

We can construct a state space to search for order-$n$ Eugrids by putting undirected graphs
in correspondence with $(n - 1) \times (n - 1)$ bit matrices where $1$s correspond to the
presence of edges between diagonal neighbors.\footnote{Eugrids include all edges between
horizontal and vertical neighbors, by definition.} For example, the order-$5$ Eugrid
exhibited above corresponds to a $4 x 4$ Eugridean matrix:

\begin{equation*}
\begin{matrix}
  0 & 0 & 0 & 0 \\
  0 & 0 & 1 & 0 \\
  0 & 1 & 0 & 1 \\
  0 & 0 & 1 & 0
\end{matrix}
\end{equation*}

The state space for order $n$ has $2^{(n-1)^2}$ elements. For $n=5$ this is only 65,536 and
we can brute-force it to see that there are 10,948 order-$5$ Eugrids; they are rather thick
on the ground. What to do about higher orders where exponential growth makes things
unpleasant? We can make some headway by noticing that higher-order Eugrids must be composed
of lower-order ones. In particular, if matrix $\mathbf{A}$ corresponds to an order-$n$
Eugrid, then all submatrices $\mathbf{A}_{1:m,1:m}$ correspond to order-$m$ Eugrids.

This naturally suggests a partition of the full $(n-1)^2$-dimensional state space into
$(n-1)$ disjoint ``layers'', like so:

\begin{center}
  \input{onion.tex}
\end{center}

Possible diagonals for the $m$th layer correspond to squares numbered $m$. So rather than
constructing an entire state in one go, we only ever construct substates corresponding to
individual layers. When constructing a substate corresponding to layer $m+1$, we can assume
that all substates corresponding to layers $1 \ldots m$ are valid (i.e. correspond to
lower-order Eugrids). We may have to backtrack of course; some lower-order Eugrids are dead
ends.

This is a good start towards tractability but is insufficient; the state subspace for layer
$m$ still has $2^{2m-1}$ elements. What we need is a more intelligent search pro

We have more work to do in order to make the search tractable. The first step is to move away
from brute-force enumeration when considering diagonals for layer $n+1$ given layer $n$
already contains a Eugrid.\footnote{The $n=0$ case corresponds to a layer only a single
search space variable, so we don't mind enumerating over it.} The basic idea here is that
every region of the space corresponding to a Pythagorean triple $(a, b, c)$ with lower-left
corner $(x, y)$ corresponds to a set of constraints on the diagonals inside of it, and we
will end up with a Eugrid iff \emph{all} such sets of constraints are satisfied.

What are these constraints, exactly? If all variables corresponding to diagonals in a
particular region have been assigned, then obviously the constraints require the shortest
paths from $(x, y)$ to $(x+a, y+b)$ have length $c$. But we can do better than this and
impose constraints on partially assigned regions as well. For example, no Eugridean matrix
can contain
\begin{equation*}
\begin{matrix}
  1 & * & * \\
  * & 1 & * \\
  * & * & 1
\end{matrix}
\end{equation*}
as a proper submatrix (where ``*'' may be either a 1 or a 0) because if so then it would be
contained within a $3x4$ region\footnote{Corresponding to the Pythagorean triple $(3, 4,
5)$.} with a shortest path for the hypotenuse of length $< 5$ in violation of Eugrideanity.
Likewise $0_{2 x 4}$ is not a submatrix of any Eugridean, because it would lead to a similar
region with hypotenuse of length $> 5$.

Since graph distance equals shortest path length, $d(u, v) = c$ requires both that no path
from $u$ to $v$ be shorter than $c$, \emph{and} that at least one path be no longer than $c$.
The partition of a square grid into layers as we have done dictates that all shortest pathsbetween.

To get tight bounds, recall that Eugridean distance is lower-bounded by $L_\infty$ and
upper-bounded by $L_1$.

For every literal \verb|x| and corresponding vertex $x$, \emph{if} there exists a region
$r = (p, q, c)$ s.t. $d(p, x) + d_1(x, q) == c$, \emph{then} $r$ is unconstrained \emph{and}
\verb|x| is negated.

For every region $r = (p, q, c)$, \emph{if} there exists a vertex $x$ s.t.
$d(p, x) + d_{\infty}(x, q) < c$, \emph{then} $r$ is unconstrained.

All other regions are constrained. For every constrained region $r = (p, q, c)$ at least one
literal \verb|x| corresponding to vertex $x$ that satisfies $d(p, x) + d_{\infty}(x, q) = c$
must be affirmed.

We can thus construct a logical conjunction of clauses where every clauses is either a
negated literal or a disjunction of non-negated literals s.t. the layer is valid iff the the
conjunction is satisfied. Whereas general Boolean satisfiability is a hard problem, formulae
with this special form are easily checkable. We can easily enumerate all valid assignments
using depth-first search.

This leads to a backtracking search procedure for finding Eugrids:

Let $1$ be the active layer.

Generate a satisfying assignment for the active layer. If no satisfying assignment exist, or
if we have already generated all satisfying assignments, backtrack to the previous layer.

Advance to the next layer.

\end{document}