\section{Errors and Warnings}\label{sec:error:warn}

This section explains the most frequent errors and warnings
related to inappropriate inputs or command line options that,
if they occur, lead to messages sent to the standard error stream.
The difference between errors and warnings is that the former
involve immediate termination,
while the latter are hints pointing at possibly corrupt input
that can still be processed further.
In the below description of errors (Section~\ref{subsec:error})
and warnings (Section~\ref{subsec:warn}),
we refrain from attributing them to a particular one among the tools
\gringo, \clasp, \clingo, and \iclingo,
in view of the fact that they share a number of functionalities.


\subsection{Errors}\label{subsec:error}

We start our description with errors that may be encountered during grounding,
where the following one indicates a syntax error in the input:
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: parsing failed:
        @\textit{File}@:@\textit{Line}@:@\textit{Column}@: unexpected token: @\textit{Token}@
\end{lstlisting}
%
To correct this error, please investigate the line~\code{\textit{Line}}
and check whether something looks strange there
(like a missing period, an unmatched parenthesis, etc.).

The next error occurs if an input program is not safe:
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: unsafe variables in:
@\textit{File}@:@\textit{Line}@:@\textit{Column}@: @\textit{Rule}@
        @\textit{File}@:@\textit{Line}@:@\textit{Column}@: @\textit{Var}@
        ...
\end{lstlisting}
%
Along with the error message, the \code{\textit{Rule}} and the
name~\code{\textit{Var}} of at least one variable causing the problem
are reported.
The first action to take usually consists of checking whether
variable~\code{\textit{Var}} is actually in the scope of any atom
(in the positive body of \code{\textit{rule}}) that can bind it.%
\footnote{%
  Recall from Section~\ref{subsec:gringo:arith} and~\ref{subsec:gringo:comp}
  that a variable in the scope of a built-in arithmetic function may not be bound
  by a corresponding atom and that built-in comparison predicates do not bind
  any variable.}
If~\code{\textit{Var}} is a local variable belonging to an atom~$A$ 
on the left-hand side of a condition (cf.\ Section~\ref{subsec:gringo:condition})
or to an aggregate (cf.\ Section~\ref{subsec:gringo:aggregate}),
an atom over some domain predicate might be included in a condition
to bind~\code{\textit{Var}}.
In particular, if~$A$ itself is over a domain predicate,
the problem is often easily fixed by writing ``\code{$A$:$A$}.''

The following error is related to conditions
(cf.\ Section~\ref{subsec:gringo:condition}):
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: unstratified predicate in:
@\textit{File}@:@\textit{Line}@:@\textit{Column}@: @\textit{Rule}@
        @\textit{File}@:@\textit{Line}@:@\textit{Column}@: @\textit{Predicate}@/@\textit{Arity}@
\end{lstlisting}
%
The problem is that an atom \code{\textit{Predicate}(...)} such
that its predicate \code{\textit{Predicate}/\!\textit{Arity}} is not a domain predicate
(cf.\ Section~\ref{subsec:gringo:condition}) is used on the right-hand side of a condition
within \code{\textit{Rule}}.
The error is corrected by either removing the atom or
by replacing it with another atom over a domain predicate.

The next errors may occur within an arithmetic evaluation
(cf.\ Section~\ref{subsec:gringo:arith}):
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: cannot convert @\textit{Term}@ to integer in:
        @\textit{File}@:@\textit{Line}@:@\textit{Column}@: @\textit{Literal}@
\end{lstlisting}
%
It means that either a (symbolic) constant or a compound term
(over an uninterpreted function with non-zero arity)
has occurred in the scope of some built-in arithmetic function.

The following error message is issued by (embedded) \clasp:
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: Read Error: Line 2, Compute Statement expected!
\end{lstlisting}
%
This error means that the input does not comply with \lparse's
numerical format~\cite{lparseManual}.
It is not unlikely that the input can be processed
by \gringo, \clingo, or \iclingo.

The next error indicates that input in
\lparse's numerical format~\cite{lparseManual} is corrupt:
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: Read Error: Line @\textit{Line}@, Atom out of bounds
\end{lstlisting}
%
There is no way to resolve this problem.
If the input has been generated by \gringo, \clingo, or \iclingo,
please report the problem to the authors of this guide.

The following error message is issued by (embedded) \clasp:
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: Read Error: Line @\textit{Line}@, Unsupported rule type!
\end{lstlisting}
%
It means that some rule type in \lparse's
numerical format~\cite{lparseManual} is not supported.
Most likely, the program under consideration contains
rules with disjunction in the head.

A similar error may occur with \clingo\ or \iclingo:
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: Error: clasp cannot handle disjunctive rules, \
              use option --shift!
\end{lstlisting}
%
The program under consideration contains rules with disjunction in the head,
which are currently not supported by \clasp,
but by \claspD~\cite{drgegrkakoossc08a}.
The integration of \clasp\ and \claspD\ is a subject to future work
(cf.\ Section~\ref{sec:future}).
Furthermore, if your program is head-cycle free, 
you might want to try \gringo's \code{--shift} option (see \ref{subsec:opt:gringo}).

All of the tools \gringo, \clasp, \clingo, and \iclingo\
try to expand incomplete (long) options to recognized ones.
Parsing command line options may nonetheless fail due to the following three reasons:
%
\begin{lstlisting}[numbers=none,escapechar=@]
ERROR: unknown option: @\textit{Option}@
ERROR: ambiguous option: '@\!\textit{Option}@' could be:
  @\textit{Option1}@
  @\textit{Option2}@
  ...
ERROR: '@\!\textit{Arg}@': invalid value for Option '@\!\textit{Option}@'
\end{lstlisting}
%
The first error means that a provided option~\code{\textit{Option}}
could not be expanded to one that is recognized,
while the second error expresses that the result of expanding~\code{\textit{Option}}
is ambiguous.
Finally, the third error occurs if a provided argument~\code{\textit{Arg}}
is invalid for option~\code{\textit{Option}}.
In either case, option \code{--help} can be used to see 
the recognized options and their arguments.


\subsection{Warnings}\label{subsec:warn}

The following warnings may be raised by \gringo, \clingo, or \iclingo:
%
\begin{lstlisting}[numbers=none,escapechar=@]
% warning: @\textit{p}@/@\!\textit{i}@ is never defined
\end{lstlisting}
%
This warning, states that a predicate \code{\textit{p}/\!\textit{i}}
has occurred in some rule body, but not in the head of any rule,
might point at a mistyped predicate.

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "guide"
%%% End: 
