%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Master Thesis in Mathematics
% "Immersions and Stiefel-Whitney classes of Manifolds"
% -- Chapter 1: Formulation of the Immersion Conjecture --
%
% Author: Gesina Schwalbe
% Supervisor: Georgios Raptis
% University of Regensburg 2018
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{Formulation of the Immersion Conjecture}
\label{chap:reformulation}
% Explain carefully how the immersion problem can be reformulated purely
% in terms of homotopy theory. [immersionconj] (The necessary results from differential
% topology and Hirsch-Smale theory should be stated clearly but may be
% presented without proofs.)
This chapter is dedicated to reviewing the concepts and results,
which are needed to formulate the immersion conjecture and its
connection to the theory of characteristic classes.

The (re)formulation in \autoref{sec:reformulation} uses as main
ingredient a theorem by Hirsch and Smale on the relation between
immersions and vector bundle monomorphisms presented in
\autoref{sec:hirschsmale}.
This, together with other required definitions and properties of
immersions, is contained in \autoref{sec:immersions}.
Thereafter, in \autoref{sec:charclsofvb}, characteristic classes of vector
bundles are reviewed. Most importantly, the Stiefel-Whitney
characteristic classes are recalled in \autoref{sec:swclasses},
together with an outline of the way these will be particularly
useful throughout this thesis.
The last section then contains an explanation on how they contribute
to the immersion problem via obstructions.

This chapter is meant as revision and outline, therefore a
couple of preliminary results are merely referenced without proof.

\section{Immersions}\label{sec:immersions}
This section recapitulates the definition some properties
of immersions.

\subsection{Definition}
As already mentioned, immersions are technically local embeddings of
manifolds.
From a different point of view, immersions are merely a special case
of monomorphisms of vector bundles. So, recall that a morphism
$(\xi_1\colon\E_1\to X_1)\to(\xi_2\colon E_2\to X_2)$
of vector bundles over different spaces is a map $F\colon E_1\to E_2$
which is linear on fibers, and that covers its restriction to the zero
section, \idest it makes the following diagram commute:
\begin{center}
  \begin{tikzcd}[column sep=large]
    E_1 \ar[r,"F"]\ar[d, "\xi_1"]
    & E_2 \ar[d, "\xi_2"]
    \\
    X_1 \ar[r, "F|_{\zerosec{\xi_1}}"]
    & X_2
  \end{tikzcd}
\end{center}
Further, remember the fact that such a morphism is a monomorphism in
the category of vector bundles if and only if its restriction to each
fiber is injective.
\begin{Def}
  A smooth map $f\colon M\to N$ of smooth manifolds is called
  an \emph{immersion}, written $M\immto N$, if its differential
  $\Diff f\colon\T M\to\T N$ is a monomorphism of vector
  bundles.
  A homotopy $H\colon M\times I\to N$ which is an immersion in each
  stage is called \emph{regular}.
\end{Def}
\begin{Rem}
  Let $M$ and $N$ be manifolds.
  \begin{enumerate}
  \item
    Immersions are local embeddings, \idest for an
    immersion $f\colon M\immto N$, around every point in $M$
    there is an open neighborhood on which $f$ is a diffeomorphism
    onto its image.
    More descriptive, immersions are mappings that do not allow creases,
    respectively sharp bends, or puncturing
    (see \forexample \cite{outsidein} for nicely illustrated examples)
    However, globally, immersions need not be injective since
    \forexample self-intersections of the image are allowed.
    \begin{proof}
      This is a conclusion from the implicit function theorem.
      For details see \forexample \cite[Chap.~1, Theorem~3.1]{hirsch}.
    \end{proof}
  \item Embeddings of manifolds are exactly those injective immersions
    that are topological embeddings.
    If $M$ is compact, any injective immersion $f\colon M\to N$ is an
    embedding.
    \begin{proof}
      % Argumentation:
      % Every manifold has Riemannian metric
      % Every Riemannian manifold is a metric space, topologies agree
      % For metric spaces, sequentially compact is equivalent to compact
      Use the fact that for manifolds compact is equivalent to
      sequentially compact, in order to get
      \begin{gather*}
        \left\{
          y=\lim_n f(x_n) \middlemid
          (x_n)_{n\in\Nat}\subset M \text{ without limit}
        \right\} \cap M = \emptyset
      \end{gather*}
      directly from injectivity of $f$, and compactness of $M$ and
      $f(M)$.
      Then apply \cite[Chap.~II, Lemma~2.6]{adachi}.
    \end{proof}
  \end{enumerate}
\end{Rem}

\subsection{The Hirsch-Smale Theorem}\label{sec:hirschsmale}
It is easy to see that in general not all vector bundle monomorphisms
between tangent bundles of smooth manifolds need to be the
differential of an immersion. However, taking the differential gives a
canonical inclusion of the set of immersions into the set of vector
bundle monomorphisms.
A theorem of Hirsch and Smale states that this inclusion
actually is a homotopy equivalence,
translating questions on the existence of immersions into the context
of characteristic classes of vector bundles.

For the formulation, one has to equip the respective sets with a
topology as follows.
\begin{Def}
  Let $M$, $N$ be closed smooth manifolds of dimensions $\dim M<\dim N$.
  \begin{enumerate}
  \item
    Equip the set of all vector bundle monomorphisms from $\xi_1$ to
    $\xi_2$ with the compact-open topology (see \forexample
    \cite{hatcher}), and denote that space by $\Mono{\xi_1}{\xi_2}$.
    Note that a path between monomorphisms $F_1$ and $F_2$ in the
    space $\Mono \xi \eta$ is an homotopy from $F_1$ to $F_2$ which is
    a vector bundle monomorphism in each stage.
  \item
    % compare Lecture_Notes_on_Immersions_of_Surfaces_in_3-Space--Nowik.ps
    % Whitney $C^r$\nbd{}topology; see [Hirsch, Differential Topology, Chap 2, p.35]
    Taking the differential yields an injection
    \begin{gather*}
      \Imm M N \longto \Mono{\T M}{\T N}
      \;,\quad
      f\longmapsto\Diff f
    \end{gather*}
    of the set $\Imm M N$ of all immersions from $M$ to $N$.
    Equip $\Imm M N$ in the following with the subspace topology.
    This results in the weak topology described in
    \cite[Section~2.1]{hirsch}, which equals the Whitney
    $C^1$\nbd{}topology since $M$ was chosen to be compact.
    By the way, $\Imm M N$ is open in $C^1(M,N)$ equipped
    with the Whitney $C^1$\nbd{}topology
    (see \cite[Section~2.1, Theorem~1.1]{hirsch}).
  \end{enumerate}
\end{Def}

Now one can state the major result in immersion theory by
Hirsch using preliminary work of Smale
\cite[Sections~5 and 6]{hirschimmersions}.
The following formulation is according to
\cite[Theorem~1.2]{immersionconj}.
\begin{Thm}[Hirsch-Smale]\label{thm:hirschsmale}
  Let $M$, $N$ be closed manifolds with $\dim M<\dim N$.
  Then the differential map
  $\Diff\colon \Imm M N\to \Mono{\T M}{\T N}$
  induces isomorphisms on the homotopy groups.
  Especially,
  \begin{gather*}
    \Diff_*\colon
    \pi_0(\Imm M N) \overset\sim\longto \pi_0(\Mono{\T M}{\T N})
  \end{gather*}
  describes an isomorphism of path-connected components.
  % Original formulation by Hirsch in [hirschimmersions], sec. 5:
  Therefore, every vector bundle monomorphism
  $F\colon\T M\to\T N$ is homotopic (through vector bundle
  monomorphisms) to a monomorphism which is the differential
  $\Diff f$ of a smooth map $f\colon M\to N$, \idest of an
  immersion.
  \begin{proof}
    See \cite[Theorem~8.2.1]{introductionhprinciple} or the original
    paper \cite{hirschimmersions}.
  \end{proof}
\end{Thm}
Thus, any monomorphism of vector bundles over smooth, closed manifolds
$M$ and $N$ implies the existence of an immersion from $M$ to $N$.
This conclusion will be needed to reformulate the immersion problem.

\subsection{Normal Bundles}
Another nice property of immersions is that every immersion gives
rise to a normal bundle. This will finally make it possible to
translate the existence of an immersion of certain codimension into
the existence of a vector bundle of certain rank fulfilling a homotopy
invariant lifting property.
\begin{Def}
  Let $\imm\colon M^n\immto N^{n+r}$ be an immersion of smooth
  manifolds.
  The \emph{normal bundle $\N{\emb}$ of $\imm$}
  is the well-defined, quotient bundle $\pb{\imm}\T N/\T M$ of rank $r$,
  respectively the one fulfilling
  $\N{\imm}\oplus\T M\cong\pb{\imm}\T N$.
\end{Def}
Recall that manifolds have the very handy property that they admit a
unique tangent bundle.
Similarly, a normal bundle of an immersion into Euclidean space is
unique up to a notion of stable equivalence, under which
characteristic classes will turn out to be invariant.
\begin{Def}
  Call two vector bundles $\xi_1$, $\xi_2$ over the same space
  \emph{stably equivalent} in case there are $s_1, s_2\in\Nat$ such
  that $\xi_1\oplus\trivbdl^{s_1}\cong\xi_2\oplus\trivbdl^{s_2}$.
\end{Def}
Now the promised notion of the stable normal bundle can be clarified.
\begin{LemDef}
  Let $M^n$ be a closed, smooth manifold.
  Then all normal bundles of immersions of $M$ into
  Euclidean spaces are stably equivalent.
  The resulting equivalence class is called the
  \emph{stable normal bundle of $M$}, written $\N M$.
  When working with vector bundles in a context that is stable in the
  above sense, like \forexample characteristic classes, the stable
  normal bundle of $M$ may be identified with an arbitrary
  representative of its class.
  \begin{proof}[Proof (sketch)]
    First show that every normal bundle of an immersion is stably
    equivalent to the
    normal bundle of \emph{some} embedding (\idest some injective
    immersion). Then ensure that all normal bundles of embeddings are
    stably equivalent.
    \begin{description}
    \item[Immersions]
      Any immersion $\imm\colon M\immto\R^{n+r}$ can be raised to
      higher codimension by concatenation with the linear embedding
      $l\colon\R^{n+r}\immto\R^{n+r+s}$ into the first components.
      As the normal bundles $\N{\imm}$ and
      $\N{l\circ\imm}\cong\N{\imm}\oplus\trivbdl^s$ are stably
      equivalent, raising the codimension does not change the stable
      equivalence class.
      Furthermore, since a regular homotopy yields an
      isomorphism on the normal bundles, it suffices to show:
      \begin{claim}
        For $r>n$ every immersion $M\immto\R^{n+r}$ is regularly
        homotopic to an embedding.
      \end{claim}
      For the claim use bumping techniques
      %as needed for the Thom transversality theorem
      to show that for $r>n$ every
      immersion $\imm\colon M\immto\R^{n+r}$ is regularly homotopic to
      an injective immersion.
      This is \forexample \cite[Chap.~II, Lemma~2.5]{adachi}.
      However, as $M$ is compact, injective immersions
      are embeddings.
    \item[Embeddings]
      By Whitney's embedding theorem
      (see \forexample \cite[Chap.~II.2]{adachi}),
      it is known that every manifold admits an embedding into some
      real space.
      Further, by \forexample the General Position theorem
      (compare \cite[Chap.~2]{embeddingsummary})
      or Haefliger's theorem (see \forexample \cite[Chap.~II.1]{adachi}),
      it is known that for sufficiently large $k\in\Nat$ all embeddings
      $M\immto\R^{n+k}$ are isotopic, \idest homotopic through embeddings,
      and hence their normal bundles are isomorphic.
      Therefore, all normal bundles of embeddings of a manifold are
      stably equivalent.
      \qedhere
    \end{description}
  \end{proof}
