Debian Codegraph @

tests/prep/0206tests/tmpexport/aninterf.sl

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % Implementation of initial the Anick resolution routines.
4 %
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 %% Copyright (C) 1996
9 %% Alexander Podoplelov (and Joergen Backelin ?)
10 %%
11 %% Bergman and Anick are distributed in the hope that they will be
12 %% useful, but WITHOUT ANY WARRANTY. No author or distributor
13 %% accepts responsibility to anyone for the consequences of using them
14 %% or for whether they serve any particular purpose or work at all,
15 %% unless (s)he says so in writing. Refer to the Bergman General
16 %% Public License for full details.
17
18 %% Everyone is granted permission to copy, modify and redistribute
19 %% bergman, but only under the conditions described in the
20 %% Bergman General Public License. A copy of this license is
21 %% supposed to have been given to you along with bergman so you
22 %% can know your rights and responsibilities. It should be in a
23 %% file named copyright. Among other things, the copyright notice
24 %% and this notice must be preserved on all copies.
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
27
28 (OFF RAISE)
29
30 % anOutChan
31 % This variable contains the output channel handler for
32 % printing Anick related information into the result file.
33 %
34 % anDIFFTIME
35 % After the Anick resolution is calculated it contain the time
36 % consumed by calculations for differentials in milliseconds.
37 %
38 % anBETTITIME
39 % After Anick resolution is calculated it contain the time
40 % consumed by calculations for Betti numbers.
41 %
42 % anBETTINUMS
43 % This variable is a list of Betti numbers. Each Betti number
44 % is of the structure ((order:int . degree:int) . value:int)
45 %
46 % ANICKRESOLUTIONOUTPUTFILE
47 % Is equal to the name of output file. In case it equals to NIL,
48 % the output channel will be associated with the file name
49 % "andifres.txt".
50 %
51 % anLASTCALCULATEDDEGREE
52 % Equals the last degree for which the anifResolutionFixDegree
53 % procedure was called.
54 (GLOBAL '(anCHAINS anbnmSORTEDCHAINS anNEWCHAINS anOutChan cGBasis
55 GBasis cDeg anBETTINUMS anCURRENTBETTINUMS !*PBSERIES
56 !*CALCBETTI !*ONFLYBETTI anDIFFTIME anBETTITIME
57 anBETTINUMS ANICKRESOLUTIONOUTPUTFILE
58 anLASTCALCULATEDDEGREE bnmLeftModuleNormalWords anbnmTensorMons
59 anbnmTensorMonsAccess anbnmNewTensorMonsAccess
60 SObeg SOmid SOend btMacMx
61 anPrintSDPMode !*anchPrintEdgeString anchEdgeString!*
62 ModeProperties!* NALGGEN
63 anbnmChainStartIndexLimits anbnmChainEndIndexLimits))
64
65 (COPYD 'anPRT2 'PRIN2)
66
67 (PUT ModeProperties!* '!*CALCBETTI (FUNCTION (LAMBDA (v a) (CALCBETTI a))))
68 (PUT ModeProperties!* '!*ONFLYBETTI (FUNCTION (LAMBDA (v a) (ONFLYBETTI a))))
69
70 % SETTENSPOLPRTSTRINGS (strings:lstr) : lstr ;
71 % The list strings should consist of 3 strings which are
72 % used to print tensor product. First string is printed
73 % at the beginning, second - as a tensor multiplication sign
74 % and the third - as the ending of thensor monomial.
75 % The list of 3 strings of old settings is returned.
76 (DF SETTENSPOLPRTSTRINGS (lstr)
77 (PROG (rt)
78 (COND ( (NOT (AND (LISTP lstr) (EQ (LENGTH lstr) 3)
79 (OR (STRINGP (CAR lstr)) (IDP (CAR lstr)))
80 (OR (STRINGP (CADR lstr)) (IDP (CADR lstr)))
81 (OR (STRINGP (CADDR lstr)) (IDP (CADDR lstr)))))
82 (ERROR 2000 "Bad argument to SETTENSPOLPRTSTRING")
83 )
84 )
85 (SETQ rt (GETTENSPOLPRTSTRINGS))
86 (SETQ SObeg (CAR lstr))
87 (SETQ SOmid (CADR lstr))
88 (SETQ SOend (CADDR lstr))
89 (RETURN rt)
90 )
91 )
92
93 % GETTENSPOLPRTSTRINGS () : lstr ;
94 % Returns a list of 3 strings which are used when tensor
95 % monomials are printed as beginning, middle and ending
96 % strings.
97 (DE GETTENSPOLPRTSTRINGS () (LIST SObeg SOmid SOend) )
98
99
100 % This procedure is called from "Bergman" application once.
101 % Purpose : initialization for the Anick resolution moduls.
102 % This procedure initializes all the variables concerned with
103 % the Anick resolution. It needs information about Groebner
104 % basis generators, therefore, it should be called after the
105 % system has them.
106
107 %# ResolutionInit () : - ;
108 (DE RingResolutionInit ()
109 (PROGN
110 (PRIN2 "The Anick resolution initialization...")
111 (TERPRI)
112
113 (COND ((NOT ANICKRESOLUTIONOUTPUTFILE)
114 (SETQ ANICKRESOLUTIONOUTPUTFILE "andifres.txt")))
115 (SETQ anOutChan (OPEN ANICKRESOLUTIONOUTPUTFILE 'OUTPUT))
116 % (ON PRINTEDGESTRING)
117 % (SETEDGESTRING "*")
118 (anCONSTRUCTZEROCHAINS)
119 (SETQ anLASTCALCULATEDDEGREE 1)
120 (SETQ anDIFFTIME 0)
121 (SETQ anBETTITIME 0)
122 (SETQ SObeg "")
123 (SETQ SOmid ".")
124 (SETQ SOend "")
125 (anBETTIINIT)
126 (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
127 (SETQ anBETTITIME (TIME))
128 (anBETTI (CAR anCHAINS))
129 (SETQ anBETTITIME (DIFFERENCE (TIME) anBETTITIME))
130 (PRINTBETTI)
131 ))
132 (PRIN2 "The Anick resolution initialization done.")
133 (TERPRI)
134 )
135 )
136
137 (DE TwoModulesResolutionInit ()
138 (PROGN
139 (PRIN2 "The Anick resolution initialization (for two modules)...")
140 (TERPRI)
141
142 (COND ((NOT ANICKRESOLUTIONOUTPUTFILE)
143 (SETQ ANICKRESOLUTIONOUTPUTFILE "andifres.txt")))
144 (SETQ anOutChan (OPEN ANICKRESOLUTIONOUTPUTFILE 'OUTPUT))
145 % (ON PRINTEDGESTRING)
146 % (SETEDGESTRING "*")
147 (anCONSTRUCTZEROCHAINS)
148 (anUPDATESORTEDCHAINS 1)
149 % (anbnmSetIndexLimits)
150 (anbnmLMNWInit)
151 (SETQ anLASTCALCULATEDDEGREE 1)
152 (SETQ anDIFFTIME 0)
153 (SETQ anBETTITIME 0)
154 (SETQ SObeg "")
155 (SETQ SOmid ".")
156 (SETQ SOend "")
157 (anBETTIINIT)
158 (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
159 (SETQ anBETTITIME (TIME))
160 (anBETTI (CAR anCHAINS))
161 (SETQ anBETTITIME (DIFFERENCE (TIME) anBETTITIME))
162 (PRINTBETTI)
163 ))
164 (PRIN2 "The Anick resolution initialization done.")
165 (TERPRI)
166 )
167 )
168
169 % CALCBETTI (flag:bool) : - ;
170 % Depending on whether flag is non-NIL or not, switches on/off
171 % the calculation of Betti numbers. It sets corresponding flags.
172 % flag is a boolean T or NIL
173 (DE CALCBETTI (flag)
174 (PROGN
175 (COND ( (NULL flag)
176 (OFF CALCBETTI)
177 (OFF ONFLYBETTI)
178 )
179 (T
180 (ON CALCBETTI)
181 )
182 )%COND
183 )
184 )
185
186 % ONFLYBETTI (flag:bool) : - ;
187 % Depending on whether flag is non-NIL or not, switches on/off
188 % the calculation of Betti numbers. Also, the feature of
189 % calculating and printing them while Groebner basis is being
190 % calculated degree by degree. It sets corresponding flags.
191 (DE ONFLYBETTI (flag)
192 (PROGN
193 (COND ( (NULL flag)
194 (OFF ONFLYBETTI)
195 )
196 (T
197 (ON CALCBETTI)
198 (ON ONFLYBETTI)
199 )
200 )%COND
201 )
202 )
203
204
205 % GETBETTINUMS () : lbtnum;
206 % Returns the list of Betti numbers.
207 (DE GETBETTINUMS () (COPY anBETTINUMS))
208
209
210 % GETBTORDER (btnumber:btnum) : int ;
211 % Returns the order of Betti number btnumber.
212 (DE GETBTORDER (btnum) (CAAR btnum))
213
214 % GETBTDEGREE (btnumber:btnum) : int ;
215 % Returns the degree of Betti number btnumber.
216 (DE GETBTDEGREE (btnum) (CDAR btnum))
217
218 % GETBTVALUE (btnumber:btnum) : int ;
219 % Returns the value of Betti number btnumber.
220 (DE GETBTVALUE (btnum) (CDR btnum))
221
222
223 % For a given degree it calculates chains and the Anick
224 % resolution differentials, and prints them into the result
225 % file. It also updates related variables.
226
227 %# anifRingResolutionFixDegree (dgr:int) : - ;
228 (DE anifRingResolutionFixDegree (dgr)
229 (PROG (chp dd t1)
230 (PRIN2 "Calculating the Anick resolution in degree ")
231 (PRIN2 dgr)
232 (PRIN2 "...")
233 (TERPRI)
234
235 (UNSIGNLC!'S cGBasis)
236 (SETQ anNEWCHAINS
237 (COND ((EQN dgr cDeg)
238 (CONS cDeg (MAPCAR (CDR cGBasis)
239 (FUNCTION anNEWGBELM2CHAIN)))
240 )
241 (T
242 (NCONS dgr)
243 )
244 )%COND
245 )
246
247 (SETQ chp (CDR anCHAINS))
248 L1 (COND
249 ( chp
250 (SETQ dd (DIFFERENCE dgr (CAAR chp)))
251 (MAPC (CDAR chp) (FUNCTION (LAMBDA (u) (anCONSTRUCTNEWCHAINS u dd ))))
252 (SETQ chp (CDR chp))
253 (GO L1)
254 )
255 )%COND
256
257 (SETQ t1 (TIME))
258 (MAPC (CDR anNEWCHAINS) (FUNCTION anDIFF))
259 (SETQ anDIFFTIME (PLUS2 anDIFFTIME (DIFFERENCE (TIME) t1)))
260 % (PRINTNEWCHAINSDIFF anOutChan)
261 % (FlushChannel anOutChan)
262 (COND ( (CDR anNEWCHAINS)
263 (NCONC anCHAINS (NCONS anNEWCHAINS))))
264
265 %%%%%%%% Betti numbers calculation should be called from this point %%%%%%%
266 (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
267 (SETQ t1 (TIME))
268 (anBETTI anNEWCHAINS)
269 (SETQ anBETTITIME (PLUS2 anBETTITIME (DIFFERENCE (TIME) t1)))
270 (PRINTBETTI)
271 (MACBETTIPRINT)
272 ))
273
274 (PRIN2 "end of Calculations.")
275 (TERPRI)
276 )
277 )
278
279 %% For a given degree this calculates chains and the Anick
280 %% resolution differentials, and prints them into the result
281 %% file. It also updates related variables.
282 %
283 %%# anifModuleResolutionFixDegree (dgr:int) : - ;
284 %(DE anifModuleResolutionFixDegree (dgr)
285 % (PROG (chp dd t1 ip)
286 % (PRIN2 "Calculating the module Anick resolution in degree ")
287 % (PRIN2 dgr)
288 % (PRIN2 "...")
289 % (TERPRI)
290 %
291 % (UNSIGNLC!'S cGBasis)
292 % (SETQ chp (CDR anCHAINS))
293 %
294 % (COND ((NOT (EQN dgr cDeg))
295 % (SETQ anNEWCHAINS (NCONS dgr))
296 % (GO L1)
297 % )
298 % )
299 %
300 % (SETQ ip (CDR cGBasis))
301 % L2 (COND ((AND ip (NOT (LESSP NALGGEN (MonSignifVar (CAR ip)))))
302 % (SETQ ip (CDR ip))
303 % (GO L2)))
304 %
305 % (SETQ anNEWCHAINS
306 % (CONS cDeg (MAPCAR ip (FUNCTION anNEWGBELM2CHAIN)))
307 % )
308 %
309 %L1 (COND
310 % ( chp
311 % (SETQ dd (DIFFERENCE dgr (CAAR chp)))
312 % (MAPC (CDAR chp) (FUNCTION (LAMBDA (u) (anCONSTRUCTNEWCHAINS u dd ))))
313 % (SETQ chp (CDR chp))
314 % (GO L1)
315 % )
316 % )%COND
317 %
318 % (SETQ t1 (TIME))
319 % (MAPC (CDR anNEWCHAINS) (FUNCTION anDIFF))
320 % (SETQ anDIFFTIME (PLUS2 anDIFFTIME (DIFFERENCE (TIME) t1)))
321 %% (PRINTNEWCHAINSDIFF anOutChan)
322 %% (FlushChannel anOutChan)
323 % (COND ( (CDR anNEWCHAINS)
324 % (NCONC anCHAINS (NCONS anNEWCHAINS))))
325 %
326 %%%%%%%%% Betti numbers calculation should be called from this point %%%%%%%
327 % (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
328 % (SETQ t1 (TIME))
329 % (anBETTI anNEWCHAINS)
330 % (SETQ anBETTITIME (PLUS2 anBETTITIME (DIFFERENCE (TIME) t1)))
331 % (PRINTBETTI)
332 % (MACBETTIPRINT)
333 % ))
334 %
335 % (PRIN2 "end of Calculations.")
336 % (TERPRI)
337 % )
338 %)
339
340
341
342 % For a given degree this calculates chains and the Anick
343 % resolution differentials, and prints them into the result
344 % file. It also updates related variables.
345
346 % Meaning of PROG variables: CHain list Position; Degree Difference;
347 % Time spent; InPut; Return list Position;
348 % Last Chain Start variable index; First Chain End variable index;
349 % Last Chain End variable index
350 %# anifTwoModulesResolutionFixDegree (dgr:int) : - ;
351 (DE anifTwoModulesResolutionFixDegree (dgr)
352 (PROG (chp dd t1 ip rp lcs fce lce)
353 (PRIN2 "Calculating the module Anick resolution in degree ")
354 (PRIN2 dgr)
355 (PRIN2 "...")
356 % (PRIN2 "... with lcs = ")
357 (TERPRI)
358
359 (UNSIGNLC!'S cGBasis)
360 (SETQ chp (CDR anCHAINS))
361 (SETQ lcs (CDR anbnmChainStartIndexLimits))
362 (SETQ fce (CAR anbnmChainEndIndexLimits))
363 (SETQ lce (CDR anbnmChainEndIndexLimits))
364 % (PRIN2 lcs)
365 % (TERPRI)
366
367 (COND ((NOT (EQN dgr cDeg))
368 (SETQ anNEWCHAINS (NCONS dgr))
369 (GO L1)
370 )
371 )
372
373 (SETQ ip (CDR cGBasis))
374 L2 (COND ((AND ip (NOT (BMI!< NALGGEN (MonSignifVar (CAR ip)))))
375 (SETQ ip (CDR ip))
376 (GO L2)))
377
378 (SETQ rp (SETQ anNEWCHAINS (NCONS dgr)))
379
380 L3
381 % (PRIN2 "At L3; ip ")
382 % (COND ((NOT ip) (PRIN2T "is empty."))
383 % (T (PRIN2 "begins with the G.b.elt. with leadmon = ")
384 % (AlgPMonPrint (PMon (CAR ip))) (TERPRI)
385 % (PRIN2 "(MonSignifVar (CAR ip)) = ")
386 % (PRIN2 (MonSignifVar (CAR ip)))
387 % (PRIN2 "; and (MonLeastSignifVar (CAR ip)) = ")
388 % (PRIN2 (MonLeastSignifVar (CAR ip)))
389 % (PRIN2T ".")))
390 (COND ((OR (NOT ip) (BMI!< lcs (MonSignifVar (CAR ip))))
391 (GO L1))
392 ((NOT (OR (BMI!> (MonLeastSignifVar (CAR ip)) lce)
393 (BMI!< fce (MonLeastSignifVar (CAR ip)))))
394 % (PRIN2T "Am creating chain for this monome.")
395 (RPLACD rp (NCONS (anNEWGBELM2CHAIN (CAR ip))))
396 (SETQ rp (CDR rp))))
397 (SETQ ip (CDR ip))
398 (GO L3)
399
400 L1 (COND
401 ( chp
402 (SETQ dd (DIFFERENCE dgr (CAAR chp)))
403 (MAPC (CDAR chp) (FUNCTION (LAMBDA (u) (anCONSTRUCTNEWCHAINS u dd ))))
404 (SETQ chp (CDR chp))
405 (GO L1)
406 )
407 )%COND
408
409 (SETQ t1 (TIME))
410 (MAPC (CDR anNEWCHAINS) (FUNCTION anDIFF))
411 (SETQ anDIFFTIME (PLUS2 anDIFFTIME (DIFFERENCE (TIME) t1)))
412 % (PRINTNEWCHAINSDIFF anOutChan)
413 % (FlushChannel anOutChan)
414 (COND ( (CDR anNEWCHAINS)
415 (NCONC anCHAINS (NCONS anNEWCHAINS))
416 (anUPDATESORTEDCHAINS dgr)))
417
418 %%%%%%%% Betti numbers calculation should be called from this point %%%%%%%
419 (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
420 (SETQ t1 (TIME))
421 (anBETTI anNEWCHAINS)
422 (SETQ anBETTITIME (PLUS2 anBETTITIME (DIFFERENCE (TIME) t1)))
423 (PRINTBETTI)
424 (MACBETTIPRINT)
425 ))
426
427 (PRIN2 "end of Calculations.")
428 (TERPRI)
429 )
430 )
431
432
433
434 % For a given degree this calculates chains and the Anick
435 % resolution differentials, and prints them into the result
436 % file. It also updates related variables.
437
438 %# anifModuleResolutionFixDegree (dgr:int) : - ;
439 (DE anifModuleResolutionFixDegree (dgr)
440 (PROG (chp dd t1 ip rp)
441 (PRIN2 "Calculating the module Anick resolution in degree ")
442 (PRIN2 dgr)
443 (PRIN2 "...")
444 (TERPRI)
445
446 (UNSIGNLC!'S cGBasis)
447 (SETQ chp (CDR anCHAINS))
448
449 (COND ((NOT (EQN dgr cDeg))
450 (SETQ anNEWCHAINS (NCONS dgr))
451 (GO L1)
452 )
453 )
454
455 (SETQ ip (CDR cGBasis))
456 L2 (COND ((AND ip (NOT (LESSP NALGGEN (MonSignifVar (CAR ip)))))
457 (SETQ ip (CDR ip))
458 (GO L2)))
459
460 (SETQ rp (SETQ anNEWCHAINS (NCONS dgr)))
461
462 L3 (COND ((AND ip (NOT (LESSP (CDR anbnmChainStartIndexLimits)
463 (MonSignifVar (CAR ip)))))
464 (RPLACD rp (NCONS (anNEWGBELM2CHAIN (CAR ip))))
465 (SETQ rp (CDR rp))
466 (SETQ ip (CDR ip))
467 (GO L3)))
468
469 L1 (COND
470 ( chp
471 (SETQ dd (DIFFERENCE dgr (CAAR chp)))
472 (MAPC (CDAR chp) (FUNCTION (LAMBDA (u) (anCONSTRUCTNEWCHAINS u dd ))))
473 (SETQ chp (CDR chp))
474 (GO L1)
475 )
476 )%COND
477
478 (SETQ t1 (TIME))
479 (MAPC (CDR anNEWCHAINS) (FUNCTION anDIFF))
480 (SETQ anDIFFTIME (PLUS2 anDIFFTIME (DIFFERENCE (TIME) t1)))
481 % (PRINTNEWCHAINSDIFF anOutChan)
482 % (FlushChannel anOutChan)
483 (COND ( (CDR anNEWCHAINS)
484 (NCONC anCHAINS (NCONS anNEWCHAINS))))
485
486 %%%%%%%% Betti numbers calculation should be called from this point %%%%%%%
487 (COND ( (AND !*CALCBETTI !*ONFLYBETTI)
488 (SETQ t1 (TIME))
489 (anBETTI anNEWCHAINS)
490 (SETQ anBETTITIME (PLUS2 anBETTITIME (DIFFERENCE (TIME) t1)))
491 (PRINTBETTI)
492 (MACBETTIPRINT)
493 ))
494
495 (PRIN2 "end of Calculations.")
496 (TERPRI)
497 )
498 )
499
500 % PRINTNEWCHAINSDIFF (chan:genint) : - ;
501 % Prints differentials for the new generated chains
502 % to the channel chan
503 (DE PRINTNEWCHAINSDIFF (chan)
504 (PROG (OldChan oldLL)
505 (SETQ OldChan (WRS chan))
506 (SETQ oldLL (LINELENGTH 1024))
507 (MAPC (CDR anNEWCHAINS)
508 (FUNCTION (LAMBDA (u)
509 (MAPC (CDR u)
510 (FUNCTION PRTCHNDIFF)))
511 )
512 )
513 (WRS OldChan)
514 (LINELENGTH oldLL)
515 )
516 )
517
518 % PRINTCHAINSDIFF (chan:genint) : - ;
519 % Prints differentials for the all generated chains
520 % to the channel chan
521 (DE PRINTCHAINSDIFF (chan)
522 (PROG (OldChan oldLL)
523 (SETQ OldChan (WRS chan))
524 (SETQ oldLL (LINELENGTH 1024))
525 (MAPC anCHAINS
526 (FUNCTION (LAMBDA (u)
527 (MAPC (CDR u)
528 (FUNCTION PRTCHNDIFF)))
529 )
530 )
531 (WRS OldChan)
532 (LINELENGTH oldLL)
533 )
534 )
535
536
537 % PRTCHNDIFF (inchain:chn) : - ;
538 % Prints differential for the chain inchain in form
539 % D (chain length, chain) = differential
540 (DE PRTCHNDIFF (chn)
541 (PROG (diff)
542 (PRIN2 "D(")
543 (PRIN2 (anChn2Length chn))
544 (PRIN2 ", ")
545 (PRINTCHAIN chn)
546 (PRIN2 ")=")
547 (COND ( (NULL (SETQ diff (anChn2Diff chn))) (PRIN2 "Nil"))
548 (T (PRETTYPRINTSDP diff))
549 )
550 (TERPRI)
551 )
552 )
553
554
555
556
557 % ResolutionFixcDegEnd () : - ;
558 % Applies the procedure anifResolutionFixDegree for
559 % all the degrees which has to be fixed in anifResolutionFixDegree
560 % sense.
561 (DE ResolutionFixcDegEnd ()
562 (PROG ()
563 Ml (COND ((LESSP anLASTCALCULATEDDEGREE cDeg)
564 (SETQ anLASTCALCULATEDDEGREE (ADD1 anLASTCALCULATEDDEGREE))
565 (anifResolutionFixDegree anLASTCALCULATEDDEGREE)
566 (GO Ml)
567 )
568 )
569 )
570 )
571
572 % ResolutionDone () : - ;
573 % Closes the output stream used in Anick related procedures.
574 %%% Wind up procedure, closes all the streams
575 (DE ResolutionDone()
576 (PROG (OldChan)
577 (COND ( (NOT (NULL anOutChan))
578 (PRIN2 "Closing the streams.")
579 (CLOSE anOutChan)
580 (SETQ anOutChan NIL)
581 )
582 )
583 )
584 )
585
586
587 % ResolutionClear () : - ;
588 % Cleans up all the Anick related variables including Betti
589 % numbers.
590 (DE ResolutionClear ()
591 (PROGN (PRIN2 "Cleaning the varibles") (TERPRI)
592 (SETQ anLASTCALCULATEDDEGREE NIL)
593 (SETQ anCHAINS NIL)
594 (SETQ anNEWCHAINS NIL)
595 (SETQ anBETTINUMS (NCONS NIL))
596 (SETQ anCURRENTBETTINUMS NIL)
597 (SETQ anbnmSORTEDCHAINS NIL)
598 (SETQ bnmLeftModuleNormalWords NIL)
599 (SETQ anbnmTensorMons NIL)
600 (SETQ anbnmTensorMonsAccess NIL)
601 (SETQ anbnmNewTensorMonsAccess NIL)
602 (SETQ btMacMx NIL)
603 (SETQ anDIFFTIME 0)
604 (SETQ anBETTITIME 0)
605 )
606 )
607
608 % CLEARRESOLUTION () : - ;
609 % Calls ResolutionDone and ResolutionClear procedures.
610 (DE CLEARRESOLUTION ()
611 (PROGN
612 (ResolutionDone)
613 (ResolutionClear)
614 )
615 )
616
617
618 % ANICKDISPLAY () : - ;
619 % Prints the Betti numbers into the result file.
620 (DE ANICKDISPLAY ()
621 (PROG (OldChan oldLL)
622 (COND ( (BETTICALC)
623 (PRIN2 "Printing the results ...")
624 (TERPRI)
625 (SETQ OldChan (WRS anOutChan))
626 (SETQ oldLL (LINELENGTH 1024))
627 (MAPC anCHAINS
628 (FUNCTION (LAMBDA (u)
629 (MAPC (CDR u)
630 (FUNCTION PRTCHNDIFF)))
631 )
632 )
633 (PRINTBETTI)
634 (MACBETTIPRINT)
635 (WRS OldChan)
636 (PRIN2 "Printing is done.")
637 (TERPRI)
638 (LINELENGTH oldLL)
639 )
640 )
641 )
642 )
643
644 % BETTICALC () : bool ;
645 % Returns true if the system is configured to calculate Betti numbers.
646 (DE BETTICALC ()
647 (COND ( (AND !*CALCBETTI (NOT !*ONFLYBETTI))
648 (anALLBETTI) T)
649 ( T
650 !*CALCBETTI)
651 )
652 )
653
654 % CALCULATEANICKRESOLUTIONTOLIMIT (limdeg:int) : - ;
655 % Countinues the process of Anick resolution calculation up to
656 % the degree limdeg. It maybe called after the Groebner basis is
657 % calculated, in case it is finite and calculations stopped
658 % at a lower degree than thatonto which the Anick resolution
659 % should be calculated.
660 (DE CALCULATEANICKRESOLUTIONTOLIMIT (limdeg)
661 (PROG ()
662 (COND ((OR (NOT GBasis) (NOT !*PBSERIES))
663 (ERROR 1001 "You cannot call CALCULATEANICKRESOLUTIONTOLIMIT now")
664 )
665 ((NOT anLASTCALCULATEDDEGREE)
666 (ResolutionInit)
667 )
668 )
669 Ml (COND ((LESSP anLASTCALCULATEDDEGREE limdeg)
670 (SETQ anLASTCALCULATEDDEGREE (ADD1 anLASTCALCULATEDDEGREE))
671 (anifResolutionFixDegree anLASTCALCULATEDDEGREE)
672 (GO Ml)
673 )
674 )
675 )
676 )
677
678
679 % Mode settings.
680
681 % ExtractAnickModes () : lmodestate ;
682 % Returns the list of modestates.
683 (DE ExtractAnickModes ()
684 (MAPCAN '(anExtractTPModes anExtractChnModes anExtractBettiModes)
685 (FUNCTION (LAMBDA (u) (APPLY u NIL)))))
686
687 % RestoreAnickModes (modeinfo:lmodestate) : - ;
688 % Restores modestates supplied by modeinfo.
689 (DE RestoreAnickModes (modeinfo)
690 (PROG (modes dp fn)
691 (SETQ modes '( (TENSPOL!-PRINTMODE . anPrintSDPMode)
692 (TENSTERM!-PRINTMODE . TENSTERM!-PRINTMODE)
693 (EDGE!-STRING . anchEdgeString!*)
694 (EDGE!-STRING!-PRINTING . !*anchPrintEdgeString)
695 (BETTI . !*CALCBETTI)
696 (BETTI-FOREACHDEGREE . !*ONFLYBETTI)
697 )
698 )
699 % (CheckModes (modeinfo))
700 L1 (COND ( (NULL modeinfo) (RETURN NIL) )
701 ( T
702 (SETQ dp (ASSOC (CAAR modeinfo) modes))
703 (COND ( (NULL dp)
704 (PRIN2 "Variable name ")
705 (PRIN2 (CAAR modeinfo))
706 (PRIN2 " is not valid, skipping it.")
707 (TERPRI)
708 )
709 (T
710 (SETQ fn (GET ModeProperties!* (CDR dp)))
711 (COND ( (NULL fn)
712 % Direct assignment
713 (SET (CDR dp) (CADAR modeinfo))
714 )
715 (T
716 % Invoking property function
717 (APPLY fn (LIST (CDR dp) (CADAR modeinfo)))
718 )
719 )%COND
720
721 )
722 )%COND
723 )
724 )%COND
725 (SETQ modeinfo (CDR modeinfo))
726 (GO L1)
727 )
728 )
729
730 %# AnickRingObject () : - ;
731 (DE AnickRingObject ()
732 (PROGN (COPYD 'anifResolutionFixDegree 'anifRingResolutionFixDegree)
733 (COPYD 'ResolutionInit 'RingResolutionInit)
734 (COPYD 'anBETTI 'anRingBETTI)
735 (COPYD 'anCONSTRUCTNEWCHAINS 'anRingCONSTRUCTNEWCHAINS) ))
736
737 %# AnickModuleObject () : - ;
738 (DE AnickModuleObject ()
739 (PROGN (COPYD 'anifResolutionFixDegree 'anifModuleResolutionFixDegree)
740 (COPYD 'ResolutionInit 'RingResolutionInit)
741 (COPYD 'anBETTI 'anRingBETTI)
742 (COPYD 'anCONSTRUCTNEWCHAINS 'anRingCONSTRUCTNEWCHAINS) ))
743
744 %# AnickTwoModulesObject () : - ;
745 (DE AnickTwoModulesObject ()
746 (PROGN (COPYD 'anifResolutionFixDegree 'anifTwoModulesResolutionFixDegree)
747 (COPYD 'ResolutionInit 'TwoModulesResolutionInit)
748 (COPYD 'anBETTI 'anTwoModulesBETTI)
749 (COPYD 'anCONSTRUCTNEWCHAINS 'anTwoModulesCONSTRUCTNEWCHAINS)))
750
751 %# AnickFactAlgObject () : - ;
752 (DE AnickFactAlgObject ()
753 (PROGN (COPYD 'anifResolutionFixDegree 'anifModuleResolutionFixDegree)
754 (COPYD 'ResolutionInit 'RingResolutionInit)
755 (COPYD 'anBETTI 'anRingBETTI)
756 (COPYD 'anCONSTRUCTNEWCHAINS 'anRingCONSTRUCTNEWCHAINS) ))
757
758 (PROG (tmp)
759 (SETQ tmp (AND (DEFP 'GETOBJECTTYPE) (GETOBJECTTYPE)))
760 (COND ((EQ tmp 'MODULE) (AnickModuleObject))
761 ((EQ tmp 'TWOMODULES) (AnickTwoModulesObject))
762 ((EQ tmp 'FACTORALGEBRA) (AnickFactAlgObject))
763 (T (AnickRingObject))) )
764
765 (ON RAISE)
766