\title{Monomial Ideals}
\titlerunning{Monomial Ideals}
\toctitle{Monomial Ideals}
\author{Serkan Ho\c{s}ten
        % \inst 1
        \and Gregory G.~Smith
        % \inst 2
        }
\authorrunning{S. Ho\c{s}ten and G. G. Smith}
% \institute{Department of Mathematics, San Francisco State University,
% San Francisco, CA 94132, USA\and Department of Mathematics, University of
% California, Berkeley, CA 94720, USA}
\maketitle

\newtheorem*{sproof}{Proof of Proposition}{\itshape}{\rmfamily}
%% old form caused problems:
%%%% \newtheorem*{sproof}{Proof of Proposition~\ref{pro:complexity}}{\itshape}{\rmfamily}

\newcommand{\supp}{\operatorname{supp}}
\newcommand{\depth}{\operatorname{depth}}
\newcommand{\GL}{\operatorname{GL}}
\newcommand{\initial}{\operatorname{in}}
\newcommand{\Hilb}{\operatorname{Hilb}}
\newcommand{\codim}{\operatorname{codim}}
\newcommand{\sg}{{\sf g}}
\newcommand{\IP}{\operatorname{IP}}

\begin{abstract}
Monomial ideals form an important link between commutative algebra and
combinatorics.  In this chapter, we demonstrate how to implement
algorithms in \Mtwo for studying and using monomial ideals.  We
illustrate these methods with examples from combinatorics, integer
programming, and algebraic geometry.
\end{abstract}

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

An ideal $I$ in $S = \bbbq[x_{1}, \dotsc, x_{n}]$ is called a monomial
ideal\index{monomial ideal}\index{ideal!monomial} if it satisfies any
of the following equivalent conditions:
\begin{enumerate}
\item[$(a)$] $I$ is generated by monomials,
\item[$(b)$] if $f = \sum_{\alpha \in \bbbn^{n}} k_{\alpha}
x^{\alpha}$ belongs to $I$ then $x^{\alpha} \in I$ whenever
$k_{\alpha} \neq 0$,
\item[$(c)$] $I$ is torus-fixed; in other words, if $(c_{1}, \dotsc,
c_{n}) \in (\bbbq^{*})^{n}$, then $I$ is fixed under the action $x_{i}
\mapsto c_{i}x_{i}$ for all $i$.
\end{enumerate}
It follows that a monomial ideal is uniquely determined by the
monomials it contains.  Most operations are far simpler for a
monomial ideal than for an ideal generated by arbitrary polynomials.
In particular, many invariants can be effectively determined for
monomial ideals.  As a result, one can solve a broad collection of
problems by reducing to or encoding data in a monomial ideal.  The aim
of this chapter is to develop the computational aspects of monomial
ideals in \Mtwo and demonstrate a range of applications.

This chapter is divided into five sections.  Each section begins with
a discussion of a computational procedure involving monomial ideals.
Algorithms are presented as \Mtwo functions.  We illustrate these
methods by solving problems from various areas of mathematics.
In particular, we include the \Mtwo code for generating interesting
families of monomial ideals.  The first section introduces the basic
functions on monomial ideals in \Mtwo.  To demonstrate these functions,
we use the Stanley-Reisner ideal associated to a simplicial complex to
compute its $f$-vector.  Next, we present two algorithms for finding a
primary decomposition of a monomial ideal.  In a related example, we
use graph ideals to study the complexity of determining the
codimension of a monomial ideal.  The third section focuses on the
standard pairs of a monomial ideal; two methods are given for finding
the set of standard pairs.  As an application, we use standard pairs
to solve integer linear programming problems.  The fourth section
examines Borel-fixed ideals and generic initial ideals.  Combining
these constructions with distractions, we demonstrate that the Hilbert
scheme $\Hilb^{\, 4t+1}(\bbbp^{4})$ is connected.  Finally, we look at
the chains of associated primes in various families of monomial
ideals.

%%----------------------------------------------------------
\section{The Basics of Monomial Ideals}

Creating monomial ideals in \Mtwo is analogous to creating general
ideals.  The monomial ideal\index{monomial
ideal}\index{ideal!monomial} generated by a sequence or list of
monomials can be constructed with the function {\tt monomialIdeal}\indexcmd{monomialIdeal}.
\beginOutput
i1 : S = QQ[a, b, c, d]; \\
\endOutput
\beginOutput
i2 : I = monomialIdeal(a^2, a*b, b^3, a*c)\\
\emptyLine
\                     2        3\\
o2 = monomialIdeal (a , a*b, b , a*c)\\
\emptyLine
o2 : MonomialIdeal of S\\
\endOutput
\beginOutput
i3 : J = monomialIdeal\{a^2, a*b, b^2\}\\
\emptyLine
\                     2        2\\
o3 = monomialIdeal (a , a*b, b )\\
\emptyLine
o3 : MonomialIdeal of S\\
\endOutput
The type {\tt MonomialIdeal}\indexcmd{MonomialIdeal} is the class of all monomial ideals.  If
an entry in the sequence or list is not a single monomial, then {\tt
monomialIdeal} takes only the leading monomial; recall that every
polynomial ring in \Mtwo is equipped with a monomial ordering.
\beginOutput
i4 : monomialIdeal(a^2+a*b, a*b+3, b^2+d)\\
\emptyLine
\                     2        2\\
o4 = monomialIdeal (a , a*b, b )\\
\emptyLine
o4 : MonomialIdeal of S\\
\endOutput