\end{LemDef}

\section{Characteristic Classes of Vector Bundles}\label{sec:charclsofvb}
The theory of characteristic classes provides the key tools
for the rest of this thesis. Therefore, this section
revises basic results, and recalls in detail several properties
of Stiefel-Whitney classes. The latter are generators of all
characteristic classes of vector bundles, and will be essential in
proving the theorems of the subsequent chapters.

\subsection{General Definition and Properties}
Before starting off with the definition of characteristic classes,
we recall the definition of universal bundles and Steenrod's
classification theorem. For more details see
\cite[Chapter~14.4]{tomdieck}.
\begin{LemDef}\label{def:charcls}
  \begin{enumerate}
  \item Any topological group $G$ admits a contractible space $\EG$ with a
    free $G$\nbd{}action, and a corresponding principal $G$\nbd{}bundle
    \begin{gather*}
      \gamma^G\colon \EG\longto\BG\coloneqq \EG/G
      \;,
    \end{gather*}
    called the  \emph{universal $G$\nbd{}bundle},
    where $\gamma_G$, $\EG$, and $\BG$ are all unique up to
    homotopy.
    $\BG$ is called the \emph{classifying space} for principal
    $G$\nbd{}bundles.
    For construction and uniqueness see \cite[Example~1B.7~ff.]{hatcher},
    respectively note that universal coverings are unique up to homotopy.
  \item\label{item:classificationthm}
    $\gamma^G$ fulfills the following universal property:
    For any space $X$ admitting the homotopy type of a CW-complex
    there is a bijection between $[X,\BG]$, which denotes the homotopy
    classes of maps from $X$ to $\BG$, and the isomorphism classes of
    principal $G$\nbd{}bundles over $X$, given by
    \begin{gather*}
      \left(f\colon X\to\BG \right) \longmapsto \pb f \gamma^G
      \;.
    \end{gather*}
    This correspondence is natural in $X$, and is a version of
    Steenrod's classification theorem,
    see
    \cite[Theorem~14.4.1]{tomdieck}, or
    \cite[Theorem~1.4, p.~75]{immersionconj}.
  \end{enumerate}
\end{LemDef}
As becomes clear directly from the statement, the classifying
theorem serves in translating bundle theoretic problems into homotopy
theoretic ones, which will be a crucial step in reformulating the
immersion problem in \autoref{sec:reformulation}.
Such homotopy theoretic questions can then be tackled using known
cohomological tools, which yields the general concept of
characteristic classes.
Some important examples for vector bundles, namely the
Stiefel-Whitney classes, will be discussed in detail in
\autoref{sec:swclasses}.
\begin{Def}
  A \emph{characteristic class}
  \begin{compactitemize}
  \item of degree $i$
  \item with coefficients in a ring $R$
  \item for principal $G$\nbd{}bundles for a group $G$
  \end{compactitemize}
  is a natural transformation
  \begin{gather*}
    \SwapAboveDisplaySkip
    \Cl\colon [-, \BG] \Longrightarrow \H^i(-; R)\;.
  \end{gather*}
  of contravariant functors from the category of spaces with the
  homotopy type of a CW-complex to the category of sets.
\end{Def}
\begin{Rem}
  By Brown's representation theorem
  (\forexample \cite[Chap.~4.E]{hatcher}),
  $\H^i(-;R)$ is a representable functor represented by the
  Eilenberg-MacLane space $K(i,R)$.
  Thus, by the Yoneda lemma, a characteristic class is
  represented by a morphism
  \begin{gather*}
    \cl\colon \BG \longto K(i, R)
  \end{gather*}
  in $\Top$, \idest by a cohomology class $\cl$ of $\BG$.
  Thus, for a space $X$, which admits the homotopy type of a
  CW-complex,
  applying $\Cl$ to a principal $G$\nbd{}bundle over $X$ that is
  represented by a morphism $\eta\colon X\to\BG$
  as in Definition~\itemref{def:charcls}{item:classificationthm},
  yields
  \begin{gather*}
    \Cl(X) = \pb{\eta} \cl \in \H^i(X;R)
    \;.
  \end{gather*}
  This describes a one-to-one correspondence between
  characteristic classes as above and cohomology classes in
  $\H^i(BG;R)$, and in the following any characteristic class will be
  identified with its corresponding cohomology class.
\end{Rem}

As this thesis is mainly concerned with vector bundles, we have a
closer look at the significance of classifying spaces in that context,
especially at their stability property and its implications for normal
bundles.
\begin{Lem}\label{lem:classificationvb}
  Let $X$ be any space, let $M^n$ be a manifold, and $r,s\in\Nat$.
  \begin{enumerate}
  \item\label{item:vbcharacterisation}
    There is a natural equivalence between the category of
    $n$\nbd{}dimensional vector bundles and that of principal
    $\Orth(n)$\nbd{}, respectively $\GL n$\nbd{}bundles.
  \item\label{item:boincl}
    The inclusion $\B\Orth(r)\to\B\Orth(r+s)$ is $r$\nbd{}connected.
  \item\label{item:bomaps}
    On vector bundles, the inclusion $\B\Orth(r)\to\B\Orth(r+s)$
    represents the direct sum with the trivial bundle $\trivbdl^s$.
    \Idest for vector bundles $\xi_1$ and $\xi_2$ over $X$ with
    classifying maps $f_1$ respectively $f_2$, there is a lift up to
    homotopy of the form
    \begin{center}
      \begin{tikzcd}
        X \ar[r, "f_1"]
        \ar[dr, bend right, "f_2"{left}]
        & \B\Orth(r)
        \ar[d, "\incl"]
        \\
        & \B\Orth(r+s)
      \end{tikzcd}
    \end{center}
    if and only if $\xi_1\oplus\trivbdl^{s}\cong\xi_2$.
  \item\label{item:charclsstablenormalbundle}
    Taking the limit of all classifying maps of the normal bundles of
    embeddings of $M$ yields a homotopy class in
    $[M,\B\Orth=\lim_{k\to\infty}\B\Orth(k)]$ % this is \injlim
    that classifies the stable normal bundle of $M$ uniquely.
    Any lift of it in $[M,\B\Orth(r)]$ represents a vector bundle
    $\N{}$ with the property $\N{}\oplus\T M\cong\trivbdl^{n+r}$.
  \end{enumerate}
  \begin{proof}
    The natural equivalence is given by the known construction of
    associated vector bundles, and the stability property of the
    family $(\B\Orth(n))_n$ becomes clear from
    $\B\Orth(n)\cong\lim_{k\to\infty}G_n(\R^k)$
    where $G_n(\R^k)$ is the Grassmann manifold of $n$\nbd{}dimensional
    vector subspaces of $\R^k$.

    For the $r$\nbd{}connectivity in \ref{item:boincl}, observe that
    the diagram
    \begin{center}
      \begin{tikzcd}[row sep=small, column sep=small]
        \Orth(r) \ar[r]\ar[d,"\incl"{near start}]
        &\E\Orth(r) \ar[r] \ar[d,"\incl"{near start}]
        &\BO(r) \ar[d,"\incl"{near start}] \\
        \Orth(r+1) \ar[r]\ar[d]
        &\E\Orth(r+1) \ar[r]
        &\BO(r+1) \\
        \Sphere{r}
      \end{tikzcd}
    \end{center}
    commutes, where the rows are the defining fiber bundles for the
    classifying spaces, and $\Orth(r)\to\Orth(r+1)\to\Sphere r$
    is the well-known fiber bundle of the inclusion of orthogonal groups.
    Since $\E\Orth(s)$ is contractible for any $s\in\Nat$,
    the long exact sequences of homotopy for the horizontal fiber bundles yield
    $\pi_i(\Orth(r))\cong\pi_{i+1}(\BO(r))$ for $i\in\Nat$, analogously for $r+1$.
    The sequence for the vertical fiber bundle yields that
    $\Orth(r)\to\Orth(r+1)$ is $r$\nbd{}connected, and commutativity gives
    the same for $\incl\colon\BO(r)\to\BO(r+1)$.

    For the lifting property of the stable normal bundle, consider a
    lift $\N{}\in[M,\BO(r)]$, $r>1$, by \ref{item:vbcharacterisation}
    classifying a vector bundle over $M$, which we will also call
    $\N{}$. By \ref{item:bomaps} and the definition
    of the stable normal bundle, there is some $s\in\Nat$
    such that
    \begin{gather*}
      \T M\oplus\N{}\oplus\trivbdl^s\cong\trivbdl^{n+r+s}
      \;.
    \end{gather*}
    Assume $s>0$.
    In order to show that this still implies
    $\T M\oplus\N{}\cong\trivbdl^{n+r}$ (\idest that their
    classifying maps are homotopic), consider the corresponding
    homotopy commutative diagram of classifying maps
    \begin{center}
      \begin{tikzcd}[column sep=large]
        M
        \ar[r, "\T M\oplus\N{}", shift left]
        \ar[r, "\trivbdl^{n+r}"{below}, shift right]
        \ar[dr, bend right, "\trivbdl^{n+r+s}\,"{left}]
        & \B\Orth(n+r)
        \ar[d, "\incl"]
        \\
        & \B\Orth(n+r+s)
      \end{tikzcd}
    \end{center}
    This says that $\incl\circ\T M\oplus\N{}$ and
    $\incl\circ\trivbdl^{n+r}$ must be homotopic via
    some homotopy
    \begin{gather*}
      H\colon M\times I\to\BO(n+r+s) \;.
    \end{gather*}
    The trick now is to use that by Morse theory $M$ has the homotopy
    type of an $n$\nbd{}dimensional CW-complex, together with $\incl$ being
    $(n+r)$\nbd{}connected, $r>0$, and both $\BO(n+r+s)$ and $\BO(n+r)$
    being path-connected. Because with these assumptions
    obstruction theory yields that
    $H$ lifts to a homotopy $M\times I\to\BO(n+r)$ between
    the classifying maps of $\T M\oplus\N{}$ and $\trivbdl^{n+r}$, as
    was needed
    (see \forexample \cite[Lemma~4.6]{hatcher}).
  \end{proof}
\end{Lem}
\begin{Not}
  Throughout this thesis assume $R=\Zmod2$ and $G=\Orth(n)$
  respectively $G=\Orth$ if not stated otherwise.
\end{Not}

\subsection{Stiefel-Whitney Classes}
\label{sec:swclasses}
Now that the general concept is known, this section reviews the
defining and immediate properties of the Stiefel-Whitney
classes, a generating set for the ring $\H^*(\BO)$ of characteristic
classes of vector bundles.
This makes them especially interesting for investigation,
as any property stable under cohomology ring operations only needs to
be checked on the generating set.
Furthermore, they will be invaluable for constructing new
characteristic classes used as obstructions or indicators.
More precisely, their duals, their inverses under certain Steenrod
operations called Wu classes, and a couple of special polynomials
evaluated on them will be used.

