source: git/Singular/LIB/schreyer.lib @ 8b368ff

spielwiese
Last change on this file since 8b368ff was 8b368ff, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Minor chages + defaults
  • Property mode set to 100644
File size: 56.2 KB
Line 
1///////////////////////////////////////////////////////////////////////////
2version="version schreyer.lib 4.0.0.0 Jun_2013 "; // $Id$
3category="General purpose";
4info="
5LIBRARY: schreyer.lib     Helpers for computing a Schreyer resolution in @code{derham.lib}
6AUTHOR:  Oleksandr Motsak <U@D>, where U={motsak}, D={mathematik.uni-kl.de}
7KEYWORDS: Schreyer ordering; Schreyer resolution; syzygy
8OVERVIEW:
9@* The library contains helper procedures for computing a Schreyer resoltion (cf. [SFO]),
10   originally meant to be used by @code{derham.lib} (which requires resolutions over the homogenized Weyl algebra).
11   The library works both in the commutative and non-commutative setting (cf. [MO]).
12   Here, we call a free resolution a Schreyer resolution if each syzygy module is given by a Groebner basis
13   with respect to the corresponding Schreyer ordering.
14   A Schreyer resolution can be much bigger than a minimal resolution of the same module, but may be easier to construct.
15@* The input for the resolution computations is a set of vectors @code{M} in form of a module over some basering @code{R}.
16   The ring @code{R} may be non-commutative, in which case the ring ordering should be global.
17@* These procedures produce/work with partial Schreyer resolutions of @code{(R^rank(M))/M} in form of
18   a ring (endowed with a special ring ordering that will be extended in the course of a resolution computation)
19   containing a list of modules @code{RES} and a module @code{MRES}:
20@* The list of modules @code{RES} contains the images of maps (also called syzygy modules) substituting the
21   computed beginning of a Schreyer resolution, that is, each syzygy module is given by a Groebner basis
22   with respect to the corresponding Schreyer ordering.
23@* The list @code{RES} starts with a zero map given by @code{rank(M)} zero generators indicating that the image of
24   the first differential map is zero. The second map @code{RES[2]} is given by @code{M}, which indicates that
25   the resolution of @code{(R^rank(M))/M} is being computed.
26@* The module @code{MRES} is a direct sum of modules from @code{RES} and thus comprises all computed differentials.
27@* Syzygies are shifted so that @code{gen(i)} is mapped to @code{MRES[i]} under the differential map.
28@* The Schreyer ordering succesively extends the starting module ordering on @code{M} (defined in Singular by the basering @code{R})
29   and is extended to higher syzygies using the following definition:
30@*        a < b if and only if (d(a) < d(b)) OR ( (d(a) = d(b) AND (comp(a) < comp(b)) ),
31@* where @code{d(a)} is the image of a under the differential (given by @code{MRES}),
32   and @code{comp(a)} is the module component, for any module terms @code{a} and @code{b} from the same higher syzygy module.
33REFERENCES:
34[SFO] Schreyer, F.O.: Die Berechnung von Syzygien mit dem verallgemeinerten Weierstrassschen Divisionssatz,
35      Master's thesis, Univ. Hamburg, 1980.
36[MO]  Motsak, O.: Non-commutative Computer Algebra with applications: Graded commutative algebra and related
37      structures in Singular with applications, Ph.D. thesis, TU Kaiserslautern, 2010
38
39NOTE:  requires the dynamic or built-in module @code{syzextra}
40
41PROCEDURES:
42  Sres(M,len)     compute Schreyer resolution of module M of maximal length len
43  Ssyz(M)         compute Schreyer resolution of module M of length 1
44  Scontinue(len)  extend currently active resolution by (at most) len syszygies
45";
46
47static proc prepareSyz( module I, list # )
48{
49  int i;
50  int k = 0;
51  int r = nrows(I);
52  int c = ncols(I);
53
54
55  if( size(#) > 0 )
56  {
57    if( typeof(#[1]) == "int" || typeof(#[1]) == "bigint" )
58    {
59      k = #[1];
60    }
61  }
62
63  if( k < r )
64  {
65    "// *** Wrong k: ", k, " < nrows: ", r, " => setting k = r = ", r;
66    k = r;
67  }
68
69//   "k: ", k;  "c: ", c;   "I: ", I;
70
71  for( i = c; i > 0; i-- )
72  {
73    I[i] = I[i] + gen(k + i);
74  }
75
76//  DetailedPrint(I);
77
78  return(I);
79}
80
81static proc separateSyzGB( module J, int c )
82{
83  module II, G; vector v; int i;
84
85  J = simplify(J, 2);
86
87  for( i = ncols(J); i > 0; i-- )
88  {
89    v = J[i];
90    if( leadcomp(v) > c )
91    {
92      II[i] = v;
93    } else
94    {
95      G[i] = v; // leave only gen(i): i <= c
96    }
97  }
98
99  II = simplify(II, 2);
100  G = simplify(G, 2);
101
102  return (list(G, II));
103}
104
105static proc splitSyzGB( module J, int c )
106{
107  module JJ; vector v, vv; int i;
108
109  for( i = ncols(J); i > 0; i-- )
110  {
111    v = J[i];
112
113    vv = 0;
114   
115    while( leadcomp(v) <= c )
116    {
117      vv = vv + lead(v);
118      v  = v  - lead(v);
119    }
120
121    J[i] = vv;
122    JJ[i] = v;
123  }
124
125  J = simplify(J, 2);
126  JJ = simplify(JJ, 2);
127
128  return (list(J, JJ));
129}
130
131
132static proc Sinit(module M)
133{
134  def @save = basering;
135 
136  int @DEBUG = !system("with", "ndebug");
137  if( @DEBUG )
138  {
139    "Sinit::Input";
140    type(M);
141    DetailedPrint(M);
142    attrib(M);
143  }
144
145  int @RANK = nrows(M); int @SIZE = ncols(M);
146
147  int @IS_A_SB = attrib(M, "isSB"); // ??? only if all weights were zero?!
148
149  if( !@IS_A_SB )
150  {
151    M = std(M); // this should be faster than computing std in S (later on)
152  }
153
154  def S = MakeInducedSchreyerOrdering(1); // 1 puts history terms to the back
155  // TODO: NOTE: +1 causes trouble to Singular interpreter!!!???
156  setring S; // a new ring with a Schreyer ordering
157
158  if( @DEBUG )
159  {
160    "Sinit::StartingISRing";
161    basering;
162//    DetailedPrint(basering);
163  }
164
165  // Setup the leading syzygy^{-1} module to zero:
166  module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0)); 
167
168  module MRES = Z;
169 
170  list RES; RES[1] = Z;
171
172  module F = freemodule(@RANK);
173  intvec @V = deg(F[1..@RANK]);
174 
175  module M = imap(@save, M);
176 
177  attrib(M, "isHomog", @V);
178  attrib(M, "isSB", 1);
179
180 
181  if( @DEBUG )
182  {
183    "Sinit::SB_Input: ";
184    type(M);
185    attrib(M);
186    attrib(M, "isHomog");
187    DetailedPrint(M);
188  }
189
190  if( @DEBUG )
191  {
192    // 0^th syz. property
193    if( size(module(transpose( transpose(M) * transpose(MRES) ))) > 0 )
194    {
195      transpose( transpose(M) * transpose(MRES) );
196      "transpose( transpose(M) * transpose(MRES) ) != 0!!!";
197      $
198    }
199  }
200
201  RES[size(RES)+1] = M; // list of all syzygy modules
202  MRES = MRES, M;
203
204  attrib(MRES, "isHomog", @V); 
205
206  attrib(S, "InducionLeads", lead(M));
207  attrib(S, "InducionStart", @RANK); 
208 
209  if( @DEBUG )
210  {
211    "Sinit::MRES";
212    DetailedPrint(MRES);
213    attrib(MRES, "isHomog");
214    attrib(S);
215  }
216
217  export RES;
218  export MRES;
219  return (S);
220}
221
222static proc Sstep()
223{
224  int @DEBUG = !system("with", "ndebug");
225
226  if( @DEBUG )
227  {
228    "Sstep::NextInducedRing";
229    DetailedPrint(basering);
230
231    attrib(basering, "InducionLeads");
232    attrib(basering, "InducionStart");
233
234    GetInducedData();
235  }
236
237  // syzygy step:
238
239/*
240  // is initial weights are all zeroes!
241  def L =  lead(M);
242  intvec @V = deg(M[1..ncols(M)]);  @W;  @V;  @W = @V;  attrib(L, "isHomog", @W); 
243  SetInducedReferrence(L, @RANK, 0);
244*/
245
246//  def L =  lead(MRES);
247//  @W = @W, @V;
248//  attrib(L, "isHomog", @W); 
249
250
251  // General setting:
252//  SetInducedReferrence(MRES, 0, 0); // limit: 0!
253  int @l = size(RES);
254
255  module M = RES[@l];
256
257  module L = attrib(basering, "InducionLeads");
258  int limit = attrib(basering, "InducionStart");
259
260//  L;  limit;
261 
262  int @RANK = ncols(MRES) - ncols(M); // nrows(M); // what if M is zero?!
263
264/*
265  if( @RANK !=  nrows(M) )
266  {
267    type(MRES);
268    @RANK;
269    type(M);
270    pause();
271  }
272*/
273 
274  intvec @W = attrib(M, "isHomog");
275  intvec @V = deg(M[1..ncols(M)]);
276  @V = @W, @V;
277   
278  if( @DEBUG )
279  {
280    "Sstep::NextInput: ";
281    M;
282    deg(M[1..ncols(M)]); // no use of @W :(?
283    @RANK;   
284    DetailedPrint(MRES);
285    attrib(MRES, "isHomog"); @W;
286    deg(MRES[1..ncols(MRES)]);
287  }
288
289 
290     
291  SetInducedReferrence(L, limit, 0);
292 
293  def K = prepareSyz(M, @RANK);
294//  K;
295 
296//   attrib(K, "isHomog", @V);   DetailedPrint(K, 1000);
297
298//  pause();
299 
300  K = idPrepare(K, @RANK); // std(K); // ?
301  K = simplify(K, 2);
302
303//  K;
304
305  module N = separateSyzGB(K, @RANK)[2]; // 1^st syz. module: vectors which start in lower part (comp >= @RANK)
306
307// "N_0: "; N; DetailedPrint(N, 10);
308
309//  basering; print(@V); type(N);
310//  attrib(N, "isHomog", @V);  // TODO: fix "wrong weights"!!!? deg is wrong :(((
311  N = std(N);
312  attrib(N, "isHomog", @V);
313
314//  N;
315 
316  if( @DEBUG )
317  {
318    if( size(N) > 0 )
319    {
320      // next syz. property
321      if( size(module(transpose( transpose(N) * transpose(MRES) ))) > 0 )
322      {
323        MRES;
324
325        "N: "; N; DetailedPrint(N, 10);
326
327        "K:"; K; DetailedPrint(K, 10);
328
329        "RANKS: ", @RANK;
330
331        "transpose( transpose(N) * transpose(MRES) ) != 0!!!";
332        transpose( transpose(N) * transpose(MRES) );
333
334        "transpose(N) * transpose(MRES): ";
335        transpose(N) * transpose(MRES);
336        DetailedPrint(module(_), 2);
337        $
338      }
339    }
340  }
341 
342  RES[@l + 1] = N; // list of all syzygy modules
343 
344  MRES = MRES, N;
345  attrib(MRES, "isHomog", @V);
346
347
348  L = L, lead(N);
349  attrib(basering, "InducionLeads", L);
350
351  if( @DEBUG )
352  {
353    "Sstep::NextSyzOutput: ";
354    DetailedPrint(N);
355    attrib(N, "isHomog");
356  }
357
358}
359
360proc Scontinue(int l)
361"USAGE:  Scontinue(int len)
362RETURN:  nothing, instead it changes the currently active resolution
363PURPOSE: extends the currently active resolution by at most len syzygies
364ASSUME:  must be used within a ring returned by Sres or Ssyz
365EXAMPLE: example Scontinue; shows an example
366"
367{
368  def data = GetInducedData();
369           
370  if( (!defined(RES)) || (!defined(MRES)) || (typeof(data) != "list") || (size(data) != 2) )
371  {
372    ERROR("Sorry, but basering does not seem to be returned by Sres or Ssyz");
373  }
374  for (;  (l != 0) && (size(RES[size(RES)]) > 0); l-- )
375  {
376    Sstep();
377  }
378}
379example
380{ "EXAMPLE:"; echo = 2;
381  ring r;
382  module M = maxideal(1); M;
383  def S = Ssyz(M); setring S; S;
384  "Only the first syzygy: ";
385  RES; MRES;
386  "More syzygies: ";
387  Scontinue(10);
388  RES; MRES;
389}
390
391proc Ssyz(module M)
392"USAGE:  Ssyz(module M)
393RETURN:  ring, containing a Schreyer resolution
394PURPOSE: computes a Schreyer resolution of M of length 1 (see the library overview)
395SEE ALSO: Sres
396EXAMPLE: example Ssyz; shows an example
397"
398{
399  def S = Sinit(M); setring S;
400 
401  Sstep(); // NOTE: what if M is zero?
402
403  return (S);
404}
405example
406{ "EXAMPLE:"; echo = 2;
407  ring r;
408  module M = maxideal(1); M;
409  def S = Ssyz(M); setring S; S;
410  "Only the first syzygy: ";
411  RES;
412  MRES; // Note gen(i)
413  kill S;
414  setring r; kill M;
415
416  module M = 0;
417  def S = Ssyz(M); setring S; S;
418  "Only the first syzygy: ";
419  RES;
420  MRES;
421}
422
423proc Sres(module M, int l)
424"USAGE:  Sres(module M, int len)
425RETURN:  ring, containing a Schreyer resolution
426PURPOSE: computes a Schreyer resolution of M of length at most len (see the library overview)
427NOTE:    If given len is zero then nvars(basering) + 1 is used instead.
428SEE ALSO: Ssyz
429EXAMPLE: example Sres; shows an example
430"
431{
432  def S = Sinit(M); setring S;
433
434  if (l == 0)
435  {
436    l = nvars(basering) + 1; // not really an estimate...?!
437  }
438 
439  Sstep(); l = l - 1;
440 
441  Scontinue(l);
442 
443  return (S);
444}
445example
446{ "EXAMPLE:"; echo = 2;
447  ring r;
448  module M = maxideal(1); M;
449  def S = Sres(M, 0); setring S; S;
450  RES;
451  MRES;
452  kill S;
453  setring r; kill M;
454
455  def A = nc_algebra(-1,0); setring A;
456  ideal Q = var(1)^2, var(2)^2, var(3)^2;
457  qring SCA = twostd(Q);
458  basering;
459
460  module M = maxideal(1);
461  def S = Sres(M, 2); setring S; S;
462  RES;
463  MRES;
464}
465
466
467
468// ================================================================== //
469
470
471LIB "general.lib"; // for sort
472
473/* static proc Tail(def M) // DONE: in C++ (dyn. module: syzextra)!
474{
475  int i = ncols(M); def m;
476  while (i > 0)
477  {
478    m = M[i];
479    m = m - lead(m); // m = tail(m)   
480    M[i] = m;   
481    i--;
482  }
483  return (M);
484}*/
485
486/* static */
487proc MySort(def M)
488{
489  if( typeof( attrib(basering, "DEBUG") ) == "int" )
490  {
491    int @DEBUG = attrib(basering, "DEBUG");
492  } else
493  {
494    int @DEBUG = !system("with", "ndebug");
495  }
496
497  if( typeof( attrib(basering, "KERCHECK") ) == "int" )
498  {
499    int @KERCHECK = attrib(basering, "KERCHECK");
500  } else
501  {
502    int @KERCHECK = @DEBUG; // TODO: @SYZCHECK:(
503  }
504
505
506  if( @DEBUG )
507  {
508    "MySort:: Input: "; M;
509  }
510
511  def @N = M; Sort_c_ds(@N);
512 
513  if( @KERCHECK )
514  {
515    def iv = sort(lead(M), "c,ds", 1)[2]; // ,1 => reversed! // TODO: not needed?
516    def @M = M;
517    @M = M[iv];
518   
519    // 0^th syz. property
520    if(size(@N) * size(@M) > 0 )
521    {
522    if( size(module( matrix(module(matrix(@N))) - matrix(module(matrix(@M))) )) > 0 )
523    {
524      "@M:"; @M;
525      "@N:"; @N;
526
527      "module( matrix(@N) - matrix(@M) ): ";
528      module( matrix(@N) - matrix(@M) );
529
530      "ERROR: MySort: wrong sorting in 'MySort': @N != @M!!!";
531      $
532    }
533    }
534  }
535
536  if( @DEBUG )
537  {
538    "MySort:: Ouput: "; @N;
539  }
540 
541  return (@N);
542}
543
544
545/* static */ proc SSinit(def M)
546{
547  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
548  {
549    ERROR("Sorry: need an ideal or a module for input");
550  }
551
552  // TODO! DONE?
553  def @save = basering;
554 
555  int @DEBUG = !system("with", "ndebug");
556
557  if( typeof( attrib(SSinit, "DEBUG") ) == "int" )
558  {
559    @DEBUG = attrib(SSinit, "DEBUG");
560  }
561
562  int @SYZCHECK = @DEBUG;
563
564  if( typeof( attrib(SSinit, "SYZCHECK") ) == "int" )
565  {
566    @SYZCHECK = attrib(SSinit, "SYZCHECK");
567  }
568
569  int @KERCHECK = @SYZCHECK;
570
571  if( typeof( attrib(SSinit, "KERCHECK") ) == "int" )
572  {
573    @KERCHECK = attrib(SSinit, "KERCHECK");
574  }
575
576  if( @DEBUG )
577  {
578    "SSinit::Input";
579    type(M);
580//    DetailedPrint(M);
581    attrib(M);
582  }
583
584  int @RANK = nrows(M); int @SIZE = ncols(M);
585
586  int @IS_A_SB = attrib(M, "isSB"); // ??? only if all weights were zero?!
587
588  if( !@IS_A_SB )
589  {
590    def opts = option(get);
591    option(redSB); option(redTail);
592    M = std(M);
593    option(set, opts);
594    kill opts;
595  } else
596  {
597    M = simplify(M, 2 + 4 + 32);
598  }
599
600  def @N = MySort(M); // TODO: replace with inplace sorting!!!
601  def LEAD = lead(@N);
602
603  if( @SYZCHECK )
604  {
605    def @LEAD = lead(M);
606
607    // sort wrt neg.deg.rev.lex!
608    intvec iv_ds = sort(@LEAD, "c,ds", 1)[2]; // ,1 => reversed!
609
610    M = M[iv_ds]; // sort M wrt ds on current leading terms
611    @LEAD = @LEAD[iv_ds];
612
613    // 0^th syz. property
614    if( size(module( matrix(@N) - matrix(M) )) > 0 )
615    {
616      "M:"; M;
617      "@N:"; @N;
618
619      "module( matrix(@N) - matrix(M) ): ";
620      module( matrix(@N) - matrix(M) );
621
622      "ERROR: wrong sorting (in SSnit): @N != M!!!";
623      $
624    }
625
626    // 0^th syz. property
627    if( size(module( matrix(@LEAD) - matrix(LEAD) )) > 0 )
628    {
629      "LEAD:"; LEAD;
630      "@LEAD:"; @LEAD;
631
632      "module( matrix(@LEAD) - matrix(LEAD) ): ";
633      module( matrix(@LEAD) - matrix(LEAD) );
634
635      "ERROR: wrong sorting (in SSnit): @LEAD != LEAD!!!";
636      $
637    }
638   
639  }
640
641  M = @N;
642 
643 
644 
645 
646  def TAIL = Tail(M);
647 
648  intvec @DEGS = deg(M[1..@SIZE]); // store actuall degrees of input elements
649 
650  // TODO: what about real modules? weighted ones?
651 
652  list @l = ringlist(@save);
653
654  int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]);
655
656  // NOTE: @wdeg will be ignored anyway :(
657  @l[3] = list(list("C", @z), list("lp", @wdeg));
658
659  kill @z, @wdeg; // since these vars are ring independent!
660
661  def S = ring(@l); // --MakeInducedSchreyerOrdering(1);
662
663  module F = freemodule(@RANK);
664  intvec @V = deg(F[1..@RANK]);
665 
666  setring S; // ring with an easy divisibility test ("C, lex")
667
668  if( @DEBUG )
669  {
670    "SSinit::NewRing(C, lex)";
671    basering;
672    DetailedPrint(basering);
673  }
674
675  // Setup the leading syzygy^{-1} module to zero:
676  module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0)); 
677
678  module MRES = Z;
679 
680  list RES;  RES[1] = Z;
681  list LRES; LRES[1] = Z;
682  list TRES; TRES[1] = Z;
683 
684  def M = imap(@save, M);
685
686  attrib(M, "isHomog", @V);
687  attrib(M, "isSB", 1);
688  attrib(M, "degrees", @DEGS); 
689 
690  def LEAD = imap(@save, LEAD);
691 
692  attrib(LEAD, "isHomog", @V);
693  attrib(LEAD, "isSB", 1); 
694 
695  def TAIL = imap(@save, TAIL);
696
697  if( @DEBUG )
698  {
699    "SSinit::(sorted) SB_Input: ";
700    type(M);
701    attrib(M);
702    attrib(M, "isHomog");
703//    DetailedPrint(M);
704  }
705
706  if( @SYZCHECK )
707  {
708    // 0^th syz. property
709    if( size(module(transpose( transpose(M) * transpose(MRES) ))) > 0 )
710    {
711      transpose( transpose(M) * transpose(MRES) );
712      "ERROR: transpose( transpose(M) * transpose(MRES) ) != 0!!!";
713      $
714    }
715  }
716
717  RES [size(RES)+1] = M; // list of all syzygy modules
718  LRES[size(LRES)+1] = LEAD; // list of all syzygy modules
719  TRES[size(TRES)+1] = TAIL; // list of all syzygy modules
720 
721  MRES = MRES, M; //?
722
723  attrib(MRES, "isHomog", @V);
724 
725//  attrib(S, "InducionStart", @RANK);
726
727
728  if( typeof( attrib(SSinit, "LEAD2SYZ") ) == "int" )
729  {
730    attrib(S, "LEAD2SYZ", attrib(SSinit, "LEAD2SYZ") );
731  } else
732  {
733    attrib(S, "LEAD2SYZ", 1);
734  }
735
736  if( typeof( attrib(SSinit, "TAILREDSYZ") ) == "int" )
737  {
738    attrib(S, "TAILREDSYZ", attrib(SSinit, "TAILREDSYZ") );
739  } else
740  {
741    attrib(S, "TAILREDSYZ", 1);
742  }
743
744
745  if( typeof( attrib(SSinit, "HYBRIDNF") ) == "int" )
746  {
747    attrib(S, "HYBRIDNF", attrib(SSinit, "HYBRIDNF") );
748  } else
749  {
750    attrib(S, "HYBRIDNF", 0);
751  }
752 
753  attrib(S, "DEBUG", @DEBUG);
754  attrib(S, "SYZCHECK", @SYZCHECK);
755  attrib(S, "KERCHECK", @KERCHECK);
756 
757  if( @DEBUG )
758  {
759    "SSinit::MRES";
760    MRES;
761//    DetailedPrint(MRES);
762    attrib(MRES, "isHomog");
763    attrib(S);
764  }
765
766  export RES;
767  export MRES;
768  export LRES;
769  export TRES;
770  return (S);
771}
772example
773{ "EXAMPLE:"; echo = 2;
774  ring R = 0, (w, x, y, z), dp;
775
776  def M = maxideal(1);
777  def S = SSinit(M); setring S; S;
778 
779  "Only the first initialization: ";
780  RES; LRES; TRES;
781  MRES;
782
783  kill S; setring R; kill M;
784 
785  ideal M = w^2 - x*z,  w*x - y*z,  x^2 - w*y, x*y - z^2, y^2 - w*z;
786  def S = SSinit(M); setring S; S;
787
788  "Only the first initialization: ";
789  RES; LRES; TRES;
790  MRES;
791
792  kill S; setring R; kill M;
793}
794
795
796LIB "poly.lib"; // for lcm
797
798
799
800/// Compute L(Syz(L))
801proc SSComputeLeadingSyzygyTerms(def L)
802{
803  if( typeof( attrib(basering, "DEBUG") ) == "int" )
804  {
805    int @DEBUG = attrib(basering, "DEBUG");
806  } else
807  {
808    int @DEBUG = !system("with", "ndebug");
809  }
810
811  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
812  {
813    int @SYZCHECK = attrib(basering, "SYZCHECK");
814  } else
815  {
816    int @SYZCHECK = @DEBUG;
817  }
818
819  if( typeof( attrib(basering, "KERCHECK") ) == "int" )
820  {
821    int @KERCHECK = attrib(basering, "KERCHECK");
822  } else
823  {
824    int @KERCHECK = @SYZCHECK;
825  }
826
827  if( @DEBUG )
828  {
829    "SSComputeLeadingSyzygyTerms::Input: ";
830    L;
831  }
832
833  module SS = ComputeLeadingSyzygyTerms(L);
834
835  if( @KERCHECK )
836  { 
837    int i, j, r;
838    int N = ncols(L);
839    def a, b;
840    poly aa, bb;
841
842    bigint c;
843
844    ideal M;
845
846    module S = 0;
847
848    for(i = 1; i <= N; i++)
849    {
850      a = L[i];
851      c = leadcomp(a);
852      r = int(c);
853
854      aa = leadmonomial(a);
855
856      M = 0;
857
858      for(j = i-1; j > 0; j--)
859      {
860        b = L[j];
861
862        if( leadcomp(b) == c )
863        {
864          bb = leadmonomial(b);
865
866          M[j] = (lcm(aa, bb) / aa);
867        }
868      }
869
870      // TODO: add quotient relations here...
871
872      M = simplify(M, 1 + 2 + 32);
873
874      M = MySort(M);
875
876      S = S, M * gen(i);
877    }
878
879    S = MySort(simplify(S, 2));
880
881    if( size(S) * size(SS) > 0 )
882    {
883    if( size(module(matrix(S) - matrix(SS))) > 0 )
884    {
885        "ERROR: SSComputeLeadingSyzygyTerms: S != SS ";
886
887        "basering: ";
888        DetailedPrint(basering);
889
890        "S: ";  S;
891        DetailedPrint(S, 1);
892        "SS: "; SS;
893        DetailedPrint(SS, 1);
894
895        "DIFF: ";
896        print(matrix(S) - matrix(SS));
897        DetailedPrint(module(matrix(S) - matrix(SS)), 2);     
898        $
899    }
900    }
901  }
902
903 
904  if( @DEBUG )
905  {
906    "SSComputeLeadingSyzygyTerms::Output: ";
907    "SS: ";
908    SS;
909  }
910 
911  if( size(SS) > 0 )
912  {
913    attrib(SS, "isSB", 1);
914  }
915 
916  return (SS);
917}
918
919/// Compute Syz(L), where L is a monomial (leading) module
920proc SSCompute2LeadingSyzygyTerms(def L)
921{
922  if( typeof( attrib(basering, "DEBUG") ) == "int" )
923  {
924    int @DEBUG = attrib(basering, "DEBUG");
925  } else
926  {
927    int @DEBUG = !system("with", "ndebug");
928  }
929
930  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
931  {
932    int @SYZCHECK = attrib(basering, "SYZCHECK");
933  } else
934  {
935    int @SYZCHECK = @DEBUG;
936  }
937
938  if( typeof( attrib(basering, "KERCHECK") ) == "int" )
939  {
940    int @KERCHECK = attrib(basering, "KERCHECK");
941  } else
942  {
943    int @KERCHECK = @SYZCHECK;
944  }
945
946  int @TAILREDSYZ = 1;
947  if( typeof( attrib(basering, "TAILREDSYZ") ) == "int" )
948  {
949    @TAILREDSYZ = attrib(basering, "TAILREDSYZ");
950  }
951 
952 
953  if( @DEBUG )
954  {
955    "SSCompute2LeadingSyzygyTerms::Input: ";
956    L;
957  }
958
959  module SS = Compute2LeadingSyzygyTerms(L);
960
961  if( @DEBUG )
962  {
963    "SSCompute2LeadingSyzygyTerms::Syz(SS): "; SS;
964  }
965 
966  if( @SYZCHECK )
967  {
968    if( size(SS) > 0 and size(L) > 0 )
969    {
970      if( size(module(transpose( transpose(SS) * transpose(L) ))) > 0 )
971      {
972        transpose( transpose(SS) * transpose(L) );
973        "ERROR: transpose( transpose(SS) * transpose(L) ) != 0!!!";
974        $
975      }
976    }
977  }
978   
979  if( @KERCHECK )
980  {
981
982    int i, j, r;
983    int N = ncols(L);
984    def a, b;
985
986    poly aa, bb, @lcm;
987
988    bigint c;
989
990    module M;
991
992    module S = 0;
993
994    for(i = 1; i <= N; i++)
995    {
996      a = L[i];
997  //    "a: ", a;
998      c = leadcomp(a);
999      r = int(c);
1000
1001      aa = leadmonomial(a);
1002
1003      M = 0;
1004
1005      for(j = i-1; j > 0; j--)
1006      {
1007        b = L[j];
1008  //      "b: ", b;
1009
1010        if( leadcomp(b) == c )
1011        {
1012          bb = leadmonomial(b);
1013          @lcm = lcm(aa, bb);
1014
1015          M[j] = (@lcm / aa)* gen(i) - (@lcm / bb)* gen(j);
1016        }
1017      }
1018
1019      M = simplify(M, 2);
1020
1021      // TODO: add quotient relations here...
1022      S = S, M;
1023    }
1024
1025    if( @TAILREDSYZ )
1026    {
1027      // Make sure that 2nd syzygy terms are not reducible by 1st
1028      def opts = option(get);
1029      option(redSB); option(redTail);
1030      S = std(S); // binomial module
1031      option(set, opts);
1032      //  kill opts;
1033    } else
1034    {
1035      S = simplify(S, 2 + 32);
1036    }
1037
1038    S = MySort(S);
1039
1040    if( @DEBUG )
1041    {
1042      "SSCompute2LeadingSyzygyTerms::Syz(S): "; S;
1043    }
1044
1045    if( size(module(matrix(S) - matrix(SS))) > 0 )
1046    {
1047      "ERROR: SSCompute2LeadingSyzygyTerms: S != SS ";
1048
1049      "basering: ";
1050      DetailedPrint(basering);
1051
1052      "S: ";  S;
1053      DetailedPrint(S, 2);
1054      "SS: "; SS;
1055      DetailedPrint(SS, 2);
1056
1057      "DIFF: ";
1058      print(matrix(S) - matrix(SS));
1059      DetailedPrint(module(matrix(S) - matrix(SS)), 4);
1060      $
1061    }
1062  }
1063 
1064  module S2 = Tail(SS);
1065  SS = lead(SS); // (C,lp) on base ring!
1066             
1067  if( @DEBUG )
1068  {
1069    "SSCompute2LeadingSyzygyTerms::Output: "; SS; S2;
1070  } 
1071 
1072  attrib(SS, "isSB", 1);
1073
1074  return (SS, S2);
1075}
1076
1077// -------------------------------------------------------- //
1078
1079/// TODO: save shortcut (syz: |-.->) LM(LM(m) * "t") -> syz?
1080proc SSFindReducer(def product, def syzterm, def L, def T, list #)
1081{
1082  if( typeof( attrib(basering, "DEBUG") ) == "int" )
1083  {
1084    int @DEBUG = attrib(basering, "DEBUG");
1085  } else
1086  {
1087    int @DEBUG = !system("with", "ndebug");
1088  }
1089
1090
1091  if( @DEBUG )
1092  {
1093    "SSFindReducer::Input: ";
1094
1095    "syzterm: ", syzterm;
1096    "product: ", product;
1097    "L: ", L;
1098    "T: ", T;
1099    if( size(#) > 0 )
1100    {
1101      "LSyz: ", #;
1102    }
1103  }
1104
1105
1106  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
1107  {
1108    int @SYZCHECK = attrib(basering, "SYZCHECK");
1109  } else
1110  {
1111    int @SYZCHECK = @DEBUG;
1112  }
1113 
1114  if( @SYZCHECK && (syzterm != 0) )
1115  {
1116    def @@c = leadcomp(syzterm); int @@r = int(@@c);
1117    def @@product = leadmonomial(syzterm) * L[@@r];
1118
1119    if( @@product != product)
1120    {
1121      "product: ", product, ", @@product: ", @@product;
1122      "ERROR: 'syzterm' results in wrong product !!!???";
1123      $
1124    }
1125  }
1126
1127//  def product = m * t;
1128
1129  bigint c = leadcomp(product); int r = int(c);
1130
1131  def a, b, bb;
1132
1133  vector nf = [0];
1134
1135  // looking for an appropriate diviser
1136  for( int k = ncols(L); k > 0; k-- )
1137  {
1138    a = L[k];
1139    // with the same mod. component
1140    if( leadcomp(a) == c )
1141    {
1142      b = - (leadmonomial(product) / leadmonomial(L[k]));
1143
1144      // which divides the product: looking for the 1st appropriate one!
1145      if( b != 0 )
1146      {
1147        bb = b * gen(k);
1148       
1149        if (size(bb + syzterm) == 0) // cannot allow something like: a*gen(i) - a*gen(i)
1150        {
1151          nf = [0];
1152        } else
1153        {
1154          nf = bb;
1155        }
1156
1157        // new syz. term should not be in <LS = #>
1158        if( size(#) > 0 )
1159        {
1160          if( typeof(#[1]) == "module" )
1161          {
1162            nf = NF(bb, #[1]);
1163          }
1164        }
1165
1166        // while the complement (the fraction) is not reducible by leading syzygies
1167        if( nf != 0 ) // nf must be == bb!!!
1168        {
1169          /// TODO: save shortcut LM(m) * T[i] -> ?
1170
1171          // choose ANY such reduction... (with the biggest index?)
1172          break;
1173        }
1174      }
1175    }
1176  } 
1177  if( @DEBUG )
1178  {
1179    "SSFindReducer::Output: ", nf;
1180  }
1181  return (nf);
1182}
1183
1184
1185
1186
1187
1188/// TODO: save shortcut (syz: |-.->) LM(m) * "t" -> ?
1189proc SSReduceTerm(poly m, def t, def syzterm, def L, def T, list #)
1190{
1191  if( typeof( attrib(basering, "DEBUG") ) == "int" )
1192  {
1193    int @DEBUG = attrib(basering, "DEBUG");
1194  } else
1195  {
1196    int @DEBUG = !system("with", "ndebug");
1197  }
1198
1199
1200  if( @DEBUG )
1201  {
1202    "SSReduce::Input: ";
1203
1204    "syzterm: ", syzterm;
1205    "mult: ", m;
1206    "term: ", t;
1207    "L: ", L;
1208    "T: ", T;
1209    if( size(#) > 0 )
1210    {
1211      "LSyz: ", #;
1212    }
1213//    "attrib(LS, 'isSB')", attrib(LS, "isSB");
1214  }
1215
1216
1217  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
1218  {
1219    int @SYZCHECK = attrib(basering, "SYZCHECK");
1220  } else
1221  {
1222    int @SYZCHECK = @DEBUG;
1223  }
1224
1225  if( @SYZCHECK && (syzterm != 0) )
1226  {
1227    def @@c = leadcomp(syzterm); int @@r = int(@@c);
1228    poly @@m = leadmonomial(syzterm); def @@t = L[@@r];
1229
1230    if( (@@m != m) || (@@t != t))
1231    {
1232      "m: ", m, ", t: ", t;
1233      "@@m: ", @@m, ", @@t: ", @@t;
1234      "ERROR: 'syzterm' results in wrong m * t !!!";
1235      $
1236    }
1237  }
1238
1239  vector s = [0];
1240
1241  if( size(t) > 0 )
1242  {
1243    def product = m * t;
1244
1245    s = SSFindReducer(product, syzterm, L, T, #);
1246
1247    if( size(s) != 0 )
1248    {
1249      poly b = leadmonomial(s);
1250
1251      def c = leadcomp(s); int k = int(c);
1252
1253      s = s + SSTraverseTail(b, T[k], L, T, #); // !!!   
1254    }
1255  }
1256   
1257  if( @DEBUG )
1258  {
1259    "SSReduceTerm::Output: ", s;
1260  }
1261 
1262  return (s);
1263}
1264
1265
1266// TODO: store m * @tail -.-^-.-^-.--> ?
1267proc SSTraverseTail(poly m, def @tail, def L, def T, list #)
1268{
1269  if( typeof( attrib(basering, "DEBUG") ) == "int" )
1270  {
1271    int @DEBUG = attrib(basering, "DEBUG");
1272  } else
1273  {
1274    int @DEBUG = !system("with", "ndebug");
1275  }
1276
1277  if( @DEBUG )
1278  {
1279    "SSTraverse::Input: ";
1280
1281    "mult: ", m;
1282    "tail: ", @tail; // T[i];
1283
1284    if( size(#) > 0 )
1285    {
1286      "LSyz: "; #[1];
1287    }
1288  }
1289
1290  vector s = 0;
1291
1292  def @l;
1293
1294  // iterate tail-terms in ANY order!
1295  while( size(@tail) > 0 )
1296  {
1297    @l = lead(@tail);
1298    s = s + SSReduceTerm(m, @l, [0], L, T, #); // :(
1299    @tail = @tail - @l;
1300  }
1301
1302  if( @DEBUG )
1303  {
1304    "SSTraverseTail::Output: ", s;
1305  }
1306  return (s);
1307}
1308
1309// -------------------------------------------------------- //
1310
1311// module (N, LL, TT) = SSComputeSyzygy(L, T);
1312// Compute Syz(L ++ T) = N = LL ++ TT
1313proc SSComputeSyzygy(def L, def T)
1314{
1315  if( typeof( attrib(basering, "DEBUG") ) == "int" )
1316  {
1317    int @DEBUG = attrib(basering, "DEBUG");
1318  } else
1319  {
1320    int @DEBUG = !system("with", "ndebug");
1321  }
1322
1323  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
1324  {
1325    int @SYZCHECK = attrib(basering, "SYZCHECK");
1326  } else
1327  {
1328    int @SYZCHECK = @DEBUG;
1329  }
1330 
1331 
1332  if( @DEBUG )
1333  {
1334    "SSComputeSyzygy::Input";
1335    "basering: ", basering; attrib(basering);
1336//    DetailedPrint(basering);
1337
1338//    "iCompShift: ", iCompShift;
1339
1340    "L: "; L;
1341    "T: "; T;
1342  }
1343
1344  def a; bigint c; int r, k; poly aa;
1345
1346  int @LEAD2SYZ = 0;
1347  if( typeof( attrib(basering, "LEAD2SYZ") ) == "int" )
1348  {
1349    @LEAD2SYZ = attrib(basering, "LEAD2SYZ");
1350  }
1351
1352  int @TAILREDSYZ = 1;
1353  if( typeof( attrib(basering, "TAILREDSYZ") ) == "int" )
1354  {
1355    @TAILREDSYZ = attrib(basering, "TAILREDSYZ");
1356  }
1357
1358  int @HYBRIDNF = 0;
1359  if( typeof( attrib(basering, "HYBRIDNF") ) == "int" )
1360  {
1361    @HYBRIDNF = attrib(basering, "HYBRIDNF");
1362  }
1363
1364  module LL;
1365  def a2; int r2; poly aa2; 
1366
1367  /// Get the critical leading syzygy terms
1368  if( @LEAD2SYZ ) // & 2nd syz. term
1369  {
1370    module LL2;
1371    (LL, LL2) = SSCompute2LeadingSyzygyTerms(L); // ++
1372  } else
1373  {
1374    LL = SSComputeLeadingSyzygyTerms(L);
1375  }
1376
1377  module TT, SYZ; def spoly;
1378
1379  if( size(LL) > 0 )
1380  {
1381    list LS;
1382
1383    if( @TAILREDSYZ)
1384    {
1385      LS = list(LL);
1386    }
1387
1388    vector @tail;
1389
1390    for(k = ncols(LL); k > 0; k-- )
1391    {
1392      // leading syz. term:
1393      a = LL[k]; c = leadcomp(a); r = int(c); aa = leadmonomial(a);
1394      //    "A: ", a, " --->>>> ", aa, " **** [", r, "]: ";
1395
1396      // NF reduction:
1397      if( !@HYBRIDNF )
1398      {
1399        /// TODO: save shortcut (aa) * T[r] -> ?
1400        @tail = SSTraverseTail(aa, T[r], L, T, LS);
1401  // //      @tail = SSTraverseTail(a, L, T, LS);
1402
1403        // get the 2nd syzygy term...
1404
1405        if( @LEAD2SYZ ) // with the 2nd syz. term:
1406        {     
1407          a2 = LL2[k]; c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2);
1408
1409          @tail = @tail + a2 +
1410               /// TODO: save shortcut (aa2) * T[r2] -> ?
1411               SSTraverseTail(aa2, T[r2], L, T, LS);
1412  // //               SSTraverseTail(a2, L, T, LS);
1413        } else
1414        {
1415          @tail = @tail +
1416                  SSReduceTerm(aa, L[r], a, L, T, LS);
1417  // //                  SSReduceTerm(a, L, T, LS);
1418        }
1419      } else
1420      {
1421        spoly = aa * T[r];
1422
1423        if( @LEAD2SYZ )
1424        {
1425          a2 = LL2[k];
1426        } else
1427        {
1428          a2 = SSFindReducer( aa * L[r], a, L, T, LS);
1429        }
1430
1431        if ( (@SYZCHECK || @DEBUG) )
1432        {
1433          if( size(a2) == 0 ) // if syzterm == 0!!!!
1434          {
1435            "ERROR: could not find the 2nd syzygy term during the hybrid NF!!!";
1436            $
1437          }
1438        }
1439       
1440        c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2);
1441       
1442        spoly = spoly + aa2 * T[r2];
1443        @tail = a2;
1444
1445        while (size(spoly) > 0)
1446        {
1447          a2 = SSFindReducer( lead(spoly), [0], L, T, LS);
1448          spoly = Tail(spoly);
1449
1450          if( size(a2) != 0)
1451          {         
1452            c = leadcomp(a2); r2 = int(c); aa2 = leadmonomial(a2);
1453
1454            spoly = spoly + aa2 * T[r2];
1455            @tail = @tail + a2;
1456          }
1457        }
1458       
1459      }
1460     
1461      TT[k] = @tail;
1462      SYZ[k] = a + @tail;
1463    }
1464  }
1465
1466  if( @DEBUG )
1467  {
1468    "SSComputeSyzygy::Output";
1469
1470    "SYZ: "; SYZ;
1471    "LL: "; LL;
1472    "TT: "; TT;
1473  }
1474
1475  return (SYZ, LL, TT);
1476}
1477
1478// resolution/syzygy step:
1479static proc SSstep()
1480{
1481  if( typeof( attrib(basering, "DEBUG") ) == "int" )
1482  {
1483    int @DEBUG = attrib(basering, "DEBUG");
1484  } else
1485  {
1486    int @DEBUG = !system("with", "ndebug");
1487  }
1488
1489
1490  if( typeof( attrib(basering, "SYZCHECK") ) == "int" )
1491  {
1492    int @SYZCHECK = attrib(basering, "SYZCHECK");
1493  } else
1494  {
1495    int @SYZCHECK = @DEBUG;
1496  }
1497
1498  if( @DEBUG )
1499  {
1500    "SSstep::NextInducedRing";
1501    "basering: ", basering; attrib(basering);
1502  }
1503
1504/*
1505  // is initial weights are all zeroes!
1506  def L =  lead(M);
1507  intvec @V = deg(M[1..ncols(M)]);  @W;  @V;  @W = @V;  attrib(L, "isHomog", @W); 
1508  SetInducedReferrence(L, @RANK, 0);
1509*/
1510
1511//  def L =  lead(MRES);
1512//  @W = @W, @V;
1513//  attrib(L, "isHomog", @W); 
1514
1515
1516  // General setting:
1517//  SetInducedReferrence(MRES, 0, 0); // limit: 0!
1518  int @l = size(RES);
1519
1520  def M =  RES[@l];
1521
1522  def L = LRES[@l];
1523  def T = TRES[@l];
1524
1525
1526  //// TODO: wrong !!!!!
1527  int @RANK = ncols(MRES) - ncols(M); // nrows(M); // what if M is zero?!
1528
1529 
1530
1531/*
1532  if( @RANK !=  nrows(M) )
1533  {
1534    type(MRES);
1535    @RANK;
1536    type(M);
1537    pause();
1538  }
1539*/
1540 
1541  intvec @W = attrib(M, "isHomog"); intvec @V = attrib(M, "degrees"); @V = @W, @V;
1542   
1543  if( @DEBUG )
1544  {
1545    "Sstep::NextInput: ";
1546    M;
1547    L;
1548    @V;
1549    @RANK;
1550//    DetailedPrint(MRES);
1551    attrib(MRES, "isHomog");
1552  }
1553
1554     
1555  // TODO: N  = SYZ( M )!!!
1556  module N, LL, TT;
1557  (N, LL, TT) = SSComputeSyzygy(/*M, */L, T/*, @RANK*/);
1558
1559  // shift syz.comp by @RANK:
1560  module Z;
1561  Z = 0; Z[@RANK] = 0; Z = Z, transpose(LL);   LL = transpose(Z);
1562  Z = 0; Z[@RANK] = 0; Z = Z, transpose(TT);   TT = transpose(Z);
1563  Z = 0; Z[@RANK] = 0; Z = Z, transpose(N);     N = transpose(Z);
1564
1565
1566  if( @SYZCHECK )
1567  {
1568    if( size(N) > 0 )
1569    {
1570      // next syz. property
1571      if( size(module(transpose( transpose(N) * transpose(MRES) ))) > 0 )
1572      {
1573        "MRES", MRES;
1574
1575        "N: "; N; // DetailedPrint(N, 2);
1576
1577        "LL:"; LL; // DetailedPrint(LL, 1);
1578        "TT:"; TT; // DetailedPrint(TT, 10);
1579
1580        "RANKS: ", @RANK;
1581
1582        "transpose( transpose(N) * transpose(MRES) ) != 0!!!";
1583        transpose( transpose(N) * transpose(MRES) );
1584
1585        "transpose(N) * transpose(MRES): ";
1586        transpose(N) * transpose(MRES);
1587        // DetailedPrint(module(_), 2);
1588        $
1589      }
1590    }
1591  }
1592
1593  attrib(N, "isHomog", @V);
1594
1595  // TODO: correct the following:
1596  intvec @DEGS = deg(N[1..ncols(N)]); // no mod. comp. weights :(
1597
1598 
1599  attrib(N, "degrees", @DEGS);
1600 
1601   RES[@l + 1] = N; // list of all syzygy modules
1602  LRES[@l + 1] = LL; // list of all syzygy modules
1603  TRES[@l + 1] = TT; // list of all syzygy modules
1604
1605  MRES = MRES, N;
1606 
1607  attrib(MRES, "isHomog", @V);
1608
1609//  L = L, lead(N);  attrib(basering, "InducionLeads", L);
1610
1611  if( @DEBUG )
1612  {
1613    "SSstep::NextSyzOutput: ";
1614    N;
1615//    DetailedPrint(N);
1616    attrib(N);
1617  }
1618
1619}
1620
1621proc SScontinue(int l)
1622"USAGE:  SScontinue(l)
1623RETURN:  nothing, instead it changes RES and MRES variables in the current ring
1624PURPOSE: computes further (at most l) syzygies
1625NOTE:    must be used within a ring returned by Sres or Ssyz. RES and MRES are
1626         explained in Sres
1627EXAMPLE: example Scontinue; shows an example
1628"
1629{
1630
1631  /// TODO!
1632//  def data = GetInducedData();
1633
1634  if( (!defined(RES)) || (!defined(MRES)) ) /* || (typeof(data) != "list") || (size(data) != 2) */
1635  {
1636    ERROR("Sorry, but basering does not seem to be returned by Sres or Ssyz");
1637  }
1638  for (;  (l != 0) && (size(RES[size(RES)]) > 0); l-- )
1639  {
1640    SSstep();
1641  }
1642}
1643example
1644{ "EXAMPLE:"; echo = 2;
1645  ring r;
1646  module M = maxideal(1); M;
1647  def S = SSsyz(M); setring S; S;
1648  "Only the first syzygy: ";
1649  RES; MRES;
1650  "More syzygies: ";
1651  SScontinue(10);
1652  RES; MRES;
1653}
1654
1655proc SSsyz(def M)
1656"USAGE:  SSsyz(M)
1657RETURN:  ring, containing a list of modules RES and a module MRES
1658PURPOSE: computes the first syzygy module of M (wrt some Schreyer ordering)?
1659NOTE:    The output is explained in Sres
1660EXAMPLE: example Ssyz; shows an example
1661"
1662{
1663  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
1664  {
1665    ERROR("Sorry: need an ideal or a module for input");
1666  }
1667
1668  def SS = SSinit(M); setring SS;
1669 
1670  SSstep(); // NOTE: what if M is zero?
1671
1672  return (SS);
1673}
1674example
1675{ "EXAMPLE:"; echo = 2;
1676  ring r;
1677
1678/*  ideal M = 0;
1679  def S = SSsyz(M); setring S; S;
1680  "Only the first syzygy: ";
1681  RES; LRES; TRES;
1682  MRES;
1683 
1684  kill S; setring r; kill M;
1685*/ 
1686
1687  ideal M = maxideal(1); M;
1688
1689  def S = SSres(M, 0); setring S; S;
1690  MRES;
1691  print(_);
1692  RES;
1693
1694  kill S; setring r; kill M;
1695
1696  kill r;
1697 
1698  ring R = 0, (w, x, y, z), dp;
1699  ideal M = w^2 - x*z,  w*x - y*z,  x^2 - w*y, x*y - z^2, y^2 - w*z;
1700 
1701  def S = SSres(M, 0); setring S; S;
1702  "";
1703  LRES;
1704  "";
1705  TRES;
1706  "";
1707  MRES;
1708  print(_);
1709  RES;
1710}
1711
1712proc SSres(def M, int l)
1713"USAGE:  SSres(I, l)
1714RETURN:  ring, containing a list of modules RES and a module MRES
1715PURPOSE: computes (at most l) syzygy modules of M wrt the classical Schreyer
1716         induced ordering with gen(i) > gen(j) if i > j, provided both gens
1717         are from the same syzygy level.???
1718NOTE:    RES contains the images of maps subsituting the beginning of the
1719         Schreyer free resolution of baseRing^r/M, while MRES is a sum of
1720         these images in a big free sum, containing all the syzygy modules.
1721         The syzygy modules are shifted so that gen(i) correspons to MRES[i].
1722         The leading zero module RES[0] indicates the fact that coker of the
1723         first map is zero. The number of zeroes inducates the rank of input.
1724NOTE:    If l == 0 then l is set to be nvars(basering) + 1
1725EXAMPLE: example SSres; shows an example
1726"
1727{
1728  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
1729  {
1730    ERROR("Sorry: need an ideal or a module for input");
1731  }
1732
1733  def SS = SSinit(M); setring SS;
1734
1735  if (l == 0)
1736  {
1737    l = nvars(basering) + 1; // not really an estimate...?!
1738  }
1739
1740  SSstep(); l = l - 1;
1741
1742  SScontinue(l);
1743
1744  return (SS);
1745}
1746example
1747{ "EXAMPLE:"; echo = 2;
1748  ring r;
1749  module M = maxideal(1); M;
1750  def S = SSres(M, 0); setring S; S;
1751  RES;
1752  MRES;
1753  kill S;
1754  setring r; kill M;
1755
1756  def A = nc_algebra(-1,0); setring A;
1757  ideal Q = var(1)^2, var(2)^2, var(3)^2;
1758  qring SCA = twostd(Q);
1759  basering;
1760
1761  module M = maxideal(1);
1762  def S = SSres(M, 2); setring S; S;
1763  RES;
1764  MRES;
1765}
1766
1767
1768
1769static proc loadme()
1770{
1771  int @DEBUG = !system("with", "ndebug");
1772
1773  if( @DEBUG )
1774  {
1775   
1776    "ndebug?: ", system("with", "ndebug");
1777    "om_ndebug?: ", system("with", "om_ndebug");
1778
1779    listvar(Top);
1780    listvar(Schreyer);
1781  }
1782//  listvar(Syzextra); listvar(Syzextra_g);
1783
1784  if( !defined(DetailedPrint) )
1785  {
1786    if( 1 )
1787    {
1788
1789      if( @DEBUG )
1790      {
1791        "Loading the Release version!";
1792      }
1793      load("syzextra.so");
1794
1795      if( @DEBUG )
1796      {
1797        listvar(Syzextra);
1798      }
1799
1800      exportto(Top, Syzextra::ClearContent);
1801      exportto(Top, Syzextra::ClearDenominators);
1802
1803      exportto(Schreyer, Syzextra::m2_end);
1804     
1805//      export Syzextra;
1806
1807//      exportto(Schreyer, Syzextra::noop);
1808      exportto(Schreyer, Syzextra::DetailedPrint);
1809      exportto(Schreyer, Syzextra::leadmonomial);
1810      exportto(Schreyer, Syzextra::leadcomp);
1811//      exportto(Schreyer, Syzextra::leadrawexp);
1812//      exportto(Schreyer, Syzextra::ISUpdateComponents);
1813      exportto(Schreyer, Syzextra::SetInducedReferrence);
1814      exportto(Schreyer, Syzextra::GetInducedData);
1815//      exportto(Schreyer, Syzextra::GetAMData);
1816//      exportto(Schreyer, Syzextra::SetSyzComp);
1817      exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering);
1818//      exportto(Schreyer, Syzextra::MakeSyzCompOrdering);
1819      exportto(Schreyer, Syzextra::idPrepare);
1820//      exportto(Schreyer, Syzextra::reduce_syz);
1821//      exportto(Schreyer, Syzextra::p_Content);
1822
1823      exportto(Schreyer, Syzextra::ProfilerStart); exportto(Schreyer, Syzextra::ProfilerStop);
1824
1825      exportto(Schreyer, Syzextra::Tail);
1826      exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms);     
1827      exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms);
1828      exportto(Schreyer, Syzextra::Sort_c_ds);
1829    }
1830/*
1831    else
1832    {
1833      if( @DEBUG )
1834      {
1835        "Loading the Debug version!";
1836      }
1837
1838      load("syzextra.so");
1839
1840      if( @DEBUG )
1841      {     
1842        listvar(Syzextra_g);
1843      }
1844     
1845      exportto(Top, Syzextra_g::ClearContent);
1846      exportto(Top, Syzextra_g::ClearDenominators);
1847
1848      exportto(Schreyer, Syzextra_g::m2_end);
1849
1850//      export Syzextra_g;
1851//      exportto(Schreyer, Syzextra_g::noop);
1852      exportto(Schreyer, Syzextra_g::DetailedPrint);
1853      exportto(Schreyer, Syzextra_g::leadmonomial);
1854      exportto(Schreyer, Syzextra_g::leadcomp);
1855//      exportto(Schreyer, Syzextra_g::leadrawexp);
1856//      exportto(Schreyer, Syzextra_g::ISUpdateComponents);
1857      exportto(Schreyer, Syzextra_g::SetInducedReferrence);
1858      exportto(Schreyer, Syzextra_g::GetInducedData);
1859//      exportto(Schreyer, Syzextra_g::GetAMData);
1860//      exportto(Schreyer, Syzextra_g::SetSyzComp);
1861      exportto(Schreyer, Syzextra_g::MakeInducedSchreyerOrdering);
1862//      exportto(Schreyer, Syzextra_g::MakeSyzCompOrdering);
1863      exportto(Schreyer, Syzextra_g::idPrepare);
1864//      exportto(Schreyer, Syzextra_g::reduce_syz);
1865//      exportto(Schreyer, Syzextra_g::p_Content);
1866
1867      exportto(Schreyer, Syzextra_g::ProfilerStart); exportto(Schreyer, Syzextra_g::ProfilerStop);
1868
1869      exportto(Schreyer, Syzextra_g::Tail);
1870      exportto(Schreyer, Syzextra_g::ComputeLeadingSyzygyTerms);
1871      exportto(Schreyer, Syzextra_g::Compute2LeadingSyzygyTerms);
1872      exportto(Schreyer, Syzextra_g::Sort_c_ds);
1873     
1874    }
1875*/
1876
1877    exportto(Top, DetailedPrint);
1878    exportto(Top, GetInducedData);
1879
1880    if( @DEBUG )
1881    {
1882      listvar(Top);
1883      listvar(Schreyer);
1884    }
1885  }
1886 
1887  if( !defined(GetInducedData) )
1888  {
1889    ERROR("Sorry but we are missing the dynamic module (syzextra.so)...");
1890  }
1891
1892}
1893
1894static proc mod_init()
1895{
1896  loadme();
1897}
1898
1899
1900proc testallSexamples()
1901{
1902  example Ssyz;
1903  example Scontinue;
1904  example Sres; 
1905}
1906
1907proc testallSSexamples()
1908{
1909  example SSsyz;
1910  example SScontinue;
1911  example SSres; 
1912}
1913
1914example
1915{ "EXAMPLE:"; echo = 2;
1916  testallSexamples();
1917  testallSSexamples();
1918}
1919
1920proc TestSSres(def M)
1921{
1922  "-------------------------------------";
1923  "options: ", attrib(SSinit, "LEAD2SYZ"), attrib(SSinit, "TAILREDSYZ"), attrib(SSinit, "HYBRIDNF"), ": ";
1924  int t = timer;
1925  def S = SSres(M, 0);
1926  int tt = timer;
1927/*
1928  setring S;
1929 
1930  MRES;
1931  RES;
1932  "";
1933  LRES;
1934  "";
1935  TRES;
1936*/ 
1937  kill S;
1938 "0-----------------------------------0 => ", tt - t;
1939}
1940
1941
1942proc TestSSresAttribs(def M)
1943{
1944
1945  // the following 2 setups are bad for AGR@101n3d002s004%1:(((
1946//  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 0); attrib(SSinit, "HYBRIDNF", 0); TestSSres(M);
1947//  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 0); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
1948
1949  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 0); TestSSres(M);
1950  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
1951
1952  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 0); attrib(SSinit, "HYBRIDNF", 0); TestSSres(M);
1953  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 0); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
1954
1955  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 0); TestSSres(M);
1956  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
1957}
1958
1959
1960proc testALLA()
1961{
1962  attrib(SSinit, "SYZCHECK", 1); // TODO: only for now!!
1963  attrib(SSinit, "KERCHECK", 0); // TODO: only for now!!
1964
1965  ring r; r; ideal M = maxideal(1); M;
1966  TestSSresAttribs(M); 
1967  kill r;
1968
1969  ring r = 0, (a, b, c, d), lp; r; ideal M = maxideal(1); M;
1970  TestSSresAttribs(M); 
1971  kill r;
1972
1973  ring R = 0, (w, x, y, z), dp; R;
1974  ideal M = w^2 - x*z,  w*x - y*z,  x^2 - w*y, x*y - z^2, y^2 - w*z; M;
1975  TestSSresAttribs(M); 
1976  kill R;
1977
1978 
1979  ring AGR = (101), (a, b, c, d), dp; AGR;
1980  // simple: AGR@101n3d002s004%1:
1981  ideal M = c*d, b*d, a*d, c^2-d^2, b*c, a*c, b^2-d^2, a*b, a^2-d^2;
1982  M;
1983  TestSSresAttribs(M);
1984
1985
1986  // medium: AGR@101n3d004s009%1;
1987  ideal M = a*b+7*a*c-16*b*c-27*a*d+37*b*d-2*c*d, d^3, c*d^2, b*d^2, a*d^2, c^2*d, b*c*d, a*c*d, b^2*d, a^2*d, c^3, b*c^2, a*c^2, b^2*c, a^2*c, b^3, a^3;
1988  M;
1989  TestSSresAttribs(M);
1990
1991  /*
1992  // lengthy: AGR@101n3d008s058%3, toooo long!!! :((((
1993  ideal M = c^4*d^2+4*a^3*d^3+29*a^2*b*d^3-2*a*b^2*d^3+2*b^3*d^3-21*a^2*c*d^3+46*a*b*c*d^3+2*b^2*c*d^3-13*a*c^2*d^3+32*b*c^2*d^3+46*c^3*d^3-28*a^2*d^4+4*a*b*d^4+29*b^2*d^4-8*a*c*d^4+33*b*c*d^4-16*c^2*d^4+17*a*d^5-3*b*d^5-42*c*d^5+47*d^6,b*c^3*d^2+35*a^3*d^3+24*a^2*b*d^3+46*a*b^2*d^3-22*b^3*d^3-48*a^2*c*d^3+20*a*b*c*d^3-28*b^2*c*d^3-40*a*c^2*d^3-4*b*c^2*d^3+35*c^3*d^3-21*a^2*d^4+3*a*b*d^4+8*b^2*d^4-2*a*c*d^4-22*b*c*d^4+24*c^2*d^4+44*a*d^5+33*b*d^5+31*c*d^5+26*d^6,a*c^3*d^2-42*a^3*d^3+34*a^2*b*d^3-10*a*b^2*d^3+30*b^3*d^3-6*a^2*c*d^3-30*a*b*c*d^3-34*b^2*c*d^3+29*a*c^2*d^3+35*b*c^2*d^3+13*c^3*d^3+8*a^2*d^4+23*a*b*d^4-29*b^2*d^4+12*a*c*d^4-22*b*c*d^4-50*c^2*d^4-4*b*d^5+9*c*d^5+13*d^6,b^2*c^2*d^2+a^3*d^3-49*a^2*b*d^3+26*a*b^2*d^3+20*b^3*d^3+24*a^2*c*d^3-2*a*b*c*d^3+31*b^2*c*d^3-30*a*c^2*d^3+21*b*c^2*d^3-24*c^3*d^3-38*a^2*d^4-14*a*b*d^4-14*b^2*d^4+6*a*c*d^4+3*b*c*d^4+13*c^2*d^4-11*a*d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-7*a*c*d^4-45*b*c*d^4+10*c^2*d^4+29*a*d^5-28*b*d^5+34*c*d^5-15*d^6,a^6-33*a^3*d^3-45*a^2*b*d^3+19*a*b^2*d^3+39*b^3*d^3-5*a^2*c*d^3-46*a*b*c*d^3+9*b^2*c*d^3+15*a*c^2*d^3-21*b*c^2*d^3+46*c^3*d^3-39*a^2*d^4-9*a*b*d^4+50*b^2*d^4-45*a*c*d^4-39*b*c*d^4-18*c^2*d^4-4*a*d^5-19*b*d^5+12*c*d^5+39*d^6,d^7,c*d^6,b*d^6,a*d^6,c^2*d^5,b*c*d^5,a*c*d^5,b^2*d^5,a*b*d^5,a^2*d^5,c^3*d^4,b*c^2*d^4,a*c^2*d^4,b^2*c*d^4,a*b*c*d^4,a^2*c*d^4,b^3*d^4,a*b^2*d^4,a^2*b*d^4,a^3*d^4;
1994  M;
1995  TestSSresAttribs(M);
1996*/ 
1997  kill AGR;
1998
1999  ring r = 0, (a, b, c, d, e, f), dp; r; ideal M = maxideal(1); M;
2000  TestSSresAttribs(M); 
2001  kill r; 
2002}
2003
2004// TODO: betti!!!
Note: See TracBrowser for help on using the repository browser.