1\section{Data formats}
2\label{sec:dataformats}
3
4In this section we describe how polynomials, lists, marked Gr\"obner
5bases etc. are represented as ASCII character strings. These strings
6will be input to the programs by typing or by redirecting the standard
7input and be output by the program on the standard output which may be
8the screen, a pipe or a file. Usually files are used for input. For
9example,
10\begin{verbatim}
11gfan_bases < inputfile.txt > outputfile.txt
12\end{verbatim}
13will read its input from {\tt inputfile.txt} and write its output to
14{\tt outputfile.txt}. The following is an example of how to use pipes
15for computing a universal Gr\"obner basis of the input:
16\begin{verbatim}
17gfan_bases < inputfile.txt | gfan_polynomialsetunion > outputfile.txt
18\end{verbatim}
19In general spaces and newlines in the input are ignored, but for the
20polyhedral formats described in Section~\ref{sec:format fan} and
21Section~\ref{sec:format cone} the rules are different.
22
23\subsection{Fields}
24Two kinds of fields are supported:
25\begin{itemize}
26\item The field $\Q$ of rationals which is represented by the string ``\texttt{Q}''.
27\item Fields of the form $\Z/p\Z$ where $p$ is a prime number. These
28fields are represented by text strings ``\texttt{Z/pZ}'' where \texttt{p}  is the
29prime number. For example ``\texttt{Z/3Z}'' or ``\texttt{Z/17Z}''. In Gfan the
30prime number $p$ must be less than $32749$.
31\end{itemize}
32\subsection{Variables}
33A variable is denoted by its name which is an string of
34characters. The exact rules for which names are allowed have not been
35decided on in this version of Gfan and therefore Gfan accepts most
36names. However, white spaces, commas and ``\texttt{]}'' are not allowed
37as characters in the name. Furthermore one should not choose variable
38names such that one name is a starting substring of an other -- don't
39choose names such as ``\texttt{x1}'' and ``\texttt{x}''
40in the same polynomial ring.
41\subsection{Polynomial rings}
42A polynomial ring is represented first by a field and then by a list of
43variable names.  The list begins with ``\texttt{[}'' and ends with
44``\texttt{]}''. Names are separated by commas. The ordering of the
45variables matters as this is also the ordering used for the entries of
46for example weight vectors. Examples: ``\texttt{Z/2Z[a,b]}'' and ``\texttt{Q[x\_1,x\_2,y1,y2]}''.
47\subsection{Polynomials}
48%The variables in the polynomial ring are named {\tt a},...,{\tt
49%z},{\tt A},...,{\tt Z}. The number of variables in the polynomial ring
50%is specified implicitly. It depends on the variables used in the
51%input. It is important to note that the first variable is always {\tt
52%a}, meaning that if, for example, {\tt h} is used then all variables
53%from {\tt a} to {\tt g} are also used and memory is allocated for
54%these variables. Thus the program will require more memory and be much
55%slower if the user uses a variable without using the previous ones. %
56%compared to start the naming with {\tt a}.  If you already have a file
57%where the variables have different names then have a look at
58%Subsection \ref{applist:_substitute}.
59
60Coefficients in the field are given as fractions. A coefficient equals
61its numerator multiplied by the inverse of the denominator. The
62numerator and denominator themselves are given by an integer in $\Z$
63which is mapped to the field by the homomorphism sending $1\in\Z$ to
64$1$ in the field. The '{\tt /}' character and the denominator can be
65left out if the denominator is $1$. If a field with non-zero
66characteristic was chosen one should be careful that the denominator
67is not $0$.
68
69Monomials are written in the following formats:
70\begin{itemize}
71\item
72\texttt{a\symbol{94}4dc}
73\item
74\texttt{a4dc}
75\item
76\texttt{aaadac}
77\end{itemize}
78The monomial $1$ cannot be written without writing it as a term in the usual way ``\texttt{1}''.
79Any other term is either a monomial or a coefficient and a monomial. A polynomial is a list of terms separated by {\tt +}. The {\tt +} may be left out if the numerator of the next monomial is negative.
80
81That description did not cover every detail. Here is an example:
82\begin{verbatim}
83hello world - 3/8 a2+23abcge^4 +1
84\end{verbatim}
85In our usual notation we would write it like this: $dehl^{3}o^{2}rw+1+23abce^{4}g-{3\over 8}a^{2}$.
86{\bf It is important to note that the first term written in a polynomial is distinguished from the other terms in the polynomial. This is useful when specifying marked Gr\"obner bases.}
87\subsection{Lists}
88A list begins with a '{\tt \{}' or a '{\tt (}', contains elements separated by '{\tt ,}' and is ended by a  '{\tt \}}' or a '{\tt )}'.
89Different types of lists may be needed when specifying input for the various programs:
90\begin{description}
91\item[An integer vector] is a list of integers.
92\item[A list of integer vectors] is a list of integer vectors. Such lists are used for example when specifying generators for subgroups of $S_n$.
93\item[A polynomial list] (or a polynomial set) is a list of polynomials.
94\item[A Gr\"obner basis]  is the list of polynomials in a Gr\"obner basis with the leading term of each listed polynomial being the initial term with respect to a term order for which this a Gr\"obner basis.
95\item[A list of polynomial sets] is a list of polynomial sets. Often the polynomial sets are required to be Gr\"obner bases.
96\item[An ideal] is written as a list of polynomials generating it.
97\end{description}
98For all other lists than integer vectors the characters '{\tt \{}' and '{\tt \}}' are used to start and end the list.
99
100\subsection{Permutations}
101When exploiting the symmetry of an ideal one needs to input permutations to the program. Each permutation is specified by a vector. The length of the vector should equal the number of elements being permuted - for example the number of variables in the polynomial ring.
102The first element in the vector describes where the first element goes and so on. Of course we start indexing from $0$. The following vectors specify the identity, a transposition and a 3-cycle, respectively, on an ordered set of four elements:
103
104\begin{itemize}
105\item {\tt (0,1,2,3)}
106\item {\tt (1,0,2,3)}
107\item {\tt (0,3,1,2)}
108\end{itemize}
109
110
111\subsection{Polyhedral fans}
112\label{sec:format fan}
113\label{format:fan}
114The output format for polyhedral fans is intended to be Polymake \cite{polymake} compatible. Polymake recently switched to an XML based format. Gfan will keep outputting data in the old text style by default as it is more convienient for the command line Gfan user. The option \texttt{--xml} switches output to being XML. In the Polymake world, the output objects will have type \texttt{SymmetricFan}. The new XML files cannot be read by Gfan at the moment, while the old non-XML format cannot be read by any version of Polymake. In the following we describe only the text (non-XML) format. For the XML format we refer to the Polymake documentation.
115
116The text representation of a fan begins with the lines
117\begin{verbatim}
118_application fan
119_version 2.2
120_type SymmetricFan
121\end{verbatim}
122After this follows a list of properties. For example
123\begin{verbatim}
124LINEALITY_SPACE
1250 0 0 0 0 1 1 1 1 1 1 1 1 1 1
1260 0 0 0 1 0 0 0 1 0 0 1 0 1 1
1270 0 0 1 0 0 0 1 0 0 1 0 1 0 1
1280 0 1 0 0 0 1 0 0 1 0 0 1 1 0
1290 1 0 0 0 0 -1 -1 -1 0 0 0 -1 -1 -1
1301 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1
131\end{verbatim}
132Each property has a name and must be assigned a value of a certain type. You can read more about the philosophy of the format in the Polymake documentation.
133
134\begin{example}
135\label{ex:polyformat}
136The ideal $I=\langle ab-c,bc-a,ca-b\rangle$ has a cyclic symmetry.
137If we run the commands
138\begin{verbatim}
139gfan --symmetry -e | gfan_topolyhedralfan --symmetry
140\end{verbatim}
141on the input
142\begin{verbatim}
143Q[a,b,c]
144{ab-c,bc-a,ca-b}
145{(1,2,0)}
146\end{verbatim}
147we get a polyhedral representation of the Gr\"obner fan of $I$:
148\begin{verbatim}
149_application PolyhedralFan
150_version 2.2
151_type PolyhedralFan
152
153AMBIENT_DIM
1543
155
156DIM
1573
158
159LINEALITY_DIM
1600
161
162RAYS
1631 1 0	# 0
1641 0 1	# 1
1650 1 1	# 2
1660 1 0	# 3
1671 0 0	# 4
1680 0 1	# 5
1692 1 1	# 6
1701 1 2	# 7
1711 2 1	# 8
1721 1 1	# 9
173
174N_RAYS
17510
176
177LINEALITY_SPACE
178
179ORTH_LINEALITY_SPACE
1800 0 1
1810 1 0
1821 0 0
183
184F_VECTOR
1851 10 18 9
186
187CONES
188{}	# New orbit	# Dimension 0
189{0}	# New orbit	# Dimension 1
190{1}
191{2}
192{3}	# New orbit
193{4}
194{5}
195{6}	# New orbit
196{7}
197{8}
198{9}	# New orbit
199{0 3}	# New orbit	# Dimension 2
200{1 4}
201{2 5}
202{0 4}	# New orbit
203{1 5}
204{2 3}
205{6 9}	# New orbit
206{7 9}
207{8 9}
208{0 6}	# New orbit
209{1 7}
210{2 8}
211{0 8}	# New orbit
212{1 6}
213{2 7}
214{3 8}	# New orbit
215{4 6}
216{5 7}
217{0 3 8}	# New orbit	# Dimension 3
218{1 4 6}
219{2 5 7}
220{0 4 6}	# New orbit
221{1 5 7}
222{2 3 8}
223{0 6 8 9}	# New orbit
224{1 6 7 9}
225{2 7 8 9}
226
227MAXIMAL_CONES
228{0 3 8}	# New orbit	# Dimension 3
229{1 4 6}
230{2 5 7}
231{0 4 6}	# New orbit
232{1 5 7}
233{2 3 8}
234{0 6 8 9}	# New orbit
235{1 6 7 9}
236{2 7 8 9}
237
238PURE
2391
240\end{verbatim}
241The most important properties are ``RAYS'' and ``CONES''. A ray is given by a relative interior point and a cone is given by a list of indices of rays that will generate the cone.
242We may compare this combinatorial data
243to the drawing of the Gr\"obner fan given in
244Figure~\ref{fig:polyformat}. Notice that this example is particularly
245simple as the dimension of the homogeneity space of $I$ is $0$.
246\end{example}
247\begin{figure}
248\begin{center}
249\epsfig{file=polyformat.eps,height=5.9cm}
250\end{center}
251\caption{The Gr\"obner fan in Example~\ref{ex:polyformat} intersected with the standard simplex in $\R^3$.}
252\label{fig:polyformat}
253\end{figure}
254
255The symbol ``\#'' is used for writing comments in the file. The comments should not be considered a part of the file. The comments are used by Gfan to let the user know about dimensions, orbits and indices.
256
257A detailed description of the properties follows in the following.
258\subsubsection{Data types}
259In Gfan's Polymake format the following data types are supported:
260\begin{description}
261\item{Cardinal:} One non-negative integer.
262\item{Boolean:} 0 or 1.
263\item{Matrix:} An array of integer vectors.
264\item{IncidenceMatrix:} An array of sets of integers.
265\item{Vector:} An integer vector.
266%\item{String}
267\end{description}
268\subsubsection{Properties}
269Before we describe the properties we need to make a few definitions.
270
271We do not consider the empty set to be a cone nor a face of a cone.
272\begin{definition}
273The \emph{lineality space} of a polyhedral cone is the largest subspace contained in the cone.
274\end{definition}
275The lineality space is the smallest face of the cone and if two cones
276are in the same polyhedral fan then they must have the same lineality
277space. We define the \emph{lineality space} of a fan to be the common
278lineality space of its cones. In the special case of a
279(non-restricted) Gr\"obner fan or a tropical variety the lineality
280space of the fan coincides with the homogeneity space of the defining ideal.
281
282\begin{definition}
283A cone (in a fan) is called a \emph{ray} if its dimension is one larger than the dimension of its lineality space.
284\end{definition}
285A ray can be represented by a vector in its relative interior. This
286vector is contained in the cone but not contained in any of its
287proper faces. The representation is not unique since the cone is
288invariant under translation by vectors in its lineality space.
289
290A Polyhedral fan in Gfan can have a subset of the following properties:
291\begin{description}
292\item{AMBIENT\_DIM} is a \emph{Cardinal} whose value is the dimension of the vector space in which the fan lives. If the fan is a Gr\"obner fan or a tropical variety then this number equals the number of variables in the polynomial ring of the defining ideal.
293\item{DIM} is a \emph{Cardinal} whose value is the dimension of the highest dimensional cone in the fan.
294\item{LINEALITY\_DIM} is a \emph{Cardinal} whose value is the dimension of the lineality space of the fan.
295\item{RAYS} is a \emph{Matrix}. The rows of the matrix are vectors representing the rays of the fan --- one for each ray. The rows are ordered and Gfan writes an index as a comment to make the file human readable.
296\item{N\_RAYS} is a \emph{Cardinal} which equals the number of rays in the fan.
297\item{LINEALITY\_SPACE} is a \emph{Matrix} whose rows form a basis for the lineality space of the fan.
298\item{ORTH\_LINEALITY\_SPACE} is a \emph{Matrix} whose rows form a basis for the orthogonal complement of the lineality space of the fan.
299\item{F\_VECTOR} is a \emph{Vector}. The number of entries is DIM$-$LINEALITY\_DIM+1. The $i$th entry is the number of cones in the fan of dimension\\ $i+$LINEALITY\_DIM$-1$.
300\item{CONES} is an \emph{IncidenceMatrix}. The section contains a line for each cone in the fan. Each line is the set of indices of the rays contained in the corresponding cone.
301\item{MAXIMAL\_CONES} is an \emph{IncidenceMatrix} and similar to CONES except that only cones which are maximal with respect to inclusion are listed.
302\item{PURE} is a \emph{Boolean}. The value is $1$ if the polyhedral fan is pure and $0$ otherwise.
303\item{MULTIPLICITIES} is a \emph{Matrix} with one column. An entry is
304the multiplicity of a maximal cone. Usually cones in polyhedral fans
305do not have multiplicities. Thus this property only makes sense for
306\emph{weighted} polyhedral fans of which tropical varieties is a
307special case. The ordering of the rows in this property is consistent
308with the ordering in MAXIMAL\_CONES.
309\item{RAY\_VALUES} is a \emph{Matrix} with just one column. It is used when the fan is meant to specify a piece-wise linear (or tropical rational) function. The function value on the $i$th ray of the fan is listed in the $i$th row of the matrix.
310\item{LINEALITY\_VALUES} is a \emph{Matrix} with just one column. It is used when the fan is meant to specify a piece-wise linear (or tropical rational) function. The function value on the $i$th generator of the lineality space (stored in LINEALITY\_SPACE) is listed in the $i$th row of the matrix.
311\end{description}
312Besides sections listed above, the sections
313MAXIMAL\_CONES\_ORBITS, CONES\_ORBITS and MULTIPLICITIES\_ORBITS
314 are introduced when doing symmetric
315computations with the \texttt{--symmetry} option. These sections are
316analogous to MAXIMAL\_CONES, CONES and MULTIPLICITIES except that they
317operate on the level of orbits of cones with respect to the symmetry
318rather than cones.
319
320%\subsubsection{Dissimilarities between Gfan and Polymake}
321%In Polymake polyhedra are affine and for this reason the first entry of a vector has a special meaning. This is not the case in Gfan.
322
323%%In Polymake, if for example the section LINEALITY\_SPACE is empty it represents a $0\times 0$ matrix. In Gfan it represents a $0\times n$ matrix where $n$ is the dimension of the ambient space (AMBIENT\_DIM).
324
325\subsection{Polyhedral cones}
326\label{format:cone}
327\label{sec:format cone}
328%Polyhedral cones are represented in a Polymake compatible format; see the previous section.
329The string representation of a polyhedral cone starts with
330\begin{verbatim}
331_application PolyhedralCone
332_version 2.2
333_type PolyhedralCone
334\end{verbatim}
335After this follows the properties. For polyhedral cones they are as follows.
336
337\begin{description}
338\item{AMBIENT\_DIM} --- see previous section.
339\item{DIM} is a \emph{Cardinal} whose value is the dimension of the cone.
340\item{IMPLIED\_EQUATIONS} is a \emph{Matrix} whose rows form a basis of the space of linear forms vanishing on the cone.
341\item{LINEALITY\_DIM} --- see previous section.
342\item{LINEALITY\_SPACE} --- see previous section.
343\item{FACETS} is a \emph{Matrix} which contains an outer normal vector for each facet of the cone.
344\item{RELATIVE\_INTERIOR\_POINT} is a \emph{Vector} in the relative interior of the cone.
345\end{description}
346