First start with the defining properties of the Stiefel-Whitney
classes. Compare \forexample \cite[compare §4, p.~37]{milnor}.
\begin{Def}\label{def:swclasses}
  The \emph{Stiefel-Whitney classes} are
  characteristic classes for principal $\Orth$\nbd{}bundles
  respectively vector bundles,
  \idest cohomology classes
  $\ws{i}\in \H^i(\BO;\Zmod2)$, $i\in\Nat$,
  fulfilling the following properties for any vector bundles $\xi$ and
  $\eta$ over a space $B$, and any map $f\colon A\to B$ of spaces:
  \begin{axioms}
  \axiom[Naturality] $\pb f\w{i}{\xi} = \w{i}{\pb f \xi}$,
  \axiom $\w{0}{\xi}=1$,
  \axiom $\W{\gamma_1} = 1 + x$,
  \axiom[Multiplicativity]\label{tag:swclassesmultiplicativity}
  $\W{\xi \oplus \eta} = \W{\xi}\cup \W{\eta}$,
  \\\idest in degree $n$ we have
    $\w{n}{\xi\oplus\eta} = \sum_{i+j=n}\w{i}{\xi} \cup \w{j}{\eta}$,
  \end{axioms}
  where the \emph{total Stiefel-Whitney class}
  $\Ws\coloneqq\sum_{i\geq 0}\ws{i}$ is the formal sum of all
  Stiefel-Whitney classes,
  $\gamma_1$ is the tautological line bundle over $\RP 1$,
  $\RPinf\cong\BO(1)\to\BO$,
  and $x$ is the%
  \footnote{
    This is well-defined: A ring $R$ of the form $\Zmod2[x]$
    with $\deg(x)=1$ only admits two elements in degree~1, $0$ and a
    generator. Therefore, there exists exactly one ring
    isomorphism, and this sends the unique generator in
    degree 1 to $x$.
  }
  generator of $\H^*(\RPinf;\Zmod2)\cong\Zmod2[x]$.
\end{Def}
Note that naturality is already implied by the requirements for a
characteristic class. However, given only the above axioms:
\begin{Thm}
  Stiefel-Whitney classes exist and are uniquely defined by the above
  properties. Furthermore, they generate the ring
  $\H^*(\BO;\Zmod2)$, which is isomorphic to $\Zmod2[\ws{i}\mid i\geq1]$.
  \begin{proof}[Proof]
      One possible concrete construction utilizes the Euler
      class, another one via Steenrod squares can be
      found in Theorem~\ref{thm:altdefswclasses}.
      For uniqueness see \cite[Theorem~7.3]{milnor}.
      For the generating property see \forexample
      \cite[Theorem~7.1~ff.]{milnor}, or \cite[Chap.~7.6]{may}.
  \end{proof}
\end{Thm}

As already mentioned, the above generating property means that every
characteristic class of vector bundles of a fixed dimension can be
represented as a certain combination of Stiefel-Whitney classes.
Moreover, they---and hence all characteristic classes---behave
extremely well with respect to vector bundle operations as emphasized
below.
\begin{Rem}
  \label{rem:propswclasses}
  Let $\xi$, $\eta$ be vector bundles over a space $X$.
  \begin{enumerate}
  \item\label{item:propswclasses:dimesioncut} $\w{i}{\eta} = 0$
    for any vector bundle $\eta$ with $\rk\eta < i$.
    Therefore, the total Stiefel-Whitney class $\W{\xi}$ is
    well-defined (\idest the sum is finite)
    for any vector bundle $\xi$ of finite rank.
    \begin{proof}
      See \cite[Sec.~19.4]{tomdieck}.
    \end{proof}
  \item\label{item:swoftrivbdl}
    $\w{i}{\trivbdl}=0$ for $i>0$, and one immediately concludes
    from multiplicativity:
    \begin{enumerate}
    \item\label{item:swclassesstable}
      The Stiefel-Whitney classes are stable, \idest
      $\w{i}{\xi\oplus\trivbdl} = \w{i}{\xi}$, which once more proves
      the stability property of characteristic classes of vector bundles.
      Thus, for a manifold $M^n$, all normal bundles $\N{\emb}$ of
      embeddings $\emb\colon M\to\R^{n+k+r}$ share the same
      Stiefel-Whitney classes, written $\W{\N M}$ accordingly.
      Note that $\W{\N M} = \pb{\N{M}}\ws{i}$, where $\N M$ denotes the
      classifying map of the stable normal bundle.
    \item\label{item:wuclassmfdinverse}
      If $\xi\oplus\eta = \trivbdl^{\rk\xi+\rk\eta}$, then
      $\W{\xi}\cup\W{\eta}=1$.
      Especially, for any choice of embedding $\emb\colon M^n\to\R^{n+k}$
      with normal bundle $\N{\emb}$ of a smooth manifold $M$ we have
      $\T M\oplus\N{\emb} = \trivbdl$, and therefore
      $1 = \W{\T M} \cup \W{\N{\emb}} = \W{\T M}\cup\W{\N M}$.
    \end{enumerate}
    \begin{proof}
      The trivial rank $n$ bundle over $X$ is defined as the pullback
      $\pb \pi \trivbdl^n$ of the rank $n$ bundle
      $\trivbdl^n\colon \R^n\to\pt$ over the point by the trivial map
      $\pi\colon X\to\pt$. The naturality of the Stiefel-Whitney
      classes gives
      \begin{gather*}
        \W{\trivbdl^n}
        = \pb\pi \W{\trivbdl^n}
        \in\pb\pi \left(\H^*(\pt;\Zmod2)\right)
        \;,
      \end{gather*}
      and the result follows from $\H^i(\pt;\Zmod2) = 0$ for $i>0$.
    \end{proof}
  \end{enumerate}
\end{Rem}

In order to algebraically work with the Stiefel-Whitney classes, the
formal inverse is often handy. Especially, since it is well-known for
manifolds as explained below.
\begin{Def}
  Define the \emph{dual Stiefel-Whitney (characteristic) classes}
  $\dualws{i}$ in degree $i$ inductively by
  \begin{align*}
    1 &= \dualws{0}\cup\ws{0} = \dualws{0}    &&\text{in degree 0}\\
    0 &= \sum_{i+j=n} \dualws{i}\cup\ws{j}  &&\text{in degree n>0}
  \end{align*}
  Denoting the formal sum by $\dualWs\coloneqq \sum_{i\geq0} \dualws{i}$ as above
  this can be reformulated as
  \begin{gather*}
    1 = \Ws\cup\dualWs
  \end{gather*}
  in the completion of the polynomial ring
  $\H^*(\BO)\cong\Zmod2[\ws{i}\mid i\in\Nat]$.
\end{Def}
By
Remark~\itemref{rem:propswclasses}{item:swoftrivbdl}\ref{item:wuclassmfdinverse},
a first example of dual Stiefel-Whitney classes is given by the
canonical tangent and normal bundle of a manifold, which makes them
especially handy in the context relevant for the immersion conjecture.
\begin{Def}
  For a manifold $M$ use the following abbreviation
  \begin{align*}
    \W{M} &\coloneqq \W{\T M}
            \;,
    &\text{and thus}&
    &\dualW{M} &\coloneqq \dualW{\T M} = \W{\N M}
    \;.
  \end{align*}
\end{Def}

\section{Reformulation of the Immersion Conjecture}
\label{sec:reformulation}

The immersion problem can finally be clearly stated with the
definitions from \autoref{sec:immersions}.
The goal of this section is to reformulate the immersion conjecture to
a statement that can be analyzed with means of homotopy theory of
vector bundles, and show how characteristic classes relate to this by
finding a powerful obstruction.
The latter will be followed up in the subsequent chapter.

Before reformulating, recall the actual immersion conjecture.
\begin{Def}
  For $n\in\Nat$ consider the unique minimal binary expansion
  \begin{gather*}
    n=2^{i_1}+\dotsb+2^{i_{l_n}},
    \quad\text{with}\quad
    i_1<\dotsb<i_{l_n}
    \;.
  \end{gather*}
  Define $\alpha(n)\coloneqq l_n$, \idest $\alpha(n)$ is the number of
  ones in the binary notation of $n$.
\end{Def}
\begin{Thm}\label{thm:immersionconj}
  For $n\in\Nat$, every closed, smooth, $n$\nbd{}dimensional manifold
  immerses into $\R^{2n-\alpha(n)}$.
\end{Thm}
In the style of this conjecture, an $n$\nbd{}manifold that immerses into
some $\R^{2n-\alpha(n)}$ will be said to have the
\emph{immersion property}.
And the question, whether a particular manifold does have the
immersion property, will be referred to as the \emph{immersion problem} for
this manifold.

Recall, that by the Theorem~\ref{thm:hirschsmale} of Hirsch and Smale,
any vector bundle monomorphism between tangent bundles of smooth
manifolds implies the existence of an immersion.
This is the main ingredient for the subsequent reformulation of the
immersion problem.
\begin{Thm}\label{thm:immersionconj:equivalences}
  Let $n,k\in\Nat$ and $M^n$ be a closed, smooth, $n$\nbd{}dimensional manifold.
  The following statements are equivalent.
  \begin{enumerate}
  \item\label{item:immersionconj:1}
    $M$ immerses into $\R^{n+k}$.
  \item\label{item:immersionconj:2}
    There is a vector bundle monomorphism $F\colon\T M\to\T{\R^{n+k}}$.
  \item\label{item:immersionconj:3}
    There is a $k$\nbd{}dimensional vector bundle
    $\N{}\colon\E{\N{}}\to M$ over $M$ with
    \begin{gather*}
      \N{}\oplus\T M\cong\trivbdl^{n+k}
      \;.
    \end{gather*}
  \item\label{item:immersionconj:4}
    For the map $\N M\colon M\to\B\Orth$ classifying the stable
    normal bundle over $M$ there is a lift $\N{}\colon M\to\B\Orth(k)$
    making the following diagram commute up to homotopy
    \begin{center}
      \begin{tikzcd}
        M
        \ar[r, "\N{}"]
        \ar[dr, "\N{M}"{left}, bend right]
        & \BO(k) \ar[d, "\incl", hookrightarrow] \\
        & \BO
      \end{tikzcd}
    \end{center}
  \end{enumerate}
\end{Thm}
% From a homotopy theoretical viewpoint, one is most
% interested in statement \ref{item:immersionconj:4}
% because it allows to apply the huge arsenal of characteristic classes
% of vector bundles, an example of which will be discussed in
% \autoref{chap:massey}.

