source: git/Singular/LIB/schreyer.lib @ 2b8fab

fieker-DuValspielwiese
Last change on this file since 2b8fab was f604741, checked in by Hans Schoenemann <hannes@…>, 6 years ago
cleanup: schreyer.lib
  • Property mode set to 100644
File size: 8.3 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="version schreyer.lib 4.1.1.1 Feb_2018 "; // $Id$
3category="General purpose";
4info="
5LIBRARY: schreyer.lib helpers for derham.lib
6AUTHOR:  Oleksandr Motsak <U@D>, where U={motsak}, D={mathematik.uni-kl.de}
7KEYWORDS: Schreyer ordering; Schreyer resolution; syzygy
8OVERVIEW:
9The library contains several procedures for computing a/part of Schreyer
10resoltion (cf. [SFO]), and some helpers for derham.lib (which requires
11resolutions over the homogenized Weyl algebra) for that purpose.
12The input for any resolution computation is a set of vectors M in form of a
13module over some basering R. The helpers works both in the commutative and
14non-commutative setting (cf. [MO]), that is the ring R may be non-commutative,
15in which case the ring ordering over it must be global. They produce/work with
16partial Schreyer resolutions of (R^rank(M))/M in form of a specially constructed
17ring (endowed with a special ring ordering that will be extended in the course
18of a resolution computation) containing the following objects:
19@* RES: the list of modules contains the images of maps (also called syzygy
20modules) substituting the computed beginning of a Schreyer resolution, that is,
21each syzygy module is given by a Groebner basis with respect to the
22corresponding Schreyer ordering. RES starts with a zero map given by rank(M)
23zero generators indicating that the image of the first differential map is
24zero. The second map RES[2] is given by M, which indicates that the resolution
25of (R^rank(M))/M is being computed.
26@* MRES: the module is a direct sum of modules from RES and thus comprises all
27computed differentials. Syzygies are shifted so that gen(i) is mapped to MRES[i]
28under the differential map.
29@* Here, we call a free resolution a Schreyer resolution if each syzygy
30module is given by a Groebner basis with respect to the corresponding Schreyer
31ordering. A Schreyer resolution can be much bigger than a minimal resolution of
32the same module, but may be easier to construct. The Schreyer ordering
33succesively extends the starting module ordering on M (defined in Singular by
34the basering R) and is extended to higher syzygies using the following
35definition:
36@* a < b if and only if (d(a)<d(b)) OR ( (d(a)=d(b) AND (comp(a)<comp(b)) ),
37@* where d(a) is the image of an under the differential (given by MRES), and
38comp(a) is the module component, for any module terms a and b from the same
39higher syzygy module.
40
41NOTE: Since most comutations require the module syzextra.so, please be make sure
42 to build it into Singular on Windows.
43
44REFERENCES:
45@*
46[BMSS] Burcin, E., Motsak, O., Schreyer, F.-O., Steenpass, A.:
47Refined algorithms to compute syzygies, 2015 (to appear).
48@*
49[SFO]  Schreyer, F.O.: Die Berechnung von Syzygien mit dem verallgemeinerten
50Weierstrassschen Divisionssatz, Master's thesis, Univ. Hamburg, 1980.
51@*
52[MO]   Motsak, O.: Non-commutative Computer Algebra with applications:
53Graded commutative algebra and related structures in Singular with applications,
54Ph.D. thesis, TU Kaiserslautern, 2010.
55
56PROCEDURES:
57  Sres(M,l)    helper for computing Schreyer resolution
58  Ssyz(M)      helper for computing Schreyer resolution of module M of length 1
59  Scontinue(l) helper for extending currently active resolution
60
61SEE ALSO: syz, sres, lres, res, fres
62";
63
64static proc prepareSyz( module I, list # )
65{
66  int i;
67  int k = 0;
68  int r = nrows(I);
69  int c = ncols(I);
70
71
72  if( size(#) > 0 )
73  {
74    if( typeof(#[1]) == "int" || typeof(#[1]) == "bigint" )
75    {
76      k = #[1];
77    }
78  }
79
80  if( k < r )
81  {
82    "// *** Wrong k: ", k, " < nrows: ", r, " => setting k = r = ", r;
83    k = r;
84  }
85
86//   "k: ", k;  "c: ", c;   "I: ", I;
87
88  for( i = c; i > 0; i-- )
89  {
90    I[i] = I[i] + gen(k + i);
91  }
92
93  return(I);
94}
95
96static proc separateSyzGB( module J, int c )
97{
98  module II, G; vector v; int i;
99
100  J = simplify(J, 2);
101
102  for( i = ncols(J); i > 0; i-- )
103  {
104    v = J[i];
105    if(   Syzextra::leadcomp(v) > c )
106    {
107      II[i] = v;
108    } else
109    {
110      G[i] = v; // leave only gen(i): i <= c
111    }
112  }
113
114  II = simplify(II, 2);
115  G = simplify(G, 2);
116
117  return (list(G, II));
118}
119
120static proc Sinit(module M)
121{
122  def @save = basering;
123
124  int @DEBUG = 0; // !system("with", "ndebug");
125
126  int @RANK = nrows(M); int @SIZE = ncols(M);
127
128  int @IS_A_SB = attrib(M, "isSB"); // ??? only if all weights were zero?!
129
130  if( !@IS_A_SB )
131  {
132    M = std(M); // this should be faster than computing std in S (later on)
133  }
134
135  def S =   Syzextra::MakeInducedSchreyerOrdering(1); // 1 puts history terms to the back
136  // TODO: NOTE: +1 causes trouble to Singular interpreter!!!???
137  setring S; // a new ring with a Schreyer ordering
138
139  // Setup the leading syzygy^{-1} module to zero:
140  module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0));
141
142  module MRES = Z;
143
144  list RES; RES[1] = Z;
145
146  module F = freemodule(@RANK);
147  intvec @V = deg(F[1..@RANK]);
148
149  module M = imap(@save, M);
150
151  attrib(M, "isHomog", @V);
152  attrib(M, "isSB", 1);
153
154  RES[size(RES)+1] = M; // list of all syzygy modules
155  MRES = MRES, M;
156
157  attrib(MRES, "isHomog", @V);
158
159  attrib(S, "InducionLeads", lead(M));
160  attrib(S, "InducionStart", @RANK);
161
162  export RES;
163  export MRES;
164  return (S);
165}
166
167static proc Sstep()
168{
169  int @DEBUG = 0; // !system("with", "ndebug");
170
171  // syzygy step:
172
173/*
174  // is initial weights are all zeroes!
175  def L =  lead(M);
176  intvec @V = deg(M[1..ncols(M)]);  @W;  @V;  @W = @V;  attrib(L, "isHomog", @W);
177    Syzextra::SetInducedReferrence(L, @RANK, 0);
178*/
179
180//  def L =  lead(MRES);
181//  @W = @W, @V;
182//  attrib(L, "isHomog", @W);
183
184
185  // General setting:
186//    Syzextra::SetInducedReferrence(MRES, 0, 0); // limit: 0!
187  int @l = size(RES);
188
189  module M = RES[@l];
190
191  module L = attrib(basering, "InducionLeads");
192  int limit = attrib(basering, "InducionStart");
193
194//  L;  limit;
195
196  int @RANK = ncols(MRES) - ncols(M); // nrows(M); // what if M is zero?!
197
198/*
199  if( @RANK !=  nrows(M) )
200  {
201    type(MRES);
202    @RANK;
203    type(M);
204    pause();
205  }
206*/
207
208  intvec @W = attrib(M, "isHomog");
209  intvec @V = deg(M[1..ncols(M)]);
210  @V = @W, @V;
211
212  Syzextra::SetInducedReferrence(L, limit, 0);
213
214  def K = prepareSyz(M, @RANK);
215//  K;
216
217//  pause();
218
219  K =   Syzextra::idPrepare(K, @RANK); // std(K); // ?
220  K = simplify(K, 2);
221
222//  K;
223
224  module N = separateSyzGB(K, @RANK)[2]; // 1^st syz. module: vectors which start in lower part (comp >= @RANK)
225
226//  basering; print(@V); type(N);
227//  attrib(N, "isHomog", @V);  // TODO: fix "wrong weights"!!!? deg is wrong :(((
228  N = std(N);
229  attrib(N, "isHomog", @V);
230
231  RES[@l + 1] = N; // list of all syzygy modules
232
233  MRES = MRES, N;
234  attrib(MRES, "isHomog", @V);
235
236
237  L = L, lead(N);
238  attrib(basering, "InducionLeads", L);
239
240}
241
242proc Scontinue(int l)
243"USAGE:  Scontinue(int len)
244RETURN:  nothing, instead it changes the currently active resolution
245PURPOSE: extends the currently active resolution by at most len syzygies
246ASSUME:  must be used within a ring returned by Sres or Ssyz
247EXAMPLE: example Scontinue; shows an example
248"
249{
250  def data =   Syzextra::GetInducedData();
251
252  if( (!defined(RES)) || (!defined(MRES)) || (typeof(data) != "list") || (size(data) != 2) )
253  {
254    ERROR("Sorry, but basering does not seem to be returned by Sres or Ssyz");
255  }
256  for (;  (l != 0) && (size(RES[size(RES)]) > 0); l-- )
257  {
258    Sstep();
259  }
260}
261example
262{ "EXAMPLE:"; echo = 2;
263  ring r;
264  module M = maxideal(1); M;
265  def S = Ssyz(M); setring S; S;
266  "Only the first syzygy: ";
267  RES; MRES;
268  "More syzygies: ";
269  Scontinue(10);
270  RES; MRES;
271}
272
273proc Sres(module M, int l)
274"USAGE:  Sres(module M, int len)
275RETURN:  ring, containing a Schreyer resolution
276PURPOSE: computes a Schreyer resolution of M of length at most len (see the library overview)
277NOTE:    If given len is zero then nvars(basering) + 1 is used instead.
278SEE ALSO: Ssyz
279EXAMPLE: example Sres; shows an example
280"
281{
282  def S = Sinit(M); setring S;
283
284  if (l == 0)
285  {
286    l = nvars(basering) + 1; // not really an estimate...?!
287  }
288
289  Sstep(); l = l - 1;
290
291  Scontinue(l);
292
293  return (S);
294}
295example
296{ "EXAMPLE:"; echo = 2;
297  ring r;
298  module M = maxideal(1); M;
299  def S = Sres(M, 0); setring S; S;
300  RES;
301  MRES;
302  kill S;
303  setring r; kill M;
304
305  def A = nc_algebra(-1,0); setring A;
306  ideal Q = var(1)^2, var(2)^2, var(3)^2;
307  qring SCA = twostd(Q);
308  basering;
309
310  module M = maxideal(1);
311  def S = Sres(M, 2); setring S; S;
312  RES;
313  MRES;
314}
315
316// ================================================================== //
317
318static proc mod_init()
319{
320  load("syzextra.so");
321}
Note: See TracBrowser for help on using the repository browser.