\documentclass[12pt,titlepage]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{color}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{xparse}
\usepackage{hyperref}
%----Macros----------
%
% Unresolved issues:
%
% \righttoleftarrow
% \lefttorightarrow
%
% \color{} with HTML colorspec
% \bgcolor
% \array with options (without options, it's equivalent to the matrix environment)
% Of the standard HTML named colors, white, black, red, green, blue and yellow
% are predefined in the color package. Here are the rest.
\definecolor{aqua}{rgb}{0, 1.0, 1.0}
\definecolor{fuschia}{rgb}{1.0, 0, 1.0}
\definecolor{gray}{rgb}{0.502, 0.502, 0.502}
\definecolor{lime}{rgb}{0, 1.0, 0}
\definecolor{maroon}{rgb}{0.502, 0, 0}
\definecolor{navy}{rgb}{0, 0, 0.502}
\definecolor{olive}{rgb}{0.502, 0.502, 0}
\definecolor{purple}{rgb}{0.502, 0, 0.502}
\definecolor{silver}{rgb}{0.753, 0.753, 0.753}
\definecolor{teal}{rgb}{0, 0.502, 0.502}
% Because of conflicts, \space and \mathop are converted to
% \itexspace and \operatorname during preprocessing.
% itex: \space{ht}{dp}{wd}
%
% Height and baseline depth measurements are in units of tenths of an ex while
% the width is measured in tenths of an em.
\makeatletter
\newdimen\itex@wd%
\newdimen\itex@dp%
\newdimen\itex@thd%
\def\itexspace#1#2#3{\itex@wd=#3em%
\itex@wd=0.1\itex@wd%
\itex@dp=#2ex%
\itex@dp=0.1\itex@dp%
\itex@thd=#1ex%
\itex@thd=0.1\itex@thd%
\advance\itex@thd\the\itex@dp%
\makebox[\the\itex@wd]{\rule[-\the\itex@dp]{0cm}{\the\itex@thd}}}
\makeatother
% \tensor and \multiscript
\makeatletter
\newif\if@sup
\newtoks\@sups
\def\append@sup#1{\edef\act{\noexpand\@sups={\the\@sups #1}}\act}%
\def\reset@sup{\@supfalse\@sups={}}%
\def\mk@scripts#1#2{\if #2/ \if@sup ^{\the\@sups}\fi \else%
\ifx #1_ \if@sup ^{\the\@sups}\reset@sup \fi {}_{#2}%
\else \append@sup#2 \@suptrue \fi%
\expandafter\mk@scripts\fi}
\def\tensor#1#2{\reset@sup#1\mk@scripts#2_/}
\def\multiscripts#1#2#3{\reset@sup{}\mk@scripts#1_/#2%
\reset@sup\mk@scripts#3_/}
\makeatother
% \slash
\makeatletter
\newbox\slashbox \setbox\slashbox=\hbox{$/$}
\def\itex@pslash#1{\setbox\@tempboxa=\hbox{$#1$}
\@tempdima=0.5\wd\slashbox \advance\@tempdima 0.5\wd\@tempboxa
\copy\slashbox \kern-\@tempdima \box\@tempboxa}
\def\slash{\protect\itex@pslash}
\makeatother
% math-mode versions of \rlap, etc
% from Alexander Perlis, "A complement to \smash, \llap, and lap"
% http://math.arizona.edu/~aprl/publications/mathclap/
\def\clap#1{\hbox to 0pt{\hss#1\hss}}
\def\mathllap{\mathpalette\mathllapinternal}
\def\mathrlap{\mathpalette\mathrlapinternal}
\def\mathclap{\mathpalette\mathclapinternal}
\def\mathllapinternal#1#2{\llap{$\mathsurround=0pt#1{#2}$}}
\def\mathrlapinternal#1#2{\rlap{$\mathsurround=0pt#1{#2}$}}
\def\mathclapinternal#1#2{\clap{$\mathsurround=0pt#1{#2}$}}
% Renames \sqrt as \oldsqrt and redefine root to result in \sqrt[#1]{#2}
\let\oldroot\root
\def\root#1#2{\oldroot #1 \of{#2}}
\renewcommand{\sqrt}[2][]{\oldroot #1 \of{#2}}
% Manually declare the txfonts symbolsC font
\DeclareSymbolFont{symbolsC}{U}{txsyc}{m}{n}
\SetSymbolFont{symbolsC}{bold}{U}{txsyc}{bx}{n}
\DeclareFontSubstitution{U}{txsyc}{m}{n}
% Manually declare the stmaryrd font
\DeclareSymbolFont{stmry}{U}{stmry}{m}{n}
\SetSymbolFont{stmry}{bold}{U}{stmry}{b}{n}
% Manually declare the MnSymbolE font
\DeclareFontFamily{OMX}{MnSymbolE}{}
\DeclareSymbolFont{mnomx}{OMX}{MnSymbolE}{m}{n}
\SetSymbolFont{mnomx}{bold}{OMX}{MnSymbolE}{b}{n}
\DeclareFontShape{OMX}{MnSymbolE}{m}{n}{
<-6> MnSymbolE5
<6-7> MnSymbolE6
<7-8> MnSymbolE7
<8-9> MnSymbolE8
<9-10> MnSymbolE9
<10-12> MnSymbolE10
<12-> MnSymbolE12}{}
% Declare specific arrows from txfonts without loading the full package
\makeatletter
\def\re@DeclareMathSymbol#1#2#3#4{%
\let#1=\undefined
\DeclareMathSymbol{#1}{#2}{#3}{#4}}
\re@DeclareMathSymbol{\neArrow}{\mathrel}{symbolsC}{116}
\re@DeclareMathSymbol{\neArr}{\mathrel}{symbolsC}{116}
\re@DeclareMathSymbol{\seArrow}{\mathrel}{symbolsC}{117}
\re@DeclareMathSymbol{\seArr}{\mathrel}{symbolsC}{117}
\re@DeclareMathSymbol{\nwArrow}{\mathrel}{symbolsC}{118}
\re@DeclareMathSymbol{\nwArr}{\mathrel}{symbolsC}{118}
\re@DeclareMathSymbol{\swArrow}{\mathrel}{symbolsC}{119}
\re@DeclareMathSymbol{\swArr}{\mathrel}{symbolsC}{119}
\re@DeclareMathSymbol{\nequiv}{\mathrel}{symbolsC}{46}
\re@DeclareMathSymbol{\Perp}{\mathrel}{symbolsC}{121}
\re@DeclareMathSymbol{\Vbar}{\mathrel}{symbolsC}{121}
\re@DeclareMathSymbol{\sslash}{\mathrel}{stmry}{12}
\re@DeclareMathSymbol{\bigsqcap}{\mathop}{stmry}{"64}
\re@DeclareMathSymbol{\biginterleave}{\mathop}{stmry}{"6}
\re@DeclareMathSymbol{\invamp}{\mathrel}{symbolsC}{77}
\re@DeclareMathSymbol{\parr}{\mathrel}{symbolsC}{77}
\makeatother
% \llangle, \rrangle, \lmoustache and \rmoustache from MnSymbolE
\makeatletter
\def\Decl@Mn@Delim#1#2#3#4{%
\if\relax\noexpand#1%
\let#1\undefined
\fi
\DeclareMathDelimiter{#1}{#2}{#3}{#4}{#3}{#4}}
\def\Decl@Mn@Open#1#2#3{\Decl@Mn@Delim{#1}{\mathopen}{#2}{#3}}
\def\Decl@Mn@Close#1#2#3{\Decl@Mn@Delim{#1}{\mathclose}{#2}{#3}}
\Decl@Mn@Open{\llangle}{mnomx}{'164}
\Decl@Mn@Close{\rrangle}{mnomx}{'171}
\Decl@Mn@Open{\lmoustache}{mnomx}{'245}
\Decl@Mn@Close{\rmoustache}{mnomx}{'244}
\makeatother
% Widecheck
\makeatletter
\DeclareRobustCommand\widecheck[1]{{\mathpalette\@widecheck{#1}}}
\def\@widecheck#1#2{%
\setbox\z@\hbox{\m@th$#1#2$}%
\setbox\tw@\hbox{\m@th$#1%
\widehat{%
\vrule\@width\z@\@height\ht\z@
\vrule\@height\z@\@width\wd\z@}$}%
\dp\tw@-\ht\z@
\@tempdima\ht\z@ \advance\@tempdima2\ht\tw@ \divide\@tempdima\thr@@
\setbox\tw@\hbox{%
\raise\@tempdima\hbox{\scalebox{1}[-1]{\lower\@tempdima\box
\tw@}}}%
{\ooalign{\box\tw@ \cr \box\z@}}}
\makeatother
% \mathraisebox{voffset}[height][depth]{something}
\makeatletter
\NewDocumentCommand\mathraisebox{moom}{%
\IfNoValueTF{#2}{\def\@temp##1##2{\raisebox{#1}{$\m@th##1##2$}}}{%
\IfNoValueTF{#3}{\def\@temp##1##2{\raisebox{#1}[#2]{$\m@th##1##2$}}%
}{\def\@temp##1##2{\raisebox{#1}[#2][#3]{$\m@th##1##2$}}}}%
\mathpalette\@temp{#4}}
\makeatletter
% udots (taken from yhmath)
\makeatletter
\def\udots{\mathinner{\mkern2mu\raise\p@\hbox{.}
\mkern2mu\raise4\p@\hbox{.}\mkern1mu
\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern1mu}}
\makeatother
%% Fix array
\newcommand{\itexarray}[1]{\begin{matrix}#1\end{matrix}}
%% \itexnum is a noop
\newcommand{\itexnum}[1]{#1}
%% Renaming existing commands
\newcommand{\underoverset}[3]{\underset{#1}{\overset{#2}{#3}}}
\newcommand{\widevec}{\overrightarrow}
\newcommand{\darr}{\downarrow}
\newcommand{\nearr}{\nearrow}
\newcommand{\nwarr}{\nwarrow}
\newcommand{\searr}{\searrow}
\newcommand{\swarr}{\swarrow}
\newcommand{\curvearrowbotright}{\curvearrowright}
\newcommand{\uparr}{\uparrow}
\newcommand{\downuparrow}{\updownarrow}
\newcommand{\duparr}{\updownarrow}
\newcommand{\updarr}{\updownarrow}
\newcommand{\gt}{>}
\newcommand{\lt}{<}
\newcommand{\map}{\mapsto}
\newcommand{\embedsin}{\hookrightarrow}
\newcommand{\Alpha}{A}
\newcommand{\Beta}{B}
\newcommand{\Zeta}{Z}
\newcommand{\Eta}{H}
\newcommand{\Iota}{I}
\newcommand{\Kappa}{K}
\newcommand{\Mu}{M}
\newcommand{\Nu}{N}
\newcommand{\Rho}{P}
\newcommand{\Tau}{T}
\newcommand{\Upsi}{\Upsilon}
\newcommand{\omicron}{o}
\newcommand{\lang}{\langle}
\newcommand{\rang}{\rangle}
\newcommand{\Union}{\bigcup}
\newcommand{\Intersection}{\bigcap}
\newcommand{\Oplus}{\bigoplus}
\newcommand{\Otimes}{\bigotimes}
\newcommand{\Wedge}{\bigwedge}
\newcommand{\Vee}{\bigvee}
\newcommand{\coproduct}{\coprod}
\newcommand{\product}{\prod}
\newcommand{\closure}{\overline}
\newcommand{\integral}{\int}
\newcommand{\doubleintegral}{\iint}
\newcommand{\tripleintegral}{\iiint}
\newcommand{\quadrupleintegral}{\iiiint}
\newcommand{\conint}{\oint}
\newcommand{\contourintegral}{\oint}
\newcommand{\infinity}{\infty}
\newcommand{\bottom}{\bot}
\newcommand{\minusb}{\boxminus}
\newcommand{\plusb}{\boxplus}
\newcommand{\timesb}{\boxtimes}
\newcommand{\intersection}{\cap}
\newcommand{\union}{\cup}
\newcommand{\Del}{\nabla}
\newcommand{\odash}{\circleddash}
\newcommand{\negspace}{\!}
\newcommand{\widebar}{\overline}
\newcommand{\textsize}{\normalsize}
\renewcommand{\scriptsize}{\scriptstyle}
\newcommand{\scriptscriptsize}{\scriptscriptstyle}
\newcommand{\mathfr}{\mathfrak}
\newcommand{\statusline}[2]{#2}
\newcommand{\tooltip}[2]{#2}
\newcommand{\toggle}[2]{#2}
% Theorem Environments
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{prop}{Proposition}
\newtheorem{cor}{Corollary}
\newtheorem*{utheorem}{Theorem}
\newtheorem*{ulemma}{Lemma}
\newtheorem*{uprop}{Proposition}
\newtheorem*{ucor}{Corollary}
\theoremstyle{definition}
\newtheorem{defn}{Definition}
\newtheorem{example}{Example}
\newtheorem*{udefn}{Definition}
\newtheorem*{uexample}{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem{note}{Note}
\newtheorem*{uremark}{Remark}
\newtheorem*{unote}{Note}
%-------------------------------------------------------------------
\begin{document}
%-------------------------------------------------------------------
\section*{Blog - Linear maps that fill pigeon holes}
\textbf{This is \emph{not} yet suitable for final editing. Review comments on the forum are welcome.}
\noindent\hyperlink{introduction}{Introduction}\dotfill \pageref*{introduction} \linebreak
\noindent\hyperlink{a_place_for_everything_and_everything_in_its_place}{A place for everything, and everything in its place}\dotfill \pageref*{a_place_for_everything_and_everything_in_its_place} \linebreak
\noindent\hyperlink{birthday_paradoxes}{Birthday paradoxes}\dotfill \pageref*{birthday_paradoxes} \linebreak
\noindent\hyperlink{finite_fields_of_size_}{Finite fields of size $2^n$}\dotfill \pageref*{finite_fields_of_size_} \linebreak
\noindent\hyperlink{extending_solutions_to_satisfy_more_equations}{Extending solutions to satisfy more equations}\dotfill \pageref*{extending_solutions_to_satisfy_more_equations} \linebreak
\noindent\hyperlink{a_concrete_procedure}{A concrete procedure}\dotfill \pageref*{a_concrete_procedure} \linebreak
\noindent\hyperlink{practical_results}{Practical results}\dotfill \pageref*{practical_results} \linebreak
\noindent\hyperlink{remind_me_why_were_doing_this}{Remind me why we’re doing this?}\dotfill \pageref*{remind_me_why_were_doing_this} \linebreak
\noindent\hyperlink{for_more}{For more}\dotfill \pageref*{for_more} \linebreak
\hypertarget{introduction}{}\section*{{Introduction}}\label{introduction}
Mathematicians and computer scientists often focus on different aspects of a task: in a mathematical view the primary thing is whether objects with particular properties \emph{exist} while computer scientists are obsessed with methods for obtaining smaller concrete representations faster. As an example, a mathematician may focus on the fact that all symmetric matrices are guaranteed to have a full set of orthogonal eigenvectors, while a computer scientist may be focused on ways to find them given a particular matrix. This is particuarly true here, where we consider the problem of finding more compact “functions” for labelling incoming data faster than the obvious way. We’ll concentrate on the core of the real-world task, which is to incrementally maintain a mapping of \emph{randomly distributed vectors} to \emph{compact labels} in a way that the mapping produced is computationally efficient. By incrementally we mean that the vectors to be labelled are revealed to us in groups and at all times we have to have a mapping which will label all the values produced so far with the same labels they were given earlier.
As a concrete example of this, consider a book publisher. They produce books with arbitrarily long names, and for all sorts of purposes such as warehouse storage of newly printed copies, labelling pallets to go to bookshops, processing returned books, etc, it helps to have a compact, uniform length label to use. This label needs to be produced from the book title, but there’s a key aspect to the task here: new book titles are \emph{only created occasionally in batches} (compared to the incredibly frequent operation of looking up the label corresponding to a given name) and \emph{on occasions when we know that new titles to be labelled are being produced}. This sets it apart from other tasks which involve “producing labels” (such as within a programming language compiler), where we can encounter a new title at any time and which use very different techniques.
There’s an important but non-obvious point here: suppose each time we create some new book titles we send the labelling to, say, every bookshop that stocks our books on a sale-or-return basis. When they need to send some books back, they can compute the short label to be attach to each crate themselves \emph{without contacting the publisher with the original titles asking for the corresponding labels}, and the shipment can be taken in and placed in the correct bins by the warehouse directly. (In actual computer applications this high degree of independence is makes it easy to use this scheme in a \textbf{distributed system}.)
Real-world applications for are not restricted to books but occur in many situations: consider for example the addition of new companies to a stock exchange listing, the addition of names of newly discovered species, the addition of new users to a social media site, etc. You could even look at it as the quaint task of deciding how to assign pigeon-holes as people appear. This is the \emph{core task} in the area of \textbf{perfect hashing}, a very active field in computer science. However, for most of the remainder of this article we’ll concentrate on the core mathematical problem, with a very brief description of the larger computer science setting at the end for experts.
This also shows how mathematical discourse is changing: the development here was inspired by a blog article (((1))) that described a clever technique devised by Prasad Raghavendra for solving linear systems over prime fields differently to standard Gaussian elimination which has some attractive properties for some applications. To the best of my knowledge this has never been published in a journal, or even a preprint on the arxiv. The real core of this article is an interesting mathematical relation that holds in spaces over finite fields of characteristic-2 – and how this can be integrated into Raghavendra’s technique – which is interesting in its own right.
\hypertarget{a_place_for_everything_and_everything_in_its_place}{}\section*{{A place for everything, and everything in its place}}\label{a_place_for_everything_and_everything_in_its_place}
A couple of notes on notation: As we’ll be choosing short, snappy names for various quantities, we’ll use $a := b$ as an abbreviation for “let us denote by $a$ the value of expression $b$” (keeping $a=b$ for cases where $a$ pre-exists). Secondly given vectors $a := (a_1,\dots,a_n)$ and $b := (b_1,\dots,b_n)$ the dot product $a\cdot b$ is the usual $a_1 b_1 + \dots + a_n b_n$.
We want to progressively and incrementally associate input vectors to distinct \textbf{label values} in some set which (in anticipation of later) we’ll call $\mathbb{F}$. More precisely, the fundamental problem being tackled is:
\begin{itemize}%
\item We’re first given a set of random input vectors $S_a := \{a_1, \dots, a_{k_a} \}$ and must find a vector $x_a$ such that the $\alpha_i := a_i \cdot x_a$ “label values under $x_a$” for each $a_i \in S_a$ are all distinct.
\item We then get an set of additional random vectors $S_b := \{b_1, \dots, b_{k_b} \}$ and determine a vector $x_b$ such that we still have $a_i \cdot x_b = \alpha_i$ (again for each $a_i \in S_a$) and also that the $\beta_i := b_i \cdot x_b$ values (over all the $b_i \in S_b$) combined with the $\alpha_i$s are still all distinct.
\item Then we get yet another set $S_c := \{c_1, \dots, c_{k_c} \}$ and find $x_c$ maintaining $a_i \cdot x_c = \alpha_i$ and $b_i \cdot x_c = \beta_i$ and that the $\gamma_i := c_i \cdot x_c$ combined with the $\alpha_i$s and $\beta_i$s are all distinct.
\item Next we get a further set of vectors …
\end{itemize}
This whole process ends when we’ve received enough $S_i$s that we fail to find a new solution vector which keeps all the dot products distinct. One way to look at this is as “dotting with $x$” as specifying a mechanism that converts from the an input vector into a box location, as shown in the sketch here:
Note that a key aspect of the problem is that once we’ve associated an input vector $d$ with a label $\delta$ at some stage, at \emph{all} future steps the new solution vector $x$ \emph{must} still satisfy $d \cdot x = \delta$.
You should also note that the problem description refers to the task of “finding vectors” rather than saying “there exists a vector”: this highlights that we’re working in the computer science realm where we’re limited in the amount of work we’re prepared to do. Indeed, in terms of \emph{mathematical existence} there’s a textbook solution \emph{if we’re prepared to wait until all the sets of vectors have been received before outputting a labelling}: choose to associate each incoming vector with a consecutive label in $\mathbb{F}$ and stack all the vectors into a big matrix $A$ and concatenate the labels into a vector to get the matrix equation
\begin{displaymath}
A x = (1, 2, \dots, N)^T
\end{displaymath}
(where $N$ is the number of vectors to label) which has solution
\begin{displaymath}
x = A^{-1} (1, 2, \dots, N)^T
\end{displaymath}
providing that matrix $A$ is of full rank, which amongst other things implies $x$ must have the same number of components as the number of random vectors we’re labelling. (We won’t go in to the solutions that still exist in some cases when $A$ isn’t of full rank here, concentrating on the alternative below.)
But as we want to keep the number of components in $x$ low, we’ll try a different tack.
\hypertarget{birthday_paradoxes}{}\subsection*{{Birthday paradoxes}}\label{birthday_paradoxes}
Before we do that, we should observe that we’d expect this labelling task to be non-trivial; we can’t just grab a random mapping vector $x$ and expect it to work. This is for the same reason as the well known phenomenon that if you take a random group of 23 people, there’s a probability of over $50$ percent that two of them share a birthday. This is referred to as a paradox because of your intuitive guess that a subset would need to be around half the size of the number of possiblities in order to get a probability $\ge 0.5$ of a collision, not around its square root. This is illustrated in the following plot (taken from Wikipedia article (((2))), a good source of more information):
This is a particular example of “given a set $\mathbb{F}$, if you take $n$ uniformly random choices the likelihood that there are at least two identical elements is better than evens when $|\mathbb{F}| \times \dots \times (|\mathbb{F}|-n+1) \le {|\mathbb{F}|^n} / 2$”. The relevance here is that if we just construct a mapping at random when $|\mathbb{F}|=2^8$, on average we’ll only be able to label 18 elements before we have an already-used label is attached to a new vector! Since this just isn’t good enough, it looks like generating a mapping entirely at random is out.
\hypertarget{finite_fields_of_size_}{}\subsection*{{Finite fields of size $2^n$}}\label{finite_fields_of_size_}
Since our goal is to obtain labels $\alpha_i$s, $\beta_i$s, etc, all lying within a small set discrete values, we don’t really want to work over the real numbers $\mathbb{R}$ or the integers $\mathbb{Z}$, both of which are infinite. Instead we’d like to work in a \textbf{finite field} $\mathbb{F}$, an “alternative set of numbers” which has only a small (and finite!) number of elements. What sort of options do we have for the size of $\mathbb{F}$? It turns out the restriction of being a field means that the sizes follow a strict pattern: it was shown in the nineteenth century that a finite field must have size $p^n$ for some prime $p$ and some natural number $n \ge 1$. These fields are known as \textbf{Galois fields}, frustratingly denoted $GF(p^n)$ rather than the more uniform $\mathbb{F}_{p^n}$. They’re very convenient since if we pick size $2^n$ (and in practice $2^8$) it fits well with the way computer hardware is built around processing entities with $2^n$ possibilities (such as \textbf{bytes}, i.e., $2^8$ possibilities).
The mathematics of constructing concrete representations of finite fields is fascinating and well worth reading (a good introduction is (((3)))). However we won’t go into details here as not only would it be impossible to do it justice within the space limitations, but we won’t be using the detailed structure of $GF(2^n)$. The key bits are the features of being a \textbf{field}, that word I snuck into the previous paragraph, which basically means that various usual algebraic identities familiar from the real numbers still hold, namely,
\begin{itemize}%
\item \textbf{associativity:} $(a+b)+c=a+(b+c)$ and $(a b)c=a(b c)$.
\item \textbf{commutativity:} $a+b=b+a$ and $a b=b a$.
\item \textbf{distributivity:} $a(b+c)=a b+a c$.
\item \textbf{identity elements:} $a+0=a$ and $1 a=a$.
\item \textbf{inverse elements:} $-a+a=0$ and, providing $a \ne 0$, $a^{-1} a=1$.
\end{itemize}
and an additional rule that is a new feature of $GF(2^n)$: $GF(2^n)$ is what’s known as a \textbf{field of characteristic 2}. What this means is that $x+x$ is always $0$ no matter what $x$ is. (In general, a finite field $\mathbb{F}$ with $p^n$ elements has characteristic $p$, i.e., adding $p$ copies of the same thing together always gives $0$.) This is a new feature that crops up with finite fields ($\mathbb{R}$ doesn’t have it) and is a very convenient property we’ll make extensive use of later on.
However, it’s important to bear in mind that a finite field like $GF(2^8)$ has some differences to normal numbers: for example, the animation below shows various \emph{lines} in a vector space over $\mathbb{R}$.
[[normalSpaceLines.gif:pic]]
Here, we’re looking at the line $(a,b)^T \cdot (x,y)^T = c$. In $\mathbb{R}^2$ keeping $a$ and $b$ fixed while increasing $c$ generates parallel lines; if in an outer process we keep $b$ fixed while increasing $a$ then we’d be continuously changing the gradient of the sets of parallel lines as seen above. By contrast, the animation below shows various \emph{lines} in a vector space over $GF(2^8)$:
For both animations the precise procedure being followed in the $\mathbb{R}^2$ or $GF(2^8)^2$ animations above is::
\begin{enumerate}%
\item I picked a fixed value for $b$ and 3 values of $c$ that “are equally spaced apart” which are associated with colour red, green or blue respectively.
\item Each frame $a$ is moved onto its “successor”.
\item In that frame, I found all the $(x, y)$ pairs which satisfy the equation for the current $a$ for each $c$ and plotted them in the associated colour.
\item When $a$ has reaches its maximum value it wraps around and the animation repeats.
\end{enumerate}
(Several terms are in “vague quotes” since the notions are a bit more awkward over $GF(p^n)$ than over $\mathbb{R}$.) What this shows is that the notion of a “straight line” – and thus also the dot-product operation – in a vector space over $GF(2^n)$ is a far more “dispersed”, disconnected structure than the straight, connected lines produced in $\mathbb{R}$.
\textbf{Puzzle 1:} The ring of integers $\mathbb{Z}/n\mathbb{Z}$ generally has \emph{some} elements with inverses; e.g., $13 \times 197 = 1 \pmod{2^8}$ and hence $13$ has inverse $197$ working over $\mathbb{Z}/2^8\mathbb{Z}$. By contrast there’s simply no element in $\mathbb{Z}/2^8\mathbb{Z}$ which works as an inverse for $8$, but so what? Why can’t we work over $\mathbb{Z}/2^8\mathbb{Z}$ rather than the more complicated $GF(2^8)$? Why is it so important that \emph{every} non-zero element has an inverse?
\hypertarget{extending_solutions_to_satisfy_more_equations}{}\section*{{Extending solutions to satisfy more equations}}\label{extending_solutions_to_satisfy_more_equations}
Now we can look at the key step in the solution: \emph{We’ve found two solution vectors $u$ and $v$ which both satisfy a set of equations $a_i \cdot x = \alpha_i$ equations, and we want to get a solution $w$ which satisfies a new equation $b \cdot x = \beta$ \textbf{while still satisfying the old equations}}. It turns out there’s an especially simple way we can combine $u$ and $v$ to get $w$, namely
\begin{displaymath}
w := \frac{\beta + b \cdot v}{b \cdot v + b \cdot u} u + \frac{\beta + b \cdot u}{b \cdot v + b \cdot u} v.
\end{displaymath}
We can see the “strangeness” of $GF(2^n)$ already if we look at what happens when we suppose $\beta = b \cdot v$, i.e., when $v$ \emph{already satisfies} the new equation:
\begin{displaymath}
w = \frac{b \cdot v + b \cdot v}{b \cdot v + b \cdot u} u + \frac{b \cdot v + b \cdot u}{b \cdot v + b \cdot u} v = \frac{0}{b \cdot v + b \cdot u} u + 1 v = v
\end{displaymath}
where we’ve used just the field identities above and that $b \cdot v + b \cdot v$ is always 0. Likewise if you investigate the case $\beta = b \cdot u$ you’ll get $w = u$. So $w$ is always a point on the “line” that \emph{passes through} $u$ and $v$. In theory what’s happening is that given two solution vectors (marked with blue plus-signs in the 2-D visualisation below) we “conceptually” construct the line between them (shown as red crosses).
[[intersect4.gif:pic]]
(Of course as a “line” in $GF(2^n)$ it’s not the straight connected line we’re used to.) We then find the point where it intersects with the solution space of the new equation (which in this 2-D case is another line, shown as green plus-signs; in $N$ dimensions it’s an $N-1$ dimensional hyper-plane). You can see that the red and green markers fall on the same point about a fifth of the way from the bottom of the image just in the half nearer the right hand edge. However, obviously we don’t \emph{really} do that; just as in the case in $\mathbb{R}$ we can find the point of intersection purely algebraically without constructing the full sets of points.
Now if we calculate what $a_i \cdot w$ is (for an arbitrary $i$) using the fact that the work we did previously has ensured that $a_i \cdot u = a_i \cdot v = \alpha_i$, we find the term involving $\beta$ “cancels” because we end up with a sum involving two copies of it and we end up with
\begin{displaymath}
\frac{b \cdot v + b \cdot u}{b \cdot v + b \cdot u} \alpha_i,
\end{displaymath}
which by the usual rules for cancelling in fractions is just $\alpha_i$. (Try writing it out: the patterns of simplification that occur are very pretty.) You can also straightforwardly compute $b \cdot w$ and this time as there are two copies of the non-$\beta$ terms (so again they vanish), ending up with
\begin{displaymath}
\frac{b \cdot v + b \cdot u}{b \cdot v + b \cdot u} \beta,
\end{displaymath}
which obviously simplifies to just $\beta$.
(This is a slight generalization of Raghavendra’s original technique, where he cleverly observed that in a finite field $\mathbb{F}_p$ – which has characteristic $p$ – if you’ve got some solution vectors $v_1$, …, $v_{p+1}$ that each individually satisfy a set of equations $a_i \cdot v_j = \alpha_i$, then
\begin{displaymath}
a_i \cdot \left( \sum_{j=1}^{p+1} v_j \right) = \sum_{j=1}^{p+1} a_i \cdot v_j = \sum_{j=1}^{p+1} \alpha_i = \alpha_i
\end{displaymath}
where the final step is because $p$ $\alpha_i$s sum to $0$ in $\mathbb{F}_p$. As this holds for all $i$, this gives a “new” solution to the set of equations generated from the existing ones. One drawback to Raghavendra’s technique is that this doesn’t give you any control of what value the new solution gives for a new equation. His procedure relies on it satisfying the new equation “by chance” and is applied over small fields like $\mathbb{F}_2$ where this chance is good.)
\hypertarget{a_concrete_procedure}{}\subsection*{{A concrete procedure}}\label{a_concrete_procedure}
This is the core technique that we’ll use, but we need to specify what to do in various unusual cases for a complete recipe. Without loss of generality, we assume that the first set of vectors to classify contains just a single vector; if it doesn’t we just split the first actual set into first a single vector, then the remainder as the next set. Doing this makes describing the initialisation easier.
So here are the gory details (where all arithmetic is done over $GF(2^n)$):
\begin{itemize}%
\item For initial vector $a$, set labelling $l := \{ 1 \}$, vectors $V := \{ a_i^{-1} e_i | 1 \le i \le 2^n \}$ and $N:=1$.
\item For each new set of vectors $S$ to extend the labelling $(V,l)$ by:
\begin{enumerate}%
\item Increase $N$ by $|S|$ and compute “trial labels” $l_{x} := \{ a \cdot x | a \in S \}$ for each $x \in V$.
\item Pick the vector $z$ from $V$ such that $|l_{z} \cup l| = N$ and add the values in $l_{z}$ to $l$.
\item Initialise new solution set $V' := \{ z \}$. (If any other vectors from $V$ give the same labelling, also add them to $V'$.)
\item Choose a vector $y$ from $V \slash V'$.
\item For each other vector $x$ use the update equation to compute a new solution vector $w$ from $x$ and $y$ and add it to $V'$.
\item If any step 1–5 isn’t possible, signal that the mapping is “full up” and exit.
\item Otherwise rename $V'$ to $V$ and pick the sparsest vector $x$ from $V$ as the current labeller.
\end{enumerate}
\end{itemize}
\textbf{TODO: point out how we’re choosing the RHS elements, not being given them}
An important point here is that we need to preserve as much variety in the vectors in $V$ as possible; that’s why we only reduce the size of $V$ by 1 each iteration rather than by $|S|$.
There’s no essential reason for choosing $p^n := 2^8$, it just happens to fit well with hardware and is low enough to be tractable in terms of memory and time usage, but another potential choice is $p^n := 2^{16}$. In complexity terms, when we’ve labelled $N$ vectors the above algorithm has done $O(N p^{2n})$ operations, the same order as solution using conventional Gaussian elimination. However, as with other alogrithms such as (((5))) the fact that we generating each new vector from two randomly chosen existing solutions \emph{only} with no dependency on anything else means that a parallelised version runs in $O(N p^n)$ timesteps.
\hypertarget{practical_results}{}\subsection*{{Practical results}}\label{practical_results}
So let’s have a look at this in practice:
[[probabilities.gif:pic]]
\textbf{EXPLANATION OF HOW NUMBER OF COMPONENTS INCREASES IN SPURTS}
\textbf{Puzzle 2:} There’s an interesting aspect to the algorithm above. It inherently uses the fact that $\mathbb{F}$ allows division, but we don’t anywhere use the fact that $\mathbb{F}$ also allows subtraction. Mathematicians, and category theorists in particular, are interested in trying to move mathematical results from using \textbf{fields} to using \textbf{rings} – which allow subtraction but not division by all elements – and if possible further so that they only use \textbf{rigs} – where neither subtraction nor division are defined for all elements. So there’s a sense that \emph{division} is an easier to avoid operation than \emph{subtraction}, but in the above there are divisions but no subtractions. So is the opposite is the case, or is there another explanation?
\hypertarget{remind_me_why_were_doing_this}{}\section*{{Remind me why we’re doing this?}}\label{remind_me_why_were_doing_this}
The problem above is one way to tackle the core issue of \emph{perfect hashing}. In general however the restriction to very small sets is not practical: we need to be able to deal with arbitrarily large sets. As discussed in the introduction, we’ve also dealt with the task is to map from names to uniform labels in such a way that there are no collisions. Since the names are likely \emph{not} to be uniform length, uniformly-randomly-distributed vectors it’s common to build a two stage process for doing the labelling to \emph{reduce the general problem to this instance} by the following means:
\begin{itemize}%
\item First use a simple, fixed \textbf{uniform hashing function} to generate a uniform key $u$ for each original key. A small number of bits from this key are used to place the key in one of several buckets, and the remaining bits are used as a uniform random vector “intermediate key”.
\item Within each bucket use a more sophisticated procedure to map the intermediate keys to a set of more compact labels, and produce the final key by concatenating the bucket number and the compact label.
\end{itemize}
This is shown in this diagram:
[[hashing.png:pic]]
If the number of keys to be processed is large, since the first step is essentially uniformly random assignment into buckets, it’s very highly likely that close to the same number of keys have landed in each one and this forms a reliable way to ensure the sophisticated procedure is only applied to a tractably small set of keys. One way to implement the second step is what we’ve looked at here.
This wider context is discussed in greater depth in, for example, (((4))).
\hypertarget{for_more}{}\section*{{For more}}\label{for_more}
The only paper I’ve found taking the ideas from (((1))) further is (((5))), and indeed if you consider the corresponding constructions between characteristc-2 $GF(2^n)$ and characteristic-0 $\mathbb{R}$, some of the formulae are related. Source code implementing the algorithm in this post can be found at (((6))).
\begin{enumerate}%
\item R J Lipton, \href{https://rjlipton.wordpress.com/2012/08/09/a-new-way-to-solve-linear-equations}{A New Way To Solve Linear Equations} . ’Gödel’s Lost Letter and P=NP’ blog.
\item \href{https://en.wikipedia.org/wiki/Birthday_problem}{Birthday problem} , Wikipedia.
\item \href{http://web.stanford.edu/class/ee392d/Chap7.pdf}{Introduction to finite fields.} .
\item \href{http://www.cs.cmu.edu/~avrim/451f11/lectures/lect1004.pdf}{Universal and Perfect hashing} .
\item Joerg Fliege, \href{https://arxiv.org/abs/1209.3995}{A Randomized Parallel Algorithm with Run Time $O(n^2)$ for Solving an $n \times n$ System of Linear Equations} , arxiv.org.
\item Github link
\end{enumerate}
\end{document}