\begin{proof}[Proof of Theorem~\ref{thm:immersionconj:equivalences}]
  The strategy is to show
  \ref{item:immersionconj:1}$\Rightarrow$%
  \ref{item:immersionconj:4}$\Rightarrow$%
  \ref{item:immersionconj:3}$\Rightarrow$%
  \ref{item:immersionconj:2}$\Leftrightarrow$%
  \ref{item:immersionconj:1}.
  \begin{description}
  \item[\ref{item:immersionconj:1}$\Rightarrow$\ref{item:immersionconj:4}:]
    The classifying map of an immersion's normal bundle
    lifts $\N{M}$ as required,
    using Steenrod's classification theorem
    \itemref{def:charcls}{item:classificationthm} and the properties
    of the stable normal bundle from
    Lemma~\itemref{lem:classificationvb}{item:charclsstablenormalbundle}.
  \item[\ref{item:immersionconj:4}$\Rightarrow$\ref{item:immersionconj:3}:]
    Also, by
    Lemma~\itemref{lem:classificationvb}{item:charclsstablenormalbundle},
    any rank $k$ vector bundle that is represented by a lift of
    $\N{M}$ to $[M,\B\Orth(k)]$ as in \ref{item:immersionconj:4},
    has the property needed for \ref{item:immersionconj:3}.
  \item[\ref{item:immersionconj:3}$\Rightarrow$\ref{item:immersionconj:2}:]
    % In order to get from a vector bundle monomorphism
    % $F\colon\T M\to\T{\R^{n+k}}$ to a vector bundle dual to the
    % tangent bundle in the sense of \ref{item:immersionconj:3}, note that
    % $\pb f\T{\R^{n+k}}$ for $f=F|_{\zerosec{\T M}}$ is
    % trivial, and that $F\colon \T M\to \pb f\T{\R^{n+k}}$ is not only
    %% Wrong according to George??
    % fiber-wise, but globally injective of constant rank
    % $\dim M$.
    % Thus, as in the definition of normal bundles,
    % $\N{}\coloneqq\pb f\T{\R^{n+k}}/\T M$ is a vector bundle over $M$
    % that obviously fulfills the required property of
    % \ref{item:immersionconj:3}.
    %
    When given some rank $k$ vector bundle $\N{}$
    such that $\N{}\oplus\T M\cong\trivbdl^{n+k}$, there is a vector
    bundle monomorphism $\T M\to\trivbdl^{n+k}$ over $M$. Then the
    following chain of vector bundle morphisms
    \begin{center}
      \begin{tikzcd}
        \T M \ar[d]
        \ar[r, hookrightarrow]
        & M\times\R^{n+k} \ar[d,"\trivbdl^{n+k}"]
        \ar[r]
        & \pt\times \R^{n+k} \ar[d,"\trivbdl^{n+k}"]
        \ar[r, hookrightarrow]
        & \R^{n+k}\times \R^{n+k} \ar[d,"\trivbdl^{n+k}"]
        \\
        M
        \ar[r,equals]
        & M
        \ar[r]
        & \pt
        \ar[r, hookrightarrow]
        & \R^{n+k}
      \end{tikzcd}
    \end{center}
    is fiber-wise injective in each stage, and hence a monomorphism as
    was needed.
  \item[\ref{item:immersionconj:1}$\Leftrightarrow$\ref{item:immersionconj:2}:]
    The tricky part is to relate \ref{item:immersionconj:1} and
    \ref{item:immersionconj:2}, even though it is easily seen that
    \ref{item:immersionconj:1} implies \ref{item:immersionconj:2} by
    simply taking $F$ to be the differential $\Diff f$ of the
    immersion from \ref{item:immersionconj:1}.

    The converse direction is an application of the Hirsch-Smale
    theorem~\ref{thm:hirschsmale}.
    However, first substitute the non-compact manifold $\R^{n+k}$ with
    the compact sphere $N=\Sphere{n+k}$, to make $M$ and $N$ comply
    with the assumptions of the theorem:
    As $\dim M<n+k$ by assumption,
    the image of $M$ under any immersion $M\to\Sphere{n+k}$ is a
    zero-set by Sard's theorem (see \forexample \cite[Chap.~3,
    Theorem~1.3]{hirsch}), and hence every such immersion misses a
    point in $\Sphere{n+k}$, thus factoring over an immersion
    $M\to\R^{n+k}$.
    This then shows that also \ref{item:immersionconj:2} implies
    \ref{item:immersionconj:1} which makes them equivalent.
    \qedhere
  \end{description}
\end{proof}

This now gives rise to involve the powerful obstruction theory of
characteristic classes of vector bundles as follows.
\begin{Cor}\label{cor:obstruction}
  Let $n,k\in\Nat$, and $M^n$ be a smooth, closed manifold.
  If $M$ immerses into $\R^{n+k}$, then $\dualw{i}{M}=0$ for all
  $i>k$.
  \begin{proof}
    By Theorem~\ref{thm:immersionconj:equivalences} $M$ immerses
    into $\R^{n+k}$ if and only if there is a rank\nbd{}$k$
    normal bundle $\N{}$ of $M$.
    Since the Stiefel-Whitney classes are stable,
    $\W{\N{}}=\W{\N M}=\dualW{M}$.
    However, as explained in
    Remark~\itemref{rem:propswclasses}{item:propswclasses:dimesioncut},
    all Stiefel-Whitney classes $\w{i}{\N{}}$ of degree $i$ exceeding
    the rank $k$ of $\N{}$ are zero.
  \end{proof}
\end{Cor}
As a result, the immersion conjecture requires that all $n$\nbd{}manifolds
have vanishing dual Stiefel-Whitney classes in degrees $i>n-\alpha(n)$.
That this is true, is a theorem of Massey which will be proven in
\autoref{chap:massey}. It was an inspiration to state the conjecture
with the value $k=n-\alpha(n)$ in the first place.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "thesis"
%%% ispell-local-dictionary: "en_US"
%%% End:


\section{Conclusion}
By including theoretical considerations, such as initialization, gradients, and sparsity, we have developed a new neural multiplication unit (NMU) that outperforms the state-of-the-art models on established extrapolation and sequential tasks.
Our model converge more consistently, faster, to more sparse solutions than previously proposed models, and supports all input ranges unlike NALU.

A natural next step would be to extend the NMU to support division and add gating between the NMU and NAU, to be comparable in theoretical features with NALU.
However we find, both experimentally and theoretically, that learning the division is impractical, because of the singularity when dividing by zero, and that a sigmoid-gate that chooses between two functions with vastly different convergences properties, such as a multiplication unit and an addition unit, cannot be consistently learned.

%Alternative
%An important aspect of neural networks is supporting a large hidden size with a distributed representation and redundancy.
%We find that our proposed Neural Multiplication Unit significantly outperforms previous models when increasing the hidden size of the network.
Finally, when it comes to considering more than just two inputs to the multiplication layer, our model performs significantly better than previously proposed methods and variations of these.
The ability for a neural layer to consider more than just two inputs, is critical in neural networks where the desired function is unknown.


\def\PS{{\mathop{\mathsf{PS}}}}

\section{Model Assessment}

\subsection{No Free Lunch}

\begin{frame}
  \frametitle{No Free Lunch}

  \begin{itemize}
    \item In the past lectures, we have come across many learning algorithms and classification techniques.
    \item They have properties such as
      \begin{itemize}
        \item low computational complexity
        \item incorporation of prior knowledge
        \item linearity\,/\,non-linearity
        \item optimality with respect to certain cost functions, etc.
      \end{itemize}
   \item Some compute smooth decision boundaries, some compute rather non-smooth decision boundaries.
  \end{itemize}
  \pspread

  We really have to ask:
  \begin{center}
    \structure{Are there any reasons to favor one algorithm over another?}
  \end{center}
\end{frame}

\begin{frame}
  \frametitle{No Free Lunch \cont}

  \begin{theorem}
    Given a cost function $f \in {\mathcal{F}}$, an algorithm $A$ and costs $c_m$ for a specific sample that is iterated on $m$ times.\\[.3cm]
    The performance of an algorithm is the conditional probability $P(c_m | f, m, A)$.\\[.5cm] \pause
    The \structure{No Free Lunch Theorem} states that for any two algorithms $A_1$ and $A_2$:
    \begin{displaymath}
      \sum_f P(c_m | f, m, A_1) = \sum_f P(c_m | f, m, A_2)
    \end{displaymath}
  \end{theorem}
\end{frame}

\begin{frame}
  \frametitle{No Free Lunch \cont}

  \structure{Consequences for classification methods:}

  \begin{itemize}
    \item If no prior assumptions about the problem are made, there is \textbf{NO} overall superior or inferior classification method! \pause
    \item We should be skeptical regarding studies that demonstrate the overall superiority of a particular method.\\[0.5cm] \pause
    \item We have to focus on the aspects that matter most for the classification problem:
      \begin{itemize}
        \item prior information
        \item data distribution
        \item amount of training data
        \item cost functions
      \end{itemize}
  \end{itemize}
\end{frame}

\subsection{Off-Training Set Error}

\begin{frame}
  \frametitle{Off-Training Set Error}

  \structure{Off-training set error:}

  \begin{itemize}
    \item Specifies the error on samples that are not contained within the training set.
    \item For large training data sets, the off-training set is necessarily small.
    \item Used to compare general classification performance of algorithms.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Off-Training Set Error \cont}

  \begin{itemize}
    \item Consider a two-class problem with training data set ${\mathcal{D}}$ consisting of patterns $\vec x_i$ and labels $y_i = \pm 1$. \pause
    \item $y_i$ is generated by an unknown target function: $F(\vec x_i) = y_i$. \pause
    \item The expected off-training set classification error for the $k$-th learning algorithm is:
      \begin{displaymath}
        E_k \{e | F, n\} = \sum_{\vec x \notin {\mathcal{D}}} p(\vec x) \left[ 1 - \delta(F(\vec x), h(\vec x)) \right] p_k(h(\vec x) | {\mathcal{D}})
      \end{displaymath}
      where $e$ is the error and $h(\vec x)$ the hypothesis on the data.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Off-Training Set Error \cont}

  \begin{figure}
    \centering
    \resizebox{0.7\linewidth}{!}{
      \input{\texfigdir/off_training_performance.pstex_t}
    }
    \vspace*{0.5cm}
    \caption{\footnotesize Each square represents all possible classification problems. $+$/$-$ indicates better/worse generalization than the average (adapted from Duda, Hart).}
  \end{figure}
\end{frame}

\subsection{Bias and Variance}

