# source:git/Singular/LIB/schreyer.lib@6b6c82

spielwiese
Last change on this file since 6b6c82 was 6b6c82, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
starting the new resolution/syzygy prototyping: initial copypasta a-la Sres + ring changing + sorting + separation...
• Property mode set to `100644`
File size: 22.6 KB
Line
1//////////////////////////////////////////////////////////////////////////////
2version="\$Id\$";
3category="General purpose";
4info="
5LIBRARY: schreyer.lib     Helpers for working with the Schreyer induced ordering
6AUTHOR:  Oleksandr Motsak <U@D>, where U={motsak}, D={mathematik.uni-kl.de}
7
8PROCEDURES:
9 Sres(M,l)      Schreyer resolution of module M of maximal length l
10 Ssyz(M)        Schreyer resolution of module M of length 1
11 Scontinue(l)   continue the resolution computation by most l steps
12
13KEYWORDS:  syzygy; Schreyer induced ordering; Schreyer free resolution
14NOTE:  requires the dynamic module: syzextra
15";
16
17static proc prepareSyz( module I, list # )
18{
19  int i;
20  int k = 0;
21  int r = nrows(I);
22  int c = ncols(I);
23
24
25  if( size(#) > 0 )
26  {
27    if( typeof(#[1]) == "int" || typeof(#[1]) == "bigint" )
28    {
29      k = #[1];
30    }
31  }
32
33  if( k < r )
34  {
35    "// *** Wrong k: ", k, " < nrows: ", r, " => setting k = r = ", r;
36    k = r;
37  }
38
39//   "k: ", k;  "c: ", c;   "I: ", I;
40
41  for( i = c; i > 0; i-- )
42  {
43    I[i] = I[i] + gen(k + i);
44  }
45
46//  DetailedPrint(I);
47
48  return(I);
49}
50
51static proc separateSyzGB( module J, int c )
52{
53  module II, G; vector v; int i;
54
55  J = simplify(J, 2);
56
57  for( i = ncols(J); i > 0; i-- )
58  {
59    v = J[i];
60    if( leadcomp(v) > c )
61    {
62      II[i] = v;
63    } else
64    {
65      G[i] = v; // leave only gen(i): i <= c
66    }
67  }
68
69  II = simplify(II, 2);
70  G = simplify(G, 2);
71
72  return (list(G, II));
73}
74
75static proc splitSyzGB( module J, int c )
76{
77  module JJ; vector v, vv; int i;
78
79  for( i = ncols(J); i > 0; i-- )
80  {
81    v = J[i];
82
83    vv = 0;
84
85    while( leadcomp(v) <= c )
86    {
87      vv = vv + lead(v);
88      v  = v  - lead(v);
89    }
90
91    J[i] = vv;
92    JJ[i] = v;
93  }
94
95  J = simplify(J, 2);
96  JJ = simplify(JJ, 2);
97
98  return (list(J, JJ));
99}
100
101
102static proc Sinit(module M)
103{
104  def @save = basering;
105
106  int @DEBUG = !system("with", "ndebug");
107  if( @DEBUG )
108  {
109    "Sinit::Input";
110    type(M);
111    DetailedPrint(M);
112    attrib(M);
113  }
114
115  int @RANK = nrows(M); int @SIZE = ncols(M);
116
117  int @IS_A_SB = attrib(M, "isSB"); // ??? only if all weights were zero?!
118
119  if( !@IS_A_SB )
120  {
121    M = std(M); // this should be faster than computing std in S (later on)
122  }
123
124  def S = MakeInducedSchreyerOrdering(1); // 1 puts history terms to the back
125  // TODO: NOTE: +1 causes trouble to Singular interpreter!!!???
126  setring S; // a new ring with a Schreyer ordering
127
128  if( @DEBUG )
129  {
130    "Sinit::StartingISRing";
131    basering;
132//    DetailedPrint(basering);
133  }
134
135  // Setup the leading syzygy^{-1} module to zero:
136  module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0));
137
138  module MRES = Z;
139
140  list RES; RES[1] = Z;
141
142  module F = freemodule(@RANK);
143  intvec @V = deg(F[1..@RANK]);
144
145  module M = imap(@save, M);
146  attrib(M, "isHomog", @V);
147  attrib(M, "isSB", 1);
148
149
150  if( @DEBUG )
151  {
152    "Sinit::SB_Input: ";
153    type(M);
154    attrib(M);
155    attrib(M, "isHomog");
156    DetailedPrint(M);
157  }
158
159  // 0^th syz. property
160  if( size(module(transpose( transpose(M) * transpose(MRES) ))) > 0 )
161  {
162    transpose( transpose(M) * transpose(MRES) );
163    "transpose( transpose(M) * transpose(MRES) ) != 0!!!";
164    \$
165  }
166
167  RES[size(RES)+1] = M; // list of all syzygy modules
168  MRES = MRES, M;
169
170  attrib(MRES, "isHomog", @V);
171
173  attrib(S, "InducionStart", @RANK);
174
175  if( @DEBUG )
176  {
177    "Sinit::MRES";
178    DetailedPrint(MRES);
179    attrib(MRES, "isHomog");
180    attrib(S);
181  }
182
183  export RES;
184  export MRES;
185  return (S);
186}
187
188static proc Sstep()
189{
190  int @DEBUG = !system("with", "ndebug");
191
192  if( @DEBUG )
193  {
194    "Sstep::NextInducedRing";
195    DetailedPrint(basering);
196
198    attrib(basering, "InducionStart");
199
200    GetInducedData();
201  }
202
203  // syzygy step:
204
205/*
206  // is initial weights are all zeroes!
208  intvec @V = deg(M[1..ncols(M)]);  @W;  @V;  @W = @V;  attrib(L, "isHomog", @W);
209  SetInducedReferrence(L, @RANK, 0);
210*/
211
213//  @W = @W, @V;
214//  attrib(L, "isHomog", @W);
215
216
217  // General setting:
218//  SetInducedReferrence(MRES, 0, 0); // limit: 0!
219  int @l = size(RES);
220
221  module M = RES[@l];
222
223  module L = attrib(basering, "InducionLeads");
224  int limit = attrib(basering, "InducionStart");
225
226//  L;  limit;
227
228  int @RANK = ncols(MRES) - ncols(M); // nrows(M); // what if M is zero?!
229
230/*
231  if( @RANK !=  nrows(M) )
232  {
233    type(MRES);
234    @RANK;
235    type(M);
236    pause();
237  }
238*/
239
240  intvec @W = attrib(M, "isHomog");
241  intvec @V = deg(M[1..ncols(M)]);
242  @V = @W, @V;
243
244  if( @DEBUG )
245  {
246    "Sstep::NextInput: ";
247    M;
248    @V;
249    @RANK;
250    DetailedPrint(MRES);
251    attrib(MRES, "isHomog");
252  }
253
254
255
256  SetInducedReferrence(L, limit, 0);
257
258  def K = prepareSyz(M, @RANK);
259//  K;
260
261//   attrib(K, "isHomog", @V);   DetailedPrint(K, 1000);
262
263//  pause();
264
265  K = idPrepare(K, @RANK); // std(K); // ?
266  K = simplify(K, 2);
267
268//  K;
269
270  module N = separateSyzGB(K, @RANK)[2]; // 1^st syz. module: vectors which start in lower part (comp >= @RANK)
271  attrib(N, "isHomog", @V);
272
273// "N_0: "; N; DetailedPrint(N, 10);
274
275  N = std(N); // TODO: fix "wrong weights"!!!?
276  attrib(N, "isHomog", @V);
277
278//  N;
279
280  if( size(N) > 0 )
281  {
282    // next syz. property
283    if( size(module(transpose( transpose(N) * transpose(MRES) ))) > 0 )
284    {
285      MRES;
286
287      "N: "; N; DetailedPrint(N, 10);
288
289      "K:"; K; DetailedPrint(K, 10);
290
291      "RANKS: ", @RANK;
292
293      "transpose( transpose(N) * transpose(MRES) ) != 0!!!";
294      transpose( transpose(N) * transpose(MRES) );
295
296      "transpose(N) * transpose(MRES): ";
297      transpose(N) * transpose(MRES);
298      DetailedPrint(module(_), 2);
299      \$
300    }
301  }
302
303  RES[@l + 1] = N; // list of all syzygy modules
304
305  MRES = MRES, N;
306  attrib(MRES, "isHomog", @V);
307
308
311
312  if( @DEBUG )
313  {
314    "Sstep::NextSyzOutput: ";
315    DetailedPrint(N);
316    attrib(N, "isHomog");
317  }
318
319}
320
321proc Scontinue(int l)
322"USAGE:  Scontinue(l)
323RETURN:  nothing, instead it changes RES and MRES variables in the current ring
324PURPOSE: computes further (at most l) syzygies
325NOTE:    must be used within a ring returned by Sres or Ssyz. RES and MRES are
326         explained in Sres
327EXAMPLE: example Scontinue; shows an example
328"
329{
330  def data = GetInducedData();
331
332  if( (!defined(RES)) || (!defined(MRES)) || (typeof(data) != "list") || (size(data) != 2) )
333  {
334    ERROR("Sorry, but basering does not seem to be returned by Sres or Ssyz");
335  }
336  for (;  (l != 0) && (size(RES[size(RES)]) > 0); l-- )
337  {
338    Sstep();
339  }
340}
341example
342{ "EXAMPLE:"; echo = 2;
343  ring r;
344  module M = maxideal(1); M;
345  def S = Ssyz(M); setring S; S;
346  "Only the first syzygy: ";
347  RES; MRES;
348  "More syzygies: ";
349  Scontinue(10);
350  RES; MRES;
351}
352
353proc Ssyz(module M)
354"USAGE:  Ssyz(M)
355RETURN:  ring, containing a list of modules RES and a module MRES
356PURPOSE: computes the first syzygy module of M (wrt some Schreyer ordering)
357NOTE:    The output is explained in Sres
358EXAMPLE: example Ssyz; shows an example
359"
360{
361  def S = Sinit(M); setring S;
362
363  Sstep(); // NOTE: what if M is zero?
364
365  return (S);
366}
367example
368{ "EXAMPLE:"; echo = 2;
369  ring r;
370  module M = maxideal(1); M;
371  def S = Ssyz(M); setring S; S;
372  "Only the first syzygy: ";
373  RES;
374  MRES; // Note gen(i)
375  kill S;
376  setring r; kill M;
377
378  module M = 0;
379  def S = Ssyz(M); setring S; S;
380  "Only the first syzygy: ";
381  RES;
382  MRES;
383}
384
385proc Sres(module M, int l)
386"USAGE:  Sres(M, l)
387RETURN:  ring, containing a list of modules RES and a module MRES
388PURPOSE: computes (at most l) syzygy modules of M wrt the classical Schreyer
389         induced ordering with gen(i) > gen(j) if i > j, provided both gens
390         are from the same syzygy level.
391NOTE:    RES contains the images of maps subsituting the beginning of the
392         Schreyer free resolution of baseRing^r/M, while MRES is a sum of
393         these images in a big free sum, containing all the syzygy modules.
394         The syzygy modules are shifted so that gen(i) correspons to MRES[i].
395         The leading zero module RES[0] indicates the fact that coker of the
396         first map is zero. The number of zeroes inducates the rank of input.
397NOTE:    If l == 0 then l is set to be nvars(basering) + 1
398EXAMPLE: example Sres; shows an example
399"
400{
401  def S = Sinit(M); setring S;
402
403  if (l == 0)
404  {
405    l = nvars(basering) + 1; // not really an estimate...?!
406  }
407
408  Sstep(); l = l - 1;
409
410  Scontinue(l);
411
412  return (S);
413}
414example
415{ "EXAMPLE:"; echo = 2;
416  ring r;
417  module M = maxideal(1); M;
418  def S = Sres(M, 0); setring S; S;
419  RES;
420  MRES;
421  kill S;
422  setring r; kill M;
423
424  def A = nc_algebra(-1,0); setring A;
425  ideal Q = var(1)^2, var(2)^2, var(3)^2;
426  qring SCA = twostd(Q);
427  basering;
428
429  module M = maxideal(1);
430  def S = Sres(M, 2); setring S; S;
431  RES;
432  MRES;
433}
434
435
436
437// ================================================================== //
438
439
440LIB "general.lib"; // for sort
441
442// TODO: in C++!
443static proc Tail(def M)
444{
445  int i = ncols(M); def m;
446  while (i > 0)
447  {
448    m = M[i];
449
450    m = m - lead(m); // m = tail(m)
451
452    M[i] = m;
453
454    i--;
455  }
456  return (M);
457}
458
459/* static */ proc SSinit(module M)
460{
461  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
462  {
463    ERROR("Sorry: need an ideal or a module for input");
464  }
465
466  // TODO! DONE?
467  def @save = basering;
468
469  int @DEBUG = !system("with", "ndebug");
470  if( @DEBUG )
471  {
472    "SSinit::Input";
473    type(M);
474    DetailedPrint(M);
475    attrib(M);
476  }
477
478  int @RANK = nrows(M); int @SIZE = ncols(M);
479
480  int @IS_A_SB = attrib(M, "isSB"); // ??? only if all weights were zero?!
481
482  if( !@IS_A_SB )
483  {
484    def opts = option(get);
485    option(redSB); option(redTail);
486    M = std(M);
487    option(set, opts);
488    kill opts;
489  } else
490  {
491    M = simplify(M, 2 + 4 + 32);
492  }
493
495
496  // sort wrt neg.deg.rev.lex!
497  intvec iv_ds = sort(LEAD, "ds", 1)[2]; // ,1 => reversed!
498
499  M = M[iv_ds]; // sort M wrt ds on current leading terms
501
502  def TAIL = Tail(M);
503
504  intvec @DEGS = deg(M[1..@SIZE]); // store actuall degrees of input elements
505
506  // TODO: what about real modules? weighted ones?
507
508  list @l = ringlist(@save);
509
510  int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]);
511
512  // NOTE: @wdeg will be ignored anyway :(
513  @l[3] = list(list("C", @z), list("lp", @wdeg));
514
515  kill @z, @wdeg; // since these vars are ring independent!
516
517  def S = ring(@l); // --MakeInducedSchreyerOrdering(1);
518
519  module F = freemodule(@RANK);
520  intvec @V = deg(F[1..@RANK]);
521
522  setring S; // ring with an easy divisibility test ("C, lex")
523
524  if( @DEBUG )
525  {
526    "SSinit::StartingISRing";
527    basering;
528//    DetailedPrint(basering);
529  }
530
531  // Setup the leading syzygy^{-1} module to zero:
532  module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0));
533
534  module MRES = Z;
535
536  list RES;  RES[1] = Z;
537  list LRES; LRES[1] = Z;
538  list TRES; TRES[1] = Z;
539
540  def M = imap(@save, M);
541  attrib(M, "isHomog", @V);
542  attrib(M, "isSB", 1);
543
544  attrib(M, "degrees", @DEGS);
545
549
550  def TAIL = imap(@save, TAIL);
551
552  if( @DEBUG )
553  {
554    "SSinit::(sorted) SB_Input: ";
555    type(M);
556    attrib(M);
557    attrib(M, "isHomog");
558    DetailedPrint(M);
559  }
560
561  // 0^th syz. property
562  if( size(module(transpose( transpose(M) * transpose(MRES) ))) > 0 )
563  {
564    transpose( transpose(M) * transpose(MRES) );
565    "ERROR: transpose( transpose(M) * transpose(MRES) ) != 0!!!";
566    \$
567  }
568
569  RES[size(RES)+1] = M; // list of all syzygy modules
570  LRES[size(LRES)+1] = LEAD; // list of all syzygy modules
571  TRES[size(TRES)+1] = TAIL; // list of all syzygy modules
572
573  MRES = MRES, M; //?
574
575  attrib(MRES, "isHomog", @V);
576
577  attrib(S, "InducionStart", @RANK);
578
579  if( @DEBUG )
580  {
581    "SSinit::MRES";
582    DetailedPrint(MRES);
583    attrib(MRES, "isHomog");
584    attrib(S);
585  }
586
587  export RES;
588  export MRES;
589  export LRES;
590  export TRES;
591  return (S);
592}
593example
594{ "EXAMPLE:"; echo = 2;
595  ring R = 0, (w, x, y, z), dp;
596
597  def M = maxideal(1);
598  def S = SSinit(M); setring S; S;
599
600  "Only the first initialization: ";
601  RES; LRES; TRES;
602  MRES;
603
604  kill S; setring R; kill M;
605
606  ideal M = w^2 - x*z,  w*x - y*z,  x^2 - w*y, x*y - z^2, y^2 - w*z;
607  def S = SSinit(M); setring S; S;
608
609  "Only the first initialization: ";
610  RES; LRES; TRES;
611  MRES;
612
613  kill S; setring R; kill M;
614}
615
616// module (N, LL, TT) = SSComputeSyzygy(L, T, @RANK); // shift syz.comp by @RANK!
617proc SSComputeSyzygy(def M, def L, def T, int iCompShift)
618{
619  int @DEBUG = !system("with", "ndebug");
620
621  if( @DEBUG )
622  {
623    "SSComputeSyzygy::Input";
624    "basering: ", basering; attrib(basering);
625//    DetailedPrint(basering);
626
627    "iCompShift: ", iCompShift;
628
629    "M: "; M;
630    "L: "; L;
631    "T: "; T;
632  }
633
634
635  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
636  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
637  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
638  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
639  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
640  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
641  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
642
643
644  def opts = option(get); option(redSB); option(redTail);
645  module SYZ = std(syz(M)); // TODO: !!!!!!!!!!!
646  option(set, opts); kill opts;
647
648  "SYZ: ";  SYZ;  print(SYZ);
649
650  module Z; Z[iCompShift] = 0; Z = Z, transpose(SYZ); SYZ = transpose(Z);
651
652  "shifted SYZ: ";  SYZ;  print(SYZ);
653
654  module LL, TT;
655
656  LL = lead(SYZ); // TODO: WRONG ORDERING!!!!!!!!
657  TT = Tail(SYZ);
658
659
660  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
661  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
662  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
663  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
664  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
665  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
666  // !!!!!!!!!!!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!! //
667
668  intvec iv_ds = sort(LL, "ds", 1)[2]; // ,1 => reversed!
669  LL = LL[iv_ds];
670  TT = TT[iv_ds];
671
672  if( @DEBUG )
673  {
674    "SSComputeSyzygy::Output";
675
676    "SYZ: "; SYZ;
677    "LL: "; LL;
678    "TT: "; TT;
679  }
680
681  return (SYZ, LL, TT);
682}
683
684// resolution/syzygy step:
685static proc SSstep()
686{
687  /// TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
688  int @DEBUG = !system("with", "ndebug");
689
690  if( @DEBUG )
691  {
692    "SSstep::NextInducedRing";
693    "basering: ", basering; attrib(basering);
694//    DetailedPrint(basering);
695  }
696
697/*
698  // is initial weights are all zeroes!
700  intvec @V = deg(M[1..ncols(M)]);  @W;  @V;  @W = @V;  attrib(L, "isHomog", @W);
701  SetInducedReferrence(L, @RANK, 0);
702*/
703
705//  @W = @W, @V;
706//  attrib(L, "isHomog", @W);
707
708
709  // General setting:
710//  SetInducedReferrence(MRES, 0, 0); // limit: 0!
711  int @l = size(RES);
712
713  def M =  RES[@l];
714
715  def L = LRES[@l];
716  def T = TRES[@l];
717
718
719  //// TODO: wrong !!!!!
720  int @RANK = ncols(MRES) - ncols(M); // nrows(M); // what if M is zero?!
721
722
723
724/*
725  if( @RANK !=  nrows(M) )
726  {
727    type(MRES);
728    @RANK;
729    type(M);
730    pause();
731  }
732*/
733
734  intvec @W = attrib(M, "isHomog"); intvec @V = attrib(M, "degrees"); @V = @W, @V;
735
736  if( @DEBUG )
737  {
738    "Sstep::NextInput: ";
739    M;
740    L;
741    @V;
742    @RANK;
743    DetailedPrint(MRES);
744    attrib(MRES, "isHomog");
745  }
746
747
748  // TODO: N  = SYZ( M )!!!
749  module N, LL, TT; (N, LL, TT) = SSComputeSyzygy(M, L, T, @RANK); // shift syz.comp by @RANK!
750
751  attrib(N, "isHomog", @V);
752
753  // TODO: correct the following:
754  intvec @DEGS = deg(N[1..ncols(N)]); // no mod. comp. weights :(
755  attrib(N, "degrees", @DEGS);
756
757  if( size(N) > 0 )
758  {
759    N;
760    MRES;
761    // next syz. property
762    if( size(module(transpose( transpose(N) * transpose(MRES) ))) > 0 )
763    {
764      MRES;
765
766      "N: "; N; // DetailedPrint(N, 2);
767
768      "LL:"; LL; // DetailedPrint(LL, 1);
769      "TT:"; TT; // DetailedPrint(TT, 10);
770
771      "RANKS: ", @RANK;
772
773      "transpose( transpose(N) * transpose(MRES) ) != 0!!!";
774      transpose( transpose(N) * transpose(MRES) );
775
776      "transpose(N) * transpose(MRES): ";
777      transpose(N) * transpose(MRES);
778      // DetailedPrint(module(_), 2);
779      \$
780    }
781  }
782
783   RES[@l + 1] = N; // list of all syzygy modules
784  LRES[@l + 1] = LL; // list of all syzygy modules
785  TRES[@l + 1] = TT; // list of all syzygy modules
786
787  MRES = MRES, N;
788  attrib(MRES, "isHomog", @V);
789
791
792  if( @DEBUG )
793  {
794    "SSstep::NextSyzOutput: ";
795    DetailedPrint(N);
796    attrib(N);
797  }
798
799}
800
801proc SScontinue(int l)
802"USAGE:  SScontinue(l)
803RETURN:  nothing, instead it changes RES and MRES variables in the current ring
804PURPOSE: computes further (at most l) syzygies
805NOTE:    must be used within a ring returned by Sres or Ssyz. RES and MRES are
806         explained in Sres
807EXAMPLE: example Scontinue; shows an example
808"
809{
810
811  /// TODO!
812//  def data = GetInducedData();
813
814  if( (!defined(RES)) || (!defined(MRES)) ) /* || (typeof(data) != "list") || (size(data) != 2) */
815  {
816    ERROR("Sorry, but basering does not seem to be returned by Sres or Ssyz");
817  }
818  for (;  (l != 0) && (size(RES[size(RES)]) > 0); l-- )
819  {
820    SSstep();
821  }
822}
823example
824{ "EXAMPLE:"; echo = 2;
825  ring r;
826  module M = maxideal(1); M;
827  def S = SSsyz(M); setring S; S;
828  "Only the first syzygy: ";
829  RES; MRES;
830  "More syzygies: ";
831  SScontinue(10);
832  RES; MRES;
833}
834
835proc SSsyz(def M)
836"USAGE:  SSsyz(M)
837RETURN:  ring, containing a list of modules RES and a module MRES
838PURPOSE: computes the first syzygy module of M (wrt some Schreyer ordering)?
839NOTE:    The output is explained in Sres
840EXAMPLE: example Ssyz; shows an example
841"
842{
843  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
844  {
845    ERROR("Sorry: need an ideal or a module for input");
846  }
847
848  def SS = SSinit(M); setring SS;
849
850  SSstep(); // NOTE: what if M is zero?
851
852  return (SS);
853}
854example
855{ "EXAMPLE:"; echo = 2;
856  ring r;
857
858/*  ideal M = 0;
859  def S = SSsyz(M); setring S; S;
860  "Only the first syzygy: ";
861  RES; LRES; TRES;
862  MRES;
863
864  kill S; setring r; kill M;
865*/
866
867  module M = maxideal(1); M;
868  def S = SSsyz(M); setring S; S;
869  "Only the first syzygy: ";
870  RES; LRES; TRES;
871  MRES;
872
873  kill S; setring r; kill M;
874
875  kill r;
876
877  ring R = 0, (w, x, y, z), dp;
878  ideal M = w^2 - x*z,  w*x - y*z,  x^2 - w*y, x*y - z^2, y^2 - w*z;
879
880  def S = SSsyz(M); setring S; S;
881  "Only the first syzygy: ";
882  RES; LRES; TRES;
883  MRES;
884}
885
886proc SSres(def M, int l)
887"USAGE:  SSres(I, l)
888RETURN:  ring, containing a list of modules RES and a module MRES
889PURPOSE: computes (at most l) syzygy modules of M wrt the classical Schreyer
890         induced ordering with gen(i) > gen(j) if i > j, provided both gens
891         are from the same syzygy level.???
892NOTE:    RES contains the images of maps subsituting the beginning of the
893         Schreyer free resolution of baseRing^r/M, while MRES is a sum of
894         these images in a big free sum, containing all the syzygy modules.
895         The syzygy modules are shifted so that gen(i) correspons to MRES[i].
896         The leading zero module RES[0] indicates the fact that coker of the
897         first map is zero. The number of zeroes inducates the rank of input.
898NOTE:    If l == 0 then l is set to be nvars(basering) + 1
899EXAMPLE: example SSres; shows an example
900"
901{
902  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
903  {
904    ERROR("Sorry: need an ideal or a module for input");
905  }
906
907  def SS = SSinit(M); setring SS;
908
909  if (l == 0)
910  {
911    l = nvars(basering) + 1; // not really an estimate...?!
912  }
913
914  SSstep(); l = l - 1;
915
916  SScontinue(l);
917
918  return (SS);
919}
920example
921{ "EXAMPLE:"; echo = 2;
922  ring r;
923  module M = maxideal(1); M;
924  def S = SSres(M, 0); setring S; S;
925  RES;
926  MRES;
927  kill S;
928  setring r; kill M;
929
930  def A = nc_algebra(-1,0); setring A;
931  ideal Q = var(1)^2, var(2)^2, var(3)^2;
932  qring SCA = twostd(Q);
933  basering;
934
935  module M = maxideal(1);
936  def S = SSres(M, 2); setring S; S;
937  RES;
938  MRES;
939}
940
941
942
944{
945  int @DEBUG = !system("with", "ndebug");
946
947  if( @DEBUG )
948  {
949
950    "ndebug?: ", system("with", "ndebug");
951    "om_ndebug?: ", system("with", "om_ndebug");
952
953    listvar(Top);
954    listvar(Schreyer);
955  }
956//  listvar(Syzextra); listvar(Syzextra_g);
957
958  if( !defined(DetailedPrint) )
959  {
960    if( !@DEBUG )
961    {
962
963      if( @DEBUG )
964      {
966      }
968
969      if( @DEBUG )
970      {
971        listvar(Syzextra);
972      }
973
974//      export Syzextra;
975
976//      exportto(Schreyer, Syzextra::noop);
977      exportto(Schreyer, Syzextra::DetailedPrint);
981//      exportto(Schreyer, Syzextra::ISUpdateComponents);
982      exportto(Schreyer, Syzextra::SetInducedReferrence);
983      exportto(Schreyer, Syzextra::GetInducedData);
984//      exportto(Schreyer, Syzextra::GetAMData);
985//      exportto(Schreyer, Syzextra::SetSyzComp);
986      exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering);
987//      exportto(Schreyer, Syzextra::MakeSyzCompOrdering);
988      exportto(Schreyer, Syzextra::idPrepare);
989//      exportto(Schreyer, Syzextra::reduce_syz);
990//      exportto(Schreyer, Syzextra::p_Content);
991
992    }
993    else
994    {
995      if( @DEBUG )
996      {
998      }
999
1001
1002      if( @DEBUG )
1003      {
1004        listvar(Syzextra_g);
1005      }
1006
1007//      export Syzextra_g;
1008//      exportto(Schreyer, Syzextra_g::noop);
1009      exportto(Schreyer, Syzextra_g::DetailedPrint);
1013//      exportto(Schreyer, Syzextra_g::ISUpdateComponents);
1014      exportto(Schreyer, Syzextra_g::SetInducedReferrence);
1015      exportto(Schreyer, Syzextra_g::GetInducedData);
1016//      exportto(Schreyer, Syzextra_g::GetAMData);
1017//      exportto(Schreyer, Syzextra_g::SetSyzComp);
1018      exportto(Schreyer, Syzextra_g::MakeInducedSchreyerOrdering);
1019//      exportto(Schreyer, Syzextra_g::MakeSyzCompOrdering);
1020      exportto(Schreyer, Syzextra_g::idPrepare);
1021//      exportto(Schreyer, Syzextra_g::reduce_syz);
1022//      exportto(Schreyer, Syzextra_g::p_Content);
1023
1024
1025    }
1026
1027    exportto(Top, DetailedPrint);
1028    exportto(Top, GetInducedData);
1029
1030    if( @DEBUG )
1031    {
1032      listvar(Top);
1033      listvar(Schreyer);
1034    }
1035  }
1036
1037  if( !defined(GetInducedData) )
1038  {
1039    ERROR("Sorry but we are missing the dynamic module (syzextra(_g)?.so)...");
1040  }
1041
1042}
1043
1044static proc mod_init()
1045{
1047}
1048
1049
1050proc testallSexamples()
1051{
1052  example Ssyz;
1053  example Scontinue;
1054  example Sres;
1055}
1056
1057proc testallSSexamples()
1058{
1059  example SSsyz;
1060  example SScontinue;
1061  example SSres;
1062}
1063
1064example
1065{ "EXAMPLE:"; echo = 2;
1066  testallSexamples();
1067  testallSSexamples();
1068}
Note: See TracBrowser for help on using the repository browser.