1\newpage
2\section{Using the software}
3In this section we will explain by examples how to use the software
4for the most common computations. \name consist of a set of subprograms
5with names like \texttt{gfan\_bases} and \texttt{gfan\_buchberger} each with
6a different purpose. See Appendix \ref{sec:dataformats} for an
7explanation of the data formats and Appendix~\ref{sec:applist} for a
8full list of the various functions and their help files.
9
10%\emph{In the
11%following we will assume that the software has been installed with
12%\texttt{make install} and that all subprograms have been installed
13%with \texttt{gfan installlinks} - see Section \ref{sec:installation}}.
14
15\subsection{Computing the Gr\"obner fan}
16The program \texttt{gfan\_bases} computes the set of reduced Gr\"obner bases
17of an ideal. To use it type in the name in the UNIX shell \footnote{It is actually much more convenient to use the Emacs shell. In Emacs press Meta-x and type \textup{shell}. When you are in the Emacs shell Ctrl-up will allow you to easily reinput old polynomial data to \name.}
18\begin{verbatim}
19gfan_bases
20\end{verbatim}
21and type in a polynomial ring followed by a set of generators for the ideal
22\begin{verbatim}
23Q[a,b,c]
24{aab-c,bbc-a,cca-b}
25\end{verbatim}
26For compatibility reasons the polynomial ring can be left out in which case the ring is assumed to be the polynomial ring over the rationals with variable names $a,b,c,\dots$.
27The program will output the polynomial ring and the list of
28reduced Gr\"obner bases of the input ideal. In this example there are
2933 such bases.
30% You may want to filter the output through the UNIX
31%program \texttt{cat} to separate the debug information and the list of
32%Gr\"obner bases. Type the following to do this:
33%\begin{verbatim}
34%gfan | cat
35%\end{verbatim}
36%and type in the input as before.
37
38Often it is convenient to store your generators in a text file instead
39of typing them in every time you use the program. You can redirect the
40standard input for the program to read from a file instead of the
41keyboard. For example, if your ring and generators are stored in the file
42\texttt{myinputfile.txt} you would type:
43\begin{verbatim}
44gfan_bases <myinputfile.txt
45\end{verbatim}
46If you want to store the output in the file \texttt{myoutputfile.txt}
47you can redirect the standard output as well:
48\begin{verbatim}
49gfan_bases <myinputfile.txt >myoutputfile.txt
50\end{verbatim}
51
52
53The list of reduced Gr\"obner bases can be transformed into a polyhedral representation of the Gr\"obner fan by using the program \texttt{gfan\_topolyhedralfan} as explained in Section~\ref{subsec:combining}.
54
55Here is another example of a polynomial ring and an ideal:
56\begin{verbatim}
57Z/3Z[x_1,x_2,x_3]
58{x_1^2x_2-x_3,x_2^2x_3-x_1,x_3^2x_1-x_2}
59\end{verbatim}
60
61\subsubsection{Exploiting symmetry}
62\label{sec:symmtry}
63As explained in Subsection \ref{subsec:global computations} the program can do its computations up to symmetry. In the example above we may cycle the three variables without changing the ideal. Hence the subgroup $G\subseteq S_n$ in Subsection \ref{subsec:global computations} is the group generated by a three cycle. A way to write down the subgroup is by writing a list of permutations that generate the subgroup:
64\begin{verbatim}
65{(0,1,2),(1,2,0)}
66\end{verbatim}
67The first permutation is the identity (which can be left out). The second permutation is three-cycle. Together they generate $G$. See Appendix~\ref{sec:dataformats} for more information on how to specify the permutations.
68
69The option \texttt{--symmetry} tells \texttt{gfan} to do its computations up to symmetry. For example,
70\begin{verbatim}
71gfan_bases --symmetry <anotherinputfile.txt
72\end{verbatim}
73will read the generators for the ideal and the generators for the group and perform the computation up to symmetry. The input file would have to look like this:
74\begin{verbatim}
75Q[a,b,c]
76{aab-c,bbc-a,cca-b}
77{(0,1,2),(1,2,0)}
78\end{verbatim}
79The output will be a list of reduced Gr\"obner basis - one for each orbit.
80
81\subsection{Combining the programs}
82\label{subsec:combining}
83The various \name programs can be combined. For example, if we are interested in the combinatorics of the Gr\"obner fan rather than the Gr\"obner bases, we can run the command:
84\begin{verbatim}
85gfan_bases <myinputfile.txt | gfan_topolyhedralfan
86\end{verbatim}
87The output is a polyhedral fan in the format explained in Appendix~\ref{format:fan}.
88
89Similarly, the command line
90\begin{verbatim}
91gfan_buchberger <myinputfile.txt | gfan_groebnercone
92\end{verbatim}
93produces the polyhedral cone (Appendix~\ref{format:cone}) of the computed reduced Gr\"obner basis, and
94\begin{verbatim}
95gfan_buchberger <myinputfile.txt | gfan_groebnercone --asfan
96\end{verbatim}
97computes the cone as a polyhedral fan (Appendix~\ref{format:fan}) with all faces of the cone listed.
98
99As another example, if we are interested in the list of monomial initial ideals rather than the complete list of reduced Gr\"obner bases of an ideal we will pipe the output of \texttt{gfan\_bases} through the program \texttt{gfan\_leadingterms}:
100\begin{verbatim}
101gfan_bases <myinputfile.txt | gfan_leadingterms -m
102\end{verbatim}
103%or if we want to direct the output:
104%\begin{verbatim}
105%gfan <myinputfile.txt | gfan_leadingterms -m >myoutputfile.txt
106%\end{verbatim}
107We need to use the option \texttt{-m} to tell \texttt{gfan\_leadingterms} that it should expect a list of Gr\"obner bases rather than a single Gr\"obner basis on its input.
108
109If we want the union of the Gr\"obner bases instead we should type:
110\begin{verbatim}
111gfan_bases <myinputfile.txt | gfan_polynomialsetunion >myoutputfile.txt
112\end{verbatim}
113This will compute a \emph{universal Gr\"obner basis}.
114
115In three variables, if we want to draw staircase diagrams of the initial ideals we may use the program \texttt{gfan\_renderstaircase}:
116\begin{verbatim}
117gfan_bases --symmetry <anotherinputfile.txt |
118                        gfan_renderstaircase -m -w6 -d16 >out.fig
119\end{verbatim}
120The output file is the xfig file in Figure \ref{fig:staircase}. To save paper we used the \texttt{--symmetry} option and gave the program the file also containing the group generators as input.
121\begin{figure}
122\begin{center}
123\epsfig{file=staircase.eps,height=4.5cm}
124\end{center}
125\caption{Staircase diagrams of the monomial initial ideals in the example - up to symmetry.}
126\label{fig:staircase}
127\end{figure}
128
129
130In three variables, if we want to draw the Gr\"obner fan - or rather draw the intersection of the $2$-dimensional standard simplex with the Gr\"obner fan we may use the program \texttt{gfan\_render}:
131\begin{verbatim}
132gfan_bases <myinputfile.txt | gfan_render >myoutputfile.fig
133\end{verbatim}
134The output is shown in Figure \ref{fig:gfan}.
135If there are more than three variables in the polynomial ring this program can still be used but it is more difficult. See Appendix~\ref{applist:_render}.
136\begin{figure}
137\begin{center}
138\epsfig{file=gfan.eps,height=5.9cm}
139\end{center}
140\caption{The Gr\"obner fan of the ideal intersected with the standard simplex.}
141\label{fig:gfan}
142\end{figure}
143
144\subsection{Interactive mode}
145To study the local structure of the Gr\"obner fan the program \texttt{gfan\_interactive} is useful. It allows the user to walk along an arbitrary path of full dimensional Gr\"obner cones in the Gr\"obner fan of the ideal. At each step the user will specify which facet to walk through. The input must be a marked Gr\"obner basis. The program will minimise and autoreduce if necessary to get the reduced Gr\"obner basis. For example running the program
146\begin{verbatim}
147gfan_interactive
148\end{verbatim}
149with input
150\begin{verbatim}
151Q[a,b,c]
152{
153c^15-c,
154b-c^11,
155a-c^9}
156\end{verbatim}
157will give us a list of facets to walk through. (One way to get a starting Gr\"obner basis is by using the program \texttt{gfan\_buchberger}.) In this case only two flips are possible, since the third wall does not lead to a new Gr\"obner cone. -- The wall is on the boundary of the Gr\"obner region. We may choose any of the two remaining facets by typing in an index (a number) followed by $<$ enter $>$. See Appendix \ref{applist:_interactive} for more options.
158%\subsection{Other useful programs}
159%We list a few more interesting programs in the package. The remaining programs can be found in Appendix \ref{sec:applist}.
160%\subsubsection{Computing a Gr\"obner cone}
161%The program \texttt{gfan\_groebnercone} extracts a defining set of half-spaces for a Gr\"obner cone.
162%The input is a Gr\"obner basis for the cone. The output is a list of vectors - each specifying a half-space.
163%For example we may compute the restricted Gr\"obner cone of the lexicographic basis above by running
164%\begin{verbatim}
165%gfan_groebnercone --restrict
166%\end{verbatim}
167%with the reduced Gr\"obner basis as input.
168%
169%\subsubsection{Computing the facets of a Gr\"obner cone}
170%The program \texttt{gfan\_facets} will take a list of vectors - each specifying a half-space whose intersection is a full-dimensional cone and compute a minimal set of defining half-spaces for the cone. Thus, we can compute the inner facet normals of the Gr\"obner cone above by running
171%\begin{verbatim}
172%gfan_groebnercone --restrict | gfan_facets
173%\end{verbatim}
174%with the reduced Gr\"obner basis as input.
175%
176%\subsubsection{Computing a weight vector}
177%The program \texttt{gfan\_weightvector} will compute a strictly positive interior point of a Gr\"obner cone given by its reduced Gr\"obner basis. In our example, if we run
178%\begin{verbatim}
179%gfan_weightvector
180%\end{verbatim}
181%on the lexicographic basis we (might) get the vector
182%\begin{verbatim}
183%(21,25,2)
184%\end{verbatim}
185
186
187\subsection{Integers and p-adics}
188Gfan handles two settings in which the usual division and Buchberger algorithms do not suffice. These are ideals in $\Z[x_1,\dots,x_n]$ and $\Q[x_1,\dots,x_n]$, where, in the latter setting, the $p$-adic valuation is taken into account when defining initial ideals.
189
190At the moment these two settings are handled by the commands \texttt{gfan\_overintegers} and \texttt{gfan\_padic}. They allow the computation of Gr\"obner bases, initial ideals, Gr\"obner cones (or polyhedra) and Gr\"obner fans (or complexes). In this section we give two examples. Use the \texttt{--help} option to get the full documentation.
191
192\begin{example}
193To compute the Gr\"obner fan of \cite[Example~3.9]{sturmfels}, with the ideal considered in the ring $\Z[a,b,c]$ we run the command
194\begin{verbatim}
195gfan_overintegers --groebnerFan -g --log1
196\end{verbatim}
197on
198\begin{verbatim}
199Q[a,b,c]
200{a^5+b^3+c^2-1, b^2+a^2+c-1, c^3+a^6+b^5-1}
201\end{verbatim}
202Since the type-system of Gfan does not understand {\texttt Z[a,b,c]} we need to trick Gfan by specifying the ring $Q[a,b,c]$ when running {\texttt gfan\_overintegers}. From the output we conclude that the ideal has $1659$ reduced Gr\"obner bases over the integers (as opposed to $360$ over a field of characteristic $0$).
203\end{example}
204
205\begin{example}
206To compute the reduced Gr\"obner basis of $I=\langle x_1+2x_2-3x_3, 3x_2-4x_3+5x_4\rangle\subseteq \Q[x_1,\dots,x_4]$ with respect to the vector $(1,0,0,1)$ (tie-broken lexicographically) and with $\Q$ having the $2$-adic valuation,
207we run
208\begin{verbatim}
209gfan_padic --groebnerBasis -p2
210\end{verbatim}
211on the input
212\begin{verbatim}
213Q[x1,x2,x3,x4]
214{
215x1+2x2-3x3,
2163x2-4x3+5x4
217}
218(1,1,0,0,1)
219\end{verbatim}
220The first coordinate of the input vector is a $1$, since {\texttt \_padic} requires ``homogenized'' weight vectors. This is Example 2.4.3 in the upcoming book by Maclagan and Sturmfels on tropical geometry. The division algorithm implemented in Gfan used for this computation was proposed by Maclagan. To find all initial ideals, we can use a combination of \texttt{gfan\_padic --groebnerBasis}, \texttt{gfan\_combinerays --section CONES -i filename} and \texttt{gfan\_padic --initialIdeals -m}.
221
222Notice that the Gr\"obner complex of $I$, where valuation is taken into account (see Maclagan-Sturmfels), is not a fan. The output of \texttt{gfan\_groebnerComlex}, however, will be a fan. To get the Gr\"obner complex we need to intersect the fan with the hyperplane $\omega_0=1$.
223
224NOTICE THAT \texttt{\_padic} USES THE MINIMUM CONVENTION AT THE MOMENT - in order to be consistent with Maclagan and Sturmfels.
225\end{example}
226
227
228\subsection{Toric ideals and secondary fans}
229
230Gfan is a replacement of the software CaTS \cite{cats} which computes Gr\"obner fans of toric and lattice ideals.
231For convenience a program for computing lattice ideals has been added to Gfan.
232To compute the lattice ideal of the lattice generated by $(2,-1,0)$ and $(3,0,-1)$ we run:
233\begin{verbatim}
234gfan_latticeideal
235{(2,-1,0),(3,0,-1)}
236\end{verbatim}
237Gfan will transform the generators into binomials and compute the
238saturation of the ideal they generate by the product of all variables. The computation is independent of the characteristic of the field.
239
240If on the other hand we wish to compute the toric ideal of a \emph{vector configuration} given by the columns of the $1\times 3$-matrix $(1,2,3)$ we run
241\begin{verbatim}
242gfan_latticeideal -t
243{(1,2,3)}
244\end{verbatim}
245More rows can be added to the matrix if we want.
246
247The choice of the term ``vector configuration'' is intentional and nonstandard. The reason for this will become clear later in this section. In Gfan terminology a \emph{point configuration} is reserved for the collection of points we have before we add a row of ones to construct a projective toric variety. By adding the row of ones the point configuration is turned into a vector configuration.
248Notice that scaling a vector of a vector configuration may change its toric ideal.
249
250Computing toric ideals Gfan is not optimal. If one needs to do big examples the software 4ti2 \cite{4ti2} is recommended.
251
252For a toric ideal the radical of a monomial initial ideal is the Stanley-Reisner ideal of a regular triangulation of the point configuration, see \cite{sturmfels}. Hence the toric Groebner fan is a refinement of the \emph{secondary fan}, indexing all regular triangulation of the point configuration.
253
254The secondary fan of the vector configuration $\{(1,0),(1,1),(1,2),(1,3)\}$ can be computed by typing
255\begin{verbatim}
256gfan_secondaryfan
257{(1,0),(1,1),(1,2),(1,3)}
258\end{verbatim}
259Comparing this to the finer Gr\"obner fan of the corresponding toric ideal which you get by doing
260\begin{footnotesize}
261\begin{verbatim}
262gfan_transposematrix  | gfan_latticeideal -t | gfan_bases | gfan_topolyhedralfan
263{(1,0),(1,1),(1,2),(1,3)}
264\end{verbatim}
265\end{footnotesize}
266you realise that three monomial initial ideals of the toric ideal have the same radical, while four monomial initial ideals pairwise have the same radical.
267
268The secondary fan computation was added for convenience.
269%For any
270%serious computation with secondary fans you should use
271An alternative is to use
272TOPCOM \cite{rambau}.  Notice however, that the vector configurations
273for gfan\_secondaryfan do not have to be pointed. This means that
274all combinatorial types of polytopes with a fixed set of normals can
275be easily enumerated. This is not possible with TOPCOM.
276