\begin{frame}
  \frametitle{Bias and Variance}

  \begin{itemize}
    \item The \emph{No Free Lunch Theorem} states that there is no general best classifier. \pause
    \item But we have to assess the quality of a learning algorithm in terms of the \structure{alignment} to the classification problem. \pause
    \item This can be achieved using the \structure{bias-variance} relation.
  \end{itemize}
  \pspread

  \structure{Bias:}

  \begin{itemize}
    \item The bias measures the accuracy or quality of the match: \\
      \structure{high bias means poor match}.
  \end{itemize}
  \pspread

  \structure{Variance:}

  \begin{itemize}
    \item The variance measures the precision of specificity for the match: \\
      \structure{high variance implies a weak match}.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Regression}

  The bias-variance relation is very demonstrative in the context of regression:

  \begin{itemize}
    \item Let $g(\vec x ; {\mathcal{D}})$ be the regression function. \pause
    \item The mean-square deviation from the true function $F(\vec x)$ is:
      \begin{eqnarray*}
         \lefteqn{E_{\mathcal{D}} \left\{ \big(g(\vec x; {\mathcal{D}}) - F(\vec x)\big)^2 \right\}} \\
         & & = \underbrace{E_{\mathcal{D}} \Big\{g(\vec x ; {\mathcal{D}}) - F(\vec x) \Big\}^2}_{\mbox{\small (\structure{bias})}^2} +
               \underbrace{E_{\mathcal{D}} \left\{ \Big(g(\vec x; {\mathcal{D}}) - E_{\mathcal{D}} \left\{ g(\vec x; {\mathcal{D}} ) \right\} \Big)^2 \right\}}_{\mbox{\small \structure{variance}}}
      \end{eqnarray*}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Regression \cont}

  \structure{Bias-Variance Trade-Off:}

  \begin{itemize}
    \item Methods with \structure{high flexibility} to adapt to the training data
      \begin{itemize}
        \item generally have low bias
        \item but yield high variance. \pause
      \end{itemize}
    \item Methods with \structure{few parameters} and less degrees of freedom
      \begin{itemize}
        \item tend to have a high bias, as they may not fit the data well.
        \item However, this does not change a lot between different data sets, so \\
          these methods generally have low variance. \pause
      \end{itemize}
    \item Unfortunately, we can virtually never get both zero bias and zero variance! \pause
    \item We need to have as \structure{much prior information} about the problem as possible to reduce both values.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Regression \cont}

  \begin{center}
    \resizebox{0.6\linewidth}{!}{
      \input{\texfigdir/bias_variance_regression.pstex_t}
    }
  \end{center}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Classification}

  Assuming a \structure{two-class classification problem}:

  \begin{itemize}
    \item In a two-class problem, the target function changes to:
      \begin{displaymath}
        F(\vec x) = p(y = 1 | \vec x) = 1 - p(y = -1 | \vec x)
      \end{displaymath}
      \pause
    \item We cannot compare $g(\vec x ; {\mathcal{D}})$ and $F(\vec x)$ based on the mean-square error as in regression. \\[.3cm] \pause
    \item For simplicity, let us assume \structure{identical priors}: $p_1 = p_2 = 0.5$
      \begin{itemize}
        \item The Bayes discriminant $y_B$ has the threshold $0.5$.
        \item The Bayes decision boundary is the set of points for which $F(\vec{x}) = 0.5$.
      \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Classification \cont}

  \structure{Boundary error}

  \begin{itemize}
    \item $p(g(\vec{x}; \mathcal{D}))$ is the pdf of obtaining a particular estimate of the discriminant given $\mathcal{D}$.
    \item Because of random variations in the training set, the boundary error will depend upon $p(g(\vec{x}; \mathcal{D}))$.
  \end{itemize}

  \begin{displaymath}
    p(g(\vec x; {\mathcal{D}}) \neq y_B) =
     \left\{
       \begin{array}{l l}
         \displaystyle{ \int_{0.5}^\infty    p(g(\vec{x}; \mathcal{D})) \, \mathsf{d}g } & \mbox{if~} F(\vec{x}) <   0.5 \\[.5cm]
         \displaystyle{ \int_{-\infty}^{0.5} p(g(\vec{x}; \mathcal{D})) \, \mathsf{d}g } & \mbox{if~} F(\vec{x}) \le 0.5 \\
       \end{array}
     \right.
  \end{displaymath}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Classification \cont}

  \begin{itemize}
    \item Convenient assumption that \structure{$p(g(\vec{x}; \mathcal{D}))$ is a Gaussian}:
      \begin{eqnarray*}
        \lefteqn{p(g(\vec x; {\mathcal{D}}) \neq y_B) =} \\
        & & \Phi \Bigg[
              \underbrace{\mathsf{sgn}\left(F(\vec x) - \frac{1}{2}\right) \cdot \left(E_{\mathcal{D}} \{ g(\vec x ; {\mathcal{D}}) \} - \frac{1}{2}\right) }_{\mbox{\small \structure{boundary bias}}}
              \cdot \underbrace{\mathsf{var\Big(g(\vec x ; {\mathcal{D}})\Big)^{-1/2}}}_{\mbox{\small \structure{variance}}}
            \Bigg]
      \end{eqnarray*}
      where $\Phi$ is a \structure{nonlinear function}: \\ \pause
      \begin{displaymath}
        \Phi(t) = \frac{1}{\sqrt{2\pi}} \int_t^\infty e^{-\frac{1}{2} u^2} \, \mathsf{d}u
      \end{displaymath}
    \item $p(g(\vec x; {\mathcal{D}}) \neq y_B)$ represents the incorrect estimation of the Bayes boundary.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Classification \cont}

  \structure{Conclusions:}

  \begin{itemize}
    \item In \structure{regression} the bias-variance relation is additive in (bias)$^2$ and variance. \pause
    \item For \structure{classification} the relation is multiplicative and nonlinear. \pause
    \item In classification the sign of the boundary bias affects the role of the variance in the error. \pause
    \item Therefore, low variance is generally important for accurate classification.
  \end{itemize}
  \pspread

  \structure{Variance generally dominates bias in classification!}
\end{frame}

\begin{frame}
  \frametitle{Bias and Variance for Classification \cont}

  \def\covA{\mat{\Sigma}_i = \left(\begin{matrix} \sigma^2_{i1} & \sigma_{i12} \\ \sigma_{i12} & \sigma^2_{i2} \end{matrix}\right)}
  \def\covB{\mat{\Sigma}_i = \left(\begin{matrix} \sigma^2_{i1} & 0            \\ 0            & \sigma^2_{i2} \end{matrix}\right)}
  \def\covC{\mat{\Sigma}_i = \left(\begin{matrix} 1             & 0            \\ 0            & 1             \end{matrix}\right)}

  \begin{center}
    \resizebox{\linewidth}{!}{
      \input{\texfigdir/bias_variance_classification.pstex_t}
    }
  \end{center}
  \spread

  \tiny{Adapted from Duda, Hart}
\end{frame}

\input{nextTime.tex}

\subsection{Estimating Bias and Variance}

\begin{frame}
  \frametitle{Resampling for Estimating Statistics}

  \structure{Problem:}

  \begin{itemize}
    \item Determine the bias and variance for some learning algorithm applied to a new problem with unknown distributions.
  \end{itemize}
  \pspread

  From what we have seen so far, bias and variance change with varying samples.
  \pspread

  \structure{Resampling techniques} can be used to yield more informative estimates of a general statistics.
\end{frame}

\begin{frame}
  \frametitle{Resampling for Estimating Statistics \cont}

  \structure{Formally:}

  \begin{itemize}
    \item Suppose we want to estimate a parameter $\theta$ that depends on a random sample set $X = (x_1, \ldots, x_n)$.
    \item Assume we have an estimator $\phi_n(X)$ of $\theta$ but do not know its distribution.
  \end{itemize}
  \pspread

  \begin{itemize}
    \item Resampling methods try to estimate the bias and variance of $\phi_n(X)$ using subsamples from $X$.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Jackknife}

  Let $\PS_i(X)$ be the $i$-th pseudovalue of $\phi_n(X)$:

  \begin{eqnarray*}
    \PS_i(X)
      &=& n \phi_n(X) - (n-1) \phi_{n-1}(X_{(i)}) \\
      &=& \phi_n(X) - \underbrace{(n-1)( \phi_{n-1}(X_{(i)}) - \phi_n(X))}_{\mathsf{bias}_{\mathsf{jack}}}
  \end{eqnarray*}
  where $X_{(i)} = (x_1, \ldots, x_{i-1}, x_{i+1}, \ldots, x_n)$ is the set without the $i$-th element.
  \pspread

  \structure{Notes:}

  \begin{itemize}
    \item $\PS_i(X)$ can be interpreted as a bias-corrected version of $\phi_n(X)$: \pause
    \item The bias trend is assumed to be in the estimators from $\phi_{n-1}(X_{(i)})$ to $\phi_n(X)$.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Jackknife \cont}

  \structure{Jackknife Principle:}

  \begin{itemize}
    \item The pseudovalues $\PS_i(X)$ are treated as independent random variables with mean $\theta$. \pause
    \item Using the central limit theorem, the ML estimators for the mean $\mu_{\PS}$ and variance $\sigma_{\PS}^2$ of the pseudovalues are:
      \begin{eqnarray*}
        \mu_{\PS}      &=& \frac{1}{n} \sum_{i=1}^n \PS_i(X) \\
        \sigma_{\PS}^2 &=& \frac{1}{n-1} \sum_{i=1}^n (\PS_i(X) - \mu_{\PS})^2
      \end{eqnarray*}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Jackknife \cont}

  \begin{example}
    \small
    Estimator for the sample mean: $\phi_n(X) = \frac{1}{n} \sum_{i=1}^n x_i = \overline{X}$ \\[.3cm] \pause

    Pseudovalues of $\phi_n(X)$:
    \begin{displaymath}
      \PS_i(X) = n\overline{X} - (n-1) \overline{X_{(i)}} = x_i
    \end{displaymath}
    \pause

    Jackknife estimates:
    \begin{eqnarray*}
      \mu_{\PS}      &=& \frac{1}{n} \sum_{i=1}^n \PS_i(X) = \overline{X} \\
      \sigma_{\PS}^2 &=& \frac{1}{n-1} \sum_{i=1}^n (x_i - \overline{X})^2
    \end{eqnarray*}
  \end{example}
\end{frame}

\begin{frame}
  \frametitle{Jackknife \cont}

  \begin{example}
    \small
    Estimator for sample variance: $\phi_n(X) = \frac{1}{n} \sum_{i=1}^n (x_i - \overline{X})^2$ \\[.3cm] \pause

    Pseudovalues of $\phi_n(X)$:
    {\footnotesize
    \begin{displaymath}
      \PS_i(X) = \frac{n}{n-1} (x_i - \overline{X})^2
    \end{displaymath}
    }
    \pause

    Which implies that:
    {\footnotesize
    \begin{displaymath}
      \mu_{\PS} = \frac{1}{n} \sum_{i=1}^n \PS_i(X) = \frac{1}{n-1} \sum_{i=1}^n (x_i - \overline{X})^2
    \end{displaymath}
    }
    \pause

    {\color{gr3} Interestingly:}

    \begin{itemize}
      \item[\color{gr3} $\bullet$] $E\{\phi_n(X)\} = \frac{n-1}{n}\sigma^2$ whereas $E\{ \mu_{\PS} \} = \sigma^2$
      \item[\color{gr3} $\bullet$] $\mu_{\PS}$ is a bias-corrected version of $\phi_n(X)$
    \end{itemize}
  \end{example}
\end{frame}

\begin{frame}
  \frametitle{Bootstrap}

  \structure{Literary Sidenote:}\\
	The term bootstrap comes from the story: \textit{The adventures of Baron M{\"u}nchhausen}.
  \pspread

  \begin{itemize}
    \item A \textit{bootstrap} data set is created by randomly selecting $n$ points from the sample set with replacement. \pause
    \item In \textit{bootstrap estimation} this selection process is independently repeated $B$ times. \pause
    \item The $B$ bootstrap data sets are treated as independent sets.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Bootstrap \cont}

  The bootstrap estimate of a statistic $\theta$ and its variance are the mean of the $B$ estimates $\hat{\theta}^B$ and its variance:
  \begin{eqnarray*}
    \mu_{\mathsf{BS}}      &=& \frac{1}{B} \sum_{i=1}^B \hat{\theta}^B_i \\
    \sigma^2_{\mathsf{BS}} &=& \frac{1}{B-1} \sum_{i=1}^B \left( \hat{\theta}^B_i - \mu_{\mathsf{BS}} \right)^2
  \end{eqnarray*}
  \pspread

  The bias is the difference between the bootstrap estimate and the estimator $\phi_n(X)$:
  \begin{displaymath}
    \mathsf{bias}_{\mathsf{BS}} = \mu_{\mathsf{BS}} - \phi_n(X)
  \end{displaymath}
\end{frame}

\begin{frame}
  \frametitle{Bootstrap \cont}

  \structure{Properties of the bootstrap estimate:}

  \begin{itemize}
    \item Bootstrapping does not change the prior of the data (choose with replacement). \pause
    \item The larger the number $B$, the more will the bootstrap estimate tend towards the true statistic $\theta$. \pause
    \item In contrast, the jackknife estimator requires exactly $n$ repetitions:
      \begin{itemize}
        \item less than $n$ repetitions yield poorer estimates
        \item more than $n$ repetitions merely duplicate information already provided
      \end{itemize}
  \end{itemize}
\end{frame}

\subsection{Estimating and Comparing Classifiers}

\begin{frame}
  \frametitle{Estimating and Comparing Classifiers}

  Two reasons why we want to know the generalization rate of a classifier on a given problem:

  \begin{enumerate}
    \item to see if the classifier performs well enough to be useful
    \item to compare its performance with a competing design
  \end{enumerate}
\end{frame}

\begin{frame}
  \frametitle{Cross-Validation}

  \begin{itemize}
    \item In \structure{cross-validation}, the training samples are split into two disjoint parts:\\[.1cm]
      \begin{itemize}
        \item The first set is the training set used for the traditional training.
        \item The second set is the test set used to estimate the classification error.
        \item In a second step, both sets are swapped.
        \item By that, the classification error can be estimated on the complete data set.
        \item Yet training and test set are always disjoint. \\[.3cm] \pause
      \end{itemize}
    \item An \structure{$m$-fold cross-validation} splits the data into $m$ disjoint sets of size $n/m$:\\[.1cm]
      \begin{itemize}
        \item 1 set is used as test set.
        \item The other $m-1$ sets are used for training.
        \item Each set is used once for testing. \\[.3cm] \pause
      \end{itemize}
    \item In the \structure{extreme case of $m=n$}, we have  a jackknife estimate of the classification accuracy.
    %\item If we train on a bootstrap set and test on another bootstrap set of the data, we get a bootstrap estimate for the classification accuracy.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Cross-Validation \cont}

  The classifier is trained until a minimum validation error is reached \\
  (good generalization vs.\ overfitting):

  \begin{figure}
    \centering
    \resizebox{.6\linewidth}{!}{
      \input{\texfigdir/cross_validation_error.pstex_t}
    }
    \caption{\footnotesize{The validation error plotted against the amount of training data (adapted from Duda, Hart).}}
  \end{figure}
