Debian Codegraph @

doc/bergman1.0.man/debugg.tex

raw
1 \section{Debugging in {\bf bergman}}
2
3 Unfortunately {\bf bergman} hasn't so many special debugging tools
4 and in the most cases only the usual Lisp error handling system
5 can be applied. Let us take an example containing several input errors
6 and follow the debugging steps trying to correct them. Suppose, you
7 are preparing
8 an input file and the list of polynomials is huge. Of course, it is quite
9 easy to make some errors in its typing. Here we have a fragment of
10 such a list,
11 it is extracted from a real problem offered by prof.M.Popa.
12
13 \begin{verbatim}
14 (setmaxdeg 10)
15 (algforminput)
16 vars v,d,r,s,t,e,q,m,b,c,h,g,l,k,p,n,a;
17 g*q^3+h*p^3-k^2*l^2,
18 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+
19 2*g*p^3+2*k^4,
20 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+
21 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-
22 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+
23 12*e^4*h+12*g*s^4-12*k^2*n^3-6*k^2*p^3,
24 -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+
25 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,
26 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+
27 2*g^2*p^3+4*k^2*q^3-2*l^2*n^3-2*m^2*p^3,
28 -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+
29 2*c^3*g*h-10*g^2*p^3-6*g*k^2-8*k^2*q^3+4*l^2*n^3+
30 8*l^2*p^3+4*m^2*p^3,
31 -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+
32 4*g*k^4+4*g*t^4-2*h*s^4+2*l^2*n^3-8*l^2*p^3,
33 -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+
34 12*g*k^4+12*g*t^4-6*k^2*q^3-18*l^2*p^3+6*m^2*p^3,
35 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+
36 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,
37 18*a^12-81*a^10*b^2+189*a^8*b^4+108*a^8*e^4-279*a^6*b^6-
38 108*a^6*b^2*e^4-30*a^6*c^6+96*a^6*c^3*d^3-12*a^6*d^6-
39 144*a^6*f^6+243*a^4*b^8-324*a^4*b^4*e^4+162*a^4*b^2*c^6-
40 432*a^4*b^2*c^3*d^3+108*a^4*b^2*d^6+324*a^4*b^2*f^6-
41 108*a^2*b^10+540*a^2*b^6*e^4-198*a^2*b^4*c^6+
42 504*a^2*b^4*c^3*d*3-144*a^2*b^4*d^6-432*a^2*b^4*f^6-
43 648*a^2*b^2*e^8+288*a^2*c^6*e^4-144*a^2*c^3*d^3*e^4-
44 144*a^2*d^6*e^4-432*a^2*e^4*f^6+18*b^12-216*b^8*e^4+
45 66*b^6*c^6-168*b^6*c^3*d^3+48*b^6*d^6+144*b^6*f^6+
46 648*b^4*e^8-720*b^2*c^6*e^4+1008*b^2*c^3*d^3*e^4-
47 288*b^2*d^6*e^4-864*b^2*e^4*f^6+128*c^12-416*c^9*d^3+
48 480*c^6*d^6+264*c^6*f^6-224*c^3*d^9-672*c^3*d^3*f^6+
49 32*d^12+192*d^6*f^6-2592*e^12+288*f^12,
50 -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;
51 \end{verbatim}
52
53 The first attempt to compute it (working in the Reduce version) failed:
54
55 \begin{verbatim}
56 Entering LISP ...
57 Bergman 0.931, 23-Oct-99
58 1 lisp> (simple "tests/inv.err")
59 10
60 *****
61 dskin of `tests/inv.err' aborted after 1 form(s).
62 ***** Segmentation Violation
63 2 lisp>
64 \end{verbatim}
65
66 The yielded error message ''Segmentation Violation'' is not very informative.
67 One can obtain more information using the possibility of tracing,
68 offered by LISP. According to the PSL documentation, ''the error
69 handler typically calls an interactive break loop, which permits
70 the user to examine the context of the error and optionally make
71 some corrections and continue the computation, or to abort the
72 computation.''
73
74 If we are in {\bf bergman} compiled under PSL the break loop is coming
75 immediately:
76
77 \begin{verbatim}
78 1 lisp> (simple "tests/inv.err")
79 10
80 *****
81 ***** Continuable error.
82 Break loop
83 2 lisp break (1) >
84 \end{verbatim}
85
86 Being in the Reduce version one should switch on the corresponding flag
87 before the computation:
88
89 \begin{verbatim}
90 Entering LISP ...
91 Bergman 0.931, 23-Oct-99
92 1 lisp> (on break)
93 nil
94 2 lisp> (simple "tests/inv.err")
95 10
96 *****
97 Break loop
98 3 lisp break (1) >
99 \end{verbatim}
100
101 Now we have similar situations in both cases and can start the
102 debugging. First of all, we
103 can use the tracing to locate the erroneous place. So, let us try
104 some of the break loop commands, for example, {\bf T}:
105
106 \begin{verbatim}
107 1 lisp> (simple "tests/inv.err")
108 10
109 *****
110 ***** Continuable error.
111 Break loop
112 2 lisp break (1) > T
113 Backtrace from top of stack:
114 backtrace top!-loop!-eval!-and!-print continuableerror
115 a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E
116 p!O!La!L!Gr!E!A!D algforminput dskin!-step
117 unprotected!-dskin!-stream
118 dskin!-stream dskin simple top!-loop!-eval!-and!-print
119 standardlisp
120 nil
121 \end{verbatim}
122
123 Looking on this information we can presume, that something is wrong with
124 the input, because the {\it continuableerror} was created by\\
125 a!L!G!I!Nr!E!A!De!R!...\\
126 followed by p!O!La!L!Gr!E!A!D. Continuing investigation we can use the ``V''
127 option:
128
129 \begin{verbatim}
130 3 lisp break (1) > V
131 \end{verbatim}
132
133 Omitting a part of output, which seems to be not very understandable,
134 let us pay attention to the following strings:
135
136 \begin{verbatim}
137 a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E -> continuableerror:
138 p!O!La!L!Gr!E!A!D -> a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E:
139 18
140 f
141 \end{verbatim}
142
143 ''18'' is the number of input variables. What is ''f''? One of the input
144 variables, why it appears here? It seems, it is treated in a
145 special manner, but why? Checking the list of input variables one can
146 see that it is absent in the
147 {\bf vars}
148 list! So, we found one error and should correct it inserting the
149 variable ''f''.
150
151 Starting the computation again we obtain, unfortunately, a new continuable
152 error and try to repeat the debugging process. Among the information
153 obtained after the applying of ``V'' option one should pick out the
154 following strings:
155
156 \begin{verbatim}
157 a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E -> continuableerror:
158 p!O!La!L!Gr!E!A!D -> a!L!G!I!Nr!E!A!De!R!Rm!E!S!S!A!G!E:
159 18
160 3
161 nil
162 504
163 \end{verbatim}
164
165 504 is one of the coefficients of the 11th polynomial, it is the
166 largest one
167 and we may expect some troubles here. Searching the input file we find
168 the monomial with such a coefficient:
169
170 \begin{verbatim}
171 504*a^2*b^4*c^3*d*3
172 \end{verbatim}
173
174 An error occurred because the sign \verb-''^''- on the end of monomial
175 was mistyped.
176 After its correction we try again:
177
178 \begin{verbatim}
179 1 lisp> (simple "tests/inv.err")
180 10
181 t
182 % 4
183 q^3*g-l^2*k^2+h*p^3,
184 2*c^3*h-b^2*g^2+2*k^4+2*g*p^3-4*g*n^3+2*m^2*a^2+
185 2*g^2*a^2-2*l^2*a^2,
186 % 5
187 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+
188 g^3*a^2-2*g*l^2*a^2-2*h*k^2*a^2,
189 -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-
190 g^3*a^2+2*g*l^2*a^2+2*h*k^2*a^2,
191 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-
192 m^2*g*a^2+g^3*a^2-g*l^2*a^2-2*h*k^2*a^2,
193 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-
194 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+
195 3*g^3*a^2+5*g*l^2*a^2-2*h*k^2*a^2,
196 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-
197 6*k^2*p^3-6*q^3*a^2+3*g*k^2*a^2,
198 -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-
199 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-
200 6*r^3*a^2+5*m^2*g*a^2-5*g*l^2*a^2+2*h*k^2*a^2,
201 -6*m^2*c^3+12*e^4*h+2*d^3*g^2-2*c^3*g^2+6*c^3*l^2-
202 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,
203
204 ***** Segmentation Violation
205 Break loop
206 2 lisp break (1) >
207 \end{verbatim}
208
209
210 The computation started, but something was wrong. The input data were
211 successfully read , the computation started ... What happened? One of
212 the most frequent error is non-homogeneity. To check it we can use,
213 as previously, the tracing, but there is a special {\bf bergman} function
214 \index{testindata} {\bf testindata} to help us in debugging.
215 This function tests the homogeneity of
216 input polynomials. It should be called immediately after the input
217 (before starting the computation), for example:
218
219 \begin {verbatim}
220
221 1 lisp> (dskin "tests/inv.err")
222 10
223 t
224 nil
225 2 lisp> (testindata)
226 ((4 4) (5 5 nil 5 5 5 5) (6 6) (12))
227 \end{verbatim}
228
229 The function prints the list of monomial's degrees, the value {\bf nil}
230 shows that one of the polynomials in degree 5 is not homogeneous.
231 In our example it is the monomial
232
233 \begin{verbatim}
234 -6*g*k^2
235 \end{verbatim}
236
237 in the 7th polynomial (there is another question how to locate it
238 using Lisp). After its correction we can re-start the computations and
239 are lucky to see the result, which is too large and not so interesting
240 to be included here.
241
242
243 One more {\bf bergman} function to help you on debugging is {\bf getsetup}
244 which displayed some useful information:
245
246 \begin{verbatim}
247
248 3 lisp> (getsetup)
249 ((objecttype ring (autoaddrelationstate nil nil))
250 (resolutiontype none)
251 (variablesetup
252 (ringtype commutative)
253 (commutativeorder tdegrevlex)
254 (noncommutativeorder tdegleftlex)
255 (variablenumber 18)
256 (invariables (v d r s t e q m f b c h g l k p na))
257 (outvariables (v d r s t e q m f b c h g l k p n a))
258 (variableweights nil))
259 (strategy
260 (mindeg nil)
261 (maxdeg 10)
262 (interruption ordinary))
263 (coefficientdomain nil (oddprimesmoduli ordinary))
264 (inputformat casesensalgin)
265 (outputformat algexptsprint)
266 (variousflags
267 (custshow off)
268 (custstrategy off)
269 (degreeprintoutput off)
270 (dynamiclogtables off)
271 (homogenised off)
272 (immediatecrit off)
273 (immediatefullreduction on)
274 (immediaterecdefine off)
275 (nobignum off)
276 (obsoletenamesinform off)
277 (oldprintmodes1 off)
278 (oldseriesmodes1 on)
279 (standardanickmodes on)
280 (pbseries off)
281 (reductivity on)
282 (savedegree off)
283 (saverecvalues on)))
284
285 \end{verbatim}
286
287 One can check the values of the polynomial ring set up:
288
289 \begin{itemize}
290 \item ring type (in our example: {\bf (ringtype commutative)}),
291 \item ordering (in our example: {\bf (commutativeorder
292 tdegrevlex)}),
293 \item characteristic (in our example: {\bf (coefficientdomain nil
294 (odd\-pri\-mes\-moduli ordinary))} corresponds to characteristic 0),
295 \item number, list of input and output variables, their weights
296 {\bf (variable\-weights nil)} in our example means the
297 naturally graded list).
298 \end{itemize}
299
300
301 Besides that we can see the set up of:
302
303 \begin{itemize}
304 \item strategy,
305 \item resolution type,
306 \item maximal and minimal degrees,
307 \item input and output formats (in our example: case sensitive
308 algebraic form input and algebraic form output where the exponents
309 values are printed explicitly),
310 \item various flags, their meaning is explained in the manual.
311 \end{itemize}
312
313
314
315
316 %PRINTNEXT - a new debugging procedure to be described in this
317 %section.
318
319
320 %printsetup, getsetup