1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | version="version schreyer.lib 4.1.1.1 Feb_2018 "; // $Id$ |
---|
3 | category="General purpose"; |
---|
4 | info=" |
---|
5 | LIBRARY: schreyer.lib helpers for derham.lib |
---|
6 | AUTHOR: Oleksandr Motsak <U@D>, where U={motsak}, D={mathematik.uni-kl.de} |
---|
7 | KEYWORDS: Schreyer ordering; Schreyer resolution; syzygy |
---|
8 | OVERVIEW: |
---|
9 | The library contains several procedures for computing a/part of Schreyer |
---|
10 | resoltion (cf. [SFO]), and some helpers for derham.lib (which requires |
---|
11 | resolutions over the homogenized Weyl algebra) for that purpose. |
---|
12 | The input for any resolution computation is a set of vectors M in form of a |
---|
13 | module over some basering R. The helpers works both in the commutative and |
---|
14 | non-commutative setting (cf. [MO]), that is the ring R may be non-commutative, |
---|
15 | in which case the ring ordering over it must be global. They produce/work with |
---|
16 | partial Schreyer resolutions of (R^rank(M))/M in form of a specially constructed |
---|
17 | ring (endowed with a special ring ordering that will be extended in the course |
---|
18 | of a resolution computation) containing the following objects: |
---|
19 | @* RES: the list of modules contains the images of maps (also called syzygy |
---|
20 | modules) substituting the computed beginning of a Schreyer resolution, that is, |
---|
21 | each syzygy module is given by a Groebner basis with respect to the |
---|
22 | corresponding Schreyer ordering. RES starts with a zero map given by rank(M) |
---|
23 | zero generators indicating that the image of the first differential map is |
---|
24 | zero. The second map RES[2] is given by M, which indicates that the resolution |
---|
25 | of (R^rank(M))/M is being computed. |
---|
26 | @* MRES: the module is a direct sum of modules from RES and thus comprises all |
---|
27 | computed differentials. Syzygies are shifted so that gen(i) is mapped to MRES[i] |
---|
28 | under the differential map. |
---|
29 | @* Here, we call a free resolution a Schreyer resolution if each syzygy |
---|
30 | module is given by a Groebner basis with respect to the corresponding Schreyer |
---|
31 | ordering. A Schreyer resolution can be much bigger than a minimal resolution of |
---|
32 | the same module, but may be easier to construct. The Schreyer ordering |
---|
33 | succesively extends the starting module ordering on M (defined in Singular by |
---|
34 | the basering R) and is extended to higher syzygies using the following |
---|
35 | definition: |
---|
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 |
---|
38 | comp(a) is the module component, for any module terms a and b from the same |
---|
39 | higher syzygy module. |
---|
40 | |
---|
41 | NOTE: Since most comutations require the module syzextra.so, please be make sure |
---|
42 | to build it into Singular on Windows. |
---|
43 | |
---|
44 | REFERENCES: |
---|
45 | @* |
---|
46 | [BMSS] Burcin, E., Motsak, O., Schreyer, F.-O., Steenpass, A.: |
---|
47 | Refined algorithms to compute syzygies, 2015 (to appear). |
---|
48 | @* |
---|
49 | [SFO] Schreyer, F.O.: Die Berechnung von Syzygien mit dem verallgemeinerten |
---|
50 | Weierstrassschen Divisionssatz, Master's thesis, Univ. Hamburg, 1980. |
---|
51 | @* |
---|
52 | [MO] Motsak, O.: Non-commutative Computer Algebra with applications: |
---|
53 | Graded commutative algebra and related structures in Singular with applications, |
---|
54 | Ph.D. thesis, TU Kaiserslautern, 2010. |
---|
55 | |
---|
56 | PROCEDURES: |
---|
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 | |
---|
61 | SEE ALSO: syz, sres, lres, res, fres |
---|
62 | "; |
---|
63 | |
---|
64 | static 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 | |
---|
96 | static 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 | |
---|
120 | static 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 | |
---|
167 | static 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 | |
---|
242 | proc Scontinue(int l) |
---|
243 | "USAGE: Scontinue(int len) |
---|
244 | RETURN: nothing, instead it changes the currently active resolution |
---|
245 | PURPOSE: extends the currently active resolution by at most len syzygies |
---|
246 | ASSUME: must be used within a ring returned by Sres or Ssyz |
---|
247 | EXAMPLE: 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 | } |
---|
261 | example |
---|
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 | |
---|
273 | proc Sres(module M, int l) |
---|
274 | "USAGE: Sres(module M, int len) |
---|
275 | RETURN: ring, containing a Schreyer resolution |
---|
276 | PURPOSE: computes a Schreyer resolution of M of length at most len (see the library overview) |
---|
277 | NOTE: If given len is zero then nvars(basering) + 1 is used instead. |
---|
278 | SEE ALSO: Ssyz |
---|
279 | EXAMPLE: 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 | } |
---|
295 | example |
---|
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 | |
---|
318 | static proc mod_init() |
---|
319 | { |
---|
320 | load("syzextra.so"); |
---|
321 | } |
---|