\end{frame}

\subsection{Lessons Learned}

\begin{frame}
  \frametitle{Lessons Learned}

  \begin{itemize}
    \item There is no such thing as a free lunch! \\[.3cm]
    \item Bias-variance trade-off \\[.3cm]
    \item Jackknife \\[.3cm]
    \item Bootstrap \\[.3cm]
    \item Cross-Validation
  \end{itemize}
\end{frame}

\input{nextTime.tex}

\subsection{Further Readings}

\begin{frame}
  \frametitle{Further Readings}

  Examples and various content have been taken from: \\[.3cm]

  \begin{itemize}
    \item Richard O.\ Duda, Peter E.\ Hart, David G.\ Stork: Pattern Classification, 2nd Edition, John Wiley \& Sons, New York, 2000. \\[.3cm]
    \item S.\ Sawyer: Resampling Data: Using a Statistical Jackknife, Washington University, 2005.
  \end{itemize}
  \spread

  \structure{Further reading:}

  \begin{itemize}
    \item T. Hastie, R. Tibshirani, J. Friedman: The Elements of Statistical Learning, 2nd Edition, Springer, 2009.
  \end{itemize}
\end{frame}

\subsection{Comprehensive Questions}

\begin{frame}
  \frametitle{Comprehensive Questions}

  \begin{itemize}
    \item What is the meaning of the terms bias and variance? \\[.5cm]
    \item What is the difference in bias-variance trade-off between regression and classification? \\[.5cm]
    \item How do you estimate the bias and variance of a method? \\[.5cm]
    \item What is cross-validation and how can it be used to train a classifier?
  \end{itemize}
\end{frame}


\section{Dijkstra's Algorithm for SSSP}

%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Dijkstra's algorithm for SSSP}
  \[
	R \triangleq \set{v \mid s \leadsto v \text{ is known}}
  \]

  \vspace{0.50cm}
  \begin{center}
	Finding shortest paths from $s$ to other nodes $t$ \\
	in increasing order of $\dist(s,t)$.
  \end{center}

  \begin{theorem}[Invariant]
	$\begin{displaystyle}
	  \exists d: \begin{cases}
		\dist(s,v) \le l, 	& \forall v \in R, \\
		\dist(s,v) > l, 	& \forall v \notin R
	  \end{cases}
	\end{displaystyle}$
  \end{theorem}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Dijkstra's algorithm for SSSP}
  \fignocaption{width = 0.35\textwidth}{figs/dijkstra-alg.png}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Negative edges}
  \begin{exampleblock}{Negative edges (Problem 6.16)}
	Dijkstra's algorithm may fail if $w(e) < 0$.
  \end{exampleblock}

  \fignocaption{width = 0.20\textwidth}{figs/dijkstra-negative.png}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Negative edges}
  \begin{exampleblock}{Negative edges from $s$ (Problem 6.21)}
	All negative edges are from $s$ in a digraph.
  \end{exampleblock}

  \vspace{0.50cm}
  \centerline{No negative cycles.}
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Generalized shortest path problem}
  \begin{exampleblock}{Generalized shortest path problem (Problem 6.20)}
	\begin{itemize}
	  \item digraph $G = (V, E), l_e > 0, c_v > 0, s \in V$
	  \item shortest paths from $s$
	\end{itemize}
  \end{exampleblock}

  \[
	l'(u,v) = l(u,v) + c_v
  \]
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Shortest paths among nodes}
  \begin{exampleblock}{Shortest paths among nodes (Problem 6.27)}
	\begin{itemize}
	  \item $G = (V, E), w(e) \ge 0$
	  \item $S, T \subseteq V$
	  \item compute $\min \set{\text{d}(s,t): s \in S, t \in T}$
	\end{itemize}
  \end{exampleblock}

  \[
	V' = V + \set{s_0, t_0}
  \]
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Shortest path through $v_0$}
  \begin{exampleblock}{Shortest paths through $v_0$ (Problem 6.28)}
	\begin{itemize}
	  \item strongly connected digraph $G = (V, E), w(e) > 0$
	  \item $v_0 \in V$
	  \item find shortest paths $s \leadsto^{\SP} t$ through $v_0$
	\end{itemize}
  \end{exampleblock}

  \[
	s \leadsto^{\SP} v_0 \leadsto^{\SP} t
  \]

  \[
	\# v_0's = 1
  \]
\end{frame}
%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Shortest path in maze}
  \begin{exampleblock}{Shortest paths in maze (Problem 6.24)}
	\begin{enumerate}
	  \item $w(e) = c > 0$ without obstacles
	  \item $w(e) = c > 0$ with obstacles
	  \item $w(e) > 0$
		\begin{enumerate}
		  \item $\rightarrow, \downarrow$; in $O(n + m)$
		  \item $\uparrow, \downarrow, \leftarrow, \uparrow$
		\end{enumerate}
	  \item $\exists e: w(e) < 0$ without negative cycles
	\end{enumerate}
  \end{exampleblock}

  \[
	(3.1)\; \text{d}[v] = \min_{u \to v} \text{d}[u] + w(u \to v)
  \]

  \centerline{Compute $\dist[v]$ in topo. order.}
\end{frame}
%%%%%%%%%%%%%%%%%%%%


\documentclass[a4paper,12pt]{llncs}
\usepackage{latexsym}

\newcommand\comment[1]{}
\renewcommand\comment[1]{#1} % to print enclosed text
\renewcommand\comment[1]{} % to not print enclosed text

\begin{document}

\title{Formalised Induction Patterns for Admissibility Proofs in Coq}

\author{Jeremy E.\ Dawson\\
etc}

% \date{}
\maketitle

\abstract{
This document describes general reasoning patterns for inductive proofs
of properties such as invertibility of rules, contraction admissibility,
and describes spedifically their implementation in Coq.
}

\section{Introduction}

Proofs of properties such as admissibility
weakening and exchange admissibility,
invertibility of certain rules,
contraction admissibility, and cut admissibility
are generally proved by induction, though there are variations
on the exact forms of induction proofs available.

For example, induction on the height (or size) of a proof,
which can sometimes require that a previously proved property such as
weakening admissibility be proved as height-preserving weakening admissibility.

Alternatively, induction on the ``proof'' itself, ie assuming that
a formula or sequent which is earlier in the proof satisfies the required
property.

It is useful to have general reasoning patterns for inductive proofs,
formalising the variety of manners of induction available.

\section{\texttt{derrec}, \texttt{derl}, \texttt{adm}}\label{s-dda}
We use the framework previously implemented in Isabelle,
described in \cite[Appendix A.1]{dawson-gore-gls},
which we recapitulate briefly here, with reference to its implementation in
Coq.

An inference rule is represented as a list of premises and a conclusion,
where the premises and conclusion are of some unspecified type.
(For all our illustrations of this work, they will be sequents whose
antecedents and succedents are lists of modal formulae).

This suggests using
\texttt{rules : list X -> X -> Prop}
(as we did initially), but we found that in Coq,
we could define the height or size of a proof object only if we
generally used \texttt{Type}, instead of \texttt{Prop}.

The predicates \texttt{derrec} and \texttt{derl} have the following meanings:

\texttt{derrec rules prems concl} means that conclusion
\texttt{concl}
is derivable from premises (or assumptions)
\texttt{prems}
using
rules
\texttt{rules}

\texttt{derl rules ps c} means that there is a derived rule
(proof tree)
with premises (leaves)
\texttt{ps}
and conclusion (root)
\texttt{c}
constructed using rules
\texttt{rules}

Their inductive definitions also require defining
\texttt{dersrec} and \texttt{dersl}
which involve a list of conclusions.

The inductive definitions follow:
\begin{verbatim}
Inductive
derrec (X : Type) (rules : list X -> X -> Type) (prems : X -> Type)
  : X -> Type :=
    dpI : forall concl : X, prems concl -> derrec rules prems concl
  | derI : forall (ps : list X) (concl : X),
           rules ps concl ->
           dersrec rules prems ps -> derrec rules prems concl
  with dersrec (X : Type) (rules : list X -> X -> Type)
       (prems : X -> Type) : list X -> Type :=
    dlNil : dersrec rules prems []
  | dlCons : forall (seq : X) (seqs : list X),
             derrec rules prems seq ->
             dersrec rules prems seqs -> dersrec rules prems (seq :: seqs)

Inductive
derl (X : Type) (rules : list X -> X -> Type) : list X -> X -> Type :=
    asmI : forall p : X, derl rules [p] p
  | dtderI : forall (pss ps : list X) (concl : X),
             rules ps concl -> dersl rules pss ps -> derl rules pss concl
  with dersl (X : Type) (rules : list X -> X -> Type)
         : list X -> list X -> Type :=
    dtNil : dersl rules [] []
  | dtCons : forall (ps : list X) (c : X) (pss cs : list X),
             derl rules ps c ->
             dersl rules pss cs -> dersl rules (ps ++ pss) (c :: cs)
\end{verbatim}

We get useful results like the following:
\begin{verbatim}
derl_derrec_trans
     : forall (X : Type) (rules : list X -> X -> Type)
         (prems : X -> Type) (rps : list X) (concl : X),
       derl rules rps concl ->
       dersrec rules prems rps -> derrec rules prems concl

derrec_derl_deriv
     : forall (X : Type) (rules : list X -> X -> Type)
         (prems : X -> Type) (concl : X),
       derrec (derl rules) prems concl -> derrec rules prems concl

derl_deriv':
  forall (X : Type) (rules : list X -> X -> Type)
    (prems : list X) (concl : X),
  derl (derl rules) prems concl -> derl rules prems concl

derrec_derrec
     : forall (X : Type) (rules : list X -> X -> Type)
         (prems : X -> Type) (c : X),
       derrec rules (derrec rules prems) c -> derrec rules prems c
\end{verbatim}

We also define \emph{admissible} rules:
a rule is \emph{admissible} if, assuming its premises
are derivable (from no assumptions) its conclusion is
likewise derivable.

\begin{verbatim}
Inductive
adm (X : Type) (rules : list X -> X -> Type) (ps : list X) (c : X) : Type :=
    admI : (dersrec rules (emptyT (X:=X)) ps ->
            derrec rules (emptyT (X:=X)) c) -> adm rules ps c
\end{verbatim}

Note that \texttt{adm}, unlike \texttt{derl}, is not monotonic in the
rules used.
From this we get the results
\begin{verbatim}
adm_adm:
  forall (X : Type) (rules : list X -> X -> Type) (ps : list X) (c : X),
  adm (adm rules) ps c -> adm rules ps c
derl_sub_adm:
  forall (X : Type) (rules : list X -> X -> Type) (ps : list X) (c : X),
  derl rules ps c -> adm rules ps c
derl_adm:
  forall (X : Type) (rules : list X -> X -> Type) (ps : list X) (c : X),
  derl (adm rules) ps c -> adm rules ps c
derrec_adm:
  forall (X : Type) (rls : list X -> X -> Type) (c : X),
  derrec (adm rls) (emptyT (X:=X)) c -> derrec rls (emptyT (X:=X)) c
TODO - adm (derl rules) vs adm rules
\end{verbatim}

\section{Our induction patterns}
In previous work we defined a general lemma which enables proof of a property
of a pair of proved sequents, notably cut-admissibility.
That general lemma, simplified, applies also to proving similar properties of a
single proved sequent, such as contraction admissibility, or invertibility of
a particular rule.

A particular problem with admissibility proofs is that, when, for example,
one logic is obtained from another by adding additional rules,
and the steps in proving an admissibility result
are similar for the rules common to both logics, it requires extra effort
to formalise the proofs in a way which enables similar parts of the proofs to
be reused.

Our focus here is to set out induction patterns and relevant lemmas
useful for inductive proofs of admissibility properties which permit relevant
portions of the proof to be re-used for other calculi containing some of the
same rules.

\comment{
NB - it seems I did something pretty similar in Isabelle,
I think not written up, unless it's in the stuff we did with Jesse,
in ~jeremy/isabelle/2005/seqms/ctr.thy
see the definition of \verb|inv_stepm| as follows

\begin{verbatim}
primrec
  (* step in invertibility ; means that, if premises (ps) derivable,
    and can apply (invs_of irls) to premises,
    then can apply (invs_of irls) to conclusion (concl) *)
  "inv_step derivs irls (ps, concl) = (set ps <= derivs -->
    (ALL p : set ps. invs_of irls p <= derivs) -->
    invs_of irls concl <= derivs)"

primrec
  (* variation on inv_step which will often be true and monotonic,
    whereby the inversions of the conclusion are derivable from the
    inversions of the premises *)
  "inv_stepm drls irls (ps, concl) = (invs_of irls concl <=
    derrec drls (set ps Un UNION (set ps) (invs_of irls)))"