There are also several methods of associating a monomial
ideal to an arbitrary ideal in a polynomial ring.  The most important
of these is the initial ideal\index{initial
ideal}\index{ideal!initial} --- the monomial ideal generated by the
leading monomials of all elements in the given ideal.  When applied to
an {\tt Ideal}, the function {\tt monomialIdeal} returns the initial
ideal.
\beginOutput
i5 : K = ideal(a^2, b^2, a*b+b*c)\\
\emptyLine
\             2   2\\
o5 = ideal (a , b , a*b + b*c)\\
\emptyLine
o5 : Ideal of S\\
\endOutput
\beginOutput
i6 : monomialIdeal K\\
\emptyLine
\                     2        2     2\\
o6 = monomialIdeal (a , a*b, b , b*c )\\
\emptyLine
o6 : MonomialIdeal of S\\
\endOutput
This is equivalent to taking the leading monomials of a Gr\"{o}bner
basis\index{Grobner basis@Gr\"obner basis} for {\tt K}.  In our example, the given
generators for {\tt K} are not a Gr\"{o}bner basis.
\beginOutput
i7 : monomialIdeal gens K\\
\emptyLine
\                     2        2\\
o7 = monomialIdeal (a , a*b, b )\\
\emptyLine
o7 : MonomialIdeal of S\\
\endOutput

One can also test if a general ideal is generated by monomials with
the function {\tt isMonomialIdeal}\indexcmd{isMonomialIdeal}.
\beginOutput
i8 : isMonomialIdeal K\\
\emptyLine
o8 = false\\
\endOutput
\beginOutput
i9 : isMonomialIdeal ideal(a^5, b^2*c, d^11)\\
\emptyLine
o9 = true\\
\endOutput
The usual algebraic operations on monomial ideals are the same as on
general ideals. For example, we have
\beginOutput
i10 : I+J\\
\emptyLine
\                      2        2\\
o10 = monomialIdeal (a , a*b, b , a*c)\\
\emptyLine
o10 : MonomialIdeal of S\\
\endOutput

%%----------------------------------------------------------
\subsection*{Example: Stanley-Reisner Ideals and $f$-vectors}

Radical monomial ideals --- ideals generated by squarefree monomials
--- have a beautiful combinatorial interpretation in terms of
simplicial complexes\index{simplicial complex}.  More explicitly, a
simplicial complex $\Delta$ on the vertex set $\{ x_{1}, \dotsc, x_{n}
\}$ corresponds to the ideal $I_{\Delta}$ in $S = \bbbq[x_{1}, \dotsc,
x_{n}]$ generated by all monomials $x_{i_{1}} \dotsb x_{i_{p}}$ such
that $\{x_{i_{1}}, \dotsc, x_{i_{p}} \} \not\in \Delta$. The ideal
$I_{\Delta}$ is called the Stanley-Reisner\index{Stanley-Reisner
ideal}\index{ideal!Stanley-Reisner} ideal of $\Delta$.

To illustrate the connections between Stanley-Reisner ideals and
simplicial complexes, we consider the
$f$-vector\index{f-vector@$f$-vector}\index{simplicial complex!$f$-vector}.
Perhaps the most important invariant of a simplicial complex, the
$f$-vector of a $d$-dimensional simplicial complex $\Delta$ is
$(f_{0}, f_{1}, \dotsc, f_{d}) \in \bbbn^{d+1}$, where $f_{i}$ denotes
the number of $i$-dimensional faces in $\Delta$.  From the monomial
ideal point of view, the $f$-vector is encoded in the Hilbert
series\index{Hilbert series} of the quotient ring $S/I_{\Delta}$ as
follows:

\begin{theorem}
If $\Delta$ is a simplicial complex with $f$-vector $(f_{0}, \dotsc,
f_{d})$, then the Hilbert series of $S / I_{\Delta}$ is
\[
H_{S/I_{\Delta}}(t) = \sum_{i=-1}^{d} \frac{f_{i}t^{i+1}}{(1-t)^{i+1}}
\, ,
\]
where $f_{-1} = 1$.
\end{theorem}

\begin{proof}
Following Stanley~\cite{MR98h:05001}, we work with the fine
grading and then
specialize.  The fine grading of $S$ is the $\bbbz^{n}$-grading
defined by $\deg x_{i} = \mathbf{e}_{i} \in \bbbz^{n}$, where
$\mathbf{e}_{i}$ is the $i$-th standard basis vector.  The
support\index{monomial!support} of a monomial $x^{\alpha}$ is defined
to be the set $\supp(x^{\alpha}) = \{ x_{i} : \alpha_{i} > 0 \}$.
Observe that $x^{\alpha} \neq 0$ in $S / I_{\Delta}$ if and only if
$\supp(x^{\alpha}) \in \Delta$.  Moreover, the nonzero monomials
$x^{\alpha}$ form a $\bbbq$-basis of $S / I_{\Delta}$.  By counting
such monomials according to their support, we obtain the following
expression for the Hilbert series with the fine grading:
\[
H_{S/I_{\Delta}}(\mathbf{t}) = \sum_{F \in \Delta}
\sum_{\substack{\alpha \in \bbbn^{n} \\ \supp(x^{\alpha}) = F}}
\mathbf{t}^{\alpha} = \sum_{F \in \Delta} \prod_{x_{i} \in F}
\frac{t_{i}}{1-t_{i}} \, .
\]
Finally, by replacing each $t_{i}$ with $t$, we complete the
proof.\qed
\end{proof}

Since $H_{S/I_{\Delta}}(t)$ is typically expressed in the form
$\frac{h_{0} + h_{1}t + \dotsb + h_{d}t^{d}}{(1-t)^{d+1}}$, we can
obtain the $f$-vector by using the identity $\sum_{i} h_{i}t^{i} =
\sum_{j=0}^{d} f_{j-1}t^{j}(1-t)^{d-j}$.  In particular, we can
compute $f$-vectors from Stanley-Reisner ideals as follows:
\beginOutput
i11 : fvector = I -> (\\
\           R := (ring I)/I;\\
\           d := dim R;\\
\           N := poincare R;\\
\           t := first gens ring N;\\
\           while 0 == substitute(N, t => 1) do N = N // (1-t);\\
\           h := apply(reverse toList(0..d), i -> N_(t^i));\\
\           f := j -> sum(0..j+1, i -> binomial(d-i, j+1-i)*h#(d-i));\\
\           apply(toList(0..d-1), j -> f(j)));\\
\endOutput
For example, we can demonstrate that the $f$-vector of the octahedron
is $(6,12,8)$.
\beginOutput
i12 : S = QQ[x_1 .. x_6];\\
\endOutput
\beginOutput
i13 : octahedron = monomialIdeal(x_1*x_2, x_3*x_4, x_5*x_6)\\
\emptyLine
o13 = monomialIdeal (x x , x x , x x )\\
\                      1 2   3 4   5 6\\
\emptyLine
o13 : MonomialIdeal of S\\
\endOutput
\beginOutput
i14 : fvector octahedron\\
\emptyLine
o14 = \{6, 12, 8\}\\
\emptyLine
o14 : List\\
\endOutput

\begin{figure}
\begin{center}
\epsfysize=1.8in \epsfbox{octahedron.eps}
\end{center}
\caption{The octahedron}
\end{figure}

More generally, we can recursively construct simplicial $2$-spheres
with $f_{0} \geq 4$, starting with the tetrahedron, by pulling a point
in the relative interior of a facet.  This procedure leads to the
following family:
\beginOutput
i15 : simplicial2sphere = v -> ( \\
\           S := QQ[x_1..x_v]; \\
\           if v === 4 then monomialIdeal product gens S \\
\           else ( \\
\                L := \{\};\\
\                scan(1..v-4, i -> L = L | apply(v-i-3, \\
\                          j -> x_i*x_(i+j+4))); \\
\                scan(2..v-3, i -> L = L | \{x_i*x_(i+1)*x_(i+2)\}); \\
\                monomialIdeal L));\\
\endOutput
\beginOutput
i16 : apply(\{4,5,6,7,8\}, j -> fvector simplicial2sphere(j))\\
\emptyLine
o16 = \{\{4, 6, 4\}, \{5, 9, 6\}, \{6, 12, 8\}, \{7, 15, 10\}, \{8, 18, 12\}\}\\
\emptyLine
o16 : List\\
\endOutput
In fact, it follows from Euler's formula that the $f$-vector of any
simplicial $2$-sphere has the form $(v, 3v-6, 2v-4)$ for $v \geq 4$.
The problem of characterizing the $f$-vectors for triangulations of
$d$-spheres is open for $d \geq 3$.  One of the most important results
in this direction is the upper bound theorem for simplicial spheres
(Corollary~5.4.7 Bruns and Herzog~\cite{MR95h:13020}) which states
that the cyclic polytope has the maximal number of $i$-faces for all
$i$.  We point out that Stanley's proof of this theorem depends
heavily on these methods from commutative algebra.

On the other hand, the $f$-vectors for several major classes of
simplicial complexes have been characterized.  The Kruskal-Katona
theorem (Theorem~8.32 in Ziegler~\cite{MR96a:52011}) gives necessary
and sufficient conditions for a sequence of nonnegative integers to be
an $f$-vector of a simplicial complex.  Stanley~\cite{MR98h:05001}
describes the $f$-vectors of pure shellable complexes and
Cohen-Macaulay complexes.  Given the Betti numbers of a simplicial
complex, Bj\"{o}rner and Kalai~\cite{MR89m:52009} specify the
$f$-vectors.  Finally, the $g$-theorem (Theorem~8.35 in
Ziegler~\cite{MR96a:52011}) characterizes the $f$-vectors for boundary
complexes of a simplicial convex polytope.

For a further study of Stanley-Reisner ideals see Bruns and
Herzog~\cite{MR95h:13020} and Stanley~\cite{MR98h:05001}.  For more
information of $f$-vectors, see Ziegler~\cite{MR96a:52011} and
Bj\"{o}rner~\cite{MR96h:05213}.

%%----------------------------------------------------------
\section{Primary Decomposition}

A primary decomposition\index{primary decomposition} of an ideal $I$
is an expression of $I$ as a finite intersection of primary ideals; an
ideal $J$ is called primary\index{ideal!primary} if $r_{1}r_{2} \in J$
implies either $r_{1} \in J$ or $r_{2}^{\ell} \in J$ for some $\ell >
0$.  Providing an algorithm for computing the primary decomposition of
an arbitrary ideal in a polynomial ring is quite difficult.  However,
for monomial ideals, there are two algorithms which are relatively
simple to describe.

We first present a recursive method for generating an irreducible
primary decomposition.  It is based on the following two observations.
\begin{lemma}
Let $I$ be a monomial ideal in $S = \bbbq[x_1, \dotsc, x_n]$.
\begin{enumerate}
\item[$(1)$] If $I$ is generated by pure powers of a subset of the
variables, then it is a primary ideal.
\item[$(2)$] If $r$ is minimal generator of $I$ such that $r =
r_{1}r_{2}$ where $r_{1}$ and $r_{2}$ are relatively prime, then $I =
\big(I + \langle r_{1} \rangle \big) \cap \big(I + \langle r_{2}
\rangle \big)$.
\end{enumerate}
\end{lemma}

\begin{proof}
$(1)$ This follows immediately from the definition of primary.  $(2)$
Since $I$ is a monomial ideal, it is enough to show that $I$ and
$\big( I + \langle r_{1} \rangle \big) \cap \big( I + \langle r_{1}
\rangle \big)$ contain the same monomials.  A monomial $r'$ belongs to
$\big( I + \langle r_{j} \rangle \big)$ if and only if $r' \in I$ or
$r_{j}$ divides $r'$.  Because $r_{1}$ and $r_{2}$ are relative prime,
we have
\[
r' \in \big( I + \langle r_{1} \rangle \big) \cap \big( I + \langle
r_{1} \rangle \big) \Leftrightarrow \text{ $r' \in I$ or $r_{1}r_{2}$
divides $r'$ } \Leftrightarrow \text{ $r' \in I$} \, . \qquad \qed
\]
\end{proof}

The following is an implementation of the resulting algorithm:
\beginOutput
i17 : supp = r -> select(gens ring r, e -> r {\char`\%} e == 0);\\
\endOutput
\beginOutput
i18 : monomialDecompose = method();\\
\endOutput
\beginOutput
i19 : monomialDecompose List := L -> (\\
\           P := select(L, I -> all(first entries gens I, \\
\                     r -> #supp(r) < 2) === false);\\
\           if #P > 0 then (\\
\                I := first P;\\
\                m := first select(first entries gens I, \\
\                     r -> #supp(r) > 1);\\
\                E := first exponents m;\\
\                i := position(E, e -> e =!= 0);\\
\                r1 := product apply(E_\{0..i\}, (gens ring I)_\{0..i\}, \\
\                     (j, r) -> r^j);\\
\                r2 := m // r1;\\
\                monomialDecompose(delete(I, L) | \{I+monomialIdeal(r1),\\
\                          I+monomialIdeal(r2)\}))\\
\           else L);\\
\endOutput
\beginOutput
i20 : monomialDecompose MonomialIdeal := I -> monomialDecompose \{I\};\\
\endOutput
Here is a small example illustrating this method.
\beginOutput
i21 : S = QQ[a,b,c,d];\\
\endOutput
\beginOutput
i22 : I = monomialIdeal(a^3*b, a^3*c, a*b^3, b^3*c, a*c^3, b*c^3)\\
\emptyLine
\                      3      3   3    3      3     3\\
o22 = monomialIdeal (a b, a*b , a c, b c, a*c , b*c )\\
\emptyLine
o22 : MonomialIdeal of S\\
\endOutput
\beginOutput
i23 : P = monomialDecompose I;\\
\endOutput
\beginOutput
i24 : scan(P, J -> << endl << J << endl);\\
\emptyLine
monomialIdeal (b, c)\\
\emptyLine
monomialIdeal (a, c)\\
\emptyLine
\                3   3   3\\
monomialIdeal (a , b , c )\\
\emptyLine
monomialIdeal (a, b)\\
\emptyLine
\                3      3\\
monomialIdeal (a , b, c )\\
\emptyLine
monomialIdeal (a, b)\\
\emptyLine
\                   3   3\\
monomialIdeal (a, b , c )\\
\endOutput
\beginOutput
i25 : I == intersect(P)\\
\emptyLine
o25 = true\\
\endOutput
As we see from this example, this procedure doesn't necessarily
yield an irredundant decomposition.

The second algorithm for finding a primary decomposition of a monomial
ideal $I$ is based on the Alexander dual\index{Alexander
dual}\index{dual, Alexander} of $I$.  The Alexander dual was first
introduced for squarefree monomial ideals.  In this case, it is the
monomial ideal of the dual of the simplicial complex $\Delta$
corresponding to $I$.  By definition the dual complex of $\Delta$ is
$\Delta^{\vee} = \{ F : F^{c} \not\in \Delta \}$, where $F^{c} =
\{x_{1}, \dotsc, x_{n}\} \setminus F$.  The following general
definition appears in Miller~\cite{M},~\cite{MR1779598}.  If
$I \subseteq \bbbq[x_{1},
\dotsc, x_{n}]$ is a monomial ideal and $x^{\lambda}$ is the least
common multiple of the minimal generators of $I$, then the Alexander
dual of $I$ is
\[
I^{\vee} = \left\langle \prod_{\beta_{i} > 0}
x_{i}^{\lambda_{i}+1-\beta_{i}} : \begin{tabular}{l} \text{$\langle
x_{i}^{\beta_{i}} : \beta_{i} \geq 1\rangle$ is an
irredundant} \\ \text{irreducible component of $I$} \end{tabular}
\right\rangle \, .
\]
In particular, the minimal generators of $I^{\vee}$ correspond to the
irredundant irreducible components of $I$.  The next proposition
provides a useful way of computing $I^{\vee}$ given a set of
generators for $I$.

\begin{proposition}
If $I$ is a monomial ideal and $x^{\lambda}$ is the least common
multiple of the minimal generators of $I$, then the generators for
$I^{\vee}$ are those generators of the ideal $\left( \langle
x_{1}^{\lambda_{1}+1}, \dotsc, x_{n}^{\lambda_{n}+1} \rangle : I
\right)$ that are not divisible by $x_{i}^{\lambda_{i}+1}$ for $1 \leq
i \leq n$.
\end{proposition}

\begin{proof}
See Theorem~2.1 in Miller~\cite{M}. \qed
\end{proof}

Miller's definition of Alexander dual is even more general than the one
above. The resulting algorithm for computing this general Alexander
dual and primary decomposition are implemented in \Mtwo as follows.
For the Alexander dual we use, the list {\tt a} that appears
as an input argument for {\tt dual}\indexcmd{dual} should be list of exponents of
the least common multiple of the minimal generators of $I$.
\beginOutput
i26 : code(dual, MonomialIdeal, List)\\
\emptyLine
o26 = -- ../../../m2/monideal.m2:260-278\\
\      dual(MonomialIdeal, List) := (I,a) -> ( -- Alexander dual\\
\           R := ring I;\\
\           X := gens R;\\
\           aI := lcmOfGens I;\\
\           if aI =!= a then (\\
\                if #aI =!= #a \\
\                then error (\\
\                     "expected list of length ",\\
\                     toString (#aI));\\
\                scan(a, aI, \\
\                     (b,c) -> (\\
\                          if b<c then\\
\                          error "exponent vector not large enough"\\
\                          ));\\
\                ); \\
\           S := R/(I + monomialIdeal apply(#X, i -> X#i^(a#i+1)));\\
\           monomialIdeal contract(\\
\                lift(syz transpose vars S, R), \\
\                product(#X, i -> X#i^(a#i))))\\
\endOutput
\beginOutput
i27 : code(primaryDecomposition, MonomialIdeal)\\
\emptyLine
o27 = -- ../../../m2/monideal.m2:286-295\\
\      primaryDecomposition MonomialIdeal := (I) -> (\\
\           R := ring I;\\
\           aI := lcmOfGens I;\\
\           M := first entries gens dual I;\\
\           L := unique apply(#M, i -> first exponents M_i);\\
\           apply(L, i -> monomialIdeal apply(#i, j -> ( \\
\                          if i#j === 0 then 0_R \\
\                          else R_j^(aI#j+1-i#j)\\
\                          )))\\
\           )\\
\endOutput
This direct algorithm is more efficient than our recursive algorithm.
In particular, it gives an irredundant decomposition.  For example,
when we use it to determine a primary decomposition for the ideal {\tt
I} above, we obtain
\beginOutput
i28 : L = primaryDecomposition I;\\
\endOutput
\beginOutput
i29 : scan(L, J -> << endl << J << endl);\\
\emptyLine
\                3   3   3\\
monomialIdeal (a , b , c )\\
\emptyLine
monomialIdeal (b, c)\\
\emptyLine
monomialIdeal (a, b)\\
\emptyLine
monomialIdeal (a, c)\\
\endOutput
\beginOutput
i30 : I == intersect L\\
\emptyLine
o30 = true\\
\endOutput

For a family of larger examples, we consider the tree
ideals\index{ideal!tree}:
\[
\left\langle \big({\textstyle \prod_{i \in F}} x_{i}\big)^{n-|F|+1} :
\text{ $\emptyset \neq F \subseteq \{ x_{1}, \dotsc, x_{n} \}$}
\right\rangle \, .
\]
These ideals are so named because their standard monomials (the
monomials not in the ideal) correspond to trees on $n+1$ labeled
vertices.  We determine the number of irredundant irreducible
components as follows:
\beginOutput
i31 : treeIdeal = n -> (\\
\           S = QQ[vars(0..n-1)];\\
\           L := delete(\{\}, subsets gens S);\\
\           monomialIdeal apply(L, F -> (product F)^(n - #F +1)));\\
\endOutput
\beginOutput
i32 : apply(2..6, i -> #primaryDecomposition treeIdeal i)\\
\emptyLine
o32 = (2, 6, 24, 120, 720)\\
\emptyLine
o32 : Sequence\\
\endOutput

%%----------------------------------------------------------
\subsection*{Example: Graph Ideals and Complexity Theory}

Monomial ideals also arise in graph theory.  Given a graph $G$ with
vertices $\{x_{1}, \dotsc, x_{n}\}$, we associate the
ideal\index{ideal!graph} $I_{G}$ in $\bbbq[x_{1}, \dotsc, x_{n}]$
generated by the quadratic monomials $x_{i}x_{j}$ such that $x_{i}$ is
adjacent to $x_{j}$.  The primary decomposition of $I_{G}$ is related to
the graph $G$ as follows.  Recall that a subset $F \subseteq \{x_{1},
\dotsc, x_{n}\}$ is called a {\em vertex cover}\index{vertex
cover}\index{cover} of $G$ if each edge in $G$ is incident to at least
one vertex in $F$.

\begin{lemma} \label{lem:graphideal}
If $G$ is a graph and $\mathcal{C}$ is the set of minimal vertex
covers of $G$ then the irreducible irredundant primary
decomposition\index{primary decomposition} of $I_{G}$ is $\bigcap_{F
\in \mathcal{C}} P_{F^{c}}$, where $P_{F^{c}}$ is the prime ideal
$\langle x_{i} : x_{i} \not\in F^{c} \rangle =
\langle x_{i} : x_{i} \in F \rangle$.
\end{lemma}

\begin{proof}
Since each generator of $I_{G}$ corresponds to an edge in $G$, it
follows from the {\tt monomialDecompose} algorithm that $I_{G}$ has an
irreducible primary decomposition of the form: $I_{G} = \bigcap
P_{F^{c}}$, where $F$ is a vertex cover.  To obtain an
irredundant decomposition, one clearly needs only the minimal vertex
covers. \qed
\end{proof}

As an application of graph ideals, we examine the complexity of
determining the codimension\index{ideal!codimension} of a monomial
ideal.  In fact, following Bayer and Stillman~\cite{MR94f:13018}, we
prove

\begin{proposition} \label{pro:complexity}
The following decision problem is NP-complete:
\begin{equation} \tag{{\sc Codim}}
\text{\begin{minipage}[c]{200pt}
Given a monomial ideal $I \subseteq \bbbq[x_1, \dotsc, x_n]$
and $m \in \bbbn$, is $\codim I \leq m$?
\end{minipage}}
\end{equation}
\end{proposition}

By definition, a decision problem is NP-complete\index{NP-complete} if
all other problems in the class NP can be reduced to it.  To prove
that a particular problem is NP-complete, it suffices to show: $(1)$
the problem belongs to the class NP; $(2)$ some known NP-complete
problem reduces to the given decision problem (see Lemma~2.3 in Garey
and Johnson~\cite{MR80g:68056}).  One of the ``standard NP-complete''
problems (see section~3.1 in Garey and Johnson~\cite{MR80g:68056}) is
the following:
\begin{equation} \tag{{\sc Vertex Cover}}
\text{\begin{minipage}[c]{200pt} Given a graph $G$ and $m \in \bbbn$,
is there a vertex cover $F$ such that $|F| \leq m$? \end{minipage}}
\end{equation}

\begin{sproof}
$(1)$ Observe that a monomial ideal $I$ has codimension at most $m$ if
and only if $I \subseteq P_{F^{c}}$ for some $F$ with $|F|
\leq m$.  Now, if $I$ has codimension at most $m$, then given an
appropriate choice of $F$, one can verify in polynomial time that $I
\subseteq P_{F^{c}}$ and $|F| \leq m$.  Therefore, the {\sc
Codim} problem belongs to the class NP.

$(2)$ Lemma~\ref{lem:graphideal} implies that $I_{G}$ has codimension
$m$ if and only if $G$ has a vertex cover of size at most $m$.  In
particular, the {\sc Vertex Cover} problem reduces to the {\sc Codim}
problem. \qed
\end{sproof}

Thus, assuming P $\neq$ NP, there is no polynomial time algorithm for
finding the codimension of a monomial ideal.  Nevertheless, we can
effectively compute the codimension for many interesting examples.

To illustrate this point, we consider the following family of
examples.  Let $S = \bbbq[X]$ denote the polynomial ring generated by
the entries of a generic $m \times n$ matrix $X = [x_{i,j}]$.  Let
$I_{k}$\index{ideal!of minors} be the ideal generated by the $k \times
k$ minors of $X$.  Since the Hilbert function of $S / I_{k}$ equals
the Hilbert function of $S / \initial(I_{k})$ (see Theorem~15.26 in
Eisenbud~\cite{MR97a:13001}), we can determine the codimension $I_{k}$
by working with the monomial ideal $\initial(I_{k})$.  Because
Sturmfels~\cite{MR91m:14076} shows that the set of $k \times k$-minors
of $X$ is the reduced Gr\"{o}bner basis of $I_{k}$ with respect to the
lexicographic term order induced from the variable order
\[
x_{1,n} > x_{1,n-1} > \dotsb > x_{1,1} > x_{2,n} > \dotsb > x_{2,1} >
\dotsb > x_{m,n} > \dotsb > x_{m,1} \, ,
\]
we can easily calculate $\initial(I_k)$.  In particular, in \Mtwo we
have
\beginOutput
i33 : minorsIdeal = (m,n,k) -> (\\
\           S := QQ[x_1..x_(m*n), MonomialOrder => Lex];\\
\           I := minors(k, matrix table(m, n, (i,j) -> x_(i*n+n-j)));\\
\           forceGB gens I;\\
\           I);\\
\endOutput
\beginOutput
i34 : apply(2..8, i -> time codim monomialIdeal minorsIdeal(i,2*i,2))\\
\     -- used 0.02 seconds\\
\     -- used 0.05 seconds\\
\     -- used 0.1 seconds\\
\     -- used 0.36 seconds\\
\     -- used 1.41 seconds\\
\     -- used 5.94 seconds\\
\     -- used 25.51 seconds\\
\emptyLine
o34 = (3, 10, 21, 36, 55, 78, 105)\\
\emptyLine
o34 : Sequence\\
\endOutput
The properties of $I_{k}$ are further developed in chapter~11 of
Sturmfels~\cite{MR97b:13034} and chapter~7 of Bruns and
Herzog~\cite{MR95h:13020}

For more on the relationships between a graph and its associated
ideal, see Villarreal~\cite{MR91b:13031}, Simis, Vasconcelos and
Villarreal~\cite{MR99c:13004}, and Ohsugi and
Hibi~\cite{MR2000a:13010}.

\beginOutput
i35 : erase symbol x;\\
\endOutput

%%----------------------------------------------------------
\section{Standard Pairs}

In this section, we examine a combinatorial object associated to a
monomial ideal.  In particular, we present two algorithms for
computing the standard pairs of a monomial ideal from its minimal
generators.  Before giving the definition of a standard pair, we
consider an example.

\begin{figure}
\begin{center}
\epsfysize=2.4in \epsfbox{standardpairs-fixed.eps}
\end{center}
\caption{Staircase diagram for $I = \langle xy^3z, xy^2z^2, y^3z^2,
y^2z^3 \rangle$}
\end{figure}

\begin{example} \label{std-ex}
Let $I = \langle xy^3z, xy^2z^2, y^3z^2, y^2z^3 \rangle$ in
$\bbbq[x,y,z]$.  We identify the monomials in $\bbbq[x,y,z]$
with the lattice points in $\bbbn^3$; see Figure~2.  The
standard monomials of $I$, those monomials which are not in $I$, can
be enumerated as follows: $(i)$ monomials corresponding to lattice
points in the $xy$-plane, $(ii)$ monomials corresponding to lattice
points in the $xz$-plane, $(iii)$ monomials corresponding to lattice
points in the plane parallel to the $xz$-plane containing $(0,1,0)$,
$(iv)$ monomials corresponding to lattice points on the line parallel
to the $y$-axis containing $(0,0,1)$, $(v)$ monomials corresponding to
lattices point on the line parallel to the $x$-axis containing
$(0,2,1)$, and $(vi)$ the monomial $y^{2}z^{2}$.
\end{example}

Following Sturmfels, Trung and Vogel~\cite{MR96i:13029}, we make the
following definitions.  Given a monomial $x^{\alpha}$ and a subset $F
\subseteq \{ x_{1}, \dotsc, x_{n} \}$, we index the set of monomials
of the form $x^{\alpha} \cdot x^{\beta}$ where $\supp(x^{\beta})
\subseteq F$ by the pair $(x^{\alpha}, F)$.  A standard
pair\index{standard pair} of a monomial ideal $I$ is a pair
$(x^{\alpha}, F)$ satisfying the following three conditions:
\begin{enumerate}
\item[$(1)$] $\supp(x^{\alpha}) \cap F = \emptyset$,
\item[$(2)$] all of the monomials represented by this pair are
standard, and
\item[$(3)$] $(x^{\alpha}, F) \not\subseteq (x^{\beta}, G)$ for any
other pair $(x^{\beta}, G)$ satisfying the first two conditions.
\end{enumerate}
Hence, the six standard pairs
\[
(1, \{x,y\}), (1, \{x,z\}), (y,\{x,z\}), (z, \{y\}), (y^{2}z, \{x\}),
(y^2z^2, \emptyset)
\]
in Example~\ref{std-ex} correspond to $(i)$--$(vi)$.

Observe that the set of standard pairs of $I$ gives an irreducible
decomposition\index{primary decomposition} of $I = \bigcap \langle
x_{i}^{\alpha_{i}+1} : \text{ $x_{i} \notin F$} \rangle$, where the
intersection is over all standard pairs $(x^{\alpha}, F)$.  Moreover,
the prime ideal $P_F := \langle x_{i} : \text{ $x_{i} \notin F$}
\rangle$ is an associated prime of $I$ if and only if there exists a
standard pair of the form $(\bullet, F)$; see Sturmfels, Trung and
Vogel~\cite{MR96i:13029} for details.

Our first algorithm for computing the set of standard
pairs\index{standard pair} is taken from Ho\c{s}ten and
Thomas~\cite{MR2000f:13052}.  The ideas behind it are as follows:
given a witness $w_1 = x^{\alpha}$ for the associated prime $P_F :=
\langle x_{i} : \text{ $x_{i} \notin F$} \rangle$, that is $(I :
x^{\alpha}) = P_F$, set $w_2 = \prod_{x_i \in \supp(w_1) \cap F^c}
x_i^{\alpha_{i}}$.  It follows that $(w_2, F)$ is a standard pair of
$I$.  Now, consider the standard pairs of the slightly larger ideal $I
+ \langle w_1 \rangle$.  Clearly $(w_2, F)$ is not a standard pair of
this ideal because $w_1$ ``destroys'' it.  This larger ideal might
have standard pairs which cover standard monomials in $(w_2, F)$ that
are not in the pair $(w_1, F)$.  However, all other standard pairs are
the same as the original ideal $I$.  Thus, the problem of finding all
standard pairs of $I$ reduces to determining if a standard pair of $I
+ \langle w_1 \rangle$ is a standard pair for $I$.  To decide if a
pair $(x^{\beta}, G)$ of $I + \langle w_1 \rangle$ is a standard pair
of $I$, we first check that $P_{F}$ is an associated prime of $I$.  If
this is true, we determine if $(w_{2},F)$ is covered by
$(x^{\beta},G)$.

The \Mtwo version of this algorithm takes the following form:
\beginOutput
i36 : stdPairs = I -> (\\
\           S := ring I;\\
\           X := gens S;\\
\           std := \{\};\\
\           J := I;\\
\           while J != S do (\\
\                w1 := 1_S;\\
\                F := X;\\
\                K := J;\\
\                while K != 0 do (\\
\                     g1 := (ideal mingens ideal K)_0;\\
\                     x := first supp g1;\\
\                     w1 = w1 * g1 // x;\\
\                     F = delete(x, F);\\
\                     K = K : monomialIdeal(g1 // x);\\
\                     L := select(first entries gens K, \\
\                          r -> not member(x, supp r));\\
\                     if #L > 0 then K = monomialIdeal L\\
\                     else K = monomialIdeal 0_S;);\\
\                w2 := w1;\\
\                scan(X, r -> if not member(r, supp w1) or member(r, F)\\
\                     then w2 = substitute(w2, \{r => 1\}));\\
\                P := monomialIdeal select(X, r -> not member(r, F));\\
\                if (I:(I:P) == P) and (all(std, p -> \\
\                          (w2 {\char`\%} (first p) != 0) or not\\
\                          isSubset(supp(w2 // first p) | F, last p)))\\
\                then std = std | \{\{w2, F\}\};\\
\                J = J + monomialIdeal(w1););\\
\           std);\\
\endOutput
We can compute the standard pairs of Example~\ref{std-ex} using this
\Mtwo function:
\beginOutput
i37 : S = QQ[x,y,z];\\
\endOutput
\beginOutput
i38 : I = monomialIdeal(x*y^3*z, x*y^2*z^2, y^3*z^2, y^2*z^3);\\
\emptyLine
o38 : MonomialIdeal of S\\
\endOutput
\beginOutput
i39 : scan(time stdPairs I, P -> << endl << P << endl);\\
\     -- used 0.66 seconds\\
\emptyLine
\{y, \{x, z\}\}\\
\emptyLine
\{1, \{x, z\}\}\\
\emptyLine
\  2 2\\
\{y z , \{\}\}\\
\emptyLine
\{z, \{y\}\}\\
\emptyLine
\  2\\
\{y z, \{x\}\}\\
\emptyLine
\{1, \{x, y\}\}\\
\endOutput

Our second algorithm is taken from section~3.2 of Saito, Sturmfels and
Takayama~\cite{MR1734566}.  The proposition below provides the main
ingredient for this algorithm.  If $I$ is a monomial ideal and $F
\subseteq \{ x_{1},\dotsc, x_{n} \}$, we write $I_F$ for the monomial
ideal in $\bbbq[x_i : \text{ $x_{i} \notin F$}]$ obtained by replacing
each $x_{i} \in F$ with $1$ in every minimal generator of $I$.

\begin{proposition}
For $(x^{\alpha}, F)$ to be a standard pair of $I$, it is necessary
and sufficient that $(x^{\alpha}, \emptyset)$ be a standard pair of
$I_F$.
\end{proposition}

\begin{proof}
Lemma 3.1 in Sturmfels, Trung and Vogel \cite{MR96i:13029}.
\end{proof}

The definition of a standard pair\index{standard pair} implies that
$(x^{\alpha}, \emptyset)$ is a standard pair of $I_F$ if and only if
$x^{\alpha}$ is one of the finitely many monomials contained in $(I_F
: P_F^\infty)$ but not contained in $I_F$, where $P_F = \langle x_i:
x_i \notin F \rangle$.  Since ideal quotients and saturations are
implemented in \Mtwo, this reduces the problem to finding a set $D$
which contains $F$ for every associated prime $P_{F}$ of $I$.  One
approach is to simply compute the associated primes of $I$ from a
primary decomposition.

The method {\tt standardPairs}\indexcmd{standardPairs} uses this algorithm to determine the
set of standard pairs for a monomial ideal.
\beginOutput
i40 : code(standardPairs, MonomialIdeal, List)\\
\emptyLine
o40 = -- ../../../m2/monideal.m2:318-341\\
\      standardPairs(MonomialIdeal, List) := (I,D) -> (\\
\           R := ring I;\\
\           X := gens R;\\
\           S := \{\};\\
\           k := coefficientRing R;\\
\           scan(D, L -> ( \\
\                     Y := X;\\
\                     m := vars R;\\
\                     Lset := set L;\\
\                     Y = select(Y, r -> not Lset#?r);\\
\                     m = substitute(m, apply(L, r -> r => 1));\\
\                     -- using monoid to create ring to avoid \\
\                     -- changing global ring.\\
\                     A := k (monoid [Y]);\\
\                     phi := map(A, R, substitute(m, A));\\
\                     J := ideal mingens ideal phi gens I;\\
\                     Jsat := saturate(J, ideal vars A);\\
\                     if Jsat != J then (\\
\                          B := flatten entries super basis (\\
\                               trim (Jsat / J));\\
\                          psi := map(R, A, matrix\{Y\});\\
\                          S = join(S, apply(B, b -> \{psi(b), L\}));\\
\                          )));\\
\           S)\\
\endOutput
\beginOutput
i41 : time standardPairs I;\\
\     -- used 0.83 seconds\\
\endOutput

As an example, we will compute the standard pairs of the permutahedron
ideal\index{ideal!permutahedron}. Let $S = \bbbq[x_1, \dotsc, x_n]$
and let $\mathfrak{S}_n$ be the symmetric group of order $n$.  We
write $\rho$ for the vector $(1, 2, \dotsc, n)$ and $\sigma(\rho)$ for
the vector obtained by applying $\sigma \in \mathfrak{S}_n$ to the
coordinates of $\rho$. The $n$-th permutahedron ideal is $\langle
x^{\sigma(\rho)} : \text{ $\sigma \in \mathfrak{S}_n$} \rangle$.  We
compute the number of standard pairs for $2 \leq n \leq 5$.
\beginOutput
i42 : permutohedronIdeal = n -> (\\
\           S := QQ[X_1..X_n];\\
\           monomialIdeal terms det matrix table(n ,gens S, \\
\                (i,r) -> r^(i+1)));\\
\endOutput
\beginOutput
i43 : L = apply(\{2,3,4,5\}, j -> standardPairs(permutohedronIdeal(j)));\\
\endOutput
\beginOutput
i44 : apply(L, i -> #i)\\
\emptyLine
o44 = \{3, 10, 53, 446\}\\
\emptyLine
o44 : List\\
\endOutput
\beginOutput
i45 : erase symbol x; erase symbol z;\\
\endOutput

%%----------------------------------------------------------
\subsection*{Example: Integer Programming Problems}

As an application of standard pairs\index{standard pair}, we show how
to solve integer linear programming problems\index{integer programming}.
Let $A$ be a $d \times n$ matrix of nonnegative integers, let $\omega
\in \bbbr^{n}$ and fix $\beta \in \bbbz^{d}$.  We focus on the
following optimization problem
\[
\IP_{A,\omega}(\beta) : \,\,\, \text{ minimize $\omega \cdot \alpha$
subject to $A \alpha = \beta$, $\alpha \in \bbbn^n$.}
\]
We view this integer linear program as a family depending on the
vector $\beta$.  The algorithm we present for solving
$\IP_{A,\omega}(\beta)$ depends on the proposition below.

The toric ideal\index{toric ideal}\index{ideal!toric} $I_{A} \subseteq
S = \bbbq[x_{1}, \dotsc, x_{n}]$ associated to $A$ is the binomial
ideal generated by $x^{\gamma} - x^{\delta}$ where $\gamma$, $\delta
\in \bbbn^{n}$ and $A \gamma = A \delta$.  We write $\initial_{\,
\omega}(I_{A})$ for the initial ideal\index{initial ideal} of $I_A$
with respect to the following order:
\[
x^{\gamma} \prec_{\omega} x^{\delta} \Longleftrightarrow \begin{cases}
\omega \cdot \gamma < \omega \cdot \delta & \text{ or } \\
\omega \cdot \gamma = \omega \cdot \delta & \text{ and } x^{\alpha}
\prec_{{\rm rlex}} x^{\gamma} \, .
\end{cases}
\]
For more information on toric ideals and their initial ideals see
Sturmfels~\cite{MR97b:13034}.

\begin{proposition}
\begin{enumerate}
\item[$(1)$] A monomial $x^{\alpha}$ is a standard monomial of
$\initial_{\, \omega}(I_{A})$ if and only if $\alpha$ is the optimal
solution to the integer program $\IP_{A,\omega}(A\alpha)$.
\item[$(2)$] If $(\bullet, F)$ is a standard pair of
$\initial_{\, \omega}(I_{A})$, then the columns of $A$ corresponding to
$F$ are linearly independent.
\end{enumerate}
\end{proposition}

\begin{proof}
See Proposition~2.1 in Ho\c{s}ten and Thomas~\cite{MR2000b:13037} for
the proof of the first statement. The second statement follows from
Corollary~2.9 of the same article.
\qed
\end{proof}

The first statement implies that the standard pairs of $\initial_{\,
\omega}(I_{A})$ cover all optimal solutions to all integer programs
in $\IP_{A,\omega}$.  If $\alpha$ is the optimal solution to
$\IP_{A,\omega}(\beta)$ covered by the standard pair $(x^{\gamma},
F)$, then the second statement guarantees there exists a unique
$\delta \in \bbbn^{n}$ such that $A \delta = \beta - A \gamma$.
Therefore, $\alpha = \delta + \gamma$.  We point out that the
complexity of this algorithm is dominated by determining the set of
standard pairs of $\initial_{\, \omega}(I_{A})$ which depends only on
$A$ and $\omega$.  As a result, this method is particularly well
suited to solving $\IP_{A,\omega}(\beta)$ as $\beta$ varies.

To implement this algorithm in \Mtwo, we need a function which returns
the toric ideal $I_A$.  Following Algorithm~12.3 in
Sturmfels~\cite{MR97b:13034}, we have
\beginOutput
i47 : toBinomial = (b, S) -> (\\
\           pos := 1_S;\\
\           neg := 1_S;\\
\           scan(#b, i -> if b_i > 0 then pos = pos*S_i^(b_i)\\
\                         else if b_i < 0 then neg = neg*S_i^(-b_i));\\
\           pos - neg);\\
\endOutput
\beginOutput
i48 : toricIdeal = (A, omega) -> (\\
\           n := rank source A;\\
\           S = QQ[x_1..x_n, Weights => omega, MonomialSize => 16];\\
\           B := transpose matrix syz A;\\
\           J := ideal apply(entries B, b -> toBinomial(b, S));\\
\           scan(gens S, r -> J = saturate(J, r));\\
\           J);\\
\endOutput
Thus, we can solve $\IP_{A,\omega}(\beta)$ using the following
function.
\beginOutput
i49 : IP = (A, omega, beta) -> (\\
\           std := standardPairs monomialIdeal toricIdeal(A, omega);\\
\           n := rank source A;\\
\           alpha := \{\};\\
\           Q := first select(1, std, P -> (\\
\                F := apply(last P, r -> index r);\\
\                gamma := transpose matrix exponents first P;\\
\                K := transpose syz (submatrix(A,F) | (A*gamma-beta));\\
\                X := select(entries K, k -> abs last(k) === 1);\\
\                scan(X, k -> if all(k, j -> j>=0) or all(k, j -> j<=0)\\
\                     then alpha = apply(n, j -> if member(j, F) \\
\                          then last(k)*k_(position(F, i -> i === j))\\
\                          else 0));\\
\                #alpha > 0));\\
\           if #Q > 0 then (matrix \{alpha\})+(matrix exponents first Q)\\
\           else 0);\\
\endOutput

We illustrate this with some examples.
\beginOutput
i50 : A = matrix\{\{1,1,1,1,1\},\{1,2,4,5,6\}\}\\
\emptyLine
o50 = | 1 1 1 1 1 |\\
\      | 1 2 4 5 6 |\\
\emptyLine
\               2        5\\
o50 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i51 : w1 = \{1,1,1,1,1\};\\
\endOutput
\beginOutput
i52 : w2 = \{2,3,5,7,11\};\\
\endOutput
\beginOutput
i53 : b1 = transpose matrix\{\{3,9\}\}\\
\emptyLine
o53 = | 3 |\\
\      | 9 |\\
\emptyLine
\               2        1\\
o53 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i54 : b2 = transpose matrix\{\{5,16\}\}\\
\emptyLine
o54 = | 5  |\\
\      | 16 |\\
\emptyLine
\               2        1\\
o54 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i55 : IP(A, w1, b1)\\
\emptyLine
o55 = | 1 1 0 0 1 |\\
\emptyLine
\               1        5\\
o55 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i56 : IP(A, w2, b1)\\
\emptyLine
o56 = | 1 0 2 0 0 |\\
\emptyLine
\               1        5\\
o56 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i57 : IP(A, w1, b2)\\
\emptyLine
o57 = | 2 1 0 0 2 |\\
\emptyLine
\               1        5\\
o57 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i58 : IP(A, w2, b2)\\
\emptyLine
o58 = | 2 0 1 2 0 |\\
\emptyLine
\               1        5\\
o58 : Matrix ZZ  <--- ZZ\\
\endOutput

%%----------------------------------------------------------
\section{Generic Initial Ideals}

Gr\"{o}bner basis calculations and initial ideals depend heavily on
the given coordinate system.  By making a generic change of coordinates
before taking the initial ideal, we may eliminate this dependence.
This procedure also endows the resulting monomial ideal with a rich
combinatorial structure.

To describe this structure, we introduce the following definitions and
notation.  Let $S = \bbbq[x_{0}, \dotsc, x_{n}]$.  If $\sg = [g_{i,j}]
\in \GL_{n+1}(\bbbq)$ and $f \in S$, then $\sg \cdot f$ denotes the
standard action of the general linear group on $S$: $x_{i} \mapsto
\sum_{j=0}^{n} g_{i,j} x_{j}$.  For an ideal $I \subseteq S$, we
define $\sg \cdot I = \{ \sg \cdot f | f \in I \}$.  Let $B$ denote
the Borel subgroup of $\GL_{n+1}(\bbbq)$ consisting of upper
triangular matrices.  A monomial ideal $I$ is called
{\em Borel-fixed}\index{Borel-fixed}\index{ideal!Borel-fixed} if it
satisfies any of the following equivalent conditions:
\begin{enumerate}
\item[$(a)$] $\sg \cdot I = I$ for every $\sg \in B$;
\item[$(b)$] if $r$ is a generator of $I$ divisible by $x_{j}$ then
$\frac{rx_{i}}{x_{j}} \in I$ for all $i < j$;
\item[$(c)$] $\initial(\sg \cdot I) = I$ for every $\sg$ is some open
neighborhood of the identity in $B$.
\end{enumerate}
For a proof that these conditions are equivalent, see Propositon~1.25
in Green~\cite{MR99m:13040}.

In \Mtwo, the function {\tt isBorel}\indexcmd{isBorel} tests whether a monomial ideal is
Borel-fixed.
\beginOutput
i59 : S = QQ[a,b,c,d];\\
\endOutput
\beginOutput
i60 : isBorel monomialIdeal(a^2, a*b, b^2)\\
\emptyLine
o60 = true\\
\endOutput
\beginOutput
i61 : isBorel monomialIdeal(a^2, b^2)\\
\emptyLine
o61 = false\\
\endOutput
The function {\tt borel}\indexcmd{borel} generates the smallest Borel-fixed ideal
containing the given monomial ideal.
\beginOutput
i62 : borel monomialIdeal(b*c)\\
\emptyLine
\                      2        2\\
o62 = monomialIdeal (a , a*b, b , a*c, b*c)\\
\emptyLine
o62 : MonomialIdeal of S\\
\endOutput
\beginOutput
i63 : borel monomialIdeal(a,c^3)\\
\emptyLine
\                         3   2      2   3\\
o63 = monomialIdeal (a, b , b c, b*c , c )\\
\emptyLine
o63 : MonomialIdeal of S\\
\endOutput

The next theorem provides the main source of Borel-fixed ideals.
\begin{theorem}[Galligo] \label{galligo}
Fix a term order on $S = \bbbq[x_{0}, \dotsc, x_{n}]$ such that $x_{0}
> \dotsc > x_{n}$.  If $I$ is a homogeneous ideal in $S$, then there
is a Zariski open subset $U \subseteq \GL_{n+1}(\bbbq)$ such that
\begin{enumerate}
\item[$(1)$] there is a monomial ideal $J \subseteq S$ such that $J =
\initial(\sg \cdot I )$ for all $\sg \in U$;
\item[$(2)$] the ideal $J$ is Borel-fixed.
\end{enumerate}
The ideal $J$ is called the generic initial ideal\index{generic
initial ideal}\index{ideal!generic initial} of $I$.
\end{theorem}

\begin{proof}
See Theorem~1.27 in Green~\cite{MR99m:13040}. \qed
\end{proof}

The following method allows one to compute generic initial ideals.
\beginOutput
i64 : gin = method();\\
\endOutput
\beginOutput
i65 : gin Ideal := I -> (\\
\           S := ring I;\\
\           StoS := map(S, S, random(S^\{0\}, S^\{numgens S:-1\}));\\
\           monomialIdeal StoS I);\\
\endOutput
\beginOutput
i66 : gin MonomialIdeal := I -> gin ideal I;\\
\endOutput
This routine assumes that the random function generates a matrix in
the Zariski open subset $U$.  Since we are working over a field of
characteristic zero this occurs with probability one.
For example, we can determine the generic initial ideal of two generic
homogeneous polynomials of degree $p$ and $q$ in $\bbbq[a,b,c,d]$.
\beginOutput
i67 : genericForms = (p,q) -> ideal(random(p,S), random(q,S));\\
\endOutput
\beginOutput
i68 : gin genericForms(2,2)\\
\emptyLine
\                      2        3\\
o68 = monomialIdeal (a , a*b, b )\\
\emptyLine
o68 : MonomialIdeal of S\\
\endOutput
\beginOutput
i69 : gin genericForms(2,3)\\
\emptyLine
\                      2     2   4\\
o69 = monomialIdeal (a , a*b , b )\\
\emptyLine
o69 : MonomialIdeal of S\\
\endOutput
Although the generic initial ideal is Borel-fixed, some non-generic
initial ideals may also be Borel-Fixed.
\beginOutput
i70 : J = ideal(a^2, a*b+b^2, a*c)\\
\emptyLine
\              2         2\\
o70 = ideal (a , a*b + b , a*c)\\
\emptyLine
o70 : Ideal of S\\
\endOutput
\beginOutput
i71 : ginJ = gin J\\
\emptyLine
\                      2        2     2\\
o71 = monomialIdeal (a , a*b, b , a*c )\\
\emptyLine
o71 : MonomialIdeal of S\\
\endOutput
\beginOutput
i72 : inJ = monomialIdeal J\\
\emptyLine
\                      2        3        2\\
o72 = monomialIdeal (a , a*b, b , a*c, b c)\\
\emptyLine
o72 : MonomialIdeal of S\\
\endOutput
\beginOutput
i73 : isBorel inJ and isBorel ginJ\\
\emptyLine
o73 = true\\
\endOutput
Finally, we show that the generic initial ideal does depend on the
term order by computing lexicographic generic initial ideal for two
generic forms of degree $p$ and $q$ in $\bbbq[a,b,c,d]$
\beginOutput
i74 : S = QQ[a,b,c,d, MonomialOrder => Lex];\\
\endOutput
\beginOutput
i75 : gin genericForms(2,2)\\
\emptyLine
\                      2        4     2\\
o75 = monomialIdeal (a , a*b, b , a*c )\\
\emptyLine
o75 : MonomialIdeal of S\\
\endOutput
\beginOutput
i76 : gin genericForms(2,3)\\
\emptyLine
\                      2     2   6       2     6         2       4\\
o76 = monomialIdeal (a , a*b , b , a*b*c , a*c , a*b*c*d , a*b*d )\\
\emptyLine
o76 : MonomialIdeal of S\\
\endOutput
A more comprehensive treatment of generic initial ideals can be found
in Green~\cite{MR99m:13040}.  The properties of Borel-fixed ideals in
characteristic $p>0$ are discussed in Eisenbud~\cite{MR97a:13001}.

%%----------------------------------------------------------
\subsection*{Example: Connectedness of the Hilbert Scheme}

Generic initial ideals are a powerful tool for studying the structure
of the Hilbert scheme\index{Hilbert scheme}.  Intuitively, the Hilbert
scheme $\Hilb^{\, p(t)}(\bbbp^{n})$ parameterizes subschemes $X
\subseteq \bbbp^{n}$ with Hilbert polynomial $p(t)$.  For an
introduction to Hilbert schemes see Harris and
Morrison~\cite{MR99g:14031}.  The construction of the Hilbert scheme $\Hilb^{\,
p(t)}(\bbbp^{n})$ can be found in Grothendieck's original
article~\cite{MR26:3566} or Altman and Kleiman~\cite{MR81f:14025a}.
While much is known about specific Hilbert schemes, the general
structure remain largely a mystery.  In particular, the component
structure --- the number of irreducible components, their dimensions,
how they intersect and what subschemes they parameterize --- is not
well understood.

Reeves~\cite{MR97g:14003} uses generic initial ideals to establish the
most important theorem to date on the component structure.  The
incidence graph\index{Hilbert scheme!incidence graph} of $\Hilb^{\,
p(t)}(\bbbp^{n})$ is defined as follows: to each irreducible component
we assign a vertex and we connect two vertices if the corresponding
components intersect.  Reeves~\cite{MR97g:14003} proves that the
distance (the number of edges in the shortest path) between any two
vertices in the incidence graph of $\Hilb^{\, p(t)}(\bbbp^{n})$ is at
most $2 \deg p(t)+2$.  Her proof can be divided into three major
steps.

{\em Step I: connect an arbitrary ideal to a Borel-fixed ideal.}
Passing to an initial ideal corresponds to taking the limit in a flat
family, in other words a path on the Hilbert scheme; see Theorem 15.17
in Eisenbud~\cite{MR97a:13001}.  Thus, Theorem~\ref{galligo} shows
that generic initial ideals\index{generic initial
ideal}\index{ideal!generic initial} connect arbitrary
ideals to Borel-fixed ideals.

{\em Step II: connect Borel-fixed ideals by projection.}  For a
homogeneous ideal $I \subseteq S = \bbbq[x_{0}, \dotsc, x_{n}]$, let
$\pi(I)$ denote the ideal obtained by setting $x_{n}=1$ and
$x_{n-1}=1$ in $I$.  With this notation, we have

\begin{theorem}
If $J$ is a Borel-fixed ideal, then the set of Borel-fixed ideals $I$,
with Hilbert polynomial $p(t)$ and $\pi(I) = J$, consists of ideals
defining subschemes of $\bbbp^{n}$ which all lie on a single component
of $\Hilb^{\, p(t)}(\bbbp^{n})$.
\end{theorem}

\begin{proof}
See Theorem~6 in Reeves~\cite{MR97g:14003}. \qed
\end{proof}

\noindent This gives an easy method for partitioning Borel-fixed
ideals into classes, each of which must lie in a single component.

{\em Step III: connect Borel-fixed ideals by distraction.}  Given a
Borel-fixed ideal, we produce a new ideal via a two-step process
called distraction\index{distraction}.  First, one polarizes the
Borel-fixed ideal.  The polarization\index{polarization} of a monomial
ideal $I \subset S$ is defined as:
\[
\left\langle \prod_{i=0}^{n}\prod_{j=1}^{\alpha_{i}} z_{i,j} : \text{
where $x_{0}^{\alpha_{0}}\dotsb x_{n}^{\alpha_{n}}$ is a minimal
generator of $I$} \right\rangle \, .
\]
One then pulls the result back to an ideal in the original variables
by taking a linear section of the polarization.  Theorem~4.10 in
Hartshorne~\cite{MR35:4232} shows that the distraction is connected to
the original Borel-fixed ideal.  Now, taking the lexicographic generic
initial ideal of the distraction yields a second Borel-fixed ideal.
Reeves~\cite{MR97g:14003} proves that repeating this process, at most
$\deg p(t) + 1$ times, one arrives at a distinguished component of
$\Hilb^{\, p(t)}(\bbbp^{n})$ called the lexicographic component.  For
more information on the lexicographic component see Reeves and
Stillman~\cite{MR98m:14003}.

We can implement these operations in \Mtwo as follows:
\beginOutput
i77 : projection = I -> (\\
\           S := ring I;\\
\           n := numgens S;\\
\           X := gens S;\\
\           monomialIdeal mingens substitute(ideal I, \\
\                \{X#(n-2) => 1, X#(n-1) => 1\}));\\
\endOutput
\beginOutput
i78 : polarization = I -> (\\
\           n := numgens ring I;\\
\           u := apply(numgens I, i -> first exponents I_i);\\
\           I.lcm = max {\char`\\} transpose u;\\
\           Z := flatten apply(n, i -> apply(I.lcm#i, j -> z_\{i,j\}));\\
\           R := QQ(monoid[Z]);\\
\           Z = gens R;\\
\           p := apply(n, i -> sum((I.lcm)_\{0..i-1\}));\\
\           monomialIdeal apply(u, e -> product apply(n, i -> \\
\                     product(toList(0..e#i-1), j -> Z#(p#i+j)))));\\
\endOutput
\beginOutput
i79 : distraction = I -> (\\
\           S := ring I;\\
\           n := numgens S;\\
\           X := gens S;\\
\           J := polarization I;\\
\           W := flatten apply(n, i -> flatten apply(I.lcm#i, \\
\                     j -> X#i));\\
\           section := map(S, ring J, apply(W, r -> r - \\
\                     random(500)*X#(n-2) - random(500)*X#(n-1)));     \\
\           section ideal J);\\
\endOutput
For example, we have
\beginOutput
i80 : S = QQ[x_0 .. x_4, MonomialOrder => GLex];\\
\endOutput
\beginOutput
i81 : I = monomialIdeal(x_0^2, x_0*x_1^2*x_3, x_1^3*x_4)\\
\emptyLine
\                      2     2     3\\
o81 = monomialIdeal (x , x x x , x x )\\
\                      0   0 1 3   1 4\\
\emptyLine
o81 : MonomialIdeal of S\\
\endOutput
\beginOutput
i82 : projection I\\
\emptyLine
\                      2     2   3\\
o82 = monomialIdeal (x , x x , x )\\
\                      0   0 1   1\\
\emptyLine
o82 : MonomialIdeal of S\\
\endOutput
\beginOutput
i83 : polarization I\\
\emptyLine
o83 = monomialIdeal (z      z      , z      z      z      z      , z   $\cdot\cdot\cdot$\\
\                      \{0, 0\} \{0, 1\}   \{0, 0\} \{1, 0\} \{1, 1\} \{3, 0\}   \{1 $\cdot\cdot\cdot$\\
\emptyLine
o83 : MonomialIdeal of QQ [z      , z      , z      , z      , z       $\cdot\cdot\cdot$\\
\                            \{0, 0\}   \{0, 1\}   \{1, 0\}   \{1, 1\}   \{1, 2\} $\cdot\cdot\cdot$\\
\endOutput
\beginOutput
i84 : distraction I\\
\emptyLine
\              2                             2                     2    $\cdot\cdot\cdot$\\
o84 = ideal (x  - 398x x  - 584x x  + 36001x  + 92816x x  + 47239x , - $\cdot\cdot\cdot$\\
\              0       0 3       0 4         3         3 4         4    $\cdot\cdot\cdot$\\
\emptyLine
o84 : Ideal of S\\
\endOutput

To illustrate Reeves' method, we show that the incidence graph of the
Hilbert scheme $\Hilb^{4t+1}(\bbbp^{4})$ has diameter at most $2$.
Note that the rational quartic curve\index{rational quartic curve} in
$\bbbp^{4}$ has Hilbert polynomial $4t+1$.
\beginOutput
i85 : m =  matrix table(\{0,1,2\}, \{0,1,2\}, (i,j) -> (gens S)#(i+j))\\
\emptyLine
o85 = | x_0 x_1 x_2 |\\
\      | x_1 x_2 x_3 |\\
\      | x_2 x_3 x_4 |\\
\emptyLine
\              3       3\\
o85 : Matrix S  <--- S\\
\endOutput
\beginOutput
i86 : rationalQuartic = minors(2, m);\\
\emptyLine
o86 : Ideal of S\\
\endOutput
\beginOutput
i87 : H = hilbertPolynomial(S/rationalQuartic);\\
\endOutput
\beginOutput
i88 : hilbertPolynomial(S/rationalQuartic, Projective => false)\\
\emptyLine
o88 = 4\$i + 1\\
\emptyLine
o88 : QQ [\$i]\\
\endOutput
There are $12$ Borel-fixed ideals with Hilbert polynomial $4t+1$; see
Example~1 in Reeves~\cite{MR97g:14003}.
\beginOutput
i89 : L = \{monomialIdeal(x_0^2, x_0*x_1, x_0*x_2, x_1^2, x_1*x_2, x_2^ $\cdot\cdot\cdot$\\
\endOutput
\beginOutput
i90 : scan(#L, i -> << endl << i+1 << " : " << L#i << endl);\\
\emptyLine
\                    2         2               2\\
1 : monomialIdeal (x , x x , x , x x , x x , x )\\
\                    0   0 1   1   0 2   1 2   2\\
\emptyLine
\                    2         2               3\\
2 : monomialIdeal (x , x x , x , x x , x x , x , x x )\\
\                    0   0 1   1   0 2   1 2   2   0 3\\
\emptyLine
\                        2     2   3\\
3 : monomialIdeal (x , x , x x , x , x x x )\\
\                    0   1   1 2   2   1 2 3\\
\emptyLine
\                        2         4   3\\
4 : monomialIdeal (x , x , x x , x , x x )\\
\                    0   1   1 2   2   2 3\\
\emptyLine
\                            5   4 3\\
5 : monomialIdeal (x , x , x , x x )\\
\                    0   1   2   2 3\\
\emptyLine
\                        2         5         4 2\\
6 : monomialIdeal (x , x , x x , x , x x , x x )\\
\                    0   1   1 2   2   1 3   2 3\\
\emptyLine
\                    2         2               5               4\\
7 : monomialIdeal (x , x x , x , x x , x x , x , x x , x x , x x )\\
\                    0   0 1   1   0 2   1 2   2   0 3   1 3   2 3\\
\emptyLine
\                        2         5   4       2\\
8 : monomialIdeal (x , x , x x , x , x x , x x )\\
\                    0   1   1 2   2   2 3   1 3\\
\emptyLine
\                    2         2               4           2\\
9 : monomialIdeal (x , x x , x , x x , x x , x , x x , x x )\\
\                    0   0 1   1   0 2   1 2   2   0 3   1 3\\
\emptyLine
\                         2     2   4             2\\
10 : monomialIdeal (x , x , x x , x , x x x , x x )\\
\                     0   1   1 2   2   1 2 3   1 3\\
\emptyLine
\                         2         4     3\\
11 : monomialIdeal (x , x , x x , x , x x )\\
\                     0   1   1 2   2   1 3\\
\emptyLine
\                             6   5     4 2\\
12 : monomialIdeal (x , x , x , x x , x x )\\
\                     0   1   2   2 3   2 3\\
\endOutput
\beginOutput
i91 : all(L, I -> isBorel I and hilbertPolynomial(S/I) == H)\\
\emptyLine
o91 = true\\
\endOutput
The projection operation partitions the list {\tt L} into $3$ classes:
\beginOutput
i92 : class1 = projection L#0\\
\emptyLine
\                      2         2               2\\
o92 = monomialIdeal (x , x x , x , x x , x x , x )\\
\                      0   0 1   1   0 2   1 2   2\\
\emptyLine
o92 : MonomialIdeal of S\\
\endOutput
\beginOutput
i93 : class2 = projection L#1\\
\emptyLine
\                          2         3\\
o93 = monomialIdeal (x , x , x x , x )\\
\                      0   1   1 2   2\\
\emptyLine
o93 : MonomialIdeal of S\\
\endOutput
\beginOutput
i94 : class3 = projection L#4\\
\emptyLine
\                              4\\
o94 = monomialIdeal (x , x , x )\\
\                      0   1   2\\
\emptyLine
o94 : MonomialIdeal of S\\
\endOutput
\beginOutput
i95 : all(1..3, i -> projection L#i == class2)\\
\emptyLine
o95 = true\\
\endOutput
\beginOutput
i96 : all(4..11, i -> projection L#i == class3)\\
\emptyLine
o96 = true\\
\endOutput
Finally, we use the distraction to connect the classes.
\beginOutput
i97 : all(L, I -> I == monomialIdeal distraction I)\\
\emptyLine
o97 = true\\
\endOutput
\beginOutput
i98 : all(0..3, i -> projection gin distraction L#i == class3)\\
\emptyLine
o98 = true\\
\endOutput
Therefore, the components corresponding to {\tt class1} and {\tt
class2} intersect the one corresponding to {\tt class3}.  Note that
{\tt class3} corresponds to the lexicographic component.

%%----------------------------------------------------------
\section{The Chain Property}

Ho\c{s}ten and Thomas~\cite{MR2000b:13037} recently established that
the initial ideals of a toric ideal have an interesting combinatorial
structure called the chain property.  This structure is on the poset
of associated primes where the partial order is given by inclusion.
Since a monomial ideal $I \subset S = \bbbq[x_{1}, \dotsc, x_{n}]$ is
prime if and only if it is generated by a subset of the variables $\{
x_{1}, \dotsc, x_{n}\}$, the poset of associated primes of $I$ is
contained in the power set of the variables.  We say that a monomial
ideal $I$ has the chain property\index{chain property} if the
following condition holds:
\[
\text{\begin{minipage}[t]{300pt}
For any embedded prime $P_{F} = \langle x_{i} : x_{i} \not\in F
\rangle$ of $I$, there exists an associated prime $P_{G} \subset
P_{F}$ such that $|G| = |F|-1$.
\end{minipage}}
\]
In other words, there is a saturated chain from every embedded prime
to some minimal prime.
Experimental evidence suggests that, in fact, most initial ideals
of prime ideals satisfy this saturated chain condition.
Because
of ubiquity and simplicity of this condition, we are interested in
understanding which classes of initial ideals (or more generally
monomial ideals) have the chain property.

More recently, Miller, Sturmfels and Yanagawa~\cite{MR1769661}
provided a large class of monomial ideals with the chain property.  A
monomial ideal $I$ is called generic\index{generic monomial ideal}
when the following condition holds: if two distinct minimal generators
$r_{1}$ and $r_{2}$ of $I$ have the same positive degree in some
variable $x_{i}$, there is a third generator $r_{3}$ which strictly
divides the least common multiple of $r_{1}$ and $r_{2}$.  In
particular, if no two distinct minimal generators have the same
positive degree in any variable, then the monomial ideal is generic.
Theorem~2.2 in Miller, Sturmfels and Yanagawa~\cite{MR1769661} shows
that generic monomial ideals have the chain property.

%%----------------------------------------------------------
\subsection*{Examples and Counterexamples}

In this final section, we illustrate how to use \Mtwo for further
experimentation and investigation of the chain property.  The
following function determines whether a monomial ideal has the chain
property:
\beginOutput
i99 : hasChainProperty = I -> (\\
\           L := ass I;\\
\           radI := radical I;\\
\           all(L, P -> radI : (radI : P) == P or (\\
\                     gensP := first entries gens P;\\
\                     all(gensP, r -> (\\
\                               Q := monomialIdeal delete(r, gensP);\\
\                               I : (I : Q) == Q)))));\\
\endOutput
Using {\tt hasChainProperty}, we examine the initial ideals of four
interesting classes of ideals related to toric ideals.

\subsubsection*{An Initial Ideal of a Toric Ideal}  As mentioned above, Ho\c{s}ten
and Thomas proved that any initial ideal of a toric ideal satisfies
the saturated chain condition.  The following example demonstrates this
phenomenon.  Consider the matrix $A$:
\beginOutput
i100 : A = matrix\{\{1,1,1,1,1,1,1\}, \{2,0,0,0,1,0,0\}, \{0,2,0,0,0,1,0\}, \{ $\cdot\cdot\cdot$\\
\emptyLine
o100 = | 1 1 1 1 1 1 1 |\\
\       | 2 0 0 0 1 0 0 |\\
\       | 0 2 0 0 0 1 0 |\\
\       | 2 2 0 2 1 1 1 |\\
\emptyLine
\                4        7\\
o100 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i101 : IA = toricIdeal(A, \{1,1,1,1,1,1,1\})\\
\emptyLine
\                      2          2          2\\
o101 = ideal (x x  - x , x x  - x , x x  - x )\\
\               3 4    7   2 3    6   1 3    5\\
\emptyLine
o101 : Ideal of S\\
\endOutput
\beginOutput
i102 : inIA = monomialIdeal IA\\
\emptyLine
\                                           2     2     2\\
o102 = monomialIdeal (x x , x x , x x , x x , x x , x x )\\
\                       1 3   2 3   3 4   2 5   4 5   4 6\\
\emptyLine
o102 : MonomialIdeal of S\\
\endOutput
\beginOutput
i103 : hasChainProperty inIA\\
\emptyLine
o103 = true\\
\endOutput

\subsubsection*{An Initial Ideal of a Prime Ideal}  Since toric ideals are
prime, one naturally asks if the initial ideal of any prime ideal has
the chain property.  By modifying the previous example, we can show
that this is not the case.  In particular, making the linear change of
coordinates by $x_{4} \mapsto x_{3}-x_{4}$, we obtain a new prime
ideal $J$.
\beginOutput
i104 : StoS = map(S, S, \{x_1, x_2, x_3, x_3 - x_4, x_5, x_6, x_7\});\\
\emptyLine
o104 : RingMap S <--- S\\
\endOutput
\beginOutput
i105 : J = StoS IA\\
\emptyLine
\               2           2          2          2\\
o105 = ideal (x  - x x  - x , x x  - x , x x  - x )\\
\               3    3 4    7   2 3    6   1 3    5\\
\emptyLine
o105 : Ideal of S\\
\endOutput
Taking the initial ideal with respect to the reverse lexicographic
term order (the default order), we have
\beginOutput
i106 : inJ = monomialIdeal J\\
\emptyLine
\                                   2     2     2       2     2       2 $\cdot\cdot\cdot$\\
o106 = monomialIdeal (x x , x x , x , x x , x x , x x x , x x , x x x  $\cdot\cdot\cdot$\\
\                       1 3   2 3   3   2 5   3 5   1 4 5   3 6   1 4 6 $\cdot\cdot\cdot$\\
\emptyLine
o106 : MonomialIdeal of S\\
\endOutput
\beginOutput
i107 : hasChainProperty inJ\\
\emptyLine
o107 = false\\
\endOutput

\subsubsection*{An $A$-graded Monomial Ideal}  Let $A$ be a $d \times n$ matrix
of nonnegative integers and let $\mathbf{a}_{i}$ denote the $i$-th
column of $A$.  Consider the polynomial ring $S = \bbbq[x_{1}, \dotsc,
x_{n}]$ with the $\bbbz^{d}$-grading defined by $\deg x_{i} =
\mathbf{a}_{i}$.  An ideal $I \subset \bbbq[x_{1}, \dotsc, x_{n}]$ is
called $A$-graded\index{ideal!$A$-graded} provided it is homogeneous with
respect to the $A$-grading and
\[
\dim_{\bbbq} \left( \frac{S}{I} \right)_{\mathbf{b}} = \begin{cases} 1
& \text{if $\mathbf{b} \in \bbbn A$} \\ 0 & \text{otherwise}
\end{cases}
\]
for all $\mathbf{b} \in \bbbn^{d}$.  Remark~10.1 in
Sturmfels~\cite{MR97b:13034} shows that the initial ideal of the toric
ideal $I_{A}$ is $A$-graded.  Altmann~\cite{Altmann} shows that when
$A$ has rank $2$ every $A$-graded monomial ideal has the chain
property.  However, Altmann~\cite{Altmann} also provides a
counterexample when $A$ has rank $3$.  We can verify his example in
\Mtwo as follows:
\beginOutput
i108 : A = matrix\{\{2,0,0,1,0,0,2,1,1,3,2,2,2,3,3,3\},\\
\                  \{0,2,0,0,1,0,1,2,1,2,3,2,3,2,3,3\},\\
\                  \{0,0,2,0,0,1,1,1,2,2,2,3,3,3,2,3\}\};\\
\emptyLine
\                3        16\\
o108 : Matrix ZZ  <--- ZZ\\
\endOutput
In \Mtwo, the first entry in degree vector of each variable must be
positive.  Hence, we append to A the sum of its rows to get a matrix whose
columns will serve as the degrees of the variables.
\beginOutput
i109 : D = A^\{0\}+A^\{1\}+A^\{2\} || A\\
\emptyLine
o109 = | 2 2 2 1 1 1 4 4 4 7 7 7 8 8 8 9 |\\
\       | 2 0 0 1 0 0 2 1 1 3 2 2 2 3 3 3 |\\
\       | 0 2 0 0 1 0 1 2 1 2 3 2 3 2 3 3 |\\
\       | 0 0 2 0 0 1 1 1 2 2 2 3 3 3 2 3 |\\
\emptyLine
\                4        16\\
o109 : Matrix ZZ  <--- ZZ\\
\endOutput
\beginOutput
i110 : D = entries transpose D;\\
\endOutput
\beginOutput
i111 : S = QQ[vars(0..15), Degrees => D, MonomialSize => 16];\\
\endOutput
\beginOutput
i112 : I = monomialIdeal(d*j, d*k, d*l, d*m, d*n, d*o, d*p, e*j, e*k,\\
\           e*l, e*m, e*n, e*o, e*p, f*j, f*k, f*l, f*m, f*n, f*o, f*p,\\
\           g*j, g*k, g*l, g*m, g*n, g*o, g*p, h*j, h*k, h*l, h*m, h*n,\\
\           h*o, h*p, i*j, i*k, i*l, i*m, i*n, i*o, i*p, g^2, g*h, g*i,\\
\           h^2, h*i, i^2, j^2, j*k, j*l, j*m, j*n, j*o, j*p, k^2, k*l,\\
\           k*m, k*n, k*o, k*p, l^2, l*m, l*n, l*o, l*p, m^2, m*n, m*o,\\
\           m*p, n^2, n*o, n*p, o^2, o*p, p^2, d^2, e^2, f^2, d*h, e*i,\\
\           f*g, f*d*i, d*e*g, e*f*h, c*d*g, a*e*h, b*f*i, c*e*g, \\
\           a*f*h, b*d*i, c*d*e, a*e*f, b*f*d, c*b*d, a*c*e, b*a*f, \\
\           c*b*g, a*c*h, b*a*i);\\
\emptyLine
o112 : MonomialIdeal of S\\
\endOutput
To help convince you that $I$ is an $A$-graded ideal, we compute the
$\dim_{\bbbq} \left( \frac{S}{I} \right)_{\mathbf{a}_{i}}$ for $1 \leq
i \leq 16$.
\beginOutput
i113 : apply(D, d -> rank source basis(d, (S^1)/ ideal I))\\
\emptyLine
o113 = \{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\}\\
\emptyLine
o113 : List\\
\endOutput
Finally, we check the chain property.
\beginOutput
i114 : hasChainProperty I\\
\emptyLine
o114 = false\\
\endOutput

\subsubsection*{The Vertex Ideal}  Lastly, we consider a different family of
monomials ideals arising from toric ideals.  The vertex
ideal\index{vertex ideal} $V_{A}$ is defined as intersection all the
monomial initial ideals of the toric ideal $I_{A}$.  Although there
are (in general) infinitely many distinct term orders on a polynomial
ring, an ideal has only finitely many initial ideals; see Theorem~1.2
in Sturmfels~\cite{MR97b:13034}.  In particular, the above
intersection is finite.  Vertex ideals were introduced and studied by
Ho{\c{s}}ten and Maclagan~\cite{Hosten-Maclagan}.  However, the
question ``Does the vertex ideal $V_A$ have the chain property?''
remains open.

% Local Variables:
% mode: latex
% mode: reftex
% tex-main-file: "chapter-wrapper.tex"
% reftex-keep-temporary-buffers: t
% reftex-use-external-file-finders: t
% reftex-external-file-finders: (("tex" . "make FILE=%f find-tex") ("bib" . "make FILE=%f find-bib"))
% End:


\section{Background}
\label{sec:background}
% This will give all the background of the project including

% Background of the problem to be solved.
% Existing solutions/approaches to the problem, if any exist, and a comparison with the solution produced in the project.
% Reading and research done to understand existing approaches, acquire the necessary information and skills to carry out the project.
% A clear statement of the project requirements.
% References to all sources consulted are expected.

This section recalls some notions used in the project with relevant researches.
The notion of \emph{Bisimulation} is introduced as the target logic feature that needs to be learned.
The notion of \emph{Artificial Neural Networks} is introduced as the object that studied in the project.

%==================

\subsection{Bisimulation}\label{sec:bac:bis}
Bisimulation is an important concept.
It has been introduced in many different fields and plays a very important role.
In modal logic, it was discovered when researches started to study the expressiveness for the logic, in 1970 \cite{Sangiorgi2009}.
Then that was developed by Van Benthem \cite{VanBenthem1976} who came up with \emph{p-relation} that define a symmetric directional relationship between models, i.e. bisimulation.
In computer science, the concept was introduced by Milner while studying concurrency theory \cite{Milner1990}.
The notation was developed to test the equivalence of processes in Calculus of Communication System \cite{Park1981}.
In the set Theory, it was used to determine if the equal objects can be identified with certain model \cite{Sangiorgi2009}.
Also, in formal verification, while describing a system, bisimulation was used to minimise the space of states \cite{Roscoe1994}.

Some of the past solutions for the bisimulation problem is from the perspective of the set theory.
One approach to this problem was studied by Kanellakis and Smolka while studying the equivalence testing of the calculus of communicating systems expression \cite{Milner1980}.
Originally they designed the algorithm to test the equivalence called congruence of finite state processes in CCS \cite{Paige1987}.
The algorithm was given with $O(mn)$ in time and $O(m+n)$ in space.
Another approach was given by Paige and Tarjan \cite{Paige1987}.
They converted the problem as relational coarsest partition problem.
By refining with respect to old blocks rather than current blocks, they reduce the running time into $O(m\log n)$.
Both of them did not solve the problem directly.
By using a group of reasoning on different perspectives, they convert the problem into a clear and easier problem.
In this project, the learning algorithm will base on the work of \cite{Paige1987}.

For the first part of the project, the baseline algorithm will use the algorithm based on the set theory.
In the algorithm, one logical is regarded as a \emph{non-well-founded set}.
``Such a set has an infinite descending membership sequence" i.e. the elements of the set recursively consisting itself \cite{Aczel}.
Mathematically, in this part the multi-directed graph (logic structure) $G = \langle N, E \rangle$ is regarded as a group of sets where each set represents a \emph{accessible pointed graphs}.
Edges resents membership, that is edge $\langle m, n \rangle$ (also $m \rightarrow n$) means that node $m$ has node $n$ as a element (also $n \in m$).
Then naturally, these sets will be \emph{non-well-founded sets}.
Thus extensionality axiom (two objects are equal if and only if they contain the same elements) cannot be used to define the bisimulation, since these sets may lead to cyclic arguments.
In this project, the baseline algorithm will base on the definition from \cite{Dovier2004}.
\begin{defin}
Given two graphs $G_1=\langle N_1, E_1 \rangle$ and $G_2=\langle N_2, E_2 \rangle$, a bisimulation between $G_1$ and $G_2$ is a relation $b\subseteq N_1 \times N_2$ such that
\renewcommand{\labelenumi}{\arabic{enumi})}
\begin{enumerate}
    \item $u_1b u_2 \wedge \langle u_1, v_1 \rangle \in E_1 \Rightarrow \exists v_2 \in N_2(v_1b v_2 \wedge \langle u_2, v_2 \rangle \in E_2)$
    \item $u_1b u_2 \wedge \langle u_2, v_2 \rangle \in E_2 \Rightarrow \exists v_2 \in N_2(v_1b v_2 \wedge \langle u_1, v_1 \rangle \in E_1)$
\end{enumerate}
\end{defin}
Also, for understanding purpose, a more common definition from the perspective of Kripke model \cite{Glabbeek2011} is given.
Here the multi-directed graph (logic structure) are labelled transition system (LTS), denoted as $(S, \rightarrow, \models)$ with the set of actions $A$ and the set of predicates $P$. $S$ stands for a class of states, $\rightarrow$ stands for a collection of binary relations $\stackrel{a}{\rightarrow}\subseteq S\times S$ where $a \in A$.
And $\models \subseteq S \times P$, where $s\models p$ indicate that predicate $p \in P$ holds in state $s \in S$ \cite{Glabbeek2011}. Definition in this prospect is given below \cite{Glabbeek2011}.
\begin{defin}
Let $(S, \rightarrow, \models)$ be an LTS over $A$ and $P$. A bisimulation is a binary relation $R \subseteq S \times S$, satisfying:
\renewcommand{\labelenumi}{\arabic{enumi})}
\begin{enumerate}
    \item if $sRt$, then $s \models p \leftrightarrow t \models p$ for all $p\in P$.
    \item if $sRt$ and $s \stackrel{a}{\rightarrow}s'$ with $a \in A$, then there exists a $t'$ with $t \stackrel{a}{\rightarrow} t'$ and $s'Rt'$
    \item if $sRt$ and $t \stackrel{a}{\rightarrow} t'$ with $a\in A$, then there exists an $s'$ with $s \stackrel{a}{\rightarrow}s'$ and $s'Rt'$
\end{enumerate}
\end{defin}

%======================

\subsection{Artificial Neural Networks (ANNs)}
For the second part of the project, the capability of the MLPs for catching the bisimulation equivalence is explored.
Here MLPs is chosen as the representative of ANNs as a kind for machine learning methods.
Generally, machine learning can be defined as an experience-base computational method \cite{Mohri2013}.
Mohri pointed out that machine learning is mainly used in the classification, regression, ranking, clustering and dimensionality reduction \cite{Mohri2013}.
Among all the machine learning methods ANN is a unique architecture which is good at the pattern related problems \cite{Dayhoff1990}.
This architecture is inspired by the neural cell in the brain.
By simulate neural cell, a neural network is prospected to learn from experience also understand the logic concepts.
In 1943, McCulloch and Pitts carried out the first neural network, namely the McCulloch-Pitts Neuron \cite{Dayhoff1990}.
It is a binary discrete-time element with excitatory, that comes to the perception which can learn the patterns through supervised learning.
And for multilayer perceptron (MLP), it is a feed forward artificial neural network.
A MLP has an input layer, an output layer and at least one hidden layer \cite{rosenblatt1961principles} (See Fiture \ref{fig:mlp}).
More importantly, most ANNs are developed base on the MLP.

\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\textwidth]{img/eg_mlp.pdf}
    \caption{Typical MLP}
    \label{fig:mlp}
\end{figure}

While research on logic and ANN has been studied.
Logic or symbolic system is more expressive and more readable for human.
Learning base on a symbolic system has less dependence on data.
While commonly, the neural network is known as a less formal system short at human reasoning.
Thus, neuro-symbolic integration is growing rapidly.
It has been shown that feedforward connectionist networks are able to compute certain semantics operators in positional logic programs and approximate them in first-order logic \cite{HITZLER2004245}.
Also, there are scholars constructed recurrent connectionist networks that can approximate logic program and its semantics \cite{holldobler1999approximating, Holldobler91towardsa}.
Further, for the logic relation, a system PAN who accept symbolic input as the condition of the logical rule is developed \cite{guillame2010first}.
There are also research investigates the neural network approach for the first-order abductive inference\cite{Ray_aneural}.

However, this project will focus on MLP and bisimulation only.
Because MLP is the most typical neural network and is part of many neural networks.
By study, the capability, the compute ability of MLPs with certain depth will be evaluated.

% TODO: activation function

% \subsection{Library Used}
% TODO
% \subsection{Cloud Computing}
% TODO


% ==============================================================================
%
%                 T H E O R E T I C A L   B A C K G R O U N D
%
% ==============================================================================
\chapter{Theoretical Background} % ------------------------------------------- %
\label{ch:app:theoretical_background}
% ---------------------------------------------------------------------------- %

This  chapter  contains  some  supplementary information  on  the  theoretical
background behind  this project. For those  who wish to better  understand the
internal  workings of  a CIC  filter, the first section  details exactly  what
happens inside a CIC filter for a very simple example. Simulink files are also
provided for further  study. The second section contains  tabulated values for
CIC filter design taken from~\cite{1163535}

\section{Internal Behavior of a CIC Filter} % <<< ---------------------------- %
\label{sec:app:cic_simu}
% ---------------------------------------------------------------------------- %

This  section presents  an example  for  a very  simple CIC  filter to  better
understand  its  internal  workings. For  verification,  the  filter  is  also
implemented in a Simulink model and simulated.

In the interest of simplicity, we choose  a filter with a decimation rate $R =
2$, a differential delay $M=1$ and $N=1$ stages. The corresponding topology is
shown in Figure~\ref{fig:cic_simu:topo}; Figure~\ref{fig:cic_simu:freqz} shows
the magnitude frequency  response of the filter. As can be  clearly seen, this
filter would be of very limited  use in practice. However, for the purposes of
this example, we  feed a DC  signal (a constant) into the  filter, so the
only thing  of importance is  the filter's DC  gain (which is  \SI{6}{\dB}, or
\num{2}).

Lastly,   we   restrict   numerical   accuracy  to   three   bits   in   two's
complement;  the  entire  range  of  representable  values  can  be  found  in
Figure~\ref{fig:cic_simu:twos_complement_circle}. This  limits  the number  of
steps  which need  to  be calculated  to  gain the  desired  insight into  the
filter's mathematical mechanics.

\begin{figure}
    \centering
    \input{images/cicSimu/cicTopo.tikz}
    \caption[Topology of Example Filter]{Topology of the CIC filter for this example}
    \label{fig:cic_simu:topo}
\end{figure}

\begin{figure}
    \centering
    \input{images/cicSimu/cic1.tikz}
    \caption[Frequency Respose of Example CIC Filter]{%
        Frequency response of a CIC  filter with $N=1$, $M=1$, $R=2$. Note the
        DC gain of \num{2}.%
    }
    \label{fig:cic_simu:freqz}
\end{figure}

The  state  of  the  filter  can  be  calculated  by  the  formulas  given  in
Equations~\ref{eq:cic_simu:INT} and \ref{eq:cic_simu:OUT}:
\begin{align}
    N             & = 1 \quad M = 1 \quad R=2\nonumber\\
    OUT_\mathrm{INT}[n]  & = IN_\mathrm{COMB}[n] = IN[n]        + OUT[n-1]
    \label{eq:cic_simu:INT} \\
    OUT_\mathrm{COMB}[n] & = IN_\mathrm{COMB}[n] - IN_\mathrm{COMB}[n-R\cdot M]
    \nonumber\\
                  & = OUT_\mathrm{INT}[n] - OUT_\mathrm{INT}[n-2]
    \label{eq:cic_simu:OUT}
\end{align}

The  input  of the  filter  shall  be a  constant  of  $1$, starting  at  time
zero. Once this  input is  applied to  the system,  the integrator  stage will
begin  to  accumulate  the  constant. Given  an  unlimited  number  of  digits
(bits),  the integrator  would in  theory reach  infinity if  it kept  running
forever. In practice, however, it wraps around once it has reached its maximum
representable value  (\code{011}~$ =  3$) and begins  counting from  its lower
numerical limit  (\code{100}~$=-4$) again. This cycle keeps  repeating as long
as the filter is running.

The  ingenuity of  the  CIC filter  lies  in exploiting  the  fact that  this
wraparound is irrelevant to the  comb stage. Whether the comb stage calculates
the difference between  an integrator's value whose precision  is unbounded or
whether it calculates the difference between two values which have potentially
been  wrapped  is  without  consequence.

As a  demonstration of this effect,  we shall examine the  computation step of
cycle $n = 4$  from Table~\ref{tab:cic_simu:cic_filter_states} (which contains
the  entire filter's  state for  15 steps). At  this point,  the state  of the
filter's output is  as follows (represented in three-bit  two's complement and
decimal):
\begin{align}
    OUT_\mathrm{COMB}[4]_\mathrm{b} &= OUT_{INT}[4] - OUT_{INT}[2]     \nonumber\\
                             &= 101_\mathrm{b} - 011_\mathrm{b} \nonumber\\
                             &= 010_\mathrm{b}
    \label{eq:cic_simu:stage4:binary} \\
    OUT_\mathrm{COMB}[4]_\mathrm{d} &= -3_\mathrm{d} - 3_\mathrm{d}    \nonumber\\
                             &= -6_\mathrm{d}
    \label{eq:cic_simu:stage4:decimal:bounded}
\end{align}
Obviously,   the  decimal   and   binary  results   do   not  match. This   is
where   the  wraparound   comes   into   play,  for   which   we  shall   look
at  Figure~\ref{fig:cic_simu:twos_complement_circle}. The  figure  presents  a
circular  arrangement  for   all  numbers  in  two's   complement  with  three
digits  precision.   In  that  arrangement,  addition  of  a  positive  number
corresponds to  moving clockwise  through the circle,  while subtraction  of a
positive number means moving  counterclockwise. Doing this for the calculation
of  Equation~\ref{eq:cic_simu:stage4:decimal:bounded},  we  find  that  moving
by  three  in  the  counterclockwise   direction  lands  us  at  $2$,  exactly
as   Equation~\ref{eq:cic_simu:stage4:binary}  demands. The   computation  has
\emph{wrapped around} its boundary ($-4$).

What     is     left    to     verify     is     that    the     result     of
Equation~\ref{eq:cic_simu:stage4:binary} is indeed the correct result, i.e. if
an  unbounded integrator  and comb  would have  yielded the  same outcome. And
indeed, they would have:
\begin{equation}
    \label{eq:cic_simu:stage4:decimal:unbounded}
    OUT_\mathrm{COMB}[6] = 7 - 5 = 2
\end{equation}

\begin{figure}
    \centering
    \input{images/cicSimu/twosComplement.tikz}
    \caption[Two's Complement Circle]{%
        Subtracting  $3$  from $-3$  in  two's  complement with  three  digits
        precision,  represented on  a  circle. Addition of  a positive  number
        corresponds  to moving  clockwise,  subtraction of  a positive  number
        corresponds to moving counterclockwise.%
    }
    \label{fig:cic_simu:twos_complement_circle}
\end{figure}

\begin{table}
    \centering
    \caption[CIC Filter Example: States for 16 Cycles]{%
        Binary and  decimal values  for the  different filter  elements during
        various  stages  of the  filtering  process. As  expected due  to  the
        filter's  DC gain  of \num{2},  its output  is \num{2}. The  two right
        columns contain the  calculations as they would occur  if the filter's
        components had unbounded precision. It can be seen that the wraparound
        effect of the  two's complement representation does  indeed not change
        the filter's output.%
    }
    \label{tab:cic_simu:cic_filter_states}
    \ttfamily
    \begin{tabular}{rrrr|rrr}
        \toprule
        \scshape Cycle                   &
        \scshape IN                      &
        \scshape OUT\textsubscript{INT}  &
        \scshape OUT                     &
        \scshape OUT\textsubscript{INT}  &
        \scshape OUT                     &
        \scshape OUT                     \\

        &
        &
        \scshape IN\textsubscript{COMB} &
        &
        (unbounded) &
        (bounded    &
        (unbounded  \\

        &
        &
        &
        &
        &
        integrator) &
        integrator) \\

        \midrule
        %     IN   OI/IC  OUT   UW
        -2 & 000 &  000 & 000 & $ 0$ &                                    & \\
        -1 & 000 &  000 & 000 & $ 0$ &                                    & \\
         0 & 001 &  001 & 001 & $ 1$ & $  1 -   0  =  1                 $ & $ 1 - 0 = 1 $\\
         1 & 001 &  010 &     & $ 2$ &                                    & \\
         2 & 001 &  011 & 010 & $ 3$ & $  3 -   1  =  2                 $ & $ 3 - 1 = 2 $\\
         3 & 001 &  100 &     & $ 4$ &                                    & \\
         4 & 001 &  101 & 010 & $ 5$ & $ -3 -   3  = -6 = 2_\mathrm{wr} $ & $ 5 - 3 = 2 $\\
         5 & 001 &  110 &     & $ 6$ &                                    & \\
         6 & 001 &  111 & 010 & $ 7$ & $ -1 - (-3) =  2                 $ & $ 7 - 5 = 2 $\\
         7 & 001 &  000 &     & $ 8$ &                                    & \\
         8 & 001 &  001 & 010 & $ 9$ & $  1 - (-1) =  2                 $ & $ 9 - 7 = 2 $\\
         9 & 001 &  010 &     & $10$ &                                    & \\
        10 & 001 &  011 & 010 & $11$ & $  3 -   1  =  2                 $ & $ 11 - 9 = 2 $\\
        11 & 001 &  100 &     & $12$ &                                    & \\
        12 & 001 &  101 & 010 & $13$ & $ -3 -   3  = -6 = 2_\mathrm{wr} $ & $ 13 - 11 = 2 $\\
        13 & 001 &  110 &     & $14$ &                                    & \\
        14 & 001 &  111 & 010 & $15$ & $ -1 - (-3) =  2                 $ & $ 15 - 13 = 2 $\\
        \bottomrule
    \end{tabular}
\end{table}

As  a   last  step   to  confirm   our  results,  the   CIC  filter   of  this
exercise  is   simulated  with   Simulink. Its  block   design  is   given  in
Figure~\ref{fig:cic_simu:simulink_model}. All   blocks   are  set   to   two's
complement with three digits of precision (no fractional bits).

The          simulation         results          are         given          in
Figure~\ref{fig:cic_simu:simulink_results}. As   can  be   seen,  the   filter
states  are  identical  to  our manually  calculated  example. The  effect  of
the  integrator's   output  wrapping   around  the  numerical   boundaries  is
also  nicely  visible. In  case  the  reader  wishes  to  tinker  around  with
this  themselves,  the  Simulink  files  can  be  found  in  the  subdirectory
\code{doc/report/images/cicSimu}, relative  to the repository  root. Note that
the fixed-point toolbox is required for this.

\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{images/cicSimu/simulink.png}
    \caption[Simulink Filter Model]{%
        Simulink model  for the filter  in Figure~\ref{fig:cic_simu:topo}. The
        Rate   Compressor is  a  simple Matlab  function  which returns  every
        second value of its input vector.%
    }
    \label{fig:cic_simu:simulink_model}
\end{figure}

\begin{figure}
    \centering
    \input{images/cicSimu/simulinkOut.tikz}
    \caption[Simulink Simulation Results]{%
        Simulation    results    from    Simulink   for    the    filter    in
        Figure~\ref{fig:cic_simu:simulink_model}%
    }
    \label{fig:cic_simu:simulink_results}
\end{figure}

Lastly,  it is  shown what  happens  when the  expected output  of the  filter
exceeds  the numerical  range  available. This is  accomplished  by feeding  a
constant of \num{2} into the filter; the expected output is therefore \num{4}.

Because \num{4}  is not  within the  range of  a three-digit  two's complement
number  system, the  filter wraps  around  and produces  an incorrect  output,
\num{-4}.   The  first  few  calculation  steps  for  this  are  presented  in
Table~\ref{tab:cic_simu:cic_filter_states:out_of_bounds};  running  the  above
simulation with the modified input also confirms this result.

\begin{table}
    \centering
    \caption[CIC Filter Example: Output Out of Range]{%
        The  same CIC  filter  as  before stimulated  with  an  input of  2. A
        comparison between the right two columns  shows that the output of the
        bounded filter and its unbounded  counterpart no longer match starting
        with the output at $n=2$; the filter produces a false output.%
    }
    \label{tab:cic_simu:cic_filter_states:out_of_bounds}
    \ttfamily
    \begin{tabular}{rrrr|rrr}
        \toprule
        \scshape Cycle                   &
        \scshape IN                      &
        \scshape OUT\textsubscript{INT}  &
        \scshape OUT                     &
        \scshape OUT\textsubscript{INT}  &
        \scshape OUT                     &
        \scshape OUT                     \\

        &
        &
        \scshape IN\textsubscript{COMB} &
        &
        (unbounded) &
        (bounded    &
        (unbounded  \\

        &
        &
        &
        &
        &
        integrator) &
        integrator) \\

        \midrule
        %     IN   OI/IC  OUT   UW
        -2 & 000 &  000 & 000 & $ 0$ &                        & \\
        -1 & 000 &  000 & 000 & $ 0$ &                        & \\
         0 & 010 &  010 & 010 & $ 2$ & $  2 -   0  =  2     $ & $ 2 - 0 = 2 $\\
         1 & 010 &  100 &     & $ 4$ &                        & \\
         2 & 010 &  110 & 100 & $ 6$ & $ -2 -   2  = -4     $ & $ 6 - 2 = 4 $\\
         3 & 010 &  000 &     & $ 8$ &                        & \\
         4 & 010 &  010 & 100 & $10$ & $  2 - (-2) = -4     $ & $10 - 6 = 4 $\\
        \bottomrule
    \end{tabular}
\end{table}
%>>>
\clearpage
\section{CIC Filter Tables} % <<< -------------------------------------------- %
\label{sec:app:cic_filter_tables}
% ---------------------------------------------------------------------------- %

\begin{table}[h]
    \centering
    \caption[CIC Filter Passband Attenuations]{%
        Passband  attenuation   for  CIC   filters  as   a  function   of  the
        bandwidth-differential delay product. Taken from~\cite{1163535}.%
    }
    \label{tab:cic:pb_attenuation}
    \begin{tabular}{rrrrrrrr}
        \toprule
            \parbox[t]{40mm}{
                Relative \\
                Bandwidth-Differential\\
                Delay Product ($Mf_c$)} &
            \multicolumn{7}{c}{\parbox[t]{60mm}{
                Passband attenuation at $f_c$ in \si{\dB} \\
                as a Function of \\
                Number of Stages ($N$)}}                                  \\
        \midrule
            & 1 & 2 & 3 & 4 & 5 & 6 \\
        \midrule
            $1/128$ & $0.00$ & $0.00$ & $0.00$ & $0.00$ & $0.00$ & $0.01$ \\
            $1/64 $ & $0.00$ & $0.01$ & $0.01$ & $0.01$ & $0.02$ & $0.02$ \\
            $1/32 $ & $0.01$ & $0.03$ & $0.04$ & $0.06$ & $0.07$ & $0.08$ \\
            $1/16 $ & $0.06$ & $0.11$ & $0.17$ & $0.22$ & $0.28$ & $0.34$ \\
            $1/8  $ & $0.22$ & $0.45$ & $0.67$ & $0.90$ & $1.12$ & $1.35$ \\
            $1/4  $ & $0.91$ & $1.82$ & $2.74$ & $3.65$ & $4.56$ & $5.47$ \\
        \bottomrule
    \end{tabular}
\end{table}

\begin{table}[h]
    \centering
    \caption[CIC Filter Passband Aliasing Attenuation]{%
        Passband aliasing  attenuation for  CIC filters as  a function  of the
        bandwidth and the differential delay. Taken from~\cite{1163535}.%
    }
    \label{tab:cic:pb_aliasing}
    \begin{tabular}{rrrrrrrrr}
        \toprule
            \parbox[t]{20mm}{
                Differential\\
                Delay\\
                ($M$)%
            } &
            \parbox[t]{20mm}{
                Relative \\
                Bandwidth\\
                ($f_c$)} &
            \multicolumn{7}{c}{\parbox[t]{70mm}{
                Aliasing/Imaging Attenuation at $f_\mathrm{s,low}$ in \si{\dB}\\
                as a Function of Number of Stages ($N$)}}\\
        \midrule
            & & 1 & 2 & 3 & 4 & 5 & 6 \\
        \midrule
            1 & $1/128$ & $42.1$ & $84.2$ & $126.2$ & $168.3$ & $210.4$ & $252.5$ \\
            1 & $1/64 $ & $36.0$ & $72.0$ & $108.0$ & $144.0$ & $180.0$ & $215.9$ \\
            1 & $1/32 $ & $29.8$ & $59.7$ & $ 89.5$ & $119.4$ & $149.2$ & $179.0$ \\
            1 & $1/16 $ & $23.6$ & $47.2$ & $ 70.7$ & $ 94.3$ & $117.9$ & $141.5$ \\
            1 & $1/8  $ & $17.1$ & $34.3$ & $ 51.4$ & $ 68.5$ & $ 85.6$ & $102.8$ \\
            1 & $1/4  $ & $10.5$ & $20.9$ & $ 31.4$ & $ 41.8$ & $ 52.3$ & $ 62.7$ \\
        \midrule
            2 & $1/256$ & $48.1$ & $96.3$ & $144.4$ & $192.5$ & $240.7$ & $288.8$ \\
            2 & $1/128$ & $42.1$ & $84.2$ & $126.2$ & $168.3$ & $210.4$ & $252.5$ \\
            2 & $1/64 $ & $36.0$ & $72.0$ & $108.0$ & $144.0$ & $180.0$ & $216.0$ \\
            2 & $1/32 $ & $29.9$ & $59.8$ & $ 89.6$ & $119.5$ & $149.4$ & $179.3$ \\
            2 & $1/16 $ & $23.7$ & $47.5$ & $ 71.2$ & $ 95.0$ & $118.7$ & $179.3$ \\
            2 & $1/8  $ & $17.8$ & $35.6$ & $ 53.4$ & $ 71.3$ & $ 89.1$ & $106.9$ \\
        \bottomrule
    \end{tabular}
\end{table}
%>>>

%^^A vim: foldenable foldcolumn=4 foldmethod=marker foldmarker=<<<,>>>