# source:git/Singular/LIB/schreyer.lib@4b2e47

spielwiese
Last change on this file since 4b2e47 was 4b2e47, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
first iteration: mostly prototype in Singular Script... without preliminary computation of 2nd syz. terms and any optimizations! add: Mi (critical leading syzygy terms) add: basic "Reduce"!
• Property mode set to `100644`
File size: 24.9 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(def 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    MRES;
583//    DetailedPrint(MRES);
584    attrib(MRES, "isHomog");
585    attrib(S);
586  }
587
588  export RES;
589  export MRES;
590  export LRES;
591  export TRES;
592  return (S);
593}
594example
595{ "EXAMPLE:"; echo = 2;
596  ring R = 0, (w, x, y, z), dp;
597
598  def M = maxideal(1);
599  def S = SSinit(M); setring S; S;
600
601  "Only the first initialization: ";
602  RES; LRES; TRES;
603  MRES;
604
605  kill S; setring R; kill M;
606
607  ideal M = w^2 - x*z,  w*x - y*z,  x^2 - w*y, x*y - z^2, y^2 - w*z;
608  def S = SSinit(M); setring S; S;
609
610  "Only the first initialization: ";
611  RES; LRES; TRES;
612  MRES;
613
614  kill S; setring R; kill M;
615}
616
617
618LIB "poly.lib"; // for lcm
619
620
622{
623  int @DEBUG = !system("with", "ndebug");
624
625  if( @DEBUG )
626  {
628    L;
629    "iCompShift: ", iCompShift;
630  }
631
632  int i, j, r; intvec iv_ds;
633  int N = ncols(L);
634  def a, b;
635  poly aa, bb;
636
637  bigint c;
638
639  ideal M;
640
641  module S = 0;
642
643  for(i = 1; i <= N; i++)
644  {
645    a = L[i];
646//    "a: ", a;
648    r = int(c);
649
650    if(r > 0)
651    {
652      aa = a[r];
653    } else
654    {
655      aa = a;
656    }
657
658    M = 0;
659
660    for(j = i-1; j > 0; j--)
661    {
662      b = L[j];
663//      "b: ", b;
664
665      if( leadcomp(b) == c )
666      {
667        if(r > 0)
668        {
669          bb = b[r];
670        } else
671        {
672          bb = b;
673        }
674
675        M[j] = (lcm(aa, bb) / aa);
676      }
677    }
678
679    // TODO: add quotient relations here...
680
681    M = simplify(M, 1 + 2 + 32);
682
683    iv_ds = sort(M, "ds", 1)[2]; // ,1 => reversed!
684
685    M = M[iv_ds];
686
687    S = S, M * gen(i + iCompShift);
688  }
689
690  S = simplify(S, 2);
691
692
693  if( @DEBUG )
694  {
696    S;
697  }
698
699  attrib(S, "isSB", 1);
700
701  return (S);
702
703}
704
705proc SSReduce(poly m, def t, def L, def T, module LS)
706{
707  int @DEBUG = !system("with", "ndebug");
708
709  if( @DEBUG )
710  {
711    "SSReduce::Input: ";
712
713    "mult: ", m;
714    "term: ", t;
715    "L: ", L;
716    "T: ", T;
717    "LS: ", LS;
718  }
719
720  vector s = 0;
721
722  if( t == 0 )
723  {
724    return (s);
725  }
726
727  def product = m * t;
728
730  int r = int(c);
731
732
733  def a, b, nf;
734
735  // looking for an appropriate reducer
736  for( int k = ncols(L); k > 0; k-- )
737  {
738    a = L[k];
739    // with the same mod. component
740    if( leadcomp(a) == c )
741    {
743      // which divides the product
744      if( b != 0 )
745      {
746//        "b: ", b;
747        nf = NF(b * gen(k), LS);
748
749//        "NF: ", nf;
750        // while the complement (the fraction) is not reducible by leading syzygies
751        if( nf != 0 )
752        {
753          s = b * gen(k) + SSTraverse(b, k, L, T, LS);
754          break;
755        }
756      }
757    }
758  }
759  if( @DEBUG )
760  {
761    "SSReduce::Output: ", s;
762  }
763  return (s);
764}
765
766proc SSTraverse(poly m, int i, def L, def T, module LS)
767{
768  int @DEBUG = !system("with", "ndebug");
769
770  if( @DEBUG )
771  {
772    "SSTraverse::Input: ";
773
774    "index: ", i;
775    "mult: ", m;
776
778    "tail: ", T[i];
779
780    "LSyz: ", LS;
781  }
782
783  //  reduce the product m * ( L[i] + T[i] ):
784//  SSReduce(m, L[i], L, T, LS);
785
786  def @tail = T[i]; def @l;
787
788  vector s = 0;
789
790  while( size(@tail) > 0 )
791  {
793    s = s + SSReduce(m, @l, L, T, LS);
794    @tail = @tail - @l;
795  }
796
797  if( @DEBUG )
798  {
799    "SSTraverse::Output: ", s;
800  }
801  return (s);
802}
803
804// module (N, LL, TT) = SSComputeSyzygy(L, T, @RANK); // shift syz.comp by @RANK!
805proc SSComputeSyzygy(def M, def L, def T, int iCompShift)
806{
807  int @DEBUG = !system("with", "ndebug");
808
809  if( @DEBUG )
810  {
811    "SSComputeSyzygy::Input";
812    "basering: ", basering; attrib(basering);
813//    DetailedPrint(basering);
814
815    "iCompShift: ", iCompShift;
816
817    "M: "; M;
818    "L: "; L;
819    "T: "; T;
820  }
821
822  def a; bigint c; int r, k; poly aa;
823
824  module LL = SSComputeLeadingSyzygyTerms(L, 0); // iCompShift // 0?
825
826  module TT, SYZ;
827
828  if( size(LL) > 0 )
829  {
830    intvec iv_ds = sort(LL, "ds", 1)[2]; // ,1 => reversed!
831    LL = LL[iv_ds];
832
833    vector @tail;
834
835    for(k = ncols(LL); k > 0; k-- )
836    {
837      a = LL[k];
838      c = leadcomp(a); r = int(c);
839
840      if (r > 0)
841      {
842        aa = a[r];
843      } else
844      {
845        aa = a;
846      }
847  //    "A: ", a, " --->>>> ", aa, " **** [", r, "]: ";
848      @tail = SSReduce(aa, L[r], L, T, LL) + SSTraverse(aa, r, L, T, LL);
849      TT[k] = @tail;
850      SYZ[k] = a + @tail;
851    }
852  }
853
854  module Z;
855  Z = 0; Z[iCompShift] = 0; Z = Z, transpose(LL);   LL = transpose(Z);
856  Z = 0; Z[iCompShift] = 0; Z = Z, transpose(TT);   TT = transpose(Z);
857  Z = 0; Z[iCompShift] = 0; Z = Z, transpose(SYZ); SYZ = transpose(Z);
858
859
860/*
861  def opts = option(get); option(redSB); option(redTail);
862  module SYZ = std(syz(M)); // TODO: !!!!!!!!!!!
863  option(set, opts); kill opts;
864
865  "SYZ: ";  SYZ;  print(SYZ);
866
867  "shifted SYZ: ";  SYZ;  print(SYZ);
868
869  module LL, TT;
870
871  LL = lead(SYZ); // TODO: WRONG ORDERING!!!!!!!!
872  TT = Tail(SYZ);
873*/
874
875  if( @DEBUG )
876  {
877    "SSComputeSyzygy::Output";
878
879    "SYZ: "; SYZ;
880    "LL: "; LL;
881    "TT: "; TT;
882  }
883
884  return (SYZ, LL, TT);
885}
886
887// resolution/syzygy step:
888static proc SSstep()
889{
890  /// TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
891  int @DEBUG = !system("with", "ndebug");
892
893  if( @DEBUG )
894  {
895    "SSstep::NextInducedRing";
896    "basering: ", basering; attrib(basering);
897  }
898
899/*
900  // is initial weights are all zeroes!
902  intvec @V = deg(M[1..ncols(M)]);  @W;  @V;  @W = @V;  attrib(L, "isHomog", @W);
903  SetInducedReferrence(L, @RANK, 0);
904*/
905
907//  @W = @W, @V;
908//  attrib(L, "isHomog", @W);
909
910
911  // General setting:
912//  SetInducedReferrence(MRES, 0, 0); // limit: 0!
913  int @l = size(RES);
914
915  def M =  RES[@l];
916
917  def L = LRES[@l];
918  def T = TRES[@l];
919
920
921  //// TODO: wrong !!!!!
922  int @RANK = ncols(MRES) - ncols(M); // nrows(M); // what if M is zero?!
923
924
925
926/*
927  if( @RANK !=  nrows(M) )
928  {
929    type(MRES);
930    @RANK;
931    type(M);
932    pause();
933  }
934*/
935
936  intvec @W = attrib(M, "isHomog"); intvec @V = attrib(M, "degrees"); @V = @W, @V;
937
938  if( @DEBUG )
939  {
940    "Sstep::NextInput: ";
941    M;
942    L;
943    @V;
944    @RANK;
945//    DetailedPrint(MRES);
946    attrib(MRES, "isHomog");
947  }
948
949
950  // TODO: N  = SYZ( M )!!!
951  module N, LL, TT; (N, LL, TT) = SSComputeSyzygy(M, L, T, @RANK); // shift syz.comp by @RANK!
952
953  attrib(N, "isHomog", @V);
954
955  // TODO: correct the following:
956  intvec @DEGS = deg(N[1..ncols(N)]); // no mod. comp. weights :(
957  attrib(N, "degrees", @DEGS);
958
959  if( size(N) > 0 )
960  {
961    N;
962    MRES;
963    // next syz. property
964    if( size(module(transpose( transpose(N) * transpose(MRES) ))) > 0 )
965    {
966      MRES;
967
968      "N: "; N; // DetailedPrint(N, 2);
969
970      "LL:"; LL; // DetailedPrint(LL, 1);
971      "TT:"; TT; // DetailedPrint(TT, 10);
972
973      "RANKS: ", @RANK;
974
975      "transpose( transpose(N) * transpose(MRES) ) != 0!!!";
976      transpose( transpose(N) * transpose(MRES) );
977
978      "transpose(N) * transpose(MRES): ";
979      transpose(N) * transpose(MRES);
980      // DetailedPrint(module(_), 2);
981      \$
982    }
983  }
984
985   RES[@l + 1] = N; // list of all syzygy modules
986  LRES[@l + 1] = LL; // list of all syzygy modules
987  TRES[@l + 1] = TT; // list of all syzygy modules
988
989  MRES = MRES, N;
990  attrib(MRES, "isHomog", @V);
991
993
994  if( @DEBUG )
995  {
996    "SSstep::NextSyzOutput: ";
997//    DetailedPrint(N);
998    attrib(N);
999  }
1000
1001}
1002
1003proc SScontinue(int l)
1004"USAGE:  SScontinue(l)
1005RETURN:  nothing, instead it changes RES and MRES variables in the current ring
1006PURPOSE: computes further (at most l) syzygies
1007NOTE:    must be used within a ring returned by Sres or Ssyz. RES and MRES are
1008         explained in Sres
1009EXAMPLE: example Scontinue; shows an example
1010"
1011{
1012
1013  /// TODO!
1014//  def data = GetInducedData();
1015
1016  if( (!defined(RES)) || (!defined(MRES)) ) /* || (typeof(data) != "list") || (size(data) != 2) */
1017  {
1018    ERROR("Sorry, but basering does not seem to be returned by Sres or Ssyz");
1019  }
1020  for (;  (l != 0) && (size(RES[size(RES)]) > 0); l-- )
1021  {
1022    SSstep();
1023  }
1024}
1025example
1026{ "EXAMPLE:"; echo = 2;
1027  ring r;
1028  module M = maxideal(1); M;
1029  def S = SSsyz(M); setring S; S;
1030  "Only the first syzygy: ";
1031  RES; MRES;
1032  "More syzygies: ";
1033  SScontinue(10);
1034  RES; MRES;
1035}
1036
1037proc SSsyz(def M)
1038"USAGE:  SSsyz(M)
1039RETURN:  ring, containing a list of modules RES and a module MRES
1040PURPOSE: computes the first syzygy module of M (wrt some Schreyer ordering)?
1041NOTE:    The output is explained in Sres
1042EXAMPLE: example Ssyz; shows an example
1043"
1044{
1045  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
1046  {
1047    ERROR("Sorry: need an ideal or a module for input");
1048  }
1049
1050  def SS = SSinit(M); setring SS;
1051
1052  SSstep(); // NOTE: what if M is zero?
1053
1054  return (SS);
1055}
1056example
1057{ "EXAMPLE:"; echo = 2;
1058  ring r;
1059
1060/*  ideal M = 0;
1061  def S = SSsyz(M); setring S; S;
1062  "Only the first syzygy: ";
1063  RES; LRES; TRES;
1064  MRES;
1065
1066  kill S; setring r; kill M;
1067*/
1068
1069  module M = maxideal(1); M;
1070  def S = SSres(M, 0); setring S; S;
1071  "Only the first syzygy: ";
1072  RES; LRES; TRES;
1073  MRES;
1074
1075  kill S; setring r; kill M;
1076
1077  kill r;
1078
1079  ring R = 0, (w, x, y, z), dp;
1080  ideal M = w^2 - x*z,  w*x - y*z,  x^2 - w*y, x*y - z^2, y^2 - w*z;
1081
1082  def S = SSres(M, 0); setring S; S;
1083  "Only the first syzygy: ";
1084  RES; LRES; TRES;
1085  MRES;
1086}
1087
1088proc SSres(def M, int l)
1089"USAGE:  SSres(I, l)
1090RETURN:  ring, containing a list of modules RES and a module MRES
1091PURPOSE: computes (at most l) syzygy modules of M wrt the classical Schreyer
1092         induced ordering with gen(i) > gen(j) if i > j, provided both gens
1093         are from the same syzygy level.???
1094NOTE:    RES contains the images of maps subsituting the beginning of the
1095         Schreyer free resolution of baseRing^r/M, while MRES is a sum of
1096         these images in a big free sum, containing all the syzygy modules.
1097         The syzygy modules are shifted so that gen(i) correspons to MRES[i].
1098         The leading zero module RES[0] indicates the fact that coker of the
1099         first map is zero. The number of zeroes inducates the rank of input.
1100NOTE:    If l == 0 then l is set to be nvars(basering) + 1
1101EXAMPLE: example SSres; shows an example
1102"
1103{
1104  if( (typeof(M) != "module") && (typeof(M) != "ideal") )
1105  {
1106    ERROR("Sorry: need an ideal or a module for input");
1107  }
1108
1109  def SS = SSinit(M); setring SS;
1110
1111  if (l == 0)
1112  {
1113    l = nvars(basering) + 1; // not really an estimate...?!
1114  }
1115
1116  SSstep(); l = l - 1;
1117
1118  SScontinue(l);
1119
1120  return (SS);
1121}
1122example
1123{ "EXAMPLE:"; echo = 2;
1124  ring r;
1125  module M = maxideal(1); M;
1126  def S = SSres(M, 0); setring S; S;
1127  RES;
1128  MRES;
1129  kill S;
1130  setring r; kill M;
1131
1132  def A = nc_algebra(-1,0); setring A;
1133  ideal Q = var(1)^2, var(2)^2, var(3)^2;
1134  qring SCA = twostd(Q);
1135  basering;
1136
1137  module M = maxideal(1);
1138  def S = SSres(M, 2); setring S; S;
1139  RES;
1140  MRES;
1141}
1142
1143
1144
1146{
1147  int @DEBUG = !system("with", "ndebug");
1148
1149  if( @DEBUG )
1150  {
1151
1152    "ndebug?: ", system("with", "ndebug");
1153    "om_ndebug?: ", system("with", "om_ndebug");
1154
1155    listvar(Top);
1156    listvar(Schreyer);
1157  }
1158//  listvar(Syzextra); listvar(Syzextra_g);
1159
1160  if( !defined(DetailedPrint) )
1161  {
1162    if( !@DEBUG )
1163    {
1164
1165      if( @DEBUG )
1166      {
1168      }
1170
1171      if( @DEBUG )
1172      {
1173        listvar(Syzextra);
1174      }
1175
1176//      export Syzextra;
1177
1178//      exportto(Schreyer, Syzextra::noop);
1179      exportto(Schreyer, Syzextra::DetailedPrint);
1183//      exportto(Schreyer, Syzextra::ISUpdateComponents);
1184      exportto(Schreyer, Syzextra::SetInducedReferrence);
1185      exportto(Schreyer, Syzextra::GetInducedData);
1186//      exportto(Schreyer, Syzextra::GetAMData);
1187//      exportto(Schreyer, Syzextra::SetSyzComp);
1188      exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering);
1189//      exportto(Schreyer, Syzextra::MakeSyzCompOrdering);
1190      exportto(Schreyer, Syzextra::idPrepare);
1191//      exportto(Schreyer, Syzextra::reduce_syz);
1192//      exportto(Schreyer, Syzextra::p_Content);
1193
1194    }
1195    else
1196    {
1197      if( @DEBUG )
1198      {
1200      }
1201
1203
1204      if( @DEBUG )
1205      {
1206        listvar(Syzextra_g);
1207      }
1208
1209//      export Syzextra_g;
1210//      exportto(Schreyer, Syzextra_g::noop);
1211      exportto(Schreyer, Syzextra_g::DetailedPrint);
1215//      exportto(Schreyer, Syzextra_g::ISUpdateComponents);
1216      exportto(Schreyer, Syzextra_g::SetInducedReferrence);
1217      exportto(Schreyer, Syzextra_g::GetInducedData);
1218//      exportto(Schreyer, Syzextra_g::GetAMData);
1219//      exportto(Schreyer, Syzextra_g::SetSyzComp);
1220      exportto(Schreyer, Syzextra_g::MakeInducedSchreyerOrdering);
1221//      exportto(Schreyer, Syzextra_g::MakeSyzCompOrdering);
1222      exportto(Schreyer, Syzextra_g::idPrepare);
1223//      exportto(Schreyer, Syzextra_g::reduce_syz);
1224//      exportto(Schreyer, Syzextra_g::p_Content);
1225
1226
1227    }
1228
1229    exportto(Top, DetailedPrint);
1230    exportto(Top, GetInducedData);
1231
1232    if( @DEBUG )
1233    {
1234      listvar(Top);
1235      listvar(Schreyer);
1236    }
1237  }
1238
1239  if( !defined(GetInducedData) )
1240  {
1241    ERROR("Sorry but we are missing the dynamic module (syzextra(_g)?.so)...");
1242  }
1243
1244}
1245
1246static proc mod_init()
1247{
1249}
1250
1251
1252proc testallSexamples()
1253{
1254  example Ssyz;
1255  example Scontinue;
1256  example Sres;
1257}
1258
1259proc testallSSexamples()
1260{
1261  example SSsyz;
1262  example SScontinue;
1263  example SSres;
1264}
1265
1266example
1267{ "EXAMPLE:"; echo = 2;
1268  testallSexamples();
1269  testallSSexamples();
1270}
Note: See TracBrowser for help on using the repository browser.