\end{verbatim}

(here, \verb|invs_of irls| means the result of changing a sequent
by inverting some rule in irls)
}

The simplest example of this is probably the following:

substitution admissibility: for example, to show that if
$A \land B \vdash A$ is derivable, then $C \land D \vdash C$ is derivable.
The proof of this is obvious: you just go through the proof, changing
every $A$ to $C$ and every $B$ to $D$.

Even this example raises two points about the formal calculus used:

each individual rule must permit these substitutions

in particular the ``axiom'' rule must be $A \vdash A$ (for any formula $A$),
rather than $p \vdash p$ (for any primitive proposition $p$).

Note that in describing the implementation, the word ``rule'' implies
specific premises and conclusion, for example, one of the substitution
instances of a ``rule'' as in Table~\ref{k4-rules}.

So we formalise this argument:

we define a relation $R$ between sequents:
for example, $R s_1 s_2$ could mean that $s_2$ is obtained from
$s_1$ by changing all occurrences of $A$ to $C$, and all $B$ to $D$
(or, applying any substitution uniformly).

Then the relevant requirement on the set of rules is that

for any rule $\displaystyle \frac{P_1 \ldots P_n} {Q}$,
and for any $Q'$ such that $R~Q~Q'$,
there exist modified premises ${P'_1 \ldots P'_n}$
and a rule $\displaystyle \frac {P'_1 \ldots P'_n} {Q'}$.

This obviously permits changing $A$ to $C$ and $B$ to $D$
throughout the entire proof.

So we define \texttt{can\_trf\_rules} to express this property
of a set of rules,
and the theorem \texttt{der\_trf} expresses the use of that property.

\begin{definition}[\texttt{can-trf-rules}]\label{def-can-trf-rules}
text of defn
\end{definition}

\begin{theorem}[\texttt{der-trf}] \label{t-der-trf}
text of thm
\end{theorem}

\begin{verbatim}
can_trf_rules =
fun (sty : Type) (R : sty -> sty -> Type) (rules : list sty -> sty -> Type)
  (ps : list sty) (c : sty) =>
forall c' : sty,
R c c' ->
{ps' : list sty &
rules ps' c' * ForallT (fun p' : sty => {p : sty & InT p ps * R p p'}) ps'}
     : forall sty : Type,
       (sty -> sty -> Type) ->
       (list sty -> sty -> Type) -> list sty -> sty -> Type

der_trf
     : forall (sty : Type) (R : sty -> sty -> Type)
         (rules : list sty -> sty -> Type),
       (forall (ps : list sty) (c : sty),
        rules ps c -> can_trf_rules R rules ps c) ->
       forall concl : sty,
       derrec rules (emptyT (X:=sty)) concl ->
       forall concl' : sty,
       R concl concl' -> derrec rules (emptyT (X:=sty)) concl'
\end{verbatim}

\subsection{Extensions and generalizations}
We use as a running example a sequent calculus for the modal logic K4,
with a minimal set of logical connectives ($\to$ and $\bot$)
and modal operator $\Box$.
A sequent is represented as a list for formulae on either side of the
turnstile $\vdash$.
There is no explicit weakening rule (except that the $(\Box)$ rule
incorporates weakening (in arbitrary positions) in its conclusion,
and no explicit exchange rule.

\begin{figure}\label{k4-rules}
GIVE RULES
\caption{Rules of our sequent calculus for K4}
\end{figure}

TO DO describe the weakening theorems,
including the gen\_ext predicate,
and the exchange theorems

In various places we found we needed extensions to the theorem.

\subsubsection{Reflexive closure of $R$}\label{s-refl-clos}
For example the K4 ($\Box$) rule allows weakening (at arbitrary points)
in the antecedent of the conclusion.
Consider the inductive proof of exchange (which we define as
the interchanging of two sublists which are not necessarily adjacent):
in the case where we are exchanging two sublists both of which consist entirely
of formula which were ``weakened in'' in the use of the ($\Box$) rule.
Then in this case there are two rule occurrences whose conclusions are related
by the exchange relation, but which have the same premise, rather than related
premises.

So we extend the definition and theorem above to the case where the
premises are related by the reflexive closure of the relation $R$, thus:

\begin{theorem}[\texttt{der-trf-rc}]\label{t-der-trf-rc}
\end{theorem}
\begin{verbatim}
can_trf_rules_rc =
fun (sty : Type) (R : sty -> sty -> Type) (rules : list sty -> sty -> Type)
  (ps : list sty) (c : sty) =>
forall c' : sty,
R c c' ->
{ps' : list sty &
rules ps' c' *
ForallT (fun p' : sty => {p : sty & InT p ps * clos_reflT R p p'}) ps'}
     : forall sty : Type,
       (sty -> sty -> Type) ->
       (list sty -> sty -> Type) -> list sty -> sty -> Type

der_trf_rc
     : forall (sty : Type) (R : sty -> sty -> Type)
         (rules : list sty -> sty -> Type),
       (forall (ps : list sty) (c : sty),
        rules ps c -> can_trf_rules_rc R rules ps c) ->
       forall concl : sty,
       derrec rules (emptyT (X:=sty)) concl ->
       forall concl' : sty,
       R concl concl' -> derrec rules (emptyT (X:=sty)) concl'
\end{verbatim}

Note that it would be trivial to infer
\texttt{can-trf-rules sty (clos-reflT R) rules ps c}
from \texttt{can-trf-rules sty R rules ps c}
if we had defined \texttt{can-trf-rules} to require that ps and c were
premises and conclusion of a rule, and in this case this definition and theorem
would not be necessary.  But some of our other results would then be more
complicated.

\subsubsection{Transitive closure of $R$}\label{s-refl-trans-clos}
The ($\Box$) rule (omitting the weakening incorporated into it) is
$\displaystyle \frac{\Gamma \Box\Gamma \vdash A}{\Box\Gamma \vdash \Box A}$.
To show the admissibility of exchange, we consider an exchange in $\Gamma$,
to give $\Gamma'$.  The corresponding rule has premise
$\Gamma' \Box\Gamma' \vdash A$ --- that is, $\Gamma \Box\Gamma \vdash A$
subjected to \emph{two} exchanges.
We therefore needed (and were able to) extend the
results of \S\ref{s-refl-clos} to reflexive transitive closure, as follows

\begin{theorem}[\texttt{der-trf-rtc}]\label{t-der-trf-rtc}
\end{theorem}
\begin{verbatim}
can_trf_rules_rtc =
fun (sty : Type) (R : sty -> sty -> Type) (rules : list sty -> sty -> Type)
  (ps : list sty) (c : sty) =>
forall c' : sty,
R c c' ->
{ps' : list sty &
rules ps' c' *
ForallT (fun p' : sty => {p : sty & InT p ps * clos_refl_transT_n1 R p p'})
  ps'}
     : forall sty : Type,
       (sty -> sty -> Type) ->
       (list sty -> sty -> Type) -> list sty -> sty -> Type

der_trf_rtc
     : forall (sty : Type) (R : sty -> sty -> Type)
         (rules : list sty -> sty -> Type),
       (forall (ps : list sty) (c : sty),
        rules ps c -> can_trf_rules_rtc R rules ps c) ->
       forall concl : sty,
       derrec rules (emptyT (X:=sty)) concl ->
       forall concl' : sty,
       clos_refl_transT_n1 R concl concl' ->
       derrec rules (emptyT (X:=sty)) concl'
\end{verbatim}

\subsubsection{Related rule is a derived rule}\label{s-der}
In proving invertibility of a rule there are some special cases.
Supposing that we are proving that if $\Gamma \vdash A \to B$ then
$\Gamma, A \vdash B$ (ie, proving that the ($\vdash\to$) rule is invertible.
Supposing then that the last rule of the proof is exactly
$\displaystyle \frac {\Gamma, A \vdash B} {\Gamma \vdash A \to B}$.
That is, given a rule $p/c$ and $c'$, we want to find $p'$ such that
$p'/c'$ is a rule and $R\ p\ p'$, but here $c'$ is exactly $p$ (and our $p'$
will be the same also).
So here the relation between $p$ and $p'$ is the reflexive closure of $R$,
and the relationship between $p'$ and $c'$ is like a reflexive closure of
inference rule application.

Now we have defined \texttt{derl}, which is like a reflexive transitive closure
of rule application, and it is in fact easy to extend the mian result to
derl, thus (this differs from \texttt{der-trf-derl}
only by the insertion of the single word \texttt{derl}):

\begin{theorem}[\texttt{der-trf-derl}]\label{t-der-trf-derl}
\end{theorem}
\begin{verbatim}
der_trf_derl
     : forall (sty : Type) (R : sty -> sty -> Type)
         (rules : list sty -> sty -> Type),
       (forall (ps : list sty) (c : sty),
        rules ps c -> can_trf_rules R (derl rules) ps c) ->
       forall concl : sty,
       derrec rules (emptyT (X:=sty)) concl ->
       forall concl' : sty,
       R concl concl' -> derrec rules (emptyT (X:=sty)) concl'
\end{verbatim}

But we also need a result allowing for the fact that $p = p'$, and we can do
this:

\begin{theorem}[\texttt{der-trf-rc-derl}]\label{t-der-trf-rc-derl}
\end{theorem}
\begin{verbatim}
der_trf_rc_derl
     : forall (sty : Type) (R : sty -> sty -> Type)
         (rules : list sty -> sty -> Type),
       (forall (ps : list sty) (c : sty),
        rules ps c -> can_trf_rules_rc R (derl rules) ps c) ->
       forall concl : sty,
       derrec rules (emptyT (X:=sty)) concl ->
       forall concl' : sty,
       R concl concl' -> derrec rules (emptyT (X:=sty)) concl'
\end{verbatim}

Notice that at this point we have extended Theorem~\ref{t-der-trf}
on the one hand, to \texttt{derl} and to reflexive closure of $R$
(in Theorem~\ref{t-der-trf-rc-derl}),
and on the other hand, to reflexive transitive closure
(in Theorem~\ref{t-der-trf-rtc}).
Can we make both extensions together?  We have tried (to some extent), and
so far have been unable.

\subsubsection{Related rule is only an admissible rule}\label{s-rc-adm}
Again we consider proving the invertibility of the ($\vdash\to$) rule,
but here, in the form, for example, where the last rule of the proof is
$\displaystyle \frac p c = \frac {\Gamma, A \vdash B} {\Gamma \vdash A \to B}$,
as before, but our choice of inversion which we want to prove is
$c' = {A, \Gamma \vdash B}$.
So here we need to set $p' = {\Gamma, A \vdash B}$, and the
relationship between $p'$ and $c'$ is that $p'/c'$ is an admissible rule,
not even a derivable rule.

\begin{theorem}[\texttt{der-trf-rc-adm}]\label{t-der-trf-rc-adm}
\end{theorem}
\begin{verbatim}
der_trf_rc_adm
     : forall (sty : Type) (R : sty -> sty -> Type)
         (rules : list sty -> sty -> Type),
       (forall (ps : list sty) (c : sty),
        rules ps c -> can_trf_rules_rc R (adm rules) ps c) ->
       forall concl : sty,
       derrec rules (emptyT (X:=sty)) concl ->
       forall concl' : sty,
       R concl concl' -> derrec rules (emptyT (X:=sty)) concl'
\end{verbatim}

\subsection{Height-preserving admissibility}

In our implementation in Isabelle of the framework described in
\S\ref{s-dda}, we defined \texttt{derl} and \texttt{derrec} as inductively
defined sets.
We also defined a datatype representing a derivation tree, as follows
\begin{verbatim}
datatype 'a dertree = Der 'a ('a dertree list) | Unf 'a
\end{verbatim}

(where \texttt{Unf} represents an unproved leaf).
We then defined a predicate testing whether a tree is valid according to
a set of rules (which requires no unproved leaf,
and that every \texttt{Der}-node is one of the given rules).

We then had to prove that a sequent is derivable if and only if it is the
root of a valid derivation tree.
With a derivation tree ``object'', we can define its height, size (number of
rules), etc, and prove theorems about these.

Alternatively, we could have dealt with such concepts as height, size, etc,
by defining new inductive sets (eg, sequents derivable in at most $n$ steps),
but this requires a new inductive definition for each such property which may
become of interest.

In Coq the inductive definition provides a "proof object", whose height (etc)
can be defined. This does require that the types of
\texttt{derl}, \texttt{derrec}, etc, use \texttt{Type},
whereas our first implementation of these used \texttt{Prop}.

\begin{verbatim}
derrec : forall X : Type,
  (list X -> X -> Type) -> (X -> Type) -> X -> Type
derl : forall X : Type,
  (list X -> X -> Type) -> list X -> X -> Type
\end{verbatim}

It also requires that relevant proved theorems
(such as those proving some instance of \texttt{derrec \ldots \ldots \ldots})
finish with Defined rather than Qed.

We proved a theorem corresponding to Theorem~\ref{t-der-trf},
but with the additional property that the derivation tree for the
related conclusion is no higher than that of the original conclusion.
\begin{verbatim}
der_trf_ht
     : forall (sty : Type) (R : sty -> sty -> Type)
         (rules : list sty -> sty -> Type),
       (forall (ps : list sty) (c : sty),
        rules ps c -> can_trf_rules R rules ps c) ->
       forall (concl : sty) (D : derrec rules (emptyT (X:=sty)) concl)
         (concl' : sty),
       R concl concl' ->
       {D' : derrec rules (emptyT (X:=sty)) concl' &
       derrec_height D' <= derrec_height D}
\end{verbatim}

There was also another problem: for the derivation tree in Isabelle, if you
take off the last rule, you get a list of subtrees each of which derives one
premise of the last rule.
In Coq, these subtrees all prove different things, so they have different
types, so they can't be made into a list.

So what we did instead was define \texttt{in\_dersrec},
which expresses that a derivation
(of type \texttt{derrec \ldots \ldots \ldots})
is one of the derivations in an object of type
\texttt{dersrec \ldots \ldots \ldots}).
Likewise we defined \texttt{allPder}
which represents that all the derivations represented
in in an object of type \texttt{dersrec \ldots \ldots \ldots}).
satisfy some property.
\begin{verbatim}
in_dersrec
     : forall (X : Type) (rules : rlsT X) (prems : X -> Type) (concl : X),
       derrec rules prems concl ->
       forall concls : list X, dersrec rules prems concls -> Type

allPder
     : forall (X : Type) (rules : rlsT X) (prems : X -> Type),
       (forall x : X, derrec rules prems x -> Type) ->
       forall concls : list X, dersrec rules prems concls -> Type
\end{verbatim}

However manipulating these functions proved difficult,
and we suspect that at some point it may become necessary to
implement a derivation tree object as we have described doing in Isabelle.
In particular there were problems which I don't understand,
 which were solved by using dependent destruction
(which relies on some axiom, which may or may not be valid).

\section{Coq proofs about K4}
We now describe the proofs about the calculus for K4 presented in
Figure~\ref{k4-rules}.

\subsection{Formalisation of the rules}

DISCUSS
eg \texttt{seqrule}, applies contexts (left and right, antecedent and
succedent) to premises and conclusion
\texttt{cgerule}, applies weakening (inserting formulae anywhere in the
antecedent and succedent lists) to conclusion
\texttt{princrule},
\texttt{K4prrule}, ($\Box$) rule without the weakening
\texttt{sing\_empty},

We then probed a weakening admissibility result, not using the framework
described here.

We next describe the proofs of further admissibility rules,
showing how we used the functions described earlier, and how the intermediate
results would be equally useful in similar proofs about a different logic,
such as S4.

\subsection{Exchange}

This lemma is meant for the classical rules, but formulated to apply to
any set of rules constructed from base rules in which antecedent satisfies
\texttt{sing\_empty} by extending premises and conclusion uniformly with
contexts.

\begin{verbatim}
exchL_std_rule: forall W (rules : rlsT (Seql W)),
  (forall ps U S, rules ps (U, S) -> sing_empty U) ->
  forall ps c, seqrule rules ps c ->
    can_trf_rules (fst_rel (swapped (T:=W))) (seqrule rules) ps c
\end{verbatim}

The relation between lists of which sublists have been swapped is
\texttt{swapped}, and so \texttt{fst\_rel (@swapped W)} is the relation between
sequents whose antecedent lists are swapped.
Here, \texttt{sing\_empty U} means that the list $U$ is either singleton or
empty.

As an easy corollary of this, we get exchange for classical propositional
logic.

\begin{verbatim}
exchL_cpl: forall V concl,
  derrec (seqrule (@princrule V)) (@emptyT _) concl ->
     forall concl', fst_rel (@swapped _) concl concl' ->
     derrec (seqrule (@princrule V)) (@emptyT _) concl'.
\end{verbatim}

Then, adding the ($\Box$) rule we get

\begin{verbatim}
exchL_K4: forall V ps c, cgerule (@K4prrule V) ps c ->
    can_trf_rules_rtc (fst_rel (@swapped _)) (cgerule (@K4prrule V)) ps c.
\end{verbatim}

Then we put these results together, using these further lemmas:
\begin{lemma}[\texttt{can\_trf\_rules\_rtc}]\label{l-can-trf-rules-rtc}
\texttt{can\_trf\_rules\_rtc} is monotonic in the rule set
\end{lemma}
\begin{lemma}[\texttt{can\_trf\_rules\_imp\_rtc}]\label{l-can-trf-rules-imp-rtc}
\texttt{can\_trf\_rules} R rules ps c ->
  \texttt{can\_trf\_rules\_rtc} R rules ps c
\end{lemma}

Then we use Theorem~\ref{t-der-trf-rtc} to get the result

\begin{theorem}[\texttt{exchL\_rtc, exchL}]\label{t-exchL}
If concl is derivable, then concl', got from concl by exchange[s] in the
antecedent, is derivable.
\end{theorem}

\subsection{Invertibility of the classical propositional rules}

From here on it is pretty incomplete.

First we proved the invertibility of the ($\vdash\to$) rule.

This uses Lemma~\ref{t-der-trf-rc-adm} and the following Lemma.

\begin{lemma}[\texttt{can\_trf\_ImpRinv}]\label{t-can-trf-ImpRinv}
\end{lemma}

\begin{verbatim}
Lemma can_trf_ImpRinv V ps c: @K4rules V ps c ->
  can_trf_rules_rc (seqrel (@ImpRinv V)) (adm (@K4rules V)) ps c.
\end{verbatim}

The proof of this lemma involves 5 cases, one for each rule,
each one being a separate lemma.
\footnote{as things stand right now, I need to massage these somewhat
to make them equally easily usable for other logics like S4}

For the ($\Box$) rule, the formula to be inverted can only be a formula added
in the weakening aspect of the rule, so no real difficulty there.

For the axiom rule, the only problem case is where the formula to be inverted
is the formula appearing on both sides (eg $C \to D \vdash C \to D$,
so the inversion gives $C, C \to D \vdash D$).
Here we need the related rule to be a derivable (or admissible) rule,
rather than simply a rule of the calculus.

The ($\bot\vdash$) is easy because inversion of $C \to D$ won't change the fact
that there is a $\bot$ in the antecedent.

The remaining two rules produce a lot of cases.
Firstly, where the last rule is also ($\vdash\to$), involving the same formula,
then the issue described in \S\ref{s-rc-adm} arises.
Then there are a multitude of cases, according to where the principal
formulae of the last rule and the formula to be inverted appear in the contexts
of both the last rule and the inversion relation.
So they need some effort in programming Coq Ltac tactics to handle all the
cases.

Finally, using Lemma~\ref{t-der-trf-rc-adm} we get
\begin{theorem}[\texttt{K4\_ImpRinv}]\label{t-K4-ImpRinv}
\end{theorem}
\begin{verbatim}
Theorem K4_ImpRinv V concl:
  derrec (@K4rules V) (@emptyT _) concl ->
  forall concl', seqrel (@ImpRinv V) concl concl' ->
  derrec (@K4rules V) (@emptyT _) concl'.
\end{verbatim}

Trying to generalise the above: first, I adapted the proof for
the last rule being ($\vdash\to$) and the rule being inverted
($\to\vdash$), to a case where the last rule is (in its conclusion) any
singleton on the right, and the rule being inverted is (in its conclusion) any
singleton on the left.

So I did this successfully for any such rules that are singletons (bearing in
mind that a ``rule'' like ($\vdash\to$) is actually lots of rules).
But then I have difficulty manipulating this to get the previous results.
Hopefully this won't be too hard.
Have to think about it. (the problem is that I can't simply say
rule = union of rule instances, and subsitute as the argument of
can\_trf\_rules\_rc because the ``='' really means that if there is a proof object
of one then there is a proof object of the other (I think!!)).

\begin{thebibliography}{10}

\bibitem{dawson-gore-gls}
J~E Dawson and R Gor{\'e}.
\newblock Generic Methods for Formalising Sequent Calculi
       Applied to Provability Logic.
\newblock In Proc.\ Logic for Programming, Artificial Intelligence and
Reasoning (LPAR 2010), LNCS 6397, 263-277.

\end{thebibliography}

\end{document}