\section{Debugging in {\bf bergman}} Unfortunately {\bf bergman} hasn't so many special debugging tools and in the most cases only the usual Lisp error handling system can be applied. Let us take an example containing several input errors and follow the debugging steps trying to correct them. Suppose, you are preparing an input file and the list of polynomials is huge. Of course, it is quite easy to make some errors in its typing. Here we have a fragment of such a list, it is extracted from a real problem offered by prof.M.Popa. \begin{verbatim} (setmaxdeg 10) (algforminput) vars v,d,r,s,t,e,q,m,b,c,h,g,l,k,p,n,a; g*q^3+h*p^3-k^2*l^2, 2*a^2*g^2-2*a^2*l^2+2*a^2*m^2-b^2*g^2+2*c^3*h-4*g*n^3+ 2*g*p^3+2*k^4, a^2*b^2*h+3*a^2*g*k^2-2*a^2*q^3-b^2*g*k^2-2*c^3*m^2+ 4*e^4*h+2*g*s^4-4*k^2*n^3, 3*a^2*b^2*h+12*a^2*g*k^2- 12*a^2*q^3+2*c^3*g^2-6*c^3*l^2-6*c^3*m^2-2*d^3*g^2+ 12*e^4*h+12*g*s^4-12*k^2*n^3-6*k^2*p^3, -a^4*g^2+4*a^2*k^4+8*a^2*t^4-2*b^4*g^2-4*b^2*g*n^3+ 8*c^3*g*k^2-16*e^4*g^2+8*e^4*m^2+8*g*v^5-4*n^6+8*p^6, a^2*g^3-a^2*g*l^2-a^2*g*m^2-2*a^2*h*k^2+2*a^2*r^3+ 2*g^2*p^3+4*k^2*q^3-2*l^2*n^3-2*m^2*p^3, -2*a^2*g^3+4*a^2*g*l^2+8*a^2*h*k^2-4*a^2*r^3-b^2*g^3+ 2*c^3*g*h-10*g^2*p^3-6*g*k^2-8*k^2*q^3+4*l^2*n^3+ 8*l^2*p^3+4*m^2*p^3, -a^2*g*l^2-3*a^2*h*k^2-b^2*h*k^2-2*c^3*g*h+4*g^2*p^3+ 4*g*k^4+4*g*t^4-2*h*s^4+2*l^2*n^3-8*l^2*p^3, -6*a^2*h*k^2-3*b^2*g*l^2-4*c^3*g*h-2*d^3*g*h+6*g^2*p^3+ 12*g*k^4+12*g*t^4-6*k^2*q^3-18*l^2*p^3+6*m^2*p^3, 3*a^2*g^3-4*a^2*g*l^2-6*a^2*h*k^2+4*a^2*r^3-2*g^2*n^3+ 8*g^2*p^3+4*g*k^4+8*k^2*q^3-4*l^2*n^3-4*l^2*p^3-4*m^2*p^3, 18*a^12-81*a^10*b^2+189*a^8*b^4+108*a^8*e^4-279*a^6*b^6- 108*a^6*b^2*e^4-30*a^6*c^6+96*a^6*c^3*d^3-12*a^6*d^6- 144*a^6*f^6+243*a^4*b^8-324*a^4*b^4*e^4+162*a^4*b^2*c^6- 432*a^4*b^2*c^3*d^3+108*a^4*b^2*d^6+324*a^4*b^2*f^6- 108*a^2*b^10+540*a^2*b^6*e^4-198*a^2*b^4*c^6+ 504*a^2*b^4*c^3*d*3-144*a^2*b^4*d^6-432*a^2*b^4*f^6- 648*a^2*b^2*e^8+288*a^2*c^6*e^4-144*a^2*c^3*d^3*e^4- 144*a^2*d^6*e^4-432*a^2*e^4*f^6+18*b^12-216*b^8*e^4+ 66*b^6*c^6-168*b^6*c^3*d^3+48*b^6*d^6+144*b^6*f^6+ 648*b^4*e^8-720*b^2*c^6*e^4+1008*b^2*c^3*d^3*e^4- 288*b^2*d^6*e^4-864*b^2*e^4*f^6+128*c^12-416*c^9*d^3+ 480*c^6*d^6+264*c^6*f^6-224*c^3*d^9-672*c^3*d^3*f^6+ 32*d^12+192*d^6*f^6-2592*e^12+288*f^12, -a^2*b^2*g^2+2*a^2*k^4+4*c^3*g*k^2-4*e^4*g^2+4*p^6; \end{verbatim} The first attempt to compute it (working in the Reduce version) failed: \begin{verbatim} Entering LISP ... Bergman 0.931, 23-Oct-99 1 lisp> (simple "tests/inv.err") 10 ***** dskin of `tests/inv.err' aborted after 1 form(s). ***** Segmentation Violation 2 lisp> \end{verbatim} The yielded error message ''Segmentation Violation'' is not very informative. One can obtain more information using the possibility of tracing, offered by LISP. According to the PSL documentation, ''the error handler typically calls an interactive break loop, which permits the user to examine the context of the error and optionally make some corrections and continue the computation, or to abort the computation.'' If we are in {\bf bergman} compiled under PSL the break loop is coming immediately: \begin{verbatim} 1 lisp> (simple "tests/inv.err") 10 ***** ***** Continuable error. Break loop 2 lisp break (1) > \end{verbatim} Being in the Reduce version one should switch on the corresponding flag before the computation: \begin{verbatim} Entering LISP ... Bergman 0.931, 23-Oct-99 1 lisp> (on break) nil 2 lisp> (simple "tests/inv.err") 10 ***** Break loop 3 lisp break (1) > \end{verbatim} Now we have similar situations in both cases and can start the debugging. First of all, we can use the tracing to locate the erroneous place. So, let us try some of the break loop commands, for example, {\bf T}: \begin{verbatim} 1 lisp> (simple "tests/inv.err") 10 ***** ***** Continuable error. Break loop 2 lisp break (1) > T Backtrace from top of stack: backtrace top!-loop!-eval!-and!-print continuableerror a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E p!O!La!L!Gr!E!A!D algforminput dskin!-step unprotected!-dskin!-stream dskin!-stream dskin simple top!-loop!-eval!-and!-print standardlisp nil \end{verbatim} Looking on this information we can presume, that something is wrong with the input, because the {\it continuableerror} was created by\\ a!L!G!I!Nr!E!A!De!R!...\\ followed by p!O!La!L!Gr!E!A!D. Continuing investigation we can use the ``V'' option: \begin{verbatim} 3 lisp break (1) > V \end{verbatim} Omitting a part of output, which seems to be not very understandable, let us pay attention to the following strings: \begin{verbatim} a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E -> continuableerror: p!O!La!L!Gr!E!A!D -> a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E: 18 f \end{verbatim} ''18'' is the number of input variables. What is ''f''? One of the input variables, why it appears here? It seems, it is treated in a special manner, but why? Checking the list of input variables one can see that it is absent in the {\bf vars} list! So, we found one error and should correct it inserting the variable ''f''. Starting the computation again we obtain, unfortunately, a new continuable error and try to repeat the debugging process. Among the information obtained after the applying of ``V'' option one should pick out the following strings: \begin{verbatim} a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E -> continuableerror: p!O!La!L!Gr!E!A!D -> a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E: 18 3 nil 504 \end{verbatim} 504 is one of the coefficients of the 11th polynomial, it is the largest one and we may expect some troubles here. Searching the input file we find the monomial with such a coefficient: \begin{verbatim} 504*a^2*b^4*c^3*d*3 \end{verbatim} An error occurred because the sign \verb-''^''- on the end of monomial was mistyped. After its correction we try again: \begin{verbatim} 1 lisp> (simple "tests/inv.err") 10 t % 4 q^3*g-l^2*k^2+h*p^3, 2*c^3*h-b^2*g^2+2*k^4+2*g*p^3-4*g*n^3+2*m^2*a^2+ 2*g^2*a^2-2*l^2*a^2, % 5 4*g*k^4+4*g^2*p^3-4*l^2*p^3-2*g^2*n^3+2*m^2*g*a^2+ g^3*a^2-2*g*l^2*a^2-2*h*k^2*a^2, -4*g*k^2-4*g^2*p^3+4*l^2*p^3+2*g^2*n^3-2*m^2*g*a^2- g^3*a^2+2*g*l^2*a^2+2*h*k^2*a^2, 4*q^3*k^2-2*m^2*p^3+2*g^2*p^3-2*l^2*n^3+2*r^3*a^2- m^2*g*a^2+g^3*a^2-g*l^2*a^2-2*h*k^2*a^2, 24*t^4*g-4*d^3*h*g-4*b^2*g^3-6*b^2*g*l^2+6*m^2*p^3- 6*g^2*p^3-4*l^2*p^3-6*l^2*n^3+6*r^3*a^2-11*m^2*g*a^2+ 3*g^3*a^2+5*g*l^2*a^2-2*h*k^2*a^2, 6*s^4*g-2*d^3*g^2+2*c^3*g^2-6*c^3*l^2+3*b^2*g*k^2- 6*k^2*p^3-6*q^3*a^2+3*g*k^2*a^2, -12*s^4*h+4*d^3*h*g-2*b^2*g^3+6*b^2*g*l^2-6*b^2*h*k^2- 6*m^2*p^3+6*g^2*p^3-8*l^2*p^3-6*g^2*n^3+18*l^2*n^3- 6*r^3*a^2+5*m^2*g*a^2-5*g*l^2*a^2+2*h*k^2*a^2, -6*m^2*c^3+12*e^4*h+2*d^3*g^2-2*c^3*g^2+6*c^3*l^2- 6*b^2*g*k^2+6*k^2*p^3-12*k^2*n^3+3*b^2*h*a^2+6*g*k^2*a^2, ***** Segmentation Violation Break loop 2 lisp break (1) > \end{verbatim} The computation started, but something was wrong. The input data were successfully read , the computation started ... What happened? One of the most frequent error is non-homogeneity. To check it we can use, as previously, the tracing, but there is a special {\bf bergman} function \index{testindata} {\bf testindata} to help us in debugging. This function tests the homogeneity of input polynomials. It should be called immediately after the input (before starting the computation), for example: \begin {verbatim} 1 lisp> (dskin "tests/inv.err") 10 t nil 2 lisp> (testindata) ((4 4) (5 5 nil 5 5 5 5) (6 6) (12)) \end{verbatim} The function prints the list of monomial's degrees, the value {\bf nil} shows that one of the polynomials in degree 5 is not homogeneous. In our example it is the monomial \begin{verbatim} -6*g*k^2 \end{verbatim} in the 7th polynomial (there is another question how to locate it using Lisp). After its correction we can re-start the computations and are lucky to see the result, which is too large and not so interesting to be included here. One more {\bf bergman} function to help you on debugging is {\bf getsetup} which displayed some useful information: \begin{verbatim} 3 lisp> (getsetup) ((objecttype ring (autoaddrelationstate nil nil)) (resolutiontype none) (variablesetup (ringtype commutative) (commutativeorder tdegrevlex) (noncommutativeorder tdegleftlex) (variablenumber 18) (invariables (v d r s t e q m f b c h g l k p na)) (outvariables (v d r s t e q m f b c h g l k p n a)) (variableweights nil)) (strategy (mindeg nil) (maxdeg 10) (interruption ordinary)) (coefficientdomain nil (oddprimesmoduli ordinary)) (inputformat casesensalgin) (outputformat algexptsprint) (variousflags (custshow off) (custstrategy off) (degreeprintoutput off) (dynamiclogtables off) (homogenised off) (immediatecrit off) (immediatefullreduction on) (immediaterecdefine off) (nobignum off) (obsoletenamesinform off) (oldprintmodes1 off) (oldseriesmodes1 on) (standardanickmodes on) (pbseries off) (reductivity on) (savedegree off) (saverecvalues on))) \end{verbatim} One can check the values of the polynomial ring set up: \begin{itemize} \item ring type (in our example: {\bf (ringtype commutative)}), \item ordering (in our example: {\bf (commutativeorder tdegrevlex)}), \item characteristic (in our example: {\bf (coefficientdomain nil (odd\-pri\-mes\-moduli ordinary))} corresponds to characteristic 0), \item number, list of input and output variables, their weights {\bf (variable\-weights nil)} in our example means the naturally graded list). \end{itemize} Besides that we can see the set up of: \begin{itemize} \item strategy, \item resolution type, \item maximal and minimal degrees, \item input and output formats (in our example: case sensitive algebraic form input and algebraic form output where the exponents values are printed explicitly), \item various flags, their meaning is explained in the manual. \end{itemize} %PRINTNEXT - a new debugging procedure to be described in this %section. %printsetup, getsetup